Merge pull request #2518 from osmandapp/moving_marker

Moving marker functionality
This commit is contained in:
vshcherb 2016-05-07 23:37:15 +02:00
commit e06be79057
33 changed files with 522 additions and 264 deletions

View file

@ -1,5 +1,4 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
// Global Parameters accepted // Global Parameters accepted
// APK_NUMBER_VERSION - version number of apk // APK_NUMBER_VERSION - version number of apk
// APK_VERSION - build number like #9999Z, for dev builds appended to app_version like 2.0.0 in no_translate.xml) // APK_VERSION - build number like #9999Z, for dev builds appended to app_version like 2.0.0 in no_translate.xml)
@ -355,19 +354,17 @@ repositories {
dependencies { dependencies {
compile project(path: ':OsmAnd-java', configuration: 'android') compile project(path: ':OsmAnd-java', configuration: 'android')
compile project(':eclipse-compile:design') // compile project(':eclipse-compile:design')
compile project(':eclipse-compile:cardview') // compile project(':eclipse-compile:cardview')
compile project(':eclipse-compile:gridlayout') // compile project(':eclipse-compile:gridlayout')
// compile project(":eclipse-compile:recyclerview") compile 'com.android.support:gridlayout-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs')
// compile "com.github.ksoichiro:android-observablescrollview:1.5.0"
// compile "com.android.support:appcompat-v7:22.2.1"
// compile "com.github.shell-software:fab:1.0.5"
// compile 'com.android.support:design:22.2.1'
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar" qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar" qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
compile files('libs/gson-2.5.jar')
} }

View file

@ -64,6 +64,11 @@
android:layout_gravity="bottom|left" android:layout_gravity="bottom|left"
android:visibility="gone"/> android:visibility="gone"/>
<include layout="@layout/move_marker_bottom_sheet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/move_marker_bottom_sheet"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/left_menu_view_bg"
android:clickable="true"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:src="@drawable/ic_action_photo_dark"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/TextAppearance.ContextMenuTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:text="@string/move_marker_bottom_sheet_title"/>
<TextView
android:id="@+id/description"
style="@style/TextAppearance.ContextMenuSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
tools:text="Lat: 50.45375 Lon: 30.48693"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp">
<android.support.v7.widget.AppCompatButton
android:id="@+id/apply_button"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shared_string_apply"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/cancel_button"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shared_string_cancel"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -75,10 +75,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/search_address_building" android:text="@string/search_address_building"
android:maxLines="6" style="@style/TextAppearance.ContextMenuTitle"/>
android:ellipsize="end"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size_large"/>
</LinearLayout> </LinearLayout>
@ -128,8 +125,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/amenity_type_finance" android:text="@string/amenity_type_finance"
android:textColor="?android:textColorSecondary" style="@style/TextAppearance.ContextMenuSubtitle"/>
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout> </LinearLayout>

View file

@ -188,7 +188,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<include layout="@layout/recording_note_fragment"/> <include layout="@layout/recording_note_fragment"
tools:visibility="gone"/>
<include layout="@layout/move_marker_bottom_sheet"/>
<LinearLayout <LinearLayout
android:id="@+id/map_context_menu_layout" android:id="@+id/map_context_menu_layout"

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/move_marker_bottom_sheet"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bottom_menu_view_bg"
android:clickable="true"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:src="@drawable/ic_action_photo_dark"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/TextAppearance.ContextMenuTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:text="@string/move_marker_bottom_sheet_title"/>
<TextView
android:id="@+id/description"
style="@style/TextAppearance.ContextMenuSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
tools:text="Lat: 50.45375 Lon: 30.48693"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp">
<android.support.v7.widget.AppCompatButton
android:id="@+id/apply_button"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shared_string_apply"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/cancel_button"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/shared_string_cancel"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -10,6 +10,8 @@
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="move_marker_bottom_sheet_title">Move the map to change marker\'s position</string>
<string name="lat_lon_pattern">Lat: %1$.6f Lon: %2$.6f</string>
<string name="follow_us">Follow us</string> <string name="follow_us">Follow us</string>
<string name="access_direction_audio_feedback">Direction audio feedback</string> <string name="access_direction_audio_feedback">Direction audio feedback</string>
<string name="access_direction_audio_feedback_descr">Indicate target point direction by sound</string> <string name="access_direction_audio_feedback_descr">Indicate target point direction by sound</string>
@ -1153,7 +1155,7 @@
<string name="rendering_attr_hikingRoutesOSMC_description">Render paths according to OSMC traces</string> <string name="rendering_attr_hikingRoutesOSMC_description">Render paths according to OSMC traces</string>
<string name="rendering_attr_noAdminboundaries_name">Hide boundaries</string> <string name="rendering_attr_noAdminboundaries_name">Hide boundaries</string>
<string name="rendering_attr_noAdminboundaries_description">Suppress display of regional boundaries (admin levels 5-9)</string> <string name="rendering_attr_noAdminboundaries_description">Suppress display of regional boundaries (admin levels 59)</string>
<string name="map_widget_max_speed">Speed limit</string> <string name="map_widget_max_speed">Speed limit</string>
<string name="monitoring_control_start">GPX</string> <string name="monitoring_control_start">GPX</string>
<string name="no_buildings_found">No buildings found.</string> <string name="no_buildings_found">No buildings found.</string>

View file

@ -377,4 +377,17 @@
<item name="typeface">@string/font_roboto_medium</item> <item name="typeface">@string/font_roboto_medium</item>
<item name="android:textSize">@dimen/default_list_text_size</item> <item name="android:textSize">@dimen/default_list_text_size</item>
</style> </style>
<style name="TextAppearance.ContextMenuTitle" parent="TextAppearance.AppCompat">
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:textSize">@dimen/default_list_text_size_large</item>
<item name="android:maxLines">6</item>
<item name="android:ellipsize">end</item>
</style>
<style name="TextAppearance.ContextMenuSubtitle" parent="TextAppearance.AppCompat.Subhead">
<item name="android:textColor">?android:textColorSecondary</item>
<item name="android:textSize">@dimen/default_desc_text_size</item>
</style>
</resources> </resources>

View file

@ -110,6 +110,9 @@ public class MapActivityLayers {
mapTextLayer = new MapTextLayer(); mapTextLayer = new MapTextLayer();
// 5.95 all labels // 5.95 all labels
mapView.addLayer(mapTextLayer, 5.95f); mapView.addLayer(mapTextLayer, 5.95f);
// 8. context menu layer
contextMenuLayer = new ContextMenuLayer(activity);
mapView.addLayer(contextMenuLayer, 8);
// mapView.addLayer(underlayLayer, -0.5f); // mapView.addLayer(underlayLayer, -0.5f);
mapTileLayer = new MapTileLayer(true); mapTileLayer = new MapTileLayer(true);
mapView.addLayer(mapTileLayer, 0.0f); mapView.addLayer(mapTileLayer, 0.0f);
@ -156,8 +159,6 @@ public class MapActivityLayers {
impassableRoadsLayer = new ImpassableRoadsLayer(activity); impassableRoadsLayer = new ImpassableRoadsLayer(activity);
mapView.addLayer(impassableRoadsLayer, 7.5f); mapView.addLayer(impassableRoadsLayer, 7.5f);
// 8. context menu layer // 8. context menu layer
contextMenuLayer = new ContextMenuLayer(activity);
mapView.addLayer(contextMenuLayer, 8);
// 9. map info layer // 9. map info layer
mapInfoLayer = new MapInfoLayer(activity, routeLayer); mapInfoLayer = new MapInfoLayer(activity, routeLayer);
mapView.addLayer(mapInfoLayer, 9); mapView.addLayer(mapInfoLayer, 9);

View file

@ -7,7 +7,6 @@ import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.PointF; import android.graphics.PointF;
import net.osmand.data.DataTileManager; import net.osmand.data.DataTileManager;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -131,13 +130,6 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
return true; return true;
} }
@Override
public String getObjectDescription(Object o) {
if(o instanceof Recording){
return ((Recording)o).getDescription(view.getContext());
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -202,4 +194,5 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
} }
} }

