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:
@@ -89,4 +89,7 @@ public abstract class TogglePreferenceController extends BasePreferenceControlle
|
||||
public boolean isPublicSlice() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract int getSliceHighlightMenuRes();
|
||||
}
|
@@ -103,6 +103,9 @@ public interface CustomSliceable extends Sliceable {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getSliceHighlightMenuRes();
|
||||
|
||||
/**
|
||||
* Build an instance of a {@link CustomSliceable} which has a {@link Context}-only constructor.
|
||||
*/
|
||||
|
@@ -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;
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.slices;
|
||||
import android.annotation.IntDef;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -50,6 +51,8 @@ public class SliceData {
|
||||
int SLIDER = 2;
|
||||
}
|
||||
|
||||
private static final String TAG = "SliceData";
|
||||
|
||||
private final String mKey;
|
||||
|
||||
private final String mTitle;
|
||||
@@ -68,6 +71,8 @@ public class SliceData {
|
||||
|
||||
private final String mPreferenceController;
|
||||
|
||||
private final int mHighlightMenuRes;
|
||||
|
||||
@SliceType
|
||||
private final int mSliceType;
|
||||
|
||||
@@ -119,6 +124,10 @@ public class SliceData {
|
||||
return mUnavailableSliceSubtitle;
|
||||
}
|
||||
|
||||
public int getHighlightMenuRes() {
|
||||
return mHighlightMenuRes;
|
||||
}
|
||||
|
||||
public boolean isPublicSlice() {
|
||||
return mIsPublicSlice;
|
||||
}
|
||||
@@ -136,6 +145,7 @@ public class SliceData {
|
||||
mSliceType = builder.mSliceType;
|
||||
mUnavailableSliceSubtitle = builder.mUnavailableSliceSubtitle;
|
||||
mIsPublicSlice = builder.mIsPublicSlice;
|
||||
mHighlightMenuRes = builder.mHighlightMenuRes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,6 +185,8 @@ public class SliceData {
|
||||
|
||||
private String mUnavailableSliceSubtitle;
|
||||
|
||||
private int mHighlightMenuRes;
|
||||
|
||||
private boolean mIsPublicSlice;
|
||||
|
||||
public Builder setKey(String key) {
|
||||
@@ -233,6 +245,11 @@ public class SliceData {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setHighlightMenuRes(int highlightMenuRes) {
|
||||
mHighlightMenuRes = highlightMenuRes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setIsPublicSlice(boolean isPublicSlice) {
|
||||
mIsPublicSlice = isPublicSlice;
|
||||
return this;
|
||||
@@ -255,6 +272,10 @@ public class SliceData {
|
||||
throw new InvalidSliceDataException("Preference Controller cannot be empty");
|
||||
}
|
||||
|
||||
if (mHighlightMenuRes == 0) {
|
||||
Log.w(TAG, "Highlight menu key res is empty: " + mPrefControllerClassName);
|
||||
}
|
||||
|
||||
return new SliceData(this);
|
||||
}
|
||||
|
||||
|
@@ -213,6 +213,7 @@ class SliceDataConverter {
|
||||
final String unavailableSliceSubtitle = bundle.getString(
|
||||
METADATA_UNAVAILABLE_SLICE_SUBTITLE);
|
||||
final boolean isPublicSlice = controller.isPublicSlice();
|
||||
final int highlightMenuRes = controller.getSliceHighlightMenuRes();
|
||||
|
||||
final SliceData xmlSlice = new SliceData.Builder()
|
||||
.setKey(key)
|
||||
@@ -226,6 +227,7 @@ class SliceDataConverter {
|
||||
.setSliceType(sliceType)
|
||||
.setUnavailableSliceSubtitle(unavailableSliceSubtitle)
|
||||
.setIsPublicSlice(isPublicSlice)
|
||||
.setHighlightMenuRes(highlightMenuRes)
|
||||
.build();
|
||||
|
||||
xmlSliceData.add(xmlSlice);
|
||||
|
@@ -50,6 +50,8 @@ public interface Sliceable {
|
||||
* - Must be understandable as a stand-alone Setting.
|
||||
* <p>
|
||||
* This does not guarantee the setting is available.
|
||||
* <p>
|
||||
* {@link #getSliceHighlightMenuRes} should also be overridden when returning true.
|
||||
*
|
||||
* @return {@code true} if the controller should be used as a Slice.
|
||||
*/
|
||||
@@ -131,4 +133,12 @@ public interface Sliceable {
|
||||
default Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a resource ID that indicates which menu entry should be highlighted in multi-pane
|
||||
* mode.
|
||||
*/
|
||||
default int getSliceHighlightMenuRes() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ public class SlicesDatabaseAccessor {
|
||||
IndexColumns.CONTROLLER,
|
||||
IndexColumns.SLICE_TYPE,
|
||||
IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
|
||||
IndexColumns.HIGHLIGHT_MENU_RESOURCE,
|
||||
};
|
||||
|
||||
private final Context mContext;
|
||||
@@ -163,6 +164,8 @@ public class SlicesDatabaseAccessor {
|
||||
cursor.getColumnIndex(IndexColumns.SLICE_TYPE));
|
||||
final String unavailableSliceSubtitle = cursor.getString(
|
||||
cursor.getColumnIndex(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE));
|
||||
final int highlightMenuRes = cursor.getInt(
|
||||
cursor.getColumnIndex(IndexColumns.HIGHLIGHT_MENU_RESOURCE));
|
||||
|
||||
if (isIntentOnly) {
|
||||
sliceType = SliceData.SliceType.INTENT;
|
||||
@@ -180,6 +183,7 @@ public class SlicesDatabaseAccessor {
|
||||
.setUri(uri)
|
||||
.setSliceType(sliceType)
|
||||
.setUnavailableSliceSubtitle(unavailableSliceSubtitle)
|
||||
.setHighlightMenuRes(highlightMenuRes)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
|
||||
private static final String DATABASE_NAME = "slices_index.db";
|
||||
private static final String SHARED_PREFS_TAG = "slices_shared_prefs";
|
||||
|
||||
private static final int DATABASE_VERSION = 8;
|
||||
private static final int DATABASE_VERSION = 9;
|
||||
|
||||
public interface Tables {
|
||||
String TABLE_SLICES_INDEX = "slices_index";
|
||||
@@ -103,39 +103,43 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
|
||||
* Whether the slice should be exposed publicly.
|
||||
*/
|
||||
String PUBLIC_SLICE = "public_slice";
|
||||
|
||||
/**
|
||||
* Resource ID for the menu entry of the setting.
|
||||
*/
|
||||
String HIGHLIGHT_MENU_RESOURCE = "highlight_menu";
|
||||
}
|
||||
|
||||
private static final String CREATE_SLICES_TABLE =
|
||||
"CREATE VIRTUAL TABLE " + Tables.TABLE_SLICES_INDEX + " USING fts4" +
|
||||
"(" +
|
||||
IndexColumns.KEY +
|
||||
", " +
|
||||
IndexColumns.SLICE_URI +
|
||||
", " +
|
||||
IndexColumns.TITLE +
|
||||
", " +
|
||||
IndexColumns.SUMMARY +
|
||||
", " +
|
||||
IndexColumns.SCREENTITLE +
|
||||
", " +
|
||||
IndexColumns.KEYWORDS +
|
||||
", " +
|
||||
IndexColumns.ICON_RESOURCE +
|
||||
", " +
|
||||
IndexColumns.FRAGMENT +
|
||||
", " +
|
||||
IndexColumns.CONTROLLER +
|
||||
", " +
|
||||
IndexColumns.SLICE_TYPE +
|
||||
", " +
|
||||
IndexColumns.UNAVAILABLE_SLICE_SUBTITLE +
|
||||
", "
|
||||
+
|
||||
IndexColumns.PUBLIC_SLICE
|
||||
+
|
||||
" INTEGER DEFAULT 0 "
|
||||
+
|
||||
");";
|
||||
"CREATE VIRTUAL TABLE " + Tables.TABLE_SLICES_INDEX + " USING fts4"
|
||||
+ "("
|
||||
+ IndexColumns.KEY
|
||||
+ ", "
|
||||
+ IndexColumns.SLICE_URI
|
||||
+ ", "
|
||||
+ IndexColumns.TITLE
|
||||
+ ", "
|
||||
+ IndexColumns.SUMMARY
|
||||
+ ", "
|
||||
+ IndexColumns.SCREENTITLE
|
||||
+ ", "
|
||||
+ IndexColumns.KEYWORDS
|
||||
+ ", "
|
||||
+ IndexColumns.ICON_RESOURCE
|
||||
+ ", "
|
||||
+ IndexColumns.FRAGMENT
|
||||
+ ", "
|
||||
+ IndexColumns.CONTROLLER
|
||||
+ ", "
|
||||
+ IndexColumns.SLICE_TYPE
|
||||
+ ", "
|
||||
+ IndexColumns.UNAVAILABLE_SLICE_SUBTITLE
|
||||
+ ", "
|
||||
+ IndexColumns.PUBLIC_SLICE
|
||||
+ ", "
|
||||
+ IndexColumns.HIGHLIGHT_MENU_RESOURCE
|
||||
+ " INTEGER DEFAULT 0 "
|
||||
+ ");";
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
|
@@ -116,6 +116,7 @@ class SlicesIndexer implements Runnable {
|
||||
values.put(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
|
||||
dataRow.getUnavailableSliceSubtitle());
|
||||
values.put(IndexColumns.PUBLIC_SLICE, dataRow.isPublicSlice());
|
||||
values.put(IndexColumns.HIGHLIGHT_MENU_RESOURCE, dataRow.getHighlightMenuRes());
|
||||
|
||||
database.replaceOrThrow(Tables.TABLE_SLICES_INDEX, null /* nullColumnHack */,
|
||||
values);
|
||||
|
@@ -707,6 +707,7 @@ public class SettingsSliceProviderTest {
|
||||
.setIcon(SliceTestUtils.FAKE_ICON)
|
||||
.setFragmentName(SliceTestUtils.FAKE_FRAGMENT_NAME)
|
||||
.setPreferenceControllerClassName(SliceTestUtils.FAKE_CONTROLLER_NAME)
|
||||
.setHighlightMenuRes(SliceTestUtils.FAKE_HIGHLIGHT_MENU_RES)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@@ -322,6 +322,8 @@ public class SliceBroadcastReceiverTest {
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.FRAGMENT, SliceTestUtils.FAKE_FRAGMENT_NAME);
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.CONTROLLER, controllerClass);
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.SLICE_URI, buildUri(key).toSafeString());
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.HIGHLIGHT_MENU_RESOURCE,
|
||||
SliceTestUtils.FAKE_HIGHLIGHT_MENU_RES);
|
||||
mDb.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,7 @@ class SliceTestUtils {
|
||||
public static final int FAKE_ICON = 1234;
|
||||
public static final String FAKE_FRAGMENT_NAME = FakeIndexProvider.class.getName();
|
||||
public static final String FAKE_CONTROLLER_NAME = FakeToggleController.class.getName();
|
||||
public static final int FAKE_HIGHLIGHT_MENU_RES = FakeToggleController.HIGHLIGHT_MENU_RES;
|
||||
|
||||
|
||||
public static void insertSliceToDb(Context context, String key) {
|
||||
@@ -75,6 +76,8 @@ class SliceTestUtils {
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
|
||||
customizedUnavailableSliceSubtitle);
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.PUBLIC_SLICE, isPublicSlice);
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.HIGHLIGHT_MENU_RESOURCE,
|
||||
FAKE_HIGHLIGHT_MENU_RES);
|
||||
|
||||
db.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
|
||||
db.close();
|
||||
|
@@ -102,6 +102,7 @@ public class SlicesDatabaseAccessorTest {
|
||||
assertThat(data.getFragmentClassName()).isEqualTo(SliceTestUtils.FAKE_FRAGMENT_NAME);
|
||||
assertThat(data.getUri()).isNull();
|
||||
assertThat(data.getPreferenceController()).isEqualTo(SliceTestUtils.FAKE_CONTROLLER_NAME);
|
||||
assertThat(data.getHighlightMenuRes()).isEqualTo(SliceTestUtils.FAKE_HIGHLIGHT_MENU_RES);
|
||||
assertThat(data.getUnavailableSliceSubtitle()).isNull();
|
||||
}
|
||||
|
||||
@@ -122,6 +123,7 @@ public class SlicesDatabaseAccessorTest {
|
||||
assertThat(data.getFragmentClassName()).isEqualTo(SliceTestUtils.FAKE_FRAGMENT_NAME);
|
||||
assertThat(data.getUri()).isNull();
|
||||
assertThat(data.getPreferenceController()).isEqualTo(SliceTestUtils.FAKE_CONTROLLER_NAME);
|
||||
assertThat(data.getHighlightMenuRes()).isEqualTo(SliceTestUtils.FAKE_HIGHLIGHT_MENU_RES);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@@ -154,6 +156,7 @@ public class SlicesDatabaseAccessorTest {
|
||||
assertThat(data.getFragmentClassName()).isEqualTo(SliceTestUtils.FAKE_FRAGMENT_NAME);
|
||||
assertThat(data.getUri()).isEqualTo(uri);
|
||||
assertThat(data.getPreferenceController()).isEqualTo(SliceTestUtils.FAKE_CONTROLLER_NAME);
|
||||
assertThat(data.getHighlightMenuRes()).isEqualTo(SliceTestUtils.FAKE_HIGHLIGHT_MENU_RES);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@@ -289,6 +292,7 @@ public class SlicesDatabaseAccessorTest {
|
||||
assertThat(data.getFragmentClassName()).isEqualTo(SliceTestUtils.FAKE_FRAGMENT_NAME);
|
||||
assertThat(data.getUri()).isNull();
|
||||
assertThat(data.getPreferenceController()).isEqualTo(SliceTestUtils.FAKE_CONTROLLER_NAME);
|
||||
assertThat(data.getHighlightMenuRes()).isEqualTo(SliceTestUtils.FAKE_HIGHLIGHT_MENU_RES);
|
||||
assertThat(data.getUnavailableSliceSubtitle()).isNull();
|
||||
}
|
||||
|
||||
@@ -309,6 +313,7 @@ public class SlicesDatabaseAccessorTest {
|
||||
assertThat(data.getFragmentClassName()).isEqualTo(SliceTestUtils.FAKE_FRAGMENT_NAME);
|
||||
assertThat(data.getUri()).isNull();
|
||||
assertThat(data.getPreferenceController()).isEqualTo(SliceTestUtils.FAKE_CONTROLLER_NAME);
|
||||
assertThat(data.getHighlightMenuRes()).isEqualTo(SliceTestUtils.FAKE_HIGHLIGHT_MENU_RES);
|
||||
assertThat(data.getUnavailableSliceSubtitle()).isEqualTo(subtitle);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -27,6 +27,7 @@ import com.android.settings.slices.SliceBackgroundWorker;
|
||||
public class FakeToggleController extends TogglePreferenceController {
|
||||
|
||||
public static final String AVAILABILITY_KEY = "fake_toggle_availability_key";
|
||||
public static final int HIGHLIGHT_MENU_RES = 5678;
|
||||
|
||||
public static final IntentFilter INTENT_FILTER = new IntentFilter(
|
||||
WifiManager.WIFI_AP_STATE_CHANGED_ACTION);
|
||||
@@ -70,6 +71,11 @@ public class FakeToggleController extends TogglePreferenceController {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return HIGHLIGHT_MENU_RES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
|
||||
return TestWorker.class;
|
||||
|
@@ -119,6 +119,11 @@ public class TogglePreferenceControllerTest {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return 5678;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
|
@@ -302,6 +302,11 @@ public class ProviderModelSliceHelperTest {
|
||||
public Intent getIntent() {
|
||||
return new Intent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private class MockProviderModelSliceHelper extends ProviderModelSliceHelper {
|
||||
|
@@ -35,6 +35,7 @@ class SliceTestUtils {
|
||||
public static final int FAKE_ICON = 1234;
|
||||
public static final String FAKE_FRAGMENT_NAME = FakeIndexProvider.class.getName();
|
||||
public static final String FAKE_CONTROLLER_NAME = FakeToggleController.class.getName();
|
||||
public static final int FAKE_HIGHLIGHT_MENU_RES = FakeToggleController.HIGHLIGHT_MENU_RES;
|
||||
|
||||
|
||||
public static void insertSliceToDb(Context context, String key) {
|
||||
@@ -75,6 +76,8 @@ class SliceTestUtils {
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
|
||||
customizedUnavailableSliceSubtitle);
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.PUBLIC_SLICE, isPublicSlice);
|
||||
values.put(SlicesDatabaseHelper.IndexColumns.HIGHLIGHT_MENU_RESOURCE,
|
||||
FAKE_HIGHLIGHT_MENU_RES);
|
||||
|
||||
db.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
|
||||
db.close();
|
||||
|
@@ -143,5 +143,10 @@ public class SpecialCaseSliceManagerTest {
|
||||
public Intent getIntent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import com.android.settings.slices.SliceBackgroundWorker;
|
||||
public class FakeToggleController extends TogglePreferenceController {
|
||||
|
||||
public static final String AVAILABILITY_KEY = "fake_toggle_availability_key";
|
||||
public static final int HIGHLIGHT_MENU_RES = 5678;
|
||||
|
||||
public static final IntentFilter INTENT_FILTER = new IntentFilter(
|
||||
WifiManager.WIFI_AP_STATE_CHANGED_ACTION);
|
||||
@@ -70,6 +71,11 @@ public class FakeToggleController extends TogglePreferenceController {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return HIGHLIGHT_MENU_RES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
|
||||
return TestWorker.class;
|
||||
|
Reference in New Issue
Block a user