List of usage examples for android.content.res Resources getString
@NonNull public String getString(@StringRes int id) throws NotFoundException
From source file:com.android.datetimepicker.date.MonthView.java
public MonthView(Context context, AttributeSet attr) { super(context, attr); 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); mDisabledDayTextColor = res.getColor(R.color.date_picker_text_disabled); 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) - getMonthHeaderSize()) / MAX_NUM_ROWS;/*from ww w . java 2s . com*/ // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); 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.customdatepicker.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;/*from ww w . java2 s.c om*/ Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(mController.getTimeZone()); mCalendar = Calendar.getInstance(mController.getTimeZone()); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme); mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme); mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled_dark_theme); mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted_dark_theme); } else { mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal); mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day); mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled); mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted); } mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white); mTodayNumberColor = mController.getAccentColor(); mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white); mStringBuilder = new StringBuilder(50); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); 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.zia.freshdocs.widget.CMISAdapter.java
/** * Send the content using a built-in Android activity which can handle the content type. * @param position/* w w w . jav a 2 s. com*/ */ public void shareContent(int position) { final NodeRef ref = getItem(position); downloadContent(ref, new Handler() { public void handleMessage(Message msg) { Context context = getContext(); boolean done = msg.getData().getBoolean("done"); if (done) { dismissProgressDlg(); File file = (File) _dlThread.getResult(); if (file != null) { Resources res = context.getResources(); Uri uri = Uri.fromFile(file); Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_STREAM, uri); emailIntent.putExtra(Intent.EXTRA_SUBJECT, ref.getName()); emailIntent.putExtra(Intent.EXTRA_TEXT, res.getString(R.string.email_text)); emailIntent.setType(ref.getContentType()); try { context.startActivity( Intent.createChooser(emailIntent, res.getString(R.string.email_title))); } catch (ActivityNotFoundException e) { String text = "No suitable applications registered to send " + ref.getContentType(); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } } } else { int value = msg.getData().getInt("progress"); if (value > 0) { _progressDlg.setProgress(value); } } } }); }
From source file:com.chauffeurprive.kronos.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;/*from w ww .ja v a 2s .c om*/ Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); mDayTextColor = ContextCompat.getColor(context, mController.getTextColor()); mMonthDayTextColor = ContextCompat.getColor(context, mController.getTextColor()); mDisabledDayTextColor = ContextCompat.getColor(context, mController.getDisabledTextColor()); mHighlightedDayTextColor = ContextCompat.getColor(context, mController.getTextColor()); mSelectedDayTextColor = ContextCompat.getColor(context, mController.getSelectedTextColor()); mTodayNumberColor = ContextCompat.getColor(context, mController.getTodayTextColor()); mMonthTitleColor = ContextCompat.getColor(context, mController.getTextColor()); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); 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.deskclock.data.TimerNotificationBuilderN.java
@Override public Notification build(Context context, NotificationModel nm, List<Timer> unexpired) { final Timer timer = unexpired.get(0); final int count = unexpired.size(); // Compute some values required below. final boolean running = timer.isRunning(); final Resources res = context.getResources(); final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final RemoteViews content = new RemoteViews(pname, R.layout.chronometer_notif_content); content.setChronometerCountDown(R.id.chronometer, true); content.setChronometer(R.id.chronometer, base, null, running); final List<Notification.Action> actions = new ArrayList<>(2); final CharSequence stateText; if (count == 1) { if (running) { // Single timer is running. if (TextUtils.isEmpty(timer.getLabel())) { stateText = res.getString(R.string.timer_notification_label); } else { stateText = timer.getLabel(); }/* w ww.j a v a 2 s . c o m*/ // Left button: Pause final Intent pause = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_PAUSE_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_pause_24dp); final CharSequence title1 = res.getText(R.string.timer_pause); final PendingIntent intent1 = Utils.pendingServiceIntent(context, pause); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right Button: +1 Minute final Intent addMinute = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_ADD_MINUTE_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon2 = Icon.createWithResource(context, R.drawable.ic_add_24dp); final CharSequence title2 = res.getText(R.string.timer_plus_1_min); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addMinute); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } else { // Single timer is paused. stateText = res.getString(R.string.timer_paused); // Left button: Start final Intent start = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_START_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_start_24dp); final CharSequence title1 = res.getText(R.string.sw_resume_button); final PendingIntent intent1 = Utils.pendingServiceIntent(context, start); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right Button: Reset final Intent reset = new Intent(context, TimerService.class) .setAction(HandleDeskClockApiCalls.ACTION_RESET_TIMER) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()); final Icon icon2 = Icon.createWithResource(context, R.drawable.ic_reset_24dp); final CharSequence title2 = res.getText(R.string.sw_reset_button); final PendingIntent intent2 = Utils.pendingServiceIntent(context, reset); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } } else { if (running) { // At least one timer is running. stateText = res.getString(R.string.timers_in_use, count); } else { // All timers are paused. stateText = res.getString(R.string.timers_stopped, count); } final Intent reset = TimerService.createResetUnexpiredTimersIntent(context); final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_reset_24dp); final CharSequence title1 = res.getText(R.string.timer_reset_all); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); } content.setTextViewText(R.id.state, stateText); // Intent to load the app and show the timer when the notification is tapped. final Intent showApp = new Intent(context, HandleDeskClockApiCalls.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setAction(HandleDeskClockApiCalls.ACTION_SHOW_TIMERS) .putExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, timer.getId()) .putExtra(HandleDeskClockApiCalls.EXTRA_EVENT_LABEL, R.string.label_notification); final PendingIntent pendingShowApp = PendingIntent.getActivity(context, 0, showApp, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); return new Notification.Builder(context).setOngoing(true).setLocalOnly(true).setShowWhen(false) .setAutoCancel(false).setCustomContentView(content).setContentIntent(pendingShowApp) .setPriority(Notification.PRIORITY_HIGH).setCategory(Notification.CATEGORY_ALARM) .setSmallIcon(R.drawable.stat_notify_timer).setGroup(nm.getTimerNotificationGroupKey()) .setVisibility(Notification.VISIBILITY_PUBLIC).setStyle(new Notification.DecoratedCustomViewStyle()) .setActions(actions.toArray(new Notification.Action[actions.size()])) .setColor(ContextCompat.getColor(context, R.color.default_background)).build(); }
From source file:com.borax12.materialdaterangepicker.single.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;/*from w w w . ja v a2 s. c om*/ Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme); mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme); mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled_dark_theme); mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted_dark_theme); } else { mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal); mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day); mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled); mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted); } mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white); mTodayNumberColor = mController.getAccentColor(); mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); 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.google.android.apps.santatracker.map.TvSantaMapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // App Measurement mMeasurement = FirebaseAnalytics.getInstance(this); MeasurementManager.recordScreenView(mMeasurement, getString(R.string.analytics_screen_tracker)); // [ANALYTICS SCREEN]: Tracker AnalyticsManager.sendScreenView(R.string.analytics_screen_tracker); setContentView(R.layout.activity_map_tv); mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); Resources resources = getResources(); LOST_CONTACT_STRING = resources.getString(R.string.lost_contact_with_santa); ANNOUNCE_ARRIVED_AT = resources.getString(R.string.santa_is_now_arriving_in_x); NO_NEXT_DESTINATION = resources.getString(R.string.no_next_destination); // Concatenate String for 'travel to' announcement StringBuilder sb = new StringBuilder(); sb.append(resources.getString(R.string.in_transit)); sb.append(" "); sb.append(resources.getString(R.string.next_destination)); sb.append(" %s"); ANNOUNCE_TRAVEL_TO = sb.toString();//from w w w . j av a 2 s . co m sb.setLength(0); // Get Map fragments mMapFragment = (SantaMapFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_map); // Set Overscan Padding final int widthPadding = getResources().getDimensionPixelOffset(R.dimen.overscan_padding_width); final int heightPadding = getResources().getDimensionPixelOffset(R.dimen.overscan_padding_height); final int cardPadding = getResources().getDimensionPixelOffset(R.dimen.card_width); mMapFragment.setCamPadding(widthPadding, heightPadding, widthPadding + cardPadding, heightPadding); mVerticalGridView = (VerticalGridView) findViewById(R.id.stream); mVerticalGridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE); mVerticalGridView.setHasFixedSize(false); mAdapter = new CardAdapter(getApplicationContext(), mCardAdapterListener, mDestinationListener, true); mAdapter.setHasStableIds(true); mVerticalGridView.setAdapter(mAdapter); }
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_SEARCH: mBottomBarControls.showSearch(true); return true; case MENU_PLAYBACK: openPlaybackActivity();/*from w ww . j a v a 2 s .com*/ return true; case MENU_SORT: { MediaAdapter adapter = (MediaAdapter) mCurrentAdapter; LinearLayout header = (LinearLayout) getLayoutInflater().inflate(R.layout.sort_dialog, null); CheckBox reverseSort = (CheckBox) header.findViewById(R.id.reverse_sort); int[] itemIds = adapter.getSortEntries(); String[] items = new String[itemIds.length]; Resources res = getResources(); for (int i = itemIds.length; --i != -1;) { items[i] = res.getString(itemIds[i]); } int mode = adapter.getSortMode(); if (mode < 0) { mode = ~mode; reverseSort.setChecked(true); } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.sort_by); builder.setSingleChoiceItems(items, mode + 1, this); // add 1 for header builder.setNeutralButton(R.string.done, null); AlertDialog dialog = builder.create(); dialog.getListView().addHeaderView(header); dialog.setOnDismissListener(this); dialog.show(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:com.android.contacts.common.model.ContactLoader.java
private void loadDirectoryMetaData(Contact result) { long directoryId = result.getDirectoryId(); Cursor cursor = getContext().getContentResolver().query( ContentUris.withAppendedId(Directory.CONTENT_URI, directoryId), DirectoryQuery.COLUMNS, null, null, null);//w ww.j ava 2 s . c o m if (cursor == null) { return; } try { if (cursor.moveToFirst()) { final String displayName = cursor.getString(DirectoryQuery.DISPLAY_NAME); final String packageName = cursor.getString(DirectoryQuery.PACKAGE_NAME); final int typeResourceId = cursor.getInt(DirectoryQuery.TYPE_RESOURCE_ID); final String accountType = cursor.getString(DirectoryQuery.ACCOUNT_TYPE); final String accountName = cursor.getString(DirectoryQuery.ACCOUNT_NAME); final int exportSupport = cursor.getInt(DirectoryQuery.EXPORT_SUPPORT); String directoryType = null; if (!TextUtils.isEmpty(packageName)) { PackageManager pm = getContext().getPackageManager(); try { Resources resources = pm.getResourcesForApplication(packageName); directoryType = resources.getString(typeResourceId); } catch (NameNotFoundException e) { Log.w(TAG, "Contact directory resource not found: " + packageName + "." + typeResourceId); } } result.setDirectoryMetaData(displayName, directoryType, accountType, accountName, exportSupport); } } finally { cursor.close(); } }
From source file:com.zia.freshdocs.widget.adapter.CMISAdapter.java
protected void startProgressDlg(boolean indeterminate) { Context context = getContext(); Resources res = context.getResources(); if (mProgressDlg == null || !mProgressDlg.isShowing()) { mProgressDlg = new ProgressDialog(context); mProgressDlg.setProgressStyle(//from ww w . j ava 2 s . c om indeterminate ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL); mProgressDlg.setMessage(res.getString(R.string.loading)); mProgressDlg.setTitle(""); mProgressDlg.setCancelable(true); mProgressDlg.setIndeterminate(indeterminate); mProgressDlg.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { interrupt(); } }); mProgressDlg.show(); } }