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

The following examples show how to use android.content.res.Resources#getText() . 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: DataReductionPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Returns summary string.
 */
public static String generateSummary(Resources resources) {
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
        String percent = DataReductionProxySettings.getInstance()
                .getContentLengthPercentSavings();
        return resources.getString(
                R.string.data_reduction_menu_item_summary, percent);
    } else {
        return (String) resources.getText(R.string.text_off);
    }
}
 
Example 2
Source File: AppOpsState.java    From AppOpsXposed with GNU General Public License v3.0 5 votes vote down vote up
public CharSequence getTimeText(Resources res, boolean showEmptyText) {
    if (isRunning()) {
        return res.getText(R.string.app_ops_running);
    }
    if (getTime() > 0) {
        return DateUtils.getRelativeTimeSpanString(getTime(),
                System.currentTimeMillis(),
                DateUtils.MINUTE_IN_MILLIS,
                DateUtils.FORMAT_ABBREV_RELATIVE);
    }
    return showEmptyText ? res.getText(R.string.app_ops_never_used) : "";
}
 
Example 3
Source File: KBoard.java    From kboard with GNU General Public License v3.0 5 votes vote down vote up
public void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_go);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_next);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_send);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            break;
    }
}
 
Example 4
Source File: MenuBuilder.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes,
        final Drawable icon, final View view) {
    final Resources r = getResources();

    if (view != null) {
        mHeaderView = view;

        // If using a custom view, then the title and icon aren't used
        mHeaderTitle = null;
        mHeaderIcon = null;
    } else {
        if (titleRes > 0) {
            mHeaderTitle = r.getText(titleRes);
        } else if (title != null) {
            mHeaderTitle = title;
        }

        if (iconRes > 0) {
            mHeaderIcon = r.getDrawable(iconRes);
        } else if (icon != null) {
            mHeaderIcon = icon;
        }

        // If using the title or icon, then a custom view isn't used
        mHeaderView = null;
    }

    // Notify of change
    onItemsChanged(false);
}
 
Example 5
Source File: PreferenceActivity.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
/**
 * Return the currently set summary.  If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned.  Otherwise
 * {@link #summary} is returned.
 */
public CharSequence getSummary(Resources res) {
    if (summaryRes != 0) {
        return res.getText(summaryRes);
    }
    return summary;
}
 
Example 6
Source File: Preferences.java    From Androzic with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Return the currently set bread crumb short title. If {@link #breadCrumbShortTitleRes} is set,
 * this resource is loaded from <var>res</var> and returned. Otherwise {@link #breadCrumbShortTitle} is returned.
 */
public CharSequence getBreadCrumbShortTitle(Resources res)
{
	if (breadCrumbShortTitleRes != 0)
	{
		return res.getText(breadCrumbShortTitleRes);
	}
	return breadCrumbShortTitle;
}
 
Example 7
Source File: KBoard.java    From kboard with GNU General Public License v3.0 5 votes vote down vote up
public void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_go);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_next);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_send);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            break;
    }
}
 
Example 8
Source File: DataReductionPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Returns summary string.
 */
public static String generateSummary(Resources resources) {
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
        String percent = DataReductionProxySettings.getInstance()
                .getContentLengthPercentSavings();
        return resources.getString(
                R.string.data_reduction_menu_item_summary, percent);
    } else {
        return (String) resources.getText(R.string.text_off);
    }
}
 
Example 9
Source File: DataReductionPreferences.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Returns summary string.
 */
public static String generateSummary(Resources resources) {
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
        String percent = DataReductionProxySettings.getInstance()
                .getContentLengthPercentSavings();
        return resources.getString(
                R.string.data_reduction_menu_item_summary, percent);
    } else {
        return (String) resources.getText(R.string.text_off);
    }
}
 
Example 10
Source File: ResourceHelper.java    From MaterialDesignSupport with MIT License 5 votes vote down vote up
public static CharSequence getResText(int resourceId) {
    Context context = CoreMaterialApplication.getContext();
    if (context == null) {
        return null;
    }

    Resources resources = context.getResources();
    if (resources == null) {
        return null;
    }

    return resources.getText(resourceId);
}
 
Example 11
Source File: LatinKeyboard.java    From AndroidKeyboard with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This looks at the ime options given by the current editor, to set the
 * appropriate label on the keyboard's enter key (if it has one).
 */
void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }
    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_go_key);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_next_key);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.ic_search_45dp);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_send_key);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.ic_check_circle_45dp);
            mEnterKey.label = null;
            break;
    }
}
 
Example 12
Source File: DashboardCategory.java    From AcDisplay with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the currently set title. If {@link #titleRes} is set,
 * this resource is loaded from <var>res</var> and stored in {@link #title}.
 */
public CharSequence getTitle(Resources res) {
    if (titleRes != 0) {
        title = res.getText(titleRes);
        titleRes = 0;
    }

    return title;
}
 
Example 13
Source File: LatinKeyboard.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * This looks at the ime options given by the current editor, to set the
 * appropriate label on the keyboard's enter key (if it has one).
 */
void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    int valnorm = KeyEvent.KEYCODE_ENTER;

    switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_go_key);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_next_key);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_send_key);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            mEnterKey.codes = TERMINAL_ENTER;
            break;
    }
}
 
