use of androidx.slice.builders.ListBuilder.RowBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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();
}
use of androidx.slice.builders.ListBuilder.RowBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryFixSlice method getSlice.
@Override
public Slice getSlice() {
final ListBuilder sliceBuilder = new ListBuilder(mContext, BATTERY_FIX_SLICE_URI, ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
if (!isBatteryTipAvailableFromCache(mContext)) {
return buildBatteryGoodSlice(sliceBuilder, true);
}
final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
final List<BatteryTip> batteryTips = worker != null ? worker.getResults() : null;
if (batteryTips == null) {
// Because we need wait slice background worker return data
return buildBatteryGoodSlice(sliceBuilder, false);
}
for (BatteryTip batteryTip : batteryTips) {
if (batteryTip.getState() == BatteryTip.StateType.INVISIBLE) {
continue;
}
final Drawable drawable = mContext.getDrawable(batteryTip.getIconId());
final int iconTintColorId = batteryTip.getIconTintColorId();
if (iconTintColorId != View.NO_ID) {
drawable.setColorFilter(new PorterDuffColorFilter(mContext.getResources().getColor(iconTintColorId), PorterDuff.Mode.SRC_IN));
}
final IconCompat icon = Utils.createIconWithDrawable(drawable);
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, batteryTip.getTitle(mContext));
sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(batteryTip.getTitle(mContext)).setSubtitle(batteryTip.getSummary(mContext)).setPrimaryAction(primaryAction));
break;
}
return sliceBuilder.build();
}
use of androidx.slice.builders.ListBuilder.RowBuilder 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();
}
use of androidx.slice.builders.ListBuilder.RowBuilder 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();
}
use of androidx.slice.builders.ListBuilder.RowBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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);
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle()))).setKeywords(keywords).build();
}
Aggregations