Merge "Add a bold-text version for the keyguard clock" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-11-11 21:16:58 +00:00
committed by Android (Google) Code Review
4 changed files with 29 additions and 31 deletions

View File

@@ -31,7 +31,6 @@ import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.util.ViewController; import com.android.systemui.util.ViewController;
@@ -49,7 +48,6 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
private final StatusBarStateController mStatusBarStateController; private final StatusBarStateController mStatusBarStateController;
private final BroadcastDispatcher mBroadcastDispatcher; private final BroadcastDispatcher mBroadcastDispatcher;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final KeyguardBypassController mBypassController;
private final BatteryController mBatteryController; private final BatteryController mBatteryController;
private final int mDozingColor = Color.WHITE; private final int mDozingColor = Color.WHITE;
private int mLockScreenColor; private int mLockScreenColor;
@@ -71,14 +69,12 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
BroadcastDispatcher broadcastDispatcher, BroadcastDispatcher broadcastDispatcher,
BatteryController batteryController, BatteryController batteryController,
KeyguardUpdateMonitor keyguardUpdateMonitor, KeyguardUpdateMonitor keyguardUpdateMonitor,
KeyguardBypassController bypassController,
@Main Resources resources @Main Resources resources
) { ) {
super(view); super(view);
mStatusBarStateController = statusBarStateController; mStatusBarStateController = statusBarStateController;
mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher;
mKeyguardUpdateMonitor = keyguardUpdateMonitor; mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mBypassController = bypassController;
mBatteryController = batteryController; mBatteryController = batteryController;
mBurmeseNumerals = mBurmeseNf.format(FORMAT_NUMBER); mBurmeseNumerals = mBurmeseNf.format(FORMAT_NUMBER);

View File

@@ -27,7 +27,6 @@ import android.util.AttributeSet;
import android.widget.TextView; import android.widget.TextView;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import java.util.Calendar; import java.util.Calendar;
import java.util.Locale; import java.util.Locale;
@@ -111,6 +110,28 @@ public class AnimatableClockView extends TextView {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
} }
int getDozingWeight() {
if (useBoldedVersion()) {
return mDozingWeight + 100;
}
return mDozingWeight;
}
int getLockScreenWeight() {
if (useBoldedVersion()) {
return mLockScreenWeight + 100;
}
return mLockScreenWeight;
}
/**
* Whether to use a bolded version based on the user specified fontWeightAdjustment.
*/
boolean useBoldedVersion() {
// "Bold text" fontWeightAdjustment is 300.
return getResources().getConfiguration().fontWeightAdjustment > 100;
}
void refreshTime() { void refreshTime() {
mTime.setTimeInMillis(System.currentTimeMillis()); mTime.setTimeInMillis(System.currentTimeMillis());
setText(DateFormat.format(mFormat, mTime)); setText(DateFormat.format(mFormat, mTime));
@@ -162,7 +183,7 @@ public class AnimatableClockView extends TextView {
} }
setTextStyle( setTextStyle(
mDozingWeight, getDozingWeight(),
-1 /* text size, no update */, -1 /* text size, no update */,
mLockScreenColor, mLockScreenColor,
false /* animate */, false /* animate */,
@@ -171,7 +192,7 @@ public class AnimatableClockView extends TextView {
null /* onAnimationEnd */); null /* onAnimationEnd */);
setTextStyle( setTextStyle(
mLockScreenWeight, getLockScreenWeight(),
-1 /* text size, no update */, -1 /* text size, no update */,
mLockScreenColor, mLockScreenColor,
true, /* animate */ true, /* animate */
@@ -180,35 +201,22 @@ public class AnimatableClockView extends TextView {
null /* onAnimationEnd */); null /* onAnimationEnd */);
} }
void animateDisappear() {
if (mTextAnimator == null) {
return;
}
setTextStyle(
0 /* weight */,
-1 /* text size, no update */,
null /* color, no update */,
true /* animate */,
KeyguardBypassController.BYPASS_FADE_DURATION /* duration */,
0 /* delay */,
null /* onAnimationEnd */);
}
void animateCharge(DozeStateGetter dozeStateGetter) { void animateCharge(DozeStateGetter dozeStateGetter) {
if (mTextAnimator == null || mTextAnimator.isRunning()) { if (mTextAnimator == null || mTextAnimator.isRunning()) {
// Skip charge animation if dozing animation is already playing. // Skip charge animation if dozing animation is already playing.
return; return;
} }
Runnable startAnimPhase2 = () -> setTextStyle( Runnable startAnimPhase2 = () -> setTextStyle(
dozeStateGetter.isDozing() ? mDozingWeight : mLockScreenWeight/* weight */, dozeStateGetter.isDozing() ? getDozingWeight() : getLockScreenWeight() /* weight */,
-1, -1,
null, null,
true /* animate */, true /* animate */,
CHARGE_ANIM_DURATION_PHASE_1, CHARGE_ANIM_DURATION_PHASE_1,
0 /* delay */, 0 /* delay */,
null /* onAnimationEnd */); null /* onAnimationEnd */);
setTextStyle(dozeStateGetter.isDozing() ? mLockScreenWeight : mDozingWeight/* weight */, setTextStyle(dozeStateGetter.isDozing()
? getLockScreenWeight()
: getDozingWeight()/* weight */,
-1, -1,
null, null,
true /* animate */, true /* animate */,
@@ -218,7 +226,7 @@ public class AnimatableClockView extends TextView {
} }
void animateDoze(boolean isDozing, boolean animate) { void animateDoze(boolean isDozing, boolean animate) {
setTextStyle(isDozing ? mDozingWeight : mLockScreenWeight /* weight */, setTextStyle(isDozing ? getDozingWeight() : getLockScreenWeight() /* weight */,
-1, -1,
isDozing ? mDozingColor : mLockScreenColor, isDozing ? mDozingColor : mLockScreenColor,
animate, animate,

View File

@@ -167,7 +167,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mBroadcastDispatcher, mBroadcastDispatcher,
mBatteryController, mBatteryController,
mKeyguardUpdateMonitor, mKeyguardUpdateMonitor,
mBypassController,
mResources); mResources);
mClockViewController.init(); mClockViewController.init();
@@ -178,7 +177,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mBroadcastDispatcher, mBroadcastDispatcher,
mBatteryController, mBatteryController,
mKeyguardUpdateMonitor, mKeyguardUpdateMonitor,
mBypassController,
mResources); mResources);
mLargeClockViewController.init(); mLargeClockViewController.init();
} }

View File

@@ -40,7 +40,6 @@ import com.android.settingslib.Utils;
import com.android.systemui.SysuiTestCase; import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryController;
import org.junit.After; import org.junit.After;
@@ -69,8 +68,6 @@ public class AnimatableClockControllerTest extends SysuiTestCase {
@Mock @Mock
private KeyguardUpdateMonitor mKeyguardUpdateMonitor; private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock @Mock
private KeyguardBypassController mBypassController;
@Mock
private Resources mResources; private Resources mResources;
private MockitoSession mStaticMockSession; private MockitoSession mStaticMockSession;
@@ -99,7 +96,6 @@ public class AnimatableClockControllerTest extends SysuiTestCase {
mBroadcastDispatcher, mBroadcastDispatcher,
mBatteryController, mBatteryController,
mKeyguardUpdateMonitor, mKeyguardUpdateMonitor,
mBypassController,
mResources mResources
); );
mAnimatableClockController.init(); mAnimatableClockController.init();