Fixes biometric dialogs in dark mode.

This change removes the hardcoded colors from the biometric dialog
layout, and recreates the dialogs in response to a configuration change.

Change-Id: I20459781570a6d223464b6cbf8ca516994710b3e
Fixes: 117504007
Test: manually
This commit is contained in:
Gus Prevas
2018-10-30 10:29:34 -04:00
parent 8c12dcd11a
commit a7df7b2f86
7 changed files with 63 additions and 45 deletions

View File

@@ -17,10 +17,10 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/biometric_dialog_bg_color" />
<solid android:color="?android:attr/colorBackgroundFloating" />
<corners android:radius="1dp"
android:topLeftRadius="@dimen/biometric_dialog_corner_size"
android:topRightRadius="@dimen/biometric_dialog_corner_size"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"/>
</shape>
</shape>

View File

@@ -36,7 +36,7 @@
android:name="_R_G_L_2_G_D_0_P_0"
android:pathData=" M-25.36 -24.41 C-25.93,-24.31 -26.49,-24.27 -26.81,-24.27 C-28.11,-24.27 -29.35,-24.62 -30.43,-25.4 C-32.11,-26.6 -33.2,-28.57 -33.2,-30.79 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -47,7 +47,7 @@
android:name="_R_G_L_2_G_D_1_P_0"
android:pathData=" M-36.14 -21.78 C-37.15,-22.98 -37.72,-23.7 -38.51,-25.29 C-39.33,-26.94 -39.82,-28.78 -39.82,-30.77 C-39.82,-34.43 -36.85,-37.4 -33.19,-37.4 C-29.52,-37.4 -26.55,-34.43 -26.55,-30.77 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -58,7 +58,7 @@
android:name="_R_G_L_2_G_D_2_P_0"
android:pathData=" M-42.19 -25.68 C-42.95,-27.82 -43.09,-29.54 -43.09,-30.8 C-43.09,-32.27 -42.84,-33.65 -42.27,-34.9 C-40.71,-38.35 -37.24,-40.75 -33.2,-40.75 C-27.71,-40.75 -23.26,-36.3 -23.26,-30.8 C-23.26,-28.97 -24.74,-27.49 -26.57,-27.49 C-28.4,-27.49 -29.89,-28.97 -29.89,-30.8 C-29.89,-32.64 -31.37,-34.12 -33.2,-34.12 C-35.04,-34.12 -36.52,-32.64 -36.52,-30.8 C-36.52,-28.23 -35.53,-25.92 -33.92,-24.22 C-32.69,-22.93 -31.48,-22.12 -29.44,-21.53 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -69,7 +69,7 @@
android:name="_R_G_L_2_G_D_3_P_0"
android:pathData=" M-44.06 -38.17 C-42.87,-39.94 -41.39,-41.41 -39.51,-42.44 C-37.62,-43.47 -35.46,-44.05 -33.16,-44.05 C-30.88,-44.05 -28.72,-43.47 -26.85,-42.45 C-24.97,-41.43 -23.48,-39.97 -22.29,-38.21 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -80,7 +80,7 @@
android:name="_R_G_L_2_G_D_4_P_0"
android:pathData=" M-25.72 -45.45 C-27.99,-46.76 -30.43,-47.52 -33.28,-47.52 C-36.13,-47.52 -38.51,-46.74 -40.62,-45.45 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -97,7 +97,7 @@
android:name="_R_G_L_1_G_D_0_P_0"
android:pathData=" M0 -9 C4.97,-9 9,-4.97 9,0 C9,4.97 4.97,9 0,9 C-4.97,9 -9,4.97 -9,0 C-9,-4.97 -4.97,-9 0,-9c "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_error_color"
android:strokeColor="?android:attr/colorError"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2"
@@ -118,7 +118,7 @@
<path
android:name="_R_G_L_0_G_D_0_P_0"
android:fillAlpha="1"
android:fillColor="@color/biometric_dialog_error_color"
android:fillColor="?android:attr/colorError"
android:fillType="nonZero"
android:pathData=" M1.1 3.94 C1.1,4.55 0.61,5.04 0,5.04 C-0.61,5.04 -1.1,4.55 -1.1,3.94 C-1.1,3.33 -0.61,2.84 0,2.84 C0.61,2.84 1.1,3.33 1.1,3.94c " />
</group>
@@ -131,7 +131,7 @@
<path
android:name="_R_G_L_0_G_D_0_P_1"
android:fillAlpha="1"
android:fillColor="@color/biometric_dialog_error_color"
android:fillColor="?android:attr/colorError"
android:fillType="nonZero"
android:pathData=" M1 -4.06 C1,-4.06 1,-0.06 1,-0.06 C1,0.49 0.55,0.94 0,0.94 C-0.55,0.94 -1,0.49 -1,-0.06 C-1,-0.06 -1,-4.06 -1,-4.06 C-1,-4.61 -0.55,-5.06 0,-5.06 C0.55,-5.06 1,-4.61 1,-4.06c " />
</group>
@@ -522,4 +522,4 @@
</set>
</aapt:attr>
</target>
</animated-vector>
</animated-vector>

