Merge "Landscape PIN bouncer: refactor of portrait layout" into udc-qpr-dev

This commit is contained in:
Jonathon Axford
2023-07-28 10:11:42 +00:00
committed by Android (Google) Code Review
4 changed files with 248 additions and 200 deletions

View File

@@ -16,202 +16,10 @@
** limitations under the License.
*/
-->
<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"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
androidprv:layout_maxWidth="@dimen/keyguard_security_width">
<include layout="@layout/keyguard_bouncer_message_area"/>
android:layout_height="match_parent">
<com.android.systemui.bouncer.ui.BouncerMessageView
android:id="@+id/bouncer_message_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<include layout="@layout/keyguard_pin_view_portrait" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/pin_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:clipChildren="false"
android:clipToPadding="false"
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="wrap_content"
android:paddingBottom="@dimen/num_pad_entry_row_margin_bottom"
androidprv:layout_constraintTop_toTopOf="parent"
androidprv:layout_constraintEnd_toEndOf="parent"
androidprv:layout_constraintStart_toStartOf="parent"
androidprv:layout_constraintBottom_toTopOf="@id/key1"
androidprv:layout_constraintVertical_bias="0.5">
<com.android.keyguard.PasswordTextView
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>
<!-- Guideline used to place the top row of keys relative to the screen height. This will be
updated in KeyguardPINView to reduce the height of the PIN pad. -->
<androidx.constraintlayout.widget.Guideline
android:id="@+id/pin_pad_top_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidprv:layout_constraintGuide_percent="0"
android:orientation="horizontal" />
<com.android.keyguard.KeyguardPinFlowView
android:id="@+id/flow1"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
android:clipChildren="false"
android:clipToPadding="false"
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_verticalBias="1.0"
androidprv:flow_verticalGap="@dimen/num_pad_entry_row_margin_bottom"
androidprv:flow_verticalStyle="packed"
androidprv:flow_wrapMode="aligned"
androidprv:layout_constraintBottom_toBottomOf="parent"
androidprv:layout_constraintEnd_toEndOf="parent"
androidprv:layout_constraintStart_toStartOf="parent"
androidprv:layout_constraintTop_toBottomOf="@id/pin_pad_top_guideline" />
<com.android.keyguard.NumPadKey
android:id="@+id/key1"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key2"
androidprv:digit="1"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key2"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key3"
androidprv:digit="2"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key3"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key4"
androidprv:digit="3"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key4"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key5"
androidprv:digit="4"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key5"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key6"
androidprv:digit="5"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key6"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key7"
androidprv:digit="6"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key7"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key8"
androidprv:digit="7"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key8"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key9"
androidprv:digit="8"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key9"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/delete_button"
androidprv:digit="9"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadButton
android:id="@+id/delete_button"
style="@style/NumPadKey.Delete"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key0"
android:contentDescription="@string/keyboardview_keycode_delete" />
<com.android.keyguard.NumPadKey
android:id="@+id/key0"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key_enter"
androidprv:digit="0"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadButton
android:id="@+id/key_enter"
style="@style/NumPadKey.Enter"
android:layout_width="0dp"
android:layout_height="0dp"
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"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
android:layout_marginBottom="@dimen/keyguard_eca_bottom_margin"
android:gravity="center_horizontal"/>
</com.android.keyguard.KeyguardPINView>
</FrameLayout>

View File

