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

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

Merge "Hide big clock when smart space appears"

parents f8a8da9a f5aff61c
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);
    }
}