Search in sources :

Example 26 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Signal-Android by signalapp.

the class ConversationParentFragment method addIconToHomeScreen.

private static void addIconToHomeScreen(@NonNull Context context, @NonNull Bitmap bitmap, @NonNull Recipient recipient) {
    IconCompat icon = IconCompat.createWithAdaptiveBitmap(bitmap);
    String name = recipient.isSelf() ? context.getString(R.string.note_to_self) : recipient.getDisplayName(context);
    ShortcutInfoCompat shortcutInfoCompat = new ShortcutInfoCompat.Builder(context, recipient.getId().serialize() + '-' + System.currentTimeMillis()).setShortLabel(name).setIcon(icon).setIntent(ShortcutLauncherActivity.createIntent(context, recipient.getId())).build();
    Intent callbackIntent = new Intent(ACTION_PINNED_SHORTCUT);
    PendingIntent shortcutPinnedCallback = PendingIntent.getBroadcast(context, REQUEST_CODE_PIN_SHORTCUT, callbackIntent, 0);
    ShortcutManagerCompat.requestPinShortcut(context, shortcutInfoCompat, shortcutPinnedCallback.getIntentSender());
    bitmap.recycle();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SpannableStringBuilder(android.text.SpannableStringBuilder) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SpannableString(android.text.SpannableString) PendingIntent(android.app.PendingIntent) ShortcutInfoCompat(androidx.core.content.pm.ShortcutInfoCompat)

Example 27 with IconCompat

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

the class BatteryFixSlice method buildBatteryGoodSlice.

private Slice buildBatteryGoodSlice(ListBuilder sliceBuilder, boolean isError) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_battery_status_good_24dp);
    final String title = mContext.getString(R.string.power_usage_summary_title);
    final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
    sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(primaryAction)).setIsError(isError);
    return sliceBuilder.build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 28 with IconCompat

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

the class BluetoothDevicesSlice method getBluetoothOffHeader.

private ListBuilder.RowBuilder getBluetoothOffHeader() {
    final Drawable drawable = mContext.getDrawable(R.drawable.ic_bluetooth_disabled);
    final int tint = Utils.getDisabled(mContext, Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal));
    drawable.setTint(tint);
    final IconCompat icon = Utils.createIconWithDrawable(drawable);
    final CharSequence title = mContext.getText(R.string.bluetooth_devices_card_off_title);
    final CharSequence summary = mContext.getText(R.string.bluetooth_devices_card_off_summary);
    final Intent intent = new Intent(getUri().toString()).setClass(mContext, SliceBroadcastReceiver.class).putExtra(EXTRA_ENABLE_BLUETOOTH, true);
    final SliceAction action = SliceAction.create(PendingIntent.getBroadcast(mContext, 0, /* requestCode */
    intent, PendingIntent.FLAG_IMMUTABLE), icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setSubtitle(summary).setPrimaryAction(action);
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) Drawable(android.graphics.drawable.Drawable) SliceAction(androidx.slice.builders.SliceAction) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) SliceBroadcastReceiver(com.android.settings.slices.SliceBroadcastReceiver)

Example 29 with IconCompat

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

the class BluetoothDevicesSlice method getPairNewDeviceAction.

private SliceAction getPairNewDeviceAction() {
    final Drawable drawable = mContext.getDrawable(R.drawable.ic_add_24dp);
    drawable.setTint(Utils.getColorAccentDefaultColor(mContext));
    final IconCompat icon = Utils.createIconWithDrawable(drawable);
    final String title = mContext.getString(R.string.bluetooth_pairing_pref_title);
    final Intent intent = new SubSettingLauncher(mContext).setDestination(BluetoothPairingDetail.class.getName()).setTitleRes(R.string.bluetooth_pairing_page_title).setSourceMetricsCategory(SettingsEnums.BLUETOOTH_PAIRING).toIntent();
    final PendingIntent pi = PendingIntent.getActivity(mContext, intent.hashCode(), intent, PendingIntent.FLAG_IMMUTABLE);
    return SliceAction.createDeeplink(pi, icon, ListBuilder.ICON_IMAGE, title);
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) IconCompat(androidx.core.graphics.drawable.IconCompat) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 30 with IconCompat

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

the class FaceSetupSlice method getSlice.

@Override
public Slice getSlice() {
    mFaceManager = Utils.getFaceManagerOrNull(mContext);
    if (mFaceManager == null) {
        return new ListBuilder(mContext, CustomSliceRegistry.FACE_ENROLL_SLICE_URI, ListBuilder.INFINITY).setIsError(true).build();
    }
    final int userId = UserHandle.myUserId();
    final boolean hasEnrolledTemplates = mFaceManager.hasEnrolledTemplates(userId);
    final int shouldReEnroll = FaceSetupSlice.getReEnrollSetting(mContext, userId);
    CharSequence title = "";
    CharSequence subtitle = "";
    // stay the same.
    if (!hasEnrolledTemplates) {
        title = mContext.getText(R.string.security_settings_face_settings_enroll);
        subtitle = mContext.getText(R.string.security_settings_face_settings_context_subtitle);
    } else if (shouldReEnroll == FACE_RE_ENROLL_SUGGESTED) {
        title = mContext.getText(R.string.security_settings_face_enroll_should_re_enroll_title);
        subtitle = mContext.getText(R.string.security_settings_face_enroll_should_re_enroll_subtitle);
    } else if (shouldReEnroll == FACE_RE_ENROLL_REQUIRED) {
        title = mContext.getText(R.string.security_settings_face_enroll_must_re_enroll_title);
        subtitle = mContext.getText(R.string.security_settings_face_enroll_must_re_enroll_subtitle);
    } else {
        return new ListBuilder(mContext, CustomSliceRegistry.FACE_ENROLL_SLICE_URI, ListBuilder.INFINITY).setIsError(true).build();
    }
    final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.FACE_ENROLL_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_face_24dp);
    return listBuilder.addRow(buildRowBuilder(title, subtitle, icon, mContext, getIntent())).build();
}
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