Search in sources :

Example 86 with IconCompat

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

the class WifiSlice method getLoadingRow.

private ListBuilder.RowBuilder getLoadingRow(CharSequence placeholder) {
    final CharSequence title = mContext.getText(R.string.wifi_empty_list_wifi_on);
    // for aligning to the Wi-Fi AP's name
    final IconCompat emptyIcon = Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
    return new ListBuilder.RowBuilder().setTitleItem(emptyIcon, ListBuilder.ICON_IMAGE).setTitle(placeholder).setSubtitle(title);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder)

Example 87 with IconCompat

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

Example 88 with IconCompat

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

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_contextual_slice_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 89 with IconCompat

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

the class BatteryFixSlice method getSlice.

@Override
public Slice getSlice() {
    final ListBuilder sliceBuilder = new ListBuilder(mContext, BATTERY_FIX_SLICE_URI, ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
    if (!isBatteryTipAvailableFromCache(mContext)) {
        return buildBatteryGoodSlice(sliceBuilder, true);
    }
    final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
    final List<BatteryTip> batteryTips = worker != null ? worker.getResults() : null;
    if (batteryTips == null) {
        // Because we need wait slice background worker return data
        return buildBatteryGoodSlice(sliceBuilder, false);
    }
    for (BatteryTip batteryTip : batteryTips) {
        if (batteryTip.getState() == BatteryTip.StateType.INVISIBLE) {
            continue;
        }
        final Drawable drawable = mContext.getDrawable(batteryTip.getIconId());
        final int iconTintColorId = batteryTip.getIconTintColorId();
        if (iconTintColorId != View.NO_ID) {
            drawable.setColorFilter(new PorterDuffColorFilter(mContext.getResources().getColor(iconTintColorId), PorterDuff.Mode.SRC_IN));
        }
        final IconCompat icon = Utils.createIconWithDrawable(drawable);
        final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, batteryTip.getTitle(mContext));
        sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(batteryTip.getTitle(mContext)).setSubtitle(batteryTip.getSummary(mContext)).setPrimaryAction(primaryAction));
        break;
    }
    return sliceBuilder.build();
}
Also used : SliceBackgroundWorker(com.android.settings.slices.SliceBackgroundWorker) IconCompat(androidx.core.graphics.drawable.IconCompat) Drawable(android.graphics.drawable.Drawable) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip)

Example 90 with IconCompat

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

the class DarkThemeSlice method getSlice.

@Override
public Slice getSlice() {
    final long currentUiSession = FeatureFactory.getFactory(mContext).getSlicesFeatureProvider().getUiSessionToken();
    if (currentUiSession != sActiveUiSession) {
        sActiveUiSession = currentUiSession;
        sKeepSliceShow = false;
    }
    // Next time the Settings displays on screen again this card should no longer persist.
    if (DEBUG) {
        Log.d(TAG, "sKeepSliceShow = " + sKeepSliceShow + ", sSliceClicked = " + sSliceClicked + ", isAvailable = " + isAvailable(mContext));
    }
    if (mPowerManager.isPowerSaveMode() || ((!sKeepSliceShow || !sSliceClicked) && !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);
    final boolean isChecked = Utils.isNightMode(mContext);
    if (sPreChecked != isChecked) {
        // Dark(Night) mode changed and reset the sSliceClicked.
        resetValue(isChecked, false);
    }
    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 */
    isChecked))).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

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