Skip to content

Commit 603ef46

Browse files
author
Pedro Amaral
committed
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 <[email protected]> Commit-Queue: Pedro Amaral <[email protected]> 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 <[email protected]> Cr-Commit-Position: refs/branch-heads/3729@{#61} Cr-Branched-From: d4a8972-refs/heads/master@{#638880}
1 parent add6db5 commit 603ef46

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import android.support.annotation.Nullable;
2121
import android.view.Display;
2222
import android.view.Menu;
23-
import android.view.Surface;
2423
import android.view.View;
2524
import android.view.ViewTreeObserver;
2625
import android.view.ViewTreeObserver.OnPreDrawListener;
@@ -75,7 +74,7 @@ public abstract class AsyncInitializationActivity
7574
private ActivityWindowAndroid mWindowAndroid;
7675
private ModalDialogManager mModalDialogManager;
7776
private Bundle mSavedInstanceState;
78-
private int mCurrentOrientation = Surface.ROTATION_0;
77+
private int mCurrentOrientation;
7978
private boolean mDestroyed;
8079
private long mLastUserInteractionTime;
8180
private boolean mIsTablet;
@@ -693,9 +692,8 @@ public long getLastUserInteractionTime() {
693692
/**
694693
* Called when the orientation of the device changes. The orientation is checked/detected on
695694
* root view layouts.
696-
* @param orientation One of {@link Surface#ROTATION_0} (no rotation),
697-
* {@link Surface#ROTATION_90}, {@link Surface#ROTATION_180}, or
698-
* {@link Surface#ROTATION_270}.
695+
* @param orientation One of {@link Configuration#ORIENTATION_PORTRAIT} or
696+
* {@link Configuration#ORIENTATION_LANDSCAPE}.
699697
*/
700698
protected void onOrientationChange(int orientation) {
701699
}
@@ -708,7 +706,7 @@ private void checkOrientation() {
708706
if (display == null) return;
709707

710708
int oldOrientation = mCurrentOrientation;
711-
mCurrentOrientation = display.getRotation();
709+
mCurrentOrientation = getResources().getConfiguration().orientation;
712710

713711
if (oldOrientation != mCurrentOrientation) onOrientationChange(mCurrentOrientation);
714712
}

0 commit comments

Comments
 (0)