Java Code Examples for android.content.res.Resources#getString()

The following examples show how to use android.content.res.Resources#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Controls.java    From crazyflie-android-client with GNU General Public License v2.0 6 votes vote down vote up
public void setDefaultPreferenceValues(Resources res) {
    mModeDefaultValue = res.getString(R.string.preferences_mode_defaultValue);
    mDeadzoneDefaultValue = res.getString(R.string.preferences_deadzone_defaultValue);

    mTrimDefaultValue = res.getString(R.string.preferences_trim_defaultValue);

    mGyroAmplificationDefaultValue = Integer.toString(R.string.preferences_gyro_amp_defaultValue);

    mControllerTypeDefaultValue = res.getString(R.string.preferences_controller_defaultValue);

    mAlt1ActionDefaultValue = res.getString(R.string.preferences_alt1_action_defaultValue);
    mAlt2ActionDefaultValue = res.getString(R.string.preferences_alt2_action_defaultValue);

    //Advanced flight control
    mMaxRollPitchAngleDefaultValue = res.getString(R.string.preferences_maxRollPitchAngle_defaultValue);
    mMaxYawAngleDefaultValue = res.getString(R.string.preferences_maxYawAngle_defaultValue);
    mMaxThrustDefaultValue = res.getString(R.string.preferences_maxThrust_defaultValue);
    mMinThrustDefaultValue = res.getString(R.string.preferences_minThrust_defaultValue);
}
 
Example 2
Source File: ColorPickerPalette.java    From KAM with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialize the size, columns, and listener.  Size should be a pre-defined size (SIZE_LARGE or SIZE_SMALL) from ColorPickerDialogFragment.
 */
public void init(int size, int columns, ColorPickerSwatch.OnColorSelectedListener listener) {
    mNumColumns = columns;
    Resources res = getResources();
    if (size == ColorPickerDialog.SIZE_LARGE) {
        mSwatchLength = res.getDimensionPixelSize(R.dimen.color_swatch_large);
        mMarginSize = res.getDimensionPixelSize(R.dimen.color_swatch_margins_large);
    } else {
        mSwatchLength = res.getDimensionPixelSize(R.dimen.color_swatch_small);
        mMarginSize = res.getDimensionPixelSize(R.dimen.color_swatch_margins_small);
    }
    mOnColorSelectedListener = listener;

    mDescription = res.getString(R.string.color_swatch_description);
    mDescriptionSelected = res.getString(R.string.color_swatch_description_selected);
}
 
Example 3
Source File: PageAbout.java    From Klyph with MIT License 6 votes vote down vote up
private String paymentOptionsHelper(PaymentOptions options)
{
	String s = "";

	Resources res = getResources();

	if (options.getVisa() > 0)
		s += res.getString(R.string.visa) + "\n";

	if (options.getMastercard() > 0)
		s += res.getString(R.string.mastercard) + "\n";

	if (options.getAmex() > 0)
		s += res.getString(R.string.amex) + "\n";

	if (options.getCash_only() > 0)
		s += res.getString(R.string.cash_only) + "\n";

	if (options.getDiscover() > 0)
		s += res.getString(R.string.discover) + "\n";

	if (s.length() > 0 && s.substring(s.length() - 1).equals("\n"))
		s = s.substring(0, s.length() - 1);

	return s;
}
 
Example 4
Source File: DigitalWatchFaceService.java    From wear-os-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onCreate");
    }
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(DigitalWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());
    Resources resources = DigitalWatchFaceService.this.getResources();
    mYOffset = resources.getDimension(R.dimen.digital_y_offset);
    mLineHeight = resources.getDimension(R.dimen.digital_line_height);
    mAmString = resources.getString(R.string.digital_am);
    mPmString = resources.getString(R.string.digital_pm);

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(mInteractiveBackgroundColor);
    mDatePaint = createTextPaint(
            ContextCompat.getColor(getApplicationContext(), R.color.digital_date));
    mHourPaint = createTextPaint(mInteractiveHourDigitsColor, BOLD_TYPEFACE);
    mMinutePaint = createTextPaint(mInteractiveMinuteDigitsColor);
    mSecondPaint = createTextPaint(mInteractiveSecondDigitsColor);
    mAmPmPaint = createTextPaint(
            ContextCompat.getColor(getApplicationContext(), R.color.digital_am_pm));
    mColonPaint = createTextPaint(
            ContextCompat.getColor(getApplicationContext(), R.color.digital_colons));

    mCalendar = Calendar.getInstance();
    mDate = new Date();
    initFormats();
}
 
