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:
Jason Chiu
2021-10-31 23:40:26 +08:00
parent e1ec69fa1a
commit 594eb43159
20 changed files with 161 additions and 45 deletions

View File

@@ -43,17 +43,18 @@ import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class SlicesIndexerTest {
private final String[] KEYS = new String[]{"key1", "key2", "key3"};
private final String[] TITLES = new String[]{"title1", "title2", "title3"};
private final String SUMMARY = "subtitle";
private final String SCREEN_TITLE = "screen title";
private final String KEYWORDS = "a, b, c";
private final String FRAGMENT_NAME = "fragment name";
private final int ICON = 1234; // I declare a thumb war
private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private final String PREF_CONTROLLER = "com.android.settings.slices.tester";
private final int SLICE_TYPE = SliceData.SliceType.SLIDER;
private final String UNAVAILABLE_SLICE_SUBTITLE = "subtitleOfUnavailableSlice";
private static final String[] KEYS = new String[]{"key1", "key2", "key3"};
private static final String[] TITLES = new String[]{"title1", "title2", "title3"};
private static final String SUMMARY = "subtitle";
private static final String SCREEN_TITLE = "screen title";
private static final String KEYWORDS = "a, b, c";
private static final String FRAGMENT_NAME = "fragment name";
private static final int ICON = 1234; // I declare a thumb war
private static final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private static final String PREF_CONTROLLER = "com.android.settings.slices.tester";
private static final int SLICE_TYPE = SliceData.SliceType.SLIDER;
private static final String UNAVAILABLE_SLICE_SUBTITLE = "subtitleOfUnavailableSlice";
private static final int HIGHLIGHT_MENU_KEY = 5678; // I declare a thumb war
private Context mContext;
@@ -142,6 +143,9 @@ public class SlicesIndexerTest {
.isEqualTo(UNAVAILABLE_SLICE_SUBTITLE);
assertThat(cursor.getInt(
cursor.getColumnIndex(IndexColumns.PUBLIC_SLICE))).isEqualTo(0);
assertThat(cursor.getInt(
cursor.getColumnIndex(IndexColumns.HIGHLIGHT_MENU_RESOURCE)))
.isEqualTo(HIGHLIGHT_MENU_KEY);
cursor.moveToNext();
}
} finally {
@@ -187,6 +191,9 @@ public class SlicesIndexerTest {
.isEqualTo(UNAVAILABLE_SLICE_SUBTITLE);
assertThat(cursor.getInt(
cursor.getColumnIndex(IndexColumns.PUBLIC_SLICE))).isEqualTo(1);
assertThat(cursor.getInt(
cursor.getColumnIndex(IndexColumns.HIGHLIGHT_MENU_RESOURCE)))
.isEqualTo(HIGHLIGHT_MENU_KEY);
cursor.moveToNext();
}
} finally {
@@ -220,7 +227,8 @@ public class SlicesIndexerTest {
.setUri(URI)
.setPreferenceControllerClassName(PREF_CONTROLLER)
.setSliceType(SLICE_TYPE)
.setUnavailableSliceSubtitle(UNAVAILABLE_SLICE_SUBTITLE);
.setUnavailableSliceSubtitle(UNAVAILABLE_SLICE_SUBTITLE)
.setHighlightMenuRes(HIGHLIGHT_MENU_KEY);
if (isPublicSlice) {
builder.setIsPublicSlice(true);