use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.
the class WifiSlice method getHeaderRow.
protected ListBuilder.RowBuilder getHeaderRow(boolean isWifiEnabled, WifiSliceItem wifiSliceItem) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
final String title = mContext.getString(R.string.wifi_settings);
final PendingIntent primaryAction = getPrimaryAction();
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
return new ListBuilder.RowBuilder().setTitle(title).setPrimaryAction(primarySliceAction);
}
use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.
the class ProviderModelSliceHelper method createCarrierRow.
protected ListBuilder.RowBuilder createCarrierRow(String networkTypeDescription) {
final String title = getMobileTitle();
final String summary = getMobileSummary(networkTypeDescription);
Drawable drawable = mContext.getDrawable(R.drawable.ic_signal_strength_zero_bar_no_internet);
try {
drawable = getMobileDrawable(drawable);
} catch (Throwable e) {
e.printStackTrace();
}
final IconCompat levelIcon = Utils.createIconWithDrawable(drawable);
final PendingIntent rowIntent = mSliceable.getBroadcastIntent(mContext);
final SliceAction primaryAction = SliceAction.create(rowIntent, levelIcon, ListBuilder.ICON_IMAGE, title);
final SliceAction toggleAction = SliceAction.createToggle(rowIntent, "mobile_toggle", /* actionTitle */
isMobileDataEnabled());
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitle(title).setTitleItem(levelIcon, ListBuilder.ICON_IMAGE).addEndItem(toggleAction).setPrimaryAction(primaryAction).setSubtitle(Html.fromHtml(summary, Html.FROM_HTML_MODE_LEGACY));
return rowBuilder;
}
use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.
the class ProviderModelSlice method createWifiToggleRow.
/**
* @return a {@link ListBuilder.RowBuilder} of the Wi-Fi toggle.
*/
protected ListBuilder.RowBuilder createWifiToggleRow(Context context, boolean isWifiEnabled) {
final Intent intent = new Intent(WIFI_SLICE_URI.toString()).setData(WIFI_SLICE_URI).setClass(context, SliceBroadcastReceiver.class).putExtra(EXTRA_TOGGLE_STATE, !isWifiEnabled).addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
final SliceAction toggleSliceAction = SliceAction.createToggle(pendingIntent, null, /* actionTitle */
isWifiEnabled);
return new ListBuilder.RowBuilder().setTitle(context.getString(R.string.wifi_settings)).setPrimaryAction(toggleSliceAction);
}
use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtils method buildUnavailableSlice.
private static Slice buildUnavailableSlice(Context context, SliceData data) {
final String title = data.getTitle();
final Set<String> keywords = buildSliceKeywords(data);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final String customSubtitle = data.getUnavailableSliceSubtitle();
final CharSequence subtitle = !TextUtils.isEmpty(customSubtitle) ? customSubtitle : context.getText(R.string.disabled_dependent_setting_summary);
final IconCompat icon = getSafeIcon(context, data);
final SliceAction primaryAction = SliceAction.createDeeplink(getContentPendingIntent(context, data), icon, ListBuilder.ICON_IMAGE, title);
final RowBuilder rowBuilder = new RowBuilder().setTitle(title).setTitleItem(icon, ListBuilder.ICON_IMAGE).setPrimaryAction(primaryAction);
if (!Utils.isSettingsIntelligence(context)) {
rowBuilder.setSubtitle(subtitle);
}
return new ListBuilder(context, data.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 buildSliderSlice.
private static Slice buildSliderSlice(Context context, SliceData sliceData, BasePreferenceController controller) {
final SliderPreferenceController sliderController = (SliderPreferenceController) controller;
if (sliderController.getMax() <= sliderController.getMin()) {
Log.e(TAG, "Invalid sliderController: " + sliderController.getPreferenceKey());
return null;
}
final PendingIntent actionIntent = getSliderAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
@ColorInt int color = Utils.getColorAccentDefaultColor(context);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
final SliceAction primaryAction = SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle());
final Set<String> keywords = buildSliceKeywords(sliceData);
int cur = sliderController.getSliderPosition();
if (cur < sliderController.getMin()) {
cur = sliderController.getMin();
}
if (cur > sliderController.getMax()) {
cur = sliderController.getMax();
}
final InputRangeBuilder inputRangeBuilder = new InputRangeBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(primaryAction).setMax(sliderController.getMax()).setMin(sliderController.getMin()).setValue(cur).setInputAction(actionIntent);
if (sliceData.getIconResource() != 0) {
inputRangeBuilder.setTitleItem(icon, ListBuilder.ICON_IMAGE);
color = CustomSliceable.COLOR_NOT_TINTED;
}
if (!Utils.isSettingsIntelligence(context)) {
inputRangeBuilder.setSubtitle(subtitleText);
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addInputRange(inputRangeBuilder).setKeywords(keywords).build();
}
Aggregations