List of usage examples for android.content.res Resources getString
@NonNull public String getString(@StringRes int id) throws NotFoundException
From source file:com.android.tv.tuner.setup.TunerSetupActivity.java
private static void sendNotification(Context context, Integer tunerType) { SoftPreconditions.checkState(tunerType != null, TAG, "tunerType is null when send notification"); if (tunerType == null) { return;/*w ww. j a v a2 s . co m*/ } Resources resources = context.getResources(); String contentTitle = resources.getString(R.string.ut_setup_notification_content_title); int contentTextId = 0; switch (tunerType) { case TunerHal.TUNER_TYPE_BUILT_IN: contentTextId = R.string.bt_setup_notification_content_text; break; case TunerHal.TUNER_TYPE_USB: contentTextId = R.string.ut_setup_notification_content_text; break; case TunerHal.TUNER_TYPE_NETWORK: contentTextId = R.string.nt_setup_notification_content_text; break; } String contentText = resources.getString(contentTextId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { sendNotificationInternal(context, contentTitle, contentText); } else { Bitmap largeIcon = BitmapFactory.decodeResource(resources, R.drawable.recommendation_antenna); sendRecommendationCard(context, contentTitle, contentText, largeIcon); } }
From source file:com.silentcircle.silenttext.util.DeviceUtils.java
public static Eligibility getPartnerEligibility(Context context) { if (context == null) { return null; }// w ww .j av a 2 s .c o m Resources resources = context.getResources(); String[] manufacturers = resources.getString(R.string.build_partners).split(","); return new WhiteListEligibility(manufacturers, null); }
From source file:com.android.mms.rcs.FavoriteDetailAdapter.java
private static String getTextMessageDetails(Context context, Cursor cursor, boolean isAppendContentType) { StringBuilder details = new StringBuilder(); Resources res = context.getResources(); // Message Type: Text message. details.append(res.getString(R.string.message_type_label)); int rcsChatType = cursor .getInt(cursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CHAT_TYPE)); boolean isRcsMessage = RcsUtils.isRcsMessage(rcsChatType); if (isRcsMessage) details.append(res.getString(R.string.rcs_text_message)); else/*from w w w . j a v a2 s . c o m*/ details.append(res.getString(R.string.text_message)); if (isAppendContentType) { details.append('\n'); details.append(res.getString(R.string.message_content_type)); int msgType = cursor.getInt(cursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.MSG_TYPE)); if (msgType == RcsUtils.RCS_MSG_TYPE_IMAGE) details.append(res.getString(R.string.message_content_image)); else if (msgType == RcsUtils.RCS_MSG_TYPE_AUDIO) details.append(res.getString(R.string.message_content_audio)); else if (msgType == RcsUtils.RCS_MSG_TYPE_VIDEO) details.append(res.getString(R.string.message_content_video)); else if (msgType == RcsUtils.RCS_MSG_TYPE_MAP) details.append(res.getString(R.string.message_content_map)); else if (msgType == RcsUtils.RCS_MSG_TYPE_VCARD) details.append(res.getString(R.string.message_content_vcard)); else if (msgType == RcsUtils.RCS_MSG_TYPE_CAIYUNFILE) details.append(res.getString(R.string.msg_type_CaiYun)); else details.append(res.getString(R.string.message_content_text)); } // Address: *** details.append('\n'); int smsType = cursor .getInt(cursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.DIRECTION)); int chatType = cursor .getInt(cursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CHAT_TYPE)); if ((smsType != Constants.MessageConstants.CONST_DIRECTION_RECEIVE) && (chatType != Constants.MessageConstants.CONST_CHAT_GROUP)) { details.append(res.getString(R.string.to_address_label)); } else { details.append(res.getString(R.string.from_label)); } String address = ""; address = cursor.getString(cursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.NUMBER)); details.append(address); // date details.append('\n'); long date = cursor.getLong(cursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.DATE)); details.append(MessageUtils.formatTimeStampString(context, date, true)); return details.toString(); }
From source file:com.chen.mail.browse.SendersView.java
static String getMe(Context context) { final Resources resources = context.getResources(); final Locale locale = resources.getConfiguration().locale; if (sMeString == null || !locale.equals(sMeStringLocale)) { sMeString = resources.getString(R.string.me_subject_pronun); sMeStringLocale = locale;//w w w . j av a 2 s. c o m } return sMeString; }
From source file:com.google.android.gms.common.C0270e.java
public static String m3397c(Context context, int i) { Resources resources = context.getResources(); switch (i) {//from w w w.j a v a2s . c om case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoShadowHeight /*1*/: return resources.getString(R.common_google_play_services_install_button); case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoParalaxOffset /*2*/: case 42: return resources.getString(R.common_google_play_services_update_button); case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFadeColor /*3*/: return resources.getString(R.common_google_play_services_enable_button); default: return resources.getString(17039370); } }
From source file:be.ac.ucl.lfsab1509.llncampus.ADE.java
/** * Start information update from ADE.//from w w w . j a v a2 s. c om * * @param sa * Activity that launches the update thread. * @param updateRunnable * Runnable that launches the display update. * @param handler * Handler to allow the display update at the end of the execution. */ public static void runUpdateADE(final ScheduleActivity sa, final Handler handler, final Runnable updateRunnable) { final Resources r = sa.getResources(); final NotificationManager nm = (NotificationManager) sa.getSystemService(Context.NOTIFICATION_SERVICE); final NotificationCompat.Builder nb = new NotificationCompat.Builder(sa) .setSmallIcon(android.R.drawable.stat_sys_download) .setContentTitle(r.getString(R.string.download_from_ADE)) .setContentText(r.getString(R.string.download_progress)).setAutoCancel(true); final NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); inboxStyle.setBigContentTitle(r.getString(R.string.download_from_ADE)); nm.notify(NOTIFY_ID, nb.build()); new Thread(new Runnable() { @Override public void run() { /* * Fetching of code of courses to load. */ ArrayList<Course> courses = Course.getList(); if (courses == null || courses.isEmpty()) { // Take the context of the ScheduleActivity SharedPreferences preferences = new SecurePreferences(sa); String username = preferences.getString("username", null); String password = preferences.getString("password", null); if (username != null && password != null) { UCLouvain.downloadCoursesFromUCLouvain(sa, username, password, new Runnable() { public void run() { runUpdateADE(sa, handler, updateRunnable); } }, handler); } } /* * Number of weeks. To download all the schedule, the numbers go from 0 to 51 * (0 = beginning of first semester, 51 = ending of the September exams session). */ String weeks = getWeeks(); /* * Fetching data from ADE and updating the database */ int nbError = 0; int i = 0; ArrayList<Event> events; for (Course course : courses) { i++; nb.setProgress(courses.size(), i, false); nb.setContentText(r.getString(R.string.download_for) + " " + course.getCourseCode() + "..."); nm.notify(NOTIFY_ID, nb.build()); events = ADE.getInfo(course.getCourseCode(), weeks); if (events == null) { nbError++; inboxStyle.addLine(course.getCourseCode() + " : " + r.getString(R.string.download_error)); } else { // Removing old data LLNCampus.getDatabase().delete("Horaire", "COURSE = ?", new String[] { course.getCourseCode() }); // Adding new data for (Event e : events) { ContentValues cv = e.toContentValues(); cv.put("COURSE", course.getCourseCode()); if (LLNCampus.getDatabase().insert("Horaire", cv) < 0) { nbError++; } } inboxStyle.addLine(course.getCourseCode() + " : " + events.size() + " " + r.getString(R.string.events)); nb.setStyle(inboxStyle); } } nb.setProgress(courses.size(), courses.size(), false); if (nbError == 0) { nb.setContentText(r.getString(R.string.download_done)); inboxStyle.setBigContentTitle(r.getString(R.string.download_done)); nb.setSmallIcon(android.R.drawable.stat_sys_download_done); nb.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); } else { nb.setContentText(r.getString(R.string.download_done) + ". " + r.getString(R.string.nb_error) + nbError + " :/"); inboxStyle.setBigContentTitle(r.getString(R.string.download_done) + ". " + r.getString(R.string.nb_error) + nbError + " :/"); nb.setSmallIcon(android.R.drawable.stat_notify_error); nb.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); } nb.setStyle(inboxStyle); nm.notify(NOTIFY_ID, nb.build()); handler.post(updateRunnable); } }).start(); }
From source file:com.android.messaging.receiver.SmsReceiver.java
public static void postNewMessageSecondaryUserNotification() { final Context context = Factory.get().getApplicationContext(); final Resources resources = context.getResources(); final PendingIntent pendingIntent = UIIntents.get() .getPendingIntentForSecondaryUserNewMessageNotification(context); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setContentTitle(resources.getString(R.string.secondary_user_new_message_title)) .setTicker(resources.getString(R.string.secondary_user_new_message_ticker)) .setSmallIcon(R.drawable.ic_sms_light) // Returning PRIORITY_HIGH causes L to put up a HUD notification. Without it, the ticker // isn't displayed. .setPriority(Notification.PRIORITY_HIGH).setContentIntent(pendingIntent); final NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(builder); bigTextStyle.bigText(resources.getString(R.string.secondary_user_new_message_title)); final Notification notification = bigTextStyle.build(); final NotificationManagerCompat notificationManager = NotificationManagerCompat .from(Factory.get().getApplicationContext()); int defaults = Notification.DEFAULT_LIGHTS; if (BugleNotifications.shouldVibrate(new SecondaryUserNotificationState())) { defaults |= Notification.DEFAULT_VIBRATE; }/*ww w . j a va2s. co m*/ notification.defaults = defaults; notificationManager.notify(getNotificationTag(), PendingIntentConstants.SMS_SECONDARY_USER_NOTIFICATION_ID, notification); }
From source file:com.android.calendar.Event.java
/** * Adds all the events from the cursors to the events list. * * @param events The list of events// w ww. j a va 2 s . com * @param cEvents Events to add to the list * @param context * @param startDay * @param endDay */ public static void buildEventsFromCursor(ArrayList<Event> events, Cursor cEvents, Context context, int startDay, int endDay) { if (cEvents == null || events == null) { Log.e(TAG, "buildEventsFromCursor: null cursor or null events list!"); return; } int count = cEvents.getCount(); if (count == 0) { return; } Resources res = context.getResources(); mNoTitleString = res.getString(R.string.no_title_label); mNoColorColor = res.getColor(R.color.event_center); // Sort events in two passes so we ensure the allday and standard events // get sorted in the correct order cEvents.moveToPosition(-1); while (cEvents.moveToNext()) { Event e = generateEventFromCursor(cEvents); if (e.startDay > endDay || e.endDay < startDay) { continue; } events.add(e); } }
From source file:com.google.android.gms.common.C0270e.java
public static String m3392b(Context context, int i) { Resources resources = context.getResources(); switch (i) {/*from www. j av a 2s . com*/ case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoShadowHeight /*1*/: return C0270e.m3390a(context.getResources()) ? resources.getString(R.common_google_play_services_install_text_tablet) : resources.getString(R.common_google_play_services_install_text_phone); case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoParalaxOffset /*2*/: return resources.getString(R.common_google_play_services_update_text); case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFadeColor /*3*/: return resources.getString(R.common_google_play_services_enable_text); case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoDragView /*5*/: return resources.getString(R.common_google_play_services_invalid_account_text); case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoClipPanel /*7*/: return resources.getString(R.common_google_play_services_network_error_text); case HTTP.HT /*9*/: return resources.getString(R.common_google_play_services_unsupported_text); case Constants.DEFAULT_MAP_ZOOM_LEVEL /*16*/: return resources.getString(R.commono_google_play_services_api_unavailable_text); case LangUtils.HASH_SEED /*17*/: return resources.getString(R.common_google_play_services_sign_in_failed_text); case 42: return resources.getString(R.common_android_wear_update_text); default: return resources.getString(R.common_google_play_services_unknown_issue); } }
From source file:com.google.android.gms.common.GooglePlayServicesUtil.java
public static String m115d(Context context, int i) { Resources resources = context.getResources(); switch (i) {/*from w w w .ja v a2s . c o m*/ case Std.STD_FILE /*1*/: return resources.getString(C0192R.string.common_google_play_services_install_button); case Std.STD_URL /*2*/: return resources.getString(C0192R.string.common_google_play_services_update_button); case Std.STD_URI /*3*/: return resources.getString(C0192R.string.common_google_play_services_enable_button); default: return resources.getString(17039370); } }