Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-09-22 16:46:40 +02:00
commit 768f5b7c27
5 changed files with 68 additions and 36 deletions

View file

@ -6,13 +6,6 @@
android:layout_height="match_parent"
android:background="@android:color/transparent">
<LinearLayout
android:id="@+id/context_menu_shadow_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"/>
<LinearLayout
android:id="@+id/context_menu_main"
android:layout_width="match_parent"

View file

@ -40,6 +40,9 @@ public class MapContextMenu {
private static final String KEY_CTX_MENU_OBJECT = "key_ctx_menu_object";
private static final String KEY_CTX_MENU_POINT_DESC = "key_ctx_menu_point_desc";
private static final String KEY_CTX_MENU_NAME_STR = "key_ctx_menu_name_str";
private static final String KEY_CTX_MENU_TYPE_STR = "key_ctx_menu_type_str";
private static final String KEY_CTX_MENU_STREET_STR = "key_ctx_menu_street_str";
public boolean isMenuVisible(MapActivity mapActivity) {
return mapActivity.getSupportFragmentManager().findFragmentByTag("MapContextMenuFragment") != null;
@ -60,8 +63,13 @@ public class MapContextMenu {
public void show(MapActivity mapActivity, PointDescription pointDescription, Object object) {
if (isMenuVisible(mapActivity))
hide(mapActivity);
if (isMenuVisible(mapActivity)) {
if (this.object == null || !this.object.equals(object)) {
hide(mapActivity);
} else {
return;
}
}
this.pointDescription = pointDescription;
this.object = object;
@ -256,6 +264,9 @@ public class MapContextMenu {
bundle.putSerializable(KEY_CTX_MENU_OBJECT, (Amenity)object);
}
bundle.putSerializable(KEY_CTX_MENU_POINT_DESC, pointDescription);
bundle.putSerializable(KEY_CTX_MENU_NAME_STR, nameStr);
bundle.putSerializable(KEY_CTX_MENU_TYPE_STR, typeStr);
bundle.putSerializable(KEY_CTX_MENU_STREET_STR, streetStr);
}
public void restoreMenuState(Bundle bundle) {
@ -263,5 +274,17 @@ public class MapContextMenu {
Object pDescObj = bundle.getSerializable(KEY_CTX_MENU_POINT_DESC);
if (pDescObj != null)
pointDescription = (PointDescription)pDescObj;
Object nameStrObj = bundle.getSerializable(KEY_CTX_MENU_NAME_STR);
if (nameStrObj != null) {
nameStr = nameStrObj.toString();
}
Object typeStrObj = bundle.getSerializable(KEY_CTX_MENU_TYPE_STR);
if (typeStrObj != null) {
typeStr = typeStrObj.toString();
}
Object streetStrObj = bundle.getSerializable(KEY_CTX_MENU_STREET_STR);
if (streetStrObj != null) {
streetStr = streetStrObj.toString();
}
}
}

View file

@ -5,7 +5,6 @@ import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.PointF;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@ -27,13 +26,11 @@ import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.sections.MenuController;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapTileView;
import org.apache.commons.logging.Log;
@ -50,8 +47,6 @@ public class MapContextMenuFragment extends Fragment {
private View view;
private View mainView;
private View bottomView;
private View shadowView;
MenuController menuController;
@ -183,25 +178,7 @@ public class MapContextMenuFragment extends Fragment {
});
shadowView = view.findViewById(R.id.context_menu_shadow_view);
final GestureDetector singleTapDetector = new GestureDetector(view.getContext(), new SingleTapConfirm());
shadowView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent event) {
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;
}
});
final View.OnTouchListener slideTouchListener = new View.OnTouchListener() {
private float dy;
@ -408,7 +385,7 @@ public class MapContextMenuFragment extends Fragment {
});
// Menu controller
bottomView = view.findViewById(R.id.context_menu_bottom_view);
View bottomView = view.findViewById(R.id.context_menu_bottom_view);
if (menuController != null) {
bottomView.setOnTouchListener(new View.OnTouchListener() {
@Override
@ -422,9 +399,17 @@ public class MapContextMenuFragment extends Fragment {
bottomView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
menuBottomViewHeight = bottomView.getMeasuredHeight();
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
return view;
}
@Override
public void onDestroyView() {
super.onDestroyView();
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
}
private void setAddressLocation() {
// Text line 1
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);

View file

@ -10,6 +10,7 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Build;
import android.text.Html;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.MotionEvent;
import android.widget.FrameLayout.LayoutParams;
@ -77,8 +78,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
private boolean showContextMarker;
private ImageView contextMarker;
private GestureDetector movementListener;
public ContextMenuLayer(MapActivity activity){
this.activity = activity;
movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener());
if(activity.getLastNonConfigurationInstanceByKey(KEY_LAT_LAN) != null) {
latLon = (LatLon) activity.getLastNonConfigurationInstanceByKey(KEY_LAT_LAN);
description = (String) activity.getLastNonConfigurationInstanceByKey(KEY_DESCRIPTION);
@ -464,6 +468,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
}
}
activity.getContextMenu().hide(activity);
return false;
}
@ -515,6 +521,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
@Override
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
if (movementListener.onTouchEvent(event)) {
if (activity.getContextMenu().isMenuVisible(activity)) {
activity.getContextMenu().hide(activity);
}
}
if (latLon != null) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int vl = pressedInTextView(tileBox, event.getX(), event.getY());
@ -564,4 +577,16 @@ public class ContextMenuLayer extends OsmandMapLayer {
map.put(KEY_DESCRIPTION, textView.getText().toString());
}
private class MenuLayerOnGestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return true;
}
}
}

View file

@ -231,7 +231,7 @@ public class MapControlsLayer extends OsmandMapLayer {
clickRouteCancel();
}
});
mapRouteInfoControlDialog = new MapRouteInfoControl(mapActivity.getMapLayers().getContextMenuLayer(),
mapActivity, this);
@ -278,7 +278,7 @@ public class MapControlsLayer extends OsmandMapLayer {
public void updateRouteButtons(View main, boolean routeInfo) {
ImageView dashButton = (ImageView) main.findViewById(R.id.map_dashboard_route_button);
dashButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_dashboard));
dashButton.setVisibility(AndroidUiHelper.isOrientationPortrait(mapActivity) ?
dashButton.setVisibility(AndroidUiHelper.isOrientationPortrait(mapActivity) ?
View.GONE : View.VISIBLE);
dashButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -328,7 +328,13 @@ public class MapControlsLayer extends OsmandMapLayer {
}
});
}
public void setControlsClickable(boolean clickable) {
for (MapHudButton mb : controls) {
mb.iv.setClickable(clickable);
}
}
protected void clickRouteParams() {
notifyClicked();
mapRouteInfoControlDialog.hideDialog();