Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c254146e authored by Grace's avatar Grace Committed by Hawkwood Glazier
Browse files

Update DefaultClockProvider colors

This is largely a cherry-pick of change
I6b32776dac1853eeab87c2a65da69478e4da5b75 but with
some notable changes to accomadate existing code
differences in tm-qpr-dev.

 - We use a boolean instead of an enum for clock region
   darkness as the enum is in a different place in tm-qpr-dev.
 - We clean up some of the initialization code in
   ClockEventController to prevent testing issues and provide
   a dependency injection point to the screenshot test.
 - Pull the clock color setting from the theme when region
   sampling is disabled instead of defaulting to always dark.

Test: Manually validated colors matched reference images on
light and dark backgrounds with the region sampling feature
both enabled and disabled.

Bug: 229771520
Change-Id: I7906850b5de7f512f55e47e1122dfaacbc9c9406
(cherry picked from commit a724e0b7)
parent 53f0dc4f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
-packages/SystemUI/src-release/com/android/systemui/flags/FlagsModule.kt
-packages/SystemUI/src/com/android/keyguard/ActiveUnlockConfig.kt
-packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt
-packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
-packages/SystemUI/src/com/android/keyguard/KeyguardBiometricLockoutLogger.kt
-packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt
-packages/SystemUI/src/com/android/keyguard/KeyguardListenQueue.kt
@@ -156,6 +157,8 @@
-packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt
-packages/SystemUI/src/com/android/systemui/controls/ui/TouchBehavior.kt
-packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt
-packages/SystemUI/src/com/android/systemui/decor/CutoutDecorProviderFactory.kt
-packages/SystemUI/src/com/android/systemui/decor/CutoutDecorProviderImpl.kt
-packages/SystemUI/src/com/android/systemui/decor/DecorProvider.kt
-packages/SystemUI/src/com/android/systemui/decor/DecorProviderFactory.kt
-packages/SystemUI/src/com/android/systemui/decor/FaceScanningProviderFactory.kt
@@ -246,6 +249,7 @@
-packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt
-packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/ChipStateSender.kt
-packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttChipControllerSender.kt
-packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttChipRootView.kt
-packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderLogger.kt
-packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderUiEventLogger.kt
-packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanel.kt
@@ -575,6 +579,7 @@
-packages/SystemUI/src/com/android/systemui/volume/VolumePanelFactory.kt
-packages/SystemUI/tests/src/com/android/keyguard/ActiveUnlockConfigTest.kt
-packages/SystemUI/tests/src/com/android/keyguard/BouncerPanelExpansionCalculatorTest.kt
-packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt
-packages/SystemUI/tests/src/com/android/keyguard/KeyguardBiometricLockoutLoggerTest.kt
-packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt
-packages/SystemUI/tests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt
@@ -633,6 +638,7 @@
-packages/SystemUI/tests/src/com/android/systemui/controls/management/TestControlsRequestDialog.kt
-packages/SystemUI/tests/src/com/android/systemui/controls/ui/ControlViewHolderTest.kt
-packages/SystemUI/tests/src/com/android/systemui/controls/ui/DetailDialogTest.kt
-packages/SystemUI/tests/src/com/android/systemui/decor/CutoutDecorProviderFactoryTest.kt
-packages/SystemUI/tests/src/com/android/systemui/decor/OverlayWindowTest.kt
-packages/SystemUI/tests/src/com/android/systemui/decor/PrivacyDotDecorProviderFactoryTest.kt
-packages/SystemUI/tests/src/com/android/systemui/decor/RoundedCornerDecorProviderFactoryTest.kt
@@ -720,6 +726,7 @@
-packages/SystemUI/tests/src/com/android/systemui/screenrecord/ScreenRecordDialogTest.kt
-packages/SystemUI/tests/src/com/android/systemui/screenshot/ImageCaptureImplTest.kt
-packages/SystemUI/tests/src/com/android/systemui/screenshot/RequestProcessorTest.kt
-packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotPolicyImplTest.kt
-packages/SystemUI/tests/src/com/android/systemui/screenshot/TakeScreenshotServiceTest.kt
-packages/SystemUI/tests/src/com/android/systemui/settings/UserFileManagerImplTest.kt
-packages/SystemUI/tests/src/com/android/systemui/settings/UserTrackerImplTest.kt
+3 −4
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.view.View
import com.android.systemui.plugins.annotations.ProvidesInterface
import com.android.systemui.shared.regionsampling.RegionDarkness
import java.io.PrintWriter
import java.util.Locale
import java.util.TimeZone
@@ -62,7 +61,7 @@ interface Clock {

    /** Initializes various rendering parameters. If never called, provides reasonable defaults. */
    fun initialize(resources: Resources, dozeFraction: Float, foldFraction: Float) {
        events.onColorPaletteChanged(resources, RegionDarkness.DEFAULT, RegionDarkness.DEFAULT)
        events.onColorPaletteChanged(resources, true, true)
        animations.doze(dozeFraction)
        animations.fold(foldFraction)
        events.onTimeTick()
@@ -92,8 +91,8 @@ interface ClockEvents {
    /** Call whenever the color palette should update */
    fun onColorPaletteChanged(
            resources: Resources,
            smallClockIsDark: RegionDarkness,
            largeClockIsDark: RegionDarkness
            smallClockIsDark: Boolean,
            largeClockIsDark: Boolean
    ) { }
}

+8 −12
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import com.android.systemui.plugins.ClockId
import com.android.systemui.plugins.ClockMetadata
import com.android.systemui.plugins.ClockProvider
import com.android.systemui.shared.R
import com.android.systemui.shared.regionsampling.RegionDarkness
import java.io.PrintWriter
import java.util.Locale
import java.util.TimeZone
@@ -84,14 +83,11 @@ class DefaultClock(
        resources.getFloat(R.dimen.keyguard_clock_line_spacing_scale_burmese)
    private val defaultLineSpacing = resources.getFloat(R.dimen.keyguard_clock_line_spacing_scale)

    private var smallRegionDarkness = RegionDarkness.DEFAULT
    private var largeRegionDarkness = RegionDarkness.DEFAULT

    private fun updateClockColor(clock: AnimatableClockView, isRegionDark: RegionDarkness) {
        val color = if (isRegionDark.isDark) {
            resources.getColor(android.R.color.system_accent2_100)
    private fun updateClockColor(clock: AnimatableClockView, isRegionDark: Boolean) {
        val color = if (isRegionDark) {
            resources.getColor(android.R.color.system_accent1_100)
        } else {
            resources.getColor(android.R.color.system_accent1_600)
            resources.getColor(android.R.color.system_accent2_600)
        }
        clock.setColors(DOZE_COLOR, color)
        clock.animateAppearOnLockscreen()
@@ -120,8 +116,8 @@ class DefaultClock(

        override fun onColorPaletteChanged(
                resources: Resources,
                smallClockIsDark: RegionDarkness,
                largeClockIsDark: RegionDarkness
                smallClockIsDark: Boolean,
                largeClockIsDark: Boolean
        ) {
            if (smallRegionDarkness != smallClockIsDark) {
                smallRegionDarkness = smallClockIsDark
@@ -217,8 +213,8 @@ class DefaultClock(
        animations = DefaultClockAnimations(dozeFraction, foldFraction)
        events.onColorPaletteChanged(
                resources,
                RegionDarkness.DEFAULT,
                RegionDarkness.DEFAULT
                true,
                true
        )
        events.onTimeTick()
    }
+0 −0

File moved.

+29 −23
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.content.Intent
import android.content.IntentFilter
import android.content.res.Resources
import android.text.format.DateFormat
import android.util.TypedValue
import android.view.View
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
@@ -41,7 +43,7 @@ import javax.inject.Inject
 * Controller for a Clock provided by the registry and used on the keyguard. Instantiated by
 * [KeyguardClockSwitchController]. Functionality is forked from [AnimatableClockController].
 */
class ClockEventController @Inject constructor(
open class ClockEventController @Inject constructor(
        private val statusBarStateController: StatusBarStateController,
        private val broadcastDispatcher: BroadcastDispatcher,
        private val batteryController: BatteryController,
@@ -74,18 +76,21 @@ class ClockEventController @Inject constructor(

    private val updateFun = object : RegionSamplingInstance.UpdateColorCallback {
        override fun updateColors() {
            smallClockIsDark = smallRegionSamplingInstance.currentRegionDarkness()
            largeClockIsDark = largeRegionSamplingInstance.currentRegionDarkness()

            if (regionSamplingEnabled) {
                smallClockIsDark = smallRegionSamplingInstance.currentRegionDarkness().isDark
                largeClockIsDark = largeRegionSamplingInstance.currentRegionDarkness().isDark
            } else {
                val isLightTheme = TypedValue()
                context.theme.resolveAttribute(android.R.attr.isLightTheme, isLightTheme, true)
                smallClockIsDark = isLightTheme.data == 0
                largeClockIsDark = isLightTheme.data == 0
            }
            clock?.events?.onColorPaletteChanged(resources, smallClockIsDark, largeClockIsDark)
        }
    }

    fun updateRegionSamplers(currentClock: Clock?) {
        smallRegionSamplingInstance.stopRegionSampler()
        largeRegionSamplingInstance.stopRegionSampler()

        smallRegionSamplingInstance = RegionSamplingInstance(
        smallRegionSamplingInstance = createRegionSampler(
                currentClock?.smallClock,
                mainExecutor,
                bgExecutor,
@@ -93,7 +98,7 @@ class ClockEventController @Inject constructor(
                updateFun
        )

        largeRegionSamplingInstance = RegionSamplingInstance(
        largeRegionSamplingInstance = createRegionSampler(
                currentClock?.largeClock,
                mainExecutor,
                bgExecutor,
@@ -107,24 +112,26 @@ class ClockEventController @Inject constructor(
        updateFun.updateColors()
    }

    var smallRegionSamplingInstance: RegionSamplingInstance = RegionSamplingInstance(
            clock?.smallClock,
    protected open fun createRegionSampler(
            sampledView: View?,
            mainExecutor: Executor?,
            bgExecutor: Executor?,
            regionSamplingEnabled: Boolean,
            updateFun: RegionSamplingInstance.UpdateColorCallback
    ): RegionSamplingInstance {
        return RegionSamplingInstance(
            sampledView,
            mainExecutor,
            bgExecutor,
            regionSamplingEnabled,
            updateFun
    )
            updateFun)
    }

    var largeRegionSamplingInstance: RegionSamplingInstance = RegionSamplingInstance(
            clock?.largeClock,
            mainExecutor,
            bgExecutor,
            regionSamplingEnabled,
            updateFun
    )
    lateinit var smallRegionSamplingInstance: RegionSamplingInstance
    lateinit var largeRegionSamplingInstance: RegionSamplingInstance

    private var smallClockIsDark = smallRegionSamplingInstance.currentRegionDarkness()
    private var largeClockIsDark = largeRegionSamplingInstance.currentRegionDarkness()
    private var smallClockIsDark = true
    private var largeClockIsDark = true

    private val configListener = object : ConfigurationController.ConfigurationListener {
        override fun onThemeChanged() {
@@ -179,7 +186,6 @@ class ClockEventController @Inject constructor(

    init {
        isDozing = statusBarStateController.isDozing
        clock?.events?.onColorPaletteChanged(resources, smallClockIsDark, largeClockIsDark)
    }

    fun registerListeners() {
Loading