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

Commit 87d3c6a1 authored by Sherry Zhou's avatar Sherry Zhou Committed by Android (Google) Code Review
Browse files

Merge "Migrate clocks to blueprint sections" into main

parents 9227c402 d3a62b3f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.systemui.plugins.ClockFaceConfig
import com.android.systemui.plugins.ClockFaceController
import com.android.systemui.plugins.ClockFaceEvents
import com.android.systemui.plugins.ClockSettings
import com.android.systemui.plugins.DefaultClockFaceLayout
import com.android.systemui.plugins.WeatherData
import java.io.PrintWriter
import java.util.Locale
@@ -114,6 +115,7 @@ class DefaultClockController(
        protected var targetRegion: Rect? = null

        override val config = ClockFaceConfig()
        override val layout = DefaultClockFaceLayout(view)

        override var messageBuffer: MessageBuffer?
            get() = view.messageBuffer
@@ -184,6 +186,7 @@ class DefaultClockController(
        view: AnimatableClockView,
        seedColor: Int?,
    ) : DefaultClockFaceController(view, seedColor) {
        override val layout = DefaultClockFaceLayout(view)
        override val config =
            ClockFaceConfig(hasCustomPositionUpdatedAnimation = hasStepClockAnimation)

+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ java_library {
    // of the library which are used by the plugins but not by systemui itself.
    static_libs: [
        "androidx.annotation_annotation",
        "androidx-constraintlayout_constraintlayout",
        "PluginCoreLib",
        "SystemUIAnimationLib",
        "SystemUICommon",
+28 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import android.content.res.Resources
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.view.View
import androidx.constraintlayout.widget.ConstraintSet
import com.android.internal.annotations.Keep
import com.android.systemui.log.core.MessageBuffer
import com.android.systemui.plugins.annotations.ProvidesInterface
@@ -85,6 +86,9 @@ interface ClockFaceController {
    /** View that renders the clock face */
    val view: View

    /** Layout specification for this clock */
    val layout: ClockFaceLayout

    /** Determines the way the hosting app should behave when rendering this clock face */
    val config: ClockFaceConfig

@@ -98,6 +102,30 @@ interface ClockFaceController {
    var messageBuffer: MessageBuffer?
}

/** Specifies layout information for the */
interface ClockFaceLayout {
    /** All clock views to add to the root constraint layout before applying constraints. */
    val views: List<View>

    /** Custom constraints to apply to Lockscreen ConstraintLayout. */
    fun applyConstraints(constraints: ConstraintSet): ConstraintSet
}

/** A ClockFaceLayout that applies the default lockscreen layout to a single view */
class DefaultClockFaceLayout(val view: View) : ClockFaceLayout {
    // both small and large clock should have a container (RelativeLayout in
    // SimpleClockFaceController)
    override val views = listOf(view)
    override fun applyConstraints(constraints: ConstraintSet): ConstraintSet {
        if (views.size != 1) {
            throw IllegalArgumentException(
                "Should have only one container view when using DefaultClockFaceLayout"
            )
        }
        return constraints
    }
}

/** Events that should call when various rendering parameters change */
interface ClockEvents {
    /** Call whenever timezone changes */
+1 −0
Original line number Diff line number Diff line
@@ -269,6 +269,7 @@ public class PluginInstance<T extends Plugin> implements PluginLifecycleManager
        private ClassLoader getParentClassLoader(ClassLoader baseClassLoader) {
            return new PluginManagerImpl.ClassLoaderFilter(
                    baseClassLoader,
                    "androidx.constraintlayout.widget",
                    "com.android.systemui.common",
                    "com.android.systemui.log",
                    "com.android.systemui.plugin");
+17 −19
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ import android.util.Log
import android.util.TypedValue
import android.view.View
import android.view.View.OnAttachStateChangeListener
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.widget.FrameLayout
import androidx.annotation.VisibleForTesting
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
@@ -63,7 +63,6 @@ import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.launch
import java.util.Locale
import java.util.TimeZone
@@ -150,15 +149,15 @@ constructor(
                        var pastVisibility: Int? = null
                        override fun onViewAttachedToWindow(view: View) {
                            value.events.onTimeFormatChanged(DateFormat.is24HourFormat(context))
                            if (view != null) {
                                smallClockFrame = view.parent as FrameLayout
                            // Match the asing for view.parent's layout classes.
                            smallClockFrame = view.parent as ViewGroup
                            smallClockFrame?.let { frame ->
                                pastVisibility = frame.visibility
                                onGlobalLayoutListener = OnGlobalLayoutListener {
                                    val currentVisibility = frame.visibility
                                    if (pastVisibility != currentVisibility) {
                                        pastVisibility = currentVisibility
                                            // when small clock  visible,
                                        // when small clock is visible,
                                        // recalculate bounds and sample
                                        if (currentVisibility == View.VISIBLE) {
                                            smallRegionSampler?.stopRegionSampler()
@@ -170,7 +169,6 @@ constructor(
                                        .addOnGlobalLayoutListener(onGlobalLayoutListener)
                            }
                        }
                        }

                        override fun onViewDetachedFromWindow(p0: View) {
                            smallClockFrame?.viewTreeObserver
@@ -197,7 +195,7 @@ constructor(
    var smallClockOnAttachStateChangeListener: OnAttachStateChangeListener? = null
    @VisibleForTesting
    var largeClockOnAttachStateChangeListener: OnAttachStateChangeListener? = null
    private var smallClockFrame: FrameLayout? = null
    private var smallClockFrame: ViewGroup? = null
    private var onGlobalLayoutListener: OnGlobalLayoutListener? = null

    private var isDozing = false
Loading