Search in sources :

Example 16 with SliceAction

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

the class BluetoothDevicesSlice method getBluetoothOffHeader.

private ListBuilder.RowBuilder getBluetoothOffHeader() {
    final Drawable drawable = mContext.getDrawable(R.drawable.ic_bluetooth_disabled);
    final int tint = Utils.getDisabled(mContext, Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal));
    drawable.setTint(tint);
    final IconCompat icon = Utils.createIconWithDrawable(drawable);
    final CharSequence title = mContext.getText(R.string.bluetooth_devices_card_off_title);
    final CharSequence summary = mContext.getText(R.string.bluetooth_devices_card_off_summary);
    final Intent intent = new Intent(getUri().toString()).setClass(mContext, SliceBroadcastReceiver.class).putExtra(EXTRA_ENABLE_BLUETOOTH, true);
    final SliceAction action = SliceAction.create(PendingIntent.getBroadcast(mContext, 0, /* requestCode */
    intent, PendingIntent.FLAG_IMMUTABLE), icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setSubtitle(summary).setPrimaryAction(action);
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) Drawable(android.graphics.drawable.Drawable) SliceAction(androidx.slice.builders.SliceAction) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) SliceBroadcastReceiver(com.android.settings.slices.SliceBroadcastReceiver)

Example 17 with SliceAction

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

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);
    final RowBuilder rowBuilder = new RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction);
    if (!Utils.isSettingsIntelligence(context)) {
        rowBuilder.setSubtitle(subtitle);
    }
    return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder).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 18 with SliceAction

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

the class MediaOutputIndicatorSlice method getSlice.

@Override
public Slice getSlice() {
    if (!isVisible()) {
        return new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setIsError(true).build();
    }
    final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
    final CharSequence title = mContext.getString(R.string.media_output_label_title, Utils.getApplicationLabel(mContext, getWorker().getPackageName()));
    final SliceAction primarySliceAction = SliceAction.create(getBroadcastIntent(mContext), icon, ListBuilder.ICON_IMAGE, title);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
    // To set an empty icon to indent the row
    final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(title).setTitleItem(createEmptyIcon(), ListBuilder.ICON_IMAGE).setSubtitle(getWorker().getCurrentConnectedMediaDevice().getName()).setPrimaryAction(primarySliceAction));
    return listBuilder.build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder)

Example 19 with SliceAction

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

the class RemoteMediaSlice method getSoundSettingAction.

private SliceAction getSoundSettingAction(CharSequence actionTitle, IconCompat icon, String id) {
    final Uri contentUri = new Uri.Builder().appendPath(id).build();
    final Intent intent = SliceBuilderUtils.buildSearchResultPageIntent(mContext, SoundSettings.class.getName(), id, mContext.getText(R.string.sound_settings).toString(), 0);
    intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
    intent.setData(contentUri);
    final PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE);
    final SliceAction primarySliceAction = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.ICON_IMAGE, actionTitle);
    return primarySliceAction;
}
Also used : SubSettings(com.android.settings.SubSettings) ListBuilder(androidx.slice.builders.ListBuilder) InputRangeBuilder(androidx.slice.builders.ListBuilder.InputRangeBuilder) SliceAction(androidx.slice.builders.SliceAction) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) SoundSettings(com.android.settings.notification.SoundSettings) Uri(android.net.Uri)

Example 20 with SliceAction

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

the class LocationSlice method getSlice.

@Override
public Slice getSlice() {
    final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_signal_location);
    final CharSequence title = mContext.getText(R.string.location_settings_title);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
    final PendingIntent primaryAction = getPrimaryAction();
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder(mContext, CustomSliceRegistry.LOCATION_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setTitleItem(icon, ICON_IMAGE).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)

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