android.text.BidiFormatter Java Examples
The following examples show how to use
android.text.BidiFormatter.
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: TimeUtil.java From AndroidWallet with GNU General Public License v3.0 | 6 votes |
public static String getTimeZoneText(TimeZone tz, boolean includeName) { Date now = new Date(); SimpleDateFormat gmtFormatter = new SimpleDateFormat("ZZZZ"); gmtFormatter.setTimeZone(tz); String gmtString = gmtFormatter.format(now); BidiFormatter bidiFormatter = BidiFormatter.getInstance(); Locale l = Locale.getDefault(); boolean isRtl = TextUtils.getLayoutDirectionFromLocale(l) == View.LAYOUT_DIRECTION_RTL; gmtString = bidiFormatter.unicodeWrap(gmtString, isRtl ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR); if (!includeName) { return gmtString; } return gmtString; }
Example #2
Source File: NumberAnimTextView.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressLint("SetTextI18n") private void start() { if (!mIsEnableAnim) { // 禁止动画 setText(mPrefixString + format(new BigDecimal(mNumEnd)) + mPostfixString); return; } BidiFormatter f = BidiFormatter.getInstance(); animator = ValueAnimator.ofObject(new BigDecimalEvaluator(), new BigDecimal(mNumStart), new BigDecimal(mNumEnd)); animator.setDuration(mDuration); animator.setInterpolator(new DecelerateInterpolator(3f)); animator.addUpdateListener(valueAnimator -> { BigDecimal value = (BigDecimal) valueAnimator.getAnimatedValue(); setText(mPrefixString + f.unicodeWrap(format(value)) + mPostfixString); }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setText(mPrefixString + f.unicodeWrap(mNumEnd) + mPostfixString); } }); animator.start(); }
Example #3
Source File: Hourly.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressLint("DefaultLocale") public String getHour(Context c) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int hour; if (TimeManager.is12Hour(c)) { hour = calendar.get(Calendar.HOUR); if (hour == 0) { hour = 12; } } else { hour = calendar.get(Calendar.HOUR_OF_DAY); } if (DisplayUtils.isRtl(c)) { return BidiFormatter.getInstance().unicodeWrap(String.format("%d", hour)) + c.getString(R.string.of_clock); } else { return hour + c.getString(R.string.of_clock); } }
Example #4
Source File: Formatter.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static String bidiWrap(@NonNull Context context, String source) { final Locale locale = localeFromContext(context); if (TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL) { return BidiFormatter.getInstance(true /* RTL*/).unicodeWrap(source); } else { return source; } }
Example #5
Source File: NumberAnimTextView.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressLint("SetTextI18n") public void setNumberString(String numberStart, String numberEnd) { mNumStart = numberStart; mNumEnd = numberEnd; if (checkNumString(numberStart, numberEnd)) { // 数字合法 开始数字动画 start(); } else { // 数字不合法 直接调用 setText 设置最终值 setText(mPrefixString + BidiFormatter.getInstance().unicodeWrap(numberEnd) + mPostfixString); } }
Example #6
Source File: TemperatureUnit.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
public String getTemperatureText(Context context, int c) { if (DisplayUtils.isRtl(context)) { return BidiFormatter.getInstance().unicodeWrap( UnitUtils.formatInt(getTemperature(c)) ) + getAbbreviation(context); } else { return getTemperature(c) + getAbbreviation(context); } }
Example #7
Source File: TemperatureUnit.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
public String getLongTemperatureText(Context context, int c) { if (DisplayUtils.isRtl(context)) { return BidiFormatter.getInstance().unicodeWrap( UnitUtils.formatInt(getTemperature(c)) ) + getLongAbbreviation(context); } else { return getTemperature(c) + getLongAbbreviation(context); } }
Example #8
Source File: TemperatureUnit.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
public String getShortTemperatureText(Context context, int c) { if (DisplayUtils.isRtl(context)) { return BidiFormatter.getInstance().unicodeWrap( UnitUtils.formatInt(getTemperature(c)) ) + getShortAbbreviation(context); } else { return getTemperature(c) + getShortAbbreviation(context); } }
Example #9
Source File: AppErrorDialog.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public AppErrorDialog(Context context, ActivityManagerService service, Data data) { super(context); Resources res = context.getResources(); mService = service; mProc = data.proc; mResult = data.result; mIsRestartable = (data.task != null || data.isRestartableForService) && Settings.Global.getInt(context.getContentResolver(), Settings.Global.SHOW_RESTART_IN_CRASH_DIALOG, 0) != 0; BidiFormatter bidi = BidiFormatter.getInstance(); CharSequence name; if ((mProc.pkgList.size() == 1) && (name = context.getPackageManager().getApplicationLabel(mProc.info)) != null) { setTitle(res.getString( data.repeating ? com.android.internal.R.string.aerr_application_repeated : com.android.internal.R.string.aerr_application, bidi.unicodeWrap(name.toString()), bidi.unicodeWrap(mProc.info.processName))); } else { name = mProc.processName; setTitle(res.getString( data.repeating ? com.android.internal.R.string.aerr_process_repeated : com.android.internal.R.string.aerr_process, bidi.unicodeWrap(name.toString()))); } setCancelable(true); setCancelMessage(mHandler.obtainMessage(CANCEL)); WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.setTitle("Application Error: " + mProc.info.processName); attrs.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR | WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; getWindow().setAttributes(attrs); if (mProc.persistent) { getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); } // After the timeout, pretend the user clicked the quit button mHandler.sendMessageDelayed( mHandler.obtainMessage(TIMEOUT), DISMISS_TIMEOUT); }
Example #10
Source File: AppNotRespondingDialog.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public AppNotRespondingDialog(ActivityManagerService service, Context context, Data data) { super(context); mService = service; mProc = data.proc; Resources res = context.getResources(); setCancelable(false); int resid; CharSequence name1 = data.activity != null ? data.activity.info.loadLabel(context.getPackageManager()) : null; CharSequence name2 = null; if ((mProc.pkgList.size() == 1) && (name2=context.getPackageManager().getApplicationLabel(mProc.info)) != null) { if (name1 != null) { resid = com.android.internal.R.string.anr_activity_application; } else { name1 = name2; name2 = mProc.processName; resid = com.android.internal.R.string.anr_application_process; } } else { if (name1 != null) { name2 = mProc.processName; resid = com.android.internal.R.string.anr_activity_process; } else { name1 = mProc.processName; resid = com.android.internal.R.string.anr_process; } } BidiFormatter bidi = BidiFormatter.getInstance(); setTitle(name2 != null ? res.getString(resid, bidi.unicodeWrap(name1.toString()), bidi.unicodeWrap(name2.toString())) : res.getString(resid, bidi.unicodeWrap(name1.toString()))); if (data.aboveSystem) { getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); } WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.setTitle("Application Not Responding: " + mProc.info.processName); attrs.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR | WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; getWindow().setAttributes(attrs); }
Example #11
Source File: BidiFormatterAssert.java From assertj-android with Apache License 2.0 | 4 votes |
public BidiFormatterAssert(BidiFormatter actual) { super(actual, BidiFormatterAssert.class); }