private String gtxt(int id) { return mContext.getText(id).toString(); }
public static class MyOtherAlertDialog { public static AlertDialog create(Context context) { final TextView message = new TextView(context); // i.e.: R.string.dialog_message => // "Test this dialog following the link to dtmilano.blogspot.com" final SpannableString s = new SpannableString(context.getText(R.string.dialog_message)); Linkify.addLinks(s, Linkify.WEB_URLS); message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(context) .setTitle(R.string.dialog_title) .setCancelable(true) .setIcon(android.R.drawable.ic_dialog_info) .setPositiveButton(R.string.dialog_action_dismiss, null) .setView(message) .create(); } }
public final CharSequence getText(@StringRes int id) { return getContext().getText(id); }
img_tip_logo.setVisibility(View.VISIBLE); progress.setVisibility(View.GONE); tv_tips.setText(getContext().getText(R.string.empty).toString()); img_tip_logo.setImageResource(R.drawable.no_content_tip); break; progress.setVisibility(View.GONE); if (TextUtils.isEmpty(errorMsg)){ tv_tips.setText(getContext().getText(R.string.net_error).toString()); }else { tv_tips.setText(errorMsg); progress.setVisibility(View.GONE); if (TextUtils.isEmpty(errorMsg)){ tv_tips.setText(getContext().getText(R.string.net_error).toString()); }else { tv_tips.setText(errorMsg); img_tip_logo.setVisibility(View.GONE); progress.setVisibility(View.VISIBLE); tv_tips.setText(getContext().getText(R.string.loading).toString()); break; case finish:
@Test public void stringResIsSet() { int stringWithNoArgs = R.string.string_with_no_args; ViewWithAnnotationsForIntegrationTestModel_ model = new ViewWithAnnotationsForIntegrationTestModel_() .requiredText(stringWithNoArgs); ViewWithAnnotationsForIntegrationTest view = bind(model); assertEquals(view.getContext().getText(stringWithNoArgs), view.requiredText); }
public void shareFileDialog(int position) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(getItem(position).getFilePath()))); shareIntent.setType("audio/mp4"); mContext.startActivity(Intent.createChooser(shareIntent, mContext.getText(R.string.send_to))); }
/** * Sets the tab's title. * * @param context * The context, which should be used, as an instance of the class {@link Context}. The * context may not be null * @param resourceId * The resource id of the title, which should be set, as an {@link Integer} value. The * resource id must correspond to a valid string resource */ public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) { setTitle(context.getText(resourceId)); }
public void showStopSyncthingWarningNotification() { final String msg = mContext.getString(R.string.appconfig_receiver_background_enabled); NotificationCompat.Builder nb = getNotificationBuilder(mInfoChannel) .setContentText(msg) .setTicker(msg) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) .setContentTitle(mContext.getText(mContext.getApplicationInfo().labelRes)) .setSmallIcon(R.drawable.ic_stat_notify) .setAutoCancel(true) .setContentIntent(PendingIntent.getActivity(mContext, 0, new Intent(mContext, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { nb.setCategory(Notification.CATEGORY_ERROR); } mNotificationManager.notify(ID_STOP_BACKGROUND_WARNING, nb.build()); } }
@Override public void setToolbarTitle(@StringRes final int resourceId) { setToolbarTitle(getContext().getText(resourceId)); }
private void deviceCheck() { if (Build.VERSION.SDK_INT >= 21) { if ((G.isDoKey(context) || isDonate())) { KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); if (keyguardManager.isKeyguardSecure()) { Intent createConfirmDeviceCredentialIntent = keyguardManager.createConfirmDeviceCredentialIntent(null, null); if (createConfirmDeviceCredentialIntent != null) { try { activity.startActivityForResult(createConfirmDeviceCredentialIntent, LOCK_VERIFICATION); } catch (ActivityNotFoundException e) { } } } else { Toast.makeText(activity, context.getText(R.string.android_version), Toast.LENGTH_SHORT).show(); } } else { Api.donateDialog(activity, true); } } }
public static void donateDialog(final Context ctx, boolean showToast) { if (showToast) { Toast.makeText(ctx, ctx.getText(R.string.donate_only), Toast.LENGTH_LONG).show(); } else { try { .show(); } catch (Exception e) { Toast.makeText(ctx, ctx.getText(R.string.donate_only), Toast.LENGTH_LONG).show();
public class NonActivity { public static void doStuff(Context context) { String TTT = context.getText(R.string.TTT); ... } }
public static CharSequence getText(Context context, int id, Object... args) { for(int i = 0; i < args.length; ++i) args[i] = args[i] instanceof String? TextUtils.htmlEncode((String)args[i]) : args[i]; return Html.fromHtml(String.format(Html.toHtml(new SpannedString(context.getText(id))), args)); }
@Override public int notify(final int titleId, final CharSequence message, final Intent intent) { final CharSequence title = BaseDroidApp.context.getText(titleId); return notify(title, message, intent); }
public void onRefreshComplete() { mState = DONE; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String date = format.format(new Date()); mHtvTime.setText(getContext().getText(R.string.pull_to_refresh_date) + date); changeHeaderViewByState(); }
public OverviewScreenAccessibilityDelegate(Workspace workspace) { mWorkspace = workspace; Context context = mWorkspace.getContext(); boolean isRtl = Utilities.isRtl(context.getResources()); mActions.put(MOVE_BACKWARD, new AccessibilityAction(MOVE_BACKWARD, context.getText(isRtl ? R.string.action_move_screen_right : R.string.action_move_screen_left))); mActions.put(MOVE_FORWARD, new AccessibilityAction(MOVE_FORWARD, context.getText(isRtl ? R.string.action_move_screen_left : R.string.action_move_screen_right))); }
/** * Sets the prompt to display when the dialog is shown. * @param promptId the resource ID of the prompt to display when the dialog is shown */ public void setPromptId(int promptId) { setPrompt(getContext().getText(promptId)); }
public void setTitle(@StringRes int resId) { if (getContext() != null) { setTitle(getContext().getText(resId)); } }
private void movePage(int finalIndex, View view) { mWorkspace.onStartReordering(); mWorkspace.removeView(view); mWorkspace.addView(view, finalIndex); mWorkspace.onEndReordering(); mWorkspace.announceForAccessibility(mWorkspace.getContext().getText(R.string.screen_moved)); mWorkspace.updateAccessibilityFlags(); view.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); }