PIN Views - Make a bit smaller for better reachability

Align with latest UX guidance, making buttons better spaced and a bit
smaller

Fixes: 182196214
Test: manual
Change-Id: Ibc29e04da3867071d558c7f3643addeb2826b2bc
This commit is contained in:
Matt Pietal
2021-03-16 09:00:31 -04:00
parent 14a5f1de4c
commit 7cbb8708b9
8 changed files with 122 additions and 109 deletions

View File

@@ -59,124 +59,127 @@
</com.android.keyguard.AlphaOptimizedRelativeLayout>
<LinearLayout
android:id="@+id/row1"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key1"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pinEntry"
androidprv:digit="1"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key2"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pinEntry"
androidprv:digit="2"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key3"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/pinEntry"
androidprv:digit="3"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/row2"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key4"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pinEntry"
androidprv:digit="4"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key5"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pinEntry"
androidprv:digit="5"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key6"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/pinEntry"
androidprv:digit="6"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/row3"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key7"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pinEntry"
androidprv:digit="7"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key8"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pinEntry"
androidprv:digit="8"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key9"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/pinEntry"
androidprv:digit="9"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/row4"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
>
<com.android.keyguard.NumPadButton
android:id="@+id/delete_button"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
android:contentDescription="@string/keyboardview_keycode_delete"
style="@style/NumPadKey.Delete"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key0"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pinEntry"
androidprv:digit="0"
/>
<com.android.keyguard.NumPadButton
android:id="@+id/key_enter"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
style="@style/NumPadKey.Enter"
android:contentDescription="@string/keyboardview_keycode_enter"
/>

View File

@@ -71,121 +71,124 @@
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key1"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="1"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key2"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="2"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key3"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="3"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key4"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="4"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key5"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="5"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key6"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="6"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key7"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="7"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key8"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="8"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key9"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="9"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
>
<com.android.keyguard.NumPadButton
android:id="@+id/delete_button"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
android:contentDescription="@string/keyboardview_keycode_delete"
style="@style/NumPadKey.Delete"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key0"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/simPinEntry"
androidprv:digit="0"
/>
<com.android.keyguard.NumPadButton
android:id="@+id/key_enter"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
style="@style/NumPadKey.Enter"
android:contentDescription="@string/keyboardview_keycode_enter"
/>

View File

@@ -72,121 +72,125 @@
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key1"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pukEntry"
androidprv:digit="1"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key2"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pukEntry"
androidprv:digit="2"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key3"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/pukEntry"
androidprv:digit="3"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key4"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pukEntry"
androidprv:digit="4"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key5"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pukEntry"
androidprv:digit="5"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key6"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/pukEntry"
androidprv:digit="6"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
>
<com.android.keyguard.NumPadKey
android:id="@+id/key7"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pukEntry"
androidprv:digit="7"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key8"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pukEntry"
androidprv:digit="8"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key9"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
androidprv:textView="@+id/pukEntry"
androidprv:digit="9"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
>
<com.android.keyguard.NumPadButton
android:id="@+id/delete_button"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
android:contentDescription="@string/keyboardview_keycode_delete"
style="@style/NumPadKey.Delete"
/>
<com.android.keyguard.NumPadKey
android:id="@+id/key0"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginEnd="@dimen/num_pad_key_margin_end"
androidprv:textView="@+id/pukEntry"
androidprv:digit="0"
/>
<com.android.keyguard.NumPadButton
android:id="@+id/key_enter"
android:layout_width="0px"
android:layout_width="@dimen/num_pad_key_width"
android:layout_height="match_parent"
android:layout_weight="1"
style="@style/NumPadKey.Enter"
android:contentDescription="@string/keyboardview_keycode_enter"
/>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2021, 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.
*/
-->
<resources>
<!-- Spacing around each button used for PIN view -->
<dimen name="num_pad_key_width">84dp</dimen>
<dimen name="num_pad_row_margin_bottom">12dp</dimen>
<dimen name="num_pad_key_margin_end">20dp</dimen>
</resources>

View File

@@ -38,7 +38,7 @@
<!-- Margin around the various security views -->
<dimen name="keyguard_security_view_top_margin">8dp</dimen>
<dimen name="keyguard_security_view_lateral_margin">36dp</dimen>
<dimen name="keyguard_security_view_lateral_margin">20dp</dimen>
<dimen name="keyguard_eca_top_margin">18dp</dimen>
@@ -87,5 +87,7 @@
<dimen name="disappear_y_translation">-32dp</dimen>
<!-- Spacing around each button used for PIN view -->
<dimen name="num_pad_key_margin">2dp</dimen>
<dimen name="num_pad_key_width">72dp</dimen>
<dimen name="num_pad_row_margin_bottom">6dp</dimen>
<dimen name="num_pad_key_margin_end">12dp</dimen>
</resources>

View File

@@ -24,7 +24,6 @@ import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.view.ContextThemeWrapper;
import android.view.ViewGroup;
import androidx.annotation.StyleRes;
@@ -41,7 +40,6 @@ class NumPadAnimator {
private GradientDrawable mBackground;
private RippleDrawable mRipple;
private GradientDrawable mRippleMask;
private int mMargin;
private int mNormalColor;
private int mHighlightColor;
private int mStyle;
@@ -55,8 +53,6 @@ class NumPadAnimator {
reloadColors(context);
mMargin = context.getResources().getDimensionPixelSize(R.dimen.num_pad_key_margin);
// Actual values will be updated later, usually during an onLayout() call
mAnimator = new AnimatorSet();
mExpandAnimator = ValueAnimator.ofFloat(0f, 1f);
@@ -82,10 +78,6 @@ class NumPadAnimator {
mAnimator.playSequentially(mExpandAnimator, mContractAnimator);
}
void updateMargin(ViewGroup.MarginLayoutParams lp) {
lp.setMargins(mMargin, mMargin, mMargin, mMargin);
}
void onLayout(int height) {
float startRadius = height / 2f;
float endRadius = height / 4f;

View File

@@ -23,7 +23,6 @@ import android.graphics.drawable.VectorDrawable;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.MotionEvent;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
@@ -50,13 +49,6 @@ public class NumPadButton extends AlphaOptimizedImageButton {
}
}
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
if (mAnimator != null) mAnimator.updateMargin((ViewGroup.MarginLayoutParams) params);
super.setLayoutParams(params);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

View File

@@ -177,13 +177,6 @@ public class NumPadKey extends ViewGroup {
return super.onTouchEvent(event);
}
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
if (mAnimator != null) mAnimator.updateMargin((ViewGroup.MarginLayoutParams) params);
super.setLayoutParams(params);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);