@@ -0,0 +1,218 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2023, 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.
*/
-->
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
androidprv:layout_maxWidth="@dimen/keyguard_security_width">
<include layout="@layout/keyguard_bouncer_message_area"/>
<com.android.systemui.bouncer.ui.BouncerMessageView
android:id="@+id/bouncer_message_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/pin_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:clipChildren="false"
android:clipToPadding="false"
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="wrap_content"
android:paddingBottom="@dimen/num_pad_entry_row_margin_bottom"
androidprv:layout_constraintTop_toTopOf="parent"
androidprv:layout_constraintEnd_toEndOf="parent"
androidprv:layout_constraintStart_toStartOf="parent"
androidprv:layout_constraintBottom_toTopOf="@id/key1"
androidprv:layout_constraintVertical_bias="0.5">
<com.android.keyguard.PasswordTextView
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>
<!-- Guideline used to place the top row of keys relative to the screen height. This will be
updated in KeyguardPINView to reduce the height of the PIN pad. -->
<androidx.constraintlayout.widget.Guideline
android:id="@+id/pin_pad_top_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidprv:layout_constraintGuide_percent="0"
android:orientation="horizontal" />
<com.android.keyguard.KeyguardPinFlowView
android:id="@+id/flow1"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
android:clipChildren="false"
android:clipToPadding="false"
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_verticalBias="1.0"
androidprv:flow_verticalGap="@dimen/num_pad_entry_row_margin_bottom"
androidprv:flow_verticalStyle="packed"
androidprv:flow_wrapMode="aligned"
androidprv:layout_constraintBottom_toBottomOf="parent"
androidprv:layout_constraintEnd_toEndOf="parent"
androidprv:layout_constraintStart_toStartOf="parent"
androidprv:layout_constraintTop_toBottomOf="@id/pin_pad_top_guideline" />
<com.android.keyguard.NumPadKey
android:id="@+id/key1"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key2"
androidprv:digit="1"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key2"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key3"
androidprv:digit="2"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key3"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key4"
androidprv:digit="3"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key4"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key5"
androidprv:digit="4"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key5"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key6"
androidprv:digit="5"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key6"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key7"
androidprv:digit="6"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key7"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key8"
androidprv:digit="7"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key8"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key9"
androidprv:digit="8"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadKey
android:id="@+id/key9"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/delete_button"
androidprv:digit="9"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadButton
android:id="@+id/delete_button"
style="@style/NumPadKey.Delete"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key0"
android:contentDescription="@string/keyboardview_keycode_delete" />
<com.android.keyguard.NumPadKey
android:id="@+id/key0"
android:layout_width="0dp"
android:layout_height="0dp"
android:accessibilityTraversalBefore="@id/key_enter"
androidprv:digit="0"
androidprv:textView="@+id/pinEntry" />
<com.android.keyguard.NumPadButton
android:id="@+id/key_enter"
style="@style/NumPadKey.Enter"
android:layout_width="0dp"
android:layout_height="0dp"
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"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
android:layout_marginBottom="@dimen/keyguard_eca_bottom_margin"
android:gravity="center_horizontal"/>
</com.android.keyguard.KeyguardPINView>

View File

@@ -117,15 +117,19 @@ public class KeyguardSecurityViewFlipperController
KeyguardSecurityCallback keyguardSecurityCallback,
@Nullable OnViewInflatedCallback onViewInflatedListener) {
int layoutId = getLayoutIdFor(securityMode);
if (layoutId != 0) {
if (DEBUG) Log.v(TAG, "inflating on bg thread id = " + layoutId);
int viewID = getKeyguardInputViewId(securityMode);
if (layoutId != 0 && viewID != 0) {
if (DEBUG) {
Log.v(TAG, "inflating on bg thread id = "
+ layoutId + " . viewID = " + viewID);
}
mAsyncLayoutInflater.inflate(layoutId, mView,
(view, resId, parent) -> {
mView.addView(view);
KeyguardInputViewController<KeyguardInputView> childController =
mKeyguardSecurityViewControllerFactory.create(
(KeyguardInputView) view, securityMode,
keyguardSecurityCallback);
(KeyguardInputView) view.findViewById(viewID),
securityMode, keyguardSecurityCallback);
childController.init();
mChildren.add(childController);
if (onViewInflatedListener != null) {
@@ -147,6 +151,19 @@ public class KeyguardSecurityViewFlipperController
}
}
private int getKeyguardInputViewId(SecurityMode securityMode) {
//Keyguard Input View is not the root view of the layout, use these IDs for lookup.
switch (securityMode) {
case Pattern: return R.id.keyguard_pattern_view;
case PIN: return R.id.keyguard_pin_view;
case Password: return R.id.keyguard_password_view;
case SimPin: return R.id.keyguard_sim_pin_view;
case SimPuk: return R.id.keyguard_sim_puk_view;
default:
return 0;
}
}
/** Makes the supplied child visible if it is contained win this view, */
public void show(KeyguardInputViewController<KeyguardInputView> childController) {
int index = childController.getIndexIn(mView);

View File

@@ -138,6 +138,11 @@ public class KeyguardSecurityViewFlipperControllerTest extends SysuiTestCase {
@Test
public void asynchronouslyInflateView_setNeedsInput() {
when(mKeyguardSecurityViewControllerFactory.create(
any(), any(SecurityMode.class),
any(KeyguardSecurityCallback.class)))
.thenReturn(mKeyguardInputViewController);
ArgumentCaptor<AsyncLayoutInflater.OnInflateFinishedListener> argumentCaptor =
ArgumentCaptor.forClass(AsyncLayoutInflater.OnInflateFinishedListener.class);
mKeyguardSecurityViewFlipperController.asynchronouslyInflateView(SecurityMode.PIN,