Android14 MTK SystemUI中设置时间为12小时制时,状态栏和锁屏界面显示AM/PM |
您所在的位置:网站首页 › nova5锁屏时间显示 › Android14 MTK SystemUI中设置时间为12小时制时,状态栏和锁屏界面显示AM/PM |
文章目录
一、状态栏显示AM/PM二、锁屏界面显示AM/PM
一、状态栏显示AM/PM
先查看状态栏的布局文件:\vendor\mediatek\proprietary\packages\apps\SystemUI\res\layout\status_bar.xml 找到和时间相关的布局: 再根据此自定义的java文件: \vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\policy\Clock.java 其是继承TextView的自定义时钟布局文件,其中定义了三个跟AM/PM显示有关的静态全局变量: private static final int AM_PM_STYLE_NORMAL = 0;// AM/PM大小与前面时间的大小一致。 private static final int AM_PM_STYLE_SMALL = 1;// AM/PM大小是前面时间的大小的0.7倍,具体是在getSmallTime()方法中实现。 private static final int AM_PM_STYLE_GONE = 2;// AM/PM不可见状态栏显示AM/PM的修改方法如下(在其构造函数中进行修改): public Clock(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mCommandQueue = Dependency.get(CommandQueue.class); TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.Clock, 0, 0); try { mSystemUIFactoryBase = OpSystemUICustomizationFactoryBase.getOpFactory(context); mStatusBarExt = mSystemUIFactoryBase.makeSystemUIStatusBar(context); /*mAmPmStyle = mStatusBarExt.getClockAmPmStyle(a.getInt(R.styleable.Clock_amPmStyle, AM_PM_STYLE_GONE));*/ mAmPmStyle = mStatusBarExt.getClockAmPmStyle(a.getInt(R.styleable.Clock_amPmStyle, AM_PM_STYLE_SMALL));// 设置为AM/PM相对时间0.7倍显示,具体为啥为0.7倍参考方法getSmallTime mNonAdaptedColor = getCurrentTextColor(); } finally { a.recycle(); } mBroadcastDispatcher = Dependency.get(BroadcastDispatcher.class); mUserTracker = Dependency.get(UserTracker.class); }查看Clock.java下的getSmallTime()方法: private final CharSequence getSmallTime() { Context context = getContext(); boolean is24 = DateFormat.is24HourFormat(context, mCurrentUserId); if (mDateTimePatternGenerator == null) { // Despite its name, getInstance creates a cloned instance, so reuse the generator to // avoid unnecessary churn. mDateTimePatternGenerator = DateTimePatternGenerator.getInstance( context.getResources().getConfiguration().locale); } final char MAGIC1 = '\uEF00'; final char MAGIC2 = '\uEF01'; final String formatSkeleton = mShowSeconds ? is24 ? "Hms" : "hms" : is24 ? "Hm" : "hm"; String format = mDateTimePatternGenerator.getBestPattern(formatSkeleton); if (!format.equals(mContentDescriptionFormatString)) { mContentDescriptionFormatString = format; mContentDescriptionFormat = new SimpleDateFormat(format); /* * Search for an unquoted "a" in the format string, so we can * add marker characters around it to let us find it again after * formatting and change its size. */ if (mAmPmStyle != AM_PM_STYLE_NORMAL) { int a = -1; boolean quoted = false; for (int i = 0; i |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |