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

Commit 47a0bec4 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Add transition for refreshing blueprint from ClockViewBinder

Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint DEVELOPMENT
Bug: 319468190
Test: manual

Change-Id: Id7ad2b5bd88773fd420027c5cc0a41383aab39f3
parent bcf67744
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import com.android.systemui.customization.R
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.DisplaySpecific
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags.REGION_SAMPLING
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -47,7 +47,6 @@ import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.log.core.Logger
import com.android.systemui.log.core.LogLevel.DEBUG
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceController
import com.android.systemui.plugins.clocks.ClockMessageBuffers
@@ -92,7 +91,7 @@ constructor(
    @Main private val mainExecutor: DelayableExecutor,
    @Background private val bgExecutor: Executor,
    private val clockBuffers: ClockMessageBuffers,
    private val featureFlags: FeatureFlags,
    private val featureFlags: FeatureFlagsClassic,
    private val zenModeController: ZenModeController,
) {
    var loggers = listOf(
+6 −0
Original line number Diff line number Diff line
@@ -196,6 +196,9 @@ public class KeyguardClockSwitch extends RelativeLayout {
            mSmallClockFrame = findViewById(R.id.lockscreen_clock_view);
            mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large);
            mStatusArea = findViewById(R.id.keyguard_status_area);
        } else {
            removeView(findViewById(R.id.lockscreen_clock_view));
            removeView(findViewById(R.id.lockscreen_clock_view_large));
        }
        onConfigChanged();
    }
@@ -263,6 +266,9 @@ public class KeyguardClockSwitch extends RelativeLayout {
    }

    void updateClockTargetRegions() {
        if (migrateClocksToBlueprint()) {
            return;
        }
        if (mClock != null) {
            if (mSmallClockFrame.isLaidOut()) {
                Rect targetRegion = getSmallClockRegion(mSmallClockFrame);
+20 −8
Original line number Diff line number Diff line
@@ -246,8 +246,11 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
    protected void onInit() {
        mKeyguardSliceViewController.init();

        if (!migrateClocksToBlueprint()) {
            mSmallClockFrame = mView.findViewById(R.id.lockscreen_clock_view);
            mLargeClockFrame = mView.findViewById(R.id.lockscreen_clock_view_large);
        }


        if (!mOnlyClock) {
            mDumpManager.unregisterDumpable(getClass().getSimpleName()); // unregister previous
@@ -526,7 +529,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
     */
    void updatePosition(int x, float scale, AnimationProperties props, boolean animate) {
        x = getCurrentLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -x : x;

        if (!migrateClocksToBlueprint()) {
            PropertyAnimator.setProperty(mSmallClockFrame, AnimatableProperty.TRANSLATION_X,
                    x, props, animate);
            PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_X,
@@ -534,6 +537,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
                    scale, props, animate);

        }

        if (mStatusArea != null) {
            PropertyAnimator.setProperty(mStatusArea, KeyguardStatusAreaView.TRANSLATE_X_AOD,
                    x, props, animate);
@@ -550,6 +555,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            return 0;
        }

        if (migrateClocksToBlueprint()) {
            return 0;
        }

        if (mLargeClockFrame.getVisibility() == View.VISIBLE) {
            // This gets the expected clock bottom if mLargeClockFrame had a top margin, but it's
            // top margin only contributed to height and didn't move the top of the view (as this
@@ -581,6 +590,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
    }

    boolean isClockTopAligned() {
        if (migrateClocksToBlueprint()) {
            return mKeyguardClockInteractor.getClockSize().getValue() == LARGE;
        }
        return mLargeClockFrame.getVisibility() != View.VISIBLE;
    }

+7 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.keyguard.ui.view.KeyguardRootView
import com.android.systemui.keyguard.ui.view.layout.KeyguardBlueprintCommandListener
import com.android.systemui.keyguard.ui.viewmodel.AodAlphaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardIndicationAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.OccludingAppDeviceEntryMessageViewModel
@@ -86,6 +87,7 @@ constructor(
    private val vibratorHelper: VibratorHelper,
    private val falsingManager: FalsingManager,
    private val aodAlphaViewModel: AodAlphaViewModel,
    private val keyguardClockViewModel: KeyguardClockViewModel,
) : CoreStartable {

    private var rootViewHandle: DisposableHandle? = null
@@ -113,7 +115,11 @@ constructor(
        initializeViews()

        if (!SceneContainerFlag.isEnabled) {
            KeyguardBlueprintViewBinder.bind(keyguardRootView, keyguardBlueprintViewModel)
            KeyguardBlueprintViewBinder.bind(
                keyguardRootView,
                keyguardBlueprintViewModel,
                keyguardClockViewModel
            )
        }
        keyguardBlueprintCommandListener.start()
    }
+9 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.shared.model.KeyguardBlueprint
import com.android.systemui.keyguard.ui.view.layout.blueprints.DefaultKeyguardBlueprint.Companion.DEFAULT
import com.android.systemui.keyguard.ui.view.layout.blueprints.KeyguardBlueprintModule
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransitionType.DefaultTransition
import java.io.PrintWriter
import java.util.TreeMap
import javax.inject.Inject
@@ -54,6 +56,8 @@ constructor(
        TreeMap<String, KeyguardBlueprint>().apply { putAll(blueprints.associateBy { it.id }) }
    val blueprint: MutableStateFlow<KeyguardBlueprint> = MutableStateFlow(blueprintIdMap[DEFAULT]!!)
    val refreshBluePrint: MutableSharedFlow<Unit> = MutableSharedFlow(extraBufferCapacity = 1)
    val refreshBlueprintTransition: MutableSharedFlow<IntraBlueprintTransitionType> =
        MutableSharedFlow(extraBufferCapacity = 1)
    val configurationChange: Flow<Unit> = configurationRepository.onAnyConfigurationChange

    /**
@@ -103,7 +107,12 @@ constructor(

    /** Re-emits the last emitted blueprint value if possible. */
    fun refreshBlueprint() {
        refreshBlueprintWithTransition(DefaultTransition)
    }

    fun refreshBlueprintWithTransition(type: IntraBlueprintTransitionType = DefaultTransition) {
        refreshBluePrint.tryEmit(Unit)
        refreshBlueprintTransition.tryEmit(type)
    }

    /** Prints all available blueprints to the PrintWriter. */
Loading