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

Commit 4aeee7e9 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Fix clock translation on lockscreen

make clock counter translation by amount of
getExpandedPreferredClockY to align to screen

Previously reverted due to b/280096103, fix by comparing clockY and
calling updateClockTargetRegions less frequently

Test: manually
Bug: 278413320
Bug: 278456894
Change-Id: I1b133bab62769681d718e273370d319b57e44e98
parent 8e471cfe
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.animation.Interpolators;
import com.android.systemui.log.LogBuffer;
import com.android.systemui.log.LogLevel;
import com.android.systemui.plugins.ClockController;
import com.android.systemui.shared.clocks.DefaultClockController;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
@@ -46,6 +47,9 @@ public class KeyguardClockSwitch extends RelativeLayout {

    public static final int LARGE = 0;
    public static final int SMALL = 1;
    // compensate for translation of parents subject to device screen
    // In this case, the translation comes from KeyguardStatusView
    public int screenOffsetYPadding = 0;

    /** Returns a region for the large clock to position itself, based on the given parent. */
    public static Rect getLargeClockRegion(ViewGroup parent) {
@@ -161,8 +165,18 @@ public class KeyguardClockSwitch extends RelativeLayout {
            }

            if (mLargeClockFrame.isLaidOut()) {
                Rect targetRegion = getLargeClockRegion(mLargeClockFrame);
                if (mClock instanceof DefaultClockController) {
                    mClock.getLargeClock().getEvents().onTargetRegionChanged(
                        getLargeClockRegion(mLargeClockFrame));
                            targetRegion);
                } else {
                    mClock.getLargeClock().getEvents().onTargetRegionChanged(
                            new Rect(
                                    targetRegion.left,
                                    targetRegion.top - screenOffsetYPadding,
                                    targetRegion.right,
                                    targetRegion.bottom - screenOffsetYPadding));
                }
            }
        }
    }
+10 −7
Original line number Diff line number Diff line
@@ -168,6 +168,16 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        mOnlyClock = onlyClock;
    }

    /**
     * Used for status view to pass the screen offset from parent view
     */
    public void setLockscreenClockY(int clockY) {
        if (mView.screenOffsetYPadding != clockY) {
            mView.screenOffsetYPadding = clockY;
            mView.updateClockTargetRegions();
        }
    }

    /**
     * Attach the controller to the view it relates to.
     */
@@ -394,13 +404,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            PropertyAnimator.setProperty(mStatusArea, AnimatableProperty.TRANSLATION_X,
                    x, props, animate);
        }

    }

    void updateKeyguardStatusViewOffset() {
        // updateClockTargetRegions will call onTargetRegionChanged
        // which will require the correct translationY property of keyguardStatusView after updating
        mView.updateClockTargetRegions();
    }

    /**
+9 −5
Original line number Diff line number Diff line
@@ -214,6 +214,15 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
        return mKeyguardClockSwitchController.isClockTopAligned();
    }

    /**
     * Pass top margin from ClockPositionAlgorithm in NotificationPanelViewController
     * Use for clock view in LS to compensate for top margin to align to the screen
     * Regardless of translation from AOD and unlock gestures
     */
    public void setLockscreenClockY(int clockY) {
        mKeyguardClockSwitchController.setLockscreenClockY(clockY);
    }

    /**
     * Set whether the view accessibility importance mode.
     */
@@ -230,7 +239,6 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
     * Update position of the view with an optional animation
     */
    public void updatePosition(int x, int y, float scale, boolean animate) {
        float oldY = mView.getY();
        setProperty(AnimatableProperty.Y, y, animate);

        ClockController clock = mKeyguardClockSwitchController.getClock();
@@ -246,10 +254,6 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
            setProperty(AnimatableProperty.SCALE_X, 1f, animate);
            setProperty(AnimatableProperty.SCALE_Y, 1f, animate);
        }

        if (oldY != y) {
            mKeyguardClockSwitchController.updateKeyguardStatusViewOffset();
        }
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -1513,6 +1513,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                mKeyguardStatusViewController.getClockBottom(mStatusBarHeaderHeightKeyguard),
                mKeyguardStatusViewController.isClockTopAligned());
        mClockPositionAlgorithm.run(mClockPositionResult);
        mKeyguardStatusViewController.setLockscreenClockY(
                mClockPositionAlgorithm.getExpandedPreferredClockY());
        mKeyguardBottomAreaInteractor.setClockPosition(
                mClockPositionResult.clockX, mClockPositionResult.clockY);
        boolean animate = mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending();
+5 −1
Original line number Diff line number Diff line
@@ -239,7 +239,11 @@ public class KeyguardClockPositionAlgorithm {
        }
    }

    private int getExpandedPreferredClockY() {
    /**
     * give the static topMargin, used for lockscreen clocks to get the initial translationY
     * to do counter translation
     */
    public int getExpandedPreferredClockY() {
        if (mIsSplitShade) {
            return mSplitShadeTargetTopMargin;
        } else {