mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 01:16:49 +00:00
Using Display listener for landscape/seascape changes
Bug: 146150882 Change-Id: Idd2ef053bd10d9add93a1366e49c0e231f2c391b
This commit is contained in:
@@ -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.LauncherSettings.Favorites;
|
||||
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 @@ import com.android.launcher3.util.TraceHelper;
|
||||
* 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 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
|
||||
private int mThemeRes = R.style.AppTheme;
|
||||
|
||||
private DisplayRotationListener mRotationListener;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -72,7 +74,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
|
||||
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 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
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 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user