Update Slice APIs to current versions
Change-Id: Icf40673e518534487be77f33427df937717735e5 Fixes: 77982356 Test: robotests
This commit is contained in:
@@ -59,10 +59,11 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
switch (action) {
|
||||
case ACTION_TOGGLE_CHANGED:
|
||||
handleToggleAction(context, key, isPlatformSlice);
|
||||
final boolean isChecked = intent.getBooleanExtra(Slice.EXTRA_TOGGLE_STATE, false);
|
||||
handleToggleAction(context, key, isChecked, isPlatformSlice);
|
||||
break;
|
||||
case ACTION_SLIDER_CHANGED:
|
||||
int newPosition = intent.getIntExtra(Slice.EXTRA_RANGE_VALUE, -1);
|
||||
final int newPosition = intent.getIntExtra(Slice.EXTRA_RANGE_VALUE, -1);
|
||||
handleSliderAction(context, key, newPosition, isPlatformSlice);
|
||||
break;
|
||||
case ACTION_WIFI_CHANGED:
|
||||
@@ -81,7 +82,8 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleToggleAction(Context context, String key, boolean isPlatformSlice) {
|
||||
private void handleToggleAction(Context context, String key, boolean isChecked,
|
||||
boolean isPlatformSlice) {
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
throw new IllegalStateException("No key passed to Intent for toggle controller");
|
||||
}
|
||||
@@ -101,10 +103,8 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
|
||||
// TODO post context.getContentResolver().notifyChanged(uri, null) in the Toggle controller
|
||||
// so that it's automatically broadcast to any slice.
|
||||
final TogglePreferenceController toggleController = (TogglePreferenceController) controller;
|
||||
final boolean currentValue = toggleController.isChecked();
|
||||
final boolean newValue = !currentValue;
|
||||
toggleController.setChecked(newValue);
|
||||
logSliceValueChange(context, key, newValue ? 1 : 0);
|
||||
toggleController.setChecked(isChecked);
|
||||
logSliceValueChange(context, key, isChecked ? 1 : 0);
|
||||
updateUri(context, key, isPlatformSlice);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user