Example usage for android.app Activity getString

List of usage examples for android.app Activity getString

Introduction

In this page you can find the example usage for android.app Activity getString.

Prototype

@NonNull
public final String getString(@StringRes int resId) 

Source Link

Document

Returns a localized string from the application's package's default string table.

Usage

From source file:com.todoroo.astrid.ui.TaskListFragmentPager.java

@SuppressWarnings("nls")
public static void showSwipeBetweenHelper(Activity activity) {
    if (!Preferences.getBoolean(PREF_SHOWED_SWIPE_HELPER, false)) {
        String body = String.format("<h3>%s</h3><img src='%s'><br><br>%s",
                activity.getString(R.string.swipe_lists_helper_header), "subtasks_horizontal.png",
                activity.getString(R.string.swipe_lists_helper_subtitle));

        String color = ThemeService.getDialogTextColorString();
        String html = String.format("<html><body style='text-align:center;color:%s'>%s</body></html>", color,
                body);// www.  j a v  a2 s .co  m

        DialogUtilities.htmlDialog(activity, html, R.string.swipe_lists_helper_title);

        Preferences.setBoolean(PREF_SHOWED_SWIPE_HELPER, true);
    }
}

From source file:com.mvc.imagepicker.ImagePicker.java

/**
 * Launch a dialog to pick an image from camera/gallery apps.
 *
 * @param activity which will launch the dialog.
 *//* ww w.  j av  a2 s .  c om*/
public static void pickImage(Activity activity) {
    String chooserTitle = activity.getString(R.string.pick_image_intent_text);
    pickImage(activity, chooserTitle);
}

From source file:org.openhab.habdroid.util.Util.java

public static void setActivityTheme(@NonNull final Activity activity) {
    final String theme = PreferenceManager.getDefaultSharedPreferences(activity)
            .getString(Constants.PREFERENCE_THEME, activity.getString(R.string.theme_value_dark));
    int themeRes;
    if (theme.equals(activity.getString(R.string.theme_value_light))) {
        themeRes = R.style.HABDroid_Light;
    } else if (theme.equals(activity.getString(R.string.theme_value_black))) {
        themeRes = R.style.HABDroid_Black;
    } else {/* w  w w . j av  a 2s . co m*/
        themeRes = R.style.HABDroid_Dark;
    }
    activity.setTheme(themeRes);
}

From source file:org.sufficientlysecure.keychain.ui.util.Notify.java

public static Showable create(Activity activity, int textResId, int duration, Style style,
        ActionListener actionListener, int actionResId) {
    return create(activity, activity.getString(textResId), duration, style, actionListener, actionResId);
}

From source file:org.gc.networktester.util.Util.java

public static AlertDialog createDialog(final Activity activity, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(message).setPositiveButton(activity.getString(R.string.dialog_ok), null);
    AlertDialog ad = builder.create();/*from w  w  w  .j  av a2 s  .co m*/
    ad.show();
    return ad;
}

From source file:com.murrayc.galaxyzoo.app.UiUtils.java

public static Bundle getTransitionOptionsBundle(final Activity activity, final View sharedElementView) {
    final ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
            sharedElementView, activity.getString(R.string.transition_subject_image));
    return options.toBundle();
}

From source file:org.liberty.android.fantastischmemo.utils.AMGUIUtility.java

public static void displayException(final Activity activity, final String title, final String text,
        final Exception e) {
    Log.e(TAG, "displayException", e);
    new AlertDialog.Builder(activity).setTitle(title)
            .setMessage(text + "\n" + activity.getString(R.string.exception_text) + ": "
                    + Throwables.getRootCause(e) + "\n" + Throwables.getStackTraceAsString(e))
            .setNeutralButton(R.string.back_menu_text, new DialogInterface.OnClickListener() {
                @Override//from w ww . j  ava2s  . co m
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            }).show();
}

From source file:org.liberty.android.fantastischmemo.utils.AMGUIUtility.java

public static void displayError(final Activity activity, final String title, final String text,
        final Exception e) {
    Log.e(TAG, "displayError", e);
    new AlertDialog.Builder(activity).setTitle(title)
            .setMessage(text + "\n" + activity.getString(R.string.exception_text) + ": "
                    + Throwables.getRootCause(e) + "\n" + Throwables.getStackTraceAsString(e))
            .setPositiveButton(activity.getString(R.string.back_menu_text),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface arg0, int arg1) {
                            activity.finish();
                        }/*from w w w.ja v  a  2  s.  co m*/
                    })
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    activity.finish();
                }
            }).show();
}

From source file:com.cloverstudio.spika.utils.Utils.java

public static String checkEmail(Activity activity, String email) {
    if (email.length() <= 0) {
        return activity.getString(R.string.email_length);
    } else if (!isEmailValid(email)) {
        return activity.getString(R.string.email_not_valid);
    }//w w  w . ja  v  a  2  s. c  om
    return activity.getString(R.string.email_ok);
}

From source file:com.cloverstudio.spika.utils.Utils.java

public static String checkPassword(Activity activity, String password) {
    if (password.length() < 6) {
        return activity.getString(R.string.password_error_number_of_characters);
    } else if (!isAlphaNumeric(password)) {
        return activity.getString(R.string.password_error_invalid_characters);
    }/*  w  w  w.j a va2s  . co  m*/
    return activity.getString(R.string.password_ok);
}