use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class FlashlightSlice method getSlice.
@Override
public Slice getSlice() {
if (!isFlashlightAvailable(mContext)) {
return null;
}
final PendingIntent toggleAction = getBroadcastIntent(mContext);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_signal_flashlight);
return new ListBuilder(mContext, CustomSliceRegistry.FLASHLIGHT_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(mContext.getText(R.string.power_flashlight)).setTitleItem(icon, ICON_IMAGE).setPrimaryAction(SliceAction.createToggle(toggleAction, null, isFlashlightEnabled(mContext)))).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class MobileDataSlice method getSlice.
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_network_cell);
final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
// Return null until we can show a disabled-action Slice, blaming Airplane mode.
if (isAirplaneModeEnabled()) {
return null;
}
// Return null until we can show a disabled-action Slice.
if (!isMobileDataAvailable()) {
return null;
}
final CharSequence summary = getSummary();
final PendingIntent toggleAction = getBroadcastIntent(mContext);
final PendingIntent primaryAction = getPrimaryAction();
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
isMobileDataEnabled());
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction);
if (!Utils.isSettingsIntelligence(mContext)) {
rowBuilder.setSubtitle(summary);
}
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder);
return listBuilder.build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtils method buildIntentSlice.
private static Slice buildIntentSlice(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 Set<String> keywords = buildSliceKeywords(sliceData);
final RowBuilder rowBuilder = new RowBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle()));
if (!Utils.isSettingsIntelligence(context)) {
rowBuilder.setSubtitle(subtitleText);
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder).setKeywords(keywords).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtils method buildCopyableSlice.
private static Slice buildCopyableSlice(Context context, SliceData sliceData, BasePreferenceController controller) {
final SliceAction copyableAction = getCopyableAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
final SliceAction primaryAction = SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle());
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final Set<String> keywords = buildSliceKeywords(sliceData);
final RowBuilder rowBuilder = new RowBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(primaryAction).addEndItem(copyableAction);
if (!Utils.isSettingsIntelligence(context)) {
rowBuilder.setSubtitle(subtitleText);
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder).setKeywords(keywords).build();
}
use of androidx.slice.builders.ListBuilder 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