Java Code Examples for androidx.annotation.StringRes

The following examples show how to use androidx.annotation.StringRes. These examples are extracted from open source projects. 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 Project: Twire   Source File: DialogService.java    License: GNU General Public License v3.0 6 votes vote down vote up
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
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 3
Source Project: mollyim-android   Source File: IdentityUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
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 4
Source Project: arcusandroid   Source File: TupleSelectorPopup.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: arcusandroid   Source File: SortedMultiModelPopup.java    License: Apache License 2.0 6 votes vote down vote up
@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 6
Source Project: arcusandroid   Source File: CareMultiModelPopup.java    License: Apache License 2.0 6 votes vote down vote up
@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 7
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 8
@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 9
Source Project: FridaHooker   Source File: MainActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 10
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 11
Source Project: a   Source File: SettingNestedFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
void setActionBarTitle(@StringRes int resId) {
    if (getActivity() != null) {
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null)
            actionBar.setTitle(resId);
    }
}
 
Example 12
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 13
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 14
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 15
Source Project: a   Source File: TabLayout.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 16
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 17
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 18
Source Project: Twire   Source File: DialogService.java    License: GNU General Public License v3.0 5 votes vote down vote up
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 19
Source Project: MediaSDK   Source File: NotificationUtil.java    License: Apache License 2.0 5 votes vote down vote up
/** @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 20
Source Project: MediaSDK   Source File: DownloadService.java    License: Apache License 2.0 5 votes vote down vote up
/** @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 21
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 22
Source Project: arcusandroid   Source File: PhoneNumberValidator.java    License: Apache License 2.0 5 votes vote down vote up
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 23
Source Project: arcusandroid   Source File: PasswordValidator.java    License: Apache License 2.0 5 votes vote down vote up
private void setError(
        @Nullable TextInputLayout textInputLayout,
        @NonNull EditText editText,
        @StringRes int stringRes
) {
   setError(textInputLayout, editText, context.getString(stringRes));
}
 
Example 24
Source Project: arcusandroid   Source File: BaseFragment.java    License: Apache License 2.0 5 votes vote down vote up
public String getResourceString(@StringRes int resId) {
    String resourceString = "";
    if (getActivity() != null && isAdded()) {
        resourceString = getString(resId);
    }
    return resourceString;
}
 
Example 25
Source Project: arcusandroid   Source File: InfoTextPopup.java    License: Apache License 2.0 5 votes vote down vote up
@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 26
Source Project: arcusandroid   Source File: InfoTextPopup.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 27
Source Project: MHViewer   Source File: SettingsActivity.java    License: Apache License 2.0 5 votes vote down vote up
@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 28
Source Project: arcusandroid   Source File: UpdateAppPopup.java    License: Apache License 2.0 5 votes vote down vote up
@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 29
Source Project: arcusandroid   Source File: VideoStorageFragment.java    License: Apache License 2.0 5 votes vote down vote up
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 30
Source Project: a   Source File: AboutFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
void setActionBarTitle(@StringRes int resId) {
    if (getActivity() != null) {
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null)
            actionBar.setTitle(resId);
    }
}