Merge "Password settings: Fix duplicate title" into sc-dev am: d8cd67b52d

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15147962

Change-Id: I72a317e62bff33ea10ed93950cd927c7b1c9a101
This commit is contained in:
TreeHugger Robot
2021-06-30 06:48:38 +00:00
committed by Automerger Merge Worker
5 changed files with 22 additions and 5 deletions

View File

@@ -37,7 +37,6 @@
<com.android.settings.widget.GearPreference <com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker" android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main" android:key="default_autofill_main"
android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords"> settings:keywords="@string/autofill_keywords">
<extra <extra
android:name="for_work" android:name="for_work"

View File

@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference <com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker" android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_main" android:key="default_autofill_main"
android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords"> settings:keywords="@string/autofill_keywords">
<extra <extra
android:name="for_work" android:name="for_work"

View File

@@ -38,7 +38,6 @@
<com.android.settings.widget.GearPreference <com.android.settings.widget.GearPreference
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker" android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
android:key="default_autofill_work" android:key="default_autofill_work"
android:title="@string/autofill_app"
settings:searchable="false"> settings:searchable="false">
<extra <extra
android:name="for_work" android:name="for_work"

View File

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

View File

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