Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9613f676d7
2 changed files with 62 additions and 2 deletions
|
@ -18,8 +18,6 @@ import android.view.VelocityTracker;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
@ -47,6 +45,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
|
|||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
|
||||
import net.osmand.plus.views.controls.SingleTapConfirm;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -241,6 +240,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
runLayoutListener();
|
||||
|
||||
final GestureDetector singleTapDetector = new GestureDetector(view.getContext(), new SingleTapConfirm());
|
||||
final GestureDetector swipeDetector = new GestureDetector(view.getContext(), new HorizontalSwipeConfirm(true));
|
||||
|
||||
final View.OnTouchListener slideTouchListener = new View.OnTouchListener() {
|
||||
private float dy;
|
||||
|
@ -285,6 +285,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
|
||||
if (menu.isLandscapeLayout()) {
|
||||
if (swipeDetector.onTouchEvent(event)) {
|
||||
menu.close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package net.osmand.plus.views.controls;
|
||||
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
public class HorizontalSwipeConfirm implements GestureDetector.OnGestureListener {
|
||||
|
||||
private static final int SWIPE_MIN_DISTANCE = 120;
|
||||
private static final int SWIPE_MAX_OFF_PATH = 250;
|
||||
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
|
||||
|
||||
private boolean rightToLeftSwipe;
|
||||
|
||||
public HorizontalSwipeConfirm(boolean rightToLeftSwipe) {
|
||||
this.rightToLeftSwipe = rightToLeftSwipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDown(MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowPress(MotionEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
|
||||
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
|
||||
return false;
|
||||
}
|
||||
// right to left swipe
|
||||
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
|
||||
return rightToLeftSwipe;
|
||||
}
|
||||
// left to right swipe
|
||||
else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
|
||||
return !rightToLeftSwipe;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue