Search in sources :

Example 36 with SliceAction

use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.

the class MobileDataSlice method getSlice.

@Override
public Slice getSlice() {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_network_cell);
    final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
    @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
    // Return null until we can show a disabled-action Slice, blaming Airplane mode.
    if (isAirplaneModeEnabled()) {
        return null;
    }
    // Return null until we can show a disabled-action Slice.
    if (!isMobileDataAvailable()) {
        return null;
    }
    final CharSequence summary = getSummary();
    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 */
    isMobileDataEnabled());
    final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction);
    if (!Utils.isSettingsIntelligence(mContext)) {
        rowBuilder.setSubtitle(summary);
    }
    final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder);
    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) PendingIntent(android.app.PendingIntent)

Example 37 with SliceAction

use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.

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);
    final RowBuilder rowBuilder = new RowBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(primaryAction).addEndItem(copyableAction);
    if (!Utils.isSettingsIntelligence(context)) {
        rowBuilder.setSubtitle(subtitleText);
    }
    return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder).setKeywords(keywords).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 38 with SliceAction

use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.

the class SliceBuilderUtils method buildToggleSlice.

private static Slice buildToggleSlice(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 TogglePreferenceController toggleController = (TogglePreferenceController) controller;
    final SliceAction sliceAction = getToggleAction(context, sliceData, toggleController.isChecked());
    final Set<String> keywords = buildSliceKeywords(sliceData);
    final RowBuilder rowBuilder = new RowBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle())).addEndItem(sliceAction);
    if (!Utils.isSettingsIntelligence(context)) {
        rowBuilder.setSubtitle(subtitleText);
    }
    return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(rowBuilder).setKeywords(keywords).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder) TogglePreferenceController(com.android.settings.core.TogglePreferenceController)

Example 39 with SliceAction

use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.

the class WifiSlice method getListBuilder.

private ListBuilder getListBuilder(boolean isWifiEnabled, WifiSliceItem wifiSliceItem) {
    final PendingIntent toggleAction = getBroadcastIntent(mContext);
    final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
    isWifiEnabled);
    final ListBuilder builder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED).setKeywords(getKeywords()).addRow(getHeaderRow(isWifiEnabled, wifiSliceItem)).addAction(toggleSliceAction);
    return builder;
}
Also used : SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 40 with SliceAction

use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.

the class BluetoothDevicesSlice method getBluetoothOnHeader.

private ListBuilder.RowBuilder getBluetoothOnHeader() {
    final Drawable drawable = mContext.getDrawable(com.android.internal.R.drawable.ic_settings_bluetooth);
    drawable.setTint(Utils.getColorAccentDefaultColor(mContext));
    final IconCompat icon = Utils.createIconWithDrawable(drawable);
    final CharSequence title = mContext.getText(R.string.bluetooth_devices);
    final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext, 0, /* requestCode */
    getIntent(), PendingIntent.FLAG_IMMUTABLE);
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(primarySliceAction).addEndItem(getPairNewDeviceAction());
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) Drawable(android.graphics.drawable.Drawable) SliceAction(androidx.slice.builders.SliceAction) PendingIntent(android.app.PendingIntent)

Aggregations

SliceAction (androidx.slice.builders.SliceAction)46 IconCompat (androidx.core.graphics.drawable.IconCompat)39 ListBuilder (androidx.slice.builders.ListBuilder)37 PendingIntent (android.app.PendingIntent)32 ColorInt (android.annotation.ColorInt)18 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)16 Intent (android.content.Intent)10 Drawable (android.graphics.drawable.Drawable)6 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3 InputRangeBuilder (androidx.slice.builders.ListBuilder.InputRangeBuilder)3 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 SliceBroadcastReceiver (com.android.settings.slices.SliceBroadcastReceiver)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 SubscriptionManager (android.telephony.SubscriptionManager)1 SpannableString (android.text.SpannableString)1