diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher3/BaseActivity.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/BaseDraggingActivity.java | 23 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 20 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 21 |
4 files changed, 58 insertions, 19 deletions
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index a41edc08b..bd38bf00d 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -213,19 +213,6 @@ public abstract class BaseActivity extends Activity { return mForceInvisible != 0; } - /** - * Sets the device profile, adjusting it accordingly in case of multi-window - */ - protected void setDeviceProfile(DeviceProfile dp) { - mDeviceProfile = dp; - if (isInMultiWindowModeCompat()) { - Display display = getWindowManager().getDefaultDisplay(); - Point mwSize = new Point(); - display.getSize(mwSize); - mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); - } - } - public interface MultiWindowModeChangedListener { void onMultiWindowModeChanged(boolean isInMultiWindowMode); } 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 */ diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 4deed73b6..4f9920c5b 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -25,6 +25,8 @@ import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.util.DisplayMetrics; +import android.view.Surface; +import android.view.WindowManager; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.badge.BadgeRenderer; @@ -118,6 +120,7 @@ public class DeviceProfile { private final Rect mInsets = new Rect(); public final Rect workspacePadding = new Rect(); private final Rect mHotseatPadding = new Rect(); + private boolean mIsSeascape; // Icon badges public BadgeRenderer mBadgeRenderer; @@ -519,9 +522,22 @@ public class DeviceProfile { return isLandscape && transposeLayoutWithOrientation; } + /** + * Updates orientation information and returns true if it has changed from the previous value. + */ + public boolean updateIsSeascape(WindowManager wm) { + if (isVerticalBarLayout()) { + boolean isSeascape = wm.getDefaultDisplay().getRotation() == Surface.ROTATION_270; + if (mIsSeascape != isSeascape) { + mIsSeascape = isSeascape; + return true; + } + } + return false; + } + public boolean isSeascape() { - // TODO: This might not hold true for multi window mode, use configuration insead. - return isVerticalBarLayout() && mInsets.left > mInsets.right; + return isVerticalBarLayout() && mIsSeascape; } public boolean shouldFadeAdjacentWorkspaceScreens() { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 9a9e001c3..ca6e97ea0 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -45,6 +45,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.sqlite.SQLiteDatabase; +import android.graphics.Point; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; @@ -57,6 +58,7 @@ import android.text.TextUtils; import android.text.method.TextKeyListener; import android.util.Log; import android.util.SparseArray; +import android.view.Display; import android.view.KeyEvent; import android.view.KeyboardShortcutGroup; import android.view.KeyboardShortcutInfo; @@ -359,9 +361,7 @@ public class Launcher extends BaseDraggingActivity mUserEventDispatcher = null; initDeviceProfile(mDeviceProfile.inv); dispatchDeviceProfileChanged(); - - getRootView().dispatchInsets(); - getStateManager().reapplyState(true /* cancelCurrentAnimation */); + reapplyUi(); // Recreate touch controllers mDragLayer.setup(mDragController); @@ -376,6 +376,12 @@ public class Launcher extends BaseDraggingActivity } @Override + protected void reapplyUi() { + getRootView().dispatchInsets(); + getStateManager().reapplyState(true /* cancelCurrentAnimation */); + } + + @Override public void rebindModel() { int currentPage = mWorkspace.getNextPage(); if (mModel.startLoader(currentPage)) { @@ -386,7 +392,14 @@ public class Launcher extends BaseDraggingActivity private void initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile - setDeviceProfile(idp.getDeviceProfile(this)); + mDeviceProfile = idp.getDeviceProfile(this); + if (isInMultiWindowModeCompat()) { + Display display = getWindowManager().getDefaultDisplay(); + Point mwSize = new Point(); + display.getSize(mwSize); + mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); + } + onDeviceProfileInitiated(); mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout(), true); } |