use of androidx.core.graphics.drawable.IconCompat in project Signal-Android by WhisperSystems.
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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiSlice method getHeaderRow.
private ListBuilder getHeaderRow(boolean isWifiEnabled) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
final String title = mContext.getString(R.string.wifi_settings);
final PendingIntent toggleAction = getBroadcastIntent(mContext);
final PendingIntent primaryAction = getPrimaryAction();
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
isWifiEnabled);
return new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED).setKeywords(getKeywords()).addRow(new ListBuilder.RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction));
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothSliceBuilderTest method getBluetoothSlice_correctSliceContent.
@Test
public void getBluetoothSlice_correctSliceContent() {
final Slice BluetoothSlice = BluetoothSliceBuilder.getSlice(mContext);
final SliceMetadata metadata = SliceMetadata.from(mContext, BluetoothSlice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LocationSliceTest method getLocationSlice_correctSliceContent.
@Test
public void getLocationSlice_correctSliceContent() {
final Slice LocationSlice = new LocationSlice(mContext).getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, LocationSlice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.location_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).isEmpty();
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_signal_location);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceInfoSliceTest method getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent.
@Test
public void getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent() {
final String phoneNumber = "1111111111";
doReturn(mSubscriptionInfo).when(mDeviceInfoSlice).getFirstSubscriptionInfo();
doReturn(phoneNumber).when(mDeviceInfoSlice).getPhoneNumber();
final Slice slice = mDeviceInfoSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_info_outline_24dp);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
final List<SliceItem> sliceItems = slice.getItems();
SliceTester.assertAnySliceItemContainsTitle(sliceItems, phoneNumber);
}
Aggregations