Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 392d8686 authored by Beverly's avatar Beverly
Browse files

Add a bold-text version for the keyguard clock

Test: manual (Settings > A11y > Text and display > Bold text)
Test: atest AnimatableClockControllerTest
Fixes: 201034059
Change-Id: I656afac3ee22e79a0bf218803699ab5182c34c66
parent 3abdb017
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Main;
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.util.ViewController;

@@ -49,7 +48,6 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
    private final StatusBarStateController mStatusBarStateController;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final KeyguardBypassController mBypassController;
    private final BatteryController mBatteryController;
    private final int mDozingColor = Color.WHITE;
    private int mLockScreenColor;
@@ -71,14 +69,12 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
            BroadcastDispatcher broadcastDispatcher,
            BatteryController batteryController,
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            KeyguardBypassController bypassController,
            @Main Resources resources
    ) {
        super(view);
        mStatusBarStateController = statusBarStateController;
        mBroadcastDispatcher = broadcastDispatcher;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mBypassController = bypassController;
        mBatteryController = batteryController;

        mBurmeseNumerals = mBurmeseNf.format(FORMAT_NUMBER);
+29 −21
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.util.AttributeSet;
import android.widget.TextView;

import com.android.systemui.R;
import com.android.systemui.statusbar.phone.KeyguardBypassController;

import java.util.Calendar;
import java.util.Locale;
@@ -111,6 +110,28 @@ public class AnimatableClockView extends TextView {
        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() {
        mTime.setTimeInMillis(System.currentTimeMillis());
        setText(DateFormat.format(mFormat, mTime));
@@ -162,7 +183,7 @@ public class AnimatableClockView extends TextView {
        }

        setTextStyle(
                mDozingWeight,
                getDozingWeight(),
                -1 /* text size, no update */,
                mLockScreenColor,
                false /* animate */,
@@ -171,7 +192,7 @@ public class AnimatableClockView extends TextView {
                null /* onAnimationEnd */);

        setTextStyle(
                mLockScreenWeight,
                getLockScreenWeight(),
                -1 /* text size, no update */,
                mLockScreenColor,
                true, /* animate */
@@ -180,35 +201,22 @@ public class AnimatableClockView extends TextView {
                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) {
        if (mTextAnimator == null || mTextAnimator.isRunning()) {
            // Skip charge animation if dozing animation is already playing.
            return;
        }
        Runnable startAnimPhase2 = () -> setTextStyle(
                dozeStateGetter.isDozing() ? mDozingWeight : mLockScreenWeight/* weight */,
                dozeStateGetter.isDozing() ? getDozingWeight() : getLockScreenWeight() /* weight */,
                -1,
                null,
                true /* animate */,
                CHARGE_ANIM_DURATION_PHASE_1,
                0 /* delay */,
                null /* onAnimationEnd */);
        setTextStyle(dozeStateGetter.isDozing() ? mLockScreenWeight : mDozingWeight/* weight */,
        setTextStyle(dozeStateGetter.isDozing()
                        ? getLockScreenWeight()
                        : getDozingWeight()/* weight */,
                -1,
                null,
                true /* animate */,
@@ -218,7 +226,7 @@ public class AnimatableClockView extends TextView {
    }

    void animateDoze(boolean isDozing, boolean animate) {
        setTextStyle(isDozing ? mDozingWeight : mLockScreenWeight /* weight */,
        setTextStyle(isDozing ? getDozingWeight() : getLockScreenWeight() /* weight */,
                -1,
                isDozing ? mDozingColor : mLockScreenColor,
                animate,
+0 −2
Original line number Diff line number Diff line
@@ -167,7 +167,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
                        mBroadcastDispatcher,
                        mBatteryController,
                        mKeyguardUpdateMonitor,
                        mBypassController,
                        mResources);
        mClockViewController.init();

@@ -178,7 +177,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
                        mBroadcastDispatcher,
                        mBatteryController,
                        mKeyguardUpdateMonitor,
                        mBypassController,
                        mResources);
        mLargeClockViewController.init();
    }
+0 −4
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import com.android.settingslib.Utils;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.BatteryController;

import org.junit.After;
@@ -69,8 +68,6 @@ public class AnimatableClockControllerTest extends SysuiTestCase {
    @Mock
    private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    @Mock
    private KeyguardBypassController mBypassController;
    @Mock
    private Resources mResources;

    private MockitoSession mStaticMockSession;
@@ -99,7 +96,6 @@ public class AnimatableClockControllerTest extends SysuiTestCase {
                mBroadcastDispatcher,
                mBatteryController,
                mKeyguardUpdateMonitor,
                mBypassController,
                mResources
        );
        mAnimatableClockController.init();