Search in sources :

Example 6 with RowBuilder

use of androidx.slice.builders.ListBuilder.RowBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothSliceBuilder method getSlice.

/**
 * Return a Bluetooth Slice bound to {@link CustomSliceRegistry#BLUETOOTH_URI}.
 * <p>
 * Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
 * Bluetooth.
 */
public static Slice getSlice(Context context) {
    final boolean isBluetoothEnabled = isBluetoothEnabled();
    final CharSequence title = context.getText(R.string.switch_on_text);
    final IconCompat icon = IconCompat.createWithResource(context, com.android.internal.R.drawable.ic_settings_bluetooth);
    @ColorInt final int color = com.android.settings.Utils.getColorAccent(context).getDefaultColor();
    final PendingIntent toggleAction = getBroadcastIntent(context);
    final PendingIntent primaryAction = getPrimaryAction(context);
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
    final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
    isBluetoothEnabled);
    return new ListBuilder(context, CustomSliceRegistry.BLUETOOTH_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction)).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 7 with RowBuilder

use of androidx.slice.builders.ListBuilder.RowBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeSliceBuilder method getSlice.

/**
 * Return a ZenMode Slice bound to {@link CustomSliceRegistry#ZEN_MODE_URI}.
 * <p>
 * Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
 * ZenMode.
 */
public static Slice getSlice(Context context) {
    final boolean isZenModeEnabled = isZenModeEnabled(context);
    final CharSequence title = context.getText(R.string.zen_mode_settings_title);
    final CharSequence subtitle = context.getText(R.string.zen_mode_slice_subtitle);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
    final PendingIntent toggleAction = getBroadcastIntent(context);
    final PendingIntent primaryAction = getPrimaryAction(context);
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, (IconCompat) null, /* icon */
    ListBuilder.ICON_IMAGE, title);
    final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
    isZenModeEnabled);
    return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setSubtitle(subtitle).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction)).build();
}
Also used : ColorInt(android.annotation.ColorInt) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 8 with RowBuilder

use of androidx.slice.builders.ListBuilder.RowBuilder 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();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder) TogglePreferenceController(com.android.settings.core.TogglePreferenceController)

Example 9 with RowBuilder

use of androidx.slice.builders.ListBuilder.RowBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceBuilderUtils method buildUnavailableSlice.

private static Slice buildUnavailableSlice(Context context, SliceData data) {
    final String title = data.getTitle();
    final Set<String> keywords = buildSliceKeywords(data);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
    final String customSubtitle = data.getUnavailableSliceSubtitle();
    final CharSequence subtitle = !TextUtils.isEmpty(customSubtitle) ? customSubtitle : context.getText(R.string.disabled_dependent_setting_summary);
    final IconCompat icon = getSafeIcon(context, data);
    final SliceAction primaryAction = SliceAction.createDeeplink(getContentPendingIntent(context, data), icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder(context, data.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setTitleItem(icon, ListBuilder.ICON_IMAGE).setSubtitle(subtitle).setPrimaryAction(primaryAction)).setKeywords(keywords).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 10 with RowBuilder

use of androidx.slice.builders.ListBuilder.RowBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Aggregations

RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)10 IconCompat (androidx.core.graphics.drawable.IconCompat)9 ListBuilder (androidx.slice.builders.ListBuilder)9 ColorInt (android.annotation.ColorInt)8 SliceAction (androidx.slice.builders.SliceAction)8 PendingIntent (android.app.PendingIntent)7 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 Drawable (android.graphics.drawable.Drawable)1 TogglePreferenceController (com.android.settings.core.TogglePreferenceController)1 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)1 SliceBackgroundWorker (com.android.settings.slices.SliceBackgroundWorker)1