Search in sources :

Example 21 with ListBuilder

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();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) Resources(android.content.res.Resources) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 22 with ListBuilder

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();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 23 with ListBuilder

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();
}
Also used : ColorInt(android.annotation.ColorInt) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 24 with ListBuilder

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();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder)

Example 25 with ListBuilder

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();
}
Also used : SpannableString(android.text.SpannableString) ForegroundColorSpan(android.text.style.ForegroundColorSpan) IconCompat(androidx.core.graphics.drawable.IconCompat) InputRangeBuilder(androidx.slice.builders.ListBuilder.InputRangeBuilder) ListBuilder(androidx.slice.builders.ListBuilder) RoutingSessionInfo(android.media.RoutingSessionInfo)

Aggregations

ListBuilder (androidx.slice.builders.ListBuilder)58 IconCompat (androidx.core.graphics.drawable.IconCompat)47 SliceAction (androidx.slice.builders.SliceAction)34 PendingIntent (android.app.PendingIntent)31 ColorInt (android.annotation.ColorInt)25 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)20 Intent (android.content.Intent)6 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3 Drawable (android.graphics.drawable.Drawable)3 InputRangeBuilder (androidx.slice.builders.ListBuilder.InputRangeBuilder)3 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)3 Resources (android.content.res.Resources)2 SpannableString (android.text.SpannableString)2 SliderPreferenceController (com.android.settings.core.SliderPreferenceController)2 TogglePreferenceController (com.android.settings.core.TogglePreferenceController)2 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)2 SliceBackgroundWorker (com.android.settings.slices.SliceBackgroundWorker)2 StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)2 AlertDialog (android.app.AlertDialog)1 BluetoothAdapter (android.bluetooth.BluetoothAdapter)1