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

Commit 6941e9b0 authored by George Lin's avatar George Lin Committed by Santiago Etchebehere
Browse files

Clock color on preview renderer

Clock light or dark color should conform with the lock screen.

Test: See bug. Manually tested the color conforms with the LS
Bug: 277832214
Change-Id: I1b5983d6e8347217ef2445fa77ad1b3ddc9b2ac8
parent 24e09b66
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ package com.android.systemui.shared.quickaffordance.shared.model
object KeyguardPreviewConstants {
    const val MESSAGE_ID_HIDE_SMART_SPACE = 1111
    const val KEY_HIDE_SMART_SPACE = "hide_smart_space"
    const val MESSAGE_ID_COLOR_OVERRIDE = 1234
    const val KEY_COLOR_OVERRIDE = "color_override" // ColorInt Encoded as string
    const val MESSAGE_ID_SLOT_SELECTED = 1337
    const val KEY_SLOT_ID = "slot_id"
    const val KEY_INITIALLY_SELECTED_SLOT_ID = "initially_selected_slot_id"
+22 −11
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@

package com.android.systemui.keyguard.ui.preview

import android.annotation.ColorInt
import android.app.WallpaperColors
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@@ -47,6 +47,7 @@ import com.android.systemui.keyguard.ui.binder.KeyguardPreviewSmartspaceViewBind
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBottomAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewSmartspaceViewModel
import com.android.systemui.monet.ColorScheme
import com.android.systemui.plugins.ClockController
import com.android.systemui.shared.clocks.ClockRegistry
import com.android.systemui.shared.clocks.DefaultClockController
@@ -91,6 +92,7 @@ constructor(
    /** [shouldHideClock] here means that we never create and bind the clock views */
    private val shouldHideClock: Boolean =
        bundle.getBoolean(ClockPreviewConstants.KEY_HIDE_CLOCK, false)
    private val wallpaperColors: WallpaperColors? = bundle.getParcelable(KEY_COLORS)

    private var host: SurfaceControlViewHost

@@ -100,7 +102,6 @@ constructor(
    private lateinit var largeClockHostView: FrameLayout
    private lateinit var smallClockHostView: FrameLayout
    private var smartSpaceView: View? = null
    private var colorOverride: Int? = null

    private val disposables = mutableSetOf<DisposableHandle>()
    private var isDestroyed = false
@@ -195,14 +196,6 @@ constructor(
        mainHandler.post { smartSpaceView?.visibility = if (hide) View.INVISIBLE else View.VISIBLE }
    }

    /** Sets the clock's color to the overridden seed color. */
    fun onColorOverridden(@ColorInt color: Int?) {
        mainHandler.post {
            colorOverride = color
            clockController.clock?.run { events.onSeedColorChanged(color) }
        }
    }

    /**
     * This sets up and shows a non-interactive smart space
     *
@@ -395,7 +388,24 @@ constructor(
        val clock = clockRegistry.createCurrentClock()
        clockController.clock = clock

        colorOverride?.let { clock.events.onSeedColorChanged(it) }
        if (clockRegistry.seedColor == null) {
            // Seed color null means users do override any color on the clock. The default color
            // will need to use wallpaper's extracted color and consider if the wallpaper's color
            // is dark or a light.
            // TODO(b/277832214) we can potentially simplify this code by checking for
            // wallpaperColors being null in the if clause above and removing the many ?.
            val wallpaperColorScheme =
                wallpaperColors?.let { ColorScheme(it, /* darkTheme= */ false) }
            val lightClockColor = wallpaperColorScheme?.accent1?.s100
            val darkClockColor = wallpaperColorScheme?.accent2?.s600
            /** Note that when [wallpaperColors] is null, isWallpaperDark is true. */
            val isWallpaperDark: Boolean =
                (wallpaperColors?.colorHints?.and(WallpaperColors.HINT_SUPPORTS_DARK_TEXT)) !=
                    WallpaperColors.HINT_SUPPORTS_DARK_TEXT
            clock.events.onSeedColorChanged(
                if (isWallpaperDark) lightClockColor else darkClockColor
            )
        }

        updateLargeClock(clock)
        updateSmallClock(clock)
@@ -431,6 +441,7 @@ constructor(
        private const val KEY_VIEW_WIDTH = "width"
        private const val KEY_VIEW_HEIGHT = "height"
        private const val KEY_DISPLAY_ID = "display_id"
        private const val KEY_COLORS = "wallpaper_colors"

        private const val DIM_ALPHA = 0.3f
    }
+0 −7
Original line number Diff line number Diff line
@@ -124,13 +124,6 @@ constructor(
                        message.data.getBoolean(KeyguardPreviewConstants.KEY_HIDE_SMART_SPACE)
                    )
                }
                KeyguardPreviewConstants.MESSAGE_ID_COLOR_OVERRIDE -> {
                    renderer.onColorOverridden(
                        message.data
                            .getString(KeyguardPreviewConstants.KEY_COLOR_OVERRIDE)
                            ?.toIntOrNull()
                    )
                }
                else -> requestDestruction(this)
            }