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

Commit d15d23ad authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Set Visibility on ClockSwitch Animation

This sets the visibility of the clock frames to invisible when they
are removed from view by KeyguardClockSwitch. This does not cause a
visual change with the clock animation directly, but allows code to
use visibility checks of the frames to determine which size clock
is shown. There is an impact on the AOD positioning for the small
clock which was already checking parameters this way, and always
using the large clock positioning parameters as a result. This is
now corrected and KeyguardClockPositionAlgorithm will recieve the
correct parameters depending on whether the large or small clock
is shown.

Fixes: 261755021
Test: Manually checked a few devices
Test: atest KeyguardClockSwitchTest
Change-Id: I1c8cb09d39e116c32ef4ed4ea07a7efad4171616
parent 34157d2c
Loading
Loading
Loading
Loading
+11 −3
Original line number Original line Diff line number Diff line
@@ -240,6 +240,7 @@ public class KeyguardClockSwitch extends RelativeLayout {


        if (!animate) {
        if (!animate) {
            out.setAlpha(0f);
            out.setAlpha(0f);
            out.setVisibility(INVISIBLE);
            in.setAlpha(1f);
            in.setAlpha(1f);
            in.setVisibility(VISIBLE);
            in.setVisibility(VISIBLE);
            mStatusArea.setTranslationY(statusAreaYTranslation);
            mStatusArea.setTranslationY(statusAreaYTranslation);
@@ -255,8 +256,11 @@ public class KeyguardClockSwitch extends RelativeLayout {
                        direction * -mClockSwitchYAmount));
                        direction * -mClockSwitchYAmount));
        mClockOutAnim.addListener(new AnimatorListenerAdapter() {
        mClockOutAnim.addListener(new AnimatorListenerAdapter() {
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                if (mClockOutAnim == animation) {
                    out.setVisibility(INVISIBLE);
                    mClockOutAnim = null;
                    mClockOutAnim = null;
                }
                }
            }
        });
        });


        in.setAlpha(0);
        in.setAlpha(0);
@@ -269,8 +273,10 @@ public class KeyguardClockSwitch extends RelativeLayout {
        mClockInAnim.setStartDelay(CLOCK_IN_START_DELAY_MILLIS);
        mClockInAnim.setStartDelay(CLOCK_IN_START_DELAY_MILLIS);
        mClockInAnim.addListener(new AnimatorListenerAdapter() {
        mClockInAnim.addListener(new AnimatorListenerAdapter() {
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                if (mClockInAnim == animation) {
                    mClockInAnim = null;
                    mClockInAnim = null;
                }
                }
            }
        });
        });


        mClockInAnim.start();
        mClockInAnim.start();
@@ -283,8 +289,10 @@ public class KeyguardClockSwitch extends RelativeLayout {
        mStatusAreaAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
        mStatusAreaAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
        mStatusAreaAnim.addListener(new AnimatorListenerAdapter() {
        mStatusAreaAnim.addListener(new AnimatorListenerAdapter() {
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                if (mStatusAreaAnim == animation) {
                    mStatusAreaAnim = null;
                    mStatusAreaAnim = null;
                }
                }
            }
        });
        });
        mStatusAreaAnim.start();
        mStatusAreaAnim.start();
    }
    }
+0 −8
Original line number Original line Diff line number Diff line
@@ -425,10 +425,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            int clockHeight = clock.getLargeClock().getView().getHeight();
            int clockHeight = clock.getLargeClock().getView().getHeight();
            return frameHeight / 2 + clockHeight / 2 + mKeyguardLargeClockTopMargin / -2;
            return frameHeight / 2 + clockHeight / 2 + mKeyguardLargeClockTopMargin / -2;
        } else {
        } else {
            // This is only called if we've never shown the large clock as the frame is inflated
            // with 'gone', but then the visibility is never set when it is animated away by
            // KeyguardClockSwitch, instead it is removed from the view hierarchy.
            // TODO(b/261755021): Cleanup Large Frame Visibility
            int clockHeight = clock.getSmallClock().getView().getHeight();
            int clockHeight = clock.getSmallClock().getView().getHeight();
            return clockHeight + statusBarHeaderHeight + mKeyguardSmallClockTopMargin;
            return clockHeight + statusBarHeaderHeight + mKeyguardSmallClockTopMargin;
        }
        }
@@ -446,15 +442,11 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        if (mLargeClockFrame.getVisibility() == View.VISIBLE) {
        if (mLargeClockFrame.getVisibility() == View.VISIBLE) {
            return clock.getLargeClock().getView().getHeight();
            return clock.getLargeClock().getView().getHeight();
        } else {
        } else {
            // Is not called except in certain edge cases, see comment in getClockBottom
            // TODO(b/261755021): Cleanup Large Frame Visibility
            return clock.getSmallClock().getView().getHeight();
            return clock.getSmallClock().getView().getHeight();
        }
        }
    }
    }


    boolean isClockTopAligned() {
    boolean isClockTopAligned() {
        // Returns false except certain edge cases, see comment in getClockBottom
        // TODO(b/261755021): Cleanup Large Frame Visibility
        return mLargeClockFrame.getVisibility() != View.VISIBLE;
        return mLargeClockFrame.getVisibility() != View.VISIBLE;
    }
    }


+5 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.keyguard;
package com.android.keyguard;


import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.View.VISIBLE;


import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
@@ -189,6 +190,7 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(1);
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(1);
        assertThat(mLargeClockFrame.getVisibility()).isEqualTo(VISIBLE);
        assertThat(mLargeClockFrame.getVisibility()).isEqualTo(VISIBLE);
        assertThat(mSmallClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mSmallClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mSmallClockFrame.getVisibility()).isEqualTo(INVISIBLE);
    }
    }


    @Test
    @Test
@@ -198,6 +200,7 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(1);
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(1);
        assertThat(mLargeClockFrame.getVisibility()).isEqualTo(VISIBLE);
        assertThat(mLargeClockFrame.getVisibility()).isEqualTo(VISIBLE);
        assertThat(mSmallClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mSmallClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mSmallClockFrame.getVisibility()).isEqualTo(INVISIBLE);
    }
    }


    @Test
    @Test
@@ -212,6 +215,7 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
        // only big clock is removed at switch
        // only big clock is removed at switch
        assertThat(mLargeClockFrame.getParent()).isNull();
        assertThat(mLargeClockFrame.getParent()).isNull();
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mLargeClockFrame.getVisibility()).isEqualTo(INVISIBLE);
    }
    }


    @Test
    @Test
@@ -223,6 +227,7 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
        // only big clock is removed at switch
        // only big clock is removed at switch
        assertThat(mLargeClockFrame.getParent()).isNull();
        assertThat(mLargeClockFrame.getParent()).isNull();
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(0);
        assertThat(mLargeClockFrame.getVisibility()).isEqualTo(INVISIBLE);
    }
    }


    @Test
    @Test