Example 5
Source File: AllAppsGridAdapter.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the last search query that was made, used to show when there are no results and to also
 * seed the intent for searching the market.
 */
public void setLastSearchQuery(String query) {
    Resources res = mLauncher.getResources();
    String formatStr = res.getString(R.string.all_apps_no_search_results);
    mLastSearchQuery = query;
    mEmptySearchMessage = String.format(formatStr, query);
    if (mMarketAppName != null) {
        mMarketSearchMessage = String.format(res.getString(R.string.all_apps_search_market_message),
                mMarketAppName);
        mMarketSearchIntent = createMarketSearchIntent(query);
    }
}
 
Example 6
Source File: WidgetCell.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public WidgetCell(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final Resources r = context.getResources();
    mLauncher = (Launcher) context;
    mStylusEventHelper = new StylusEventHelper(this);

    mDimensionsFormatString = r.getString(R.string.widget_dims_format);
    setContainerWidth();
    setWillNotDraw(false);
    setClipToPadding(false);
    setAccessibilityDelegate(LauncherAppState.getInstance().getAccessibilityDelegate());
}
 
Example 7
Source File: FieldTripClientsService.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {

    if (wakeLock == null && wifiLock == null) {
        updater = new Updater(this);
        updater.start();
        updater.update = false;
        final int port = intent.getIntExtra("port", 1972);

        // Get Wakelocks
        final PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, C.WAKELOCKTAG);
        wakeLock.acquire();

        final WifiManager wifiMan = (WifiManager) getSystemService(WIFI_SERVICE);
        wifiLock = wifiMan.createWifiLock(C.WAKELOCKTAGWIFI);
        wifiLock.acquire();

        // Create Foreground Notification
        // Create notification text
        final Resources res = getResources();
        final String notification_text = res.getString(R.string.notification_text);
        final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable
                .ic_launcher).setContentTitle(res.getString(R.string.notification_title)).setContentText
                (notification_text);

        // Turn this service into a foreground service
        startForeground(1, mBuilder.build());
        Log.i(TAG, "Fieldtrip Clients Service moved to foreground.");
    }

    createAllThreadsAndBroadcastInfo();

    if (threads != null) {
        this.registerReceiver(mMessageReceiver, intentFilter);
    }

    return START_NOT_STICKY;
}
 
Example 8
Source File: LocalizedContent.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Load the content for focus:rights
 */
private static void loadRights(@NonNull final IWebView webView, Context context) {
    final Resources resources = Locales.getLocalizedResources(context);

    final Map<String, String> substitutionMap = new ArrayMap<>();

    final String appName = context.getResources().getString(R.string.app_name);
    final String mplUrl = "https://www.mozilla.org/en-US/MPL/";
    final String trademarkPolicyUrl = "https://www.mozilla.org/foundation/trademarks/policy/";
    final String gplUrl = "gpl.html";
    final String trackingProtectionUrl = "https://wiki.mozilla.org/Security/Tracking_protection#Lists";
    final String licensesUrl = "licenses.html";

    final String content1 = resources.getString(R.string.your_rights_content1, appName);
    substitutionMap.put("%your-rights-content1%", content1);

    final String content2 = resources.getString(R.string.your_rights_content2, appName, mplUrl);
    substitutionMap.put("%your-rights-content2%", content2);

    final String content3 = resources.getString(R.string.your_rights_content3, appName, trademarkPolicyUrl);
    substitutionMap.put("%your-rights-content3%", content3);

    final String content4 = resources.getString(R.string.your_rights_content4, appName, licensesUrl);
    substitutionMap.put("%your-rights-content4%", content4);

    final String content5 = resources.getString(R.string.your_rights_content5, appName, gplUrl, trackingProtectionUrl);
    substitutionMap.put("%your-rights-content5%", content5);

    putLayoutDirectionIntoMap(substitutionMap, context);

    final String data = HtmlLoader.loadResourceFile(context, R.raw.rights, substitutionMap);
    webView.loadData("file:///android_asset/rights.html", data, "text/html", "UTF-8", URL_RIGHTS);
}
 
