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

Commit 98f21387 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[DO NOT MERGE] Keyguard PIN View - Landscape fixes" into sc-v2-dev

parents 5150b2b5 3695a34e
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
** 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"
@@ -186,8 +185,6 @@

    </androidx.constraintlayout.widget.ConstraintLayout>



    <include layout="@layout/keyguard_eca"
             android:id="@+id/keyguard_selector_fade_container"
             android:layout_width="match_parent"
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
-->
<resources>
    <dimen name="num_pad_row_margin_bottom">3dp</dimen>
    <dimen name="keyguard_eca_top_margin">0dp</dimen>
    <dimen name="keyguard_eca_top_margin">2dp</dimen>
    <dimen name="keyguard_eca_bottom_margin">2dp</dimen>
    <dimen name="keyguard_password_height">26dp</dimen>
    <dimen name="num_pad_entry_row_margin_bottom">0dp</dimen>
+23 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.keyguard;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Handler;
@@ -58,7 +59,8 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
    private boolean mBouncerVisible;
    private boolean mAltBouncerShowing;
    private ViewGroup mContainer;
    private int mTopMargin;
    private int mContainerTopMargin;
    private int mLastOrientation = -1;

    public KeyguardMessageArea(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -74,18 +76,30 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
        mContainer = getRootView().findViewById(R.id.keyguard_message_area_container);
    }

    void onConfigChanged() {
    void onConfigChanged(Configuration newConfig) {
        final int newTopMargin = SystemBarUtils.getStatusBarHeight(getContext());
        if (mTopMargin == newTopMargin) {
            return;
        }
        mTopMargin = newTopMargin;
        if (mContainerTopMargin != newTopMargin) {
            mContainerTopMargin = newTopMargin;
            ViewGroup.MarginLayoutParams lp =
                (ViewGroup.MarginLayoutParams) mContainer.getLayoutParams();
        lp.topMargin = mTopMargin;
            lp.topMargin = mContainerTopMargin;
            mContainer.setLayoutParams(lp);
        }

        if (mLastOrientation != newConfig.orientation) {
            mLastOrientation = newConfig.orientation;
            int messageAreaTopMargin = 0;
            if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
                messageAreaTopMargin = mContext.getResources().getDimensionPixelSize(
                        R.dimen.keyguard_lock_padding);
            }

            ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) getLayoutParams();
            lp.topMargin = messageAreaTopMargin;
            setLayoutParams(lp);
        }
    }

    @Override
    public void setNextMessageColor(ColorStateList colorState) {
        mNextMessageColorState = colorState;
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag
    private ConfigurationListener mConfigurationListener = new ConfigurationListener() {
        @Override
        public void onConfigChanged(Configuration newConfig) {
            mView.onConfigChanged();
            mView.onConfigChanged(newConfig);
        }

        @Override
+33 −33
Original line number Diff line number Diff line
@@ -21,10 +21,13 @@ import static com.android.systemui.statusbar.policy.DevicePostureController.DEVI

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

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

@@ -87,48 +90,45 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
    }

    private void updateMargins() {
        // Re-apply everything to the keys...
        int bottomMargin = mContext.getResources().getDimensionPixelSize(
                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);

        // 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;
                }
        Resources res = mContext.getResources();

                // Don't set margins on the rightmost buttons.
                if (column != 2) {
                    lp.rightMargin = rightMargin;
                }
        // Re-apply everything to the keys...
        int verticalMargin = res.getDimensionPixelSize(R.dimen.num_pad_entry_row_margin_bottom);
        int horizontalMargin = res.getDimensionPixelSize(R.dimen.num_pad_key_margin_end);
        String ratio = res.getString(R.string.num_pad_key_ratio);

                key.setLayoutParams(lp);
            }
        }
        Flow flow = (Flow) mContainer.findViewById(R.id.flow1);
        flow.setHorizontalGap(horizontalMargin);
        flow.setVerticalGap(verticalMargin);

        // Update the guideline based on the device posture...
        float halfOpenPercentage =
                mContext.getResources().getFloat(R.dimen.half_opened_bouncer_height_ratio);
        float halfOpenPercentage = res.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);

        // Password entry area
        int passwordHeight = res.getDimensionPixelSize(R.dimen.keyguard_password_height);
        View pinEntry = mContainer.findViewById(R.id.pinEntry);
        ViewGroup.LayoutParams lp = pinEntry.getLayoutParams();
        lp.height = passwordHeight;
        pinEntry.setLayoutParams(lp);

        // Below row0
        View row0 = mContainer.findViewById(R.id.row0);
        row0.setPadding(0, 0, 0, verticalMargin);

        // Above the emergency contact area
        int marginTop = res.getDimensionPixelSize(R.dimen.keyguard_eca_top_margin);
        View eca = findViewById(R.id.keyguard_selector_fade_container);
        if (eca != null) {
            ViewGroup.MarginLayoutParams mLp = (ViewGroup.MarginLayoutParams) eca.getLayoutParams();
            mLp.topMargin = marginTop;
            eca.setLayoutParams(mLp);
        }
    }

    @Override