mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Merge "Update recents child views RTL handling" into ub-launcher3-rvc-dev
This commit is contained in:
@@ -58,6 +58,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
|
||||
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<T extends BaseDraggingActivity>
|
||||
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<T extends BaseDraggingActivity>
|
||||
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<T extends BaseDraggingActivity>
|
||||
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<T extends BaseDraggingActivity>
|
||||
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<T extends BaseDraggingActivity>
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1608,7 +1608,12 @@ public abstract class RecentsView<T extends BaseActivity> 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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user