Search in sources :

Example 11 with ListBuilder

use of androidx.slice.builders.ListBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ContextualAdaptiveSleepSlice method getSlice.

@Override
public Slice getSlice() {
    final long setupTime = mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE).getLong(PREF_KEY_SETUP_TIME, DEFAULT_SETUP_TIME);
    if (setupTime == DEFAULT_SETUP_TIME) {
        // Set the first setup time.
        mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE).edit().putLong(PREF_KEY_SETUP_TIME, System.currentTimeMillis()).apply();
        return null;
    }
    // 4. Screen Attention is off.
    if (isSettingsAvailable() && !isUserInteracted() && !isRecentlySetup() && !isTurnedOn()) {
        final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_adaptive_sleep);
        final CharSequence title = mContext.getText(R.string.adaptive_sleep_title);
        final CharSequence subtitle = mContext.getText(R.string.adaptive_sleep_contextual_slice_summary);
        final SliceAction pAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
        final ListBuilder listBuilder = new ListBuilder(mContext, CONTEXTUAL_ADAPTIVE_SLEEP_URI, ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED).addRow(new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setSubtitle(subtitle).setPrimaryAction(pAction));
        return listBuilder.build();
    } else {
        return null;
    }
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder)

Example 12 with ListBuilder

use of androidx.slice.builders.ListBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DarkThemeSlice method getSlice.

@Override
public Slice getSlice() {
    final long currentUiSession = FeatureFactory.getFactory(mContext).getSlicesFeatureProvider().getUiSessionToken();
    if (currentUiSession != sActiveUiSession) {
        sActiveUiSession = currentUiSession;
        sKeepSliceShow = false;
    }
    // Dark theme slice will disappear when battery saver is ON.
    if (mPowerManager.isPowerSaveMode() || (!sKeepSliceShow && !isAvailable(mContext))) {
        return new ListBuilder(mContext, CustomSliceRegistry.DARK_THEME_SLICE_URI, ListBuilder.INFINITY).setIsError(true).build();
    }
    sKeepSliceShow = true;
    final PendingIntent toggleAction = getBroadcastIntent(mContext);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.dark_theme);
    return new ListBuilder(mContext, CustomSliceRegistry.DARK_THEME_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(mContext.getText(R.string.dark_theme_slice_title)).setTitleItem(icon, ICON_IMAGE).setSubtitle(mContext.getText(R.string.dark_theme_slice_subtitle)).setPrimaryAction(SliceAction.createToggle(toggleAction, null, /* actionTitle */
    isDarkThemeMode(mContext)))).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 13 with ListBuilder

use of androidx.slice.builders.ListBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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);
    return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(primaryAction).addEndItem(copyableAction)).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 14 with ListBuilder

use of androidx.slice.builders.ListBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceBuilderUtils method buildIntentSlice.

private static Slice buildIntentSlice(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 Set<String> keywords = buildSliceKeywords(sliceData);
    return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle()))).setKeywords(keywords).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 15 with ListBuilder

use of androidx.slice.builders.ListBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothSliceBuilder method getSlice.

/**
 * Return a Bluetooth Slice bound to {@link CustomSliceRegistry#BLUETOOTH_URI}.
 * <p>
 * Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
 * Bluetooth.
 */
public static Slice getSlice(Context context) {
    final boolean isBluetoothEnabled = isBluetoothEnabled();
    final CharSequence title = context.getText(R.string.switch_on_text);
    final IconCompat icon = IconCompat.createWithResource(context, com.android.internal.R.drawable.ic_settings_bluetooth);
    @ColorInt final int color = com.android.settings.Utils.getColorAccent(context).getDefaultColor();
    final PendingIntent toggleAction = getBroadcastIntent(context);
    final PendingIntent primaryAction = getPrimaryAction(context);
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
    final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
    isBluetoothEnabled);
    return new ListBuilder(context, CustomSliceRegistry.BLUETOOTH_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction)).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)

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