diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-05-13 18:31:22 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-05-13 18:31:22 +0000 |
commit | 0098e382fb0606d1808c49f68b87bb48905f8833 (patch) | |
tree | 01751787d815d50e6b28f5f8d6c192611474cfe7 /src | |
parent | 06892dcfab2a714e9406f93f89d11b76319b8492 (diff) | |
parent | 7a39b1bc5f544eaebb0e9887362fd96bdd99ca4d (diff) | |
download | android_packages_apps_Trebuchet-0098e382fb0606d1808c49f68b87bb48905f8833.tar.gz android_packages_apps_Trebuchet-0098e382fb0606d1808c49f68b87bb48905f8833.tar.bz2 android_packages_apps_Trebuchet-0098e382fb0606d1808c49f68b87bb48905f8833.zip |
Merge "Fixing insets mapping in 3-button and 2-button mode" into ub-launcher3-qt-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragLayer.java | 24 | ||||
-rw-r--r-- | src/com/android/launcher3/graphics/RotationMode.java | 31 |
4 files changed, 22 insertions, 46 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 417c5a29a..823fb6b0a 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -431,8 +431,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, @Override protected void reapplyUi() { if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) { - mRotationMode = mStableDeviceProfile == null ? RotationMode.NORMAL : - (mDeviceProfile.isSeascape() ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE); + mRotationMode = mStableDeviceProfile == null + ? RotationMode.NORMAL : UiFactory.getRotationMode(mDeviceProfile); } getRootView().dispatchInsets(); getStateManager().reapplyState(true /* cancelCurrentAnimation */); @@ -489,8 +489,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, if (FeatureFlags.FAKE_LANDSCAPE_UI.get() && mDeviceProfile.isVerticalBarLayout() && !mDeviceProfile.isMultiWindowMode) { mStableDeviceProfile = mDeviceProfile.inv.portraitProfile; - mRotationMode = mDeviceProfile.isSeascape() - ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE; + mRotationMode = UiFactory.getRotationMode(mDeviceProfile); } else { mStableDeviceProfile = null; mRotationMode = RotationMode.NORMAL; @@ -503,7 +502,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, public void updateInsets(Rect insets) { mDeviceProfile.updateInsets(insets); if (mStableDeviceProfile != null) { - mStableDeviceProfile.updateInsets(insets); + Rect r = mStableDeviceProfile.getInsets(); + mRotationMode.mapInsets(this, insets, r); + mStableDeviceProfile.updateInsets(r); } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 0f4c42d51..a508ce52b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -302,7 +302,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> rotationMode.mapRect(padding, mTempRect); setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom); - rotationMode.mapRect(insets, mInsets); + rotationMode.mapRect(stableGrid.getInsets(), mInsets); if (mWorkspaceFadeInAdjacentScreens) { // In landscape mode the page spacing is set to the default. diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 8de2f57ee..b35e23ce9 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -638,25 +638,11 @@ public class DragLayer extends BaseDragLayer<Launcher> { final int layoutDirection = getLayoutDirection(); int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection); - int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK; - int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK; if (child instanceof Transposable) { - if (rotation == RotationMode.SEASCAPE) { - if (horizontalGravity == Gravity.RIGHT) { - horizontalGravity = Gravity.LEFT; - } else if (horizontalGravity == Gravity.LEFT) { - horizontalGravity = Gravity.RIGHT; - } - - if (verticalGravity == Gravity.TOP) { - verticalGravity = Gravity.BOTTOM; - } else if (verticalGravity == Gravity.BOTTOM) { - verticalGravity = Gravity.TOP; - } - } + absoluteGravity = rotation.toNaturalGravity(absoluteGravity); - switch (horizontalGravity) { + switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: childTop = (parentHeight - height) / 2 + lp.topMargin - lp.bottomMargin; @@ -669,7 +655,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { childTop = parentHeight - lp.leftMargin - width / 2 - height / 2; } - switch (verticalGravity) { + switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.CENTER_VERTICAL: childLeft = (parentWidth - width) / 2 + lp.leftMargin - lp.rightMargin; @@ -682,7 +668,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { childLeft = height / 2 - width / 2 + lp.topMargin; } } else { - switch (horizontalGravity) { + switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: childLeft = (parentWidth - width) / 2 + lp.leftMargin - lp.rightMargin; @@ -695,7 +681,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { childLeft = lp.leftMargin; } - switch (verticalGravity) { + switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: childTop = lp.topMargin; break; diff --git a/src/com/android/launcher3/graphics/RotationMode.java b/src/com/android/launcher3/graphics/RotationMode.java index 1b2cbdb9f..b06305fc2 100644 --- a/src/com/android/launcher3/graphics/RotationMode.java +++ b/src/com/android/launcher3/graphics/RotationMode.java @@ -15,14 +15,17 @@ */ package com.android.launcher3.graphics; +import android.content.Context; import android.graphics.Rect; public abstract class RotationMode { + public static RotationMode NORMAL = new RotationMode(0) { }; + public final float surfaceRotation; public final boolean isTransposed; - private RotationMode(float surfaceRotation) { + public RotationMode(float surfaceRotation) { this.surfaceRotation = surfaceRotation; isTransposed = surfaceRotation != 0; } @@ -35,25 +38,11 @@ public abstract class RotationMode { out.set(left, top, right, bottom); } - public static RotationMode NORMAL = new RotationMode(0) { }; + public void mapInsets(Context context, Rect insets, Rect out) { + out.set(insets); + } - public static RotationMode LANDSCAPE = new RotationMode(-90) { - @Override - public void mapRect(int left, int top, int right, int bottom, Rect out) { - out.left = top; - out.top = right; - out.right = bottom; - out.bottom = left; - } - }; - - public static RotationMode SEASCAPE = new RotationMode(90) { - @Override - public void mapRect(int left, int top, int right, int bottom, Rect out) { - out.left = bottom; - out.top = left; - out.right = top; - out.bottom = right; - } - }; + public int toNaturalGravity(int absoluteGravity) { + return absoluteGravity; + } } |