View file

@ -24,7 +24,6 @@ import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -682,30 +681,6 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
} }
} }
@Override
public String getObjectDescription(Object o) {
if(o instanceof WptPt) {
PointDescription desc = getObjectName(o);
List<String> l = new ArrayList<String>();
if(!Double.isNaN(((WptPt) o).ele)) {
l.add(app.getString(R.string.plugin_distance_point_ele) + " "+ OsmAndFormatter.getFormattedDistance((float) ((WptPt) o).ele, app));
}
if(!Double.isNaN(((WptPt) o).speed)) {
l.add(app.getString(R.string.plugin_distance_point_speed) + " "+ OsmAndFormatter.getFormattedSpeed((float) ((WptPt) o).speed, app));
}
if(!Double.isNaN(((WptPt) o).hdop)) {
l.add(app.getString(R.string.plugin_distance_point_hdop) + " "+ OsmAndFormatter.getFormattedDistance((float) ((WptPt) o).hdop, app));
}
if(((WptPt) o).time != 0) {
Date date = new Date(((WptPt) o).time);
java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(app);
java.text.DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(app);
l.add(app.getString(R.string.plugin_distance_point_time) + " "+ dateFormat.format(date) + " " + timeFormat.format(date));
}
return desc.getName() + " " + l;
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -718,6 +693,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
return null; return null;
} }
} }

View file

@ -1,6 +1,7 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
@ -58,7 +59,7 @@ public class WptPtMenuController extends MenuController {
@Override @Override
public Drawable getLeftIcon() { public Drawable getLeftIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(),
wpt.getColor(getMapActivity().getResources().getColor(R.color.gpx_color_point)), false); wpt.getColor(ContextCompat.getColor(getMapActivity(), R.color.gpx_color_point)), false);
} }
@Override @Override

View file

@ -15,7 +15,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -457,13 +456,6 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
} }
@Override
public String getObjectDescription(Object o) {
if (o instanceof OpenStreetNote) {
return activity.getString(R.string.osn_bug_name) + ": " + ((OpenStreetNote) o).getCommentDescription(); //$NON-NLS-1$
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -626,4 +618,5 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
} }
} }
} }

