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();
}
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();
}
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);
}
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);
}
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();
}
Aggregations