Clean up some redundant logic in the Android tab picker
In StackLayout, which implements the Android tab picker, we currently have two places that implement essentially the same piece of logic for deciding whether a drag event should be interpreted as switching between the two stacks, or closing a tab in the current stack. Besides the redundancy making the code unnecessarily confusing, there are three other problems: - The inline logic in computeInputMode() computes switchDelta using x + dx or y + dy, but isDraggingStackInWrongDirection() uses x or y without the delta term. This introduces a small amount of judder when dragging a tab back and forth between the "swipe to close" and "swipe to change stacks" directions. - isDraggingStackInWrongDirection() always prohibits dragging if the horizontal movement is smaller than the vertical movement...even in landscape mode. This means swiping between stacks barely works in landscape mode (it only works if you put your finger on the other tab to start; this case works because it hits the "currentIndex != getViewportParameters().getStackIndexAt(x, y)" logic earlier in the method. - isDraggingStackInWrongDirection() is broken for RTL mode. This CL makes the code easier to follow and fixes these three problems. Change-Id: Idb507b75f2977859c561a93d13c7737dfd84b97a Reviewed-on: https://chromium-review.googlesource.com/935450Reviewed-by:Matthew Jones <mdjones@chromium.org> Commit-Queue: Ryan Landay <rlanday@chromium.org> Cr-Commit-Position: refs/heads/master@{#539224}
Showing
Please register or sign in to comment