View file

@ -5,7 +5,6 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PointF; import android.graphics.PointF;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -158,14 +157,6 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
if(o instanceof OsmPoint) {
OsmPoint point = (OsmPoint) o;
return OsmEditingPlugin.getEditName(point);
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -184,4 +175,5 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
} }
return null; return null;
} }
} }

View file

@ -13,7 +13,6 @@ import android.graphics.PointF;
import android.os.Handler; import android.os.Handler;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -229,20 +228,6 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
if (o instanceof OsMoDevice) {
String d = map.getString(R.string.osmo_user_name) + " " + ((OsMoDevice) o).getVisibleName();
final Location l = ((OsMoDevice) o).getLastLocation();
float speed = 0;
if(l != null && l.hasSpeed()) {
speed = l.getSpeed();
}
d += "\n"+ OsmAndFormatter.getFormattedSpeed(speed, map.getMyApplication());
return d;
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -427,6 +412,6 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
followTrackerId = null; followTrackerId = null;
} }
} }
} }

View file

@ -131,11 +131,6 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
return plugin.getParkingDescription(map);
}
public String getFormattedTime(long time){ public String getFormattedTime(long time){
return plugin.getFormattedTime(time, map); return plugin.getFormattedTime(time, map);
@ -187,5 +182,6 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
} }
} }
} }
} }

View file

@ -3,7 +3,6 @@ package net.osmand.plus.routepointsnavigation;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PointF; import android.graphics.PointF;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -53,11 +52,6 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
return null; return null;
@ -142,5 +136,4 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
} }
} }
} }

View file

