diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 8faeb155b1e6f..112f91ca05c97 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -308,11 +308,23 @@ public class KeyguardIndicationController implements StateListener { // Walk down a precedence-ordered list of what indication // should be shown based on user or device state if (mDozing) { + // When dozing we ignore any text color and use white instead, because + // colors can be hard to read in low brightness. + mTextView.setTextColor(Color.WHITE); if (!TextUtils.isEmpty(mTransientIndication)) { - mTextView.setTextColor(Color.WHITE); mTextView.switchIndication(mTransientIndication); + } else if (mPowerPluggedIn) { + String indication = computePowerIndication(); + if (animate) { + animateText(mTextView, indication); + } else { + mTextView.switchIndication(indication); + } + } else { + String percentage = NumberFormat.getPercentInstance() + .format(mBatteryLevel / 100f); + mTextView.switchIndication(percentage); } - updateAlphas(); return; } @@ -353,14 +365,6 @@ public class KeyguardIndicationController implements StateListener { } } - private void updateAlphas() { - if (!TextUtils.isEmpty(mTransientIndication)) { - mTextView.setAlpha(1f); - } else { - mTextView.setAlpha(1f - mDarkAmount); - } - } - // animates textView - textView moves up and bounces down private void animateText(KeyguardIndicationTextView textView, String indication) { int yTranslation = mContext.getResources().getInteger( @@ -523,14 +527,6 @@ public class KeyguardIndicationController implements StateListener { pw.println(" computePowerIndication(): " + computePowerIndication()); } - public void setDarkAmount(float darkAmount) { - if (mDarkAmount == darkAmount) { - return; - } - mDarkAmount = darkAmount; - updateAlphas(); - } - @Override public void onStateChanged(int newState) { // don't care diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 2d91d53212f47..a924680b7043a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone; import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; +import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_BUTTON; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_UNLOCK; import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_RIGHT_BUTTON; @@ -172,6 +173,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private boolean mDozing; private int mIndicationBottomMargin; private float mDarkAmount; + private int mBurnInXOffset; + private int mBurnInYOffset; private ActivityIntentHelper mActivityIntentHelper; public KeyguardBottomAreaView(Context context) { @@ -252,6 +255,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL mIndicationText = findViewById(R.id.keyguard_indication_text); mIndicationBottomMargin = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom); + mBurnInYOffset = getResources().getDimensionPixelSize( + R.dimen.default_burn_in_prevention_offset); updateCameraVisibility(); mUnlockMethodCache = UnlockMethodCache.getInstance(getContext()); mUnlockMethodCache.addListener(this); @@ -321,6 +326,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL super.onConfigurationChanged(newConfig); mIndicationBottomMargin = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom); + mBurnInYOffset = getResources().getDimensionPixelSize( + R.dimen.default_burn_in_prevention_offset); MarginLayoutParams mlp = (MarginLayoutParams) mIndicationArea.getLayoutParams(); if (mlp.bottomMargin != mIndicationBottomMargin) { mlp.bottomMargin = mIndicationBottomMargin; @@ -564,8 +571,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } mDarkAmount = darkAmount; - mIndicationController.setDarkAmount(darkAmount); mLockIcon.setDarkAmount(darkAmount); + dozeTimeTick(); } /** @@ -841,6 +848,20 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } } + public void dozeTimeTick() { + int burnInYOffset = getBurnInOffset(mBurnInYOffset * 2, false /* xAxis */) + - mBurnInYOffset; + mIndicationArea.setTranslationY(burnInYOffset * mDarkAmount); + } + + public void setAntiBurnInOffsetX(int burnInXOffset) { + if (mBurnInXOffset == burnInXOffset) { + return; + } + mBurnInXOffset = burnInXOffset; + mIndicationArea.setTranslationX(burnInXOffset); + } + /** * Sets the alpha of the indication areas and affordances, excluding the lock icon. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 4c50d07aa6eac..2bd8d41a24e30 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -17,7 +17,6 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.ScreenDecorations.DisplayCutoutView.boundsFromDirection; -import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import android.annotation.ColorInt; import android.content.Context; @@ -102,19 +101,6 @@ public class KeyguardStatusBarView extends RelativeLayout */ private int mCutoutSideNudge = 0; - /** - * How much to move icons to avoid burn in. - */ - private int mBurnInOffset; - private int mCurrentBurnInOffsetX; - private int mCurrentBurnInOffsetY; - - /** - * Ratio representing being in ambient mode or not. - */ - private float mDarkAmount; - private boolean mDozing; - public KeyguardStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); } @@ -186,8 +172,6 @@ public class KeyguardStatusBarView extends RelativeLayout R.dimen.system_icons_super_container_avatarless_margin_end); mCutoutSideNudge = getResources().getDimensionPixelSize( R.dimen.display_cutout_margin_consumption); - mBurnInOffset = getResources().getDimensionPixelSize( - R.dimen.default_burn_in_prevention_offset); mShowPercentAvailable = getContext().getResources().getBoolean( com.android.internal.R.bool.config_battery_percentage_setting_available); } @@ -211,7 +195,7 @@ public class KeyguardStatusBarView extends RelativeLayout mMultiUserSwitch.setVisibility(View.GONE); } } - mBatteryView.setForceShowPercent(mBatteryCharging && mShowPercentAvailable || mDozing); + mBatteryView.setForceShowPercent(mBatteryCharging && mShowPercentAvailable); } private void updateSystemIconsLayoutParams() { @@ -348,7 +332,6 @@ public class KeyguardStatusBarView extends RelativeLayout mIconManager = new TintedIconManager(findViewById(R.id.statusIcons)); Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager); onThemeChanged(); - updateDarkState(); } @Override @@ -492,7 +475,7 @@ public class KeyguardStatusBarView extends RelativeLayout mIconManager.setTint(iconColor); } - applyDarkness(R.id.battery, mEmptyRect, intensity * (1f - mDarkAmount), iconColor); + applyDarkness(R.id.battery, mEmptyRect, intensity, iconColor); applyDarkness(R.id.clock, mEmptyRect, intensity, iconColor); } @@ -513,48 +496,4 @@ public class KeyguardStatusBarView extends RelativeLayout mBatteryView.dump(fd, pw, args); } } - - public void setDozing(boolean dozing) { - if (mDozing == dozing) { - return; - } - mDozing = dozing; - setClipChildren(!dozing); - setClipToPadding(!dozing); - updateVisibilities(); - } - - public void setDarkAmount(float darkAmount) { - mDarkAmount = darkAmount; - if (darkAmount == 0) { - dozeTimeTick(); - } - updateDarkState(); - } - - public void dozeTimeTick() { - mCurrentBurnInOffsetX = getBurnInOffset(mBurnInOffset, true /* xAxis */); - mCurrentBurnInOffsetY = getBurnInOffset(mBurnInOffset, false /* xAxis */); - updateDarkState(); - } - - private void updateDarkState() { - float alpha = 1f - mDarkAmount; - int visibility = alpha != 0f ? VISIBLE : INVISIBLE; - mCarrierLabel.setAlpha(alpha * alpha); - mStatusIconContainer.setAlpha(alpha); - mStatusIconContainer.setVisibility(visibility); - - float iconsX = -mCurrentBurnInOffsetX; - if (mMultiUserSwitch.getVisibility() == VISIBLE) { - // Squared alpha to add a nice easing curve and avoid overlap during animation. - mMultiUserAvatar.setAlpha(alpha * alpha); - iconsX += mMultiUserAvatar.getPaddingLeft() + mMultiUserAvatar.getWidth() - + mMultiUserAvatar.getPaddingRight(); - } - mSystemIconsContainer.setTranslationX(iconsX * mDarkAmount); - mSystemIconsContainer.setTranslationY(mCurrentBurnInOffsetY * mDarkAmount); - updateIconsAndTextColors(); - } - } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 9ab2a7d879000..fca07dcc82dc5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -635,6 +635,7 @@ public class NotificationPanelView extends PanelView implements } mNotificationStackScroller.setIntrinsicPadding(stackScrollerPadding); mNotificationStackScroller.setAntiBurnInOffsetX(mClockPositionResult.clockX); + mKeyguardBottomArea.setAntiBurnInOffsetX(mClockPositionResult.clockX); mStackScrollerMeasuringPass++; requestScrollerTopPaddingUpdate(animate); @@ -1886,7 +1887,7 @@ public class NotificationPanelView extends PanelView implements float newAlpha = Math.min(getKeyguardContentsAlpha(), alphaQsExpansion) * mKeyguardStatusBarAnimateAlpha; mKeyguardStatusBar.setAlpha(newAlpha); - mKeyguardStatusBar.setVisibility(newAlpha != 0f ? VISIBLE : INVISIBLE); + mKeyguardStatusBar.setVisibility(newAlpha != 0f && !mDozing ? VISIBLE : INVISIBLE); } private void updateKeyguardBottomAreaAlpha() { @@ -2373,12 +2374,11 @@ public class NotificationPanelView extends PanelView implements positionClockAndNotifications(); } - private static float interpolate(float t, float start, float end) { - return (1 - t) * start + t * end; - } - private void updateDozingVisibilities(boolean animate) { mKeyguardBottomArea.setDozing(mDozing, animate); + if (!mDozing && animate) { + animateKeyguardStatusBarIn(StackStateAnimator.ANIMATION_DURATION_STANDARD); + } } @Override @@ -2814,7 +2814,7 @@ public class NotificationPanelView extends PanelView implements if (mDozing) { mNotificationStackScroller.setShowDarkShelf(!hasCustomClock()); } - mKeyguardStatusBar.setDozing(mDozing); + mKeyguardBottomArea.setDozing(mDozing, animate); if (mBarState == StatusBarState.KEYGUARD || mBarState == StatusBarState.SHADE_LOCKED) { @@ -2829,7 +2829,6 @@ public class NotificationPanelView extends PanelView implements public void onDozeAmountChanged(float linearAmount, float amount) { mInterpolatedDarkAmount = amount; mLinearDarkAmount = linearAmount; - mKeyguardStatusBar.setDarkAmount(mInterpolatedDarkAmount); mKeyguardStatusView.setDarkAmount(mInterpolatedDarkAmount); mKeyguardBottomArea.setDarkAmount(mInterpolatedDarkAmount); positionClockAndNotifications(); @@ -2861,7 +2860,7 @@ public class NotificationPanelView extends PanelView implements } public void dozeTimeTick() { - mKeyguardStatusBar.dozeTimeTick(); + mKeyguardBottomArea.dozeTimeTick(); mKeyguardStatusView.dozeTimeTick(); if (mInterpolatedDarkAmount > 0) { positionClockAndNotifications(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index 232c6a25a7089..3b56e45ea3546 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -60,6 +60,8 @@ public class NotificationPanelViewTest extends SysuiTestCase { @Mock private KeyguardStatusView mKeyguardStatusView; @Mock + private KeyguardBottomAreaView mKeyguardBottomArea; + @Mock private KeyguardStatusBarView mKeyguardStatusBar; private NotificationPanelView mNotificationPanelView; @@ -113,6 +115,7 @@ public class NotificationPanelViewTest extends SysuiTestCase { mNotificationStackScroller = mNotificationStackScrollLayout; mKeyguardStatusView = NotificationPanelViewTest.this.mKeyguardStatusView; mKeyguardStatusBar = NotificationPanelViewTest.this.mKeyguardStatusBar; + mKeyguardBottomArea = NotificationPanelViewTest.this.mKeyguardBottomArea; } } }