androidx.annotation.StringRes Java Examples
The following examples show how to use
androidx.annotation.StringRes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DialogService.java From Twire with GNU General Public License v3.0 | 6 votes |
public static MaterialDialog getChooseCardSizeDialog(Activity activity, @StringRes int dialogTitle, String currentlySelected, MaterialDialog.ListCallbackSingleChoice callbackSingleChoice) { int indexOfPage = 0; String[] sizeTitles = activity.getResources().getStringArray(R.array.CardSizes); for (int i = 0; i < sizeTitles.length; i++) { if (sizeTitles[i].equals(currentlySelected)) { indexOfPage = i; break; } } return getBaseThemedDialog(activity) .title(dialogTitle) .itemsCallbackSingleChoice(indexOfPage, callbackSingleChoice) .items(sizeTitles) .positiveText(R.string.done) .build(); }
Example #2
Source File: CareMultiModelPopup.java From arcusandroid with Apache License 2.0 | 6 votes |
@NonNull public static CareMultiModelPopup newInstance(List<String> modelIDs, @StringRes @Nullable Integer titleRes, @Nullable List<String> preSelected, @Nullable Boolean allowMultipleSelections) { CareMultiModelPopup fragment = new CareMultiModelPopup(); ArrayList<String> modelsSelectedList = new ArrayList<>(); if (preSelected != null) { modelsSelectedList.addAll(preSelected); } ArrayList<String> modelAddressList = new ArrayList<>(); if (modelIDs != null) { modelAddressList.addAll(modelIDs); } Bundle bundle = new Bundle(2); bundle.putInt(POPUP_TITLE, titleRes == null ? R.string.choose_devices_text : titleRes); bundle.putStringArrayList(MODELS_SELECTED, modelsSelectedList); bundle.putStringArrayList(MODEL_LIST, modelAddressList); bundle.putBoolean(MULTIPLE_MODELS_SELECTABLE, Boolean.TRUE.equals(allowMultipleSelections)); fragment.setArguments(bundle); return fragment; }
Example #3
Source File: SortedMultiModelPopup.java From arcusandroid with Apache License 2.0 | 6 votes |
@NonNull public static SortedMultiModelPopup newInstance( List<String> modelIDs, @StringRes @Nullable Integer titleRes, @Nullable List<String> preSelected, @Nullable Boolean allowMultipleSelections ) { SortedMultiModelPopup fragment = new SortedMultiModelPopup(); ArrayList<String> modelsSelectedList = new ArrayList<>(); if (preSelected != null) { modelsSelectedList.addAll(preSelected); } ArrayList<String> modelAddressList = new ArrayList<>(); if (modelIDs != null) { modelAddressList.addAll(modelIDs); } Bundle bundle = new Bundle(2); bundle.putInt(POPUP_TITLE, titleRes == null ? R.string.choose_devices_text : titleRes); bundle.putStringArrayList(MODELS_SELECTED, modelsSelectedList); bundle.putStringArrayList(MODEL_LIST, modelAddressList); bundle.putBoolean(MULTIPLE_MODELS_SELECTABLE, Boolean.TRUE.equals(allowMultipleSelections)); fragment.setArguments(bundle); return fragment; }
Example #4
Source File: TupleSelectorPopup.java From arcusandroid with Apache License 2.0 | 6 votes |
public static TupleSelectorPopup newInstance( List<StringPair> selections, @StringRes int title, @Nullable String selected, @Nullable Boolean showDivider ) { TupleSelectorPopup popup = new TupleSelectorPopup(); Bundle bundle = new Bundle(4); ArrayList<StringPair> values; if (selections == null) { values = new ArrayList<>(); } else { values = new ArrayList<>(selections); } bundle.putSerializable(SELECTIONS, values); bundle.putInt(TITLE, title); bundle.putString(SELECTED, selected); bundle.putBoolean(DIVIDER, Boolean.TRUE.equals(showDivider)); popup.setArguments(bundle); return popup; }
Example #5
Source File: IdentityUtil.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private static @Nullable String getPluralizedIdentityDescription(@NonNull Context context, @NonNull List<Recipient> recipients, @StringRes int resourceOne, @StringRes int resourceTwo, @StringRes int resourceMany) { if (recipients.isEmpty()) return null; if (recipients.size() == 1) { String name = recipients.get(0).toShortString(context); return context.getString(resourceOne, name); } else { String firstName = recipients.get(0).toShortString(context); String secondName = recipients.get(1).toShortString(context); if (recipients.size() == 2) { return context.getString(resourceTwo, firstName, secondName); } else { int othersCount = recipients.size() - 2; String nMore = context.getResources().getQuantityString(R.plurals.identity_others, othersCount, othersCount); return context.getString(resourceMany, firstName, secondName, nMore); } } }
Example #6
Source File: EditProfileFragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public static EditProfileFragment create(boolean excludeSystem, Intent nextIntent, boolean displayUsernameField, @StringRes int nextButtonText) { EditProfileFragment fragment = new EditProfileFragment(); Bundle args = new Bundle(); args.putBoolean(EXCLUDE_SYSTEM, excludeSystem); args.putParcelable(NEXT_INTENT, nextIntent); args.putBoolean(DISPLAY_USERNAME, displayUsernameField); args.putInt(NEXT_BUTTON_TEXT, nextButtonText); fragment.setArguments(args); return fragment; }
Example #7
Source File: MainActivity.java From FridaHooker with GNU General Public License v2.0 | 5 votes |
private AlertDialog.Builder makeMessageDialog(@StringRes int title, @StringRes int message) { AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this); dialog.setTitle(title); dialog.setMessage(message); dialog.setNegativeButton(R.string.close, (dialog1, which) -> {}); return dialog; }
Example #8
Source File: MediaOverviewActivity.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static @StringRes int sortingToString(@NonNull Sorting sorting) { switch (sorting) { case Oldest : return R.string.MediaOverviewActivity_Oldest; case Newest : return R.string.MediaOverviewActivity_Newest; case Largest : return R.string.MediaOverviewActivity_Storage_used; default : throw new AssertionError(); } }
Example #9
Source File: TabLayout.java From a with GNU General Public License v3.0 | 5 votes |
/** * Set the text displayed on this tab. Text may be truncated if there is not room to display * the entire string. * * @param resId A resource ID referring to the text that should be displayed * @return The current instance for call chaining */ @NonNull public Tab setText(@StringRes int resId) { if (mParent == null) { throw new IllegalArgumentException("Tab not attached to a TabLayout"); } return setText(mParent.getResources().getText(resId)); }
Example #10
Source File: AboutFragment.java From a with GNU General Public License v3.0 | 5 votes |
void setActionBarTitle(@StringRes int resId) { if (getActivity() != null) { ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (actionBar != null) actionBar.setTitle(resId); } }
Example #11
Source File: BaseKbsPinFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private @StringRes int resolveKeyboardToggleText(@NonNull PinKeyboardType keyboard) { if (keyboard == PinKeyboardType.ALPHA_NUMERIC) { return R.string.BaseKbsPinFragment__create_numeric_pin; } else { return R.string.BaseKbsPinFragment__create_alphanumeric_pin; } }
Example #12
Source File: NotificationUtil.java From MediaSDK with Apache License 2.0 | 5 votes |
/** @deprecated Use {@link #createNotificationChannel(Context, String, int, int, int)}. */ @Deprecated public static void createNotificationChannel( Context context, String id, @StringRes int nameResourceId, @Importance int importance) { createNotificationChannel( context, id, nameResourceId, /* descriptionResourceId= */ 0, importance); }
Example #13
Source File: SettingNestedFragment.java From a with GNU General Public License v3.0 | 5 votes |
void setActionBarTitle(@StringRes int resId) { if (getActivity() != null) { ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (actionBar != null) actionBar.setTitle(resId); } }
Example #14
Source File: SingleRecipientNotificationBuilder.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@StringRes private static int replyMethodLongDescription(@NonNull ReplyMethod replyMethod) { switch (replyMethod) { case GroupMessage: return R.string.MessageNotifier_reply; case SecureMessage: return R.string.MessageNotifier_signal_message; case UnsecuredSmsMessage: return R.string.MessageNotifier_unsecured_sms; default: return R.string.MessageNotifier_reply; } }
Example #15
Source File: StickerManagementAdapter.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
StickerSection(@NonNull String tag, @StringRes int titleResId, @StringRes int emptyResId, @NonNull List<StickerPackRecord> records, int offset) { super(offset); this.tag = tag; this.titleResId = titleResId; this.emptyResId = emptyResId; this.records = records; }
Example #16
Source File: RegistrationLockFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private @StringRes static int resolveKeyboardToggleText(@NonNull PinKeyboardType keyboard) { if (keyboard == PinKeyboardType.ALPHA_NUMERIC) { return R.string.RegistrationLockFragment__enter_alphanumeric_pin; } else { return R.string.RegistrationLockFragment__enter_numeric_pin; } }
Example #17
Source File: ViewOnceMessageView.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static @StringRes int getDescriptionId(@NonNull MmsMessageRecord messageRecord) { Slide thumbnailSlide = messageRecord.getSlideDeck().getThumbnailSlide(); if (thumbnailSlide != null && MediaUtil.isVideoType(thumbnailSlide.getContentType())) { return R.string.RevealableMessageView_view_video; } return R.string.RevealableMessageView_view_photo; }
Example #18
Source File: CallNotificationBuilder.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static NotificationCompat.Action getActivityNotificationAction(@NonNull Context context, @NonNull String action, @DrawableRes int iconResId, @StringRes int titleResId) { Intent intent = new Intent(context, WebRtcCallActivity.class); intent.setAction(action); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent); }
Example #19
Source File: DialogService.java From Twire with GNU General Public License v3.0 | 5 votes |
public static MaterialDialog getChooseChatSizeDialog(Activity activity, @StringRes int dialogTitle, @ArrayRes int array, int currentSize, MaterialDialog.ListCallbackSingleChoice callbackSingleChoice) { int indexOfPage = currentSize - 1; String[] sizeTitles = activity.getResources().getStringArray(array); return getBaseThemedDialog(activity) .title(dialogTitle) .itemsCallbackSingleChoice(indexOfPage, callbackSingleChoice) .items(sizeTitles) .positiveText(R.string.done) .build(); }
Example #20
Source File: SignalPinReminders.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public static @StringRes int getReminderString(long interval) { Integer stringRes = STRINGS.get(interval); if (stringRes != null) { return stringRes; } else { Log.w(TAG, "Couldn't find a string for interval " + interval); return R.string.SignalPinReminders_well_remind_you_again_later; } }
Example #21
Source File: DownloadService.java From MediaSDK with Apache License 2.0 | 5 votes |
/** @deprecated Use {@link #DownloadService(int, long, String, int, int)}. */ @Deprecated protected DownloadService( int foregroundNotificationId, long foregroundNotificationUpdateInterval, @Nullable String channelId, @StringRes int channelNameResourceId) { this( foregroundNotificationId, foregroundNotificationUpdateInterval, channelId, channelNameResourceId, /* channelDescriptionResourceId= */ 0); }
Example #22
Source File: AlertDialogsHelper.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
public static AlertDialog getInsertTextDialog(ThemedActivity activity, EditText editText, @StringRes int title) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle()); View dialogLayout = activity.getLayoutInflater().inflate(com.alienpants.leafpicrevived.R.layout.dialog_insert_text, null); TextView textViewTitle = dialogLayout.findViewById(R.id.rename_title); ((CardView) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.dialog_chose_provider_title)).setCardBackgroundColor(activity.getCardBackgroundColor()); textViewTitle.setBackgroundColor(activity.getPrimaryColor()); textViewTitle.setText(title); ThemeHelper.setCursorColor(editText, activity.getTextColor()); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editText.setLayoutParams(layoutParams); editText.setSingleLine(true); editText.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_IN); editText.setTextColor(activity.getTextColor()); try { Field f = TextView.class.getDeclaredField("mCursorDrawableRes"); f.setAccessible(true); f.set(editText, null); } catch (Exception ignored) { } ((RelativeLayout) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.container_edit_text)).addView(editText); dialogBuilder.setView(dialogLayout); return dialogBuilder.create(); }
Example #23
Source File: VideoStorageFragment.java From arcusandroid with Apache License 2.0 | 5 votes |
protected AlertPopup createPopup( @StringRes int description, @StringRes int topButtonText, Runnable topClickAction ) { AlertPopup popup = AlertPopup.newInstance( getString(R.string.are_you_sure), getString(description), getString(topButtonText), getString(R.string.cancel), new AlertPopup.AlertButtonCallback() { @Override public boolean topAlertButtonClicked() { topClickAction.run(); return false; } @Override public boolean bottomAlertButtonClicked() { return true; } @Override public boolean errorButtonClicked() { return false; } @Override public void close() {} }); popup.setCloseButtonVisible(false); return popup; }
Example #24
Source File: UpdateAppPopup.java From arcusandroid with Apache License 2.0 | 5 votes |
@NonNull public static UpdateAppPopup newInstance(@StringRes int infoTextResId, @StringRes int buttonTextId, UpdateAppPopupCallback listener) { UpdateAppPopup instance = new UpdateAppPopup(); Bundle arguments = new Bundle(); arguments.putInt(INFO_TEXT_ID, infoTextResId); arguments.putInt(BUTTON_TEXT_ID, buttonTextId); instance.setArguments(arguments); instance.setListener(listener); return instance; }
Example #25
Source File: SettingsActivity.java From MHViewer with Apache License 2.0 | 5 votes |
@Override public void startWithFragment(String fragmentName, Bundle args, Fragment resultTo, int resultRequestCode, @StringRes int titleRes, @StringRes int shortTitleRes) { Intent intent = onBuildStartFragmentIntent(fragmentName, args, titleRes, shortTitleRes); if (resultTo == null) { startActivityForResult(intent, REQUEST_CODE_FRAGMENT); } else { resultTo.startActivityForResult(intent, resultRequestCode); } }
Example #26
Source File: PhoneNumberValidator.java From arcusandroid with Apache License 2.0 | 5 votes |
private void setError( @Nullable TextInputLayout layout, @NonNull EditText editText, @StringRes int stringRes) { if (layout != null) { layout.setError(context.getString(stringRes)); } else { editText.setError(context.getString(stringRes)); } }
Example #27
Source File: PasswordValidator.java From arcusandroid with Apache License 2.0 | 5 votes |
private void setError( @Nullable TextInputLayout textInputLayout, @NonNull EditText editText, @StringRes int stringRes ) { setError(textInputLayout, editText, context.getString(stringRes)); }
Example #28
Source File: BaseFragment.java From arcusandroid with Apache License 2.0 | 5 votes |
public String getResourceString(@StringRes int resId) { String resourceString = ""; if (getActivity() != null && isAdded()) { resourceString = getString(resId); } return resourceString; }
Example #29
Source File: InfoTextPopup.java From arcusandroid with Apache License 2.0 | 5 votes |
@NonNull public static InfoTextPopup newInstance (String infoText, @StringRes int infoTextTitle) { InfoTextPopup instance = new InfoTextPopup(); Bundle arguments = new Bundle(); arguments.putString(INFO_TEXT, String.valueOf(infoText)); // Handle null gracefully arguments.putInt(INFO_TEXT_TITLE_ID, infoTextTitle); instance.setArguments(arguments); return instance; }
Example #30
Source File: InfoTextPopup.java From arcusandroid with Apache License 2.0 | 5 votes |
@NonNull public static InfoTextPopup newInstance (@StringRes int infoTextResId, @StringRes int infoTextTitle, Boolean showShopNow) { InfoTextPopup instance = new InfoTextPopup(); Bundle arguments = new Bundle(); arguments.putBoolean(SHOW_SHOP_NOW, showShopNow); arguments.putInt(INFO_TEXT_ID, infoTextResId); arguments.putInt(INFO_TEXT_TITLE_ID, infoTextTitle); instance.setArguments(arguments); return instance; }