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

Commit f5aff61c authored by Wesley.CW Wang's avatar Wesley.CW Wang
Browse files

Hide big clock when smart space appears

 - Add new method to KeyguardClockSwitch and check it when slice changed
 - Check hasHeader value when updating big clock visibility

Bug: 153692869
Test: atest KeyguardClockSwitchTest and manually
Change-Id: Id761558224e56ea2b1ea38578be59f17a6b06247
parent de8205a2
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -423,9 +423,8 @@ public class KeyguardClockSwitch extends RelativeLayout {
        }
        final boolean inDisplayState = mStatusBarState == StatusBarState.KEYGUARD
                || mStatusBarState == StatusBarState.SHADE_LOCKED;
        final int visibility =
                inDisplayState && mBigClockContainer.getChildCount() != 0 ? View.VISIBLE
                        : View.GONE;
        final int visibility = !mShowingHeader && inDisplayState
                    && mBigClockContainer.getChildCount() != 0 ? View.VISIBLE : View.GONE;
        if (mBigClockContainer.getVisibility() != visibility) {
            mBigClockContainer.setVisibility(visibility);
        }
@@ -497,6 +496,16 @@ public class KeyguardClockSwitch extends RelativeLayout {
                mClockViewBold.getPaddingRight(), paddingBottom);
    }

    /**
     * Hide big clock if the keyguard slice is showing a header, need to reduce visual clutter in
     * these cases.
     */
    public void setKeyguardHidingBigClock(boolean hasHeader) {
        if (mBigClockContainer != null) {
            mBigClockContainer.setVisibility(hasHeader ? View.GONE : View.VISIBLE);
        }
    }

    @VisibleForTesting(otherwise = VisibleForTesting.NONE)
    ClockManager.ClockChangedListener getClockChangedListener() {
        return mClockChangedListener;
+2 −0
Original line number Diff line number Diff line
@@ -245,6 +245,8 @@ public class KeyguardStatusView extends GridLayout implements
                    params.bottomMargin);
            mNotificationIcons.setLayoutParams(params);
        }

        mClockView.setKeyguardHidingBigClock(hasHeader);
    }

    @Override
+36 −0
Original line number Diff line number Diff line
@@ -348,4 +348,40 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
        // THEN the container is made visible.
        assertThat(mBigClockContainer.getVisibility()).isEqualTo(View.VISIBLE);
    }

    @Test
    public void setKeyguardHidingBigClock_gone() {
        // GIVEN that the container for the big clock has visibility GONE
        mBigClockContainer.setVisibility(GONE);
        mKeyguardClockSwitch.setBigClockContainer(mBigClockContainer);
        // AND the plugin returns a view for the big clock
        ClockPlugin plugin = mock(ClockPlugin.class);
        when(plugin.getBigClockView()).thenReturn(mBigClock);
        // AND in the keyguard state
        mStateListener.onStateChanged(StatusBarState.KEYGUARD);
        // WHEN the plugin is connected
        mKeyguardClockSwitch.getClockChangedListener().onClockChanged(plugin);
        // WHEN the container set hiding clock as true
        mKeyguardClockSwitch.setKeyguardHidingBigClock(true);
        // THEN the container is gone.
        assertThat(mBigClockContainer.getVisibility()).isEqualTo(View.GONE);
    }

    @Test
    public void setKeyguardHidingBigClock_visible() {
        // GIVEN that the container for the big clock has visibility GONE
        mBigClockContainer.setVisibility(GONE);
        mKeyguardClockSwitch.setBigClockContainer(mBigClockContainer);
        // AND the plugin returns a view for the big clock
        ClockPlugin plugin = mock(ClockPlugin.class);
        when(plugin.getBigClockView()).thenReturn(mBigClock);
        // AND in the keyguard state
        mStateListener.onStateChanged(StatusBarState.KEYGUARD);
        // WHEN the plugin is connected
        mKeyguardClockSwitch.getClockChangedListener().onClockChanged(plugin);
        // WHEN the container set hiding clock as false
        mKeyguardClockSwitch.setKeyguardHidingBigClock(false);
        // THEN the container is made visible.
        assertThat(mBigClockContainer.getVisibility()).isEqualTo(View.VISIBLE);
    }
}