Example usage for android.content.res Resources getString

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

Introduction

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

Prototype

@NonNull
public String getString(@StringRes int id) throws NotFoundException 

Source Link

Document

Return the string value associated with a particular resource ID.

Usage

From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapterTest.java

@Test
public void testBestChannelsGHZ2ErrorMessage() throws Exception {
    // setup/*from   w w w.  j  a  va2  s. c  o m*/
    Resources resources = mainActivity.getResources();
    String expected = resources.getText(R.string.channel_rating_best_none).toString()
            + resources.getText(R.string.channel_rating_best_alternative) + " "
            + resources.getString(WiFiBand.GHZ5.getTextResource());
    List<WiFiChannel> wiFiChannels = new ArrayList<>();
    List<ChannelAPCount> channelAPCounts = new ArrayList<>();
    when(channelRating.getBestChannels(wiFiChannels)).thenReturn(channelAPCounts);
    // execute
    fixture.bestChannels(WiFiBand.GHZ2, wiFiChannels);
    // validate
    assertEquals(expected, bestChannels.getText());
    verify(channelRating).getBestChannels(wiFiChannels);
}

From source file:com.bangz.smartmute.content.LocationCondition.java

@Override
public String description(final Context ctx) {
    Resources res = ctx.getResources();
    int transition = getTriggerCondition().getTransitionType();
    if (transition == Geofence.GEOFENCE_TRANSITION_ENTER) {
        return String.format(res.getString(R.string.info_trigger_by_enter), (int) radius);
    } else {//w w  w  . j av  a  2  s . co  m
        return String.format(res.getString(R.string.info_trigger_by_dwell), (int) radius,
                getTriggerCondition().getLoiteringDelay() / Constants.ONE_MINUTE_IN_MS);
    }

}

From source file:com.filemanager.free.fragments.TabFragment.java

String parsePathForName(String path, int openmode) {
    Resources resources = getActivity().getResources();
    if ("/".equals(path))
        return resources.getString(R.string.rootdirectory);
    else if (openmode == 1 && path.startsWith("smb:/"))
        return (new File(parseSmbPath(path)).getName());
    else if ("/storage/emulated/0".equals(path))
        return resources.getString(R.string.storage);
    else if (openmode == 2)
        return new MainActivityHelper(mainActivity).getIntegralNames(path);
    else/*from w  w w  .j  a v  a2s. co m*/
        return new File(path).getName();
}

From source file:com.ichi2.anki.stats.OverviewStatsBuilder.java

private void appendOverViewStats(StringBuilder stringBuilder) {
    Stats stats = new Stats(mCol, mWholeCollection);

    OverviewStats oStats = new OverviewStats();
    stats.calculateOverviewStatistics(mType, oStats);
    Resources res = mWebView.getResources();

    stringBuilder.append(_title(res.getString(mType.descriptionId)));

    boolean allDaysStudied = oStats.daysStudied == oStats.allDays;
    String daysStudied = res.getString(R.string.stats_overview_days_studied,
            (int) ((float) oStats.daysStudied / (float) oStats.allDays * 100), oStats.daysStudied,
            oStats.allDays);//from w w  w .  jav  a 2 s  .  c o m

    // FORECAST
    // Fill in the forecast summaries first
    calculateForecastOverview(mType, oStats);

    stringBuilder.append(_subtitle(res.getString(R.string.stats_forecast).toUpperCase()));
    stringBuilder.append(res.getString(R.string.stats_overview_forecast_total, oStats.forecastTotalReviews));
    stringBuilder.append("<br>");
    stringBuilder
            .append(res.getString(R.string.stats_overview_forecast_average, oStats.forecastAverageReviews));
    stringBuilder.append("<br>");
    stringBuilder
            .append(res.getString(R.string.stats_overview_forecast_due_tomorrow, oStats.forecastDueTomorrow));

    stringBuilder.append("<br>");

    // REVIEW COUNT
    stringBuilder.append(_subtitle(res.getString(R.string.stats_review_count).toUpperCase()));
    stringBuilder.append(daysStudied);
    stringBuilder.append("<br>");
    stringBuilder.append(res.getString(R.string.stats_overview_total_reviews, oStats.totalReviews));
    stringBuilder.append("<br>");
    stringBuilder.append(
            res.getString(R.string.stats_overview_reviews_per_day_studydays, oStats.reviewsPerDayOnStudyDays));
    if (!allDaysStudied) {
        stringBuilder.append("<br>");
        stringBuilder
                .append(res.getString(R.string.stats_overview_reviews_per_day_all, oStats.reviewsPerDayOnAll));
    }

    stringBuilder.append("<br>");

    //REVIEW TIME
    stringBuilder.append(_subtitle(res.getString(R.string.stats_review_time).toUpperCase()));
    stringBuilder.append(daysStudied);
    stringBuilder.append("<br>");
    // TODO: Total: x minutes
    stringBuilder.append(
            res.getString(R.string.stats_overview_time_per_day_studydays, oStats.timePerDayOnStudyDays));
    if (!allDaysStudied) {
        stringBuilder.append("<br>");
        stringBuilder.append(res.getString(R.string.stats_overview_time_per_day_all, oStats.timePerDayOnAll));
    }
    // TODO: Average answer time: x.xs (x.x cards/minute)

    stringBuilder.append("<br>");

    // ADDED
    stringBuilder.append(_subtitle(res.getString(R.string.stats_added).toUpperCase()));
    stringBuilder.append(res.getString(R.string.stats_overview_total_new_cards, oStats.totalNewCards));
    stringBuilder.append("<br>");
    stringBuilder.append(res.getString(R.string.stats_overview_new_cards_per_day, oStats.newCardsPerDay));

    stringBuilder.append("<br>");

    // INTERVALS
    stringBuilder.append(_subtitle(res.getString(R.string.stats_review_intervals).toUpperCase()));
    stringBuilder.append(res.getString(R.string.stats_overview_average_interval));
    stringBuilder.append(Utils.roundedTimeSpan(mWebView.getContext(),
            (int) Math.round(oStats.averageInterval * Stats.SECONDS_PER_DAY)));
    stringBuilder.append("<br>");
    stringBuilder.append(res.getString(R.string.stats_overview_longest_interval));
    stringBuilder.append(Utils.roundedTimeSpan(mWebView.getContext(),
            (int) Math.round(oStats.longestInterval * Stats.SECONDS_PER_DAY)));
}

