use of androidx.core.graphics.drawable.IconCompat 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.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtils method buildIntentSlice.
private static Slice buildIntentSlice(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 Set<String> keywords = buildSliceKeywords(sliceData);
final RowBuilder rowBuilder = new RowBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle()));
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.core.graphics.drawable.IconCompat 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.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtils method getCopyableAction.
private static SliceAction getCopyableAction(Context context, SliceData sliceData) {
final PendingIntent intent = getActionIntent(context, SettingsSliceProvider.ACTION_COPY, sliceData);
final IconCompat icon = IconCompat.createWithResource(context, R.drawable.ic_content_copy_grey600_24dp);
return SliceAction.create(intent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle());
}
use of androidx.core.graphics.drawable.IconCompat 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();
}
Aggregations