Search in sources :

Example 61 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(title).setSubtitle(summary).addEndItem(toggleSliceAction).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) PendingIntent(android.app.PendingIntent)

Example 62 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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);
    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())).addEndItem(sliceAction)).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 63 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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);
    return new ListBuilder(context, data.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setTitleItem(icon, ListBuilder.ICON_IMAGE).setSubtitle(subtitle).setPrimaryAction(primaryAction)).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) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 64 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 final 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();
    }
    return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addInputRange(new InputRangeBuilder().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(primaryAction).setMax(sliderController.getMax()).setMin(sliderController.getMin()).setValue(cur).setInputAction(actionIntent)).setKeywords(keywords).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) InputRangeBuilder(androidx.slice.builders.ListBuilder.InputRangeBuilder) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) SliderPreferenceController(com.android.settings.core.SliderPreferenceController)

Example 65 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class FlashlightSlice method getSlice.

@Override
public Slice getSlice() {
    if (!isFlashlightAvailable(mContext)) {
        return null;
    }
    final PendingIntent toggleAction = getBroadcastIntent(mContext);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_signal_flashlight);
    return new ListBuilder(mContext, CustomSliceRegistry.FLASHLIGHT_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(mContext.getText(R.string.power_flashlight)).setTitleItem(icon, ICON_IMAGE).setPrimaryAction(SliceAction.createToggle(toggleAction, null, isFlashlightEnabled(mContext)))).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)

Aggregations

IconCompat (androidx.core.graphics.drawable.IconCompat)103 ListBuilder (androidx.slice.builders.ListBuilder)55 PendingIntent (android.app.PendingIntent)42 SliceAction (androidx.slice.builders.SliceAction)39 Test (org.junit.Test)25 ColorInt (android.annotation.ColorInt)22 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)21 SliceMetadata (androidx.slice.SliceMetadata)18 SliceAction (androidx.slice.core.SliceAction)18 Intent (android.content.Intent)15 Slice (androidx.slice.Slice)14 Drawable (android.graphics.drawable.Drawable)7 ShortcutInfoCompat (androidx.core.content.pm.ShortcutInfoCompat)7 SliceItem (androidx.slice.SliceItem)6 ColorDrawable (android.graphics.drawable.ColorDrawable)5 Bitmap (android.graphics.Bitmap)4 SpannableString (android.text.SpannableString)4 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)4 Resources (android.content.res.Resources)3 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3