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

This commit is contained in:
TreeHugger Robot
2021-06-30 06:35:33 +00:00
committed by Android (Google) Code Review
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;
}
}