diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-05-07 17:31:40 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-05-07 17:32:46 -0700 |
commit | 59d086c3ce5d9c3d800abca73762e82f2489cbec (patch) | |
tree | a6ced495cc09f81894133b54aabd2ec87af976da /src/com/android/launcher3/BaseDraggingActivity.java | |
parent | c247a00e22d248ce7b1be492792d6f237ea64316 (diff) | |
download | android_packages_apps_Trebuchet-59d086c3ce5d9c3d800abca73762e82f2489cbec.tar.gz android_packages_apps_Trebuchet-59d086c3ce5d9c3d800abca73762e82f2489cbec.tar.bz2 android_packages_apps_Trebuchet-59d086c3ce5d9c3d800abca73762e82f2489cbec.zip |
Using surface rotation instead of insets to determine seascape configuration
Insets may not correctly indicate seascape configuration in multi-window or
when the presence of device-cutouts
Bug: 79376298
Change-Id: I8268efca0001fe527a0ffefe48cc71e774fad01c
Diffstat (limited to 'src/com/android/launcher3/BaseDraggingActivity.java')
-rw-r--r-- | src/com/android/launcher3/BaseDraggingActivity.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index 1400432c9..e47dbe535 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -28,12 +28,14 @@ import android.os.StrictMode; import android.os.UserHandle; import android.util.Log; import android.view.ActionMode; +import android.view.Surface; import android.view.View; import android.widget.Toast; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.badge.BadgeInfo; import com.android.launcher3.compat.LauncherAppsCompat; +import com.android.launcher3.uioverrides.DisplayRotationListener; import com.android.launcher3.uioverrides.WallpaperColorInfo; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.views.BaseDragLayer; @@ -61,10 +63,13 @@ public abstract class BaseDraggingActivity extends BaseActivity private int mThemeRes = R.style.LauncherTheme; + private DisplayRotationListener mRotationListener; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mIsSafeModeEnabled = getPackageManager().isSafeMode(); + mRotationListener = new DisplayRotationListener(this, this::onDeviceRotationChanged); // Update theme WallpaperColorInfo wallpaperColorInfo = WallpaperColorInfo.getInstance(this); @@ -237,12 +242,30 @@ public abstract class BaseDraggingActivity extends BaseActivity protected void onDestroy() { super.onDestroy(); WallpaperColorInfo.getInstance(this).removeOnChangeListener(this); + mRotationListener.disable(); } public <T extends BaseDraggingActivity> void setOnStartCallback(OnStartCallback<T> callback) { mOnStartCallback = callback; } + protected void onDeviceProfileInitiated() { + if (mDeviceProfile.isVerticalBarLayout()) { + mRotationListener.enable(); + mDeviceProfile.updateIsSeascape(getWindowManager()); + } else { + mRotationListener.disable(); + } + } + + private void onDeviceRotationChanged() { + if (mDeviceProfile.updateIsSeascape(getWindowManager())) { + reapplyUi(); + } + } + + protected abstract void reapplyUi(); + /** * Callback for listening for onStart */ |