From 3695a34ec9288c6679aef8ee20ed985ce67db56e Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 25 Jan 2022 14:35:18 -0500 Subject: [DO NOT MERGE] Keyguard PIN View - Landscape fixes Upon entering landscape, updated resource values were not being applied to the num pad keys or other elements. Manually apply. Fixes: 214985639 Test: manual (launch camera on lockscreen, rotate, use unlock button, observe) Change-Id: Iff67fb46ceb9bb1b626f0d57e42aa232daec59a3 --- .../src/com/android/keyguard/KeyguardPINView.java | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java') diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java index 1efda7edee2f..5115aba26ee7 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java @@ -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() { + Resources res = mContext.getResources(); + // 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; - } - - // Don't set margins on the rightmost buttons. - if (column != 2) { - lp.rightMargin = rightMargin; - } - - key.setLayoutParams(lp); - } - } + 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); + + 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 -- cgit v1.2.3 From 2bbaf5d0994592aee7ce72eac09a9617dbe6022d Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Tue, 1 Feb 2022 15:43:21 -0800 Subject: DO NOT MERGE Allow pinEntry field to be outside pin_container On automotive, the pinEntry field lives outside the pin_container. Because of this, ag/16719218 broke the auto layout since R.id.pinEntry cannot be found inside the container. Looking across the entire pin view fixes this. Bug: 217401027 Test: manual Change-Id: I860b3f93e5e96e439dae542725f7aceadba6f9db --- packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java') diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java index 5115aba26ee7..5b4f7a21f8d0 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java @@ -112,13 +112,13 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { // Password entry area int passwordHeight = res.getDimensionPixelSize(R.dimen.keyguard_password_height); - View pinEntry = mContainer.findViewById(R.id.pinEntry); + View pinEntry = findViewById(getPasswordTextViewId()); ViewGroup.LayoutParams lp = pinEntry.getLayoutParams(); lp.height = passwordHeight; pinEntry.setLayoutParams(lp); // Below row0 - View row0 = mContainer.findViewById(R.id.row0); + View row0 = findViewById(R.id.row0); row0.setPadding(0, 0, 0, verticalMargin); // Above the emergency contact area -- cgit v1.2.3