Show default description only if description and html description are empty
* AccessibilitySettings only get the description to pass to the ToggleFeaturePreferenceFragment * ToggleFeaturePreferenceFragment handle the default description logic Bug: 154092127 Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.accessibility.AccessibilitySettingsTest" Change-Id: I516a393aeef1472ca5d185d477a2b0b108fc5342
This commit is contained in:
@@ -307,11 +307,7 @@ public class AccessibilitySettings extends DashboardFragment {
|
||||
return context.getText(R.string.accessibility_description_state_stopped);
|
||||
}
|
||||
|
||||
final String description = info.loadDescription(context.getPackageManager());
|
||||
|
||||
return TextUtils.isEmpty(description)
|
||||
? context.getText(R.string.accessibility_service_default_description)
|
||||
: description;
|
||||
return info.loadDescription(context.getPackageManager());
|
||||
}
|
||||
|
||||
static boolean isRampingRingerEnabled(final Context context) {
|
||||
@@ -460,7 +456,7 @@ public class AccessibilitySettings extends DashboardFragment {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the order of perferences in the category by matching their preference
|
||||
* Update the order of preferences in the category by matching their preference
|
||||
* key with the string array of preference order which is defined in the xml.
|
||||
*
|
||||
* @param categoryKey The key of the category need to update the order
|
||||
@@ -708,10 +704,9 @@ public class AccessibilitySettings extends DashboardFragment {
|
||||
CharSequence title, CharSequence summary, int imageRes, String htmlDescription,
|
||||
ComponentName componentName) {
|
||||
final Bundle extras = preference.getExtras();
|
||||
|
||||
extras.putString(EXTRA_PREFERENCE_KEY, prefKey);
|
||||
extras.putString(EXTRA_TITLE, title.toString());
|
||||
extras.putString(EXTRA_SUMMARY, summary.toString());
|
||||
extras.putCharSequence(EXTRA_TITLE, title);
|
||||
extras.putCharSequence(EXTRA_SUMMARY, summary);
|
||||
extras.putParcelable(EXTRA_COMPONENT_NAME, componentName);
|
||||
extras.putInt(EXTRA_ANIMATED_IMAGE_RES, imageRes);
|
||||
extras.putString(AccessibilitySettings.EXTRA_HTML_DESCRIPTION, htmlDescription);
|
||||
|
@@ -83,6 +83,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
protected ComponentName mComponentName;
|
||||
protected CharSequence mPackageName;
|
||||
protected Uri mImageUri;
|
||||
private CharSequence mDescription;
|
||||
protected CharSequence mHtmlDescription;
|
||||
// Used to restore the edit dialog status.
|
||||
protected int mUserShortcutTypesCache = UserShortcutType.EMPTY;
|
||||
@@ -190,7 +191,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
groupCategory.addPreference(mSettingsPreference);
|
||||
}
|
||||
|
||||
if (mHtmlDescription != null) {
|
||||
if (!TextUtils.isEmpty(mHtmlDescription)) {
|
||||
final PreferenceCategory introductionCategory = new PreferenceCategory(
|
||||
getPrefContext());
|
||||
final CharSequence title = getString(R.string.accessibility_introduction_title,
|
||||
@@ -205,6 +206,16 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
htmlTextPreference.setSelectable(false);
|
||||
introductionCategory.addPreference(htmlTextPreference);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mDescription)) {
|
||||
createFooterPreference(mDescription);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(mHtmlDescription) && TextUtils.isEmpty(mDescription)) {
|
||||
final CharSequence defaultDescription = getText(
|
||||
R.string.accessibility_service_default_description);
|
||||
createFooterPreference(defaultDescription);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -364,9 +375,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
|
||||
// Summary.
|
||||
if (arguments.containsKey(AccessibilitySettings.EXTRA_SUMMARY)) {
|
||||
final CharSequence summary = arguments.getCharSequence(
|
||||
AccessibilitySettings.EXTRA_SUMMARY);
|
||||
createFooterPreference(summary);
|
||||
mDescription = arguments.getCharSequence(AccessibilitySettings.EXTRA_SUMMARY);
|
||||
}
|
||||
|
||||
// Settings html description.
|
||||
|
@@ -214,17 +214,6 @@ public class AccessibilitySettingsTest {
|
||||
assertThat(description).isEqualTo(DEFAULT_DESCRIPTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getServiceDescription_noDescription_showsDefaultString() {
|
||||
doReturn(EMPTY_STRING).when(mServiceInfo).loadDescription(any());
|
||||
|
||||
final CharSequence description = AccessibilitySettings.getServiceDescription(mContext,
|
||||
mServiceInfo, SERVICE_ENABLED);
|
||||
|
||||
assertThat(description).isEqualTo(
|
||||
mContext.getString(R.string.accessibility_service_default_description));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAccessibilityServicePreferenceList_hasOneInfo_containsSameKey() {
|
||||
final String key = DUMMY_COMPONENT_NAME.flattenToString();
|
||||
|
Reference in New Issue
Block a user