use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class WifiCallingSliceHelper method getWifiCallingSlice.
/**
* Builds a toggle slice where the intent takes you to the wifi calling page and the toggle
* enables/disables wifi calling.
*/
private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled, int subId) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
final Resources res = getResourcesForSubId(subId);
return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext)).addRow(new RowBuilder().setTitle(res.getText(R.string.wifi_calling_settings_title)).addEndItem(SliceAction.createToggle(getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED), null, /* actionTitle */
isWifiCallingEnabled)).setPrimaryAction(SliceAction.createDeeplink(getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY), icon, ListBuilder.ICON_IMAGE, res.getText(R.string.wifi_calling_settings_title)))).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class WifiCallingSliceHelper method getNonActionableWifiCallingSlice.
/**
* Returns Slice with the title and subtitle provided as arguments with wifi signal Icon.
*
* @param title Title of the slice
* @param subtitle Subtitle of the slice
* @param sliceUri slice uri
* @return Slice with title and subtitle
*/
private Slice getNonActionableWifiCallingSlice(CharSequence title, CharSequence subtitle, Uri sliceUri, PendingIntent primaryActionIntent) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
final RowBuilder rowBuilder = new RowBuilder().setTitle(title).setPrimaryAction(SliceAction.createDeeplink(primaryActionIntent, icon, ListBuilder.SMALL_IMAGE, title));
if (!Utils.isSettingsIntelligence(mContext)) {
rowBuilder.setSubtitle(subtitle);
}
return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext)).addRow(rowBuilder).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class AlwaysOnDisplaySlice method getSlice.
@Override
public Slice getSlice() {
if (!mConfig.alwaysOnAvailableForUser(MY_USER)) {
return null;
}
final PendingIntent toggleAction = getBroadcastIntent(mContext);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final boolean isChecked = mConfig.alwaysOnEnabled(MY_USER);
return new ListBuilder(mContext, CustomSliceRegistry.ALWAYS_ON_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(mContext.getText(R.string.doze_always_on_title)).setSubtitle(mContext.getText(R.string.doze_always_on_summary)).setPrimaryAction(SliceAction.createToggle(toggleAction, null, /* actionTitle */
isChecked))).build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class MediaOutputIndicatorSlice method getSlice.
@Override
public Slice getSlice() {
if (!isVisible()) {
return new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setIsError(true).build();
}
final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
final CharSequence title = mContext.getString(R.string.media_output_label_title, Utils.getApplicationLabel(mContext, getWorker().getPackageName()));
final SliceAction primarySliceAction = SliceAction.create(getBroadcastIntent(mContext), icon, ListBuilder.ICON_IMAGE, title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
// To set an empty icon to indent the row
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(title).setTitleItem(createEmptyIcon(), ListBuilder.ICON_IMAGE).setSubtitle(getWorker().getCurrentConnectedMediaDevice().getName()).setPrimaryAction(primarySliceAction));
return listBuilder.build();
}
use of androidx.slice.builders.ListBuilder in project android_packages_apps_Settings by omnirom.
the class RemoteMediaSlice method getSlice.
@Override
public Slice getSlice() {
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
if (getWorker() == null) {
Log.e(TAG, "Unable to get the slice worker.");
return listBuilder.build();
}
if (mRouterManager == null) {
mRouterManager = MediaRouter2Manager.getInstance(mContext);
}
// Only displaying remote devices
final List<RoutingSessionInfo> infos = getWorker().getActiveRemoteMediaDevice();
if (infos.isEmpty()) {
Log.d(TAG, "No active remote media device");
return listBuilder.build();
}
final CharSequence castVolume = mContext.getText(R.string.remote_media_volume_option_title);
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_volume_remote);
// To create an empty icon to indent the row
final IconCompat emptyIcon = createEmptyIcon();
for (RoutingSessionInfo info : infos) {
final int maxVolume = info.getVolumeMax();
if (maxVolume <= 0) {
Log.d(TAG, "Unable to add Slice. " + info.getName() + ": max volume is " + maxVolume);
continue;
}
if (!getWorker().shouldEnableVolumeSeekBar(info)) {
// There is no disable state. We hide it directly.
Log.d(TAG, "Unable to add Slice. " + info.getName() + ": This is a group session");
continue;
}
final CharSequence appName = Utils.getApplicationLabel(mContext, info.getClientPackageName());
final CharSequence outputTitle = mContext.getString(R.string.media_output_label_title, appName);
listBuilder.addInputRange(new InputRangeBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(castVolume).setInputAction(getSliderInputAction(info.getId().hashCode(), info.getId())).setPrimaryAction(getSoundSettingAction(castVolume, icon, info.getId())).setMax(maxVolume).setValue(info.getVolume()));
final boolean isMediaOutputDisabled = getWorker().shouldDisableMediaOutput(info.getClientPackageName());
final SpannableString spannableTitle = new SpannableString(TextUtils.isEmpty(appName) ? "" : appName);
spannableTitle.setSpan(new ForegroundColorSpan(Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorSecondary)), 0, spannableTitle.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
listBuilder.addRow(new ListBuilder.RowBuilder().setTitle(isMediaOutputDisabled ? spannableTitle : outputTitle).setSubtitle(info.getName()).setTitleItem(emptyIcon, ListBuilder.ICON_IMAGE).setPrimaryAction(getMediaOutputDialogAction(info, isMediaOutputDisabled)));
}
return listBuilder.build();
}
Aggregations