summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEl Dainosor <eldainosor@gmail.com>2020-04-17 23:35:23 +0000
committeralk3pInjection <webmaster@raspii.tech>2021-09-27 21:17:05 +0800
commitdeaad8c59c4e9a6cd8d88c8d294b4f79be44e7dd (patch)
treef5cff45f32007a1f6f690689e5530c635b77ef46
parentf4696843308f59cc374bed6a15f924514e0d56da (diff)
[crdroid][11.0] TypeClock: Properly calculate the height
As it was using the small clock all this time along. Let's get code for smallclock and add the dynamic height of the view Change-Id: I71889678b7a11245c8522a39c0cfd55d02d36d29
-rw-r--r--packages/SystemUI/src/com/android/keyguard/clock/TypeClockController.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/TypeClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/TypeClockController.java
index 890ba1da0911..fbcf1e190d99 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/TypeClockController.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/TypeClockController.java
@@ -21,6 +21,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Paint.Style;
+import android.util.MathUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -54,7 +55,11 @@ public class TypeClockController implements ClockPlugin {
/**
* Computes preferred position of clock.
*/
- private final SmallClockPosition mClockPosition;
+ private float mDarkAmount;
+ private final int mStatusBarHeight;
+ private final int mKeyguardLockPadding;
+ private final int mKeyguardLockHeight;
+ private final int mBurnInOffsetY;
/**
* Renders preview from clock view.
@@ -89,7 +94,10 @@ public class TypeClockController implements ClockPlugin {
mResources = res;
mLayoutInflater = inflater;
mColorExtractor = colorExtractor;
- mClockPosition = new SmallClockPosition(res);
+ mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
+ mKeyguardLockPadding = res.getDimensionPixelSize(R.dimen.keyguard_lock_padding);
+ mKeyguardLockHeight = res.getDimensionPixelSize(R.dimen.keyguard_lock_height);
+ mBurnInOffsetY = res.getDimensionPixelSize(R.dimen.burn_in_prevention_offset_y);
}
private void createViews() {
@@ -162,7 +170,12 @@ public class TypeClockController implements ClockPlugin {
@Override
public int getPreferredY(int totalHeight) {
- return mClockPosition.getPreferredY();
+ // On AOD, clock needs to appear below the status bar with enough room for pixel shifting
+ int aodY = mStatusBarHeight + mKeyguardLockHeight + 2 * mKeyguardLockPadding
+ + mBurnInOffsetY + mTypeClock.getHeight() + (mTypeClock.getHeight() / 2);
+ // On lock screen, clock needs to appear below the lock icon
+ int lockY = mStatusBarHeight + mKeyguardLockHeight + 2 * mKeyguardLockPadding + (mTypeClock.getHeight() / 2);
+ return (int) MathUtils.lerp(lockY, aodY, mDarkAmount);
}
@Override
@@ -192,10 +205,10 @@ public class TypeClockController implements ClockPlugin {
@Override
public void setDarkAmount(float darkAmount) {
+ mDarkAmount = darkAmount;
if (mDarkController != null) {
mDarkController.setDarkAmount(darkAmount);
}
- mClockPosition.setDarkAmount(darkAmount);
}
@Override