Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
933f45c377
30 changed files with 1069 additions and 295 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet"
|
||||
android:id="@+id/add_gpx_point_bottom_sheet"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -25,14 +25,14 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet_title"
|
||||
android:id="@+id/add_gpx_point_bottom_sheet_title"
|
||||
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/add_gpx_waypoint_bottom_sheet_title"/>
|
||||
android:text="@string/waypoint_one"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
|
@ -53,7 +53,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/shared_string_create"/>
|
||||
android:text="@string/shared_string_add"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/cancel_button"
|
|
@ -262,7 +262,7 @@
|
|||
tools:visibility="visible"/>
|
||||
|
||||
<include
|
||||
layout="@layout/add_gpx_waypoint_bottom_sheet"
|
||||
layout="@layout/add_gpx_point_bottom_sheet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|left"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet"
|
||||
android:id="@+id/add_gpx_point_bottom_sheet"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -24,14 +24,14 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/add_gpx_waypoint_bottom_sheet_title"
|
||||
android:id="@+id/add_gpx_point_bottom_sheet_title"
|
||||
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/add_gpx_waypoint_bottom_sheet_title"/>
|
||||
tools:text="@string/waypoint_one"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
|
@ -55,7 +55,7 @@
|
|||
android:id="@+id/create_button"
|
||||
style="@style/DialogActionButton"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@string/shared_string_create"/>
|
||||
android:text="@string/shared_string_add"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
|
@ -43,11 +43,9 @@
|
|||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
tools:src="@drawable/ic_action_arrow_down"/>
|
||||
|
||||
<TextView
|
||||
|
@ -83,6 +81,28 @@
|
|||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/points_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="220dp"
|
||||
android:background="@color/ctx_menu_info_view_bg_dark"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<include layout="@layout/card_bottom_divider"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/points_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="215dp"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_onmap"/>
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -94,11 +114,9 @@
|
|||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
tools:src="@drawable/ic_action_undo_dark"/>
|
||||
|
||||
<ImageButton
|
||||
|
@ -106,11 +124,11 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/undo_point_button"
|
||||
android:layout_toRightOf="@id/undo_point_button"
|
||||
android:background="@null"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingStart="8dp"
|
||||
tools:src="@drawable/ic_action_redo_dark"/>
|
||||
|
||||
<Button
|
||||
|
|
|
@ -223,7 +223,7 @@
|
|||
<include layout="@layout/move_marker_bottom_sheet"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<include layout="@layout/add_gpx_waypoint_bottom_sheet"
|
||||
<include layout="@layout/add_gpx_point_bottom_sheet"
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<FrameLayout
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/MainLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -19,14 +21,93 @@
|
|||
android:groupIndicator="@android:color/transparent"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fabButton"
|
||||
android:id="@+id/menu_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_action_plus"
|
||||
android:contentDescription="@string/quick_action_new_action"
|
||||
app:backgroundTint="@color/dashboard_blue"/>
|
||||
android:src="@drawable/ic_action_plus"
|
||||
app:backgroundTint="@color/dashboard_blue"
|
||||
app:fabSize="normal"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/waypoint_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/menu_fab"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="24dp"
|
||||
android:contentDescription="@string/quick_action_new_action"
|
||||
android:src="@drawable/ic_action_marker_dark"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/dashboard_blue"
|
||||
app:fabSize="mini"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/waypoint_text_layout"
|
||||
android:layout_toLeftOf="@id/waypoint_fab"
|
||||
android:layout_toStartOf="@id/waypoint_fab"
|
||||
android:layout_above="@id/menu_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/waypoint_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/add_waypoint"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/route_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/waypoint_fab"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:contentDescription="@string/quick_action_new_action"
|
||||
android:src="@drawable/ic_action_markers_dark"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/dashboard_blue"
|
||||
app:fabSize="mini"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/route_text_layout"
|
||||
android:layout_toLeftOf="@id/route_fab"
|
||||
android:layout_toStartOf="@id/route_fab"
|
||||
android:layout_above="@id/waypoint_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/route_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/add_route_point"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
60
OsmAnd/res/layout/save_gpx_dialog.xml
Normal file
60
OsmAnd/res/layout/save_gpx_dialog.xml
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/gpx_name_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:inputType="text"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_exists_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/file_with_name_already_exists"
|
||||
android:textColor="@color/marker_red"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_show_on_map"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@id/toggle_row_toggle"
|
||||
android:layout_toStartOf="@id/toggle_row_toggle"
|
||||
android:text="@string/show_on_map_after_saving"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -9,8 +9,11 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
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="measurement_tool_action_bar">Select a location on the map and click "Add" to add a point to the ruler.</string>
|
||||
<string name="measurement_tool">Measurement tool</string>
|
||||
<string name="none_point_error">You need to add at least one point.</string>
|
||||
<string name="enter_gpx_name">Enter name for GPX</string>
|
||||
<string name="show_on_map_after_saving">Show on map after saving</string>
|
||||
<string name="measurement_tool_action_bar">Browse map and add points to a line</string>
|
||||
<string name="measurement_tool">Measure distance</string>
|
||||
<string name="quick_action_resume_pause_navigation">Resume/Pause Navigation</string>
|
||||
<string name="quick_action_resume_pause_navigation_descr">Press this button to pause the navigation, or to resume it if it was already paused.</string>
|
||||
<string name="quick_action_show_navigation_finish_dialog">Show Finish navigation dialog</string>
|
||||
|
@ -2660,6 +2663,10 @@
|
|||
<string name="shared_string_action_name">Action name</string>
|
||||
<string name="mappilary_no_internet_desc">You need internet to view photos from Mapillary</string>
|
||||
<string name="retry">Retry</string>
|
||||
<string name="add_gpx_waypoint_bottom_sheet_title">Add gpx waypoint</string>
|
||||
<string name="shared_string_create">Create</string>
|
||||
<string name="add_route_point">Add Route Point</string>
|
||||
<string name="add_waypoint">Add Waypoint</string>
|
||||
<string name="save_gpx_waypoint">Save GPX Waypoint</string>
|
||||
<string name="save_route_point">Save Route Point</string>
|
||||
<string name="waypoint_one">Waypoint 1</string>
|
||||
<string name="route_point_one">Route Point 1</string>
|
||||
</resources>
|
||||
|
|
|
@ -24,6 +24,7 @@ public class PointDescription {
|
|||
|
||||
public static final String POINT_TYPE_FAVORITE = "favorite";
|
||||
public static final String POINT_TYPE_WPT = "wpt";
|
||||
public static final String POINT_TYPE_RTE = "rte";
|
||||
public static final String POINT_TYPE_POI = "poi";
|
||||
public static final String POINT_TYPE_ADDRESS = "address";
|
||||
public static final String POINT_TYPE_OSM_NOTE= "osm_note";
|
||||
|
@ -212,6 +213,10 @@ public class PointDescription {
|
|||
return POINT_TYPE_WPT.equals(type);
|
||||
}
|
||||
|
||||
public boolean isRte() {
|
||||
return POINT_TYPE_RTE.equals(type);
|
||||
}
|
||||
|
||||
public boolean isPoi() {
|
||||
return POINT_TYPE_POI.equals(type);
|
||||
}
|
||||
|
|
|
@ -102,18 +102,6 @@ public class GPXUtilities {
|
|||
public float speed;
|
||||
}
|
||||
|
||||
public static class NewGpxWaypoint {
|
||||
private GPXFile gpx;
|
||||
|
||||
public NewGpxWaypoint(GPXFile gpx) {
|
||||
this.gpx = gpx;
|
||||
}
|
||||
|
||||
public GPXFile getGpx() {
|
||||
return gpx;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WptPt extends GPXExtensions implements LocationPoint {
|
||||
public boolean firstPoint = false;
|
||||
public boolean lastPoint = false;
|
||||
|
@ -872,6 +860,29 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
points.add(pt);
|
||||
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
public WptPt addRtePt(double lat, double lon, long time, String description, String name, String category, int color) {
|
||||
double latAdjusted = Double.parseDouble(latLonFormat.format(lat));
|
||||
double lonAdjusted = Double.parseDouble(latLonFormat.format(lon));
|
||||
final WptPt pt = new WptPt(latAdjusted, lonAdjusted, time, Double.NaN, 0, Double.NaN);
|
||||
pt.name = name;
|
||||
pt.category = category;
|
||||
pt.desc = description;
|
||||
if (color != 0) {
|
||||
pt.setColor(color);
|
||||
}
|
||||
|
||||
if (routes.size() == 0) {
|
||||
routes.add(new Route());
|
||||
}
|
||||
Route currentRoute = routes.get(routes.size() -1);
|
||||
currentRoute.points.add(pt);
|
||||
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
|
||||
return pt;
|
||||
|
|
|
@ -57,8 +57,6 @@ import net.osmand.plus.AppInitializer;
|
|||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||
import net.osmand.plus.AppInitializer.InitEvents;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
|
@ -97,6 +95,7 @@ import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
|
|||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -105,6 +104,7 @@ import net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback;
|
|||
import net.osmand.plus.search.QuickSearchDialogFragment;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.MapControlsLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
|
@ -500,6 +500,14 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (getMeasurementToolFragment() != null) {
|
||||
getMeasurementToolFragment().showQuitDialog();
|
||||
return;
|
||||
}
|
||||
if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) {
|
||||
mapContextMenu.close();
|
||||
return;
|
||||
}
|
||||
if (prevActivityIntent != null && getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
||||
prevActivityIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
LatLon loc = getMapLocation();
|
||||
|
@ -918,9 +926,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
} else if (toShow instanceof QuadRect) {
|
||||
QuadRect qr = (QuadRect) toShow;
|
||||
mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0);
|
||||
} else if (toShow instanceof NewGpxWaypoint) {
|
||||
NewGpxWaypoint newGpxWaypoint = (NewGpxWaypoint) toShow;
|
||||
getMapLayers().getContextMenuLayer().enterAddGpxWaypointMode(newGpxWaypoint);
|
||||
} else if (toShow instanceof NewGpxPoint) {
|
||||
NewGpxPoint newGpxPoint = (NewGpxPoint) toShow;
|
||||
getMapLayers().getContextMenuLayer().enterAddGpxPointMode(newGpxPoint);
|
||||
} else {
|
||||
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
||||
}
|
||||
|
@ -1675,6 +1683,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return fragment!= null && !fragment.isDetached() && !fragment.isRemoving() ? (QuickSearchDialogFragment) fragment : null;
|
||||
}
|
||||
|
||||
public MeasurementToolFragment getMeasurementToolFragment() {
|
||||
Fragment fragment = getSupportFragmentManager().findFragmentByTag(MeasurementToolFragment.TAG);
|
||||
return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (MeasurementToolFragment) fragment : null;
|
||||
}
|
||||
|
||||
public boolean isTopToolbarActive() {
|
||||
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
|
||||
return mapInfoLayer.hasTopToolbar();
|
||||
|
|
|
@ -696,21 +696,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
|
||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.bottomFragmentContainer, fragment, MeasurementToolFragment.TAG)
|
||||
.addToBackStack(MeasurementToolFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
|
@ -774,6 +759,21 @@ public class MapActivityActions implements DialogProvider {
|
|||
}).createItem());
|
||||
*/
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
|
||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.bottomFragmentContainer, fragment, MeasurementToolFragment.TAG)
|
||||
.addToBackStack(MeasurementToolFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
||||
.setIcon(R.drawable.ic_extension_dark)
|
||||
.setListener(new ItemClickListener() {
|
||||
|
@ -843,16 +843,16 @@ public class MapActivityActions implements DialogProvider {
|
|||
//////////// Others
|
||||
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
|
||||
int pluginsItemIndex = -1;
|
||||
int measureDistanceItemIndex = -1;
|
||||
for (int i = 0; i < optionsMenuHelper.length(); i++) {
|
||||
if (optionsMenuHelper.getItem(i).getTitleId() == R.string.prefs_plugins) {
|
||||
pluginsItemIndex = i;
|
||||
if (optionsMenuHelper.getItem(i).getTitleId() == R.string.measurement_tool) {
|
||||
measureDistanceItemIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ItemBuilder divider = new ItemBuilder().setLayout(R.layout.drawer_divider);
|
||||
divider.setPosition(pluginsItemIndex >= 0 ? pluginsItemIndex : 7);
|
||||
divider.setPosition(measureDistanceItemIndex >= 0 ? measureDistanceItemIndex : 8);
|
||||
optionsMenuHelper.addItem(divider.createItem());
|
||||
|
||||
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.util.List;
|
|||
public class TrackActivity extends TabActivity {
|
||||
|
||||
public static final String TRACK_FILE_NAME = "TRACK_FILE_NAME";
|
||||
public static final String OPEN_POINTS_TAB = "OPEN_POINTS_TAB";
|
||||
public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
|
||||
protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
|
||||
protected PagerSlidingTabStrip slidingTabLayout;
|
||||
|
@ -47,6 +48,7 @@ public class TrackActivity extends TabActivity {
|
|||
private List<GpxDisplayGroup> displayGroups;
|
||||
private List<GpxDisplayGroup> originalGroups = new ArrayList<>();
|
||||
private boolean stopped = false;
|
||||
public boolean openPointsTab = false;
|
||||
|
||||
public PagerSlidingTabStrip getSlidingTabLayout() {
|
||||
return slidingTabLayout;
|
||||
|
@ -75,6 +77,9 @@ public class TrackActivity extends TabActivity {
|
|||
}
|
||||
actionBar.setElevation(0);
|
||||
}
|
||||
if (intent.hasExtra(OPEN_POINTS_TAB)) {
|
||||
openPointsTab = true;
|
||||
}
|
||||
setContentView(R.layout.tab_content);
|
||||
}
|
||||
|
||||
|
@ -188,6 +193,9 @@ public class TrackActivity extends TabActivity {
|
|||
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
||||
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
|
||||
getTabIndicator(R.string.points, TrackPointFragment.class));
|
||||
if (openPointsTab) {
|
||||
mViewPager.setCurrentItem(1, false);
|
||||
}
|
||||
} else {
|
||||
slidingTabLayout.setVisibility(View.GONE);
|
||||
getSupportActionBar().setElevation(AndroidUtils.dpToPx(getMyApplication(), 4f));
|
||||
|
|
|
@ -40,6 +40,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
|
|||
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
|
@ -64,6 +65,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
|
||||
private FavoritePointEditor favoritePointEditor;
|
||||
private WptPtEditor wptPtEditor;
|
||||
private RtePtEditor rtePtEditor;
|
||||
|
||||
private boolean active;
|
||||
private LatLon latLon;
|
||||
|
@ -147,6 +149,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
if (wptPtEditor != null) {
|
||||
wptPtEditor.setMapActivity(mapActivity);
|
||||
}
|
||||
if (rtePtEditor != null) {
|
||||
rtePtEditor.setMapActivity(mapActivity);
|
||||
}
|
||||
|
||||
if (active) {
|
||||
acquireMenuController(false);
|
||||
|
@ -196,11 +201,20 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
return wptPtEditor;
|
||||
}
|
||||
|
||||
public RtePtEditor getRtePtPointEditor() {
|
||||
if (rtePtEditor == null) {
|
||||
rtePtEditor = new RtePtEditor(mapActivity);
|
||||
}
|
||||
return rtePtEditor;
|
||||
}
|
||||
|
||||
public PointEditor getPointEditor(String tag) {
|
||||
if (favoritePointEditor != null && favoritePointEditor.getFragmentTag().equals(tag)) {
|
||||
return favoritePointEditor;
|
||||
} else if (wptPtEditor != null && wptPtEditor.getFragmentTag().equals(tag)) {
|
||||
return wptPtEditor;
|
||||
} else if (rtePtEditor != null && rtePtEditor.getFragmentTag().equals(tag)) {
|
||||
return rtePtEditor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -379,15 +393,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
init(latLon, pointDescription, object, true, false);
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().rebuildMenu();
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuildMenu() {
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().rebuildMenu();
|
||||
fragmentRef.get().rebuildMenu(centerMarker);
|
||||
}
|
||||
centerMarker = false;
|
||||
}
|
||||
|
||||
public void showOrUpdate(LatLon latLon, PointDescription pointDescription, Object object) {
|
||||
|
@ -609,8 +617,12 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
|
||||
public void onSingleTapOnMap() {
|
||||
if (menuController == null || !menuController.handleSingleTapOnMap()) {
|
||||
if (menuController != null && !menuController.isClosable()) {
|
||||
hide();
|
||||
} else {
|
||||
updateMapCenter(null);
|
||||
close();
|
||||
}
|
||||
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn()) {
|
||||
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
|
||||
}
|
||||
|
@ -994,6 +1006,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
return menuController == null || menuController.fabVisible();
|
||||
}
|
||||
|
||||
public boolean isClosable() {
|
||||
return menuController == null || menuController.isClosable();
|
||||
}
|
||||
|
||||
public boolean buttonsVisible() {
|
||||
return menuController == null || menuController.buttonsVisible();
|
||||
}
|
||||
|
|
|
@ -792,7 +792,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
menu.setMapZoom(0);
|
||||
}
|
||||
|
||||
public void rebuildMenu() {
|
||||
public void rebuildMenu(boolean centered) {
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null && view != null) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
|
@ -807,6 +807,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
bottomLayout.removeAllViews();
|
||||
buildBottomView();
|
||||
|
||||
if (centered) {
|
||||
this.initLayout = true;
|
||||
this.centered = true;
|
||||
}
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
|
@ -1284,7 +1288,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
public void downloadHasFinished() {
|
||||
updateOnDownload();
|
||||
if (menu != null && menu.isVisible() && menu.isMapDownloaded()) {
|
||||
rebuildMenu();
|
||||
rebuildMenu(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ public class MenuBuilder {
|
|||
private LatLon latLon;
|
||||
private boolean hidden;
|
||||
private boolean showNearestWiki = false;
|
||||
private boolean showOnlinePhotos = true;
|
||||
protected List<Amenity> nearestWiki = new ArrayList<>();
|
||||
private List<OsmandPlugin> menuPlugins = new ArrayList<>();
|
||||
private CardsRowBuilder onlinePhotoCardsRow;
|
||||
|
@ -207,6 +208,14 @@ public class MenuBuilder {
|
|||
this.showNearestWiki = showNearestWiki;
|
||||
}
|
||||
|
||||
public boolean isShowOnlinePhotos() {
|
||||
return showOnlinePhotos;
|
||||
}
|
||||
|
||||
public void setShowOnlinePhotos(boolean showOnlinePhotos) {
|
||||
this.showOnlinePhotos = showOnlinePhotos;
|
||||
}
|
||||
|
||||
public void setShowNearestWiki(boolean showNearestWiki, long objectId) {
|
||||
this.objectId = objectId;
|
||||
this.showNearestWiki = showNearestWiki;
|
||||
|
@ -228,7 +237,9 @@ public class MenuBuilder {
|
|||
buildPlainMenuItems(view);
|
||||
}
|
||||
buildInternal(view);
|
||||
if (showOnlinePhotos) {
|
||||
buildNearestPhotosRow(view);
|
||||
}
|
||||
buildPluginRows(view);
|
||||
buildAfter(view);
|
||||
}
|
||||
|
|
|
@ -348,6 +348,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isClosable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean needStreetName() {
|
||||
return !displayDistanceDirection();
|
||||
}
|
||||
|
|
|
@ -10,13 +10,11 @@ import net.osmand.data.TransportStop;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
|
||||
import net.osmand.plus.views.TransportStopsLayer;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
public class TransportRouteController extends MenuController {
|
||||
|
@ -27,6 +25,7 @@ public class TransportRouteController extends MenuController {
|
|||
final TransportStopRoute transportRoute) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.transportRoute = transportRoute;
|
||||
builder.setShowOnlinePhotos(false);
|
||||
toolbarController = new ContextMenuToolbarController(this);
|
||||
toolbarController.setTitle(getNameStr());
|
||||
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
|
||||
|
@ -83,21 +82,26 @@ public class TransportRouteController extends MenuController {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buttonsVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return super.displayStreetNameInTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
if (transportRoute.refStop != null) {
|
||||
return transportRoute.refStop.getName();
|
||||
} else if (transportRoute.stop != null) {
|
||||
return transportRoute.stop.getName();
|
||||
} else {
|
||||
return getPointDescription().getTypeName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow() {
|
||||
|
@ -154,15 +158,32 @@ public class TransportRouteController extends MenuController {
|
|||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
MapContextMenu menu = getMapActivity().getContextMenu();
|
||||
if (mapContextMenu != null) {
|
||||
transportRoute.stop = stop;
|
||||
transportRoute.refStop = stop;
|
||||
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
|
||||
transportRoute.getDescription(getMapActivity().getMyApplication(), false));
|
||||
|
||||
LatLon stopLocation = stop.getLocation();
|
||||
if (mapContextMenu.isVisible()) {
|
||||
mapContextMenu.updateMapCenter(stopLocation);
|
||||
} else {
|
||||
mapContextMenu.setMapCenter(stopLocation);
|
||||
mapContextMenu.setMapPosition(getMapActivity().getMapView().getMapPosition());
|
||||
}
|
||||
mapContextMenu.setCenterMarker(true);
|
||||
mapContextMenu.setMapZoom(15);
|
||||
mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute);
|
||||
}
|
||||
/*
|
||||
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP,
|
||||
getMapActivity().getString(R.string.transport_Stop), name);
|
||||
resetRoute();
|
||||
menu.show(stop.getLocation(), pd, stop);
|
||||
WeakReference<MapContextMenuFragment> rr = menu.findMenuFragment();
|
||||
if (rr != null && rr.get() != null) {
|
||||
rr.get().centerMarkerLocation();
|
||||
}
|
||||
LatLon stopLocation = stop.getLocation();
|
||||
getMapActivity().getMyApplication().getSettings()
|
||||
.setMapLocationToShow(stopLocation.getLatitude(), stopLocation.getLongitude(),
|
||||
15, pd, false, transportRoute);
|
||||
MapActivity.launchMapActivityMoveToTop(getMapActivity());
|
||||
*/
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class RtePtEditor extends WptPtEditor {
|
||||
|
||||
public static final String TAG = "RtePtEditorFragment";
|
||||
|
||||
public RtePtEditor(MapActivity mapActivity) {
|
||||
super(mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEditorFragment() {
|
||||
RtePtEditorFragment.showInstance(mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showEditorFragment(boolean skipDialog) {
|
||||
RtePtEditorFragment.showInstance(mapActivity, skipDialog);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package net.osmand.plus.mapcontextmenu.editors;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class RtePtEditorFragment extends WptPtEditorFragment {
|
||||
|
||||
@Override
|
||||
public void assignEditor() {
|
||||
editor = getMapActivity().getContextMenu().getRtePtPointEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolbarTitle() {
|
||||
return getMapActivity().getResources().getString(R.string.save_route_point);
|
||||
}
|
||||
|
||||
public static void showInstance(final MapActivity mapActivity) {
|
||||
RtePtEditor editor = mapActivity.getContextMenu().getRtePtPointEditor();
|
||||
//int slideInAnim = editor.getSlideInAnimation();
|
||||
//int slideOutAnim = editor.getSlideOutAnimation();
|
||||
|
||||
RtePtEditorFragment fragment = new RtePtEditorFragment();
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.fragmentContainer, fragment, editor.getFragmentTag())
|
||||
.addToBackStack(null).commit();
|
||||
}
|
||||
|
||||
public static void showInstance(final MapActivity mapActivity, boolean skipDialog) {
|
||||
RtePtEditor editor = mapActivity.getContextMenu().getRtePtPointEditor();
|
||||
//int slideInAnim = editor.getSlideInAnimation();
|
||||
//int slideOutAnim = editor.getSlideOutAnimation();
|
||||
|
||||
RtePtEditorFragment fragment = new RtePtEditorFragment();
|
||||
fragment.skipDialog = skipDialog;
|
||||
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.fragmentContainer, fragment, editor.getFragmentTag())
|
||||
.addToBackStack(null).commit();
|
||||
}
|
||||
}
|
|
@ -9,9 +9,11 @@ import net.osmand.plus.activities.MapActivity;
|
|||
|
||||
public class WptPtEditor extends PointEditor {
|
||||
|
||||
private OnDismissListener onDismissListener;
|
||||
private GPXFile gpxFile;
|
||||
private WptPt wpt;
|
||||
private boolean gpxSelected;
|
||||
private boolean newGpxPointProcessing;
|
||||
|
||||
public static final String TAG = "WptPtEditorFragment";
|
||||
|
||||
|
@ -19,9 +21,24 @@ public class WptPtEditor extends PointEditor {
|
|||
super(mapActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
public void setNewGpxPointProcessing(boolean newGpxPointProcessing) {
|
||||
this.newGpxPointProcessing = newGpxPointProcessing;
|
||||
}
|
||||
|
||||
public boolean isNewGpxPointProcessing() {
|
||||
return newGpxPointProcessing;
|
||||
}
|
||||
|
||||
public interface OnDismissListener {
|
||||
void onDismiss();
|
||||
}
|
||||
|
||||
public void setOnDismissListener(OnDismissListener listener) {
|
||||
onDismissListener = listener;
|
||||
}
|
||||
|
||||
public OnDismissListener getOnDismissListener() {
|
||||
return onDismissListener;
|
||||
}
|
||||
|
||||
public GPXFile getGpxFile() {
|
||||
|
@ -36,6 +53,11 @@ public class WptPtEditor extends PointEditor {
|
|||
return wpt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
public void add(GPXFile gpxFile, LatLon latLon, String title) {
|
||||
if (latLon == null) {
|
||||
return;
|
||||
|
@ -50,7 +72,7 @@ public class WptPtEditor extends PointEditor {
|
|||
wpt = new WptPt(latLon.getLatitude(), latLon.getLongitude(),
|
||||
System.currentTimeMillis(), Double.NaN, 0, Double.NaN);
|
||||
wpt.name = title;
|
||||
WptPtEditorFragment.showInstance(mapActivity);
|
||||
showEditorFragment();
|
||||
}
|
||||
|
||||
public void add(GPXFile gpxFile, LatLon latLon, String title, String categoryName, int categoryColor, boolean skipDialog) {
|
||||
|
@ -86,7 +108,7 @@ public class WptPtEditor extends PointEditor {
|
|||
|
||||
wpt.category = categoryName;
|
||||
|
||||
WptPtEditorFragment.showInstance(mapActivity, skipDialog);
|
||||
showEditorFragment(skipDialog);
|
||||
}
|
||||
|
||||
public void edit(WptPt wpt) {
|
||||
|
@ -101,6 +123,14 @@ public class WptPtEditor extends PointEditor {
|
|||
gpxFile = selectedGpxFile.getGpxFile();
|
||||
}
|
||||
this.wpt = wpt;
|
||||
showEditorFragment();
|
||||
}
|
||||
|
||||
public void showEditorFragment() {
|
||||
WptPtEditorFragment.showInstance(mapActivity);
|
||||
}
|
||||
|
||||
public void showEditorFragment(boolean skipDialog) {
|
||||
WptPtEditorFragment.showInstance(mapActivity, skipDialog);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
|||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -26,7 +27,8 @@ import net.osmand.util.Algorithms;
|
|||
import java.io.File;
|
||||
|
||||
public class WptPtEditorFragment extends PointEditorFragment {
|
||||
private WptPtEditor editor;
|
||||
|
||||
protected WptPtEditor editor;
|
||||
private WptPt wpt;
|
||||
private SavingTrackHelper savingTrackHelper;
|
||||
private GpxSelectionHelper selectedGpxHelper;
|
||||
|
@ -34,17 +36,21 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
private boolean saved;
|
||||
private int color;
|
||||
private int defaultColor;
|
||||
private boolean skipDialog;
|
||||
protected boolean skipDialog;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
savingTrackHelper = getMapActivity().getMyApplication().getSavingTrackHelper();
|
||||
selectedGpxHelper = getMapActivity().getMyApplication().getSelectedGpxHelper();
|
||||
editor = getMapActivity().getContextMenu().getWptPtPointEditor();
|
||||
assignEditor();
|
||||
defaultColor = getResources().getColor(R.color.gpx_color_point);
|
||||
}
|
||||
|
||||
protected void assignEditor() {
|
||||
editor = getMapActivity().getContextMenu().getWptPtPointEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -69,6 +75,17 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss(boolean includingMenu) {
|
||||
super.dismiss(includingMenu);
|
||||
OnDismissListener listener = editor.getOnDismissListener();
|
||||
if (listener != null) {
|
||||
listener.onDismiss();
|
||||
}
|
||||
editor.setNewGpxPointProcessing(false);
|
||||
editor.setOnDismissListener(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointEditor getEditor() {
|
||||
return editor;
|
||||
|
@ -76,12 +93,16 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
|
||||
@Override
|
||||
public String getToolbarTitle() {
|
||||
if (editor.isNewGpxPointProcessing()) {
|
||||
return getMapActivity().getResources().getString(R.string.save_gpx_waypoint);
|
||||
} else {
|
||||
if (editor.isNew()) {
|
||||
return getMapActivity().getResources().getString(R.string.context_menu_item_add_waypoint);
|
||||
} else {
|
||||
return getMapActivity().getResources().getString(R.string.shared_string_edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void showInstance(final MapActivity mapActivity) {
|
||||
WptPtEditor editor = mapActivity.getContextMenu().getWptPtPointEditor();
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
|
|||
import net.osmand.plus.mapcontextmenu.MenuTitleController;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -194,8 +195,8 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
public void openContextMenu(@NonNull MenuObject menuObject) {
|
||||
IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject());
|
||||
hide();
|
||||
getMapActivity().getMapLayers().getContextMenuLayer().showContextMenu(
|
||||
menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
|
||||
ContextMenuLayer contextMenuLayer = getMapActivity().getMapLayers().getContextMenuLayer();
|
||||
contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
|
||||
}
|
||||
|
||||
private void clearSelectedObjects() {
|
||||
|
|
|
@ -1,20 +1,35 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.Route;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -23,6 +38,16 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
|||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
import net.osmand.plus.widgets.IconPopupMenu;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
|
||||
import static net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import static net.osmand.plus.helpers.GpxImportHelper.GPX_SUFFIX;
|
||||
|
||||
public class MeasurementToolFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "MeasurementToolFragment";
|
||||
|
@ -33,23 +58,27 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private String pointsSt;
|
||||
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean pointsDetailsOpened;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
final IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
final int backgroundColor = ContextCompat.getColor(getActivity(),
|
||||
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
|
||||
pointsSt = mapActivity.getString(R.string.points).toLowerCase();
|
||||
pointsSt = getString(R.string.points).toLowerCase();
|
||||
|
||||
View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_measurement_tool, null);
|
||||
|
||||
final View mainView = view.findViewById(R.id.main_view);
|
||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
view.findViewById(R.id.points_list_container).setBackgroundColor(backgroundColor);
|
||||
|
||||
distanceTv = (TextView) mainView.findViewById(R.id.measurement_distance_text_view);
|
||||
pointsTv = (TextView) mainView.findViewById(R.id.measurement_points_text_view);
|
||||
|
@ -62,7 +91,11 @@ public class MeasurementToolFragment extends Fragment {
|
|||
upDownBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getActivity(), "Up / Down", Toast.LENGTH_SHORT).show();
|
||||
if (!pointsDetailsOpened) {
|
||||
upBtnOnClick(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_down));
|
||||
} else {
|
||||
downBtnOnClick(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -101,23 +134,23 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
measurementLayer.addPointOnClick();
|
||||
enable(undoBtn);
|
||||
enable(undoBtn, upDownBtn);
|
||||
disable(redoBtn);
|
||||
updateText();
|
||||
}
|
||||
});
|
||||
|
||||
disable(undoBtn, redoBtn);
|
||||
disable(undoBtn, redoBtn, upDownBtn);
|
||||
|
||||
enterMeasurementMode();
|
||||
|
||||
if (portrait) {
|
||||
toolBarController = new MeasurementToolBarController();
|
||||
toolBarController.setTitle(mapActivity.getString(R.string.measurement_tool_action_bar));
|
||||
toolBarController.setTitle(getString(R.string.measurement_tool_action_bar));
|
||||
toolBarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.onBackPressed();
|
||||
showQuitDialog();
|
||||
}
|
||||
});
|
||||
toolBarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
||||
|
@ -134,11 +167,15 @@ public class MeasurementToolFragment extends Fragment {
|
|||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.action_save_as_gpx:
|
||||
Toast.makeText(mapActivity, "Save as gpx", Toast.LENGTH_SHORT).show();
|
||||
if (measurementLayer.getPointsCount() > 0) {
|
||||
saveAsGpxOnClick(mapActivity);
|
||||
} else {
|
||||
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_clear_all:
|
||||
measurementLayer.clearPoints();
|
||||
disable(undoBtn, redoBtn);
|
||||
disable(undoBtn, redoBtn, upDownBtn);
|
||||
updateText();
|
||||
return true;
|
||||
}
|
||||
|
@ -154,6 +191,147 @@ public class MeasurementToolFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
private void upBtnOnClick(View view, Drawable icon) {
|
||||
pointsDetailsOpened = true;
|
||||
view.findViewById(R.id.points_list_container).setVisibility(View.VISIBLE);
|
||||
((ImageButton) view.findViewById(R.id.up_down_button)).setImageDrawable(icon);
|
||||
}
|
||||
|
||||
private void downBtnOnClick(View view, Drawable icon) {
|
||||
pointsDetailsOpened = false;
|
||||
view.findViewById(R.id.points_list_container).setVisibility(View.GONE);
|
||||
((ImageButton) view.findViewById(R.id.up_down_button)).setImageDrawable(icon);
|
||||
}
|
||||
|
||||
private void saveAsGpxOnClick(MapActivity mapActivity) {
|
||||
final File dir = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
final LayoutInflater inflater = getLayoutInflater();
|
||||
final View view = inflater.inflate(R.layout.save_gpx_dialog, null);
|
||||
final EditText nameEt = (EditText) view.findViewById(R.id.gpx_name_et);
|
||||
final TextView fileExistsTv = (TextView) view.findViewById(R.id.file_exists_text_view);
|
||||
final SwitchCompat showOnMapToggle = (SwitchCompat) view.findViewById(R.id.toggle_show_on_map);
|
||||
showOnMapToggle.setChecked(true);
|
||||
|
||||
final String suggestedName = new SimpleDateFormat("yyyy-M-dd_HH-mm_EEE", Locale.US).format(new Date());
|
||||
String displayedName = suggestedName;
|
||||
File fout = new File(dir, suggestedName + GPX_SUFFIX);
|
||||
int ind = 1;
|
||||
while (fout.exists()) {
|
||||
displayedName = suggestedName + "_" + (++ind);
|
||||
fout = new File(dir, displayedName + GPX_SUFFIX);
|
||||
}
|
||||
nameEt.setText(displayedName);
|
||||
nameEt.setSelection(displayedName.length());
|
||||
|
||||
final boolean[] textChanged = new boolean[1];
|
||||
nameEt.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (new File(dir, editable.toString() + GPX_SUFFIX).exists()) {
|
||||
fileExistsTv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
fileExistsTv.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
textChanged[0] = true;
|
||||
}
|
||||
});
|
||||
|
||||
new AlertDialog.Builder(mapActivity)
|
||||
.setTitle(R.string.enter_gpx_name)
|
||||
.setView(view)
|
||||
.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final String name = nameEt.getText().toString();
|
||||
String fileName = name + GPX_SUFFIX;
|
||||
if (textChanged[0]) {
|
||||
File fout = new File(dir, fileName);
|
||||
int ind = 1;
|
||||
while (fout.exists()) {
|
||||
fileName = name + "_" + (++ind) + GPX_SUFFIX;
|
||||
fout = new File(dir, fileName);
|
||||
}
|
||||
}
|
||||
saveGpx(dir, fileName, showOnMapToggle.isChecked());
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void saveGpx(final File dir, final String fileName, final boolean showOnMap) {
|
||||
new AsyncTask<Void, Void, String>() {
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
private File toSave;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
MapActivity activity = getMapActivity();
|
||||
if (activity != null) {
|
||||
progressDialog = new ProgressDialog(activity);
|
||||
progressDialog.setMessage(getString(R.string.saving_gpx_tracks));
|
||||
progressDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... voids) {
|
||||
toSave = new File(dir, fileName);
|
||||
GPXFile gpx = new GPXFile();
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
LinkedList<WptPt> points = measurementLayer.getMeasurementPoints();
|
||||
if (points.size() == 1) {
|
||||
gpx.points.add(points.getFirst());
|
||||
} else if (points.size() > 1) {
|
||||
Route rt = new Route();
|
||||
gpx.routes.add(rt);
|
||||
rt.points.addAll(points);
|
||||
}
|
||||
}
|
||||
MapActivity activity = getMapActivity();
|
||||
if (activity != null) {
|
||||
String res = GPXUtilities.writeGpxFile(toSave, gpx, activity.getMyApplication());
|
||||
gpx.path = toSave.getAbsolutePath();
|
||||
if (showOnMap) {
|
||||
activity.getMyApplication().getSelectedGpxHelper().selectGpxFile(gpx, true, false);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String warning) {
|
||||
MapActivity activity = getMapActivity();
|
||||
if (activity != null) {
|
||||
if (warning == null) {
|
||||
Toast.makeText(activity,
|
||||
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), toSave.getAbsolutePath()),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(activity, warning, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
activity.refreshMap();
|
||||
}
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
@ -252,6 +430,36 @@ public class MeasurementToolFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void showQuitDialog() {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (mapActivity != null && measurementLayer != null) {
|
||||
if (measurementLayer.getPointsCount() < 1) {
|
||||
dismiss(mapActivity);
|
||||
return;
|
||||
}
|
||||
new AlertDialog.Builder(mapActivity)
|
||||
.setTitle(getString(R.string.are_you_sure))
|
||||
.setMessage(getString(R.string.unsaved_changes_will_be_lost))
|
||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dismiss(mapActivity);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void dismiss(MapActivity mapActivity) {
|
||||
try {
|
||||
mapActivity.getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private static class MeasurementToolBarController extends TopToolbarController {
|
||||
|
||||
MeasurementToolBarController() {
|
||||
|
|
|
@ -5,27 +5,31 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class MeasurementToolLayer extends OsmandMapLayer {
|
||||
public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||
|
||||
private OsmandMapTileView view;
|
||||
private boolean inMeasurementMode;
|
||||
private LinkedList<WptPt> measurementPoints = new LinkedList<>();
|
||||
private LinkedList<WptPt> cacheMeasurementPoints;
|
||||
private LinkedList<WptPt> cacheMeasurementPoints = new LinkedList<>();
|
||||
private Bitmap centerIconDay;
|
||||
private Bitmap centerIconNight;
|
||||
private Bitmap pointIcon;
|
||||
|
@ -66,6 +70,10 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
return measurementPoints.size();
|
||||
}
|
||||
|
||||
public LinkedList<WptPt> getMeasurementPoints() {
|
||||
return measurementPoints;
|
||||
}
|
||||
|
||||
String getDistanceSt() {
|
||||
float dist = 0;
|
||||
if (measurementPoints.size() > 0) {
|
||||
|
@ -104,16 +112,19 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
}
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
|
||||
if (tb.containsLatLon(pt.lat, pt.lon)) {
|
||||
canvas.drawBitmap(pointIcon, locX - marginX, locY - marginY, bitmapPaint);
|
||||
}
|
||||
}
|
||||
path.lineTo(tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
tx.add(tb.getCenterPixelX());
|
||||
ty.add(tb.getCenterPixelY());
|
||||
calculatePath(tb, tx, ty, path);
|
||||
canvas.drawPath(path, lineAttrs.paint);
|
||||
for (WptPt pt : measurementPoints) {
|
||||
if (tb.containsLatLon(pt.lat, pt.lon)) {
|
||||
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||
canvas.drawBitmap(pointIcon, locX - marginX, locY - marginY, bitmapPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,8 +160,10 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
|
||||
boolean undoPointOnClick() {
|
||||
measurementPoints.remove(measurementPoints.size() - 1);
|
||||
if (measurementPoints.size() > 0) {
|
||||
WptPt pt = measurementPoints.get(measurementPoints.size() - 1);
|
||||
view.getAnimatedDraggingThread().startMoving(pt.getLatitude(), pt.getLongitude(), view.getZoom(), true);
|
||||
}
|
||||
return measurementPoints.size() > 0;
|
||||
}
|
||||
|
||||
|
@ -170,4 +183,34 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
public boolean drawInScreenPixels() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLon getObjectLocation(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableSingleTap() {
|
||||
return isInMeasurementMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableLongPressOnMap() {
|
||||
return isInMeasurementMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObjectClickable(Object o) {
|
||||
return !isInMeasurementMode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.os.Handler;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ActionMode;
|
||||
|
@ -20,6 +21,7 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
|
@ -30,16 +32,13 @@ import android.widget.ListView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
|
@ -58,6 +57,7 @@ import net.osmand.plus.activities.TrackActivity;
|
|||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.base.OsmandExpandableListFragment;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -93,7 +93,12 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
private Set<Integer> selectedGroups = new LinkedHashSet<>();
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
private FloatingActionButton fab;
|
||||
private boolean menuOpened = false;
|
||||
private FloatingActionButton menuFab;
|
||||
private FloatingActionButton waypointFab;
|
||||
private View waypointTextLayout;
|
||||
private FloatingActionButton routePointFab;
|
||||
private View routePointTextLayout;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
@ -104,6 +109,20 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
|
||||
if (menuOpened) {
|
||||
closeMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
|
||||
}
|
||||
});
|
||||
listView.setBackgroundColor(getResources().getColor(
|
||||
getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
||||
: R.color.ctx_menu_info_view_bg_dark));
|
||||
|
@ -115,26 +134,38 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
fab = (FloatingActionButton) view.findViewById(R.id.fabButton);
|
||||
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
menuFab = (FloatingActionButton) view.findViewById(R.id.menu_fab);
|
||||
menuFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
GPXFile gpx = getGpx();
|
||||
Location location = app.getLocationProvider().getLastKnownLocation();
|
||||
if (location != null) {
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.context_menu_item_add_waypoint)),
|
||||
false,
|
||||
new NewGpxWaypoint(gpx));
|
||||
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
if (menuOpened) {
|
||||
closeMenu();
|
||||
} else {
|
||||
openMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
waypointFab = (FloatingActionButton) view.findViewById(R.id.waypoint_fab);
|
||||
waypointFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.add_waypoint));
|
||||
addPoint(pointDescription);
|
||||
}
|
||||
});
|
||||
waypointTextLayout = view.findViewById(R.id.waypoint_text_layout);
|
||||
|
||||
routePointFab = (FloatingActionButton) view.findViewById(R.id.route_fab);
|
||||
routePointFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_RTE, getString(R.string.add_route_point));
|
||||
addPoint(pointDescription);
|
||||
}
|
||||
});
|
||||
routePointTextLayout = view.findViewById(R.id.route_text_layout);
|
||||
|
||||
TextView tv = new TextView(getActivity());
|
||||
tv.setText(R.string.none_selected_gpx);
|
||||
tv.setTextSize(24);
|
||||
|
@ -146,6 +177,43 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
private void addPoint(PointDescription pointDescription) {
|
||||
Intent currentIntent = getTrackActivity().getIntent();
|
||||
if (currentIntent != null) {
|
||||
currentIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||
}
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
GPXFile gpx = getGpx();
|
||||
LatLon location = settings.getLastKnownMapLocation();
|
||||
if (gpx != null && location != null) {
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
pointDescription,
|
||||
false,
|
||||
new NewGpxPoint(gpx, pointDescription));
|
||||
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
private void openMenu() {
|
||||
menuFab.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_remove_dark));
|
||||
waypointFab.setVisibility(View.VISIBLE);
|
||||
waypointTextLayout.setVisibility(View.VISIBLE);
|
||||
routePointFab.setVisibility(View.VISIBLE);
|
||||
routePointTextLayout.setVisibility(View.VISIBLE);
|
||||
menuOpened = true;
|
||||
}
|
||||
|
||||
private void closeMenu() {
|
||||
menuFab.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_plus));
|
||||
waypointFab.setVisibility(View.GONE);
|
||||
waypointTextLayout.setVisibility(View.GONE);
|
||||
routePointFab.setVisibility(View.GONE);
|
||||
routePointTextLayout.setVisibility(View.GONE);
|
||||
menuOpened = false;
|
||||
}
|
||||
|
||||
public TrackActivity getTrackActivity() {
|
||||
return (TrackActivity) getActivity();
|
||||
}
|
||||
|
@ -168,6 +236,11 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
if (!adapter.isEmpty() && listView.getHeaderViewsCount() == 0) {
|
||||
listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_header, null, false));
|
||||
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
|
||||
View view = new View(getActivity());
|
||||
view.setLayoutParams(new AbsListView.LayoutParams(
|
||||
AbsListView.LayoutParams.MATCH_PARENT,
|
||||
AndroidUtils.dpToPx(getActivity(), 72)));
|
||||
listView.addFooterView(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,6 +343,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
menu.clear();
|
||||
getTrackActivity().getClearToolbar(false);
|
||||
MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark,
|
||||
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
searchView = new SearchView(getActivity());
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.PointF;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||
|
||||
public class AddGpxPointBottomSheetHelper implements OnDismissListener {
|
||||
private final View view;
|
||||
private final TextView title;
|
||||
private final TextView description;
|
||||
private final ImageView icon;
|
||||
private final MapActivity mapActivity;
|
||||
private final MapContextMenu contextMenu;
|
||||
private final ContextMenuLayer contextMenuLayer;
|
||||
private final IconsCache iconsCache;
|
||||
private String titleText;
|
||||
private boolean applyingPositionMode;
|
||||
private NewGpxPoint newGpxPoint;
|
||||
private PointDescription pointDescription;
|
||||
|
||||
public AddGpxPointBottomSheetHelper(final MapActivity activity, ContextMenuLayer ctxMenuLayer) {
|
||||
this.contextMenuLayer = ctxMenuLayer;
|
||||
iconsCache = activity.getMyApplication().getIconsCache();
|
||||
mapActivity = activity;
|
||||
contextMenu = activity.getContextMenu();
|
||||
view = activity.findViewById(R.id.add_gpx_point_bottom_sheet);
|
||||
title = (TextView) view.findViewById(R.id.add_gpx_point_bottom_sheet_title);
|
||||
description = (TextView) view.findViewById(R.id.description);
|
||||
icon = (ImageView) view.findViewById(R.id.icon);
|
||||
|
||||
view.findViewById(R.id.create_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
contextMenuLayer.createGpxPoint();
|
||||
GPXFile gpx = newGpxPoint.getGpx();
|
||||
LatLon latLon = contextMenu.getLatLon();
|
||||
if (pointDescription.isWpt()) {
|
||||
WptPtEditor editor = activity.getContextMenu().getWptPtPointEditor();
|
||||
editor.setOnDismissListener(AddGpxPointBottomSheetHelper.this);
|
||||
editor.setNewGpxPointProcessing(true);
|
||||
editor.add(gpx, latLon, titleText);
|
||||
} else if (pointDescription.isRte()) {
|
||||
RtePtEditor editor = activity.getContextMenu().getRtePtPointEditor();
|
||||
editor.setOnDismissListener(AddGpxPointBottomSheetHelper.this);
|
||||
editor.setNewGpxPointProcessing(true);
|
||||
editor.add(gpx, latLon, titleText);
|
||||
}
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hide();
|
||||
contextMenuLayer.cancelAddGpxPoint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onDraw(RotatedTileBox rt) {
|
||||
PointF point = contextMenuLayer.getMovableCenterPoint(rt);
|
||||
double lat = rt.getLatFromPixel(point.x, point.y);
|
||||
double lon = rt.getLonFromPixel(point.x, point.y);
|
||||
description.setText(PointDescription.getLocationName(mapActivity, lat, lon, true));
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
if (title.equals("")) {
|
||||
if (pointDescription.isWpt()) {
|
||||
title = mapActivity.getString(R.string.waypoint_one);
|
||||
} else if (pointDescription.isRte()) {
|
||||
title = mapActivity.getString(R.string.route_point_one);
|
||||
}
|
||||
}
|
||||
titleText = title;
|
||||
this.title.setText(titleText);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return view.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void show(NewGpxPoint newPoint) {
|
||||
this.newGpxPoint = newPoint;
|
||||
pointDescription = newPoint.getPointDescription();
|
||||
if (pointDescription.isWpt()) {
|
||||
setTitle(mapActivity.getString(R.string.waypoint_one));
|
||||
icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_marker_dark));
|
||||
} else if (pointDescription.isRte()) {
|
||||
setTitle(mapActivity.getString(R.string.route_point_one));
|
||||
icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_markers_dark));
|
||||
}
|
||||
exitApplyPositionMode();
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
exitApplyPositionMode();
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void enterApplyPositionMode() {
|
||||
if (!applyingPositionMode) {
|
||||
applyingPositionMode = true;
|
||||
view.findViewById(R.id.create_button).setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void exitApplyPositionMode() {
|
||||
if (applyingPositionMode) {
|
||||
applyingPositionMode = false;
|
||||
view.findViewById(R.id.create_button).setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
||||
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, newGpxPoint.getGpx().path);
|
||||
newIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(newIntent);
|
||||
}
|
||||
|
||||
public static class NewGpxPoint {
|
||||
private PointDescription pointDescription;
|
||||
private GPXFile gpx;
|
||||
|
||||
public NewGpxPoint(GPXFile gpx, PointDescription pointDescription) {
|
||||
this.gpx = gpx;
|
||||
this.pointDescription = pointDescription;
|
||||
}
|
||||
|
||||
public GPXFile getGpx() {
|
||||
return gpx;
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
return pointDescription;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
|
||||
public class AddWaypointBottomSheetHelper {
|
||||
private final View view;
|
||||
private final TextView title;
|
||||
private String titleText = "";
|
||||
private final TextView description;
|
||||
private final Context context;
|
||||
private final MapContextMenu contextMenu;
|
||||
private final ContextMenuLayer contextMenuLayer;
|
||||
private boolean applyingPositionMode;
|
||||
private NewGpxWaypoint newGpxWaypoint;
|
||||
|
||||
public AddWaypointBottomSheetHelper(final MapActivity activity, ContextMenuLayer ctxMenuLayer) {
|
||||
this.contextMenuLayer = ctxMenuLayer;
|
||||
view = activity.findViewById(R.id.add_gpx_waypoint_bottom_sheet);
|
||||
title = (TextView) view.findViewById(R.id.add_gpx_waypoint_bottom_sheet_title);
|
||||
description = (TextView) view.findViewById(R.id.description);
|
||||
context = activity;
|
||||
contextMenu = activity.getContextMenu();
|
||||
ImageView icon = (ImageView) view.findViewById(R.id.icon);
|
||||
|
||||
IconsCache iconsCache = activity.getMyApplication().getIconsCache();
|
||||
icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_photo_dark, R.color.marker_green));
|
||||
view.findViewById(R.id.create_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
contextMenuLayer.createGpxWaypoint();
|
||||
GPXFile gpx = newGpxWaypoint.getGpx();
|
||||
LatLon latLon = contextMenu.getLatLon();
|
||||
activity.getContextMenu().getWptPtPointEditor().add(gpx, latLon, titleText);
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hide();
|
||||
contextMenuLayer.cancelAddGpxWaypoint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onDraw(RotatedTileBox rt) {
|
||||
PointF point = contextMenuLayer.getMovableCenterPoint(rt);
|
||||
double lat = rt.getLatFromPixel(point.x, point.y);
|
||||
double lon = rt.getLonFromPixel(point.x, point.y);
|
||||
description.setText(PointDescription.getLocationName(context, lat, lon, true));
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
titleText = title;
|
||||
this.title.setText(titleText);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return view.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public void show(Drawable drawable, NewGpxWaypoint newGpxWaypoint) {
|
||||
this.newGpxWaypoint = newGpxWaypoint;
|
||||
exitApplyPositionMode();
|
||||
view.setVisibility(View.VISIBLE);
|
||||
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
exitApplyPositionMode();
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void enterApplyPositionMode() {
|
||||
if (!applyingPositionMode) {
|
||||
applyingPositionMode = true;
|
||||
view.findViewById(R.id.create_button).setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void exitApplyPositionMode() {
|
||||
if (applyingPositionMode) {
|
||||
applyingPositionMode = false;
|
||||
view.findViewById(R.id.create_button).setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,13 +35,13 @@ import net.osmand.osm.PoiFilter;
|
|||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities.NewGpxWaypoint;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -76,14 +76,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private GestureDetector movementListener;
|
||||
|
||||
private final MoveMarkerBottomSheetHelper mMoveMarkerBottomSheetHelper;
|
||||
private final AddWaypointBottomSheetHelper mAddWaypointBottomSheetHelper;
|
||||
private final AddGpxPointBottomSheetHelper mAddGpxPointBottomSheetHelper;
|
||||
private boolean mInChangeMarkerPositionMode;
|
||||
private IContextMenuProvider selectedObjectContextMenuProvider;
|
||||
private boolean cancelApplyingNewMarkerPosition;
|
||||
private LatLon applyingMarkerLatLon;
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean mInGpxDetailsMode;
|
||||
private boolean mInAddGpxWaypointMode;
|
||||
private boolean mInAddGpxPointMode;
|
||||
|
||||
private List<String> publicTransportTypes;
|
||||
private Object selectedObject;
|
||||
|
@ -94,7 +94,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
multiSelectionMenu = menu.getMultiSelectionMenu();
|
||||
movementListener = new GestureDetector(activity, new MenuLayerOnGestureListener());
|
||||
mMoveMarkerBottomSheetHelper = new MoveMarkerBottomSheetHelper(activity, this);
|
||||
mAddWaypointBottomSheetHelper = new AddWaypointBottomSheetHelper(activity, this);
|
||||
mAddGpxPointBottomSheetHelper = new AddGpxPointBottomSheetHelper(activity, this);
|
||||
}
|
||||
|
||||
public AddGpxPointBottomSheetHelper getAddGpxPointBottomSheetHelper() {
|
||||
return mAddGpxPointBottomSheetHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -207,10 +211,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
contextMarker.draw(canvas);
|
||||
}
|
||||
mMoveMarkerBottomSheetHelper.onDraw(box);
|
||||
} else if (mInAddGpxWaypointMode) {
|
||||
} else if (mInAddGpxPointMode) {
|
||||
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
mAddWaypointBottomSheetHelper.onDraw(box);
|
||||
mAddGpxPointBottomSheetHelper.onDraw(box);
|
||||
} else if (menu.isActive()) {
|
||||
LatLon latLon = menu.getLatLon();
|
||||
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
|
@ -289,7 +293,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public Object getMoveableObject() {
|
||||
return mInChangeMarkerPositionMode || mInAddGpxWaypointMode ? menu.getObject() : null;
|
||||
return mInChangeMarkerPositionMode ? menu.getObject() : null;
|
||||
}
|
||||
|
||||
public boolean isInChangeMarkerPositionMode() {
|
||||
|
@ -300,8 +304,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
return mInGpxDetailsMode;
|
||||
}
|
||||
|
||||
public boolean isInAddGpxWaypointMode() {
|
||||
return mInAddGpxWaypointMode;
|
||||
public boolean isInAddGpxPointMode() {
|
||||
return mInAddGpxPointMode;
|
||||
}
|
||||
|
||||
public boolean isObjectMoveable(Object o) {
|
||||
|
@ -318,14 +322,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public void applyMovedObject(Object o, LatLon position, ApplyMovedObjectCallback callback) {
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
if (selectedObjectContextMenuProvider != null && !isInAddGpxPointMode()) {
|
||||
if (selectedObjectContextMenuProvider instanceof IMoveObjectProvider) {
|
||||
final IMoveObjectProvider l = (IMoveObjectProvider) selectedObjectContextMenuProvider;
|
||||
if (l.isObjectMovable(o)) {
|
||||
l.applyNewObjectPosition(o, position, callback);
|
||||
}
|
||||
}
|
||||
} else if (mInChangeMarkerPositionMode || mInAddGpxWaypointMode) {
|
||||
} else if (mInChangeMarkerPositionMode || mInAddGpxPointMode) {
|
||||
callback.onApplyMovedObject(true, null);
|
||||
}
|
||||
}
|
||||
|
@ -351,11 +355,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
mMoveMarkerBottomSheetHelper.hide();
|
||||
quitMovingMarker();
|
||||
|
||||
PointDescription pointDescription = null;
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
pointDescription = selectedObjectContextMenuProvider.getObjectName(newObject);
|
||||
}
|
||||
menu.show(ll, pointDescription, newObject);
|
||||
|
||||
view.refreshMap();
|
||||
}
|
||||
selectedObjectContextMenuProvider = null;
|
||||
|
@ -369,9 +369,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
});
|
||||
}
|
||||
|
||||
public void createGpxWaypoint() {
|
||||
if (!mInAddGpxWaypointMode) {
|
||||
throw new IllegalStateException("Not in add gpx waypoint mode");
|
||||
public void createGpxPoint() {
|
||||
if (!mInAddGpxPointMode) {
|
||||
throw new IllegalStateException("Not in add gpx point mode");
|
||||
}
|
||||
|
||||
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
|
||||
|
@ -381,14 +381,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
Object obj = getMoveableObject();
|
||||
cancelApplyingNewMarkerPosition = false;
|
||||
mAddWaypointBottomSheetHelper.enterApplyPositionMode();
|
||||
mAddGpxPointBottomSheetHelper.enterApplyPositionMode();
|
||||
applyMovedObject(obj, ll, new ApplyMovedObjectCallback() {
|
||||
@Override
|
||||
public void onApplyMovedObject(boolean success, @Nullable Object newObject) {
|
||||
mAddWaypointBottomSheetHelper.exitApplyPositionMode();
|
||||
mAddGpxPointBottomSheetHelper.exitApplyPositionMode();
|
||||
if (success && !cancelApplyingNewMarkerPosition) {
|
||||
mAddWaypointBottomSheetHelper.hide();
|
||||
quitAddGpxWaipoint();
|
||||
mAddGpxPointBottomSheetHelper.hide();
|
||||
quitAddGpxPoint();
|
||||
|
||||
PointDescription pointDescription = null;
|
||||
if (selectedObjectContextMenuProvider != null) {
|
||||
|
@ -449,8 +449,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
private void quitAddGpxWaipoint() {
|
||||
mInAddGpxWaypointMode = false;
|
||||
private void quitAddGpxPoint() {
|
||||
mInAddGpxPointMode = 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);
|
||||
|
||||
|
@ -460,14 +460,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
public void enterAddGpxWaypointMode(NewGpxWaypoint newGpxWaypoint) {
|
||||
public void enterAddGpxPointMode(NewGpxPoint newGpxPoint) {
|
||||
menu.updateMapCenter(null);
|
||||
menu.hide();
|
||||
|
||||
activity.disableDrawer();
|
||||
|
||||
mInAddGpxWaypointMode = true;
|
||||
mAddWaypointBottomSheetHelper.show(menu.getLeftIcon(), newGpxWaypoint);
|
||||
mInAddGpxPointMode = true;
|
||||
mAddGpxPointBottomSheetHelper.show(newGpxPoint);
|
||||
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);
|
||||
|
||||
|
@ -529,9 +529,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
||||
public void cancelAddGpxWaypoint() {
|
||||
public void cancelAddGpxPoint() {
|
||||
cancelApplyingNewMarkerPosition = true;
|
||||
quitAddGpxWaipoint();
|
||||
quitAddGpxPoint();
|
||||
activity.getContextMenu().show();
|
||||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
@ -547,6 +547,11 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
@Nullable PointDescription pointDescription,
|
||||
@Nullable Object object,
|
||||
@Nullable IContextMenuProvider provider) {
|
||||
if (mInAddGpxPointMode) {
|
||||
String title = pointDescription == null ? "" : pointDescription.getName();
|
||||
mAddGpxPointBottomSheetHelper.setTitle(title);
|
||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||
} else {
|
||||
selectedObjectContextMenuProvider = provider;
|
||||
hideVisibleMenues();
|
||||
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
|
@ -556,6 +561,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
menu.setCenterMarker(true);
|
||||
}
|
||||
menu.show(latLon, pointDescription, object);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -641,10 +647,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
if (latLon == null) {
|
||||
latLon = getLatLon(point, tileBox);
|
||||
}
|
||||
if (mInAddGpxWaypointMode) {
|
||||
if (pointDescription != null) {
|
||||
mAddWaypointBottomSheetHelper.setTitle(pointDescription.getName());
|
||||
}
|
||||
if (mInAddGpxPointMode) {
|
||||
String title = pointDescription == null ? "" : pointDescription.getName();
|
||||
mAddGpxPointBottomSheetHelper.setTitle(title);
|
||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||
} else {
|
||||
showContextMenu(latLon, pointDescription, selectedObj, provider);
|
||||
|
@ -661,7 +666,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
selectedObjectContextMenuProvider = null;
|
||||
LatLon latLon = getLatLon(point, tileBox);
|
||||
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
if (mInAddGpxPointMode) {
|
||||
mAddGpxPointBottomSheetHelper.setTitle("");
|
||||
view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
|
||||
} else {
|
||||
menu.show(latLon, null, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -690,7 +700,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public boolean disableLongPressOnMap() {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxWaypointMode) {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxPointMode) {
|
||||
return true;
|
||||
}
|
||||
boolean res = false;
|
||||
|
@ -854,9 +864,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
if (movementListener.onTouchEvent(event)) {
|
||||
if (menu.isVisible()) {
|
||||
if (!menu.isClosable()) {
|
||||
menu.hide();
|
||||
} else {
|
||||
menu.updateMapCenter(null);
|
||||
menu.close();
|
||||
}
|
||||
}
|
||||
if (multiSelectionMenu.isVisible()) {
|
||||
multiSelectionMenu.hide();
|
||||
}
|
||||
|
|
|
@ -1120,8 +1120,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
private boolean isInMovingMarkerMode(){
|
||||
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxWaypointMode():
|
||||
mapQuickActionLayer.isInMovingMarkerMode() || contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxWaypointMode();
|
||||
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode():
|
||||
mapQuickActionLayer.isInMovingMarkerMode() || contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInAddGpxPointMode();
|
||||
}
|
||||
|
||||
private boolean isInGpxDetailsMode() {
|
||||
|
|
Loading…
Reference in a new issue