View File

@@ -36,7 +36,7 @@
android:name="_R_G_L_3_G_D_0_P_0"
android:pathData=" M-25.36 -24.41 C-25.93,-24.31 -26.49,-24.27 -26.81,-24.27 C-28.11,-24.27 -29.35,-24.62 -30.43,-25.4 C-32.11,-26.6 -33.2,-28.57 -33.2,-30.79 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -47,7 +47,7 @@
android:name="_R_G_L_3_G_D_1_P_0"
android:pathData=" M-36.14 -21.78 C-37.15,-22.98 -37.72,-23.7 -38.51,-25.29 C-39.33,-26.94 -39.82,-28.78 -39.82,-30.77 C-39.82,-34.43 -36.85,-37.4 -33.19,-37.4 C-29.52,-37.4 -26.55,-34.43 -26.55,-30.77 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -58,7 +58,7 @@
android:name="_R_G_L_3_G_D_2_P_0"
android:pathData=" M-42.19 -25.68 C-42.95,-27.82 -43.09,-29.54 -43.09,-30.8 C-43.09,-32.27 -42.84,-33.65 -42.27,-34.9 C-40.71,-38.35 -37.24,-40.75 -33.2,-40.75 C-27.71,-40.75 -23.26,-36.3 -23.26,-30.8 C-23.26,-28.97 -24.74,-27.49 -26.57,-27.49 C-28.4,-27.49 -29.89,-28.97 -29.89,-30.8 C-29.89,-32.64 -31.37,-34.12 -33.2,-34.12 C-35.04,-34.12 -36.52,-32.64 -36.52,-30.8 C-36.52,-28.23 -35.53,-25.92 -33.92,-24.22 C-32.69,-22.93 -31.48,-22.12 -29.44,-21.53 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -69,7 +69,7 @@
android:name="_R_G_L_3_G_D_3_P_0"
android:pathData=" M-44.06 -38.17 C-42.87,-39.94 -41.39,-41.41 -39.51,-42.44 C-37.62,-43.47 -35.46,-44.05 -33.16,-44.05 C-30.88,-44.05 -28.72,-43.47 -26.85,-42.45 C-24.97,-41.43 -23.48,-39.97 -22.29,-38.21 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -80,7 +80,7 @@
android:name="_R_G_L_3_G_D_4_P_0"
android:pathData=" M-25.72 -45.45 C-27.99,-46.76 -30.43,-47.52 -33.28,-47.52 C-36.13,-47.52 -38.51,-46.74 -40.62,-45.45 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_biometric_color"
android:strokeColor="?android:attr/colorAccent"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -101,7 +101,7 @@
android:name="_R_G_L_2_G_D_0_P_0"
android:pathData=" M-25.36 -24.41 C-25.93,-24.31 -26.49,-24.27 -26.81,-24.27 C-28.11,-24.27 -29.35,-24.62 -30.43,-25.4 C-32.11,-26.6 -33.2,-28.57 -33.2,-30.79 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_error_color"
android:strokeColor="?android:attr/colorError"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -112,7 +112,7 @@
android:name="_R_G_L_2_G_D_1_P_0"
android:pathData=" M-36.14 -21.78 C-37.15,-22.98 -37.72,-23.7 -38.51,-25.29 C-39.33,-26.94 -39.82,-28.78 -39.82,-30.77 C-39.82,-34.43 -36.85,-37.4 -33.19,-37.4 C-29.52,-37.4 -26.55,-34.43 -26.55,-30.77 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_error_color"
android:strokeColor="?android:attr/colorError"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -123,7 +123,7 @@
android:name="_R_G_L_2_G_D_2_P_0"
android:pathData=" M-42.19 -25.68 C-42.95,-27.82 -43.09,-29.54 -43.09,-30.8 C-43.09,-32.27 -42.84,-33.65 -42.27,-34.9 C-40.71,-38.35 -37.24,-40.75 -33.2,-40.75 C-27.71,-40.75 -23.26,-36.3 -23.26,-30.8 C-23.26,-28.97 -24.74,-27.49 -26.57,-27.49 C-28.4,-27.49 -29.89,-28.97 -29.89,-30.8 C-29.89,-32.64 -31.37,-34.12 -33.2,-34.12 C-35.04,-34.12 -36.52,-32.64 -36.52,-30.8 C-36.52,-28.23 -35.53,-25.92 -33.92,-24.22 C-32.69,-22.93 -31.48,-22.12 -29.44,-21.53 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_error_color"
android:strokeColor="?android:attr/colorError"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -134,7 +134,7 @@
android:name="_R_G_L_2_G_D_3_P_0"
android:pathData=" M-44.06 -38.17 C-42.87,-39.94 -41.39,-41.41 -39.51,-42.44 C-37.62,-43.47 -35.46,-44.05 -33.16,-44.05 C-30.88,-44.05 -28.72,-43.47 -26.85,-42.45 C-24.97,-41.43 -23.48,-39.97 -22.29,-38.21 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_error_color"
android:strokeColor="?android:attr/colorError"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -145,7 +145,7 @@
android:name="_R_G_L_2_G_D_4_P_0"
android:pathData=" M-25.72 -45.45 C-27.99,-46.76 -30.43,-47.52 -33.28,-47.52 C-36.13,-47.52 -38.51,-46.74 -40.62,-45.45 "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_error_color"
android:strokeColor="?android:attr/colorError"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="1.45"
@@ -162,7 +162,7 @@
android:name="_R_G_L_1_G_D_0_P_0"
android:pathData=" M0 -9 C4.97,-9 9,-4.97 9,0 C9,4.97 4.97,9 0,9 C-4.97,9 -9,4.97 -9,0 C-9,-4.97 -4.97,-9 0,-9c "
android:strokeAlpha="1"
android:strokeColor="@color/biometric_dialog_error_color"
android:strokeColor="?android:attr/colorError"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2"
@@ -183,7 +183,7 @@
<path
android:name="_R_G_L_0_G_D_0_P_0"
android:fillAlpha="1"
android:fillColor="@color/biometric_dialog_error_color"
android:fillColor="?android:attr/colorError"
android:fillType="nonZero"
android:pathData=" M1.1 3.94 C1.1,4.55 0.61,5.04 0,5.04 C-0.61,5.04 -1.1,4.55 -1.1,3.94 C-1.1,3.33 -0.61,2.84 0,2.84 C0.61,2.84 1.1,3.33 1.1,3.94c " />
</group>
@@ -196,7 +196,7 @@
<path
android:name="_R_G_L_0_G_D_0_P_1"
android:fillAlpha="1"
android:fillColor="@color/biometric_dialog_error_color"
android:fillColor="?android:attr/colorError"
android:fillType="nonZero"
android:pathData=" M1 -4.06 C1,-4.06 1,-0.06 1,-0.06 C1,0.49 0.55,0.94 0,0.94 C-0.55,0.94 -1,0.49 -1,-0.06 C-1,-0.06 -1,-4.06 -1,-4.06 C-1,-4.61 -0.55,-5.06 0,-5.06 C0.55,-5.06 1,-4.61 1,-4.06c " />
</group>
@@ -851,4 +851,4 @@
</set>
</aapt:attr>
</target>
</animated-vector>
</animated-vector>

