Merge "[DO NOT MERGE] Keyguard PIN View - Landscape fixes" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
98f21387dc
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user