@ -1,14 +1,20 @@
package net.osmand.plus.views; package net.osmand.plus.views;
import android.Manifest;
import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Vibrator;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.RequiresPermission;
import android.support.v4.content.ContextCompat;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.FrameLayout.LayoutParams; import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView; import android.widget.ImageView;
@ -30,32 +36,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class ContextMenuLayer extends OsmandMapLayer { public class ContextMenuLayer extends OsmandMapLayer {
//private static final Log LOG = PlatformUtil.getLog(ContextMenuLayer.class);
public interface IContextMenuProvider { public static final int VIBRATE_SHORT = 100;
void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o);
LatLon getObjectLocation(Object o);
String getObjectDescription(Object o);
PointDescription getObjectName(Object o);
boolean disableSingleTap();
boolean disableLongPressOnMap();
boolean isObjectClickable(Object o);
}
public interface IContextMenuProviderSelection {
int getOrder(Object o);
void setSelectedObject(Object o);
void clearSelectedObject();
}
private OsmandMapTileView view; private OsmandMapTileView view;
@ -73,11 +55,16 @@ public class ContextMenuLayer extends OsmandMapLayer {
private GestureDetector movementListener; private GestureDetector movementListener;
private final MoveMarkerBottomSheetHelper mMoveMarkerBottomSheetHelper;
private boolean mInChangeMarkerPositionMode;
private IContextMenuProvider selectedObjectContextMenuProvider;
public ContextMenuLayer(MapActivity activity) { public ContextMenuLayer(MapActivity activity) {
this.activity = activity; this.activity = activity;
menu = activity.getContextMenu(); menu = activity.getContextMenu();
multiSelectionMenu = menu.getMultiSelectionMenu(); multiSelectionMenu = menu.getMultiSelectionMenu();
movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener()); movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener());
mMoveMarkerBottomSheetHelper = new MoveMarkerBottomSheetHelper(activity, this);
} }
@Override @Override
@ -88,9 +75,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
public void initLayer(OsmandMapTileView view) { public void initLayer(OsmandMapTileView view) {
this.view = view; this.view = view;
contextMarker = new ImageView(view.getContext()); Context context = view.getContext();
contextMarker = new ImageView(context);
contextMarker.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); contextMarker.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
contextMarker.setImageDrawable(view.getResources().getDrawable(R.drawable.map_pin_context_menu)); contextMarker.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.map_pin_context_menu));
contextMarker.setClickable(true); contextMarker.setClickable(true);
int minw = contextMarker.getDrawable().getMinimumWidth(); int minw = contextMarker.getDrawable().getMinimumWidth();
int minh = contextMarker.getDrawable().getMinimumHeight(); int minh = contextMarker.getDrawable().getMinimumHeight();
@ -118,7 +106,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint); canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint);
} }
if (menu.isActive()) { if (mInChangeMarkerPositionMode) {
if (menu.getObject() == null) {
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
contextMarker.draw(canvas);
}
mMoveMarkerBottomSheetHelper.onDraw(box);
} else if (menu.isActive()) {
LatLon latLon = menu.getLatLon(); LatLon latLon = menu.getLatLon();
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()); int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
@ -151,17 +145,126 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
@Override @Override
@RequiresPermission(Manifest.permission.VIBRATE)
public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) { public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) {
if (disableLongPressOnMap()) { if (disableLongPressOnMap()) {
return false; return false;
} }
if (pressedContextMarker(tileBox, point.x, point.y)) {
Object obj = menu.getObject();
if (isObjectMoveable(obj)) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_SHORT);
menu.updateMapCenter(null);
menu.hide();
LatLon ll = menu.getLatLon();
RotatedTileBox rb = new RotatedTileBox(tileBox);
rb.setCenterLocation(0.5f, 0.5f);
rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude());
double lat = rb.getLatFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
view.setLatLon(lat, lon);
enterMovingMode();
view.refreshMap();
return true;
}
return false;
}
showContextMenu(point, tileBox, true); showContextMenu(point, tileBox, true);
view.refreshMap(); view.refreshMap();
return true; return true;
} }
public PointF getMoveableCenterPoint(RotatedTileBox tb) {
return new PointF(tb.getPixWidth() / 2, tb.getPixHeight() / 2);
}
public Object getMoveableObject() {
return mInChangeMarkerPositionMode ? menu.getObject() : null;
}
public boolean isInChangeMarkerPositionMode() {
return mInChangeMarkerPositionMode;
}
public boolean isObjectMoveable(Object o) {
if (o == null) {
return true;
} else if (selectedObjectContextMenuProvider != null
&& selectedObjectContextMenuProvider instanceof ContextMenuLayer.IMoveObjectProvider) {
final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) selectedObjectContextMenuProvider;
if (l.isObjectMoveable(o)) {
return true;
}
}
return false;
}
public void applyMovedObject(Object o, LatLon position) {
if (selectedObjectContextMenuProvider != null
&& selectedObjectContextMenuProvider instanceof ContextMenuLayer.IMoveObjectProvider) {
final IMoveObjectProvider l = (ContextMenuLayer.IMoveObjectProvider) selectedObjectContextMenuProvider;
if (l.isObjectMoveable(o)) {
l.applyNewObjectPosition(o, position);
}
}
}
public void applyNewMarkerPosition() {
if (!mInChangeMarkerPositionMode) {
throw new IllegalStateException("Not in change marker position mode");
}
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
PointF newMarkerPosition = getMoveableCenterPoint(tileBox);
LatLon ll = tileBox.getLatLonFromPixel(newMarkerPosition.x, newMarkerPosition.y);
Object obj = getMoveableObject();
applyMovedObject(obj, ll);
quitMovingMarker();
PointDescription pointDescription = null;
if (selectedObjectContextMenuProvider != null) {
pointDescription = selectedObjectContextMenuProvider.getObjectName(obj);
}
menu.show(ll, pointDescription, obj);
view.refreshMap();
}
private void quitMovingMarker() {
mInChangeMarkerPositionMode = false;
mark(View.VISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
}
private void enterMovingMode() {
mInChangeMarkerPositionMode = true;
mMoveMarkerBottomSheetHelper.show(menu.getLeftIcon());
mark(View.INVISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
}
private void mark(int status, int... widgets) {
for (int widget : widgets) {
View v = activity.findViewById(widget);
if (v != null) {
v.setVisibility(status);
}
}
}
public void cancelMovingMarker() {
quitMovingMarker();
activity.getContextMenu().show();
}
public boolean showContextMenu(double latitude, double longitude, boolean showUnknownLocation) { public boolean showContextMenu(double latitude, double longitude, boolean showUnknownLocation) {
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox().copy(); RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox();
float x = cp.getPixXFromLatLon(latitude, longitude); float x = cp.getPixXFromLatLon(latitude, longitude);
float y = cp.getPixYFromLatLon(latitude, longitude); float y = cp.getPixYFromLatLon(latitude, longitude);
return showContextMenu(new PointF(x, y), activity.getMapView().getCurrentRotatedTileBox(), showUnknownLocation); return showContextMenu(new PointF(x, y), activity.getMapView().getCurrentRotatedTileBox(), showUnknownLocation);
@ -171,29 +274,30 @@ public class ContextMenuLayer extends OsmandMapLayer {
Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point, false); Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point, false);
if (selectedObjects.size() == 1) { if (selectedObjects.size() == 1) {
Object selectedObj = selectedObjects.keySet().iterator().next(); Object selectedObj = selectedObjects.keySet().iterator().next();
IContextMenuProvider contextObject = selectedObjects.get(selectedObj); selectedObjectContextMenuProvider = selectedObjects.get(selectedObj);
LatLon latLon = null; LatLon latLon = null;
PointDescription pointDescription = null; PointDescription pointDescription = null;
if (contextObject != null) { if (selectedObjectContextMenuProvider != null) {
latLon = contextObject.getObjectLocation(selectedObj); latLon = selectedObjectContextMenuProvider.getObjectLocation(selectedObj);
pointDescription = contextObject.getObjectName(selectedObj); pointDescription = selectedObjectContextMenuProvider.getObjectName(selectedObj);
} }
if (latLon == null) { if (latLon == null) {
latLon = getLatLon(point, tileBox); latLon = getLatLon(point, tileBox);
} }
hideVisibleMenues(); hideVisibleMenues();
activity.getMapViewTrackingUtilities().locationChanged(latLon.getLatitude(), latLon.getLongitude(), this); activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
menu.show(latLon, pointDescription, selectedObj); menu.show(latLon, pointDescription, selectedObj);
return true; return true;
} else if (selectedObjects.size() > 1) { } else if (selectedObjects.size() > 1) {
selectedObjectContextMenuProvider = null;
showContextMenuForSelectedObjects(getLatLon(point, tileBox), selectedObjects); showContextMenuForSelectedObjects(getLatLon(point, tileBox), selectedObjects);
return true; return true;
} else if (showUnknownLocation) { } else if (showUnknownLocation) {
hideVisibleMenues(); hideVisibleMenues();
LatLon latLon = getLatLon(point, tileBox); LatLon latLon = getLatLon(point, tileBox);
activity.getMapViewTrackingUtilities().locationChanged(latLon.getLatitude(), latLon.getLongitude(), this); activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
menu.show(latLon, null, null); menu.show(latLon, null, null);
return true; return true;
} }
@ -223,6 +327,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
public boolean disableLongPressOnMap() { public boolean disableLongPressOnMap() {
if (mInChangeMarkerPositionMode) {
return true;
}
boolean res = false; boolean res = false;
for (OsmandMapLayer lt : view.getLayers()) { for (OsmandMapLayer lt : view.getLayers()) {
if (lt instanceof ContextMenuLayer.IContextMenuProvider) { if (lt instanceof ContextMenuLayer.IContextMenuProvider) {
@ -272,20 +379,32 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
public boolean pressedContextMarker(RotatedTileBox tb, float px, float py) { public boolean pressedContextMarker(RotatedTileBox tb, float px, float py) {
if (menu.isActive()) { float markerX;
float markerY;
if (mInChangeMarkerPositionMode) {
markerX = tb.getCenterPixelX();
markerY = tb.getCenterPixelY();
} else if (menu.isActive()) {
LatLon latLon = menu.getLatLon(); LatLon latLon = menu.getLatLon();
Rect bs = contextMarker.getDrawable().getBounds(); markerX = tb.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int dx = (int) (px - tb.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude())); markerY = tb.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int dy = (int) (py - tb.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude())); } else {
int bx = dx + bs.width() / 2; return false;
int by = dy + bs.height();
return (bs.contains(bx, by));
} }
return false; Rect bs = contextMarker.getDrawable().getBounds();
int dx = (int) (px - markerX);
int dy = (int) (py - markerY);
int bx = dx + bs.width() / 2;
int by = dy + bs.height();
return (bs.contains(bx, by));
} }
@Override @Override
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
if (mInChangeMarkerPositionMode) {
return true;
}
if (pressedContextMarker(tileBox, point.x, point.y)) { if (pressedContextMarker(tileBox, point.x, point.y)) {
hideVisibleMenues(); hideVisibleMenues();
menu.show(); menu.show();
@ -337,9 +456,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
switch (event.getAction()) { switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true); if (!mInChangeMarkerPositionMode) {
if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) { selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true);
view.refreshMap(); if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) {
view.refreshMap();
}
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
@ -353,6 +474,40 @@ public class ContextMenuLayer extends OsmandMapLayer {
return false; return false;
} }
public interface IContextMenuProvider {
void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o);
LatLon getObjectLocation(Object o);
PointDescription getObjectName(Object o);
boolean disableSingleTap();
boolean disableLongPressOnMap();
boolean isObjectClickable(Object o);
}
public interface IMoveObjectProvider {
boolean isObjectMoveable(Object o);
boolean applyNewObjectPosition(Object o, LatLon position);
}
public interface IContextMenuProviderSelection {
int getOrder(Object o);
void setSelectedObject(Object o);
void clearSelectedObject();
}
private class MenuLayerOnGestureListener extends GestureDetector.SimpleOnGestureListener { private class MenuLayerOnGestureListener extends GestureDetector.SimpleOnGestureListener {
@Override @Override

View file

@ -11,7 +11,6 @@ import android.graphics.PointF;
import android.text.TextPaint; import android.text.TextPaint;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.binary.BinaryMapDataObject; import net.osmand.binary.BinaryMapDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -431,11 +430,6 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
return view.getContext().getString(R.string.shared_string_map);
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if (o instanceof DownloadMapObject) { if (o instanceof DownloadMapObject) {
@ -547,4 +541,5 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
public void clearSelectedObject() { public void clearSelectedObject() {
selectedObjects = new LinkedList<>(); selectedObjects = new LinkedList<>();
} }
} }

View file

@ -1,17 +1,10 @@
package net.osmand.plus.views; package net.osmand.plus.views;
import android.graphics.Bitmap; import java.util.ArrayList;
import android.graphics.BitmapFactory; import java.util.List;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.data.QuadTree; import net.osmand.data.QuadTree;
@ -21,34 +14,40 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.views.MapTextLayer.MapTextProvider; import net.osmand.plus.views.MapTextLayer.MapTextProvider;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.support.annotation.ColorInt;
import java.util.ArrayList; public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider,
import java.util.List; ContextMenuLayer.IMoveObjectProvider, MapTextProvider<FavouritePoint> {
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider, MapTextProvider<LocationPoint> {
protected int startZoom = 6; protected int startZoom = 6;
protected OsmandMapTileView view; protected OsmandMapTileView view;
private Paint paint; private Paint paint;
private FavouritesDbHelper favorites; private FavouritesDbHelper favorites;
protected List<LocationPoint> cache = new ArrayList<LocationPoint>(); protected List<FavouritePoint> cache = new ArrayList<FavouritePoint>();
private MapTextLayer textLayer; private MapTextLayer textLayer;
private ContextMenuLayer contextMenuLayer;
private Paint paintIcon; private Paint paintIcon;
private Bitmap pointSmall; private Bitmap pointSmall;
private int defaultColor; private int defaultColor;
private OsmandSettings settings; private OsmandSettings settings;
protected Class<? extends LocationPoint> getFavoriteClass() {
return (Class<? extends LocationPoint>) FavouritePoint.class;
}
protected String getObjName() { protected String getObjName() {
return view.getContext().getString(R.string.favorite); return view.getContext().getString(R.string.favorite);
} }
protected List<? extends LocationPoint> getPoints() { protected List<? extends FavouritePoint> getPoints() {
return favorites.getFavouritePoints(); return favorites.getFavouritePoints();
} }
@ -62,6 +61,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
settings = view.getApplication().getSettings(); settings = view.getApplication().getSettings();
favorites = view.getApplication().getFavorites(); favorites = view.getApplication().getFavorites();
textLayer = view.getLayerByClass(MapTextLayer.class); textLayer = view.getLayerByClass(MapTextLayer.class);
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
paintIcon = new Paint(); paintIcon = new Paint();
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small); pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
defaultColor = view.getResources().getColor(R.color.color_favorite); defaultColor = view.getResources().getColor(R.color.color_favorite);
@ -87,6 +87,12 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
@Override @Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof FavouritePoint) {
FavouritePoint fp = (FavouritePoint) contextMenuLayer.getMoveableObject();
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), fp.getColor(), true);
PointF pf = contextMenuLayer.getMoveableCenterPoint(tileBox);
fid.drawBitmapInCenter(canvas, pf.x, pf.y);
}
} }
@Override @Override
@ -100,10 +106,10 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
// request to load // request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds(); final QuadRect latLonBounds = tileBox.getLatLonBounds();
List<LocationPoint> fullObjects = new ArrayList<>(); List<FavouritePoint> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>(); List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>(); List<LatLon> smallObjectsLatLon = new ArrayList<>();
for (LocationPoint o : getPoints()) { for (FavouritePoint o : getPoints()) {
if (!o.isVisible()) { if (!o.isVisible()) {
continue; continue;
} }
@ -111,6 +117,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) { if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
@ColorInt
int col = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor(); int col = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor();
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY)); paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon); canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
@ -120,8 +127,10 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude())); fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} }
} }
for (LocationPoint o : fullObjects) { for (FavouritePoint o : fullObjects) {
drawPoint(canvas, tileBox, latLonBounds, o); if (o != contextMenuLayer.getMoveableObject()) {
drawPoint(canvas, tileBox, latLonBounds, o);
}
} }
this.fullObjectsLatLon = fullObjectsLatLon; this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon; this.smallObjectsLatLon = smallObjectsLatLon;
@ -134,7 +143,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
} }
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, final QuadRect latLonBounds, LocationPoint o) { private void drawPoint(Canvas canvas, RotatedTileBox tileBox, final QuadRect latLonBounds, FavouritePoint o) {
if (o.isVisible() && o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left if (o.isVisible() && o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left
&& o.getLongitude() <= latLonBounds.right ) { && o.getLongitude() <= latLonBounds.right ) {
cache.add(o); cache.add(o);
@ -142,8 +151,6 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude()); int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true); FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true);
fid.drawBitmapInCenter(canvas, x, y); fid.drawBitmapInCenter(canvas, x, y);
// canvas.drawBitmap(favoriteIcon, x - favoriteIcon.getWidth() / 2,
// y - favoriteIcon.getHeight(), paint);
} }
} }
@ -153,17 +160,17 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
return false; return false;
} }
public void getFavoriteFromPoint(RotatedTileBox tb, PointF point, List<? super LocationPoint> res) { public void getFavoriteFromPoint(RotatedTileBox tb, PointF point, List<? super FavouritePoint> res) {
int r = (int) (15 * tb.getDensity()); int r = (int) (15 * tb.getDensity());
int ex = (int) point.x; int ex = (int) point.x;
int ey = (int) point.y; int ey = (int) point.y;
for (LocationPoint n : getPoints()) { for (FavouritePoint n : getPoints()) {
getFavFromPoint(tb, res, r, ex, ey, n); getFavFromPoint(tb, res, r, ex, ey, n);
} }
} }
private void getFavFromPoint(RotatedTileBox tb, List<? super LocationPoint> res, int r, int ex, int ey, private void getFavFromPoint(RotatedTileBox tb, List<? super FavouritePoint> res, int r, int ex, int ey,
LocationPoint n) { FavouritePoint n) {
if (n.isVisible()) { if (n.isVisible()) {
int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude()); int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude()); int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
@ -173,21 +180,11 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
} }
} }
@Override
public String getObjectDescription(Object o) {
Class<? extends LocationPoint> fcl = getFavoriteClass();
if(o!= null && fcl.isInstance(o)) {
return PointDescription.getSimpleName((LocationPoint) o, view.getContext()) ;
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if(o instanceof LocationPoint){ if(o instanceof FavouritePoint){
return ((LocationPoint) o).getPointDescription(view.getContext()); //$NON-NLS-1$ return ((FavouritePoint) o).getPointDescription(view.getContext()); //$NON-NLS-1$
} }
return null; return null;
} }
@ -204,7 +201,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
@Override @Override
public boolean isObjectClickable(Object o) { public boolean isObjectClickable(Object o) {
return o instanceof LocationPoint; return o instanceof FavouritePoint && o != contextMenuLayer.getMoveableObject();
} }
@Override @Override
@ -216,28 +213,41 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
@Override @Override
public LatLon getObjectLocation(Object o) { public LatLon getObjectLocation(Object o) {
if(o instanceof LocationPoint){ if(o instanceof FavouritePoint){
return new LatLon(((LocationPoint)o).getLatitude(), ((LocationPoint)o).getLongitude()); return new LatLon(((FavouritePoint)o).getLatitude(), ((FavouritePoint)o).getLongitude());
} }
return null; return null;
} }
@Override @Override
public LatLon getTextLocation(LocationPoint o) { public LatLon getTextLocation(FavouritePoint o) {
return new LatLon(o.getLatitude(), o.getLongitude()); return new LatLon(o.getLatitude(), o.getLongitude());
} }
@Override @Override
public int getTextShift(LocationPoint o, RotatedTileBox rb) { public int getTextShift(FavouritePoint o, RotatedTileBox rb) {
return (int) (16 * rb.getDensity()); return (int) (16 * rb.getDensity());
} }
@Override @Override
public String getText(LocationPoint o) { public String getText(FavouritePoint o) {
return PointDescription.getSimpleName(o, view.getContext()); return PointDescription.getSimpleName(o, view.getContext());
} }
@Override
public boolean isObjectMoveable(Object o) {
return o instanceof FavouritePoint;
}
@Override
public boolean applyNewObjectPosition(Object o, LatLon position) {
if(o instanceof FavouritePoint) {
favorites.editFavourite((FavouritePoint) o, position.getLatitude(), position.getLongitude());
return true;
}
return false;
}
} }

