Fix landscape to reverse landscape issue
Fingerprint enrollment page needs to display different types of layout for both landscape mode and reverse landscape mode. However onConfigurationChanged doesn't get called when landscape mode rotates to reverse landscape mode directly, that causes it displays a wrong layout in the both landscape and reverse landscape modes. Trying to monitor rotation event and checking if the case that directly turns landscape mode to reverse landscape mode happens, if so, reCreate method will get called to re-lay out the page. There will be a flicker problem happening in re-laying out the page but this solution still works for users to have the correct layout. Fix: 186372522 Test: manual test 1) Navigate to fingerprint enrollment page 2) Rotate the screen from landscape mode to reverse landscape mode 3) Observe the page and see if it has a correct layout Change-Id: Ie94f43a6546f453c10ae9f1c3ba83e1178784950
This commit is contained in:
@@ -36,6 +36,8 @@ import android.os.Vibrator;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
import android.view.OrientationEventListener;
|
||||||
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
@@ -116,6 +118,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
private AccessibilityManager mAccessibilityManager;
|
private AccessibilityManager mAccessibilityManager;
|
||||||
private boolean mIsAccessibilityEnabled;
|
private boolean mIsAccessibilityEnabled;
|
||||||
|
|
||||||
|
private OrientationEventListener mOrientationEventListener;
|
||||||
|
private int mPreviousRotation = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -128,6 +133,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
mAccessibilityManager = getSystemService(AccessibilityManager.class);
|
mAccessibilityManager = getSystemService(AccessibilityManager.class);
|
||||||
mIsAccessibilityEnabled = mAccessibilityManager.isEnabled();
|
mIsAccessibilityEnabled = mAccessibilityManager.isEnabled();
|
||||||
|
|
||||||
|
listenOrientationEvent();
|
||||||
|
|
||||||
if (mCanAssumeUdfps) {
|
if (mCanAssumeUdfps) {
|
||||||
if (BiometricUtils.isReverseLandscape(getApplicationContext())) {
|
if (BiometricUtils.isReverseLandscape(getApplicationContext())) {
|
||||||
setContentView(R.layout.udfps_enroll_enrolling_land);
|
setContentView(R.layout.udfps_enroll_enrolling_land);
|
||||||
@@ -255,6 +262,12 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
stopIconAnimation();
|
stopIconAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
stopListenOrientationEvent();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
private void animateProgress(int progress) {
|
private void animateProgress(int progress) {
|
||||||
if (mCanAssumeUdfps) {
|
if (mCanAssumeUdfps) {
|
||||||
// UDFPS animations are owned by SystemUI
|
// UDFPS animations are owned by SystemUI
|
||||||
@@ -451,6 +464,31 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void listenOrientationEvent() {
|
||||||
|
mOrientationEventListener = new OrientationEventListener(this) {
|
||||||
|
@Override
|
||||||
|
public void onOrientationChanged(int orientation) {
|
||||||
|
final int currentRotation = getDisplay().getRotation();
|
||||||
|
if ((mPreviousRotation == Surface.ROTATION_90
|
||||||
|
&& currentRotation == Surface.ROTATION_270) || (
|
||||||
|
mPreviousRotation == Surface.ROTATION_270
|
||||||
|
&& currentRotation == Surface.ROTATION_90)) {
|
||||||
|
mPreviousRotation = currentRotation;
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mOrientationEventListener.enable();
|
||||||
|
mPreviousRotation = getDisplay().getRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopListenOrientationEvent() {
|
||||||
|
if (mOrientationEventListener != null) {
|
||||||
|
mOrientationEventListener.disable();
|
||||||
|
}
|
||||||
|
mOrientationEventListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
private final Animator.AnimatorListener mProgressAnimationListener
|
private final Animator.AnimatorListener mProgressAnimationListener
|
||||||
= new Animator.AnimatorListener() {
|
= new Animator.AnimatorListener() {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user