/** * Creates a new instance enabling the given repeat toggle modes. * * @param context The context. * @param player The player on which to toggle the repeat mode. * @param repeatToggleModes The toggle modes to enable. */ public RepeatModeActionProvider(Context context, Player player, @RepeatModeUtil.RepeatToggleModes int repeatToggleModes) { this.player = player; this.repeatToggleModes = repeatToggleModes; repeatAllDescription = context.getString(R.string.exo_media_action_repeat_all_description); repeatOneDescription = context.getString(R.string.exo_media_action_repeat_one_description); repeatOffDescription = context.getString(R.string.exo_media_action_repeat_off_description); }
private void requestWritePermissionNotification() { if (permissionNotificationDisplayed) { return; } permissionNotificationDisplayed = true; PendingIntent pendingIntent = RequestStoragePermissionActivity.createPendingIntent(context); String contentTitle = context.getString(R.string.leak_canary_permission_notification_title); CharSequence packageName = context.getPackageName(); String contentText = context.getString(R.string.leak_canary_permission_notification_text, packageName); showNotification(context, contentTitle, contentText, pendingIntent, 0xDEAFBEEF); }
@Provides Account account(Context context) { AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); Account[] accounts = accountManager.getAccountsByType(context.getString(R.string.account_type)); return accounts[0]; }
/** * Set the title dialog. Default is "Permissions Required". */ @NonNull public Builder setTitle(@StringRes int title) { mTitle = mContext.getString(title); return this; }
/** * Set the rationale dialog. Default is * "This app may not work correctly without the requested permissions. * Open the app settings screen to modify app permissions." */ @NonNull public Builder setRationale(@StringRes int rationale) { mRationale = mContext.getString(rationale); return this; }
/** * Set the positive button text, default is {@link android.R.string#ok}. */ @NonNull public Builder setPositiveButton(@StringRes int textId) { mPositiveButtonText = mContext.getString(textId); return this; }
/** * Set the negative button text, default is {@link android.R.string#cancel}. */ @NonNull public Builder setNegativeButton(@StringRes int textId) { mNegativeButtonText = mContext.getString(textId); return this; }
@NonNull private String getTitleValue(@NonNull XmlResourceParser parser, @IntRange(from = 0) int attrIndex) { int titleResource = parser.getAttributeResourceValue(attrIndex, 0); return titleResource == RESOURCE_NOT_FOUND ? parser.getAttributeValue(attrIndex) : context.getString(titleResource); }
private static @Nullable Unbinder parseBindString(Object target, Field field, View source) { BindString bindString = field.getAnnotation(BindString.class); if (bindString == null) { return null; } validateMember(field); int id = bindString.value(); Context context = source.getContext(); Class<?> fieldType = field.getType(); Object value; if (fieldType == String.class) { value = context.getString(id); } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
/** * @param resId the string resource to be used as a rationale * @see #setRationale(String) */ @NonNull public Builder setRationale(@StringRes int resId) { mRationale = mHelper.getContext().getString(resId); return this; }
/** * @see #setPositiveButtonText(String) */ @NonNull public Builder setPositiveButtonText(@StringRes int resId) { mPositiveButtonText = mHelper.getContext().getString(resId); return this; }
/** * @see #setNegativeButtonText(String) */ @NonNull public Builder setNegativeButtonText(@StringRes int resId) { mNegativeButtonText = mHelper.getContext().getString(resId); return this; }
private Notification buildDefaultNotification(Context context) { String title = context.getString(R.string.default_filedownloader_notification_title); String content = context.getString(R.string.default_filedownloader_notification_content); Notification.Builder builder = new Notification.Builder(context, notificationChannelId); builder.setContentTitle(title).setContentText(content) .setSmallIcon(DEFAULT_NOTIFICATION_ID); return builder.build(); }
@Override public IncapableCause filter(Context context, Item item) { if (!needFiltering(context, item)) return null; Point size = PhotoMetadataUtils.getBitmapBound(context.getContentResolver(), item.getContentUri()); if (size.x < mMinWidth || size.y < mMinHeight || item.size > mMaxSize) { return new IncapableCause(IncapableCause.DIALOG, context.getString(R.string.error_gif, mMinWidth, String.valueOf(PhotoMetadataUtils.getSizeInMB(mMaxSize)))); } return null; }
@Override public void onPlayerError(ExoPlaybackException exception) { Callback callback = getCallback(); if (errorMessageProvider != null) { Pair<Integer, String> errorMessage = errorMessageProvider.getErrorMessage(exception); callback.onError(LeanbackPlayerAdapter.this, errorMessage.first, errorMessage.second); } else { callback.onError(LeanbackPlayerAdapter.this, exception.type, context.getString( R.string.lb_media_player_error, exception.type, exception.rendererIndex)); } }
public void testNetworkConnectionErrorMessage() { String expectedMessage = getContext().getString(R.string.exception_message_no_connection); String actualMessage = ErrorMessageFactory.create(getContext(), new NetworkConnectionException()); assertThat(actualMessage, is(equalTo(expectedMessage))); }
public void testUserNotFoundErrorMessage() { String expectedMessage = getContext().getString(R.string.exception_message_user_not_found); String actualMessage = ErrorMessageFactory.create(getContext(), new UserNotFoundException()); assertThat(actualMessage, is(equalTo(expectedMessage))); } }
@Test public void simpleInt() { Target target = new Target(); String expected = context.getString(R.string.hey); Unbinder unbinder = new BindStringTest$Target_ViewBinding(target, context); assertThat(target.actual).isEqualTo(expected); unbinder.unbind(); assertThat(target.actual).isEqualTo(expected); } }
@Test public void getResourcesForApplication_currentApplication() throws Exception { assertThat( packageManager .getResourcesForApplication("org.robolectric") .getString(R.string.app_name)) .isEqualTo(ApplicationProvider.getApplicationContext().getString(R.string.app_name)); }