Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Added ability to scroll Tab groups bar icons on swipe #11939

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ public class BraveScrollingBottomViewResourceFrameLayout
View mBottomToolbar;
View mBottomContainerSlot;

private class SwipeGestureListenerImpl extends SwipeGestureListener {
public SwipeGestureListenerImpl(Context context, SwipeHandler handler) {
super(context, handler);
}

@Override
public boolean shouldRecognizeSwipe(MotionEvent e1, MotionEvent e2) {
int x = Math.round(e1.getX());
int y = Math.round(e1.getY());
if (x > mBottomToolbar.getLeft() && x < mBottomToolbar.getRight()
&& y > mBottomToolbar.getTop() && y < mBottomToolbar.getBottom()) {
// Only handle swipe on bottom toolbar itself.
return true;
}
return false;
}
}

public BraveScrollingBottomViewResourceFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mCallbackController = new CallbackController();
Expand All @@ -51,7 +69,7 @@ protected void onFinishInflate() {
* @param handler A handler for swipe events on this view.
*/
public void setSwipeDetector(SwipeHandler handler) {
mSwipeGestureListener = new SwipeGestureListener(getContext(), handler);
mSwipeGestureListener = new SwipeGestureListenerImpl(getContext(), handler);

// TODO(mdjones): This line of code makes it impossible to scroll through the bottom
// toolbar. If the user accidentally swipes up on this view, the scroll no longer goes
Expand Down