From 8c556d72f1cbe1d3e22cb1d97851b63c7ddc886a Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Wed, 27 Jun 2018 11:44:57 -0700 Subject: [PATCH] Move charging indication vertically on time tick Before, a new translation was only calculated when the device enters AOD, and then, during time tick, we would only move it 5px wich isn't enough. Now, the translation varies 5dps vertically on every time tick. Fixes: 110888643 Test: take screenshots for N minutes and compare them Change-Id: Ia3f239d669b83aad0d97d8d7a7f7374f4890777d Merged-In: Ia3f239d669b83aad0d97d8d7a7f7374f4890777d --- packages/SystemUI/res/values/dimens.xml | 12 ++++++++---- .../statusbar/phone/KeyguardBottomAreaView.java | 16 ++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 34d71da2c0173..883ed8dd17d9a 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -919,14 +919,18 @@ 120dp - + 8dp - + 50dp + + 5dp + 8dp 0dp 48dp 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 0716b37ff8d9a..60d62d52995d3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -172,6 +172,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private int mIndicationBottomMarginAmbient; private float mDarkAmount; private int mBurnInXOffset; + private int mBurnInYOffset; public KeyguardBottomAreaView(Context context) { this(context, null); @@ -245,6 +246,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL R.dimen.keyguard_indication_margin_bottom); mIndicationBottomMarginAmbient = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom_ambient); + mBurnInYOffset = getResources().getDimensionPixelSize( + R.dimen.charging_indication_burn_in_prevention_offset_y); updateCameraVisibility(); mUnlockMethodCache = UnlockMethodCache.getInstance(getContext()); mUnlockMethodCache.addListener(this); @@ -317,6 +320,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL R.dimen.keyguard_indication_margin_bottom); mIndicationBottomMarginAmbient = getResources().getDimensionPixelSize( R.dimen.keyguard_indication_margin_bottom_ambient); + mBurnInYOffset = getResources().getDimensionPixelSize( + R.dimen.charging_indication_burn_in_prevention_offset_y); MarginLayoutParams mlp = (MarginLayoutParams) mIndicationArea.getLayoutParams(); if (mlp.bottomMargin != mIndicationBottomMargin) { mlp.bottomMargin = mIndicationBottomMargin; @@ -560,12 +565,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } mDarkAmount = darkAmount; - // Let's randomize the bottom margin every time we wake up to avoid burn-in. - if (darkAmount == 0) { - mIndicationBottomMarginAmbient = getResources().getDimensionPixelSize( - R.dimen.keyguard_indication_margin_bottom_ambient) - + (int) (Math.random() * mIndicationText.getTextSize()); - } mIndicationArea.setAlpha(MathUtils.lerp(1f, 0.7f, darkAmount)); mIndicationArea.setTranslationY(MathUtils.lerp(0, mIndicationBottomMargin - mIndicationBottomMarginAmbient, darkAmount)); @@ -841,8 +840,9 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL public void dozeTimeTick() { if (mDarkAmount == 1) { // Move indication every minute to avoid burn-in - final int dozeTranslation = mIndicationBottomMargin - mIndicationBottomMarginAmbient; - mIndicationArea.setTranslationY(dozeTranslation + (float) Math.random() * 5); + int dozeTranslation = mIndicationBottomMargin - mIndicationBottomMarginAmbient; + int burnInYOffset = (int) (-mBurnInYOffset + Math.random() * mBurnInYOffset * 2); + mIndicationArea.setTranslationY(dozeTranslation + burnInYOffset); } }