From source file:com.scigames.slidegame.MenuActivity.java

@Override
public void onResultsSucceeded(String[] student, String[] slide_session, String[] slide_level,
        String[] objective_images, String[] fabric, String[] result_images, String[] score_images,
        String attempts, boolean no_session, JSONObject serverResponseJSON) throws JSONException {

    massIn = student[7];/* www.  j a v  a  2 s . c om*/
    //update all text fields
    Resources res = getResources();

    //TextView greets = (TextView)findViewById(R.id.greeting);
    setTextViewFont(Museo500Regular, greets);
    greets.setText(String.format(res.getString(R.string.profile_name), student[2], student[3]));
    setTextViewFont(Museo500Regular, greets);
    //setTextViewFont(Museo500Regular, teachername, classid, mpass, classname);

    Log.d(TAG, "...Profile Info");

}

From source file:com.classiqo.nativeandroid_32bitz.model.MusicProvider.java

private MediaBrowserCompat.MediaItem createBrowsableMediaItemForRoot(Resources resources) {
    MediaDescriptionCompat description = new MediaDescriptionCompat.Builder()
            .setMediaId(MEDIA_ID_MUSICS_BY_GENRE).setTitle(resources.getString(R.string.browse_genres))
            .setSubtitle(resources.getString(R.string.browse_genre_subtitle))
            .setIconUri(/*from   w  w  w  .j a  va  2s  .  c o m*/
                    Uri.parse("android.resource://" + "com.classiqo.nativeandroid_32bitz/drawable/ic_by_genre"))
            .build();

    return new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE);
}

From source file:com.android.settings.sim.SimSelectNotification.java

private void createNotification(Context context) {
    final Resources resources = context.getResources();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
            .setColor(context.getColor(R.color.sim_noitification))
            .setContentTitle(resources.getString(R.string.sim_notification_title))
            .setContentText(resources.getString(R.string.sim_notification_summary));
    Intent resultIntent = new Intent(context, SimSettingsActivity.class);
    resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setContentIntent(resultPendingIntent);
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, builder.build());
}

From source file:com.albedinsky.android.support.intent.ImageIntent.java

/**
 * Invoked from {@link #withDefaultHandlers()} to create gallery intent handler.
 *
 * @param resources Application resources.
 * @return Content handler with gallery intent.
 * @see #onCreateCameraHandler(Resources)
 *//*from w  w  w  . ja v a2  s .c o m*/
@NonNull
protected ContentHandler onCreateGalleryHandler(@NonNull Resources resources) {
    return new ContentHandler(resources.getString(R.string.intent_content_handler_gallery),
            createGalleryIntent()).requestCode(REQUEST_CODE_GALLERY);
}

From source file:com.albedinsky.android.support.intent.ImageIntent.java

/**
 * Invoked from {@link #withDefaultHandlers()} to create camera intent handler.
 *
 * @param resources Application resources.
 * @return Content handler with camera intent.
 * @see #onCreateGalleryHandler(Resources)
 *//*from   w  w  w . ja v  a2  s .  c  om*/
@NonNull
protected ContentHandler onCreateCameraHandler(@NonNull Resources resources) {
    return new ContentHandler(resources.getString(R.string.intent_content_handler_camera), createCameraIntent())
            .requestCode(REQUEST_CODE_CAMERA);
}

From source file:com.codetroopers.betterpickers.radialtimepicker.AmPmCirclesView.java

public void initialize(Context context, int amOrPm) {
    if (mIsInitialized) {
        Log.e(TAG, "AmPmCirclesView may only be initialized once.");
        return;/*w  w w  .ja  v  a  2  s  .  c  om*/
    }

    Resources res = context.getResources();
    mUnselectedColor = res.getColor(R.color.bpWhite);
    mSelectedColor = res.getColor(R.color.bpBlue);
    mAmPmTextColor = res.getColor(R.color.ampm_text_color);
    String typefaceFamily = res.getString(R.string.sans_serif);
    Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL);
    mPaint.setTypeface(tf);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier));
    mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier));
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    setAmOrPm(amOrPm);
    mAmOrPmPressed = -1;

    mIsInitialized = true;
}