Example usage for android.content.res Resources getText

List of usage examples for android.content.res Resources getText

Introduction

In this page you can find the example usage for android.content.res Resources getText.

Prototype

@NonNull
public CharSequence getText(@StringRes int id) throws NotFoundException 

Source Link

Document

Return the string value associated with a particular resource ID.

Usage

From source file:Main.java

public static String getApplicationName(Context context) {
    Resources appR = context.getResources();
    String txt = (String) appR.getText(appR.getIdentifier("app_name", "string", context.getPackageName()));
    return txt;/*from w w w. ja va 2  s.co m*/
}

From source file:com.crea_si.eviacam.wizard.WizardUtils.java

static void checkEngineAndFinishIfNeeded(final Activity a) {
    AccessibilityServiceModeEngine engine = MainEngine.getAccessibilityServiceModeEngine();
    if (engine == null || !engine.isReady()) {
        // Engine is not ready anymore
        final Resources res = a.getResources();
        AlertDialog ad = new AlertDialog.Builder(a).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setTitle(res.getText(R.string.eva_not_running));
        ad.setMessage(res.getText(R.string.eva_not_running_summary));
        ad.setButton(DialogInterface.BUTTON_NEUTRAL, res.getText(R.string.close),
                new DialogInterface.OnClickListener() {
                    @Override/*w  ww .  java  2  s .  com*/
                    public void onClick(DialogInterface dialog, int which) {
                        finishWizard(a);
                    }
                });
        ad.show();
    }
}

From source file:Main.java

/**
 * @return a localized version of the text resource specified by resId
 *///from ww  w  .j av a2s.c  om
static CharSequence getTextForLocale(Context context, Locale locale, int resId) {
    final Resources res = context.getResources();
    final Configuration config = res.getConfiguration();
    final Locale prevLocale = config.locale;
    try {
        config.locale = locale;
        res.updateConfiguration(config, null);
        return res.getText(resId);
    } finally {
        config.locale = prevLocale;
        res.updateConfiguration(config, null);
    }
}

From source file:com.nextgis.mobile.forms.CompassFragment.java

public static String getDirectionCode(float azimuth, Resources res) {
    int nIndex = Math.round(azimuth / 45);

    String directionCodes[] = { (String) res.getText(R.string.compas_N),
            (String) res.getText(R.string.compas_NE), (String) res.getText(R.string.compas_E),
            (String) res.getText(R.string.compas_SE), (String) res.getText(R.string.compas_S),
            (String) res.getText(R.string.compas_SW), (String) res.getText(R.string.compas_W),
            (String) res.getText(R.string.compas_NW), (String) res.getText(R.string.compas_N) };
    if (nIndex > 8 || nIndex < 0) {
        return directionCodes[0];
    } else {//  w w  w .j  ava 2s .co  m
        return directionCodes[nIndex];
    }
}

From source file:net.eledge.android.europeana.gui.notification.NewBlogNotification.java

