Password settings: Fix duplicate title
For the autofill service settings, "Autofill service" is both the
section title and the preference title. This change removes the
duplicate preference title and promotes the app label from the summary
string to the title in its place.
Fix: 192403526
Test: manual - single profile, personal+work profile, change service and
re-check
Change-Id: Ia012232ba2856e0757289982bc3045d948ff4aa8
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index c8627e7..71bfc18 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -37,7 +37,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
- android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
index e0ba71b..b01c235 100644
--- a/res/xml/accounts_personal_dashboard_settings.xml
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main"
- android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
<extra
android:name="for_work"
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
index 1c4c6aa..c24ea6f 100644
--- a/res/xml/accounts_work_dashboard_settings.xml
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_work"
- android:title="@string/autofill_app"
settings:searchable="false">
<extra
android:name="for_work"
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
index fd6f4c2..d962692 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceController.java
@@ -65,11 +65,19 @@
((TwoTargetPreference) preference).setIconSize(ICON_SIZE_MEDIUM);
}
if (!TextUtils.isEmpty(defaultAppLabel)) {
- preference.setSummary(defaultAppLabel);
+ if (showLabelAsTitle()) {
+ preference.setTitle(defaultAppLabel);
+ } else {
+ preference.setSummary(defaultAppLabel);
+ }
preference.setIcon(Utils.getSafeIcon(getDefaultAppIcon()));
} else {
Log.d(TAG, "No default app");
- preference.setSummary(R.string.app_list_preference_none);
+ if (showLabelAsTitle()) {
+ preference.setTitle(R.string.app_list_preference_none);
+ } else {
+ preference.setSummary(R.string.app_list_preference_none);
+ }
preference.setIcon(null);
}
mayUpdateGearIcon(app, preference);
@@ -102,6 +110,13 @@
return null;
}
+ /**
+ * Whether to show the default app label as the title, instead of as the summary.
+ */
+ protected boolean showLabelAsTitle() {
+ return false;
+ }
+
public Drawable getDefaultAppIcon() {
if (!isAvailable()) {
return null;
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
index d32322b..1493e30 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAutofillPreferenceController.java
@@ -69,4 +69,9 @@
}
return null;
}
+
+ @Override
+ protected boolean showLabelAsTitle() {
+ return true;
+ }
}