View File

@@ -63,7 +63,7 @@
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:textColor="@color/biometric_dialog_text_dark_color"/>
android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/subtitle"
@@ -78,7 +78,7 @@
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:textColor="@color/biometric_dialog_text_dark_color"/>
android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/description"
@@ -90,7 +90,7 @@
android:paddingTop="8dp"
android:textSize="16sp"
android:maxLines="4"
android:textColor="@color/biometric_dialog_text_dark_color"/>
android:textColor="?android:attr/textColorPrimary"/>
<ImageView
android:id="@+id/biometric_icon"
@@ -112,7 +112,7 @@
android:gravity="center_horizontal"
android:accessibilityLiveRegion="polite"
android:contentDescription="@string/accessibility_biometric_dialog_help_area"
android:textColor="@color/biometric_dialog_text_light_color"/>
android:textColor="?android:attr/textColorSecondary"/>
<LinearLayout
android:layout_width="match_parent"
@@ -164,4 +164,4 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -129,12 +129,7 @@
<color name="smart_reply_button_stroke">#ffdadce0</color>
<!-- Biometric dialog colors -->
<color name="biometric_dialog_bg_color">#ffffffff</color> <!-- 100% white -->
<color name="biometric_dialog_text_dark_color">#dd000000</color> <!-- 87% black -->
<color name="biometric_dialog_text_light_color">#89000000</color> <!-- 54% black -->
<color name="biometric_dialog_dim_color">#80000000</color> <!-- 50% black -->
<color name="biometric_dialog_error_color">#fff44336</color> <!-- red -->
<color name="biometric_dialog_biometric_color">#ff008577</color> <!-- teal -->
<!-- Logout button -->
<color name="logout_button_bg_color">#ccffffff</color>

