Loading packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +3 −3 Original line number Diff line number Diff line Loading @@ -35,13 +35,13 @@ android:id="@+id/animatable_clock_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" android:layout_gravity="start" android:gravity="start" android:textSize="@dimen/clock_text_size" android:fontFamily="@font/clock" android:typeface="monospace" android:elegantTextHeight="false" android:singleLine="true" android:fontFeatureSettings="pnum" chargeAnimationDelay="350" dozeWeight="200" lockScreenWeight="400" Loading packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +1 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie } else { mView.setLineSpacingScale(mDefaultLineSpacing); } mView.refreshFormat(); } } Loading packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java +31 −10 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ package com.android.keyguard; import android.annotation.FloatRange; import android.annotation.IntRange; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.icu.text.DateTimePatternGenerator; import android.text.format.DateFormat; import android.util.AttributeSet; import android.widget.TextView; Loading @@ -30,6 +30,7 @@ import com.android.systemui.R; import com.android.systemui.statusbar.phone.KeyguardBypassController; import java.util.Calendar; import java.util.Locale; import java.util.TimeZone; import kotlin.Unit; Loading @@ -41,8 +42,6 @@ import kotlin.Unit; public class AnimatableClockView extends TextView { private static final CharSequence DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm"; private static final CharSequence DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm"; private static final CharSequence SINGLE_LINE_FORMAT_12_HOUR = "h:mm"; private static final CharSequence SINGLE_LINE_FORMAT_24_HOUR = "HH:mm"; private static final long DOZE_ANIM_DURATION = 300; private static final long APPEAR_ANIM_DURATION = 350; private static final long CHARGE_ANIM_DURATION_PHASE_0 = 500; Loading Loading @@ -259,25 +258,47 @@ public class AnimatableClockView extends TextView { } void refreshFormat() { Patterns.update(mContext); final boolean use24HourFormat = DateFormat.is24HourFormat(getContext()); if (mIsSingleLine && use24HourFormat) { mFormat = SINGLE_LINE_FORMAT_24_HOUR; mFormat = Patterns.sClockView24; } else if (!mIsSingleLine && use24HourFormat) { mFormat = DOUBLE_LINE_FORMAT_24_HOUR; } else if (mIsSingleLine && !use24HourFormat) { mFormat = SINGLE_LINE_FORMAT_12_HOUR; mFormat = Patterns.sClockView12; } else { mFormat = DOUBLE_LINE_FORMAT_12_HOUR; } mDescFormat = getBestDateTimePattern(getContext(), use24HourFormat ? "Hm" : "hm"); mDescFormat = use24HourFormat ? Patterns.sClockView24 : Patterns.sClockView12; refreshTime(); } private static String getBestDateTimePattern(Context context, String skeleton) { DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance( context.getResources().getConfiguration().locale); return dtpg.getBestPattern(skeleton); // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often. // This is an optimization to ensure we only recompute the patterns when the inputs change. private static final class Patterns { static String sClockView12; static String sClockView24; static String sCacheKey; static void update(Context context) { final Locale locale = Locale.getDefault(); final Resources res = context.getResources(); final String clockView12Skel = res.getString(R.string.clock_12hr_format); final String clockView24Skel = res.getString(R.string.clock_24hr_format); final String key = locale.toString() + clockView12Skel + clockView24Skel; if (key.equals(sCacheKey)) return; sClockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel); // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton // format. The following code removes the AM/PM indicator if we didn't want it. if (!clockView12Skel.contains("a")) { sClockView12 = sClockView12.replaceAll("a", "").trim(); } sClockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel); sCacheKey = key; } } interface DozeStateGetter { Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +0 −33 Original line number Diff line number Diff line Loading @@ -20,9 +20,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.WallpaperManager; import android.content.res.Resources; import android.text.TextUtils; import android.text.format.DateFormat; import android.view.View; import android.widget.FrameLayout; import android.widget.RelativeLayout; Loading Loading @@ -367,37 +365,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS return mColorExtractor.getColors(WallpaperManager.FLAG_LOCK); } // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often. // This is an optimization to ensure we only recompute the patterns when the inputs change. private static final class Patterns { static String sClockView12; static String sClockView24; static String sCacheKey; static void update(Resources res) { final Locale locale = Locale.getDefault(); final String clockView12Skel = res.getString(R.string.clock_12hr_format); final String clockView24Skel = res.getString(R.string.clock_24hr_format); final String key = locale.toString() + clockView12Skel + clockView24Skel; if (key.equals(sCacheKey)) return; sClockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel); // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton // format. The following code removes the AM/PM indicator if we didn't want it. if (!clockView12Skel.contains("a")) { sClockView12 = sClockView12.replaceAll("a", "").trim(); } sClockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel); // Use fancy colon. sClockView24 = sClockView24.replace(':', '\uee01'); sClockView12 = sClockView12.replace(':', '\uee01'); sCacheKey = key; } } private int getCurrentLayoutDirection() { return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()); } Loading Loading
packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +3 −3 Original line number Diff line number Diff line Loading @@ -35,13 +35,13 @@ android:id="@+id/animatable_clock_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" android:layout_gravity="start" android:gravity="start" android:textSize="@dimen/clock_text_size" android:fontFamily="@font/clock" android:typeface="monospace" android:elegantTextHeight="false" android:singleLine="true" android:fontFeatureSettings="pnum" chargeAnimationDelay="350" dozeWeight="200" lockScreenWeight="400" Loading
packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +1 −0 Original line number Diff line number Diff line Loading @@ -212,6 +212,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie } else { mView.setLineSpacingScale(mDefaultLineSpacing); } mView.refreshFormat(); } } Loading
packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java +31 −10 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ package com.android.keyguard; import android.annotation.FloatRange; import android.annotation.IntRange; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.icu.text.DateTimePatternGenerator; import android.text.format.DateFormat; import android.util.AttributeSet; import android.widget.TextView; Loading @@ -30,6 +30,7 @@ import com.android.systemui.R; import com.android.systemui.statusbar.phone.KeyguardBypassController; import java.util.Calendar; import java.util.Locale; import java.util.TimeZone; import kotlin.Unit; Loading @@ -41,8 +42,6 @@ import kotlin.Unit; public class AnimatableClockView extends TextView { private static final CharSequence DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm"; private static final CharSequence DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm"; private static final CharSequence SINGLE_LINE_FORMAT_12_HOUR = "h:mm"; private static final CharSequence SINGLE_LINE_FORMAT_24_HOUR = "HH:mm"; private static final long DOZE_ANIM_DURATION = 300; private static final long APPEAR_ANIM_DURATION = 350; private static final long CHARGE_ANIM_DURATION_PHASE_0 = 500; Loading Loading @@ -259,25 +258,47 @@ public class AnimatableClockView extends TextView { } void refreshFormat() { Patterns.update(mContext); final boolean use24HourFormat = DateFormat.is24HourFormat(getContext()); if (mIsSingleLine && use24HourFormat) { mFormat = SINGLE_LINE_FORMAT_24_HOUR; mFormat = Patterns.sClockView24; } else if (!mIsSingleLine && use24HourFormat) { mFormat = DOUBLE_LINE_FORMAT_24_HOUR; } else if (mIsSingleLine && !use24HourFormat) { mFormat = SINGLE_LINE_FORMAT_12_HOUR; mFormat = Patterns.sClockView12; } else { mFormat = DOUBLE_LINE_FORMAT_12_HOUR; } mDescFormat = getBestDateTimePattern(getContext(), use24HourFormat ? "Hm" : "hm"); mDescFormat = use24HourFormat ? Patterns.sClockView24 : Patterns.sClockView12; refreshTime(); } private static String getBestDateTimePattern(Context context, String skeleton) { DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance( context.getResources().getConfiguration().locale); return dtpg.getBestPattern(skeleton); // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often. // This is an optimization to ensure we only recompute the patterns when the inputs change. private static final class Patterns { static String sClockView12; static String sClockView24; static String sCacheKey; static void update(Context context) { final Locale locale = Locale.getDefault(); final Resources res = context.getResources(); final String clockView12Skel = res.getString(R.string.clock_12hr_format); final String clockView24Skel = res.getString(R.string.clock_24hr_format); final String key = locale.toString() + clockView12Skel + clockView24Skel; if (key.equals(sCacheKey)) return; sClockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel); // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton // format. The following code removes the AM/PM indicator if we didn't want it. if (!clockView12Skel.contains("a")) { sClockView12 = sClockView12.replaceAll("a", "").trim(); } sClockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel); sCacheKey = key; } } interface DozeStateGetter { Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +0 −33 Original line number Diff line number Diff line Loading @@ -20,9 +20,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.WallpaperManager; import android.content.res.Resources; import android.text.TextUtils; import android.text.format.DateFormat; import android.view.View; import android.widget.FrameLayout; import android.widget.RelativeLayout; Loading Loading @@ -367,37 +365,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS return mColorExtractor.getColors(WallpaperManager.FLAG_LOCK); } // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often. // This is an optimization to ensure we only recompute the patterns when the inputs change. private static final class Patterns { static String sClockView12; static String sClockView24; static String sCacheKey; static void update(Resources res) { final Locale locale = Locale.getDefault(); final String clockView12Skel = res.getString(R.string.clock_12hr_format); final String clockView24Skel = res.getString(R.string.clock_24hr_format); final String key = locale.toString() + clockView12Skel + clockView24Skel; if (key.equals(sCacheKey)) return; sClockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel); // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton // format. The following code removes the AM/PM indicator if we didn't want it. if (!clockView12Skel.contains("a")) { sClockView12 = sClockView12.replaceAll("a", "").trim(); } sClockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel); // Use fancy colon. sClockView24 = sClockView24.replace(':', '\uee01'); sClockView12 = sClockView12.replace(':', '\uee01'); sCacheKey = key; } } private int getCurrentLayoutDirection() { return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()); } Loading