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

Commit ebfcc39a authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Show transient error strings in white

For better visibility and consistency.

Note: dock misalignment text color is still customized
(light red)

Test: manual
Fixes: 192350893
Change-Id: Icb25eaf4302894f0d4c5f90663b49479dadbbbb4
parent 4e395b98
Loading
Loading
Loading
Loading
+2 −6
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ import android.text.TextUtils;


import androidx.annotation.IntDef;
import androidx.annotation.IntDef;


import com.android.settingslib.Utils;
import com.android.systemui.Dumpable;
import com.android.systemui.Dumpable;
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;
@@ -164,17 +163,14 @@ public class KeyguardIndicationRotateTextViewController extends
     * Transient messages:
     * Transient messages:
     * - show immediately
     * - show immediately
     * - will continue to be in the rotation of messages shown until hideTransient is called.
     * - will continue to be in the rotation of messages shown until hideTransient is called.
     * - can be presented with an "error" color if isError is true
     */
     */
    public void showTransient(CharSequence newIndication, boolean isError) {
    public void showTransient(CharSequence newIndication) {
        final long inAnimationDuration = 600L; // see KeyguardIndicationTextView.getYInDuration
        final long inAnimationDuration = 600L; // see KeyguardIndicationTextView.getYInDuration
        updateIndication(INDICATION_TYPE_TRANSIENT,
        updateIndication(INDICATION_TYPE_TRANSIENT,
                new KeyguardIndication.Builder()
                new KeyguardIndication.Builder()
                        .setMessage(newIndication)
                        .setMessage(newIndication)
                        .setTextColor(isError
                                ? Utils.getColorError(getContext())
                                : mInitialTextColorState)
                        .setMinVisibilityMillis(2000L + inAnimationDuration)
                        .setMinVisibilityMillis(2000L + inAnimationDuration)
                        .setTextColor(mInitialTextColorState)
                        .build(),
                        .build(),
                /* showImmediately */true);
                /* showImmediately */true);
    }
    }
+3 −7
Original line number Original line Diff line number Diff line
@@ -66,7 +66,6 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.ViewClippingUtil;
import com.android.internal.widget.ViewClippingUtil;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.settingslib.Utils;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.animation.Interpolators;
@@ -130,7 +129,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
    private String mRestingIndication;
    private String mRestingIndication;
    private String mAlignmentIndication;
    private String mAlignmentIndication;
    private CharSequence mTransientIndication;
    private CharSequence mTransientIndication;
    private boolean mTransientTextIsError;
    protected ColorStateList mInitialTextColorState;
    protected ColorStateList mInitialTextColorState;
    private boolean mVisible;
    private boolean mVisible;
    private boolean mHideTransientMessageOnScreenOff;
    private boolean mHideTransientMessageOnScreenOff;
