Define a constant Sliceable#NO_RES for no resource cases

Fix: 204733076
Test: build
Change-Id: Ifa3b9db0e915a3ec056ad68a9a1862811594d423
This commit is contained in:
Jason Chiu
2021-11-03 12:18:39 +08:00
parent 6821b6be32
commit 9fc0f18181
11 changed files with 21 additions and 14 deletions

View File

@@ -95,6 +95,6 @@ public class BiometricSettingsAppPreferenceController extends TogglePreferenceCo
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable // not needed since it's not sliceable
return 0; return NO_RES;
} }
} }

View File

@@ -77,6 +77,6 @@ public class BiometricSettingsKeyguardPreferenceController extends TogglePrefere
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable // not needed since it's not sliceable
return 0; return NO_RES;
} }
} }

View File

@@ -55,6 +55,6 @@ public abstract class FaceSettingsPreferenceController extends TogglePreferenceC
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable // not needed since it's not sliceable
return 0; return NO_RES;
} }
} }

View File

@@ -120,7 +120,7 @@ public class LocationTimeZoneDetectionPreferenceController
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable // not needed since it's not sliceable
return 0; return NO_RES;
} }
@Override @Override

View File

@@ -55,7 +55,7 @@ public class EmergencyGestureSoundPreferenceController extends TogglePreferenceC
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable // not needed since it's not sliceable
return 0; return NO_RES;
} }
@Override @Override

View File

@@ -120,7 +120,7 @@ public class FlashlightSlice implements CustomSliceable {
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// no landing page in Settings // no landing page in Settings
return 0; return NO_RES;
} }
private static String getCameraId(Context context) throws CameraAccessException { private static String getCameraId(Context context) throws CameraAccessException {

View File

@@ -68,7 +68,7 @@ public abstract class TelephonyTogglePreferenceController extends TogglePreferen
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable // not needed since it's not sliceable
return 0; return NO_RES;
} }
/** /**

View File

@@ -91,7 +91,7 @@ public class BubbleNotificationPreferenceController extends
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
// not needed since it's not sliceable // not needed since it's not sliceable
return 0; return NO_RES;
} }
@Override @Override

View File

@@ -25,6 +25,7 @@ import android.content.IntentFilter;
import android.net.Uri; import android.net.Uri;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.StringRes;
import androidx.slice.Slice; import androidx.slice.Slice;
import com.android.settings.R; import com.android.settings.R;
@@ -135,10 +136,16 @@ public interface Sliceable {
} }
/** /**
* @return a resource ID that indicates which menu entry should be highlighted in multi-pane * Used to mark a {@link Sliceable} that has no highlight menu string resource.
* mode.
*/ */
default int getSliceHighlightMenuRes() { int NO_RES = 0;
return 0;
/**
* @return a string resource declared in res/values/menu_keys.xml that indicates which menu
* entry should be highlighted in two-pane mode, or {@link #NO_RES} representing highlighting is
* not applicable.
*/
@StringRes default int getSliceHighlightMenuRes() {
return NO_RES;
} }
} }

View File

@@ -305,7 +305,7 @@ public class ProviderModelSliceHelperTest {
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
return 0; return NO_RES;
} }
} }

View File

@@ -146,7 +146,7 @@ public class SpecialCaseSliceManagerTest {
@Override @Override
public int getSliceHighlightMenuRes() { public int getSliceHighlightMenuRes() {
return 0; return NO_RES;
} }
} }
} }