Merge "Define menu keys for highlighting the menu entry on 2-pane UI" into sc-v2-dev am: f8bb8aced9 am: 89a745dd8c

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

Change-Id: Ib9173bcda2280a683fda2e163bfc7467923d0bf2
This commit is contained in:
TreeHugger Robot
2021-09-07 08:00:49 +00:00
committed by Automerger Merge Worker
8 changed files with 99 additions and 11 deletions

View File

@@ -73,7 +73,8 @@ public class PreferenceXmlParserUtils {
MetadataFlag.FLAG_NEED_PREF_ICON,
MetadataFlag.FLAG_NEED_SEARCHABLE,
MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE,
MetadataFlag.FLAG_FOR_WORK})
MetadataFlag.FLAG_FOR_WORK,
MetadataFlag.FLAG_NEED_HIGHLIGHTABLE_MENU_KEY})
@Retention(RetentionPolicy.SOURCE)
public @interface MetadataFlag {
@@ -89,6 +90,7 @@ public class PreferenceXmlParserUtils {
int FLAG_NEED_PREF_APPEND = 1 << 10;
int FLAG_UNAVAILABLE_SLICE_SUBTITLE = 1 << 11;
int FLAG_FOR_WORK = 1 << 12;
int FLAG_NEED_HIGHLIGHTABLE_MENU_KEY = 1 << 13;
}
public static final String METADATA_PREF_TYPE = "type";
@@ -102,6 +104,7 @@ public class PreferenceXmlParserUtils {
public static final String METADATA_APPEND = "staticPreferenceLocation";
public static final String METADATA_UNAVAILABLE_SLICE_SUBTITLE = "unavailable_slice_subtitle";
public static final String METADATA_FOR_WORK = "for_work";
public static final String METADATA_HIGHLIGHTABLE_MENU_KEY = "highlightable_menu_key";
private static final String ENTRIES_SEPARATOR = "|";
@@ -250,6 +253,10 @@ public class PreferenceXmlParserUtils {
preferenceMetadata.putBoolean(METADATA_FOR_WORK,
isForWork(preferenceAttributes));
}
if (hasFlag(flags, MetadataFlag.FLAG_NEED_HIGHLIGHTABLE_MENU_KEY)) {
preferenceMetadata.putString(METADATA_HIGHLIGHTABLE_MENU_KEY,
getHighlightableMenuKey(preferenceAttributes));
}
metadata.add(preferenceMetadata);
preferenceAttributes.recycle();
@@ -314,6 +321,10 @@ public class PreferenceXmlParserUtils {
return styledAttributes.getString(R.styleable.Preference_controller);
}
private static String getHighlightableMenuKey(TypedArray styledAttributes) {
return styledAttributes.getString(R.styleable.Preference_highlightableMenuKey);
}
private static int getIcon(TypedArray styledAttributes) {
return styledAttributes.getResourceId(com.android.internal.R.styleable.Icon_icon, 0);
}