Example 9
Source File: GraphOptionsController.java    From science-journal with Apache License 2.0 5 votes vote down vote up
public void launchOptionsDialog(
    ScalarDisplayOptions scalarDisplayOptions, FailureListener failureListener) {
  Resources resources = context.getResources();
  String optionsTitle = resources.getString(R.string.graph_options_title);
  super.launchOptionsDialog(
      new GraphOptionsManager(scalarDisplayOptions).makeCallbacks(context),
      resources.getString(R.string.graph_name),
      optionsTitle,
      getOptions(failureListener));
}
 
Example 10
Source File: Folder.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 */
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);
    setAlwaysDrawnWithCacheEnabled(false);
    mHandler = new Handler();
    mInputMethodManager = (InputMethodManager)
            getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

    Resources res = getResources();
    mExpandDuration = res.getInteger(R.integer.config_folderExpandDuration);
    mMaterialExpandDuration = res.getInteger(R.integer.config_materialFolderExpandDuration);
    mMaterialExpandStagger = res.getInteger(R.integer.config_materialFolderExpandStagger);

    if (sDefaultFolderName == null) {
        sDefaultFolderName = res.getString(R.string.folder_name);
    }
    if (sHintText == null) {
        sHintText = res.getString(R.string.folder_hint_text);
    }
    mLauncher = (Launcher) context;
    // We need this view to be focusable in touch mode so that when text editing of the folder
    // name is complete, we have something to focus on, thus hiding the cursor and giving
    // reliable behavior when clicking the text field (since it will always gain focus on click).
    setFocusableInTouchMode(true);
}
 
Example 11
Source File: AmPmCirclesView.java    From StyleableDateTimePicker with MIT License 5 votes vote down vote up
public void initialize(Context context, int amOrPm) {
    if (mIsInitialized) {
        Log.e(TAG, "AmPmCirclesView may only be initialized once.");
        return;
    }

    Resources res = context.getResources();
    mUnselectedColor = res.getColor(R.color.white);
    mSelectedColor = res.getColor(R.color.blue);
    mAmPmTextColor = res.getColor(R.color.ampm_text_color);
    mSelectedAlpha = SELECTED_ALPHA;
    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;
}
 
Example 12
Source File: LanguageEditor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private String getStringFromLocale(int id, Locale desired_locale) {
    final Resources my_resources = getResources();
    final Configuration cfg = my_resources.getConfiguration();
    final Locale savedLocale = cfg.locale;
    cfg.setLocale(desired_locale);
    my_resources.updateConfiguration(cfg, null);
    final String result = my_resources.getString(id);
    cfg.setLocale(savedLocale);
    my_resources.updateConfiguration(cfg, null);
    return result;
}
 
Example 13
Source File: GameHelperUtils.java    From FixMath with Apache License 2.0 5 votes vote down vote up
static String getAppIdFromResource(Context ctx) {
    try {
        Resources res = ctx.getResources();
        String pkgName = ctx.getPackageName();
        int res_id = res.getIdentifier("app_id", "string", pkgName);
        return res.getString(res_id);
    } catch (Exception ex) {
        ex.printStackTrace();
        return "??? (failed to retrieve APP ID)";
    }
}
 
Example 14
Source File: SingleDateSelector.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public String getSelectionDisplayString(@NonNull Context context) {
  Resources res = context.getResources();
  if (selectedItem == null) {
    return res.getString(R.string.mtrl_picker_date_header_unselected);
  }
  String startString = DateStrings.getYearMonthDay(selectedItem);
  return res.getString(R.string.mtrl_picker_date_header_selected, startString);
}
 
Example 15
Source File: AdMobCustomMuteThisAdFragment.java    From android-ads with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a request for a new unified native ad based on the boolean parameters and calls the
 * "populateUnifiedNativeAdView" method when one is successfully returned.
 */
