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

Commit dfae7133 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Show transient error strings in white" into sc-dev

parents a52ca6db ebfcc39a
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.text.TextUtils;

import androidx.annotation.IntDef;

import com.android.settingslib.Utils;
import com.android.systemui.Dumpable;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -164,17 +163,14 @@ public class KeyguardIndicationRotateTextViewController extends
     * Transient messages:
     * - show immediately
     * - 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
        updateIndication(INDICATION_TYPE_TRANSIENT,
                new KeyguardIndication.Builder()
                        .setMessage(newIndication)
                        .setTextColor(isError
                                ? Utils.getColorError(getContext())
                                : mInitialTextColorState)
                        .setMinVisibilityMillis(2000L + inAnimationDuration)
                        .setTextColor(mInitialTextColorState)
                        .build(),
                /* showImmediately */true);
    }
+3 −7
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.ViewClippingUtil;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.settingslib.Utils;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
@@ -130,7 +129,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal
    private String mRestingIndication;
    private String mAlignmentIndication;
    private CharSequence mTransientIndication;
    private boolean mTransientTextIsError;
    protected ColorStateList mInitialTextColorState;
    private boolean mVisible;
    private boolean mHideTransientMessageOnScreenOff;
@@ -382,8 +380,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal

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

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

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

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

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

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

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

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

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

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