use of com.android.settings.core.TogglePreferenceController in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtils method buildToggleSlice.
private static Slice buildToggleSlice(Context context, SliceData sliceData, BasePreferenceController controller) {
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final TogglePreferenceController toggleController = (TogglePreferenceController) controller;
final SliceAction sliceAction = getToggleAction(context, sliceData, toggleController.isChecked());
final Set<String> keywords = buildSliceKeywords(sliceData);
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle())).addEndItem(sliceAction)).setKeywords(keywords).build();
}
use of com.android.settings.core.TogglePreferenceController in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBroadcastReceiver method handleToggleAction.
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");
}
final BasePreferenceController controller = getPreferenceController(context, key);
if (!(controller instanceof TogglePreferenceController)) {
throw new IllegalStateException("Toggle action passed for a non-toggle key: " + key);
}
if (!controller.isAvailable()) {
Log.w(TAG, "Can't update " + key + " since the setting is unavailable");
if (!controller.hasAsyncUpdate()) {
updateUri(context, key, isPlatformSlice);
}
return;
}
// 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;
toggleController.setChecked(isChecked);
logSliceValueChange(context, key, isChecked ? 1 : 0);
if (!controller.hasAsyncUpdate()) {
updateUri(context, key, isPlatformSlice);
}
}
use of com.android.settings.core.TogglePreferenceController in project android_packages_apps_Settings by omnirom.
the class SliceBroadcastReceiver method handleToggleAction.
private void handleToggleAction(Context context, Uri sliceUri, String key, boolean isChecked) {
if (TextUtils.isEmpty(key)) {
throw new IllegalStateException("No key passed to Intent for toggle controller");
}
final BasePreferenceController controller = getPreferenceController(context, key);
if (!(controller instanceof TogglePreferenceController)) {
throw new IllegalStateException("Toggle action passed for a non-toggle key: " + key);
}
if (!controller.isAvailable()) {
Log.w(TAG, "Can't update " + key + " since the setting is unavailable");
if (!controller.hasAsyncUpdate()) {
context.getContentResolver().notifyChange(sliceUri, null);
}
return;
}
// 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;
toggleController.setChecked(isChecked);
logSliceValueChange(context, key, isChecked ? 1 : 0);
if (!controller.hasAsyncUpdate()) {
context.getContentResolver().notifyChange(sliceUri, null);
}
}
use of com.android.settings.core.TogglePreferenceController in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtils method buildToggleSlice.
private static Slice buildToggleSlice(Context context, SliceData sliceData, BasePreferenceController controller) {
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final TogglePreferenceController toggleController = (TogglePreferenceController) controller;
final SliceAction sliceAction = getToggleAction(context, sliceData, toggleController.isChecked());
final Set<String> keywords = buildSliceKeywords(sliceData);
final RowBuilder rowBuilder = new RowBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle())).addEndItem(sliceAction);
if (!Utils.isSettingsIntelligence(context)) {
rowBuilder.setSubtitle(subtitleText);
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder).setKeywords(keywords).build();
}
Aggregations