Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 189d98ec authored by Jamie Garside's avatar Jamie Garside Committed by Automerger Merge Worker
Browse files

Merge "Updated keyguard_pin_view to use a ConstraintLayout." into sc-v2-dev...

Merge "Updated keyguard_pin_view to use a ConstraintLayout." into sc-v2-dev am: a8813c12 am: d7a0bdba

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15302107

Change-Id: I1c00f4ed8e936c18ae807042e6127897a793aed7
parents 87cb5699 d7a0bdba
Loading
Loading
Loading
Loading
+152 −157
Original line number Diff line number Diff line
@@ -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"
    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

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/pin_container"
        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"
          />
        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_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"
                style="@style/Widget.TextView.Password"
                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"
                    />
                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"

        <androidx.constraintlayout.helper.widget.Flow
            android:id="@+id/flow1"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:orientation="horizontal"
                android:layout_gravity="center_horizontal"
                android:layout_marginBottom="@dimen/num_pad_row_margin_bottom"
                >

            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    android:layout_marginEnd="@dimen/num_pad_key_margin_end"
                    androidprv:textView="@+id/pinEntry"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    android:layout_marginEnd="@dimen/num_pad_key_margin_end"
                    androidprv:textView="@+id/pinEntry"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    androidprv:textView="@+id/pinEntry"
            android:layout_width="0dp"
            android:layout_height="0dp"
            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"
                >
            androidprv:textView="@+id/pinEntry" />

        <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"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    android:layout_marginEnd="@dimen/num_pad_key_margin_end"
                    androidprv:textView="@+id/pinEntry"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    androidprv:textView="@+id/pinEntry"
            android:layout_width="0dp"
            android:layout_height="0dp"
            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"
                >
            androidprv:textView="@+id/pinEntry" />

        <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"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    android:layout_marginEnd="@dimen/num_pad_key_margin_end"
                    androidprv:textView="@+id/pinEntry"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    androidprv:textView="@+id/pinEntry"
            android:layout_width="0dp"
            android:layout_height="0dp"
            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"
                >
            androidprv:textView="@+id/pinEntry" />


        <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"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
                    android:layout_marginEnd="@dimen/num_pad_key_margin_end"
                    androidprv:textView="@+id/pinEntry"
            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="@dimen/num_pad_key_width"
                    android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_height="0dp"
            style="@style/NumPadKey.Enter"
            android:contentDescription="@string/keyboardview_keycode_enter"
            />
        </LinearLayout>
    </LinearLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>



    <include layout="@layout/keyguard_eca"
             android:id="@+id/keyguard_selector_fade_container"
             android:layout_width="match_parent"
+19 −0
Original line number Diff line number Diff line
<?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>
+2 −0
Original line number Diff line number Diff line
@@ -29,4 +29,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>
+4 −0
Original line number Diff line number Diff line
@@ -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">
+32 −36
Original line number Diff line number Diff line
@@ -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);
                R.dimen.num_pad_entry_row_margin_bottom);
        int rightMargin = mContext.getResources().getDimensionPixelSize(
                R.dimen.num_pad_key_margin_end);
        String ratio = mContext.getResources().getString(R.string.num_pad_key_ratio);

        for (ViewGroup vg : List.of(mRow1, mRow2, mRow3)) {
            ((LinearLayout.LayoutParams) vg.getLayoutParams()).setMargins(0, 0, 0, bottomMargin);
        }
        // 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];

        bottomMargin = mContext.getResources().getDimensionPixelSize(
                R.dimen.num_pad_entry_row_margin_bottom);
        ((LinearLayout.LayoutParams) mRow0.getLayoutParams()).setMargins(0, 0, 0, bottomMargin);
                ConstraintLayout.LayoutParams lp =
                        (ConstraintLayout.LayoutParams) key.getLayoutParams();

        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);
                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;
                }

        View entryView = findViewById(R.id.pinEntry);
        ViewGroup.LayoutParams lp = entryView.getLayoutParams();
        lp.height = mContext.getResources().getDimensionPixelSize(R.dimen.keyguard_password_height);
        entryView.setLayoutParams(lp);
                key.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);
    }

Loading