Support slice deep links highlighting menu entries
- Add an interface to get highlight menu key resource in Sliceable - Force implementing the new interface in TogglePreferenceController and CustomSliceable at syntax level - Update the slice index db schema Bug: 204695404 Test: manual, robotest build pass, unit Change-Id: I0b5068bccd04f1590023de7f3385bc0a4c6fa47b
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.slices;
|
||||
|
||||
import static android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY;
|
||||
|
||||
import static com.android.settings.SettingsActivity.EXTRA_IS_FROM_SLICE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||
import static com.android.settings.slices.SettingsSliceProvider.EXTRA_SLICE_KEY;
|
||||
@@ -203,8 +205,15 @@ public class SliceBuilderUtils {
|
||||
}
|
||||
|
||||
public static Intent buildSearchResultPageIntent(Context context, String className, String key,
|
||||
String screenTitle, int sourceMetricsCategory) {
|
||||
String screenTitle, int sourceMetricsCategory, int highlightMenuRes) {
|
||||
final Bundle args = new Bundle();
|
||||
String highlightMenuKey = null;
|
||||
if (highlightMenuRes != 0) {
|
||||
highlightMenuKey = context.getString(highlightMenuRes);
|
||||
if (TextUtils.isEmpty(highlightMenuKey)) {
|
||||
Log.w(TAG, "Invalid menu key res from: " + screenTitle);
|
||||
}
|
||||
}
|
||||
args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
|
||||
final Intent searchDestination = new SubSettingLauncher(context)
|
||||
.setDestination(className)
|
||||
@@ -215,6 +224,7 @@ public class SliceBuilderUtils {
|
||||
searchDestination
|
||||
.putExtra(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key)
|
||||
.putExtra(EXTRA_IS_FROM_SLICE, true)
|
||||
.putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY, highlightMenuKey)
|
||||
.setAction("com.android.settings.SEARCH_RESULT_TRAMPOLINE")
|
||||
.setComponent(null);
|
||||
searchDestination.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -222,13 +232,22 @@ public class SliceBuilderUtils {
|
||||
return searchDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a search result page intent for {@link CustomSliceable}
|
||||
*/
|
||||
public static Intent buildSearchResultPageIntent(Context context, String className, String key,
|
||||
String screenTitle, int sourceMetricsCategory, CustomSliceable sliceable) {
|
||||
return buildSearchResultPageIntent(context, className, key, screenTitle,
|
||||
sourceMetricsCategory, sliceable.getSliceHighlightMenuRes());
|
||||
}
|
||||
|
||||
public static Intent getContentIntent(Context context, SliceData sliceData) {
|
||||
final Uri contentUri = new Uri.Builder().appendPath(sliceData.getKey()).build();
|
||||
final String screenTitle = TextUtils.isEmpty(sliceData.getScreenTitle()) ? null
|
||||
: sliceData.getScreenTitle().toString();
|
||||
final Intent intent = buildSearchResultPageIntent(context,
|
||||
sliceData.getFragmentClassName(), sliceData.getKey(),
|
||||
screenTitle, 0 /* TODO */);
|
||||
screenTitle, 0 /* TODO */, sliceData.getHighlightMenuRes());
|
||||
intent.setClassName(context.getPackageName(), SubSettings.class.getName());
|
||||
intent.setData(contentUri);
|
||||
return intent;
|
||||
|
Reference in New Issue
Block a user