Updated keyguard_pin_view to use a ConstraintLayout.
Bug: 191347942 Test: Manually tested. Change-Id: Ie2f752b6d4ff4293aaa59a298e7ec44f20f7d4dc
This commit is contained in:
@@ -20,171 +20,166 @@
|
||||
<com.android.keyguard.KeyguardPINView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/keyguard_pin_view"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/keyguard_pin_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<LinearLayout
|
||||
android:id="@+id/pin_container"
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/pin_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_weight="1"
|
||||
android:layoutDirection="ltr"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Set this to be just above key1. It would be better to introduce a barrier above
|
||||
key1/key2/key3, then place this View above that. Sadly, that doesn't work (the Barrier
|
||||
drops to the bottom of the page, and key1/2/3 all shoot up to the top-left). In any
|
||||
case, the Flow should ensure that key1/2/3 all have the same top, so this should be
|
||||
fine. -->
|
||||
<com.android.keyguard.AlphaOptimizedRelativeLayout
|
||||
android:id="@+id/row0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1"
|
||||
android:layoutDirection="ltr"
|
||||
android:layout_marginBottom="8dp"
|
||||
>
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
<com.android.keyguard.AlphaOptimizedRelativeLayout
|
||||
android:id="@+id/row0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/num_pad_entry_row_margin_bottom"
|
||||
>
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/num_pad_entry_row_margin_bottom"
|
||||
androidprv:layout_constraintBottom_toTopOf="@id/key1"
|
||||
androidprv:layout_constraintEnd_toEndOf="parent"
|
||||
androidprv:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
androidprv:layout_constraintTop_toTopOf="parent"
|
||||
androidprv:layout_constraintVertical_bias="1.0">
|
||||
|
||||
<com.android.keyguard.PasswordTextView
|
||||
android:id="@+id/pinEntry"
|
||||
android:layout_width="@dimen/keyguard_security_width"
|
||||
android:layout_height="@dimen/keyguard_password_height"
|
||||
style="@style/Widget.TextView.Password"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginRight="72dp"
|
||||
androidprv:scaledTextSize="@integer/scaled_password_text_size"
|
||||
android:contentDescription="@string/keyguard_accessibility_pin_area"
|
||||
/>
|
||||
android:id="@+id/pinEntry"
|
||||
style="@style/Widget.TextView.Password"
|
||||
android:layout_width="@dimen/keyguard_security_width"
|
||||
android:layout_height="@dimen/keyguard_password_height"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginRight="72dp"
|
||||
android:contentDescription="@string/keyguard_accessibility_pin_area"
|
||||
androidprv:scaledTextSize="@integer/scaled_password_text_size" />
|
||||
</com.android.keyguard.AlphaOptimizedRelativeLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/row1"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
androidprv:textView="@+id/pinEntry"
|
||||
androidprv:digit="3"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/row2"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
androidprv:textView="@+id/pinEntry"
|
||||
androidprv:digit="6"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/row3"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
androidprv:textView="@+id/pinEntry"
|
||||
androidprv:digit="9"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/row4"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
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="@dimen/num_pad_key_width"
|
||||
android:layout_height="match_parent"
|
||||
style="@style/NumPadKey.Enter"
|
||||
android:contentDescription="@string/keyboardview_keycode_enter"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.helper.widget.Flow
|
||||
android:id="@+id/flow1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
|
||||
androidprv:constraint_referenced_ids="key1,key2,key3,key4,key5,key6,key7,key8,key9,delete_button,key0,key_enter"
|
||||
|
||||
androidprv:flow_horizontalGap="@dimen/num_pad_key_margin_end"
|
||||
|
||||
androidprv:flow_horizontalStyle="packed"
|
||||
androidprv:flow_maxElementsWrap="3"
|
||||
|
||||
androidprv:flow_verticalGap="@dimen/num_pad_entry_row_margin_bottom"
|
||||
androidprv:flow_verticalStyle="packed"
|
||||
androidprv:flow_verticalBias="1.0"
|
||||
|
||||
androidprv:flow_wrapMode="aligned"
|
||||
|
||||
androidprv:layout_constraintTop_toTopOf="parent"
|
||||
androidprv:layout_constraintBottom_toBottomOf="parent"
|
||||
androidprv:layout_constraintEnd_toEndOf="parent"
|
||||
androidprv:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="1"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="2"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="3"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="4"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="5"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="6"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="7"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key8"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="8"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key9"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="9"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
|
||||
<com.android.keyguard.NumPadButton
|
||||
android:id="@+id/delete_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
style="@style/NumPadKey.Delete"
|
||||
android:contentDescription="@string/keyboardview_keycode_delete"
|
||||
/>
|
||||
|
||||
<com.android.keyguard.NumPadKey
|
||||
android:id="@+id/key0"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:digit="0"
|
||||
androidprv:textView="@+id/pinEntry" />
|
||||
|
||||
<com.android.keyguard.NumPadButton
|
||||
android:id="@+id/key_enter"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
style="@style/NumPadKey.Enter"
|
||||
android:contentDescription="@string/keyboardview_keycode_enter"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
<include layout="@layout/keyguard_eca"
|
||||
android:id="@+id/keyguard_selector_fade_container"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="num_pad_key_ratio">1.51</string>
|
||||
</resources>
|
||||
@@ -26,4 +26,6 @@
|
||||
|
||||
<!-- Skeleton string format for displaying the time in 24-hour format. -->
|
||||
<string name="clock_24hr_format">Hm</string>
|
||||
|
||||
<string name="num_pad_key_ratio">1</string>
|
||||
</resources>
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
<item name="android:colorControlNormal">@null</item>
|
||||
<item name="android:colorControlHighlight">?android:attr/colorAccent</item>
|
||||
<item name="android:background">@drawable/num_pad_key_background</item>
|
||||
|
||||
<!-- Default values for NumPadKey used in a ConstraintLayout. -->
|
||||
<item name="layout_constraintDimensionRatio">@string/num_pad_key_ratio</item>
|
||||
<item name="layout_constraintWidth_max">@dimen/num_pad_key_width</item>
|
||||
</style>
|
||||
<style name="Widget.TextView.NumPadKey.Digit"
|
||||
parent="@android:style/Widget.DeviceDefault.TextView">
|
||||
|
||||
@@ -22,15 +22,14 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.android.internal.jank.InteractionJankMonitor;
|
||||
import com.android.settingslib.animation.AppearAnimationUtils;
|
||||
import com.android.settingslib.animation.DisappearAnimationUtils;
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays a PIN pad for unlocking.
|
||||
*/
|
||||
@@ -40,10 +39,6 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
||||
private final DisappearAnimationUtils mDisappearAnimationUtils;
|
||||
private final DisappearAnimationUtils mDisappearAnimationUtilsLocked;
|
||||
private ViewGroup mContainer;
|
||||
private ViewGroup mRow0;
|
||||
private ViewGroup mRow1;
|
||||
private ViewGroup mRow2;
|
||||
private ViewGroup mRow3;
|
||||
private int mDisappearYTranslation;
|
||||
private View[][] mViews;
|
||||
|
||||
@@ -82,30 +77,38 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
||||
}
|
||||
|
||||
private void updateMargins() {
|
||||
// Re-apply everything to the keys...
|
||||
int bottomMargin = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.num_pad_row_margin_bottom);
|
||||
|
||||
for (ViewGroup vg : List.of(mRow1, mRow2, mRow3)) {
|
||||
((LinearLayout.LayoutParams) vg.getLayoutParams()).setMargins(0, 0, 0, bottomMargin);
|
||||
}
|
||||
|
||||
bottomMargin = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.num_pad_entry_row_margin_bottom);
|
||||
((LinearLayout.LayoutParams) mRow0.getLayoutParams()).setMargins(0, 0, 0, bottomMargin);
|
||||
int rightMargin = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.num_pad_key_margin_end);
|
||||
String ratio = mContext.getResources().getString(R.string.num_pad_key_ratio);
|
||||
|
||||
if (mEcaView != null) {
|
||||
int ecaTopMargin = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.keyguard_eca_top_margin);
|
||||
int ecaBottomMargin = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.keyguard_eca_bottom_margin);
|
||||
((LinearLayout.LayoutParams) mEcaView.getLayoutParams()).setMargins(0, ecaTopMargin,
|
||||
0, ecaBottomMargin);
|
||||
// mView contains all Views that make up the PIN pad; row0 = the entry test field, then
|
||||
// rows 1-4 contain the buttons. Iterate over all views that make up the buttons in the pad,
|
||||
// and re-set all the margins.
|
||||
for (int row = 1; row < 5; row++) {
|
||||
for (int column = 0; column < 3; column++) {
|
||||
View key = mViews[row][column];
|
||||
|
||||
ConstraintLayout.LayoutParams lp =
|
||||
(ConstraintLayout.LayoutParams) key.getLayoutParams();
|
||||
|
||||
lp.dimensionRatio = ratio;
|
||||
|
||||
// Don't set any margins on the last row of buttons.
|
||||
if (row != 4) {
|
||||
lp.bottomMargin = bottomMargin;
|
||||
}
|
||||
|
||||
// Don't set margins on the rightmost buttons.
|
||||
if (column != 2) {
|
||||
lp.rightMargin = rightMargin;
|
||||
}
|
||||
|
||||
key.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
|
||||
View entryView = findViewById(R.id.pinEntry);
|
||||
ViewGroup.LayoutParams lp = entryView.getLayoutParams();
|
||||
lp.height = mContext.getResources().getDimensionPixelSize(R.dimen.keyguard_password_height);
|
||||
entryView.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,13 +116,9 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
||||
super.onFinishInflate();
|
||||
|
||||
mContainer = findViewById(R.id.pin_container);
|
||||
mRow0 = findViewById(R.id.row0);
|
||||
mRow1 = findViewById(R.id.row1);
|
||||
mRow2 = findViewById(R.id.row2);
|
||||
mRow3 = findViewById(R.id.row3);
|
||||
mViews = new View[][]{
|
||||
new View[]{
|
||||
mRow0, null, null
|
||||
findViewById(R.id.row0), null, null
|
||||
},
|
||||
new View[]{
|
||||
findViewById(R.id.key1), findViewById(R.id.key2),
|
||||
@@ -188,9 +187,6 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
||||
private void enableClipping(boolean enable) {
|
||||
mContainer.setClipToPadding(enable);
|
||||
mContainer.setClipChildren(enable);
|
||||
mRow1.setClipToPadding(enable);
|
||||
mRow2.setClipToPadding(enable);
|
||||
mRow3.setClipToPadding(enable);
|
||||
setClipChildren(enable);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,9 @@ public class NumPadButton extends AlphaOptimizedImageButton {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
// Set width/height to the same value to ensure a smooth circle for the bg, but shrink
|
||||
// the height to match the old pin bouncer
|
||||
// the height to match the old pin bouncer.
|
||||
// This is only used for PIN/PUK; the main PIN pad now uses ConstraintLayout, which will
|
||||
// force our width/height to conform to the ratio in the layout.
|
||||
int width = getMeasuredWidth();
|
||||
|
||||
boolean shortenHeight = mAnimator == null
|
||||
|
||||
@@ -175,7 +175,9 @@ public class NumPadKey extends ViewGroup {
|
||||
measureChildren(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
// Set width/height to the same value to ensure a smooth circle for the bg, but shrink
|
||||
// the height to match the old pin bouncer
|
||||
// the height to match the old pin bouncer.
|
||||
// This is only used for PIN/PUK; the main PIN pad now uses ConstraintLayout, which will
|
||||
// force our width/height to conform to the ratio in the layout.
|
||||
int width = getMeasuredWidth();
|
||||
|
||||
boolean shortenHeight = mAnimator == null
|
||||
|
||||
Reference in New Issue
Block a user