mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Merge "Prevent x-axis window movement during the initial swipe up to show transient taskbar" into tm-qpr-dev
This commit is contained in:
@@ -289,6 +289,8 @@
|
||||
<dimen name="transient_taskbar_key_shadow_distance">10dp</dimen>
|
||||
<dimen name="transient_taskbar_stashed_size">32dp</dimen>
|
||||
<dimen name="transient_taskbar_icon_spacing">10dp</dimen>
|
||||
<!-- An additional touch slop to prevent x-axis movement during the swipe up to show taskbar -->
|
||||
<dimen name="transient_taskbar_clamped_offset_bound">16dp</dimen>
|
||||
<!-- Taskbar swipe up thresholds -->
|
||||
<dimen name="taskbar_app_window_threshold">150dp</dimen>
|
||||
<dimen name="taskbar_home_overview_threshold">225dp</dimen>
|
||||
|
||||
@@ -755,6 +755,21 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not we should clamp the scroll offset.
|
||||
* This is used to avoid x-axis movement when swiping up transient taskbar.
|
||||
* @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is
|
||||
* met.
|
||||
*/
|
||||
public void setClampScrollOffset(boolean clampScrollOffset) {
|
||||
if (mRecentsView == null) {
|
||||
mStateCallback.runOnceAtState(STATE_LAUNCHER_PRESENT,
|
||||
() -> mRecentsView.setClampScrollOffset(clampScrollOffset));
|
||||
return;
|
||||
}
|
||||
mRecentsView.setClampScrollOffset(clampScrollOffset);
|
||||
}
|
||||
|
||||
public void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask) {
|
||||
setIsLikelyToStartNewTask(
|
||||
isLikelyToStartNewTask,
|
||||
|
||||
@@ -378,6 +378,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
mInteractionHandler.onGestureStarted(isLikelyToStartNewTask);
|
||||
|
||||
mInteractionHandler.setTaskbarAlreadyOpen(mTaskbarAlreadyOpen);
|
||||
if (mIsTransientTaskbar && !mTaskbarAlreadyOpen && !isLikelyToStartNewTask) {
|
||||
mInteractionHandler.setClampScrollOffset(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void startTouchTrackingForWindowAnimation(long touchTimeMs) {
|
||||
@@ -473,6 +476,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
@UiThread
|
||||
private void onInteractionGestureFinished() {
|
||||
Preconditions.assertUIThread();
|
||||
if (mInteractionHandler != null) {
|
||||
mInteractionHandler.setClampScrollOffset(false);
|
||||
}
|
||||
removeListener();
|
||||
mInteractionHandler = null;
|
||||
cleanupAfterGesture();
|
||||
|
||||
@@ -498,6 +498,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
private boolean mOverviewFullscreenEnabled;
|
||||
private boolean mOverviewSelectEnabled;
|
||||
|
||||
private boolean mShouldClampScrollOffset;
|
||||
private int mClampedScrollOffsetBound;
|
||||
|
||||
private float mAdjacentPageHorizontalOffset = 0;
|
||||
protected float mTaskViewsSecondaryTranslation = 0;
|
||||
protected float mTaskViewsPrimarySplitTranslation = 0;
|
||||
@@ -752,6 +755,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
mSplitPlaceholderInset = getResources().getDimensionPixelSize(
|
||||
R.dimen.split_placeholder_inset);
|
||||
mSquaredTouchSlop = squaredTouchSlop(context);
|
||||
mClampedScrollOffsetBound = getResources().getDimensionPixelSize(
|
||||
R.dimen.transient_taskbar_clamped_offset_bound);
|
||||
|
||||
mEmptyIcon = context.getDrawable(R.drawable.ic_empty_recents);
|
||||
mEmptyIcon.setCallback(this);
|
||||
@@ -5054,10 +5059,36 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
|
||||
return getScrollOffset(getRunningTaskIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not we should clamp the scroll offset.
|
||||
* This is used to avoid x-axis movement when swiping up transient taskbar.
|
||||
* Should only be set at the beginning and end of the gesture, otherwise a jump may occur.
|
||||
* @param clampScrollOffset When true, we clamp the scroll to 0 before the clamp threshold is
|
||||
* met.
|
||||
*/
|
||||
public void setClampScrollOffset(boolean clampScrollOffset) {
|
||||
mShouldClampScrollOffset = clampScrollOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how many pixels the page is offset on the currently laid out dominant axis.
|
||||
*/
|
||||
public int getScrollOffset(int pageIndex) {
|
||||
int unboundedOffset = getUnclampedScrollOffset(pageIndex);
|
||||
if (!mShouldClampScrollOffset) {
|
||||
return unboundedOffset;
|
||||
}
|
||||
if (Math.abs(unboundedOffset) < mClampedScrollOffsetBound) {
|
||||
return 0;
|
||||
}
|
||||
return unboundedOffset
|
||||
- Math.round(Math.signum(unboundedOffset) * mClampedScrollOffsetBound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns how many pixels the page is offset on the currently laid out dominant axis.
|
||||
*/
|
||||
private int getUnclampedScrollOffset(int pageIndex) {
|
||||
if (pageIndex == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -368,6 +368,7 @@
|
||||
<dimen name="transient_taskbar_shadow_blur">0dp</dimen>
|
||||
<dimen name="transient_taskbar_key_shadow_distance">0dp</dimen>
|
||||
<dimen name="transient_taskbar_stashed_size">0dp</dimen>
|
||||
<dimen name="transient_taskbar_clamped_offset_bound">0dp</dimen>
|
||||
<!-- Note that this applies to both sides of all icons, so visible space is double this. -->
|
||||
<dimen name="transient_taskbar_icon_spacing">0dp</dimen>
|
||||
<!-- Note that this applies to both sides of all icons, so visible space is double this. -->
|
||||
|
||||
Reference in New Issue
Block a user