List of usage examples for android.content.res Resources getString
@NonNull public String getString(@StringRes int id) throws NotFoundException
From source file:com.android.messaging.ui.conversationlist.ConversationListItemView.java
private String getSnippetText() { String snippetText = mData.getShowDraft() ? mData.getDraftSnippetText() : mData.getSnippetText(); final String previewContentType = mData.getShowDraft() ? mData.getDraftPreviewContentType() : mData.getPreviewContentType(); if (TextUtils.isEmpty(snippetText)) { Resources resources = getResources(); // Use the attachment type as a snippet so the preview doesn't look odd if (ContentType.isAudioType(previewContentType)) { snippetText = resources.getString(R.string.conversation_list_snippet_audio_clip); } else if (ContentType.isImageType(previewContentType)) { snippetText = resources.getString(R.string.conversation_list_snippet_picture); } else if (ContentType.isVideoType(previewContentType)) { snippetText = resources.getString(R.string.conversation_list_snippet_video); } else if (ContentType.isVCardType(previewContentType)) { snippetText = resources.getString(R.string.conversation_list_snippet_vcard); }/*from w w w . ja v a 2 s.c om*/ } return snippetText; }
From source file:com.bluros.updater.service.UpdateCheckService.java
private void recordAvailableUpdates(LinkedList<UpdateInfo> availableUpdates, Intent finishedIntent) { if (availableUpdates == null) { sendBroadcast(finishedIntent);//from w ww . j ava 2 s . c o m return; } // Store the last update check time and ensure boot check completed is true Date d = new Date(); PreferenceManager.getDefaultSharedPreferences(UpdateCheckService.this).edit() .putLong(Constants.LAST_UPDATE_CHECK_PREF, d.getTime()) .putBoolean(Constants.BOOT_CHECK_COMPLETED, true).apply(); int realUpdateCount = finishedIntent.getIntExtra(EXTRA_REAL_UPDATE_COUNT, 0); UpdateApplication app = (UpdateApplication) getApplicationContext(); // Write to log Log.i(TAG, "The update check successfully completed at " + d + " and found " + availableUpdates.size() + " updates (" + realUpdateCount + " newer than installed)"); if (realUpdateCount != 0 && !app.isMainActivityActive()) { // There are updates available // The notification should launch the main app Intent i = new Intent(this, UpdatesSettings.class); i.putExtra(UpdatesSettings.EXTRA_UPDATE_LIST_UPDATED, true); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_ONE_SHOT); Resources res = getResources(); String text = res.getQuantityString(R.plurals.not_new_updates_found_body, realUpdateCount, realUpdateCount); // Get the notification ready NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_system_update).setWhen(System.currentTimeMillis()) .setTicker(res.getString(R.string.not_new_updates_found_ticker)) .setContentTitle(res.getString(R.string.not_new_updates_found_title)).setContentText(text) .setContentIntent(contentIntent).setLocalOnly(true).setAutoCancel(true); LinkedList<UpdateInfo> realUpdates = new LinkedList<UpdateInfo>(); for (UpdateInfo ui : availableUpdates) { if (ui.isNewerThanInstalled()) { realUpdates.add(ui); } } Collections.sort(realUpdates, new Comparator<UpdateInfo>() { @Override public int compare(UpdateInfo lhs, UpdateInfo rhs) { /* sort by date descending */ long lhsDate = lhs.getDate(); long rhsDate = rhs.getDate(); if (lhsDate == rhsDate) { return 0; } return lhsDate < rhsDate ? 1 : -1; } }); NotificationCompat.InboxStyle inbox = new NotificationCompat.InboxStyle(builder) .setBigContentTitle(text); int added = 0, count = realUpdates.size(); for (UpdateInfo ui : realUpdates) { if (added < EXPANDED_NOTIF_UPDATE_COUNT) { inbox.addLine(ui.getName()); added++; } } if (added != count) { inbox.setSummaryText( res.getQuantityString(R.plurals.not_additional_count, count - added, count - added)); } builder.setStyle(inbox); builder.setNumber(availableUpdates.size()); if (count == 1) { i = new Intent(this, DownloadReceiver.class); i.setAction(DownloadReceiver.ACTION_START_DOWNLOAD); i.putExtra(DownloadReceiver.EXTRA_UPDATE_INFO, (Parcelable) realUpdates.getFirst()); PendingIntent downloadIntent = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(R.drawable.ic_tab_download, res.getString(R.string.not_action_download), downloadIntent); } // Trigger the notification NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.notify(R.string.not_new_updates_found_title, builder.build()); } sendBroadcast(finishedIntent); }
From source file:com.hichinaschool.flashcards.anki.Preferences.java
@Override protected Dialog onCreateDialog(int id) { Resources res = getResources(); StyledDialog.Builder builder = new StyledDialog.Builder(this); switch (id) { case DIALOG_BACKUP: builder.setTitle(res.getString(R.string.backup_manager_title)); builder.setCancelable(false);/* w w w .j av a 2s .c o m*/ builder.setMessage(res.getString(R.string.pref_backup_warning)); builder.setPositiveButton(res.getString(R.string.yes), new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { lockCheckAction = true; useBackupPreference.setChecked(false); dialogMessage = getResources().getString(R.string.backup_delete); DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DELETE_BACKUPS, mDeckOperationHandler, (DeckTask.TaskData[]) null); } }); builder.setNegativeButton(res.getString(R.string.no), null); break; case DIALOG_ASYNC: builder.setTitle(res.getString(R.string.async_mode)); builder.setCancelable(false); builder.setMessage(res.getString(R.string.async_mode_message)); builder.setPositiveButton(res.getString(R.string.yes), new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { lockCheckAction = true; asyncModePreference.setChecked(true); } }); builder.setNegativeButton(res.getString(R.string.no), null); break; case DIALOG_WRITE_ANSWERS: builder.setTitle(res.getString(R.string.write_answers)); builder.setCancelable(false); builder.setMessage(res.getString(R.string.write_answers_message)); builder.setNegativeButton(res.getString(R.string.ok), null); break; case DIALOG_HEBREW_FONT: builder.setTitle(res.getString(R.string.fix_hebrew_text)); builder.setCancelable(false); builder.setMessage( res.getString(R.string.fix_hebrew_instructions, AnkiDroidApp.getCurrentAnkiDroidDirectory())); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(res.getString(R.string.fix_hebrew_download_font), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(getResources().getString(R.string.link_hebrew_font))); startActivity(intent); } }); break; } return builder.create(); }
From source file:ch.uzh.supersede.feedbacklibrary.FeedbackActivity.java
@Override public void onImageSelect(ScreenshotMechanismView screenshotMechanismView) { tempMechanismViewId = screenshotMechanismView.getMechanismViewIndex(); final Resources res = getResources(); final CharSequence[] items = { res.getString(R.string.supersede_feedbacklibrary_library_chooser_text), res.getString(R.string.supersede_feedbacklibrary_cancel_string) }; AlertDialog.Builder builder = new AlertDialog.Builder(FeedbackActivity.this); builder.setTitle(res.getString(R.string.supersede_feedbacklibrary_image_selection_dialog_title)); builder.setItems(items, new DialogInterface.OnClickListener() { @Override/*from w w w. j a v a2 s. c o m*/ public void onClick(DialogInterface dialog, int item) { if (!items[item].equals(res.getString(R.string.supersede_feedbacklibrary_cancel_string))) { boolean result = Utils.checkSinglePermission(FeedbackActivity.this, PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, null, null, false); if (items[item].equals(res.getString(R.string.supersede_feedbacklibrary_photo_capture_text))) { userScreenshotChosenTask = res .getString(R.string.supersede_feedbacklibrary_photo_capture_text); if (result) { } } else if (items[item] .equals(res.getString(R.string.supersede_feedbacklibrary_library_chooser_text))) { userScreenshotChosenTask = res .getString(R.string.supersede_feedbacklibrary_library_chooser_text); if (result) { galleryIntent(); } } } else { dialog.dismiss(); } } }); builder.show(); }
From source file:app.android.datetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;/* w w w.j a va 2 s. c o m*/ // Set up accessibility components. mTouchHelper = new MonthViewTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.diandi.widget.googledatetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;/*from ww w . j ava2 s . c om*/ // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.doomonafireball.betterpickers.calendardatepicker.MonthView.java
public MonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;/*from w w w. ja v a 2 s .c o m*/ // Set up accessibility components. mTouchHelper = new MonthViewTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); sMiniDayNumberTextSize = res.getDimensionPixelSize(R.dimen.day_number_size); sMonthLabelTextSize = res.getDimensionPixelSize(R.dimen.month_label_size); sMonthDayLabelTextSize = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); sMonthHeaderSize = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); sDaySelectedCircleSize = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - sMonthHeaderSize) / MAX_NUM_ROWS;/*from w w w .ja v a2 s . c om*/ // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.deange.datetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.HOLOYOLO); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;/*from www . ja va 2 s .c o m*/ // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.android.emailcommon.provider.EmailContent.java
public static synchronized void init(Context context) { if (AUTHORITY == null) { final Resources res = context.getResources(); EMAIL_PACKAGE_NAME = res.getString(R.string.email_package_name); AUTHORITY = EMAIL_PACKAGE_NAME + ".provider"; LogUtils.d("EmailContent", "init for " + AUTHORITY); NOTIFIER_AUTHORITY = EMAIL_PACKAGE_NAME + ".notifier"; CONTENT_URI = Uri.parse("content://" + AUTHORITY); CONTENT_NOTIFIER_URI = Uri.parse("content://" + NOTIFIER_AUTHORITY); PICK_TRASH_FOLDER_URI = Uri.parse("content://" + AUTHORITY + "/pickTrashFolder"); PICK_SENT_FOLDER_URI = Uri.parse("content://" + AUTHORITY + "/pickSentFolder"); MAILBOX_NOTIFICATION_URI = Uri.parse("content://" + AUTHORITY + "/mailboxNotification"); MAILBOX_MOST_RECENT_MESSAGE_URI = Uri.parse("content://" + AUTHORITY + "/mailboxMostRecentMessage"); ACCOUNT_CHECK_URI = Uri.parse("content://" + AUTHORITY + "/accountCheck"); PROVIDER_PERMISSION = EMAIL_PACKAGE_NAME + ".permission.ACCESS_PROVIDER"; // Initialize subclasses Account.initAccount();/*from w ww.jav a2 s . c o m*/ Mailbox.initMailbox(); QuickResponse.initQuickResponse(); HostAuth.initHostAuth(); Credential.initCredential(); Policy.initPolicy(); Message.initMessage(); MessageMove.init(); MessageStateChange.init(); Body.initBody(); Attachment.initAttachment(); } }