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
This commit is contained in:
Ahaan Ugale
2021-06-29 17:16:25 -07:00
parent 22f6857a6a
commit 437c037830
5 changed files with 22 additions and 5 deletions

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -65,11 +65,19 @@ public abstract class DefaultAppPreferenceController extends AbstractPreferenceC
((TwoTargetPreference) preference).setIconSize(ICON_SIZE_MEDIUM);
}
if (!TextUtils.isEmpty(defaultAppLabel)) {
if (showLabelAsTitle()) {
preference.setTitle(defaultAppLabel);
} else {
preference.setSummary(defaultAppLabel);
}
preference.setIcon(Utils.getSafeIcon(getDefaultAppIcon()));
} else {
Log.d(TAG, "No default app");
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 @@ public abstract class DefaultAppPreferenceController extends AbstractPreferenceC
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;

View File

@@ -69,4 +69,9 @@ public class DefaultAutofillPreferenceController extends DefaultAppPreferenceCon
}
return null;
}
@Override
protected boolean showLabelAsTitle() {
return true;
}
}