Example 14
Source File: MenuBuilder.java    From android-apps with MIT License 5 votes vote down vote up
private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes,
        final Drawable icon, final View view) {
    final Resources r = getResources();

    if (view != null) {
        mHeaderView = view;

        // If using a custom view, then the title and icon aren't used
        mHeaderTitle = null;
        mHeaderIcon = null;
    } else {
        if (titleRes > 0) {
            mHeaderTitle = r.getText(titleRes);
        } else if (title != null) {
            mHeaderTitle = title;
        }

        if (iconRes > 0) {
            mHeaderIcon = r.getDrawable(iconRes);
        } else if (icon != null) {
            mHeaderIcon = icon;
        }

        // If using the title or icon, then a custom view isn't used
        mHeaderView = null;
    }

    // Notify of change
    onItemsChanged(false);
}
 
Example 15
Source File: PreferenceActivity.java    From PreferenceFragment with Apache License 2.0 5 votes vote down vote up
/**
 * Return the currently set bread crumb title. If {@link #breadCrumbTitleRes} is set,
 * this resource is loaded from <var>res</var> and returned. Otherwise
 * {@link #breadCrumbTitle} is returned.
 */
public CharSequence getBreadCrumbTitle(Resources res) {
    if (breadCrumbTitleRes != 0) {
        return res.getText(breadCrumbTitleRes);
    }
    return breadCrumbTitle;
}
 
Example 16
Source File: PreferenceActivity.java    From PreferenceFragment with Apache License 2.0 5 votes vote down vote up
/**
 * Return the currently set summary. If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned. Otherwise {@link #summary} is
 * returned.
 */
public CharSequence getSummary(Resources res) {
    if (summaryRes != 0) {
        return res.getText(summaryRes);
    }
    return summary;
}
 
Example 17
Source File: PreferenceActivity.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Return the currently set summary.  If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned.  Otherwise
 * {@link #summary} is returned.
 */
public CharSequence getSummary(Resources res) {
    if (summaryRes != 0) {
        return res.getText(summaryRes);
    }
    return summary;
}
 
Example 18
Source File: PlaybackModule.java    From PainlessMusicPlayer with Apache License 2.0 5 votes vote down vote up
@Provides
SearchPlaybackInitializer provideSearchPlaybackInitializer(
        @NonNull final Resources resources,
        @NonNull final PlaybackInitializer playbackInitializer,
        @NonNull final PlaybackServiceControl playbackServiceControl,
        @NonNull final QueueProviderSearch queueProviderSearch) {
    return new SearchPlaybackInitializerImpl(
            resources.getText(R.string.No_media_found),
            resources.getString(R.string.No_media_found_for_s),
            playbackInitializer,
            playbackServiceControl,
            queueProviderSearch);
}
 
Example 19
Source File: DSubWidgetProvider.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
/**
    * Update all active widget instances by pushing changes
    */
   private void performUpdate(Context context, DownloadService service, int[] appWidgetIds, boolean playing) {
       final Resources res = context.getResources();
       final RemoteViews views = new RemoteViews(context.getPackageName(), getLayout());

	if(playing) {
		views.setViewVisibility(R.id.widget_root, View.VISIBLE);
	} else {
		// Hide widget
		SharedPreferences prefs = Util.getPreferences(context);
		if(prefs.getBoolean(Constants.PREFERENCES_KEY_HIDE_WIDGET, false)) {
			views.setViewVisibility(R.id.widget_root, View.GONE);
		}
	}

// Get Entry from current playing DownloadFile
       MusicDirectory.Entry currentPlaying = null;
       if(service == null) {
       	// Deserialize from playling list to setup
           try {
               PlayerQueue state = FileUtil.deserialize(context, DownloadServiceLifecycleSupport.FILENAME_DOWNLOADS_SER, PlayerQueue.class);
               if (state != null && state.currentPlayingIndex != -1) {
                   currentPlaying = state.songs.get(state.currentPlayingIndex);
               }
           } catch(Exception e) {
               Log.e(TAG, "Failed to grab current playing", e);
           }
       } else {
		currentPlaying = service.getCurrentPlaying() == null ? null : service.getCurrentPlaying().getSong();
       }
       
       String title = currentPlaying == null ? null : currentPlaying.getTitle();
       CharSequence artist = currentPlaying == null ? null : currentPlaying.getArtist();
	CharSequence album = currentPlaying == null ? null : currentPlaying.getAlbum();
       CharSequence errorState = null;

       // Show error message?
       String status = Environment.getExternalStorageState();
       if (status.equals(Environment.MEDIA_SHARED) ||
           status.equals(Environment.MEDIA_UNMOUNTED)) {
           errorState = res.getText(R.string.widget_sdcard_busy);
       } else if (status.equals(Environment.MEDIA_REMOVED)) {
           errorState = res.getText(R.string.widget_sdcard_missing);
       } else if (currentPlaying == null) {
           errorState = res.getText(R.string.widget_initial_text);
       }

       setText(views, title, artist, album, errorState);

       // Set correct drawable for pause state
       if (playing) {
           views.setImageViewResource(R.id.control_play, R.drawable.media_pause_dark);
       } else {
           views.setImageViewResource(R.id.control_play, R.drawable.media_start_dark);
       }

       setImage(views, context, currentPlaying);

       // Link actions buttons to intents
       linkButtons(context, views, currentPlaying != null);

       pushUpdate(context, appWidgetIds, views);
   }
 
Example 20
Source File: DashboardTile.java    From HeadsUp with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Return the currently set summary.  If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned.  Otherwise
 * {@link #summary} is returned.
 */
public CharSequence getSummary(Resources res) {
    return summaryRes != 0 ? res.getText(summaryRes) : summary;
}