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

Commit ce4ffc40 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Rebuild SmartspaceSection on configuration changes" into main

parents 43098f56 e8c20fe7
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -179,8 +179,15 @@ class TextAnimator(

    private val fontVariationUtils = FontVariationUtils()

    fun updateLayout(layout: Layout) {
    fun updateLayout(layout: Layout, textSize: Float = -1f) {
        textInterpolator.layout = layout

        if (textSize >= 0) {
            textInterpolator.targetPaint.textSize = textSize
            textInterpolator.basePaint.textSize = textSize
            textInterpolator.onTargetPaintModified()
            textInterpolator.onBasePaintModified()
        }
    }

    fun isRunning(): Boolean {
+19 −52
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.systemui.shared.clocks

import android.animation.TimeInterpolator
import android.annotation.ColorInt
import android.annotation.FloatRange
import android.annotation.IntRange
import android.annotation.SuppressLint
import android.content.Context
@@ -27,7 +26,7 @@ import android.text.TextUtils
import android.text.format.DateFormat
import android.util.AttributeSet
import android.util.MathUtils.constrainedMap
import android.util.TypedValue
import android.util.TypedValue.COMPLEX_UNIT_PX
import android.view.View
import android.view.View.MeasureSpec.EXACTLY
import android.widget.TextView
@@ -219,9 +218,7 @@ constructor(

    override fun setTextSize(type: Int, size: Float) {
        super.setTextSize(type, size)
        if (type == TypedValue.COMPLEX_UNIT_PX) {
            lastUnconstrainedTextSize = size
        }
        lastUnconstrainedTextSize = if (type == COMPLEX_UNIT_PX) size else Float.MAX_VALUE
    }

    @SuppressLint("DrawAllocation")
@@ -234,22 +231,18 @@ constructor(
                MeasureSpec.getMode(heightMeasureSpec) == EXACTLY
        ) {
            // Call straight into TextView.setTextSize to avoid setting lastUnconstrainedTextSize
            super.setTextSize(
                TypedValue.COMPLEX_UNIT_PX,
                min(lastUnconstrainedTextSize, MeasureSpec.getSize(heightMeasureSpec) / 2F)
            )
            val size = min(lastUnconstrainedTextSize, MeasureSpec.getSize(heightMeasureSpec) / 2F)
            super.setTextSize(COMPLEX_UNIT_PX, size)
        }

        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
        val animator = textAnimator
        if (animator == null) {
        textAnimator?.let { animator -> animator.updateLayout(layout, textSize) }
            ?: run {
                textAnimator =
                textAnimatorFactory(layout, ::invalidate)?.also {
                    textAnimatorFactory(layout, ::invalidate).also {
                        onTextAnimatorInitialized?.invoke(it)
                        onTextAnimatorInitialized = null
                    }
        } else {
            animator.updateLayout(layout)
            }

        if (migratedClocks && hasCustomPositionUpdatedAnimation) {
@@ -307,18 +300,18 @@ constructor(
        logger.d("animateColorChange")
        setTextStyle(
            weight = lockScreenWeight,
            textSize = -1f,
            color = null, /* using current color */
            animate = false,
            interpolator = null,
            duration = 0,
            delay = 0,
            onAnimationEnd = null
        )
        setTextStyle(
            weight = lockScreenWeight,
            textSize = -1f,
            color = lockScreenColor,
            animate = true,
            interpolator = null,
            duration = COLOR_ANIM_DURATION,
            delay = 0,
            onAnimationEnd = null
@@ -329,16 +322,15 @@ constructor(
        logger.d("animateAppearOnLockscreen")
        setTextStyle(
            weight = dozingWeight,
            textSize = -1f,
            color = lockScreenColor,
            animate = false,
            interpolator = null,
            duration = 0,
            delay = 0,
            onAnimationEnd = null
        )
        setTextStyle(
            weight = lockScreenWeight,
            textSize = -1f,
            color = lockScreenColor,
            animate = true,
            duration = APPEAR_ANIM_DURATION,
@@ -356,16 +348,15 @@ constructor(
        logger.d("animateFoldAppear")
        setTextStyle(
            weight = lockScreenWeightInternal,
            textSize = -1f,
            color = lockScreenColor,
            animate = false,
            interpolator = null,
            duration = 0,
            delay = 0,
            onAnimationEnd = null
        )
        setTextStyle(
            weight = dozingWeightInternal,
            textSize = -1f,
            color = dozingColor,
            animate = animate,
            interpolator = Interpolators.EMPHASIZED_DECELERATE,
@@ -385,9 +376,9 @@ constructor(
        val startAnimPhase2 = Runnable {
            setTextStyle(
                weight = if (isDozing()) dozingWeight else lockScreenWeight,
                textSize = -1f,
                color = null,
                animate = true,
                interpolator = null,
                duration = CHARGE_ANIM_DURATION_PHASE_1,
                delay = 0,
                onAnimationEnd = null
@@ -395,9 +386,9 @@ constructor(
        }
        setTextStyle(
            weight = if (isDozing()) lockScreenWeight else dozingWeight,
            textSize = -1f,
            color = null,
            animate = true,
            interpolator = null,
            duration = CHARGE_ANIM_DURATION_PHASE_0,
            delay = chargeAnimationDelay.toLong(),
            onAnimationEnd = startAnimPhase2
@@ -408,9 +399,9 @@ constructor(
        logger.d("animateDoze")
        setTextStyle(
            weight = if (isDozing) dozingWeight else lockScreenWeight,
            textSize = -1f,
            color = if (isDozing) dozingColor else lockScreenColor,
            animate = animate,
            interpolator = null,
            duration = DOZE_ANIM_DURATION,
            delay = 0,
            onAnimationEnd = null
@@ -448,7 +439,6 @@ constructor(
     */
    private fun setTextStyle(
        @IntRange(from = 0, to = 1000) weight: Int,
        @FloatRange(from = 0.0) textSize: Float,
        color: Int?,
        animate: Boolean,
        interpolator: TimeInterpolator?,
@@ -459,7 +449,6 @@ constructor(
        textAnimator?.let {
            it.setTextStyle(
                weight = weight,
                textSize = textSize,
                color = color,
                animate = animate && isAnimationEnabled,
                duration = duration,
@@ -474,7 +463,6 @@ constructor(
                onTextAnimatorInitialized = { textAnimator ->
                    textAnimator.setTextStyle(
                        weight = weight,
                        textSize = textSize,
                        color = color,
                        animate = false,
                        duration = duration,
@@ -487,27 +475,6 @@ constructor(
            }
    }

    private fun setTextStyle(
        @IntRange(from = 0, to = 1000) weight: Int,
        @FloatRange(from = 0.0) textSize: Float,
        color: Int?,
        animate: Boolean,
        duration: Long,
        delay: Long,
        onAnimationEnd: Runnable?
    ) {
        setTextStyle(
            weight = weight,
            textSize = textSize,
            color = color,
            animate = animate,
            interpolator = null,
            duration = duration,
            delay = delay,
            onAnimationEnd = onAnimationEnd
        )
    }

    fun refreshFormat() = refreshFormat(DateFormat.is24HourFormat(context))
    fun refreshFormat(use24HourFormat: Boolean) {
        Patterns.update(context)
+22 −26
Original line number Diff line number Diff line
@@ -15,12 +15,12 @@
 */
package com.android.keyguard

import android.os.Trace
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.res.Resources
import android.os.Trace
import android.text.format.DateFormat
import android.util.Log
import android.util.TypedValue
@@ -466,15 +466,11 @@ constructor(
        largeRegionSampler?.stopRegionSampler()
        smallTimeListener?.stop()
        largeTimeListener?.stop()
        clock
            ?.smallClock
            ?.view
            ?.removeOnAttachStateChangeListener(smallClockOnAttachStateChangeListener)
        clock?.apply {
            smallClock.view.removeOnAttachStateChangeListener(smallClockOnAttachStateChangeListener)
            largeClock.view.removeOnAttachStateChangeListener(largeClockOnAttachStateChangeListener)
        }
        smallClockFrame?.viewTreeObserver?.removeOnGlobalLayoutListener(onGlobalLayoutListener)
        clock
            ?.largeClock
            ?.view
            ?.removeOnAttachStateChangeListener(largeClockOnAttachStateChangeListener)
    }

    /**
@@ -505,15 +501,17 @@ constructor(
        }
    }

    private fun updateFontSizes() {
    fun updateFontSizes() {
        clock?.run {
            smallClock.events.onFontSettingChanged(
                resources.getDimensionPixelSize(R.dimen.small_clock_text_size).toFloat()
            )
            smallClock.events.onFontSettingChanged(getSmallClockSizePx())
            largeClock.events.onFontSettingChanged(getLargeClockSizePx())
        }
    }

    private fun getSmallClockSizePx(): Float {
        return resources.getDimensionPixelSize(R.dimen.small_clock_text_size).toFloat()
    }

    private fun getLargeClockSizePx(): Float {
        return if (largeClockOnSecondaryDisplay) {
            resources.getDimensionPixelSize(R.dimen.presentation_clock_text_size).toFloat()
@@ -549,9 +547,8 @@ constructor(
                        it.copy(value = 1f - it.value)
                    },
                    keyguardTransitionInteractor.transition(Edge.create(LOCKSCREEN, AOD)),
                ).filter {
                    it.transitionState != TransitionState.FINISHED
                }
                )
                .filter { it.transitionState != TransitionState.FINISHED }
                .collect { handleDoze(it.value) }
        }
    }
@@ -582,8 +579,8 @@ constructor(
    }

    /**
     * When keyguard is displayed due to pulsing notifications when AOD is off,
     * we should make sure clock is in dozing state instead of LS state
     * When keyguard is displayed due to pulsing notifications when AOD is off, we should make sure
     * clock is in dozing state instead of LS state
     */
    @VisibleForTesting
    internal fun listenForAnyStateToDozingTransition(scope: CoroutineScope): Job {
@@ -595,7 +592,6 @@ constructor(
        }
    }


    @VisibleForTesting
    internal fun listenForDozing(scope: CoroutineScope): Job {
        return scope.launch {
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManagerImpl;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.keyguard.ui.composable.blueprint.DefaultBlueprintModule;
import com.android.systemui.keyguard.ui.view.layout.blueprints.KeyguardBlueprintModule;
import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule;
import com.android.systemui.media.dagger.MediaModule;
import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionCli;
import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
@@ -112,6 +114,8 @@ import javax.inject.Named;
        GestureModule.class,
        HeadsUpModule.class,
        KeyboardShortcutsModule.class,
        KeyguardBlueprintModule.class,
        KeyguardSectionsModule.class,
        MediaModule.class,
        MediaMuteAwaitConnectionCli.StartableModule.class,
        MultiUserUtilsModule.class,
+0 −4
Original line number Diff line number Diff line
@@ -70,8 +70,6 @@ import com.android.systemui.inputmethod.InputMethodModule;
import com.android.systemui.keyboard.KeyboardModule;
import com.android.systemui.keyevent.data.repository.KeyEventRepositoryModule;
import com.android.systemui.keyguard.ui.composable.LockscreenContent;
import com.android.systemui.keyguard.ui.view.layout.blueprints.KeyguardBlueprintModule;
import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule;
import com.android.systemui.log.dagger.LogModule;
import com.android.systemui.log.dagger.MonitorLog;
import com.android.systemui.log.table.TableLogBuffer;
@@ -222,8 +220,6 @@ import javax.inject.Named;
        InputMethodModule.class,
        KeyEventRepositoryModule.class,
        KeyboardModule.class,
        KeyguardBlueprintModule.class,
        KeyguardSectionsModule.class,
        LetterboxModule.class,
        LogModule.class,
        MediaProjectionActivitiesModule.class,
Loading