use of androidx.slice.builders.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiSlice method getHeaderRow.
private ListBuilder getHeaderRow(boolean isWifiEnabled) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
final String title = mContext.getString(R.string.wifi_settings);
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 */
isWifiEnabled);
return new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED).setKeywords(getKeywords()).addRow(new ListBuilder.RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction));
}
use of androidx.slice.builders.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceDeferredSetupCardRendererHelperTest method buildSlice.
private Slice buildSlice() {
final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
final PendingIntent pendingIntent = PendingIntent.getActivity(mActivity, TITLE.hashCode(), /* requestCode */
new Intent("test action"), 0);
final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, TITLE);
return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle(TITLE).setSubtitle(SUMMARY).setPrimaryAction(action)).build();
}
use of androidx.slice.builders.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceFullCardRendererHelperTest method buildSlice.
private Slice buildSlice() {
final String title = "test_title";
final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
final PendingIntent pendingIntent = PendingIntent.getActivity(mActivity, title.hashCode(), /* requestCode */
new Intent("test action"), 0);
final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(action)).build();
}
use of androidx.slice.builders.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageSlice method getSlice.
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_data_usage);
final String title = mContext.getString(R.string.data_usage_summary_title);
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
DataUsageController dataUsageController = new DataUsageController(mContext);
DataUsageController.DataUsageInfo info = null;
SubscriptionManager subscriptionManager = (SubscriptionManager) mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
int defaultSubId = subscriptionManager.getDefaultDataSubscriptionId();
boolean showDailyDataUsage = Settings.System.getInt(mContext.getContentResolver(), Settings.System.DATA_USAGE_PERIOD, 1) == 0;
if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
info = dataUsageController.getDataUsageInfo();
} else {
info = showDailyDataUsage ? dataUsageController.getDailyDataUsageInfo(DataUsageUtils.getMobileTemplate(mContext, defaultSubId)) : dataUsageController.getDataUsageInfo(DataUsageUtils.getMobileTemplate(mContext, defaultSubId));
}
final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.DATA_USAGE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext)).setHeader(new ListBuilder.HeaderBuilder().setTitle(title));
if (DataUsageUtils.hasSim(mContext)) {
listBuilder.addRow(new ListBuilder.RowBuilder().setTitle(getDataUsageText(info)).setSubtitle(getCycleTime(info)).setPrimaryAction(primaryAction));
} else {
listBuilder.addRow(new ListBuilder.RowBuilder().setTitle(mContext.getText(R.string.no_sim_card)).setPrimaryAction(primaryAction));
}
return listBuilder.build();
}
use of androidx.slice.builders.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MediaOutputIndicatorSlice method getSlice.
@Override
public Slice getSlice() {
if (!isVisible()) {
return null;
}
final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
final CharSequence title = mContext.getText(R.string.media_output_title);
final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext, 0, /* requestCode */
getMediaOutputSliceIntent(), 0);
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final ListBuilder listBuilder = new ListBuilder(mContext, MEDIA_OUTPUT_INDICATOR_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(title).setSubtitle(findActiveDeviceName()).setPrimaryAction(primarySliceAction));
return listBuilder.build();
}
Aggregations