Fixing insets mapping in 3-button and 2-button mode
Bug: 131360075 Change-Id: If6e3a4fbb011fc313efeb91686a9d787761862c5
This commit is contained in:
@@ -21,10 +21,12 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.LandscapeStatesTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
|
||||
@@ -102,4 +104,8 @@ public abstract class RecentsUiFactory {
|
||||
* @param launcher the launcher activity
|
||||
*/
|
||||
public static void onLauncherStateOrResumeChanged(Launcher launcher) {}
|
||||
|
||||
public static RotationMode getRotationMode(DeviceProfile dp) {
|
||||
return RotationMode.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
+79
-2
@@ -20,6 +20,11 @@ import static android.view.View.VISIBLE;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.Gravity;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
@@ -28,6 +33,7 @@ import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.FlingAndHoldTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.NavBarToHomeTouchController;
|
||||
@@ -58,12 +64,83 @@ public abstract class RecentsUiFactory {
|
||||
// Scale recents takes before animating in
|
||||
private static final float RECENTS_PREPARE_SCALE = 1.33f;
|
||||
|
||||
public static RotationMode ROTATION_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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapInsets(Context context, Rect insets, Rect out) {
|
||||
if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
|
||||
out.set(insets);
|
||||
} else {
|
||||
out.top = Math.max(insets.top, insets.left);
|
||||
out.bottom = insets.right;
|
||||
out.left = insets.bottom;
|
||||
out.right = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static RotationMode ROTATION_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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapInsets(Context context, Rect insets, Rect out) {
|
||||
if (SysUINavigationMode.getMode(context) == NO_BUTTON) {
|
||||
out.set(insets);
|
||||
} else {
|
||||
out.top = Math.max(insets.top, insets.right);
|
||||
out.bottom = insets.left;
|
||||
out.right = insets.bottom;
|
||||
out.left = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toNaturalGravity(int absoluteGravity) {
|
||||
int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return ((absoluteGravity & ~Gravity.HORIZONTAL_GRAVITY_MASK)
|
||||
& ~Gravity.VERTICAL_GRAVITY_MASK)
|
||||
| horizontalGravity | verticalGravity;
|
||||
}
|
||||
};
|
||||
|
||||
public static RotationMode getRotationMode(DeviceProfile dp) {
|
||||
return !dp.isVerticalBarLayout() ? RotationMode.NORMAL
|
||||
: (dp.isSeascape() ? ROTATION_SEASCAPE : ROTATION_LANDSCAPE);
|
||||
}
|
||||
|
||||
public static TouchController[] createTouchControllers(Launcher launcher) {
|
||||
Mode mode = SysUINavigationMode.getMode(launcher);
|
||||
|
||||
ArrayList<TouchController> list = new ArrayList<>();
|
||||
list.add(launcher.getDragController());
|
||||
if (mode == Mode.NO_BUTTON) {
|
||||
if (mode == NO_BUTTON) {
|
||||
list.add(new QuickSwitchTouchController(launcher));
|
||||
list.add(new NavBarToHomeTouchController(launcher));
|
||||
list.add(new FlingAndHoldTouchController(launcher));
|
||||
@@ -106,7 +183,7 @@ public abstract class RecentsUiFactory {
|
||||
* @param launcher the launcher activity
|
||||
*/
|
||||
public static void prepareToShowOverview(Launcher launcher) {
|
||||
if (SysUINavigationMode.getMode(launcher) == Mode.NO_BUTTON) {
|
||||
if (SysUINavigationMode.getMode(launcher) == NO_BUTTON) {
|
||||
// Overview lives on the side, so doesn't scale in from above.
|
||||
return;
|
||||
}
|
||||
|
||||
+4
-2
@@ -22,6 +22,8 @@ import static android.view.MotionEvent.ACTION_POINTER_UP;
|
||||
import static android.view.MotionEvent.ACTION_UP;
|
||||
import static android.view.MotionEvent.INVALID_POINTER_ID;
|
||||
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
|
||||
import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_LANDSCAPE;
|
||||
import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_SEASCAPE;
|
||||
import static com.android.launcher3.util.RaceConditionTracker.ENTER;
|
||||
import static com.android.launcher3.util.RaceConditionTracker.EXIT;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
@@ -171,8 +173,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
&& !mRecentsViewDispatcher.hasConsumer()) {
|
||||
mRecentsViewDispatcher.setConsumer(mInteractionHandler.getRecentsViewDispatcher(
|
||||
isNavBarOnLeft()
|
||||
? RotationMode.SEASCAPE
|
||||
: (isNavBarOnRight() ? RotationMode.LANDSCAPE : RotationMode.NORMAL)));
|
||||
? ROTATION_SEASCAPE
|
||||
: (isNavBarOnRight() ? ROTATION_LANDSCAPE : RotationMode.NORMAL)));
|
||||
}
|
||||
int edgeFlags = ev.getEdgeFlags();
|
||||
ev.setEdgeFlags(edgeFlags | EDGE_NAV_BAR);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
absoluteGravity = rotation.toNaturalGravity(absoluteGravity);
|
||||
|
||||
if (verticalGravity == Gravity.TOP) {
|
||||
verticalGravity = Gravity.BOTTOM;
|
||||
} else if (verticalGravity == Gravity.BOTTOM) {
|
||||
verticalGravity = Gravity.TOP;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.CancellationSignal;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherState.ScaleAndTranslation;
|
||||
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -73,4 +75,8 @@ public class UiFactory {
|
||||
public static ScaleAndTranslation getOverviewScaleAndTranslationForNormalState(Launcher l) {
|
||||
return new ScaleAndTranslation(1.1f, 0f, 0f);
|
||||
}
|
||||
|
||||
public static RotationMode getRotationMode(DeviceProfile dp) {
|
||||
return RotationMode.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user