From 603ef46adb973dd10d5886fc866144ada33cc068 Mon Sep 17 00:00:00 2001 From: Pedro Amaral Date: Tue, 12 Mar 2019 21:50:37 +0000 Subject: [PATCH] AsyncInitializationActivity#checkOrientation() should check orientation not rotation Previously checkOrientation() would get the new rotation, see if the rotation changed, and if it did call onOrientationChanged() with the new rotation. This is confusing since rotation and orientation mean different things. The only consumer of these onOrientationChanged() events is ToolbarManager#onOrientionChanged() which does two things: 1) ActionModeController#showControlsOnOrientationChange() ActionModeController#showControlsOnOrientationChange() suggests listening to orientation changes is more correct than rotation changes. 2) Update the Duet adaptive toolbar using Configuration#orientation. Listening to orientation changes will fix the adaptive toolbar bugs that are linked. Bug: 938860, 938564, 935348 Change-Id: Icc759d4821b9dd397b0ccc7ea824b143ad474212 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1512934 Reviewed-by: Theresa Commit-Queue: Pedro Amaral Cr-Original-Commit-Position: refs/heads/master@{#639642}(cherry picked from commit fa266cacff34c30936e54f7eaf3e2379136c0161) Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1519090 Reviewed-by: Pedro Amaral Cr-Commit-Position: refs/branch-heads/3729@{#61} Cr-Branched-From: d4a8972e30b604f090aeda5dfff68386ae656267-refs/heads/master@{#638880} --- .../browser/init/AsyncInitializationActivity.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java index ea0973774c02..fa6ca955c869 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java @@ -20,7 +20,6 @@ import android.support.annotation.Nullable; import android.view.Display; import android.view.Menu; -import android.view.Surface; import android.view.View; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnPreDrawListener; @@ -75,7 +74,7 @@ public abstract class AsyncInitializationActivity private ActivityWindowAndroid mWindowAndroid; private ModalDialogManager mModalDialogManager; private Bundle mSavedInstanceState; - private int mCurrentOrientation = Surface.ROTATION_0; + private int mCurrentOrientation; private boolean mDestroyed; private long mLastUserInteractionTime; private boolean mIsTablet; @@ -693,9 +692,8 @@ public long getLastUserInteractionTime() { /** * Called when the orientation of the device changes. The orientation is checked/detected on * root view layouts. - * @param orientation One of {@link Surface#ROTATION_0} (no rotation), - * {@link Surface#ROTATION_90}, {@link Surface#ROTATION_180}, or - * {@link Surface#ROTATION_270}. + * @param orientation One of {@link Configuration#ORIENTATION_PORTRAIT} or + * {@link Configuration#ORIENTATION_LANDSCAPE}. */ protected void onOrientationChange(int orientation) { } @@ -708,7 +706,7 @@ private void checkOrientation() { if (display == null) return; int oldOrientation = mCurrentOrientation; - mCurrentOrientation = display.getRotation(); + mCurrentOrientation = getResources().getConfiguration().orientation; if (oldOrientation != mCurrentOrientation) onOrientationChange(mCurrentOrientation); }