Using Display listener for landscape/seascape changes
Bug: 146150882
Change-Id: Idd2ef053bd10d9add93a1366e49c0e231f2c391b
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index dda38b3..0d9126b 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -16,6 +16,8 @@
package com.android.launcher3;
+import static com.android.launcher3.util.DefaultDisplay.CHANGE_ROTATION;
+
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Intent;
@@ -38,8 +40,10 @@
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.touch.ItemClickHandler;
-import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
+import com.android.launcher3.util.DefaultDisplay;
+import com.android.launcher3.util.DefaultDisplay.DisplayInfoChangeListener;
+import com.android.launcher3.util.DefaultDisplay.Info;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.TraceHelper;
@@ -48,7 +52,7 @@
* Extension of BaseActivity allowing support for drag-n-drop
*/
public abstract class BaseDraggingActivity extends BaseActivity
- implements WallpaperColorInfo.OnChangeListener {
+ implements WallpaperColorInfo.OnChangeListener, DisplayInfoChangeListener {
private static final String TAG = "BaseDraggingActivity";
@@ -63,8 +67,6 @@
private int mThemeRes = R.style.AppTheme;
- private DisplayRotationListener mRotationListener;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -72,7 +74,7 @@
mIsSafeModeEnabled = TraceHelper.whitelistIpcs("isSafeMode",
() -> getPackageManager().isSafeMode());
- mRotationListener = new DisplayRotationListener(this, this::onDeviceRotationChanged);
+ DefaultDisplay.INSTANCE.get(this).addChangeListener(this);
// Update theme
WallpaperColorInfo.INSTANCE.get(this).addOnChangeListener(this);
@@ -238,7 +240,7 @@
protected void onDestroy() {
super.onDestroy();
WallpaperColorInfo.INSTANCE.get(this).removeOnChangeListener(this);
- mRotationListener.disable();
+ DefaultDisplay.INSTANCE.get(this).removeChangeListener(this);
}
public void runOnceOnStart(Runnable action) {
@@ -251,15 +253,13 @@
protected void onDeviceProfileInitiated() {
if (mDeviceProfile.isVerticalBarLayout()) {
- mRotationListener.enable();
mDeviceProfile.updateIsSeascape(this);
- } else {
- mRotationListener.disable();
}
}
- private void onDeviceRotationChanged() {
- if (mDeviceProfile.updateIsSeascape(this)) {
+ @Override
+ public void onDisplayInfoChanged(Info info, int flags) {
+ if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.updateIsSeascape(this)) {
reapplyUi();
}
}