List of usage examples for android.content.res Resources getString
@NonNull public String getString(@StringRes int id, Object... formatArgs) throws NotFoundException
From source file:com.google.android.gms.common.internal.zzt.java
@NonNull public static String c(final Context context, final int n) { final Resources resources = context.getResources(); final String a = a(context); String s = null;/* ww w. ja va 2 s . c o m*/ switch (n) { default: { s = resources.getString(R$string.common_google_play_services_unknown_issue, new Object[] { a }); break; } case 1: { s = resources.getString(R$string.common_google_play_services_install_text, new Object[] { a }); break; } case 3: { s = resources.getString(R$string.common_google_play_services_enable_text, new Object[] { a }); break; } case 18: { s = resources.getString(R$string.common_google_play_services_updating_text, new Object[] { a }); break; } case 2: { if (zzi.b(context)) { s = resources.getString(R$string.common_google_play_services_wear_update_text); break; } s = resources.getString(R$string.common_google_play_services_update_text, new Object[] { a }); break; } case 9: { s = resources.getString(R$string.common_google_play_services_unsupported_text, new Object[] { a }); break; } case 7: { s = a(context, "common_google_play_services_network_error_text", a); break; } case 5: { s = a(context, "common_google_play_services_invalid_account_text", a); break; } case 16: { s = a(context, "common_google_play_services_api_unavailable_text", a); break; } case 17: { s = a(context, "common_google_play_services_sign_in_failed_text", a); break; } case 20: { s = a(context, "common_google_play_services_restricted_profile_text", a); break; } } return s; }
From source file:com.dabay6.libraries.androidshared.ui.dialogs.changelog.util.ChangeLogDialogUtils.java
private static String parseReleases(final Context context, final List<Release> releases) { final Resources res = context.getResources(); final StringBuilder html = new StringBuilder(); for (final Release release : releases) { html.append("<h1>"); html.append(res.getString(R.string.change_log_release, release.getVersion())); html.append("</h1>"); if (release.getChanges().size() > 0) { final List<ChangeLogItem> list = release.getChanges(); html.append("<h3>"); html.append(res.getString(R.string.change_log_changes)); html.append("</h3>"); html.append("<ul>"); for (final ChangeLogItem item : list) { html.append(String.format("<li>%s</li>", item.getDescription())); }//from w w w. j a v a 2 s. c o m html.append("</ul>"); } if (release.getFixes().size() > 0) { final List<ChangeLogItem> list = release.getFixes(); html.append("<h3>"); html.append(res.getString(R.string.change_log_fixes)); html.append("</h3>"); html.append("<ul>"); for (final ChangeLogItem item : list) { html.append(String.format("<li>%s</li>", item.getDescription())); } html.append("</ul>"); } } return html.toString(); }
From source file:com.todoroo.astrid.sync.SyncProviderPreferences.java
private static final String adjustErrorForDisplay(Resources r, String lastError, String service) { Set<String> exceptions = getExceptionMap().keySet(); Integer resource = null;//w ww . j a v a 2 s . c o m for (String key : exceptions) { if (lastError.contains(key)) { resource = getExceptionMap().get(key); break; } } if (resource == null) return lastError; return r.getString(resource.intValue(), service); }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a dialog containing the code received by goo.gl if any, or an error * message stating that the pairing operation failed. * /*from w w w. ja v a 2 s . c o m*/ * @param googl * the pairing code retrieved by goo.gl * @param activity * the caller activity */ public static void onObtainPairingCode(final String googl, final MainActivity activity) { new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = getBuilder(activity); if (googl != null) { View layout = View.inflate(getContext(), R.layout.pairing_code_dialog, null); TextView message = (TextView) layout.findViewById(R.id.pairingCode); Typeface typeFace = Typeface.createFromAsset(activity.getAssets(), CUSTOM_TYPEFACE_PATH); message.setTypeface(typeFace); message.setText(googl); builder.setView(layout); } else { builder.setMessage(getResources().getString(R.string.code_dialog_fail)); } builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (googl != null) { Resources res = getResources(); String howManyTotal = res.getQuantityString(R.plurals.added_device, activity.getInboundDevicesCount(), activity.getInboundDevicesCount()); Toast.makeText(getActivity(), res.getString(R.string.device_paired, howManyTotal), Toast.LENGTH_LONG).show(); } } }); return builder.create(); } }.show(activity.getSupportFragmentManager(), "resultCode"); }
From source file:com.probam.updater.updater.GooPackage.java
@Override public String getMessage(Context context) { Resources res = context.getResources(); return res.getString(R.string.goo_package_description, new Object[] { filename, md5, folder, description }); }
From source file:org.addhen.smssync.net.MessageSyncHttpClient.java
public void setServerError(String error, int statusCode) { log("Server error " + error); Resources res = context.getResources(); final String customError = res.getString(R.string.sending_failed_custom_error, error); final String code = res.getString(R.string.sending_failed_http_code, statusCode); this.serverError = String.format("%s %s ", customError, code); Util.logActivities(context, serverError); }
From source file:org.addhen.smssync.net.MessageSyncHttpClient.java
public void setClientError(String error) { log("Client error " + error); Resources res = context.getResources(); this.clientError = String.format(Locale.getDefault(), "%s", res.getString(R.string.sending_failed_custom_error, error)); Util.logActivities(context, clientError); }
From source file:com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment.java
private void showSubtypeAlreadyExistsToast(final InputMethodSubtype subtype) { final Context context = getActivity(); final Resources res = context.getResources(); final String message = res.getString(R.string.custom_input_style_already_exists, SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)); Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); }
From source file:com.android.deskclock.timer.TimerSetupView.java
@Override public void onClick(View v) { final boolean validInputBeforeClick = hasValidInput(); final Integer n = (Integer) v.getTag(R.id.numbers_key); // A number was pressed if (n != null) { // pressing "0" as the first digit does nothing if (mInputPointer == -1 && n == 0) { return; }// www . j a v a2s. c om // No space for more digits, so ignore input. if (mInputPointer == mInput.length - 1) { return; } // Append the new digit. System.arraycopy(mInput, 0, mInput, 1, mInputPointer + 1); mInput[0] = n; mInputPointer++; updateTime(); // Update talkback to read the number being deleted final Resources resources = getResources(); final String cd = resources.getString(R.string.timer_descriptive_delete, n.toString()); mDelete.setContentDescription(cd); } // other keys if (v == mDelete) { if (mInputPointer < 0) { // Nothing exists to delete so return. return; } System.arraycopy(mInput, 1, mInput, 0, mInputPointer); mInput[mInputPointer] = 0; mInputPointer--; updateTime(); // Update talkback to read the number being deleted or its original description. final String number = mInputPointer < 0 ? "" : Integer.toString(mInput[mInputPointer]); final String cd = getResources().getString(R.string.timer_descriptive_delete, number); mDelete.setContentDescription(cd); } if (validInputBeforeClick != hasValidInput()) { updateFab(); updateDeleteButtonAndDivider(); } }
From source file:com.ichi2.libanki.Utils.java
/** * Return a string representing a time quantity * * @param context The application's environment. * @param time_s The time to format, in seconds * @return The time quantity string. Something like "3 s" or "1.7 yr". */// w ww.jav a 2s.com public static String timeQuantity(Context context, int time_s) { Resources res = context.getResources(); // N.B.: the integer s, min, h, d and (one decimal, rounded by format) double for month, year is // hard-coded. See also 01-core.xml if (Math.abs(time_s) < TIME_MINUTE) { return res.getString(R.string.time_quantity_seconds, time_s); } else if (Math.abs(time_s) < TIME_HOUR) { return res.getString(R.string.time_quantity_minutes, (int) Math.round(time_s / TIME_MINUTE)); } else if (Math.abs(time_s) < TIME_DAY) { return res.getString(R.string.time_quantity_hours, (int) Math.round(time_s / TIME_HOUR)); } else if (Math.abs(time_s) < TIME_MONTH) { return res.getString(R.string.time_quantity_days, (int) Math.round(time_s / TIME_DAY)); } else if (Math.abs(time_s) < TIME_YEAR) { return res.getString(R.string.time_quantity_months, time_s / TIME_MONTH); } else { return res.getString(R.string.time_quantity_years, time_s / TIME_YEAR); } }