@@ -382,8 +380,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal


    private void updateTransient() {
    private void updateTransient() {
        if (!TextUtils.isEmpty(mTransientIndication)) {
        if (!TextUtils.isEmpty(mTransientIndication)) {
            mRotateTextViewController.showTransient(mTransientIndication,
            mRotateTextViewController.showTransient(mTransientIndication);
                    mTransientTextIsError);
        } else {
        } else {
            mRotateTextViewController.hideTransient();
            mRotateTextViewController.hideTransient();
        }
        }
@@ -421,7 +418,8 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
                    INDICATION_TYPE_ALIGNMENT,
                    INDICATION_TYPE_ALIGNMENT,
                    new KeyguardIndication.Builder()
                    new KeyguardIndication.Builder()
                            .setMessage(mAlignmentIndication)
                            .setMessage(mAlignmentIndication)
                            .setTextColor(Utils.getColorError(mContext))
                            .setTextColor(ColorStateList.valueOf(
                                    mContext.getColor(R.color.misalignment_text_color)))
                            .build(),
                            .build(),
                    true);
                    true);
        } else {
        } else {
@@ -594,7 +592,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
            boolean isError, boolean hideOnScreenOff) {
            boolean isError, boolean hideOnScreenOff) {
        mTransientIndication = transientIndication;
        mTransientIndication = transientIndication;
        mHideTransientMessageOnScreenOff = hideOnScreenOff && transientIndication != null;
        mHideTransientMessageOnScreenOff = hideOnScreenOff && transientIndication != null;
        mTransientTextIsError = isError;
        mHandler.removeMessages(MSG_HIDE_TRANSIENT);
        mHandler.removeMessages(MSG_HIDE_TRANSIENT);
        mHandler.removeMessages(MSG_SWIPE_UP_TO_UNLOCK);
        mHandler.removeMessages(MSG_SWIPE_UP_TO_UNLOCK);
        if (mDozing && !TextUtils.isEmpty(mTransientIndication)) {
        if (mDozing && !TextUtils.isEmpty(mTransientIndication)) {
@@ -811,7 +808,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal


    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("KeyguardIndicationController:");
        pw.println("KeyguardIndicationController:");
        pw.println("  mTransientTextIsError: " + mTransientTextIsError);
        pw.println("  mInitialTextColorState: " + mInitialTextColorState);
        pw.println("  mInitialTextColorState: " + mInitialTextColorState);
        pw.println("  mPowerPluggedInWired: " + mPowerPluggedInWired);
        pw.println("  mPowerPluggedInWired: " + mPowerPluggedInWired);
        pw.println("  mPowerPluggedIn: " + mPowerPluggedIn);
        pw.println("  mPowerPluggedIn: " + mPowerPluggedIn);
+1 −1
Original line number Original line Diff line number Diff line
@@ -211,7 +211,7 @@ public class KeyguardIndicationRotateTextViewControllerTest extends SysuiTestCas
        reset(mExecutor);
        reset(mExecutor);


        // WHEN we have a transient message
        // WHEN we have a transient message
        mController.showTransient(TEST_MESSAGE_2, false);
        mController.showTransient(TEST_MESSAGE_2);


        // THEN
        // THEN
        // - we immediately update
        // - we immediately update
+7 −8
Original line number Original line Diff line number Diff line
@@ -72,7 +72,6 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.internal.app.IBatteryStats;
import com.android.internal.app.IBatteryStats;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.settingslib.Utils;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.SysuiTestCase;
@@ -248,8 +247,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {


        verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
        verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
                mContext.getResources().getString(R.string.dock_alignment_slow_charging));
                mContext.getResources().getString(R.string.dock_alignment_slow_charging));
        assertThat(mKeyguardIndicationCaptor.getValue().getTextColor())
        assertThat(mKeyguardIndicationCaptor.getValue().getTextColor().getDefaultColor())
                .isEqualTo(Utils.getColorError(mContext));
                .isEqualTo(mContext.getColor(R.color.misalignment_text_color));
    }
    }


    @Test
    @Test
@@ -265,8 +264,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {


        verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
        verifyIndicationMessage(INDICATION_TYPE_ALIGNMENT,
                mContext.getResources().getString(R.string.dock_alignment_not_charging));
                mContext.getResources().getString(R.string.dock_alignment_not_charging));
        assertThat(mKeyguardIndicationCaptor.getValue().getTextColor())
        assertThat(mKeyguardIndicationCaptor.getValue().getTextColor().getDefaultColor())
                .isEqualTo(Utils.getColorError(mContext));
                .isEqualTo(mContext.getColor(R.color.misalignment_text_color));
    }
    }


    @Test
    @Test
@@ -680,7 +679,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
    private void verifyHideIndication(int type) {
    private void verifyHideIndication(int type) {
        if (type == INDICATION_TYPE_TRANSIENT) {
        if (type == INDICATION_TYPE_TRANSIENT) {
            verify(mRotateTextViewController).hideTransient();
            verify(mRotateTextViewController).hideTransient();
            verify(mRotateTextViewController, never()).showTransient(anyString(), anyBoolean());
            verify(mRotateTextViewController, never()).showTransient(anyString());
        } else {
        } else {
            verify(mRotateTextViewController).hideIndication(type);
            verify(mRotateTextViewController).hideIndication(type);
            verify(mRotateTextViewController, never()).updateIndication(eq(type),
            verify(mRotateTextViewController, never()).updateIndication(eq(type),
@@ -689,10 +688,10 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
    }
    }


    private void verifyTransientMessage(String message) {
    private void verifyTransientMessage(String message) {
        verify(mRotateTextViewController).showTransient(eq(message), anyBoolean());
        verify(mRotateTextViewController).showTransient(eq(message));
    }
    }


    private void verifyNoTransientMessage() {
    private void verifyNoTransientMessage() {
        verify(mRotateTextViewController, never()).showTransient(any(), anyBoolean());
        verify(mRotateTextViewController, never()).showTransient(any());
    }
    }
}
}