Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.shared.clocks import android.content.Context import android.content.res.Resources import android.graphics.Typeface import android.os.Vibrator import android.view.LayoutInflater import com.android.systemui.customization.R import com.android.systemui.log.core.MessageBuffer Loading @@ -40,6 +41,7 @@ data class ClockContext( val typefaceCache: TypefaceCache, val messageBuffers: ClockMessageBuffers, val messageBuffer: MessageBuffer, val vibrator: Vibrator?, ) /** Provides the default system clock */ Loading @@ -48,6 +50,7 @@ class DefaultClockProvider( val layoutInflater: LayoutInflater, val resources: Resources, private val isClockReactiveVariantsEnabled: Boolean = false, private val vibrator: Vibrator?, ) : ClockProvider { private var messageBuffers: ClockMessageBuffers? = null Loading Loading @@ -82,6 +85,7 @@ class DefaultClockProvider( typefaceCache, buffers, buffers.infraMessageBuffer, vibrator, ) ) } else { Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +41 −10 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.graphics.Point import android.graphics.PorterDuff import android.graphics.PorterDuffXfermode import android.graphics.Rect import android.os.VibrationEffect import android.text.Layout import android.text.TextPaint import android.util.AttributeSet Loading Loading @@ -67,7 +68,7 @@ enum class HorizontalAlignment { @SuppressLint("AppCompatCustomView") open class SimpleDigitalClockTextView( clockCtx: ClockContext, val clockCtx: ClockContext, isLargeClock: Boolean, attrs: AttributeSet? = null, ) : TextView(clockCtx.context, attrs) { Loading @@ -92,6 +93,9 @@ open class SimpleDigitalClockTextView( (fixedAodAxes + listOf(roundAxis, SLANT_AXIS)).toFVar() } // TODO(b/374306512): Fidget endpoint to spec private var fidgetFontVariation = aodFontVariation private val parser = DimensionParser(clockCtx.context) var maxSingleDigitHeight = -1 var maxSingleDigitWidth = -1 Loading Loading @@ -289,24 +293,45 @@ open class SimpleDigitalClockTextView( return } logger.d("animateCharge()") val startAnimPhase2 = Runnable { textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) aodFontVariation else lsFontVariation, animate = isAnimationEnabled, onAnimationEnd = Runnable { textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) lsFontVariation else aodFontVariation, animate = isAnimationEnabled, ) updateTextBoundsForTextAnimator() } textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) aodFontVariation else lsFontVariation, animate = isAnimationEnabled, onAnimationEnd = startAnimPhase2, }, ) updateTextBoundsForTextAnimator() } fun animateFidget(x: Float, y: Float) { // TODO(b/374306512): Implement Fidget Animation if (!this::textAnimator.isInitialized || textAnimator.isRunning()) { // Skip fidget animation if other animation is already playing. return } logger.animateFidget(x, y) clockCtx.vibrator?.vibrate(FIDGET_HAPTICS) // TODO(b/374306512): Duplicated charge animation as placeholder. Implement final version // when we have a complete spec. May require additional code to animate individual digits. textAnimator.setTextStyle( fvar = fidgetFontVariation, animate = isAnimationEnabled, onAnimationEnd = Runnable { textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) lsFontVariation else aodFontVariation, animate = isAnimationEnabled, ) updateTextBoundsForTextAnimator() }, ) updateTextBoundsForTextAnimator() } fun refreshText() { Loading Loading @@ -533,6 +558,12 @@ open class SimpleDigitalClockTextView( private val PORTER_DUFF_XFER_MODE_PAINT = Paint().also { it.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_OUT) } val FIDGET_HAPTICS = VibrationEffect.startComposition() .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 0) .addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, 1.0f, 43) .compose() val AOD_COLOR = Color.WHITE val LS_WEIGHT_AXIS = ClockFontAxisSetting(GSFAxes.WEIGHT, 400f) val AOD_WEIGHT_AXIS = ClockFontAxisSetting(GSFAxes.WEIGHT, 200f) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shared/clocks/DefaultClockProviderTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ class DefaultClockProviderTest : SysuiTestCase() { whenever(mockSmallClockView.getLayoutParams()).thenReturn(FrameLayout.LayoutParams(10, 10)) whenever(mockLargeClockView.getLayoutParams()).thenReturn(FrameLayout.LayoutParams(10, 10)) provider = DefaultClockProvider(context, layoutInflater, resources) provider = DefaultClockProvider(context, layoutInflater, resources, vibrator = null) } @Test Loading packages/SystemUI/src/com/android/keyguard/dagger/ClockRegistryModule.java +7 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.keyguard.dagger; import android.content.Context; import android.content.res.Resources; import android.os.Vibrator; import android.view.LayoutInflater; import androidx.annotation.Nullable; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Application; import com.android.systemui.dagger.qualifiers.Background; Loading Loading @@ -55,7 +58,8 @@ public abstract class ClockRegistryModule { FeatureFlags featureFlags, @Main Resources resources, LayoutInflater layoutInflater, ClockMessageBuffers clockBuffers) { ClockMessageBuffers clockBuffers, @Nullable Vibrator vibrator) { ClockRegistry registry = new ClockRegistry( context, pluginManager, Loading @@ -69,7 +73,8 @@ public abstract class ClockRegistryModule { context, layoutInflater, resources, com.android.systemui.shared.Flags.clockReactiveVariants() com.android.systemui.shared.Flags.clockReactiveVariants(), vibrator ), context.getString(R.string.lockscreen_clock_id_fallback), clockBuffers, Loading packages/SystemUI/tests/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextViewTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class SimpleDigitalClockTextViewTest : SysuiTestCase() { }, ClockMessageBuffers(messageBuffer), messageBuffer, vibrator = null, ), isLargeClock = false, ) Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.shared.clocks import android.content.Context import android.content.res.Resources import android.graphics.Typeface import android.os.Vibrator import android.view.LayoutInflater import com.android.systemui.customization.R import com.android.systemui.log.core.MessageBuffer Loading @@ -40,6 +41,7 @@ data class ClockContext( val typefaceCache: TypefaceCache, val messageBuffers: ClockMessageBuffers, val messageBuffer: MessageBuffer, val vibrator: Vibrator?, ) /** Provides the default system clock */ Loading @@ -48,6 +50,7 @@ class DefaultClockProvider( val layoutInflater: LayoutInflater, val resources: Resources, private val isClockReactiveVariantsEnabled: Boolean = false, private val vibrator: Vibrator?, ) : ClockProvider { private var messageBuffers: ClockMessageBuffers? = null Loading Loading @@ -82,6 +85,7 @@ class DefaultClockProvider( typefaceCache, buffers, buffers.infraMessageBuffer, vibrator, ) ) } else { Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextView.kt +41 −10 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.graphics.Point import android.graphics.PorterDuff import android.graphics.PorterDuffXfermode import android.graphics.Rect import android.os.VibrationEffect import android.text.Layout import android.text.TextPaint import android.util.AttributeSet Loading Loading @@ -67,7 +68,7 @@ enum class HorizontalAlignment { @SuppressLint("AppCompatCustomView") open class SimpleDigitalClockTextView( clockCtx: ClockContext, val clockCtx: ClockContext, isLargeClock: Boolean, attrs: AttributeSet? = null, ) : TextView(clockCtx.context, attrs) { Loading @@ -92,6 +93,9 @@ open class SimpleDigitalClockTextView( (fixedAodAxes + listOf(roundAxis, SLANT_AXIS)).toFVar() } // TODO(b/374306512): Fidget endpoint to spec private var fidgetFontVariation = aodFontVariation private val parser = DimensionParser(clockCtx.context) var maxSingleDigitHeight = -1 var maxSingleDigitWidth = -1 Loading Loading @@ -289,24 +293,45 @@ open class SimpleDigitalClockTextView( return } logger.d("animateCharge()") val startAnimPhase2 = Runnable { textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) aodFontVariation else lsFontVariation, animate = isAnimationEnabled, onAnimationEnd = Runnable { textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) lsFontVariation else aodFontVariation, animate = isAnimationEnabled, ) updateTextBoundsForTextAnimator() } textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) aodFontVariation else lsFontVariation, animate = isAnimationEnabled, onAnimationEnd = startAnimPhase2, }, ) updateTextBoundsForTextAnimator() } fun animateFidget(x: Float, y: Float) { // TODO(b/374306512): Implement Fidget Animation if (!this::textAnimator.isInitialized || textAnimator.isRunning()) { // Skip fidget animation if other animation is already playing. return } logger.animateFidget(x, y) clockCtx.vibrator?.vibrate(FIDGET_HAPTICS) // TODO(b/374306512): Duplicated charge animation as placeholder. Implement final version // when we have a complete spec. May require additional code to animate individual digits. textAnimator.setTextStyle( fvar = fidgetFontVariation, animate = isAnimationEnabled, onAnimationEnd = Runnable { textAnimator.setTextStyle( fvar = if (dozeFraction == 0F) lsFontVariation else aodFontVariation, animate = isAnimationEnabled, ) updateTextBoundsForTextAnimator() }, ) updateTextBoundsForTextAnimator() } fun refreshText() { Loading Loading @@ -533,6 +558,12 @@ open class SimpleDigitalClockTextView( private val PORTER_DUFF_XFER_MODE_PAINT = Paint().also { it.xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_OUT) } val FIDGET_HAPTICS = VibrationEffect.startComposition() .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 0) .addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, 1.0f, 43) .compose() val AOD_COLOR = Color.WHITE val LS_WEIGHT_AXIS = ClockFontAxisSetting(GSFAxes.WEIGHT, 400f) val AOD_WEIGHT_AXIS = ClockFontAxisSetting(GSFAxes.WEIGHT, 200f) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shared/clocks/DefaultClockProviderTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ class DefaultClockProviderTest : SysuiTestCase() { whenever(mockSmallClockView.getLayoutParams()).thenReturn(FrameLayout.LayoutParams(10, 10)) whenever(mockLargeClockView.getLayoutParams()).thenReturn(FrameLayout.LayoutParams(10, 10)) provider = DefaultClockProvider(context, layoutInflater, resources) provider = DefaultClockProvider(context, layoutInflater, resources, vibrator = null) } @Test Loading
packages/SystemUI/src/com/android/keyguard/dagger/ClockRegistryModule.java +7 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.keyguard.dagger; import android.content.Context; import android.content.res.Resources; import android.os.Vibrator; import android.view.LayoutInflater; import androidx.annotation.Nullable; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Application; import com.android.systemui.dagger.qualifiers.Background; Loading Loading @@ -55,7 +58,8 @@ public abstract class ClockRegistryModule { FeatureFlags featureFlags, @Main Resources resources, LayoutInflater layoutInflater, ClockMessageBuffers clockBuffers) { ClockMessageBuffers clockBuffers, @Nullable Vibrator vibrator) { ClockRegistry registry = new ClockRegistry( context, pluginManager, Loading @@ -69,7 +73,8 @@ public abstract class ClockRegistryModule { context, layoutInflater, resources, com.android.systemui.shared.Flags.clockReactiveVariants() com.android.systemui.shared.Flags.clockReactiveVariants(), vibrator ), context.getString(R.string.lockscreen_clock_id_fallback), clockBuffers, Loading
packages/SystemUI/tests/src/com/android/systemui/shared/clocks/view/SimpleDigitalClockTextViewTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class SimpleDigitalClockTextViewTest : SysuiTestCase() { }, ClockMessageBuffers(messageBuffer), messageBuffer, vibrator = null, ), isLargeClock = false, ) Loading