Loading packages/SystemUI/res-keyguard/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -129,4 +129,7 @@ <dimen name="user_switcher_icon_selected_width">8dp</dimen> <dimen name="user_switcher_fullscreen_button_text_size">14sp</dimen> <dimen name="user_switcher_fullscreen_button_padding">12dp</dimen> <!-- Translation y for appear animation --> <dimen name="keyguard_host_view_translation_y">80dp</dimen> </resources> packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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 */ package com.android.keyguard import android.util.MathUtils object BouncerPanelExpansionCalculator { /** * Scale the alpha/position of the host view. */ @JvmStatic fun getHostViewScaledExpansion(fraction: Float): Float { return when { fraction >= 0.9f -> 1f fraction < 0.6 -> 0f else -> (fraction - 0.6f) / 0.3f } } /** * Scale the alpha/tint of the back scrim. */ @JvmStatic fun getBackScrimScaledExpansion(fraction: Float): Float { return MathUtils.constrain((fraction - 0.9f) / 0.1f, 0f, 1f) } /** * This will scale the alpha/position of the clock. */ @JvmStatic fun getKeyguardClockScaledExpansion(fraction: Float): Float { return MathUtils.constrain((fraction - 0.7f) / 0.3f, 0f, 1f) } } No newline at end of file packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java +8 −4 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import com.android.keyguard.dagger.KeyguardBouncerScope; import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.util.ViewController; import java.io.File; Loading @@ -64,6 +63,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> private ActivityStarter.OnDismissAction mDismissAction; private Runnable mCancelAction; private int mTranslationY; private final KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { Loading Loading @@ -322,12 +322,14 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> /** * Fades and translates in/out the security screen. * Fades in as expansion approaches 0. * Animation duration is between 0.33f and 0.67f of panel expansion fraction. * @param fraction amount of the screen that should show. */ public void setExpansion(float fraction) { float alpha = MathUtils.map(KeyguardBouncer.ALPHA_EXPANSION_THRESHOLD, 1, 1, 0, fraction); mView.setAlpha(MathUtils.constrain(alpha, 0f, 1f)); mView.setTranslationY(fraction * mView.getHeight()); float scaledFraction = BouncerPanelExpansionCalculator.getHostViewScaledExpansion(fraction); mView.setAlpha(MathUtils.constrain(1 - scaledFraction, 0f, 1f)); mView.setTranslationY(scaledFraction * mTranslationY); } /** Loading Loading @@ -490,6 +492,8 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> gravity = resources.getInteger(R.integer.keyguard_host_view_gravity); } mTranslationY = resources .getDimensionPixelSize(R.dimen.keyguard_host_view_translation_y); // Android SysUI uses a FrameLayout as the top-level, but Auto uses RelativeLayout. // We're just changing the gravity here though (which can't be applied to RelativeLayout), // so only attempt the update if mView is inside a FrameLayout. Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +3 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.systemui.statusbar.notification.NotificationUtils.inte import android.content.res.Resources; import android.util.MathUtils; import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.keyguard.KeyguardStatusView; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; Loading Loading @@ -169,7 +170,8 @@ public class KeyguardClockPositionAlgorithm { boolean isSplitShade, float udfpsTop, float clockBottom, boolean isClockTopAligned) { mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(mContainerTopPadding, userSwitchHeight); mPanelExpansion = panelExpansion; mPanelExpansion = BouncerPanelExpansionCalculator .getKeyguardClockScaledExpansion(panelExpansion); mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin; mUserSwitchHeight = userSwitchHeight; mUserSwitchPreferredY = userSwitchPreferredY; Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +10 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.colorextraction.ColorExtractor.GradientColors; import com.android.internal.graphics.ColorUtils; import com.android.internal.util.function.TriConsumer; import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.settingslib.Utils; Loading Loading @@ -808,7 +809,15 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private Pair<Integer, Float> calculateBackStateForState(ScrimState state) { // Either darken of make the scrim transparent when you // pull down the shade float interpolatedFract = getInterpolatedFraction(); float interpolatedFract; if (state == ScrimState.KEYGUARD) { interpolatedFract = BouncerPanelExpansionCalculator .getBackScrimScaledExpansion(mPanelExpansionFraction); } else { interpolatedFract = getInterpolatedFraction(); } float stateBehind = mClipsQsScrim ? state.getNotifAlpha() : state.getBehindAlpha(); float behindAlpha; int behindTint; Loading Loading
packages/SystemUI/res-keyguard/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -129,4 +129,7 @@ <dimen name="user_switcher_icon_selected_width">8dp</dimen> <dimen name="user_switcher_fullscreen_button_text_size">14sp</dimen> <dimen name="user_switcher_fullscreen_button_padding">12dp</dimen> <!-- Translation y for appear animation --> <dimen name="keyguard_host_view_translation_y">80dp</dimen> </resources>
packages/SystemUI/src/com/android/keyguard/BouncerPanelExpansionCalculator.kt 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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 */ package com.android.keyguard import android.util.MathUtils object BouncerPanelExpansionCalculator { /** * Scale the alpha/position of the host view. */ @JvmStatic fun getHostViewScaledExpansion(fraction: Float): Float { return when { fraction >= 0.9f -> 1f fraction < 0.6 -> 0f else -> (fraction - 0.6f) / 0.3f } } /** * Scale the alpha/tint of the back scrim. */ @JvmStatic fun getBackScrimScaledExpansion(fraction: Float): Float { return MathUtils.constrain((fraction - 0.9f) / 0.1f, 0f, 1f) } /** * This will scale the alpha/position of the clock. */ @JvmStatic fun getKeyguardClockScaledExpansion(fraction: Float): Float { return MathUtils.constrain((fraction - 0.7f) / 0.3f, 0f, 1f) } } No newline at end of file
packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java +8 −4 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import com.android.keyguard.dagger.KeyguardBouncerScope; import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.util.ViewController; import java.io.File; Loading @@ -64,6 +63,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> private ActivityStarter.OnDismissAction mDismissAction; private Runnable mCancelAction; private int mTranslationY; private final KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { Loading Loading @@ -322,12 +322,14 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> /** * Fades and translates in/out the security screen. * Fades in as expansion approaches 0. * Animation duration is between 0.33f and 0.67f of panel expansion fraction. * @param fraction amount of the screen that should show. */ public void setExpansion(float fraction) { float alpha = MathUtils.map(KeyguardBouncer.ALPHA_EXPANSION_THRESHOLD, 1, 1, 0, fraction); mView.setAlpha(MathUtils.constrain(alpha, 0f, 1f)); mView.setTranslationY(fraction * mView.getHeight()); float scaledFraction = BouncerPanelExpansionCalculator.getHostViewScaledExpansion(fraction); mView.setAlpha(MathUtils.constrain(1 - scaledFraction, 0f, 1f)); mView.setTranslationY(scaledFraction * mTranslationY); } /** Loading Loading @@ -490,6 +492,8 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView> gravity = resources.getInteger(R.integer.keyguard_host_view_gravity); } mTranslationY = resources .getDimensionPixelSize(R.dimen.keyguard_host_view_translation_y); // Android SysUI uses a FrameLayout as the top-level, but Auto uses RelativeLayout. // We're just changing the gravity here though (which can't be applied to RelativeLayout), // so only attempt the update if mView is inside a FrameLayout. Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +3 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.systemui.statusbar.notification.NotificationUtils.inte import android.content.res.Resources; import android.util.MathUtils; import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.keyguard.KeyguardStatusView; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; Loading Loading @@ -169,7 +170,8 @@ public class KeyguardClockPositionAlgorithm { boolean isSplitShade, float udfpsTop, float clockBottom, boolean isClockTopAligned) { mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(mContainerTopPadding, userSwitchHeight); mPanelExpansion = panelExpansion; mPanelExpansion = BouncerPanelExpansionCalculator .getKeyguardClockScaledExpansion(panelExpansion); mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin; mUserSwitchHeight = userSwitchHeight; mUserSwitchPreferredY = userSwitchPreferredY; Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +10 −1 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.colorextraction.ColorExtractor.GradientColors; import com.android.internal.graphics.ColorUtils; import com.android.internal.util.function.TriConsumer; import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.settingslib.Utils; Loading Loading @@ -808,7 +809,15 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private Pair<Integer, Float> calculateBackStateForState(ScrimState state) { // Either darken of make the scrim transparent when you // pull down the shade float interpolatedFract = getInterpolatedFraction(); float interpolatedFract; if (state == ScrimState.KEYGUARD) { interpolatedFract = BouncerPanelExpansionCalculator .getBackScrimScaledExpansion(mPanelExpansionFraction); } else { interpolatedFract = getInterpolatedFraction(); } float stateBehind = mClipsQsScrim ? state.getNotifAlpha() : state.getBehindAlpha(); float behindAlpha; int behindTint; Loading