diff options
author | Scott Lobdell <slobdell@google.com> | 2021-03-29 16:12:49 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-04-02 22:35:29 +0000 |
commit | 21cdef883cc867db55340b25d5c95e19b12ab383 (patch) | |
tree | 93d1444ebe783f53f5f0ae2647592723b27b3fb8 /packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java | |
parent | 7deab3736bb5f3a92be8ac820096926dce2366ad (diff) | |
parent | d1d45f856fdf68835f5b42eacecab44e6dfa8545 (diff) |
Merge SP1A.210329.001
Change-Id: I1e21c5890b5b2e2f2855f09960bc8eec8aa922bf
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java b/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java index 64b3d7356d3c..c918d9871a7d 100644 --- a/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java +++ b/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java @@ -38,8 +38,10 @@ import kotlin.Unit; * The time's text color is a gradient that changes its colors based on its controller. */ public class AnimatableClockView extends TextView { - private static final CharSequence FORMAT_12_HOUR = "hh\nmm"; - private static final CharSequence FORMAT_24_HOUR = "HH\nmm"; + 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 = "H:mm"; private static final long ANIM_DURATION = 300; private final Calendar mTime = Calendar.getInstance(); @@ -55,6 +57,8 @@ public class AnimatableClockView extends TextView { private TextAnimator mTextAnimator = null; private Runnable mOnTextAnimatorInitialized; + private boolean mIsSingleLine; + public AnimatableClockView(Context context) { this(context, null, 0, 0); } @@ -78,6 +82,15 @@ public class AnimatableClockView extends TextView { } finally { ta.recycle(); } + + ta = context.obtainStyledAttributes( + attrs, android.R.styleable.TextView, defStyleAttr, defStyleRes); + try { + mIsSingleLine = ta.getBoolean(android.R.styleable.TextView_singleLine, false); + } finally { + ta.recycle(); + } + refreshFormat(); } @@ -171,7 +184,16 @@ public class AnimatableClockView extends TextView { void refreshFormat() { final boolean use24HourFormat = DateFormat.is24HourFormat(getContext()); - mFormat = use24HourFormat ? FORMAT_24_HOUR : FORMAT_12_HOUR; + if (mIsSingleLine && use24HourFormat) { + mFormat = SINGLE_LINE_FORMAT_24_HOUR; + } else if (!mIsSingleLine && use24HourFormat) { + mFormat = DOUBLE_LINE_FORMAT_24_HOUR; + } else if (mIsSingleLine && !use24HourFormat) { + mFormat = SINGLE_LINE_FORMAT_12_HOUR; + } else { + mFormat = DOUBLE_LINE_FORMAT_12_HOUR; + } + mDescFormat = getBestDateTimePattern(getContext(), use24HourFormat ? "Hm" : "hm"); refreshTime(); } |