summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Pietal <mpietal@google.com>2022-01-25 14:35:18 -0500
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-18 05:35:04 +0000
commit5bd6ff638d131c5965bed7378571620bc43ecfff (patch)
tree7ab974d29ecf2b28caa59374e51b87b7b40fd3db
parent21251cc8fb6c4ea792a5e88e4e1081c930d13d2a (diff)
downloadbase-5bd6ff638d131c5965bed7378571620bc43ecfff.tar.gz
[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 (cherry picked from commit 3695a34ec9288c6679aef8ee20ed985ce67db56e) Merged-In:Iff67fb46ceb9bb1b626f0d57e42aa232daec59a3
-rw-r--r--packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml3
-rw-r--r--packages/SystemUI/res-keyguard/values-land/dimens.xml2
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java32
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java2
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java66
5 files changed, 58 insertions, 47 deletions
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
index a946318cb313..0a2d226a33eb 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml
@@ -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"
diff --git a/packages/SystemUI/res-keyguard/values-land/dimens.xml b/packages/SystemUI/res-keyguard/values-land/dimens.xml
index 6342b9c0c7f0..af284a87295b 100644
--- a/packages/SystemUI/res-keyguard/values-land/dimens.xml
+++ b/packages/SystemUI/res-keyguard/values-land/dimens.xml
@@ -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>
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
index 099dd5d82a10..a7840cbf2789 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
@@ -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,16 +76,28 @@ 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;
- ViewGroup.MarginLayoutParams lp =
+ if (mContainerTopMargin != newTopMargin) {
+ mContainerTopMargin = newTopMargin;
+ ViewGroup.MarginLayoutParams lp =
(ViewGroup.MarginLayoutParams) mContainer.getLayoutParams();
- lp.topMargin = mTopMargin;
- mContainer.setLayoutParams(lp);
+ 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
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java
index 05318bb0df78..659aadd69614 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java
@@ -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
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