diff options
| author | 2018-02-06 16:30:31 -0800 | |
|---|---|---|
| committer | 2018-02-20 11:16:41 -0800 | |
| commit | d0544dcb36b4578eed4f5e1ca8374cde6a393a47 (patch) | |
| tree | 8515a0e2565c0c9bc0f687fcdca05cb64f31f853 | |
| parent | 0f888de06b3dcbb73a410578d48539ca970f4f3b (diff) | |
Tweak FingerprintDialog layout
Bug: 72475614
Test: manual, layout looks good
Change-Id: I2af6a8b8c803d2829a365b3c9a35d19de4b8020e
7 files changed, 153 insertions, 154 deletions
diff --git a/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml b/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml deleted file mode 100644 index 4a77af911441..000000000000 --- a/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2018 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License - --> - -<shape xmlns:android="http://schemas.android.com/apk/res/android"> - <solid android:color="@color/fingerprint_dialog_bg_color" /> - <corners android:radius="1dp" - android:topLeftRadius="16dp" - android:topRightRadius="16dp" - android:bottomLeftRadius="0dp" - android:bottomRightRadius="0dp"/> -</shape>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/fingerprint_dialog.xml b/packages/SystemUI/res/layout/fingerprint_dialog.xml index 161f13fd9455..f02c0ba35e77 100644 --- a/packages/SystemUI/res/layout/fingerprint_dialog.xml +++ b/packages/SystemUI/res/layout/fingerprint_dialog.xml @@ -35,131 +35,105 @@ android:layout_height="wrap_content" android:orientation="vertical" android:elevation="2dp" - android:background="@drawable/fingerprint_dialog_bg"> + android:background="@color/fingerprint_dialog_bg_color"> - <RelativeLayout + <TextView + android:id="@+id/title" + android:fontFamily="@*android:string/config_headlineFontFamilyMedium" android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="center_vertical" - android:elevation="2dp"> - - <ImageView - android:id="@+id/icon" - android:layout_width="@dimen/fingerprint_dialog_icon_size" - android:layout_height="@dimen/fingerprint_dialog_icon_size" - android:layout_marginTop="16dp" - android:layout_marginStart="16dp" - android:scaleType="centerInside" /> - - <TextView - android:id="@+id/title" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_toRightOf="@+id/icon" - android:layout_marginEnd="16dp" - android:layout_marginStart="16dp" - android:layout_marginTop="16dp" - android:textSize="20sp" - android:maxLines="1" - android:singleLine="true" - android:ellipsize="marquee" - android:marqueeRepeatLimit="marquee_forever" - android:textColor="@color/fingerprint_dialog_text_color"/> + android:layout_marginEnd="24dp" + android:layout_marginStart="24dp" + android:layout_marginTop="24dp" + android:gravity="center" + android:textSize="20sp" + android:maxLines="1" + android:singleLine="true" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:textColor="@color/fingerprint_dialog_text_dark_color"/> - <TextView - android:id="@+id/subtitle" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_toRightOf="@+id/icon" - android:layout_below="@+id/title" - android:layout_marginEnd="16dp" - android:layout_marginStart="16dp" - android:layout_marginTop="4dp" - android:textSize="12sp" - android:maxLines="2" - android:textColor="@color/fingerprint_dialog_text_color"/> - - </RelativeLayout> + <TextView + android:id="@+id/subtitle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="12dp" + android:layout_marginStart="24dp" + android:layout_marginEnd="24dp" + android:gravity="center_horizontal" + android:textSize="14sp" + android:maxLines="1" + android:singleLine="true" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:textColor="@color/fingerprint_dialog_text_light_color"/> <TextView android:id="@+id/description" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:layout_marginStart="16dp" - android:paddingTop="16dp" - android:paddingBottom="20dp" + android:layout_marginEnd="24dp" + android:layout_marginStart="24dp" + android:paddingTop="24dp" android:textSize="16sp" android:maxLines="4" - android:textColor="@color/fingerprint_dialog_text_color"/> + android:textColor="@color/fingerprint_dialog_text_dark_color"/> <ImageView android:id="@+id/fingerprint_icon" android:layout_width="@dimen/fingerprint_dialog_fp_icon_size" android:layout_height="@dimen/fingerprint_dialog_fp_icon_size" android:layout_gravity="center_horizontal" - android:scaleType="centerInside" - android:contentDescription="@string/accessibility_fingerprint_dialog_fingerprint_icon" - android:src="@drawable/fingerprint_icon"/> + android:layout_marginTop="32dp" + android:scaleType="fitXY" + android:contentDescription="@string/accessibility_fingerprint_dialog_fingerprint_icon" /> <TextView android:id="@+id/error" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginEnd = "16dp" - android:layout_marginStart="16dp" + android:layout_marginEnd="24dp" + android:layout_marginStart="24dp" android:paddingTop="16dp" - android:paddingBottom="60dp" + android:paddingBottom="24dp" android:textSize="12sp" - android:visibility="invisible" android:gravity="center_horizontal" android:accessibilityLiveRegion="polite" + android:text="@string/fingerprint_dialog_touch_sensor" android:contentDescription="@string/accessibility_fingerprint_dialog_help_area" - android:textColor="@color/fingerprint_error_message_color"/> + android:textColor="@color/fingerprint_dialog_text_light_color"/> - <LinearLayout android:id="@+id/buttonPanel" + <LinearLayout android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="54dip" - android:orientation="vertical" > - <LinearLayout - style="?android:attr/buttonBarStyle" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:paddingTop="4dip" - android:paddingStart="2dip" - android:paddingEnd="2dip" - android:measureWithLargestChild="true"> - <LinearLayout android:id="@+id/leftSpacer" - android:layout_weight="0.25" - android:layout_width="0dip" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:visibility="gone" /> - <!-- Positive Button --> - <Button android:id="@+id/button1" - android:layout_width="0dip" - android:layout_gravity="start" - android:layout_weight="1" - style="?android:attr/buttonBarButtonStyle" - android:maxLines="2" - android:layout_height="wrap_content"/> - <!-- Negative Button --> - <Button android:id="@+id/button2" - android:layout_width="0dip" - android:layout_gravity="end" - android:layout_weight="1" - style="?android:attr/buttonBarButtonStyle" - android:maxLines="2" - android:layout_height="wrap_content" /> - <LinearLayout android:id="@+id/rightSpacer" - android:layout_width="0dip" - android:layout_weight="0.25" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:visibility="gone" /> - </LinearLayout> + android:layout_height="72dip" + android:paddingTop="16dp" + android:layout_gravity="center_vertical" + style="?android:attr/buttonBarStyle" + android:orientation="horizontal" + android:measureWithLargestChild="true"> + <Space android:id="@+id/leftSpacer" + android:layout_width="24dp" + android:layout_height="match_parent" + android:visibility="visible" /> + <!-- Negative Button --> + <Button android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="match_parent" + style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored" + android:layout_marginStart="-12dp" + android:gravity="start|center_vertical" + android:maxLines="2" /> + <!-- Positive Button --> + <Button android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="match_parent" + style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored" + android:layout_marginEnd="12dp" + android:maxLines="2" /> + <Space android:id="@+id/rightSpacer" + android:layout_width="24dip" + android:layout_height="match_parent" + android:visibility="gone" /> </LinearLayout> </LinearLayout> diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index be8e990fb075..125c8ec8190b 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -162,9 +162,11 @@ <!-- Fingerprint dialog colors --> <color name="fingerprint_dialog_bg_color">#f4ffffff</color> <!-- 96% white --> - <color name="fingerprint_dialog_text_color">#ff424242</color> <!-- gray 800--> + <color name="fingerprint_dialog_text_dark_color">#ff212121</color> + <color name="fingerprint_dialog_text_light_color">#ff757575</color> <color name="fingerprint_dialog_dim_color">#80000000</color> <!-- 50% black --> - <color name="fingerprint_error_message_color">#ff5722</color> + <color name="fingerprint_dialog_error_message_color">#ffff5722</color> + <color name="fingerprint_dialog_fingerprint_color">#ff009688</color> <!-- Logout button --> <color name="logout_button_bg_color">#ccffffff</color> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index d17cd21b217c..1c34480f891b 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -892,7 +892,7 @@ <dimen name="smart_reply_button_padding_vertical">4dp</dimen> <dimen name="smart_reply_button_font_size">14sp</dimen> - <dimen name="fingerprint_dialog_icon_size">44dp</dimen> + <!-- Fingerprint Dialog values --> <dimen name="fingerprint_dialog_fp_icon_size">60dp</dimen> <dimen name="fingerprint_dialog_animation_translation_offset">350dp</dimen> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 8c59e75315a1..0b5b7bde380f 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -259,6 +259,8 @@ <!-- Button name for "Cancel". [CHAR LIMIT=NONE] --> <string name="cancel">Cancel</string> + <!-- Message shown when the system-provided fingerprint dialog is shown, asking for authentication --> + <string name="fingerprint_dialog_touch_sensor">Touch the fingerprint sensor</string> <!-- Content description of the fingerprint icon when the system-provided fingerprint dialog is showing, for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_fingerprint_dialog_fingerprint_icon">Fingerprint icon</string> <!-- Content description of the application icon when the system-provided fingerprint dialog is showing, for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> diff --git a/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java index 262c71ae0b1e..1d43b1d7d554 100644 --- a/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java @@ -211,7 +211,7 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call } private void handleClearMessage() { - mDialogView.clearMessage(); + mDialogView.resetMessage(); } private void handleUserCanceled() { diff --git a/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java index 9779937aed99..e828b2c097ea 100644 --- a/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java +++ b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogView.java @@ -16,17 +16,18 @@ package com.android.systemui.fingerprint; -import android.app.ActivityManager; -import android.content.ComponentName; import android.content.Context; -import android.content.pm.ActivityInfo; +import android.graphics.Color; import android.graphics.PixelFormat; +import android.graphics.PorterDuff; +import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.hardware.fingerprint.FingerprintDialog; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; +import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -41,8 +42,6 @@ import android.widget.TextView; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.shared.system.PackageManagerWrapper; /** * This class loads the view for the system-provided dialog. The view consists of: @@ -55,28 +54,39 @@ public class FingerprintDialogView extends LinearLayout { private static final int ANIMATION_DURATION = 250; // ms + private static final int STATE_NONE = 0; + private static final int STATE_FINGERPRINT = 1; + private static final int STATE_FINGERPRINT_ERROR = 2; + private static final int STATE_FINGERPRINT_AUTHENTICATED = 3; + private final IBinder mWindowToken = new Binder(); - private final ActivityManagerWrapper mActivityManagerWrapper; - private final PackageManagerWrapper mPackageManageWrapper; private final Interpolator mLinearOutSlowIn; private final Interpolator mFastOutLinearIn; private final float mAnimationTranslationOffset; + private final int mErrorTextColor; + private final int mTextColor; + private final int mFingerprintColor; private ViewGroup mLayout; private final TextView mErrorText; private Handler mHandler; private Bundle mBundle; private final LinearLayout mDialog; + private int mLastState; public FingerprintDialogView(Context context, Handler handler) { super(context); mHandler = handler; - mActivityManagerWrapper = ActivityManagerWrapper.getInstance(); - mPackageManageWrapper = PackageManagerWrapper.getInstance(); mLinearOutSlowIn = Interpolators.LINEAR_OUT_SLOW_IN; mFastOutLinearIn = Interpolators.FAST_OUT_LINEAR_IN; mAnimationTranslationOffset = getResources() .getDimension(R.dimen.fingerprint_dialog_animation_translation_offset); + mErrorTextColor = Color.parseColor( + getResources().getString(R.color.fingerprint_dialog_error_message_color)); + mTextColor = Color.parseColor( + getResources().getString(R.color.fingerprint_dialog_text_light_color)); + mFingerprintColor = Color.parseColor( + getResources().getString(R.color.fingerprint_dialog_fingerprint_color)); // Create the dialog LayoutInflater factory = LayoutInflater.from(getContext()); @@ -112,7 +122,7 @@ public class FingerprintDialogView extends LinearLayout { space.setClickable(true); space.setOnTouchListener((View view, MotionEvent event) -> { - mHandler.obtainMessage(FingerprintDialogImpl.MSG_HIDE_DIALOG, true /* userCanceled*/) + mHandler.obtainMessage(FingerprintDialogImpl.MSG_HIDE_DIALOG, true /* userCanceled */) .sendToTarget(); return true; }); @@ -137,16 +147,16 @@ public class FingerprintDialogView extends LinearLayout { final TextView subtitle = mLayout.findViewById(R.id.subtitle); final TextView description = mLayout.findViewById(R.id.description); final Button negative = mLayout.findViewById(R.id.button2); - final ImageView image = mLayout.findViewById(R.id.icon); final Button positive = mLayout.findViewById(R.id.button1); - final ImageView fingerprint_icon = mLayout.findViewById(R.id.fingerprint_icon); + + mLastState = STATE_NONE; + updateFingerprintIcon(STATE_FINGERPRINT); title.setText(mBundle.getCharSequence(FingerprintDialog.KEY_TITLE)); title.setSelected(true); subtitle.setText(mBundle.getCharSequence(FingerprintDialog.KEY_SUBTITLE)); description.setText(mBundle.getCharSequence(FingerprintDialog.KEY_DESCRIPTION)); negative.setText(mBundle.getCharSequence(FingerprintDialog.KEY_NEGATIVE_TEXT)); - setAppIcon(image); final CharSequence positiveText = mBundle.getCharSequence(FingerprintDialog.KEY_POSITIVE_TEXT); @@ -183,39 +193,75 @@ public class FingerprintDialogView extends LinearLayout { mBundle = bundle; } - protected void clearMessage() { - mErrorText.setVisibility(View.INVISIBLE); + // Clears the temporary message and shows the help message. + protected void resetMessage() { + updateFingerprintIcon(STATE_FINGERPRINT); + mErrorText.setText(R.string.fingerprint_dialog_touch_sensor); + mErrorText.setTextColor(mTextColor); } - private void showMessage(String message) { + // Shows an error/help message + private void showTemporaryMessage(String message) { mHandler.removeMessages(FingerprintDialogImpl.MSG_CLEAR_MESSAGE); + updateFingerprintIcon(STATE_FINGERPRINT_ERROR); mErrorText.setText(message); + mErrorText.setTextColor(mErrorTextColor); mErrorText.setContentDescription(message); - mErrorText.setVisibility(View.VISIBLE); mHandler.sendMessageDelayed(mHandler.obtainMessage(FingerprintDialogImpl.MSG_CLEAR_MESSAGE), FingerprintDialog.HIDE_DIALOG_DELAY); } public void showHelpMessage(String message) { - showMessage(message); + showTemporaryMessage(message); } public void showErrorMessage(String error) { - showMessage(error); + showTemporaryMessage(error); mHandler.sendMessageDelayed(mHandler.obtainMessage(FingerprintDialogImpl.MSG_HIDE_DIALOG, false /* userCanceled */), FingerprintDialog.HIDE_DIALOG_DELAY); } - private void setAppIcon(ImageView image) { - final ActivityManager.RunningTaskInfo taskInfo = mActivityManagerWrapper.getRunningTask(); - final ComponentName cn = taskInfo.topActivity; - final int userId = mActivityManagerWrapper.getCurrentUserId(); - final ActivityInfo activityInfo = mPackageManageWrapper.getActivityInfo(cn, userId); - image.setImageDrawable(mActivityManagerWrapper.getBadgedActivityIcon(activityInfo, userId)); - image.setContentDescription( - getResources().getString(R.string.accessibility_fingerprint_dialog_app_icon) - + " " - + mActivityManagerWrapper.getBadgedActivityLabel(activityInfo, userId)); + private void updateFingerprintIcon(int newState) { + Drawable icon = getAnimationResForTransition(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; + + final ImageView fingerprint_icon = mLayout.findViewById(R.id.fingerprint_icon); + fingerprint_icon.setImageDrawable(icon); + + if (animation != null) { + animation.forceAnimationOnUI(); + animation.start(); + } + + mLastState = newState; + } + + private Drawable getAnimationResForTransition(int oldState, int newState) { + int iconRes; + if (oldState == STATE_NONE && newState == STATE_FINGERPRINT) { + iconRes = R.drawable.lockscreen_fingerprint_draw_on_animation; + } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_ERROR) { + iconRes = R.drawable.lockscreen_fingerprint_fp_to_error_state_animation; + } else if (oldState == STATE_FINGERPRINT_ERROR && newState == STATE_FINGERPRINT) { + iconRes = R.drawable.lockscreen_fingerprint_error_state_to_fp_animation; + } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_AUTHENTICATED) { + iconRes = R.drawable.lockscreen_fingerprint_draw_off_animation; + } else { + return null; + } + return mContext.getDrawable(iconRes); } public WindowManager.LayoutParams getLayoutParams() { |