From 178ace506be66997e30e10cc870e8462e0bfc43b Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Fri, 30 Mar 2018 12:36:32 -0700 Subject: [PATCH] Fix fingerprint dialog icon color The Keyguard resource has 50% opacity on the "ridges" assets but 100% on the "error" assets, making it very difficult to fix/animate correctly in both Keyguard and FingerprintDialogView. This change decouples the FingerprintDialogView from the Keyguard resource. Fixes: 75290621 Test: manual test with FingerprintDialog APK visually inspect colors/animations Change-Id: Ie04c706e24e129f01b6ddb500c689f108c41ae3e --- .../fingerprint_dialog_error_to_fp.xml | 525 +++++++++++ .../fingerprint_dialog_fp_to_error.xml | 854 ++++++++++++++++++ packages/SystemUI/res/values/colors.xml | 4 +- .../fingerprint/FingerprintDialogView.java | 46 +- 4 files changed, 1409 insertions(+), 20 deletions(-) create mode 100644 packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml create mode 100644 packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml diff --git a/packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml b/packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml new file mode 100644 index 0000000000000..83c1949b681ca --- /dev/null +++ b/packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml b/packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml new file mode 100644 index 0000000000000..f682f87003dc8 --- /dev/null +++ b/packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml @@ -0,0 +1,854 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 906ca4a536caa..3c1f995f3de82 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -158,8 +158,8 @@ #dd000000 #89000000 #80000000 - #ffd93025 - #ff008577 + #fff44336 + #ff008577 #ccffffff diff --git a/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java index 95258b0129bea..3e1ac022de61e 100644 --- a/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java +++ b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java @@ -17,7 +17,6 @@ package com.android.systemui.fingerprint; import android.content.Context; -import android.content.res.Configuration; import android.graphics.Color; import android.graphics.PixelFormat; import android.graphics.PorterDuff; @@ -44,7 +43,6 @@ import android.widget.TextView; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.util.leak.RotationUtils; /** * This class loads the view for the system-provided dialog. The view consists of: @@ -67,7 +65,7 @@ public class FingerprintDialogView extends LinearLayout { private final Interpolator mLinearOutSlowIn; private final WindowManager mWindowManager; private final float mAnimationTranslationOffset; - private final int mErrorTextColor; + private final int mErrorColor; private final int mTextColor; private final int mFingerprintColor; @@ -87,8 +85,8 @@ public class FingerprintDialogView extends LinearLayout { mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); mAnimationTranslationOffset = getResources() .getDimension(R.dimen.fingerprint_dialog_animation_translation_offset); - mErrorTextColor = Color.parseColor( - getResources().getString(R.color.fingerprint_dialog_error_message_color)); + mErrorColor = Color.parseColor( + getResources().getString(R.color.fingerprint_dialog_error_color)); mTextColor = Color.parseColor( getResources().getString(R.color.fingerprint_dialog_text_light_color)); mFingerprintColor = Color.parseColor( @@ -268,7 +266,7 @@ public class FingerprintDialogView extends LinearLayout { mHandler.removeMessages(FingerprintDialogImpl.MSG_CLEAR_MESSAGE); updateFingerprintIcon(STATE_FINGERPRINT_ERROR); mErrorText.setText(message); - mErrorText.setTextColor(mErrorTextColor); + mErrorText.setTextColor(mErrorColor); mErrorText.setContentDescription(message); mHandler.sendMessageDelayed(mHandler.obtainMessage(FingerprintDialogImpl.MSG_CLEAR_MESSAGE), BiometricDialog.HIDE_DIALOG_DELAY); @@ -285,17 +283,13 @@ public class FingerprintDialogView extends LinearLayout { } private void updateFingerprintIcon(int newState) { - Drawable icon = getAnimationResForTransition(mLastState, newState); + Drawable icon = getAnimationForTransition(mLastState, newState); if (icon == null) { Log.e(TAG, "Animation not found"); return; } - if (newState == STATE_FINGERPRINT) { - icon.setColorFilter(mFingerprintColor, PorterDuff.Mode.SRC_IN); - } - final AnimatedVectorDrawable animation = icon instanceof AnimatedVectorDrawable ? (AnimatedVectorDrawable) icon : null; @@ -303,7 +297,7 @@ public class FingerprintDialogView extends LinearLayout { final ImageView fingerprint_icon = mLayout.findViewById(R.id.fingerprint_icon); fingerprint_icon.setImageDrawable(icon); - if (animation != null) { + if (animation != null && shouldAnimateForTransition(mLastState, newState)) { animation.forceAnimationOnUI(); animation.start(); } @@ -311,17 +305,33 @@ public class FingerprintDialogView extends LinearLayout { mLastState = newState; } - private Drawable getAnimationResForTransition(int oldState, int newState) { + private boolean shouldAnimateForTransition(int oldState, int newState) { + if (oldState == STATE_NONE && newState == STATE_FINGERPRINT) { + return false; + } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_ERROR) { + return true; + } else if (oldState == STATE_FINGERPRINT_ERROR && newState == STATE_FINGERPRINT) { + return true; + } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_AUTHENTICATED) { + // TODO(b/77328470): add animation when fingerprint is authenticated + return false; + } + return false; + } + + private Drawable getAnimationForTransition(int oldState, int newState) { int iconRes; if (oldState == STATE_NONE && newState == STATE_FINGERPRINT) { - iconRes = R.drawable.lockscreen_fingerprint_draw_on_animation; + iconRes = R.drawable.fingerprint_dialog_fp_to_error; } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_ERROR) { - iconRes = R.drawable.lockscreen_fingerprint_fp_to_error_state_animation; + iconRes = R.drawable.fingerprint_dialog_fp_to_error; } else if (oldState == STATE_FINGERPRINT_ERROR && newState == STATE_FINGERPRINT) { - iconRes = R.drawable.lockscreen_fingerprint_error_state_to_fp_animation; + iconRes = R.drawable.fingerprint_dialog_error_to_fp; } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_AUTHENTICATED) { - iconRes = R.drawable.lockscreen_fingerprint_draw_off_animation; - } else { + // TODO(b/77328470): add animation when fingerprint is authenticated + iconRes = R.drawable.fingerprint_dialog_error_to_fp; + } + else { return null; } return mContext.getDrawable(iconRes);