private void refreshAd() {
    refresh.setEnabled(false);
    muteButton.setEnabled(false);

    Resources resources = getActivity().getResources();
    AdLoader.Builder builder = new AdLoader.Builder(getActivity(),
            resources.getString(R.string.custommute_fragment_ad_unit_id));

    builder.forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {
        // OnUnifiedNativeAdLoadedListener implementation.
        @Override
        public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
            AdMobCustomMuteThisAdFragment.this.nativeAd = unifiedNativeAd;
            muteButton.setEnabled(unifiedNativeAd.isCustomMuteThisAdEnabled());
            nativeAd.setMuteThisAdListener(new MuteThisAdListener() {
                @Override
                public void onAdMuted() {
                    muteAd();
                    Toast.makeText(getActivity(), "Ad muted", Toast.LENGTH_SHORT).show();
                }
            });

            UnifiedNativeAdView adView = (UnifiedNativeAdView) getLayoutInflater()
                .inflate(R.layout.ad_unified, null);
            populateUnifiedNativeAdView(unifiedNativeAd, adView);
            adContainer.removeAllViews();
            adContainer.addView(adView);
        }

    });

    NativeAdOptions adOptions = new NativeAdOptions.Builder()
        .setRequestCustomMuteThisAd(true)
        .build();

    builder.withNativeAdOptions(adOptions);

    AdLoader adLoader = builder.withAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            refresh.setEnabled(true);
            Toast.makeText(getActivity(), "Failed to load native ad: "
                    + errorCode, Toast.LENGTH_SHORT).show();
        }
    }).build();

    adLoader.loadAd(new AdRequest.Builder().build());
}
 
Example 16
Source File: AppCompatTimePickerDelegate.java    From AppCompat-Extension-Library with Apache License 2.0 4 votes vote down vote up
public AppCompatTimePickerDelegate(AppCompatTimePicker delegator, Context context, AttributeSet attrs,
                                   int defStyleAttr, int defStyleRes) {
    super(delegator, context);

    // process style attributes
    final TypedArray a = mContext.obtainStyledAttributes(attrs,
            R.styleable.TimePickerDialog, defStyleAttr, defStyleRes);
    final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    final Resources res = mContext.getResources();

    mSelectHours = res.getString(R.string.select_hours);
    mSelectMinutes = res.getString(R.string.select_minutes);

    String[] amPmStrings = getAmPmStrings(context);
    mAmText = amPmStrings[0];
    mPmText = amPmStrings[1];

    final View mainView = inflater.inflate(R.layout.time_picker_material, delegator);

    mHeaderView = mainView.findViewById(R.id.time_header);

    // Set up hour/minute labels.
    mHourView = (TextView) mainView.findViewById(R.id.hours);
    mHourView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mHourView,
            new ClickActionDelegate(context, R.string.select_hours));
    mSeparatorView = (TextView) mainView.findViewById(R.id.separator);
    mMinuteView = (TextView) mainView.findViewById(R.id.minutes);
    mMinuteView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mMinuteView,
            new ClickActionDelegate(context, R.string.select_minutes));

    // Now that we have text appearances out of the way, make sure the hour
    // and minute views are correctly sized.
    mHourView.setMinWidth(computeStableWidth(mHourView, 24));
    mMinuteView.setMinWidth(computeStableWidth(mMinuteView, 60));

    // Set up AM/PM labels.
    mAmPmLayout = mainView.findViewById(R.id.ampm_layout);
    mAmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.am_label);
    mAmLabel.setText(obtainVerbatim(amPmStrings[0]));
    mAmLabel.setOnClickListener(mClickListener);
    mPmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.pm_label);
    mPmLabel.setText(obtainVerbatim(amPmStrings[1]));
    mPmLabel.setOnClickListener(mClickListener);


    // Set up header text color, if available.
    ColorStateList headerTextColor;
    if (a.hasValue(R.styleable.TimePickerDialog_headerTextColor)) {
        headerTextColor = a.getColorStateList(R.styleable.DatePickerDialog_headerTextColor);
    } else {
        headerTextColor = PickerThemeUtils.getHeaderTextColorStateList(mContext);
    }
    mHourView.setTextColor(headerTextColor);
    mSeparatorView.setTextColor(headerTextColor);
    mMinuteView.setTextColor(headerTextColor);
    mAmLabel.setTextColor(headerTextColor);
    mPmLabel.setTextColor(headerTextColor);

    // Set up header background, if available.
    ViewCompatUtils.setBackground(mHeaderView, PickerThemeUtils.getHeaderBackground(mContext,
            a.getColor(R.styleable.DatePickerDialog_headerBackground,
                    ThemeUtils.getThemeAttrColor(mContext, R.attr.colorAccent))));

    a.recycle();

    mRadialTimePickerView = (RadialTimePickerView) mainView.findViewById(
            R.id.radial_picker);

    setupListeners();

    mAllowAutoAdvance = true;

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();

    // Initialize with current time
    final Calendar calendar = Calendar.getInstance(mCurrentLocale);
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);
    initialize(currentHour, currentMinute, false /* 12h */, HOUR_INDEX);
}
 
