Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-09-17 15:40:46 +02:00
commit 2e40e0682c
2 changed files with 54 additions and 1 deletions

View file

@ -5,11 +5,14 @@ import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.PointF;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.VelocityTracker; import android.view.VelocityTracker;
@ -22,11 +25,13 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.sections.MenuController; import net.osmand.plus.mapcontextmenu.sections.MenuController;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -57,6 +62,41 @@ public class MapContextMenuFragment extends Fragment {
private int menuFullHeight; private int menuFullHeight;
private int menuFullHeightMax; private int menuFullHeightMax;
private class SingleTapConfirm implements OnGestureListener {
@Override
public boolean onDown(MotionEvent e) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
@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) {
return false;
}
}
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
@ -136,9 +176,21 @@ public class MapContextMenuFragment extends Fragment {
}); });
shadowView = view.findViewById(R.id.context_menu_shadow_view); shadowView = view.findViewById(R.id.context_menu_shadow_view);
final GestureDetector singleTapDetector = new GestureDetector(view.getContext(), new SingleTapConfirm());
shadowView.setOnTouchListener(new View.OnTouchListener() { shadowView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent event) { public boolean onTouch(View view, MotionEvent event) {
dismissMenu();
if (singleTapDetector.onTouchEvent(event)) {
MapActivity mapActivity = getMapActivity();
ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
PointF point = new PointF(event.getX(), event.getY());
RotatedTileBox tileBox = mapActivity.getMapView().getCurrentRotatedTileBox();
if (!contextMenuLayer.pressedContextMarker(tileBox, point.x, point.y) &&
!contextMenuLayer.onSingleTap(point, tileBox)) {
dismissMenu();
}
}
return true; return true;
} }
}); });

View file

@ -457,6 +457,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
selectedObj = selectedObjects.keySet().iterator().next(); selectedObj = selectedObjects.keySet().iterator().next();
contextObject = selectedObjects.get(selectedObj); contextObject = selectedObjects.get(selectedObj);
showMapContextMenu(latLon); showMapContextMenu(latLon);
return true;
} else if (selectedObjects.size() > 1) { } else if (selectedObjects.size() > 1) {
showContextMenuForSelectedObjects(latLon); showContextMenuForSelectedObjects(latLon);
return true; return true;