Loading AndroidManifest.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -3229,7 +3229,7 @@ </activity> </activity> <provider android:name=".slices.SettingsSliceProvider" <provider android:name=".slices.SettingsSliceProvider" android:authorities="com.android.settings.slices" android:authorities="com.android.settings.slices;android.settings.slices" android:exported="true"> android:exported="true"> </provider> </provider> Loading res/values/attrs.xml +4 −0 Original line number Original line Diff line number Diff line Loading @@ -96,8 +96,12 @@ <!-- For Search --> <!-- For Search --> <declare-styleable name="Preference"> <declare-styleable name="Preference"> <!-- Synonyms for search results --> <attr name="keywords" format="string" /> <attr name="keywords" format="string" /> <!-- Classname of a PreferenceController corresponding to the preference --> <attr name="controller" format="string" /> <attr name="controller" format="string" /> <!-- {@code true} when the controller declared represents a slice from {@link android.app.SettingsSliceContract} --> <attr name="platform_slice" format="boolean" /> </declare-styleable> </declare-styleable> <!-- For DotsPageIndicator --> <!-- For DotsPageIndicator --> Loading res/xml/connected_devices_advanced.xml +2 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ android:icon="@drawable/ic_settings_bluetooth" android:icon="@drawable/ic_settings_bluetooth" android:summary="@string/bluetooth_pref_summary" android:summary="@string/bluetooth_pref_summary" android:order="-7" android:order="-7" settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController"/> settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController" settings:platform_slice="true"/> <SwitchPreference <SwitchPreference android:key="toggle_nfc" android:key="toggle_nfc" Loading src/com/android/settings/core/PreferenceXmlParserUtils.java +76 −14 Original line number Original line Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class PreferenceXmlParserUtils { int FLAG_NEED_PREF_TITLE = 1 << 4; int FLAG_NEED_PREF_TITLE = 1 << 4; int FLAG_NEED_PREF_SUMMARY = 1 << 5; int FLAG_NEED_PREF_SUMMARY = 1 << 5; int FLAG_NEED_PREF_ICON = 1 << 6; int FLAG_NEED_PREF_ICON = 1 << 6; int FLAG_NEED_PLATFORM_SLICE_FLAG = 1 << 7; } } public static final String METADATA_PREF_TYPE = "type"; public static final String METADATA_PREF_TYPE = "type"; Loading @@ -84,35 +85,48 @@ public class PreferenceXmlParserUtils { public static final String METADATA_TITLE = "title"; public static final String METADATA_TITLE = "title"; public static final String METADATA_SUMMARY = "summary"; public static final String METADATA_SUMMARY = "summary"; public static final String METADATA_ICON = "icon"; public static final String METADATA_ICON = "icon"; public static final String METADATA_PLATFORM_SLICE_FLAG = "platform_slice"; private static final String ENTRIES_SEPARATOR = "|"; private static final String ENTRIES_SEPARATOR = "|"; /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_KEY} instead. */ @Deprecated public static String getDataKey(Context context, AttributeSet attrs) { public static String getDataKey(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference_key); com.android.internal.R.styleable.Preference_key); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_TITLE} instead. */ @Deprecated public static String getDataTitle(Context context, AttributeSet attrs) { public static String getDataTitle(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference_title); com.android.internal.R.styleable.Preference_title); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_SUMMARY} instead. */ @Deprecated public static String getDataSummary(Context context, AttributeSet attrs) { public static String getDataSummary(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference_summary); com.android.internal.R.styleable.Preference_summary); } } public static String getDataSummaryOn(Context context, AttributeSet attrs) { public static String getDataSummaryOn(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference_summaryOn); com.android.internal.R.styleable.CheckBoxPreference_summaryOn); } } public static String getDataSummaryOff(Context context, AttributeSet attrs) { public static String getDataSummaryOff(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference_summaryOff); com.android.internal.R.styleable.CheckBoxPreference_summaryOff); } } Loading @@ -124,13 +138,23 @@ public class PreferenceXmlParserUtils { } } public static String getDataKeywords(Context context, AttributeSet attrs) { public static String getDataKeywords(Context context, AttributeSet attrs) { return getData(context, attrs, R.styleable.Preference, R.styleable.Preference_keywords); return getStringData(context, attrs, R.styleable.Preference, R.styleable.Preference_keywords); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_CONTROLLER} instead. */ @Deprecated public static String getController(Context context, AttributeSet attrs) { public static String getController(Context context, AttributeSet attrs) { return getData(context, attrs, R.styleable.Preference, R.styleable.Preference_controller); return getStringData(context, attrs, R.styleable.Preference, R.styleable.Preference_controller); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_ICON} instead. */ @Deprecated public static int getDataIcon(Context context, AttributeSet attrs) { public static int getDataIcon(Context context, AttributeSet attrs) { final TypedArray ta = context.obtainStyledAttributes(attrs, final TypedArray ta = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Preference); com.android.internal.R.styleable.Preference); Loading Loading @@ -176,25 +200,35 @@ public class PreferenceXmlParserUtils { } } final Bundle preferenceMetadata = new Bundle(); final Bundle preferenceMetadata = new Bundle(); final AttributeSet attrs = Xml.asAttributeSet(parser); final AttributeSet attrs = Xml.asAttributeSet(parser); final TypedArray preferenceAttributes = context.obtainStyledAttributes(attrs, R.styleable.Preference); if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TYPE)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TYPE)) { preferenceMetadata.putString(METADATA_PREF_TYPE, nodeName); preferenceMetadata.putString(METADATA_PREF_TYPE, nodeName); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_KEY)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_KEY)) { preferenceMetadata.putString(METADATA_KEY, getDataKey(context, attrs)); preferenceMetadata.putString(METADATA_KEY, getKey(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_CONTROLLER)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_CONTROLLER)) { preferenceMetadata.putString(METADATA_CONTROLLER, getController(context, attrs)); preferenceMetadata.putString(METADATA_CONTROLLER, getController(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TITLE)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TITLE)) { preferenceMetadata.putString(METADATA_TITLE, getDataTitle(context, attrs)); preferenceMetadata.putString(METADATA_TITLE, getTitle(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_SUMMARY)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_SUMMARY)) { preferenceMetadata.putString(METADATA_SUMMARY, getDataSummary(context, attrs)); preferenceMetadata.putString(METADATA_SUMMARY, getSummary(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_ICON)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_ICON)) { preferenceMetadata.putInt(METADATA_ICON, getDataIcon(context, attrs)); preferenceMetadata.putInt(METADATA_ICON, getIcon(preferenceAttributes)); } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PLATFORM_SLICE_FLAG)) { preferenceMetadata.putBoolean(METADATA_PLATFORM_SLICE_FLAG, getPlatformSlice(preferenceAttributes)); } } metadata.add(preferenceMetadata); metadata.add(preferenceMetadata); preferenceAttributes.recycle(); } while ((type = parser.next()) != XmlPullParser.END_DOCUMENT } while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)); && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)); parser.close(); parser.close(); Loading @@ -205,12 +239,16 @@ public class PreferenceXmlParserUtils { * Returns the fragment name if this preference launches a child fragment. * Returns the fragment name if this preference launches a child fragment. */ */ public static String getDataChildFragment(Context context, AttributeSet attrs) { public static String getDataChildFragment(Context context, AttributeSet attrs) { return getData(context, attrs, R.styleable.Preference, return getStringData(context, attrs, R.styleable.Preference, R.styleable.Preference_android_fragment); R.styleable.Preference_android_fragment); } } /** * Call {@link #extractMetadata(Context, int, int)} with a {@link MetadataFlag} instead. */ @Deprecated @Nullable @Nullable private static String getData(Context context, AttributeSet set, int[] attrs, int resId) { private static String getStringData(Context context, AttributeSet set, int[] attrs, int resId) { final TypedArray ta = context.obtainStyledAttributes(set, attrs); final TypedArray ta = context.obtainStyledAttributes(set, attrs); String data = ta.getString(resId); String data = ta.getString(resId); ta.recycle(); ta.recycle(); Loading Loading @@ -243,4 +281,28 @@ public class PreferenceXmlParserUtils { } } return result.toString(); return result.toString(); } } private static String getKey(TypedArray styledAttributes) { return styledAttributes.getString(com.android.internal.R.styleable.Preference_key); } private static String getTitle(TypedArray styledAttributes) { return styledAttributes.getString(com.android.internal.R.styleable.Preference_title); } private static String getSummary(TypedArray styledAttributes) { return styledAttributes.getString(com.android.internal.R.styleable.Preference_summary); } private static String getController(TypedArray styledAttributes) { return styledAttributes.getString(R.styleable.Preference_controller); } private static int getIcon(TypedArray styledAttributes) { return styledAttributes.getResourceId(com.android.internal.R.styleable.Icon_icon, 0); } private static boolean getPlatformSlice(TypedArray styledAttributes) { return styledAttributes.getBoolean(R.styleable.Preference_platform_slice, false /* def */); } } } src/com/android/settings/slices/SettingsSliceProvider.java +7 −8 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Intent; import android.graphics.drawable.Icon; import android.graphics.drawable.Icon; import android.net.Uri; import android.net.Uri; import android.net.wifi.WifiManager; import android.net.wifi.WifiManager; import android.provider.SettingsSlicesContract; import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting; import android.util.Log; import android.util.Log; Loading Loading @@ -63,6 +64,10 @@ public class SettingsSliceProvider extends SliceProvider { private static final String TAG = "SettingsSliceProvider"; private static final String TAG = "SettingsSliceProvider"; /** * Authority for Settings slices not officially supported by the platform, but extensible for * OEMs. */ public static final String SLICE_AUTHORITY = "com.android.settings.slices"; public static final String SLICE_AUTHORITY = "com.android.settings.slices"; public static final String PATH_WIFI = "wifi"; public static final String PATH_WIFI = "wifi"; Loading @@ -82,13 +87,6 @@ public class SettingsSliceProvider extends SliceProvider { @VisibleForTesting @VisibleForTesting Map<Uri, SliceData> mSliceDataCache; Map<Uri, SliceData> mSliceDataCache; public static Uri getUri(String path) { return new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(SLICE_AUTHORITY) .appendPath(path).build(); } @Override @Override public boolean onCreateSliceProvider() { public boolean onCreateSliceProvider() { mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(getContext()); mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(getContext()); Loading Loading @@ -176,7 +174,8 @@ public class SettingsSliceProvider extends SliceProvider { .setSubtitle(state) .setSubtitle(state) .addEndItem(new SliceAction(getBroadcastIntent(ACTION_WIFI_CHANGED), .addEndItem(new SliceAction(getBroadcastIntent(ACTION_WIFI_CHANGED), null, finalWifiEnabled)) null, finalWifiEnabled)) .setPrimaryAction(new SliceAction(getIntent(Intent.ACTION_MAIN), null, null))) .setPrimaryAction( new SliceAction(getIntent(Intent.ACTION_MAIN), null, null))) .build(); .build(); } } Loading Loading
AndroidManifest.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -3229,7 +3229,7 @@ </activity> </activity> <provider android:name=".slices.SettingsSliceProvider" <provider android:name=".slices.SettingsSliceProvider" android:authorities="com.android.settings.slices" android:authorities="com.android.settings.slices;android.settings.slices" android:exported="true"> android:exported="true"> </provider> </provider> Loading
res/values/attrs.xml +4 −0 Original line number Original line Diff line number Diff line Loading @@ -96,8 +96,12 @@ <!-- For Search --> <!-- For Search --> <declare-styleable name="Preference"> <declare-styleable name="Preference"> <!-- Synonyms for search results --> <attr name="keywords" format="string" /> <attr name="keywords" format="string" /> <!-- Classname of a PreferenceController corresponding to the preference --> <attr name="controller" format="string" /> <attr name="controller" format="string" /> <!-- {@code true} when the controller declared represents a slice from {@link android.app.SettingsSliceContract} --> <attr name="platform_slice" format="boolean" /> </declare-styleable> </declare-styleable> <!-- For DotsPageIndicator --> <!-- For DotsPageIndicator --> Loading
res/xml/connected_devices_advanced.xml +2 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ android:icon="@drawable/ic_settings_bluetooth" android:icon="@drawable/ic_settings_bluetooth" android:summary="@string/bluetooth_pref_summary" android:summary="@string/bluetooth_pref_summary" android:order="-7" android:order="-7" settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController"/> settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController" settings:platform_slice="true"/> <SwitchPreference <SwitchPreference android:key="toggle_nfc" android:key="toggle_nfc" Loading
src/com/android/settings/core/PreferenceXmlParserUtils.java +76 −14 Original line number Original line Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class PreferenceXmlParserUtils { int FLAG_NEED_PREF_TITLE = 1 << 4; int FLAG_NEED_PREF_TITLE = 1 << 4; int FLAG_NEED_PREF_SUMMARY = 1 << 5; int FLAG_NEED_PREF_SUMMARY = 1 << 5; int FLAG_NEED_PREF_ICON = 1 << 6; int FLAG_NEED_PREF_ICON = 1 << 6; int FLAG_NEED_PLATFORM_SLICE_FLAG = 1 << 7; } } public static final String METADATA_PREF_TYPE = "type"; public static final String METADATA_PREF_TYPE = "type"; Loading @@ -84,35 +85,48 @@ public class PreferenceXmlParserUtils { public static final String METADATA_TITLE = "title"; public static final String METADATA_TITLE = "title"; public static final String METADATA_SUMMARY = "summary"; public static final String METADATA_SUMMARY = "summary"; public static final String METADATA_ICON = "icon"; public static final String METADATA_ICON = "icon"; public static final String METADATA_PLATFORM_SLICE_FLAG = "platform_slice"; private static final String ENTRIES_SEPARATOR = "|"; private static final String ENTRIES_SEPARATOR = "|"; /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_KEY} instead. */ @Deprecated public static String getDataKey(Context context, AttributeSet attrs) { public static String getDataKey(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference_key); com.android.internal.R.styleable.Preference_key); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_TITLE} instead. */ @Deprecated public static String getDataTitle(Context context, AttributeSet attrs) { public static String getDataTitle(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference_title); com.android.internal.R.styleable.Preference_title); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_SUMMARY} instead. */ @Deprecated public static String getDataSummary(Context context, AttributeSet attrs) { public static String getDataSummary(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference, com.android.internal.R.styleable.Preference_summary); com.android.internal.R.styleable.Preference_summary); } } public static String getDataSummaryOn(Context context, AttributeSet attrs) { public static String getDataSummaryOn(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference_summaryOn); com.android.internal.R.styleable.CheckBoxPreference_summaryOn); } } public static String getDataSummaryOff(Context context, AttributeSet attrs) { public static String getDataSummaryOff(Context context, AttributeSet attrs) { return getData(context, attrs, return getStringData(context, attrs, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference, com.android.internal.R.styleable.CheckBoxPreference_summaryOff); com.android.internal.R.styleable.CheckBoxPreference_summaryOff); } } Loading @@ -124,13 +138,23 @@ public class PreferenceXmlParserUtils { } } public static String getDataKeywords(Context context, AttributeSet attrs) { public static String getDataKeywords(Context context, AttributeSet attrs) { return getData(context, attrs, R.styleable.Preference, R.styleable.Preference_keywords); return getStringData(context, attrs, R.styleable.Preference, R.styleable.Preference_keywords); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_CONTROLLER} instead. */ @Deprecated public static String getController(Context context, AttributeSet attrs) { public static String getController(Context context, AttributeSet attrs) { return getData(context, attrs, R.styleable.Preference, R.styleable.Preference_controller); return getStringData(context, attrs, R.styleable.Preference, R.styleable.Preference_controller); } } /** * Call {@link #extractMetadata(Context, int, int)} with {@link #METADATA_ICON} instead. */ @Deprecated public static int getDataIcon(Context context, AttributeSet attrs) { public static int getDataIcon(Context context, AttributeSet attrs) { final TypedArray ta = context.obtainStyledAttributes(attrs, final TypedArray ta = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Preference); com.android.internal.R.styleable.Preference); Loading Loading @@ -176,25 +200,35 @@ public class PreferenceXmlParserUtils { } } final Bundle preferenceMetadata = new Bundle(); final Bundle preferenceMetadata = new Bundle(); final AttributeSet attrs = Xml.asAttributeSet(parser); final AttributeSet attrs = Xml.asAttributeSet(parser); final TypedArray preferenceAttributes = context.obtainStyledAttributes(attrs, R.styleable.Preference); if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TYPE)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TYPE)) { preferenceMetadata.putString(METADATA_PREF_TYPE, nodeName); preferenceMetadata.putString(METADATA_PREF_TYPE, nodeName); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_KEY)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_KEY)) { preferenceMetadata.putString(METADATA_KEY, getDataKey(context, attrs)); preferenceMetadata.putString(METADATA_KEY, getKey(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_CONTROLLER)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_CONTROLLER)) { preferenceMetadata.putString(METADATA_CONTROLLER, getController(context, attrs)); preferenceMetadata.putString(METADATA_CONTROLLER, getController(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TITLE)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_TITLE)) { preferenceMetadata.putString(METADATA_TITLE, getDataTitle(context, attrs)); preferenceMetadata.putString(METADATA_TITLE, getTitle(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_SUMMARY)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_SUMMARY)) { preferenceMetadata.putString(METADATA_SUMMARY, getDataSummary(context, attrs)); preferenceMetadata.putString(METADATA_SUMMARY, getSummary(preferenceAttributes)); } } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_ICON)) { if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_ICON)) { preferenceMetadata.putInt(METADATA_ICON, getDataIcon(context, attrs)); preferenceMetadata.putInt(METADATA_ICON, getIcon(preferenceAttributes)); } if (hasFlag(flags, MetadataFlag.FLAG_NEED_PLATFORM_SLICE_FLAG)) { preferenceMetadata.putBoolean(METADATA_PLATFORM_SLICE_FLAG, getPlatformSlice(preferenceAttributes)); } } metadata.add(preferenceMetadata); metadata.add(preferenceMetadata); preferenceAttributes.recycle(); } while ((type = parser.next()) != XmlPullParser.END_DOCUMENT } while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)); && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)); parser.close(); parser.close(); Loading @@ -205,12 +239,16 @@ public class PreferenceXmlParserUtils { * Returns the fragment name if this preference launches a child fragment. * Returns the fragment name if this preference launches a child fragment. */ */ public static String getDataChildFragment(Context context, AttributeSet attrs) { public static String getDataChildFragment(Context context, AttributeSet attrs) { return getData(context, attrs, R.styleable.Preference, return getStringData(context, attrs, R.styleable.Preference, R.styleable.Preference_android_fragment); R.styleable.Preference_android_fragment); } } /** * Call {@link #extractMetadata(Context, int, int)} with a {@link MetadataFlag} instead. */ @Deprecated @Nullable @Nullable private static String getData(Context context, AttributeSet set, int[] attrs, int resId) { private static String getStringData(Context context, AttributeSet set, int[] attrs, int resId) { final TypedArray ta = context.obtainStyledAttributes(set, attrs); final TypedArray ta = context.obtainStyledAttributes(set, attrs); String data = ta.getString(resId); String data = ta.getString(resId); ta.recycle(); ta.recycle(); Loading Loading @@ -243,4 +281,28 @@ public class PreferenceXmlParserUtils { } } return result.toString(); return result.toString(); } } private static String getKey(TypedArray styledAttributes) { return styledAttributes.getString(com.android.internal.R.styleable.Preference_key); } private static String getTitle(TypedArray styledAttributes) { return styledAttributes.getString(com.android.internal.R.styleable.Preference_title); } private static String getSummary(TypedArray styledAttributes) { return styledAttributes.getString(com.android.internal.R.styleable.Preference_summary); } private static String getController(TypedArray styledAttributes) { return styledAttributes.getString(R.styleable.Preference_controller); } private static int getIcon(TypedArray styledAttributes) { return styledAttributes.getResourceId(com.android.internal.R.styleable.Icon_icon, 0); } private static boolean getPlatformSlice(TypedArray styledAttributes) { return styledAttributes.getBoolean(R.styleable.Preference_platform_slice, false /* def */); } } }
src/com/android/settings/slices/SettingsSliceProvider.java +7 −8 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Intent; import android.graphics.drawable.Icon; import android.graphics.drawable.Icon; import android.net.Uri; import android.net.Uri; import android.net.wifi.WifiManager; import android.net.wifi.WifiManager; import android.provider.SettingsSlicesContract; import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting; import android.util.Log; import android.util.Log; Loading Loading @@ -63,6 +64,10 @@ public class SettingsSliceProvider extends SliceProvider { private static final String TAG = "SettingsSliceProvider"; private static final String TAG = "SettingsSliceProvider"; /** * Authority for Settings slices not officially supported by the platform, but extensible for * OEMs. */ public static final String SLICE_AUTHORITY = "com.android.settings.slices"; public static final String SLICE_AUTHORITY = "com.android.settings.slices"; public static final String PATH_WIFI = "wifi"; public static final String PATH_WIFI = "wifi"; Loading @@ -82,13 +87,6 @@ public class SettingsSliceProvider extends SliceProvider { @VisibleForTesting @VisibleForTesting Map<Uri, SliceData> mSliceDataCache; Map<Uri, SliceData> mSliceDataCache; public static Uri getUri(String path) { return new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(SLICE_AUTHORITY) .appendPath(path).build(); } @Override @Override public boolean onCreateSliceProvider() { public boolean onCreateSliceProvider() { mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(getContext()); mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(getContext()); Loading Loading @@ -176,7 +174,8 @@ public class SettingsSliceProvider extends SliceProvider { .setSubtitle(state) .setSubtitle(state) .addEndItem(new SliceAction(getBroadcastIntent(ACTION_WIFI_CHANGED), .addEndItem(new SliceAction(getBroadcastIntent(ACTION_WIFI_CHANGED), null, finalWifiEnabled)) null, finalWifiEnabled)) .setPrimaryAction(new SliceAction(getIntent(Intent.ACTION_MAIN), null, null))) .setPrimaryAction( new SliceAction(getIntent(Intent.ACTION_MAIN), null, null))) .build(); .build(); } } Loading