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);
}
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();
}
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();
}
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;
}
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();
}
Aggregations