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

Commit 9f4b3a64 authored by Jamie Garside's avatar Jamie Garside
Browse files

Resize PIN pad when the device is half folded.

This will use a guideline to size the PIN pad so it fits on half of the
screen when the device is in tabletop mode.

Bug: 191347942
Test: Manually tested.
Change-Id: I9f273ba9dbbee74d9b427d4bededb62de96a7f90
parent a40dd998
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -47,11 +47,11 @@
            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_constraintBottom_toTopOf="@id/key1"
            androidprv:layout_constraintVertical_bias="1.0">

            <com.android.keyguard.PasswordTextView
@@ -65,6 +65,15 @@
                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" />

        <androidx.constraintlayout.helper.widget.Flow
            android:id="@+id/flow1"
            android:layout_width="0dp"
@@ -78,16 +87,15 @@
            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_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" />
            androidprv:layout_constraintStart_toStartOf="parent"
            androidprv:layout_constraintTop_toBottomOf="@id/pin_pad_top_guideline" />

        <com.android.keyguard.NumPadKey
            android:id="@+id/key1"
+6 −0
Original line number Diff line number Diff line
@@ -98,4 +98,10 @@
    <dimen name="below_clock_padding_start">32dp</dimen>
    <dimen name="below_clock_padding_end">16dp</dimen>
    <dimen name="below_clock_padding_start_icons">28dp</dimen>

    <!-- Proportion of the screen height to use to set the maximum height of the bouncer to when
         the device is in the DEVICE_POSTURE_HALF_OPENED posture, for the PIN/pattern entry. 0 will
         allow it to use the whole screen space, 0.6 will allow it to use just under half of the
         screen. -->
    <item name="half_opened_bouncer_height_ratio" type="dimen" format="float">0.0</item>
</resources>
+7 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.util.ViewController;
import com.android.systemui.util.concurrency.DelayableExecutor;

@@ -166,6 +167,7 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
        private final TelephonyManager mTelephonyManager;
        private final EmergencyButtonController.Factory mEmergencyButtonControllerFactory;
        private final FalsingCollector mFalsingCollector;
        private final DevicePostureController mDevicePostureController;

        @Inject
        public Factory(KeyguardUpdateMonitor keyguardUpdateMonitor,
@@ -175,7 +177,8 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
                InputMethodManager inputMethodManager, @Main DelayableExecutor mainExecutor,
                @Main Resources resources, LiftToActivateListener liftToActivateListener,
                TelephonyManager telephonyManager, FalsingCollector falsingCollector,
                EmergencyButtonController.Factory emergencyButtonControllerFactory) {
                EmergencyButtonController.Factory emergencyButtonControllerFactory,
                DevicePostureController devicePostureController) {
            mKeyguardUpdateMonitor = keyguardUpdateMonitor;
            mLockPatternUtils = lockPatternUtils;
            mLatencyTracker = latencyTracker;
@@ -187,6 +190,7 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
            mTelephonyManager = telephonyManager;
            mEmergencyButtonControllerFactory = emergencyButtonControllerFactory;
            mFalsingCollector = falsingCollector;
            mDevicePostureController = devicePostureController;
        }

        /** Create a new {@link KeyguardInputViewController}. */
@@ -212,7 +216,8 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
                return new KeyguardPinViewController((KeyguardPINView) keyguardInputView,
                        mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
                        keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker,
                        mLiftToActivateListener, emergencyButtonController, mFalsingCollector);
                        mLiftToActivateListener, emergencyButtonController, mFalsingCollector,
                        mDevicePostureController);
            } else if (keyguardInputView instanceof KeyguardSimPinView) {
                return new KeyguardSimPinViewController((KeyguardSimPinView) keyguardInputView,
                        mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
+22 −2
Original line number Diff line number Diff line
@@ -16,19 +16,23 @@

package com.android.keyguard;

import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_HALF_OPENED;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;

import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;

import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;

import com.android.internal.jank.InteractionJankMonitor;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.DevicePostureController.DevicePostureInt;

/**
 * Displays a PIN pad for unlocking.
@@ -38,9 +42,10 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
    private final AppearAnimationUtils mAppearAnimationUtils;
    private final DisappearAnimationUtils mDisappearAnimationUtils;
    private final DisappearAnimationUtils mDisappearAnimationUtilsLocked;
    private ViewGroup mContainer;
    private ConstraintLayout mContainer;
    private int mDisappearYTranslation;
    private View[][] mViews;
    @DevicePostureInt private int mLastDevicePosture = DEVICE_POSTURE_UNKNOWN;

    public KeyguardPINView(Context context) {
        this(context, null);
@@ -67,6 +72,11 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
        updateMargins();
    }

    void onDevicePostureChanged(@DevicePostureInt int posture) {
        mLastDevicePosture = posture;
        updateMargins();
    }

    @Override
    protected void resetState() {
    }
@@ -109,6 +119,16 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
                key.setLayoutParams(lp);
            }
        }

        // Update the guideline based on the device posture...
        float halfOpenPercentage =
                mContext.getResources().getFloat(R.dimen.half_opened_bouncer_height_ratio);

        ConstraintSet cs = new ConstraintSet();
        cs.clone(mContainer);
        cs.setGuidelinePercent(R.id.pin_pad_top_guideline,
                mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED ? halfOpenPercentage : 0.0f);
        cs.applyTo(mContainer);
    }

    @Override
+15 −1
Original line number Diff line number Diff line
@@ -23,10 +23,14 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.statusbar.policy.DevicePostureController;

public class KeyguardPinViewController
        extends KeyguardPinBasedInputViewController<KeyguardPINView> {
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final DevicePostureController mPostureController;
    private final DevicePostureController.Callback mPostureCallback = posture ->
            mView.onDevicePostureChanged(posture);

    protected KeyguardPinViewController(KeyguardPINView view,
            KeyguardUpdateMonitor keyguardUpdateMonitor,
@@ -35,11 +39,13 @@ public class KeyguardPinViewController
            KeyguardMessageAreaController.Factory messageAreaControllerFactory,
            LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener,
            EmergencyButtonController emergencyButtonController,
            FalsingCollector falsingCollector) {
            FalsingCollector falsingCollector,
            DevicePostureController postureController) {
        super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback,
                messageAreaControllerFactory, latencyTracker, liftToActivateListener,
                emergencyButtonController, falsingCollector);
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mPostureController = postureController;
    }

    @Override
@@ -53,6 +59,14 @@ public class KeyguardPinViewController
                getKeyguardSecurityCallback().onCancelClicked();
            });
        }

        mPostureController.addCallback(mPostureCallback);
    }

    @Override
    protected void onViewDetached() {
        super.onViewDetached();
        mPostureController.removeCallback(mPostureCallback);
    }

    @Override