Merge pull request #2518 from osmandapp/moving_marker
Moving marker functionality
This commit is contained in:
commit
e06be79057
33 changed files with 522 additions and 264 deletions
|
@ -1,5 +1,4 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
// Global Parameters accepted
|
||||
// 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)
|
||||
|
@ -355,19 +354,17 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
compile project(path: ':OsmAnd-java', configuration: 'android')
|
||||
compile project(':eclipse-compile:design')
|
||||
compile project(':eclipse-compile:cardview')
|
||||
compile project(':eclipse-compile:gridlayout')
|
||||
// compile project(":eclipse-compile:recyclerview")
|
||||
// compile project(':eclipse-compile:design')
|
||||
// compile project(':eclipse-compile:cardview')
|
||||
// compile project(':eclipse-compile:gridlayout')
|
||||
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 "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"
|
||||
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug: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_android:0.1-SNAPSHOT@aar"
|
||||
compile files('libs/gson-2.5.jar')
|
||||
}
|
||||
|
|
|
@ -64,6 +64,11 @@
|
|||
android:layout_gravity="bottom|left"
|
||||
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
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
70
OsmAnd/res/layout-land/move_marker_bottom_sheet.xml
Normal file
70
OsmAnd/res/layout-land/move_marker_bottom_sheet.xml
Normal 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>
|
|
@ -75,10 +75,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_address_building"
|
||||
android:maxLines="6"
|
||||
android:ellipsize="end"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size_large"/>
|
||||
style="@style/TextAppearance.ContextMenuTitle"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -128,8 +125,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/amenity_type_finance"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -188,7 +188,10 @@
|
|||
android:layout_width="match_parent"
|
||||
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
|
||||
android:id="@+id/map_context_menu_layout"
|
||||
|
|
70
OsmAnd/res/layout/move_marker_bottom_sheet.xml
Normal file
70
OsmAnd/res/layout/move_marker_bottom_sheet.xml
Normal 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>
|
|
@ -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
|
||||
-->
|
||||
|
||||
<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="access_direction_audio_feedback">Direction audio feedback</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_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 5–9)</string>
|
||||
<string name="map_widget_max_speed">Speed limit</string>
|
||||
<string name="monitoring_control_start">GPX</string>
|
||||
<string name="no_buildings_found">No buildings found.</string>
|
||||
|
|
|
@ -377,4 +377,17 @@
|
|||
<item name="typeface">@string/font_roboto_medium</item>
|
||||
<item name="android:textSize">@dimen/default_list_text_size</item>
|
||||
</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>
|
||||
|
|
|
@ -110,6 +110,9 @@ public class MapActivityLayers {
|
|||
mapTextLayer = new MapTextLayer();
|
||||
// 5.95 all labels
|
||||
mapView.addLayer(mapTextLayer, 5.95f);
|
||||
// 8. context menu layer
|
||||
contextMenuLayer = new ContextMenuLayer(activity);
|
||||
mapView.addLayer(contextMenuLayer, 8);
|
||||
// mapView.addLayer(underlayLayer, -0.5f);
|
||||
mapTileLayer = new MapTileLayer(true);
|
||||
mapView.addLayer(mapTileLayer, 0.0f);
|
||||
|
@ -156,8 +159,6 @@ public class MapActivityLayers {
|
|||
impassableRoadsLayer = new ImpassableRoadsLayer(activity);
|
||||
mapView.addLayer(impassableRoadsLayer, 7.5f);
|
||||
// 8. context menu layer
|
||||
contextMenuLayer = new ContextMenuLayer(activity);
|
||||
mapView.addLayer(contextMenuLayer, 8);
|
||||
// 9. map info layer
|
||||
mapInfoLayer = new MapInfoLayer(activity, routeLayer);
|
||||
mapView.addLayer(mapInfoLayer, 9);
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.Color;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.data.DataTileManager;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -131,13 +130,6 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
if(o instanceof Recording){
|
||||
return ((Recording)o).getDescription(view.getContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -202,4 +194,5 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -24,7 +24,6 @@ import android.widget.EditText;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.IndexConstants;
|
||||
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
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -718,6 +693,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
|
@ -58,7 +59,7 @@ public class WptPtMenuController extends MenuController {
|
|||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
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
|
||||
|
|
|
@ -15,7 +15,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
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
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -626,4 +618,5 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -158,14 +157,6 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
if(o instanceof OsmPoint) {
|
||||
OsmPoint point = (OsmPoint) o;
|
||||
return OsmEditingPlugin.getEditName(point);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -184,4 +175,5 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.graphics.PointF;
|
|||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -229,20 +228,6 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
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
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -427,6 +412,6 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
followTrackerId = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -131,11 +131,6 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
return plugin.getParkingDescription(map);
|
||||
|
||||
}
|
||||
|
||||
public String getFormattedTime(long time){
|
||||
return plugin.getFormattedTime(time, map);
|
||||
|
@ -187,5 +182,6 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.routepointsnavigation;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -53,11 +52,6 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
return null;
|
||||
|
@ -142,5 +136,4 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Vibrator;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.RequiresPermission;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout.LayoutParams;
|
||||
import android.widget.ImageView;
|
||||
|
@ -30,32 +36,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class ContextMenuLayer extends OsmandMapLayer {
|
||||
|
||||
public interface IContextMenuProvider {
|
||||
|
||||
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 static final Log LOG = PlatformUtil.getLog(ContextMenuLayer.class);
|
||||
public static final int VIBRATE_SHORT = 100;
|
||||
|
||||
private OsmandMapTileView view;
|
||||
|
||||
|
@ -73,11 +55,16 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
private GestureDetector movementListener;
|
||||
|
||||
private final MoveMarkerBottomSheetHelper mMoveMarkerBottomSheetHelper;
|
||||
private boolean mInChangeMarkerPositionMode;
|
||||
private IContextMenuProvider selectedObjectContextMenuProvider;
|
||||
|
||||
public ContextMenuLayer(MapActivity activity) {
|
||||
this.activity = activity;
|
||||
menu = activity.getContextMenu();
|
||||
multiSelectionMenu = menu.getMultiSelectionMenu();
|
||||
movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener());
|
||||
mMoveMarkerBottomSheetHelper = new MoveMarkerBottomSheetHelper(activity, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,9 +75,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
public void initLayer(OsmandMapTileView 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.setImageDrawable(view.getResources().getDrawable(R.drawable.map_pin_context_menu));
|
||||
contextMarker.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.map_pin_context_menu));
|
||||
contextMarker.setClickable(true);
|
||||
int minw = contextMarker.getDrawable().getMinimumWidth();
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
|
@ -151,17 +145,126 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
@Override
|
||||
@RequiresPermission(Manifest.permission.VIBRATE)
|
||||
public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) {
|
||||
if (disableLongPressOnMap()) {
|
||||
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);
|
||||
view.refreshMap();
|
||||
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) {
|
||||
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox().copy();
|
||||
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox();
|
||||
float x = cp.getPixXFromLatLon(latitude, longitude);
|
||||
float y = cp.getPixYFromLatLon(latitude, longitude);
|
||||
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);
|
||||
if (selectedObjects.size() == 1) {
|
||||
Object selectedObj = selectedObjects.keySet().iterator().next();
|
||||
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
|
||||
selectedObjectContextMenuProvider = selectedObjects.get(selectedObj);
|
||||
LatLon latLon = null;
|
||||
PointDescription pointDescription = null;
|
||||
if (contextObject != null) {
|
||||
latLon = contextObject.getObjectLocation(selectedObj);
|
||||
pointDescription = contextObject.getObjectName(selectedObj);
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
latLon = selectedObjectContextMenuProvider.getObjectLocation(selectedObj);
|
||||
pointDescription = selectedObjectContextMenuProvider.getObjectName(selectedObj);
|
||||
}
|
||||
if (latLon == null) {
|
||||
latLon = getLatLon(point, tileBox);
|
||||
}
|
||||
hideVisibleMenues();
|
||||
activity.getMapViewTrackingUtilities().locationChanged(latLon.getLatitude(), latLon.getLongitude(), this);
|
||||
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
menu.show(latLon, pointDescription, selectedObj);
|
||||
return true;
|
||||
|
||||
} else if (selectedObjects.size() > 1) {
|
||||
selectedObjectContextMenuProvider = null;
|
||||
showContextMenuForSelectedObjects(getLatLon(point, tileBox), selectedObjects);
|
||||
return true;
|
||||
|
||||
} else if (showUnknownLocation) {
|
||||
hideVisibleMenues();
|
||||
LatLon latLon = getLatLon(point, tileBox);
|
||||
activity.getMapViewTrackingUtilities().locationChanged(latLon.getLatitude(), latLon.getLongitude(), this);
|
||||
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
menu.show(latLon, null, null);
|
||||
return true;
|
||||
}
|
||||
|
@ -223,6 +327,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public boolean disableLongPressOnMap() {
|
||||
if (mInChangeMarkerPositionMode) {
|
||||
return true;
|
||||
}
|
||||
boolean res = false;
|
||||
for (OsmandMapLayer lt : view.getLayers()) {
|
||||
if (lt instanceof ContextMenuLayer.IContextMenuProvider) {
|
||||
|
@ -272,20 +379,32 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
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();
|
||||
Rect bs = contextMarker.getDrawable().getBounds();
|
||||
int dx = (int) (px - tb.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()));
|
||||
int dy = (int) (py - tb.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude()));
|
||||
int bx = dx + bs.width() / 2;
|
||||
int by = dy + bs.height();
|
||||
return (bs.contains(bx, by));
|
||||
markerX = tb.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
markerY = tb.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
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
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if (mInChangeMarkerPositionMode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pressedContextMarker(tileBox, point.x, point.y)) {
|
||||
hideVisibleMenues();
|
||||
menu.show();
|
||||
|
@ -337,9 +456,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true);
|
||||
if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) {
|
||||
view.refreshMap();
|
||||
if (!mInChangeMarkerPositionMode) {
|
||||
selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true);
|
||||
if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) {
|
||||
view.refreshMap();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
|
@ -353,6 +474,40 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
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 {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.graphics.PointF;
|
|||
import android.text.TextPaint;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -431,11 +430,6 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
return view.getContext().getString(R.string.shared_string_map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if (o instanceof DownloadMapObject) {
|
||||
|
@ -547,4 +541,5 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
public void clearSelectedObject() {
|
||||
selectedObjects = new LinkedList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
|
@ -21,34 +14,40 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider, MapTextProvider<LocationPoint> {
|
||||
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider,
|
||||
ContextMenuLayer.IMoveObjectProvider, MapTextProvider<FavouritePoint> {
|
||||
|
||||
protected int startZoom = 6;
|
||||
|
||||
protected OsmandMapTileView view;
|
||||
private Paint paint;
|
||||
private FavouritesDbHelper favorites;
|
||||
protected List<LocationPoint> cache = new ArrayList<LocationPoint>();
|
||||
protected List<FavouritePoint> cache = new ArrayList<FavouritePoint>();
|
||||
private MapTextLayer textLayer;
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
private Paint paintIcon;
|
||||
private Bitmap pointSmall;
|
||||
private int defaultColor;
|
||||
|
||||
private OsmandSettings settings;
|
||||
|
||||
protected Class<? extends LocationPoint> getFavoriteClass() {
|
||||
return (Class<? extends LocationPoint>) FavouritePoint.class;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String getObjName() {
|
||||
return view.getContext().getString(R.string.favorite);
|
||||
}
|
||||
|
||||
protected List<? extends LocationPoint> getPoints() {
|
||||
protected List<? extends FavouritePoint> getPoints() {
|
||||
return favorites.getFavouritePoints();
|
||||
}
|
||||
|
||||
|
@ -62,6 +61,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
settings = view.getApplication().getSettings();
|
||||
favorites = view.getApplication().getFavorites();
|
||||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||
defaultColor = view.getResources().getColor(R.color.color_favorite);
|
||||
|
@ -87,6 +87,12 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
@Override
|
||||
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
|
||||
|
@ -100,10 +106,10 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
// request to load
|
||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
List<LocationPoint> fullObjects = new ArrayList<>();
|
||||
List<FavouritePoint> fullObjects = new ArrayList<>();
|
||||
List<LatLon> fullObjectsLatLon = new ArrayList<>();
|
||||
List<LatLon> smallObjectsLatLon = new ArrayList<>();
|
||||
for (LocationPoint o : getPoints()) {
|
||||
for (FavouritePoint o : getPoints()) {
|
||||
if (!o.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -111,6 +117,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
|
||||
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
||||
@ColorInt
|
||||
int col = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor();
|
||||
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
for (LocationPoint o : fullObjects) {
|
||||
drawPoint(canvas, tileBox, latLonBounds, o);
|
||||
for (FavouritePoint o : fullObjects) {
|
||||
if (o != contextMenuLayer.getMoveableObject()) {
|
||||
drawPoint(canvas, tileBox, latLonBounds, o);
|
||||
}
|
||||
}
|
||||
this.fullObjectsLatLon = fullObjectsLatLon;
|
||||
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
|
||||
&& o.getLongitude() <= latLonBounds.right ) {
|
||||
cache.add(o);
|
||||
|
@ -142,8 +151,6 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true);
|
||||
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;
|
||||
}
|
||||
|
||||
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 ex = (int) point.x;
|
||||
int ey = (int) point.y;
|
||||
for (LocationPoint n : getPoints()) {
|
||||
for (FavouritePoint n : getPoints()) {
|
||||
getFavFromPoint(tb, res, r, ex, ey, n);
|
||||
}
|
||||
}
|
||||
|
||||
private void getFavFromPoint(RotatedTileBox tb, List<? super LocationPoint> res, int r, int ex, int ey,
|
||||
LocationPoint n) {
|
||||
private void getFavFromPoint(RotatedTileBox tb, List<? super FavouritePoint> res, int r, int ex, int ey,
|
||||
FavouritePoint n) {
|
||||
if (n.isVisible()) {
|
||||
int x = (int) tb.getPixXFromLatLon(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
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if(o instanceof LocationPoint){
|
||||
return ((LocationPoint) o).getPointDescription(view.getContext()); //$NON-NLS-1$
|
||||
if(o instanceof FavouritePoint){
|
||||
return ((FavouritePoint) o).getPointDescription(view.getContext()); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -204,7 +201,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
@Override
|
||||
public boolean isObjectClickable(Object o) {
|
||||
return o instanceof LocationPoint;
|
||||
return o instanceof FavouritePoint && o != contextMenuLayer.getMoveableObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,28 +213,41 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
|
||||
@Override
|
||||
public LatLon getObjectLocation(Object o) {
|
||||
if(o instanceof LocationPoint){
|
||||
return new LatLon(((LocationPoint)o).getLatitude(), ((LocationPoint)o).getLongitude());
|
||||
if(o instanceof FavouritePoint){
|
||||
return new LatLon(((FavouritePoint)o).getLatitude(), ((FavouritePoint)o).getLongitude());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLon getTextLocation(LocationPoint o) {
|
||||
public LatLon getTextLocation(FavouritePoint o) {
|
||||
return new LatLon(o.getLatitude(), o.getLongitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextShift(LocationPoint o, RotatedTileBox rb) {
|
||||
public int getTextShift(FavouritePoint o, RotatedTileBox rb) {
|
||||
return (int) (16 * rb.getDensity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LocationPoint o) {
|
||||
public String getText(FavouritePoint o) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.graphics.PointF;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
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
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if(o instanceof WptPt){
|
||||
|
@ -473,6 +464,4 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -146,11 +145,6 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if (o instanceof RouteDataObject) {
|
||||
|
|
|
@ -89,12 +89,14 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private MapHudButton layersHud;
|
||||
private long lastZoom;
|
||||
private boolean hasTargets;
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
|
||||
public MapControlsLayer(MapActivity activity) {
|
||||
this.mapActivity = activity;
|
||||
app = activity.getMyApplication();
|
||||
settings = activity.getMyApplication().getSettings();
|
||||
mapView = mapActivity.getMapView();
|
||||
contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
|
||||
}
|
||||
|
||||
public MapRouteInfoMenu getMapRouteInfoMenu() {
|
||||
|
@ -504,7 +506,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
boolean showRouteCalculationControls = routePlanningMode ||
|
||||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
|
||||
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);
|
||||
if (rh.isFollowingMode()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.os.Handler;
|
|||
import android.os.Message;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -450,13 +449,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
if (o instanceof MapMarker) {
|
||||
return ((MapMarker) o).getPointDescription(view.getContext()).getFullPlainName(view.getContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -489,4 +481,5 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
@Override
|
||||
public void clearSelectedObject() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ public abstract class OsmandMapLayer {
|
|||
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public <Params> void executeTaskInBackground(AsyncTask<Params, ?, ?> task, Params... params) {
|
||||
task.execute(params);
|
||||
|
|
|
@ -133,7 +133,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
|
||||
private AccessibilityActionsProvider accessibilityActions;
|
||||
|
||||
private List<OsmandMapLayer> layers = new ArrayList<OsmandMapLayer>();
|
||||
private List<OsmandMapLayer> layers = new ArrayList<>();
|
||||
|
||||
private BaseMapLayer mainLayer;
|
||||
|
||||
|
@ -604,6 +604,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected void drawMapPosition(Canvas canvas, float x, float y) {
|
||||
canvas.drawCircle(x, y, 3 * dm.density, paintCenter);
|
||||
canvas.drawCircle(x, y, 7 * dm.density, paintCenter);
|
||||
|
|
|
@ -33,7 +33,6 @@ import android.widget.LinearLayout;
|
|||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
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
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if (o instanceof Amenity) {
|
||||
|
@ -558,4 +549,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.Paint;
|
|||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -175,10 +174,6 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
return getMyLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
return view.getResources().getString(R.string.shared_string_my_location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -223,4 +218,5 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.Paint;
|
|||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
|
@ -227,13 +226,6 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
if (o instanceof TargetPoint) {
|
||||
return ((TargetPoint) o).getPointDescription(view.getContext()).getFullPlainName(view.getContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
|
@ -242,4 +234,6 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.graphics.Paint;
|
|||
import android.graphics.PointF;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
|
@ -171,14 +170,6 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectDescription(Object o) {
|
||||
if(o instanceof TransportStop){
|
||||
return getStopDescription((TransportStop) o, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if(o instanceof TransportStop){
|
||||
|
@ -217,4 +208,5 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,5 +64,4 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile project(":eclipse-compile:appcompat")
|
||||
}
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
include ':OsmAnd-java'
|
||||
include ':eclipse-compile:gridlayout'
|
||||
include ':eclipse-compile:cardview'
|
||||
include ':eclipse-compile:design'
|
||||
include ':eclipse-compile:appcompat'
|
||||
include ':OsmAnd'
|
||||
include ':plugins:OsmAnd-AddressPlugin'
|
||||
include ':plugins:Osmand-ParkingPlugin'
|
||||
|
|
Loading…
Reference in a new issue