Search in sources :

Example 41 with IconCompat

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

the class LocationSlice method getSlice.

@Override
public Slice getSlice() {
    final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_signal_location);
    final CharSequence title = mContext.getText(R.string.location_settings_title);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
    final PendingIntent primaryAction = getPrimaryAction();
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder(mContext, CustomSliceRegistry.LOCATION_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setTitleItem(icon, ICON_IMAGE).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)

Example 42 with IconCompat

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

the class UtilsTest method createIconWithDrawable_VectorDrawable.

@Test
public void createIconWithDrawable_VectorDrawable() {
    final VectorDrawable drawable = VectorDrawable.create(mContext.getResources(), R.drawable.ic_settings_accent);
    final IconCompat icon = Utils.createIconWithDrawable(drawable);
    assertThat(icon.getBitmap()).isNotNull();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) VectorDrawable(android.graphics.drawable.VectorDrawable) Test(org.junit.Test)

Example 43 with IconCompat

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

the class UtilsTest method createIconWithDrawable_ColorDrawable.

@Test
public void createIconWithDrawable_ColorDrawable() {
    final ColorDrawable drawable = new ColorDrawable(Color.BLACK);
    final IconCompat icon = Utils.createIconWithDrawable(drawable);
    assertThat(icon.getBitmap()).isNotNull();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) IconCompat(androidx.core.graphics.drawable.IconCompat) Test(org.junit.Test)

Example 44 with IconCompat

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

the class WifiSlice method getHeaderRow.

protected ListBuilder.RowBuilder getHeaderRow(boolean isWifiEnabled, WifiSliceItem wifiSliceItem) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    final String title = mContext.getString(R.string.wifi_settings);
    final PendingIntent primaryAction = getPrimaryAction();
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder.RowBuilder().setTitle(title).setPrimaryAction(primarySliceAction);
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) PendingIntent(android.app.PendingIntent)

Example 45 with IconCompat

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

the class WifiSlice method getWifiSliceItemRow.

protected ListBuilder.RowBuilder getWifiSliceItemRow(WifiSliceItem wifiSliceItem) {
    final CharSequence title = wifiSliceItem.getTitle();
    final IconCompat levelIcon = getWifiSliceItemLevelIcon(wifiSliceItem);
    final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitleItem(levelIcon, ListBuilder.ICON_IMAGE).setTitle(title).setSubtitle(wifiSliceItem.getSummary()).setContentDescription(wifiSliceItem.getContentDescription()).setPrimaryAction(getWifiEntryAction(wifiSliceItem, levelIcon, title));
    final IconCompat endIcon = getEndIcon(wifiSliceItem);
    if (endIcon != null) {
        rowBuilder.addEndItem(endIcon, ListBuilder.ICON_IMAGE);
    }
    return rowBuilder;
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder)

Aggregations

IconCompat (androidx.core.graphics.drawable.IconCompat)102 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)14 Slice (androidx.slice.Slice)14 Drawable (android.graphics.drawable.Drawable)7 ShortcutInfoCompat (androidx.core.content.pm.ShortcutInfoCompat)6 SliceItem (androidx.slice.SliceItem)6 ColorDrawable (android.graphics.drawable.ColorDrawable)5 SpannableString (android.text.SpannableString)4 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)4 Resources (android.content.res.Resources)3 Bitmap (android.graphics.Bitmap)3 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3