Merge "PIN bouncer - basic landscape support" into sc-dev
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
android:id="@+id/row0"
|
android:id="@+id/row0"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="@dimen/num_pad_entry_row_margin_bottom"
|
||||||
>
|
>
|
||||||
<com.android.keyguard.PasswordTextView
|
<com.android.keyguard.PasswordTextView
|
||||||
android:id="@+id/pinEntry"
|
android:id="@+id/pinEntry"
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_gravity="bottom|center_horizontal"
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
|
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
|
||||||
android:layout_marginBottom="12dp"
|
android:layout_marginBottom="@dimen/keyguard_eca_bottom_margin"
|
||||||
android:gravity="center_horizontal"/>
|
android:gravity="center_horizontal"/>
|
||||||
|
|
||||||
</com.android.keyguard.KeyguardPINView>
|
</com.android.keyguard.KeyguardPINView>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2021, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<resources>
|
||||||
|
<dimen name="num_pad_row_margin_bottom">4dp</dimen>
|
||||||
|
<dimen name="keyguard_eca_top_margin">4dp</dimen>
|
||||||
|
<dimen name="keyguard_eca_bottom_margin">4dp</dimen>
|
||||||
|
<dimen name="keyguard_password_height">50dp</dimen>
|
||||||
|
<dimen name="num_pad_entry_row_margin_bottom">4dp</dimen>
|
||||||
|
</resources>
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
<dimen name="keyguard_security_view_lateral_margin">20dp</dimen>
|
<dimen name="keyguard_security_view_lateral_margin">20dp</dimen>
|
||||||
|
|
||||||
<dimen name="keyguard_eca_top_margin">18dp</dimen>
|
<dimen name="keyguard_eca_top_margin">18dp</dimen>
|
||||||
|
<dimen name="keyguard_eca_bottom_margin">12dp</dimen>
|
||||||
|
|
||||||
<!-- EmergencyCarrierArea overlap - amount to overlap the emergency button and carrier text.
|
<!-- EmergencyCarrierArea overlap - amount to overlap the emergency button and carrier text.
|
||||||
Should be 0 on devices with plenty of room (e.g. tablets) -->
|
Should be 0 on devices with plenty of room (e.g. tablets) -->
|
||||||
@@ -88,6 +89,7 @@
|
|||||||
|
|
||||||
<!-- Spacing around each button used for PIN view -->
|
<!-- Spacing around each button used for PIN view -->
|
||||||
<dimen name="num_pad_key_width">72dp</dimen>
|
<dimen name="num_pad_key_width">72dp</dimen>
|
||||||
|
<dimen name="num_pad_entry_row_margin_bottom">16dp</dimen>
|
||||||
<dimen name="num_pad_row_margin_bottom">6dp</dimen>
|
<dimen name="num_pad_row_margin_bottom">6dp</dimen>
|
||||||
<dimen name="num_pad_key_margin_end">12dp</dimen>
|
<dimen name="num_pad_key_margin_end">12dp</dimen>
|
||||||
|
|
||||||
|
|||||||
@@ -17,16 +17,20 @@
|
|||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import com.android.internal.jank.InteractionJankMonitor;
|
import com.android.internal.jank.InteractionJankMonitor;
|
||||||
import com.android.settingslib.animation.AppearAnimationUtils;
|
import com.android.settingslib.animation.AppearAnimationUtils;
|
||||||
import com.android.settingslib.animation.DisappearAnimationUtils;
|
import com.android.settingslib.animation.DisappearAnimationUtils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a PIN pad for unlocking.
|
* Displays a PIN pad for unlocking.
|
||||||
*/
|
*/
|
||||||
@@ -63,6 +67,11 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
|||||||
R.dimen.disappear_y_translation);
|
R.dimen.disappear_y_translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
updateMargins();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void resetState() {
|
protected void resetState() {
|
||||||
}
|
}
|
||||||
@@ -72,6 +81,33 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
|||||||
return R.id.pinEntry;
|
return R.id.pinEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateMargins() {
|
||||||
|
int bottomMargin = mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.num_pad_row_margin_bottom);
|
||||||
|
|
||||||
|
for (ViewGroup vg : List.of(mRow1, mRow2, mRow3)) {
|
||||||
|
((LinearLayout.LayoutParams) vg.getLayoutParams()).setMargins(0, 0, 0, bottomMargin);
|
||||||
|
}
|
||||||
|
|
||||||
|
bottomMargin = mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.num_pad_entry_row_margin_bottom);
|
||||||
|
((LinearLayout.LayoutParams) mRow0.getLayoutParams()).setMargins(0, 0, 0, bottomMargin);
|
||||||
|
|
||||||
|
if (mEcaView != null) {
|
||||||
|
int ecaTopMargin = mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.keyguard_eca_top_margin);
|
||||||
|
int ecaBottomMargin = mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.keyguard_eca_bottom_margin);
|
||||||
|
((LinearLayout.LayoutParams) mEcaView.getLayoutParams()).setMargins(0, ecaTopMargin,
|
||||||
|
0, ecaBottomMargin);
|
||||||
|
}
|
||||||
|
|
||||||
|
View entryView = findViewById(R.id.pinEntry);
|
||||||
|
ViewGroup.LayoutParams lp = entryView.getLayoutParams();
|
||||||
|
lp.height = mContext.getResources().getDimensionPixelSize(R.dimen.keyguard_password_height);
|
||||||
|
entryView.setLayoutParams(lp);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.android.keyguard;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.RippleDrawable;
|
import android.graphics.drawable.RippleDrawable;
|
||||||
import android.graphics.drawable.VectorDrawable;
|
import android.graphics.drawable.VectorDrawable;
|
||||||
@@ -26,7 +27,6 @@ import android.view.MotionEvent;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.systemui.R;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to the {@link NumPadKey}, but displays an image.
|
* Similar to the {@link NumPadKey}, but displays an image.
|
||||||
@@ -35,6 +35,7 @@ public class NumPadButton extends AlphaOptimizedImageButton {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private NumPadAnimator mAnimator;
|
private NumPadAnimator mAnimator;
|
||||||
|
private int mOrientation;
|
||||||
|
|
||||||
public NumPadButton(Context context, AttributeSet attrs) {
|
public NumPadButton(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -48,6 +49,11 @@ public class NumPadButton extends AlphaOptimizedImageButton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
mOrientation = newConfig.orientation;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
@@ -55,7 +61,10 @@ public class NumPadButton extends AlphaOptimizedImageButton {
|
|||||||
// Set width/height to the same value to ensure a smooth circle for the bg, but shrink
|
// Set width/height to the same value to ensure a smooth circle for the bg, but shrink
|
||||||
// the height to match the old pin bouncer
|
// the height to match the old pin bouncer
|
||||||
int width = getMeasuredWidth();
|
int width = getMeasuredWidth();
|
||||||
int height = mAnimator == null ? (int) (width * .75f) : width;
|
|
||||||
|
boolean shortenHeight = mAnimator == null
|
||||||
|
|| mOrientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
|
int height = shortenHeight ? (int) (width * .66f) : width;
|
||||||
|
|
||||||
setMeasuredDimension(getMeasuredWidth(), height);
|
setMeasuredDimension(getMeasuredWidth(), height);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.RippleDrawable;
|
import android.graphics.drawable.RippleDrawable;
|
||||||
@@ -52,6 +52,7 @@ public class NumPadKey extends ViewGroup {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private NumPadAnimator mAnimator;
|
private NumPadAnimator mAnimator;
|
||||||
|
private int mOrientation;
|
||||||
|
|
||||||
private View.OnClickListener mListener = new View.OnClickListener() {
|
private View.OnClickListener mListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -139,6 +140,11 @@ public class NumPadKey extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
mOrientation = newConfig.orientation;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload colors from resources.
|
* Reload colors from resources.
|
||||||
**/
|
**/
|
||||||
@@ -171,7 +177,10 @@ public class NumPadKey extends ViewGroup {
|
|||||||
// Set width/height to the same value to ensure a smooth circle for the bg, but shrink
|
// Set width/height to the same value to ensure a smooth circle for the bg, but shrink
|
||||||
// the height to match the old pin bouncer
|
// the height to match the old pin bouncer
|
||||||
int width = getMeasuredWidth();
|
int width = getMeasuredWidth();
|
||||||
int height = mAnimator == null ? (int) (width * .75f) : width;
|
|
||||||
|
boolean shortenHeight = mAnimator == null
|
||||||
|
|| mOrientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
|
int height = shortenHeight ? (int) (width * .66f) : width;
|
||||||
|
|
||||||
setMeasuredDimension(getMeasuredWidth(), height);
|
setMeasuredDimension(getMeasuredWidth(), height);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user