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

Commit 7b0f1752 authored by Jane Ha's avatar Jane Ha
Browse files

Add background check for password entry in Keyguard

Bug: 326262444
Test: manual
Change-Id: I8c7149decfe2ba6b042d7a9c53ba2db60da5d4ba
Flag: NA
parent 5190facc
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.keyguard;
import static com.android.systemui.Flags.pinInputFieldStyledFocusState;
import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.util.TypedValue;
@@ -150,18 +151,22 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB
    }

    private void setKeyboardBasedFocusOutline(boolean isAnyKeyboardConnected) {
        StateListDrawable background = (StateListDrawable) mPasswordEntry.getBackground();
        GradientDrawable stateDrawable = (GradientDrawable) background.getStateDrawable(0);
        Drawable background = mPasswordEntry.getBackground();
        if (!(background instanceof StateListDrawable)) return;
        Drawable stateDrawable = ((StateListDrawable) background).getStateDrawable(0);
        if (!(stateDrawable instanceof GradientDrawable gradientDrawable)) return;

        int color = getResources().getColor(R.color.bouncer_password_focus_color);
        if (!isAnyKeyboardConnected) {
            stateDrawable.setStroke(0, color);
            gradientDrawable.setStroke(0, color);
        } else {
            int strokeWidthInDP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3,
                    getResources().getDisplayMetrics());
            stateDrawable.setStroke(strokeWidthInDP, color);
            gradientDrawable.setStroke(strokeWidthInDP, color);
        }
    }


    @Override
    protected void onViewDetached() {
        super.onViewDetached();