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

Commit 42a2803b authored by Nicolò Mazzucato's avatar Nicolò Mazzucato
Browse files

Fix clocks moving to the left on connected display after locking

The onTargetRegionChanged callback was causing clocks to shift on the left side of the screen after locking the device twice.

The Presentation already adds the clock with center gravity, and it doesn't seem to be needed to pass these events over.

The Weather clock still looks wrong (not centered correctly), but this CL doesn't seem to change its behaviour.

Bug: 362719719
Bug: 353886316
Test: KeyguardDisplayManagerTest + show keyguard on external display + turn screen off/on a few times, observe the clock stays centered
Flag: com.android.systemui.shade_window_goes_around
Change-Id: I501ec143232ccdba7a70e7c9f1a08fc0f1daae46
parent 57cb264e
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -27,10 +27,10 @@ import android.view.View
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.view.WindowManager
import android.widget.FrameLayout
import android.widget.FrameLayout.LayoutParams
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceController
import com.android.systemui.res.R
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.shared.clocks.ClockRegistry
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
@@ -55,7 +55,6 @@ constructor(
    private lateinit var rootView: FrameLayout
    private var clock: View? = null
    private lateinit var faceController: ClockFaceController
    private lateinit var clockFrame: FrameLayout

    private val clockChangedListener =
        object : ClockRegistry.ClockChangeListener {
@@ -126,11 +125,18 @@ constructor(
    }

    private fun setClock(clockController: ClockController) {
        if (!ShadeWindowGoesAround.isEnabled) {
            clock?.removeOnLayoutChangeListener(layoutChangeListener)
        }
        rootView.removeAllViews()

        faceController = clockController.largeClock
        clock = faceController.view.also { it.addOnLayoutChangeListener(layoutChangeListener) }
        clock =
            faceController.view.also {
                if (!ShadeWindowGoesAround.isEnabled) {
                    it.addOnLayoutChangeListener(layoutChangeListener)
                }
            }
        rootView.addView(
            clock,
            FrameLayout.LayoutParams(