View file

@ -12,7 +12,6 @@ import android.graphics.PointF;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
@ -390,14 +389,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
} }
} }
@Override
public String getObjectDescription(Object o) {
if(o instanceof WptPt){
return view.getContext().getString(R.string.gpx_wpt) + " : " + ((WptPt)o).name; //$NON-NLS-1$
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if(o instanceof WptPt){ if(o instanceof WptPt){
@ -473,6 +464,4 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
} }
} }

View file

@ -6,7 +6,6 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PointF; import android.graphics.PointF;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -146,11 +145,6 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if (o instanceof RouteDataObject) { if (o instanceof RouteDataObject) {

View file

@ -89,12 +89,14 @@ public class MapControlsLayer extends OsmandMapLayer {
private MapHudButton layersHud; private MapHudButton layersHud;
private long lastZoom; private long lastZoom;
private boolean hasTargets; private boolean hasTargets;
private ContextMenuLayer contextMenuLayer;
public MapControlsLayer(MapActivity activity) { public MapControlsLayer(MapActivity activity) {
this.mapActivity = activity; this.mapActivity = activity;
app = activity.getMyApplication(); app = activity.getMyApplication();
settings = activity.getMyApplication().getSettings(); settings = activity.getMyApplication().getSettings();
mapView = mapActivity.getMapView(); mapView = mapActivity.getMapView();
contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
} }
public MapRouteInfoMenu getMapRouteInfoMenu() { public MapRouteInfoMenu getMapRouteInfoMenu() {
@ -504,7 +506,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean showRouteCalculationControls = routePlanningMode || boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
updateMyLocation(rh, dialogOpened); updateMyLocation(rh, dialogOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode); boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) && !contextMenuLayer.isInChangeMarkerPositionMode();
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions); //routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (rh.isFollowingMode()) { if (rh.isFollowingMode()) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation); routePlanningBtn.setIconResId(R.drawable.map_start_navigation);

View file

@ -12,7 +12,6 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.MotionEvent; import android.view.MotionEvent;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -450,13 +449,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
if (o instanceof MapMarker) {
return ((MapMarker) o).getPointDescription(view.getContext()).getFullPlainName(view.getContext());
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -489,4 +481,5 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
@Override @Override
public void clearSelectedObject() { public void clearSelectedObject() {
} }
} }

View file

@ -0,0 +1,62 @@
package net.osmand.plus.views;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.IconsCache;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
public class MoveMarkerBottomSheetHelper {
private final View mView;
private final TextView mDescription;
private final Context mContext;
private final ContextMenuLayer mContextMenuLayer;
public MoveMarkerBottomSheetHelper(MapActivity activity, ContextMenuLayer contextMenuLayer) {
mContextMenuLayer = contextMenuLayer;
this.mView = activity.findViewById(R.id.move_marker_bottom_sheet);
ImageView icon = (ImageView) mView.findViewById(R.id.icon);
this.mDescription = (TextView) mView.findViewById(R.id.description);
this.mContext = activity;
IconsCache iconsCache = activity.getMyApplication().getIconsCache();
icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_photo_dark, R.color.marker_green));
mView.findViewById(R.id.apply_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hide();
mContextMenuLayer.applyNewMarkerPosition();
}
});
mView.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hide();
mContextMenuLayer.cancelMovingMarker();
}
});
}
public void onDraw(RotatedTileBox rt) {
double lat = rt.getLatFromPixel(rt.getPixWidth() / 2, rt.getPixHeight() / 2);
double lon = rt.getLonFromPixel(rt.getPixWidth() / 2, rt.getPixHeight() / 2);
mDescription.setText(mContext.getString(R.string.lat_lon_pattern, lat, lon));
}
public boolean isVisible() {
return mView.getVisibility() == View.VISIBLE;
}
public void show(Drawable drawable) {
mView.setVisibility(View.VISIBLE);
((ImageView) mView.findViewById(R.id.icon)).setImageDrawable(drawable);
}
public void hide() {
mView.setVisibility(View.GONE);
}
}