public static void notify(final Context context, List<BlogArticle> articles) {
    if ((articles == null) || articles.isEmpty()) {
        return;// w w w .j  av a 2  s.com
    }
    // cancel earlier notification
    cancel(context);
    final Resources res = context.getResources();

    String blogUrl = UriHelper.URL_BLOG;
    String title = res.getString(R.string.new_blog_notification_title_multiple, articles.size());

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(R.drawable.ic_stat_new_blog)
            .setContentText(res.getText(R.string.app_name)).setPriority(NotificationCompat.PRIORITY_DEFAULT)
            .setTicker(title).setAutoCancel(true);
    if (articles.size() == 1) {
        BlogArticle item = articles.get(0);
        blogUrl = item.guid;
        title = res.getString(R.string.new_blog_notification_title_single, item.title);

    } else {
        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        for (BlogArticle item : articles) {
            inboxStyle.addLine(item.title);
        }
        builder.setStyle(inboxStyle);
    }

    Intent buttonIntent = new Intent(context, UrlButtonReceiver.class);
    buttonIntent.putExtra(UrlButtonReceiver.PARAM_NOTIFICATIONID, Config.NOTIFICATION_NEWBLOG);
    buttonIntent.putExtra(UrlButtonReceiver.PARAM_URL, blogUrl);
    PendingIntent openUrl = PendingIntent.getBroadcast(context, 0, buttonIntent, 0);

    PendingIntent openApp = PendingIntent.getActivity(context, 0, new Intent(context, HomeActivity.class),
            PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(openApp).addAction(0, res.getString(R.string.action_open_browser), openUrl)
            .addAction(0, res.getString(R.string.action_open_app), openApp).setContentTitle(title);

    notify(context, builder.build());
}

From source file:com.vuze.android.remote.fragment.OpenOptionsPagerAdapter.java

@Override
public CharSequence getPageTitle(int position) {
    Resources resources = VuzeRemoteApp.getContext().getResources();
    switch (position) {
    case 1://from w  w  w . ja v a  2  s.  co  m
        return resources.getText(R.string.details_tab_files);

    case 0:
        return resources.getText(R.string.details_tab_general);
    }
    return super.getPageTitle(position);
}

From source file:com.vuze.android.remote.fragment.TorrentDetailsPagerAdapter.java

@Override
public CharSequence getPageTitle(int position) {
    Resources resources = VuzeRemoteApp.getContext().getResources();
    switch (position) {
    case 0:/*w ww .j  a va  2s .c  o m*/
        return resources.getText(R.string.details_tab_files);

    case 2:
        return resources.getText(R.string.details_tab_peers);

    case 1:
        return resources.getText(R.string.details_tab_info);
    }
    return super.getPageTitle(position);
}

From source file:com.crea_si.eviacam.wizard.SetupWizard.java

private boolean showKeyboardWarnDialog(DialogInterface.OnClickListener listenerPos,
        DialogInterface.OnClickListener listenerNeg) {
    if (InputMethodAction.isEnabledCustomKeyboard(getActivity()))
        return true;

    mStepBefore = -1;/*  w ww.j ava  2s  . c  o m*/

    DialogInterface.OnClickListener dummyListener = new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // do nothing
        }
    };

    if (listenerPos == null)
        listenerPos = dummyListener;
    if (listenerNeg == null)
        listenerNeg = dummyListener;

    Resources r = getResources();

    new AlertDialog.Builder(getActivity()).setTitle(r.getText(R.string.keyboard_not_configured))
            .setMessage(r.getText(R.string.keyboard_not_configured_confirm))
            .setPositiveButton(android.R.string.yes, listenerPos)
            .setNegativeButton(android.R.string.no, listenerNeg).setIcon(android.R.drawable.ic_dialog_alert)
            .show();

    return false;
}

From source file:comkriscamillerimobilehci.httpsgithub.cardcutter.SimpleGridPagerAdapter.java

private Fragment cardFragment(int titleRes, int textRes) {
    Resources res = mContext.getResources();
    CardFragment fragment = CardFragment.create(res.getText(titleRes), res.getText(textRes));
    // Add some extra bottom margin to leave room for the page indicator
    fragment.setCardMarginBottom(res.getDimensionPixelSize(R.dimen.card_content_padding_rect_top));
    return fragment;
}

From source file:com.vuze.android.remote.adapter.TorrentDetailsPagerAdapter.java

@Override
public CharSequence getPageTitle(int position) {
    Resources resources = VuzeRemoteApp.getContext().getResources();
    switch (position) {
    case 0:/*from w ww .  j  a  v a  2 s . com*/
        return resources.getText(R.string.details_tab_files);

    case 2:
        return resources.getText(R.string.details_tab_peers);

    case 3:
        return resources.getText(R.string.details_tab_tags);

    case 1:
        return resources.getText(R.string.details_tab_info);
    }
    return super.getPageTitle(position);
}