Search in sources :

Example 76 with IconCompat

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

the class WifiCallingSliceHelper method getWifiCallingPreferenceSlice.

/**
 * Returns actionable wifi calling preference slice.
 *
 * @param isWifiOnlySupported adds row for wifi only if this is true
 * @param currentWfcPref      current Preference {@link ImsConfig}
 * @param sliceUri            sliceUri
 * @return Slice for actionable wifi calling preference settings
 */
private Slice getWifiCallingPreferenceSlice(boolean isWifiOnlySupported, int currentWfcPref, Uri sliceUri) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
    // Top row shows information on current preference state
    ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
    listBuilder.setHeader(new ListBuilder.HeaderBuilder().setTitle(mContext.getText(R.string.wifi_calling_mode_title)).setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref)).setPrimaryAction(SliceAction.createDeeplink(getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY), icon, ListBuilder.ICON_IMAGE, mContext.getText(R.string.wifi_calling_mode_title))));
    if (isWifiOnlySupported) {
        listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_wifi_only_summary, ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY, currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
    }
    listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_wifi_preferred_summary, ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED, currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED));
    listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_cellular_preferred_summary, ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED, currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
    return listBuilder.build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) ListBuilder(androidx.slice.builders.ListBuilder)

Example 77 with IconCompat

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

the class SliceTester method testSettingsCopyableSlice.

/**
 * Test the copyable slice, including:
 * - No intent
 * - Correct title
 * - Correct intent
 * - Correct keywords
 * - TTL
 * - Color
 */
public static void testSettingsCopyableSlice(Context context, Slice slice, SliceData sliceData) {
    final SliceMetadata metadata = SliceMetadata.from(context, slice);
    final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
    final int color = colorItem.getInt();
    assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedIcon = IconCompat.createWithResource(context, sliceData.getIconResource());
    assertThat(expectedIcon.toString()).isEqualTo(primaryAction.getIcon().toString());
    final long sliceTTL = metadata.getExpiry();
    assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
    // Check primary intent
    final PendingIntent primaryPendingIntent = primaryAction.getAction();
    assertThat(primaryPendingIntent).isEqualTo(SliceBuilderUtils.getContentPendingIntent(context, sliceData));
    assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
    assertKeywords(metadata, sliceData);
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) SliceItem(androidx.slice.SliceItem) PendingIntent(android.app.PendingIntent)

Example 78 with IconCompat

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

the class SliceHalfCardRendererHelperTest method buildSlice.

private Slice buildSlice() {
    final String title = "test_title";
    final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
    final PendingIntent pendingIntent = PendingIntent.getActivity(mActivity, title.hashCode(), /* requestCode */
    new Intent("test action"), 0);
    final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
    return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(action)).build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 79 with IconCompat

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

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.bluetooth_settings);
    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)

Example 80 with IconCompat

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

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