Search in sources :

Example 11 with SliceAction

use of androidx.slice.builders.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BatteryFixSlice method buildBatteryGoodSlice.

private Slice buildBatteryGoodSlice(ListBuilder sliceBuilder, boolean isError) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_battery_status_good_24dp);
    final String title = mContext.getString(R.string.power_usage_summary_title);
    final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
    sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(primaryAction)).setIsError(isError);
    return sliceBuilder.build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 12 with SliceAction

use of androidx.slice.builders.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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);
    return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(primaryAction).addEndItem(copyableAction)).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)

Example 13 with SliceAction

use of androidx.slice.builders.SliceAction 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 14 with SliceAction

use of androidx.slice.builders.SliceAction 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 15 with SliceAction

use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.

the class BatteryFixSlice method buildBatteryGoodSlice.

private Slice buildBatteryGoodSlice(ListBuilder sliceBuilder, boolean isError) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_battery_status_good_24dp);
    final String title = mContext.getString(R.string.power_usage_summary_title);
    final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
    sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(primaryAction)).setIsError(isError);
    return sliceBuilder.build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Aggregations

SliceAction (androidx.slice.builders.SliceAction)46 IconCompat (androidx.core.graphics.drawable.IconCompat)39 ListBuilder (androidx.slice.builders.ListBuilder)37 PendingIntent (android.app.PendingIntent)32 ColorInt (android.annotation.ColorInt)18 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)16 Intent (android.content.Intent)10 Drawable (android.graphics.drawable.Drawable)6 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3 InputRangeBuilder (androidx.slice.builders.ListBuilder.InputRangeBuilder)3 SliderPreferenceController (com.android.settings.core.SliderPreferenceController)2 TogglePreferenceController (com.android.settings.core.TogglePreferenceController)2 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)2 SliceBackgroundWorker (com.android.settings.slices.SliceBackgroundWorker)2 SliceBroadcastReceiver (com.android.settings.slices.SliceBroadcastReceiver)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 SubscriptionManager (android.telephony.SubscriptionManager)1 SpannableString (android.text.SpannableString)1