use of androidx.slice.builders.SliceAction 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.SliceAction 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.SliceAction 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();
}
use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.
the class WifiSlice method getListBuilder.
private ListBuilder getListBuilder(boolean isWifiEnabled, WifiSliceItem wifiSliceItem) {
final PendingIntent toggleAction = getBroadcastIntent(mContext);
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
isWifiEnabled);
final ListBuilder builder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED).setKeywords(getKeywords()).addRow(getHeaderRow(isWifiEnabled, wifiSliceItem)).addAction(toggleSliceAction);
return builder;
}
use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.
the class BluetoothDevicesSlice method getBluetoothOnHeader.
private ListBuilder.RowBuilder getBluetoothOnHeader() {
final Drawable drawable = mContext.getDrawable(com.android.internal.R.drawable.ic_settings_bluetooth);
drawable.setTint(Utils.getColorAccentDefaultColor(mContext));
final IconCompat icon = Utils.createIconWithDrawable(drawable);
final CharSequence title = mContext.getText(R.string.bluetooth_devices);
final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext, 0, /* requestCode */
getIntent(), PendingIntent.FLAG_IMMUTABLE);
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
return new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(primarySliceAction).addEndItem(getPairNewDeviceAction());
}
Aggregations