View File

@@ -18,6 +18,7 @@ package com.android.systemui.biometrics;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricPrompt;
import android.hardware.biometrics.IBiometricPromptReceiver;
@@ -53,6 +54,7 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
private static final int MSG_BUTTON_POSITIVE = 8;
private Map<Integer, BiometricDialogView> mDialogs; // BiometricAuthenticator type, view
private SomeArgs mCurrentDialogArgs;
private BiometricDialogView mCurrentDialog;
private WindowManager mWindowManager;
private IBiometricPromptReceiver mReceiver;
@@ -116,6 +118,15 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
@Override
public void start() {
createDialogs();
if (!mDialogs.isEmpty()) {
getComponent(CommandQueue.class).addCallbacks(this);
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
}
private void createDialogs() {
final PackageManager pm = mContext.getPackageManager();
mDialogs = new HashMap<>();
if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
@@ -125,11 +136,6 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
mDialogs.put(BiometricAuthenticator.TYPE_FINGERPRINT,
new FingerprintDialogView(mContext, mCallback));
}
if (!mDialogs.isEmpty()) {
getComponent(CommandQueue.class).addCallbacks(this);
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
}
@Override
@@ -173,6 +179,7 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
}
private void handleShowDialog(SomeArgs args) {
mCurrentDialogArgs = args;
final int type = args.argi1;
mCurrentDialog = mDialogs.get(type);
@@ -268,4 +275,18 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
private void handleUserCanceled() {
handleHideDialog(true /* userCanceled */);
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
if (mDialogShowing) {
mCurrentDialog.forceRemove();
}
createDialogs();
if (mDialogShowing) {
mCurrentDialog = mDialogs.get(mCurrentDialogArgs.argi1);
mCurrentDialog.forceRemove(); // Prevents intro animation when reattaching.
mDialogShowing = false;
handleShowDialog(mCurrentDialogArgs);
}
}
}

View File

@@ -17,7 +17,7 @@
package com.android.systemui.biometrics;
import android.content.Context;
import android.graphics.Color;
import android.content.res.TypedArray;
import android.graphics.PixelFormat;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Binder;
@@ -122,10 +122,12 @@ public abstract class BiometricDialogView extends LinearLayout {
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
mAnimationTranslationOffset = getResources()
.getDimension(R.dimen.biometric_dialog_animation_translation_offset);
mErrorColor = Color.parseColor(
getResources().getString(R.color.biometric_dialog_error_color));
mTextColor = Color.parseColor(
getResources().getString(R.color.biometric_dialog_text_light_color));
TypedArray array = getContext().obtainStyledAttributes(
new int[]{android.R.attr.colorError, android.R.attr.textColorSecondary});
mErrorColor = array.getColor(0, 0);
mTextColor = array.getColor(1, 0);
array.recycle();
DisplayMetrics metrics = new DisplayMetrics();
mWindowManager.getDefaultDisplay().getMetrics(metrics);