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

Commit f2936a7d authored by Jonathon Axford's avatar Jonathon Axford Committed by Android (Google) Code Review
Browse files

Merge "Force small clock on small landscape lockscreen (except AOD)" into main

parents 5b8d258a 8c2fe3f7
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright (c) 2023, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
-->
<resources>
    <!-- Only use small clock on lockscreen.
     True here because only small clock used on small devices in landscape -->
    <bool name="force_small_clock_on_lockscreen">true</bool>
</resources>
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright (c) 2023, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
-->
<resources>
    <!-- Only use small clock on lockscreen.
     False here because large clock is allowed on large devices in landscape -->
    <bool name="force_small_clock_on_lockscreen">false</bool>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -59,4 +59,8 @@

      True here so bouncers constraints are updated when rotating on small screens -->
    <bool name="update_bouncer_constraints">true</bool>

    <!-- Only use small clock on lockscreen.
     False here because large clock used by default, unless otherwise specified -->
    <bool name="force_small_clock_on_lockscreen">false</bool>
</resources>
+11 −0
Original line number Diff line number Diff line
@@ -1675,6 +1675,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

    @ClockSize
    private int computeDesiredClockSize() {
        if (shouldForceSmallClock()) {
            return SMALL;
        }

        if (mSplitShadeEnabled) {
            return computeDesiredClockSizeForSplitShade();
        }
@@ -1707,6 +1711,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        return LARGE;
    }

    private boolean shouldForceSmallClock() {
        return mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)
                && !isOnAod()
                // True on small landscape screens
                && mResources.getBoolean(R.bool.force_small_clock_on_lockscreen);
    }

    private void updateKeyguardStatusViewAlignment(boolean animate) {
        boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered();
        ConstraintLayout layout;
+36 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.shade;

import static com.android.keyguard.FaceAuthApiRequestReason.NOTIFICATION_PANEL_CLICKED;
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import static com.android.keyguard.KeyguardClockSwitch.SMALL;
import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_CLOSED;
@@ -834,6 +833,42 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo
        verify(mKeyguardStatusViewController).displayClock(LARGE, /* animate */ false);
    }

    @Test
    public void switchesToBigClockInSplitShadeOn_landFlagOn_ForceSmallClock() {
        when(mScreenOffAnimationController.shouldAnimateClockChange()).thenReturn(false);
        mStatusBarStateController.setState(KEYGUARD);
        enableSplitShade(/* enabled= */ false);
        mNotificationPanelViewController.setDozing(false, false);
        when(mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)).thenReturn(true);
        when(mResources.getBoolean(R.bool.force_small_clock_on_lockscreen)).thenReturn(true);
        when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
        when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(0);
        clearInvocations(mKeyguardStatusViewController);

        enableSplitShade(/* enabled= */ true);
        mNotificationPanelViewController.updateResources();

        verify(mKeyguardStatusViewController).displayClock(SMALL, /* animate */ false);
    }

    @Test
    public void switchesToBigClockInSplitShadeOn_landFlagOff_DontForceSmallClock() {
        when(mScreenOffAnimationController.shouldAnimateClockChange()).thenReturn(false);
        mStatusBarStateController.setState(KEYGUARD);
        enableSplitShade(/* enabled= */ false);
        mNotificationPanelViewController.setDozing(false, false);
        when(mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE)).thenReturn(false);
        when(mResources.getBoolean(R.bool.force_small_clock_on_lockscreen)).thenReturn(true);
        when(mMediaDataManager.hasActiveMedia()).thenReturn(false);
        when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(0);
        clearInvocations(mKeyguardStatusViewController);

        enableSplitShade(/* enabled= */ true);
        mNotificationPanelViewController.updateResources();

        verify(mKeyguardStatusViewController).displayClock(LARGE, /* animate */ false);
    }

    @Test
    public void testDisplaysSmallClockOnLockscreenInSplitShadeWhenMediaIsPlaying() {
        mStatusBarStateController.setState(KEYGUARD);