View file

@ -52,6 +52,7 @@ public abstract class OsmandMapLayer {
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) { public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
return false; return false;
} }
public <Params> void executeTaskInBackground(AsyncTask<Params, ?, ?> task, Params... params) { public <Params> void executeTaskInBackground(AsyncTask<Params, ?, ?> task, Params... params) {
task.execute(params); task.execute(params);

View file

@ -133,7 +133,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private AccessibilityActionsProvider accessibilityActions; private AccessibilityActionsProvider accessibilityActions;
private List<OsmandMapLayer> layers = new ArrayList<OsmandMapLayer>(); private List<OsmandMapLayer> layers = new ArrayList<>();
private BaseMapLayer mainLayer; private BaseMapLayer mainLayer;
@ -604,6 +604,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
} }
protected void drawMapPosition(Canvas canvas, float x, float y) { protected void drawMapPosition(Canvas canvas, float x, float y) {
canvas.drawCircle(x, y, 3 * dm.density, paintCenter); canvas.drawCircle(x, y, 3 * dm.density, paintCenter);
canvas.drawCircle(x, y, 7 * dm.density, paintCenter); canvas.drawCircle(x, y, 7 * dm.density, paintCenter);

View file

@ -33,7 +33,6 @@ import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams; import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher; import net.osmand.ResultMatcher;
import net.osmand.ValueHolder; import net.osmand.ValueHolder;
@ -476,14 +475,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
} }
@Override
public String getObjectDescription(Object o) {
if (o instanceof Amenity) {
return buildPoiInformation(new StringBuilder(), (Amenity) o).toString();
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) { if (o instanceof Amenity) {
@ -558,4 +549,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
r.getDisplayMetrics() r.getDisplayMetrics()
); );
} }
} }