Example 17
Source File: CallSupportError.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@NonNull
public String getAcceptButtonTitle (@NonNull Resources resources) {
    return resources.getString(acceptButtonText);
}
 
Example 18
Source File: HeartRateDeviceSettingsFragment.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
/**
 * Display the error dialog for no permissions.
 */
private void showErrorDialogNoPermissions() {
    Resources res = getActivity().getResources();
    String message = res.getString(R.string.heart_rate_setting_dialog_error_permission);
    showErrorDialog(message);
}
 
Example 19
Source File: SearchView.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create and return an Intent that can launch the voice search activity, perform a specific
 * voice transcription, and forward the results to the searchable activity.
 *
 * @param baseIntent The voice app search intent to start from
 * @return A completely-configured intent ready to send to the voice search activity
 */
private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
    ComponentName searchActivity = searchable.getSearchActivity();

    // create the necessary intent to set up a search-and-forward operation
    // in the voice search system.   We have to keep the bundle separate,
    // because it becomes immutable once it enters the PendingIntent
    Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
    queryIntent.setComponent(searchActivity);
    PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent,
            PendingIntent.FLAG_ONE_SHOT);

    // Now set up the bundle that will be inserted into the pending intent
    // when it's time to do the search.  We always build it here (even if empty)
    // because the voice search activity will always need to insert "QUERY" into
    // it anyway.
    Bundle queryExtras = new Bundle();

    // Now build the intent to launch the voice search.  Add all necessary
    // extras to launch the voice recognizer, and then all the necessary extras
    // to forward the results to the searchable activity
    Intent voiceIntent = new Intent(baseIntent);

    // Add all of the configuration options supplied by the searchable's metadata
    String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
    String prompt = null;
    String language = null;
    int maxResults = 1;

    Resources resources = getResources();
    if (searchable.getVoiceLanguageModeId() != 0) {
        languageModel = resources.getString(searchable.getVoiceLanguageModeId());
    }
    if (searchable.getVoicePromptTextId() != 0) {
        prompt = resources.getString(searchable.getVoicePromptTextId());
    }
    if (searchable.getVoiceLanguageId() != 0) {
        language = resources.getString(searchable.getVoiceLanguageId());
    }
    if (searchable.getVoiceMaxResults() != 0) {
        maxResults = searchable.getVoiceMaxResults();
    }
    voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
            : searchActivity.flattenToShortString());

    // Add the values that configure forwarding the results
    voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);

    return voiceIntent;
}
 
Example 20
Source File: Reminder.java    From narrate-android with Apache License 2.0 3 votes vote down vote up
public static String getOccurence(Resources res, DateTime date, Recurrence er) {
    if ( er.getInternalValue() > 0 ) {

        if (er == null)
            return null;

        if (er == Recurrence.Daily)
            return res.getString(R.string.daily_occurrence) + mTimeFormat.format(date.toDate());

        if (er == Recurrence.Weekly)
            return res.getString(R.string.weekly_occurrence) + mDayOfWeek.format(date.toDate()) + res.getString(R.string.at) + mTimeFormat.format(date.toDate());

        if (er == Recurrence.Monthly)
            return NumberUtil.getOrdinalSuffix(date.getDayOfMonth()) + res.getString(R.string.monthly_occurrence);

        if ( er == Recurrence.Yearly)
            return mYearlyFormat.format(date.toDate()) + res.getString(R.string.yearly_occurrence);

        return null;

    } else {

        if ( DateUtil.isToday(date) )
            return res.getString(R.string.today_occurrence) + mTimeFormat.format(date.toDate());

        if ( DateUtil.isTomorrow(date) )
            return res.getString(R.string.tomorrow_occurrence) + mTimeFormat.format(date.toDate());

        return mDateFormat.format(date.toDate()) + res.getString(R.string.at) + mTimeFormat.format(date.toDate());

    }
}