Skip to content

Commit

Permalink
AsyncInitializationActivity#checkOrientation() should check orientati…
Browse files Browse the repository at this point in the history
…on 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}
  • Loading branch information
Pedro Amaral committed Mar 12, 2019
1 parent add6db5 commit 603ef46
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 603ef46

Please sign in to comment.