Prevent swipe right/left in WebView

This commit is contained in:
M66B
2019-04-26 10:04:50 +02:00
parent 48d5392b3b
commit 1e4a29d2a4
2 changed files with 28 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.SeekBar;
@@ -993,18 +994,39 @@ public class FragmentMessages extends FragmentBase {
private SwipeListener swipeListener = new SwipeListener(getContext(), new SwipeListener.ISwipeListener() {
@Override
public boolean onSwipeRight() {
public boolean onSwipeRight(MotionEvent me) {
if (inWebView(me))
return false;
if (previous != null)
navigate(previous, true);
return (previous != null);
}
@Override
public boolean onSwipeLeft() {
public boolean onSwipeLeft(MotionEvent me) {
if (inWebView(me))
return false;
if (next != null)
navigate(next, false);
return (next != null);
}
private boolean inWebView(MotionEvent me) {
View parent = rvMessage.findChildViewUnder(me.getX(), me.getY());
if (parent == null)
return false;
View child = parent.findViewById(R.id.vwBody);
if (!(child instanceof WebView))
return false;
int[] location = new int[2];
child.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
return (me.getRawX() >= x && me.getRawX() <= x + view.getWidth() &&
me.getRawY() >= y && me.getRawY() <= y + view.getHeight());
}
});
private void onActionMove(String folderType) {