Search in sources :

Example 81 with IconCompat

use of androidx.core.graphics.drawable.IconCompat 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 82 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

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);
    final RowBuilder rowBuilder = new RowBuilder().setTitle(sliceData.getTitle()).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle()));
    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) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 83 with IconCompat

use of androidx.core.graphics.drawable.IconCompat 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 84 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class SliceBuilderUtils method getCopyableAction.

private static SliceAction getCopyableAction(Context context, SliceData sliceData) {
    final PendingIntent intent = getActionIntent(context, SettingsSliceProvider.ACTION_COPY, sliceData);
    final IconCompat icon = IconCompat.createWithResource(context, R.drawable.ic_content_copy_grey600_24dp);
    return SliceAction.create(intent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle());
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) PendingIntent(android.app.PendingIntent)

Example 85 with IconCompat

use of androidx.core.graphics.drawable.IconCompat 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)

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