use of androidx.core.graphics.drawable.IconCompat in project orgzly-android by orgzly.
the class TemplateChooserActivity method onBookClicked.
@Override
public void onBookClicked(long bookId) {
if (action == null) {
return;
}
if (!action.equals(Intent.ACTION_CREATE_SHORTCUT)) {
return;
}
Book book = dataRepository.getBook(bookId);
if (book == null) {
Toast.makeText(this, R.string.book_does_not_exist_anymore, Toast.LENGTH_SHORT).show();
setResult(RESULT_CANCELED);
finish();
return;
}
String id = "template-" + bookId;
String name = book.getName();
String title = BookUtils.getFragmentTitleForBook(book);
Intent launchIntent = ShareActivity.createNewNoteInNotebookIntent(this, bookId);
IconCompat icon = createIcon();
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(this, id).setShortLabel(name).setLongLabel(title).setIcon(icon).setIntent(launchIntent).build();
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
finish();
}
use of androidx.core.graphics.drawable.IconCompat in project orgzly-android by orgzly.
the class BookChooserActivity method onBookClicked.
@Override
public void onBookClicked(long bookId) {
if (BuildConfig.LOG_DEBUG)
LogUtils.d(TAG, bookId, action);
if (action != null && action.equals(Intent.ACTION_CREATE_SHORTCUT)) {
// Get Book by its ID
Book book = dataRepository.getBook(bookId);
if (book == null) {
Toast.makeText(this, R.string.book_does_not_exist_anymore, Toast.LENGTH_SHORT).show();
setResult(RESULT_CANCELED);
finish();
return;
}
String id = "notebook-" + bookId;
String name = book.getName();
String title = BookUtils.getFragmentTitleForBook(book);
Intent launchIntent = createLaunchIntent(book);
IconCompat icon = createIcon();
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(this, id).setShortLabel(name).setLongLabel(title).setIcon(icon).setIntent(launchIntent).build();
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
finish();
}
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ContextualCardFeatureProviderImplTest method buildSlice.
private Slice buildSlice(Uri sliceUri, String packageName) {
final Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, packageName);
final Intent intent = new Intent("action");
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
final PendingIntent pendingIntent = spy(PendingIntent.getActivity(mContext, 0, /* requestCode */
intent, 0));
doReturn(intent).when(pendingIntent).getIntent();
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.empty_icon);
final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, "title");
return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle("title").setPrimaryAction(action)).build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageSliceTest method getSlice_hasSim_shouldBeCorrectSliceContent.
@Test
public void getSlice_hasSim_shouldBeCorrectSliceContent() {
ShadowDataUsageUtils.HAS_SIM = true;
doReturn(DATA_USAGE_TITLE).when(mDataUsageSlice).getDataUsageText(any());
doReturn(DATA_USAGE_SUMMARY).when(mDataUsageSlice).getCycleTime(any());
final Slice slice = mDataUsageSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.data_usage_summary_title));
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_data_usage);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageSliceTest method getSlice_shouldBeCorrectSliceContent.
@Test
public void getSlice_shouldBeCorrectSliceContent() {
final PrivateStorageInfo info = new PrivateStorageInfo(100L, 600L);
doReturn(info).when(mStorageSlice).getPrivateStorageInfo();
doReturn(USED_BYTES_TEXT).when(mStorageSlice).getStorageUsedText(any());
doReturn(SUMMARY_TEXT).when(mStorageSlice).getStorageSummaryText(any());
final Slice slice = mStorageSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_label));
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_homepage_storage);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
}
Aggregations