diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java index 1f3b82cd98..0ee5d047c6 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java @@ -58,6 +58,7 @@ public abstract class TaskViewTouchController private final SingleAxisSwipeDetector mDetector; private final RecentsView mRecentsView; private final int[] mTempCords = new int[2]; + private final boolean mIsRtl; private PendingAnimation mPendingAnimation; private AnimatorPlaybackController mCurrentAnimation; @@ -75,6 +76,7 @@ public abstract class TaskViewTouchController public TaskViewTouchController(T activity) { mActivity = activity; mRecentsView = activity.getOverviewPanel(); + mIsRtl = Utilities.isRtl(activity.getResources()); SingleAxisSwipeDetector.Direction dir = mRecentsView.getPagedOrientationHandler().getOppositeSwipeDirection(); mDetector = new SingleAxisSwipeDetector(activity, this, dir); @@ -201,8 +203,8 @@ public abstract class TaskViewTouchController mCurrentAnimationIsGoingUp = goingUp; BaseDragLayer dl = mActivity.getDragLayer(); final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl); - long maxDuration = (long) (2 * secondaryLayerDimension); - int verticalFactor = -orientationHandler.getTaskDismissDirectionFactor(); + long maxDuration = 2 * secondaryLayerDimension; + int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl); int secondaryTaskDimension = orientationHandler.getSecondaryDimension(mTaskBeingDragged); if (goingUp) { mPendingAnimation = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, @@ -236,7 +238,7 @@ public abstract class TaskViewTouchController public void onDragStart(boolean start, float startDisplacement) { PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler(); if (mCurrentAnimation == null) { - reInitAnimationController(orientationHandler.isGoingUp(startDisplacement)); + reInitAnimationController(orientationHandler.isGoingUp(startDisplacement, mIsRtl)); mDisplacementShift = 0; } else { mDisplacementShift = mCurrentAnimation.getProgressFraction() / mProgressMultiplier; @@ -250,7 +252,7 @@ public abstract class TaskViewTouchController PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler(); float totalDisplacement = displacement + mDisplacementShift; boolean isGoingUp = totalDisplacement == 0 ? mCurrentAnimationIsGoingUp : - orientationHandler.isGoingUp(totalDisplacement); + orientationHandler.isGoingUp(totalDisplacement, mIsRtl); if (isGoingUp != mCurrentAnimationIsGoingUp) { reInitAnimationController(isGoingUp); mFlingBlockCheck.blockFling(); @@ -282,7 +284,7 @@ public abstract class TaskViewTouchController float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress(); if (fling) { logAction = Touch.FLING; - boolean goingUp = orientationHandler.isGoingUp(velocity); + boolean goingUp = orientationHandler.isGoingUp(velocity, mIsRtl); goingToEnd = goingUp == mCurrentAnimationIsGoingUp; } else { logAction = Touch.SWIPE; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/ClearAllButton.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/ClearAllButton.java index 1018211ed2..2c85618361 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/ClearAllButton.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/ClearAllButton.java @@ -64,7 +64,13 @@ public class ClearAllButton extends Button implements PageCallbacks { protected void onAttachedToWindow() { super.onAttachedToWindow(); mParent = (RecentsView) getParent(); - mIsRtl = !mParent.getPagedOrientationHandler().getRecentsRtlSetting(getResources()); + mIsRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; + } + + @Override + public void onRtlPropertiesChanged(int layoutDirection) { + super.onRtlPropertiesChanged(layoutDirection); + mIsRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; } @Override diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index bf9119e02b..54ed40f3e9 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -1608,7 +1608,12 @@ public abstract class RecentsView extends PagedView impl if (mOrientationState.update(touchRotation, displayRotation)) { mOrientationHandler = mOrientationState.getOrientationHandler(); mIsRtl = mOrientationHandler.getRecentsRtlSetting(getResources()); - setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR); + setLayoutDirection(mIsRtl + ? View.LAYOUT_DIRECTION_RTL + : View.LAYOUT_DIRECTION_LTR); + mClearAllButton.setLayoutDirection(mIsRtl + ? View.LAYOUT_DIRECTION_LTR + : View.LAYOUT_DIRECTION_RTL); mClearAllButton.setRotation(mOrientationHandler.getDegreesRotated()); mActivity.getDragLayer().recreateControllers(); mActionsView.updateHiddenFlags(HIDDEN_NON_ZERO_ROTATION, diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index da9468ed38..6b759ba43a 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -449,13 +449,13 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { public void setOrientationState(RecentsOrientedState orientationState) { PagedOrientationHandler orientationHandler = orientationState.getOrientationHandler(); - boolean isRtl = orientationHandler.getRecentsRtlSetting(getResources()); + boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; LayoutParams snapshotParams = (LayoutParams) mSnapshotView.getLayoutParams(); int thumbnailPadding = (int) getResources().getDimension(R.dimen.task_thumbnail_top_margin); LayoutParams iconParams = (LayoutParams) mIconView.getLayoutParams(); switch (orientationHandler.getRotation()) { case Surface.ROTATION_90: - iconParams.gravity = (isRtl ? END : START) | CENTER_VERTICAL; + iconParams.gravity = (isRtl ? START : END) | CENTER_VERTICAL; iconParams.rightMargin = -thumbnailPadding; iconParams.leftMargin = 0; iconParams.topMargin = snapshotParams.topMargin / 2; diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 5007ca0ae9..d02c731de3 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -33,7 +33,6 @@ import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.widget.LinearLayout; -import com.android.launcher3.DeviceProfile; import com.android.launcher3.PagedView; import com.android.launcher3.Utilities; import com.android.launcher3.util.OverScroller; @@ -74,8 +73,8 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { } @Override - public boolean isGoingUp(float displacement) { - return displacement > 0; + public boolean isGoingUp(float displacement, boolean isRtl) { + return isRtl ? displacement < 0 : displacement > 0; } @Override @@ -226,13 +225,13 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { } @Override - public int getShortEdgeLength(DeviceProfile dp) { - return dp.heightPx; + public int getTaskDismissDirectionFactor() { + return 1; } @Override - public int getTaskDismissDirectionFactor() { - return 1; + public int getTaskDragDisplacementFactor(boolean isRtl) { + return isRtl ? 1 : -1; } @Override diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index cdfe6d5a12..2e0268dc79 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -75,8 +75,8 @@ public interface PagedOrientationHandler { int getScrollOffsetStart(View view, Rect insets); int getScrollOffsetEnd(View view, Rect insets); SingleAxisSwipeDetector.Direction getOppositeSwipeDirection(); - int getShortEdgeLength(DeviceProfile dp); int getTaskDismissDirectionFactor(); + int getTaskDragDisplacementFactor(boolean isRtl); ChildBounds getChildBounds(View child, int childStart, int pageCenter, boolean layoutChild); void setMaxScroll(AccessibilityEvent event, int maxScroll); boolean getRecentsRtlSetting(Resources resources); @@ -91,7 +91,7 @@ public interface PagedOrientationHandler { void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y); void scrollerStartScroll(OverScroller scroller, int newPosition); void getCurveProperties(PagedView view, Rect insets, CurveProperties out); - boolean isGoingUp(float displacement); + boolean isGoingUp(float displacement, boolean isRtl); boolean isLayoutNaturalToLauncher(); float getTaskMenuX(float x, View thumbnailView); float getTaskMenuY(float y, View thumbnailView); diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 25dc1f6ca0..2fc7a9f40e 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -32,7 +32,6 @@ import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.widget.LinearLayout; -import com.android.launcher3.DeviceProfile; import com.android.launcher3.PagedView; import com.android.launcher3.Utilities; import com.android.launcher3.util.OverScroller; @@ -73,7 +72,8 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } @Override - public boolean isGoingUp(float displacement) { + public boolean isGoingUp(float displacement, boolean isRtl) { + // Ignore rtl since it only affects X value displacement, Y displacement doesn't change return displacement < 0; } @@ -223,13 +223,14 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } @Override - public int getShortEdgeLength(DeviceProfile dp) { - return dp.widthPx; + public int getTaskDismissDirectionFactor() { + return -1; } @Override - public int getTaskDismissDirectionFactor() { - return -1; + public int getTaskDragDisplacementFactor(boolean isRtl) { + // Ignore rtl since it only affects X value displacement, Y displacement doesn't change + return 1; } @Override diff --git a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java index dde2829859..4c1700ee9a 100644 --- a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java @@ -31,6 +31,11 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler { return -1; } + @Override + public int getTaskDragDisplacementFactor(boolean isRtl) { + return isRtl ? -1 : 1; + } + @Override public boolean getRecentsRtlSetting(Resources resources) { return Utilities.isRtl(resources); @@ -60,8 +65,8 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler { } @Override - public boolean isGoingUp(float displacement) { - return displacement < 0; + public boolean isGoingUp(float displacement, boolean isRtl) { + return isRtl ? displacement > 0 : displacement < 0; } @Override @@ -81,14 +86,9 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler { return y + thumbnailView.getMeasuredHeight(); } - @Override - public int getClearAllScrollOffset(View view, boolean isRtl) { - return (isRtl ? view.getPaddingTop() : - view.getPaddingBottom()) / 2; - } - @Override public void setPrimaryAndResetSecondaryTranslate(View view, float translation) { view.setTranslationX(0); - view.setTranslationY(-translation); + view.setTranslationY(translation); } }