View file

@ -8,7 +8,6 @@ import android.graphics.Paint;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.RectF; import android.graphics.RectF;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
@ -175,10 +174,6 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
return getMyLocation(); return getMyLocation();
} }
@Override
public String getObjectDescription(Object o) {
return view.getResources().getString(R.string.shared_string_my_location);
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -223,4 +218,5 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
} }
} }
} }
} }

View file

@ -8,7 +8,6 @@ import android.graphics.Paint;
import android.graphics.Paint.Align; import android.graphics.Paint.Align;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.PointF; import android.graphics.PointF;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;
@ -227,13 +226,6 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
return null; return null;
} }
@Override
public String getObjectDescription(Object o) {
if (o instanceof TargetPoint) {
return ((TargetPoint) o).getPointDescription(view.getContext()).getFullPlainName(view.getContext());
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
@ -242,4 +234,6 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
} }
return null; return null;
} }
} }

View file

@ -8,7 +8,6 @@ import android.graphics.Paint;
import android.graphics.PointF; import android.graphics.PointF;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
@ -171,14 +170,6 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
return false; return false;
} }
@Override
public String getObjectDescription(Object o) {
if(o instanceof TransportStop){
return getStopDescription((TransportStop) o, false);
}
return null;
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if(o instanceof TransportStop){ if(o instanceof TransportStop){
@ -217,4 +208,5 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
} }
return null; return null;
} }
} }

View file

@ -64,5 +64,4 @@ repositories {
} }
dependencies { dependencies {
compile project(":eclipse-compile:appcompat")
} }

View file

@ -1,8 +1,4 @@
include ':OsmAnd-java' include ':OsmAnd-java'
include ':eclipse-compile:gridlayout'
include ':eclipse-compile:cardview'
include ':eclipse-compile:design'
include ':eclipse-compile:appcompat'
include ':OsmAnd' include ':OsmAnd'
include ':plugins:OsmAnd-AddressPlugin' include ':plugins:OsmAnd-AddressPlugin'
include ':plugins:Osmand-ParkingPlugin' include ':plugins:Osmand-ParkingPlugin'