From 0a09f46e85589131a920c2ee1bae11fbc0afd5de Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 7 Nov 2017 15:03:52 +0200 Subject: [PATCH 1/5] Remove delete option from marker menu on map --- .../res/layout/marker_menu_on_map_content.xml | 35 ------------------- .../mapmarkers/MarkerMenuOnMapFragment.java | 20 ----------- 2 files changed, 55 deletions(-) diff --git a/OsmAnd/res/layout/marker_menu_on_map_content.xml b/OsmAnd/res/layout/marker_menu_on_map_content.xml index 2a3f3e760a..3c8cefbff8 100644 --- a/OsmAnd/res/layout/marker_menu_on_map_content.xml +++ b/OsmAnd/res/layout/marker_menu_on_map_content.xml @@ -122,39 +122,4 @@ android:textAppearance="@style/TextAppearance.ListItemTitle"/> - - - - - - - - - diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java index 714edcdfc1..0a4d5084f2 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java @@ -82,7 +82,6 @@ public class MarkerMenuOnMapFragment extends BaseOsmAndFragment implements OsmAn ((ImageView) mainView.findViewById(R.id.marker_icon)) .setImageDrawable(getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex))); ((ImageView) mainView.findViewById(R.id.rename_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark)); - ((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark)); ((TextView) mainView.findViewById(R.id.marker_title)).setText(marker.getName(getActivity())); @@ -143,25 +142,6 @@ public class MarkerMenuOnMapFragment extends BaseOsmAndFragment implements OsmAn } }); - mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - app.getMapMarkersHelper().removeMarker(marker); - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - Snackbar.make(mapActivity.findViewById(R.id.bottomFragmentContainer), R.string.item_removed, Snackbar.LENGTH_LONG) - .setAction(R.string.shared_string_undo, new View.OnClickListener() { - @Override - public void onClick(View view) { - app.getMapMarkersHelper().addMarker(marker); - } - }) - .show(); - } - dismiss(); - } - }); - mainView.findViewById(R.id.back_row).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { From 1e64a284732e3ae10b3e511ee3c29eb87f56c95c Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 7 Nov 2017 16:59:39 +0200 Subject: [PATCH 2/5] Add the ability to rename the marker from the context menu --- OsmAnd/res/values/strings.xml | 1 + .../plus/mapcontextmenu/MapContextMenu.java | 48 ++++++++++++++----- .../MapContextMenuFragment.java | 12 ++--- .../plus/mapcontextmenu/MenuController.java | 10 ++++ .../controllers/MapMarkerMenuController.java | 10 ++++ .../mapmarkers/MarkerMenuOnMapFragment.java | 5 +- ...RenameMarkerBottomSheetDialogFragment.java | 12 +++++ 7 files changed, 72 insertions(+), 26 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 98c978f12d..d7c3bb7104 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 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 --> + Rename marker A tap on the map toggles the control buttons and widgets. Full screen mode Show on Top Bar diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 3d989f1929..b33f1f56ef 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -44,6 +44,7 @@ import net.osmand.plus.mapcontextmenu.editors.WptPtEditor; import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.mapmarkers.MapMarkersDialogFragment; +import net.osmand.plus.mapmarkers.RenameMarkerBottomSheetDialogFragment; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.ContextMenuLayer; @@ -87,6 +88,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL private boolean autoHide; private int favActionIconId; + private int waypointActionIconId; private MenuAction searchDoneAction; @@ -704,12 +706,27 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL return R.string.shared_string_add_to_favorites; } + public int getWaypointActionIconId() { + return waypointActionIconId; + } + + public int getWaypointActionStringId() { + if (menuController != null) { + return menuController.getWaypointActionStringId(); + } + return settings.USE_MAP_MARKERS.get() + ? R.string.shared_string_add_to_map_markers : R.string.context_menu_item_destination_point; + } + protected void acquireIcons() { super.acquireIcons(); if (menuController != null) { favActionIconId = menuController.getFavActionIconId(); + waypointActionIconId = menuController.getWaypointActionIconId(); } else { favActionIconId = R.drawable.map_action_fav_dark; + waypointActionIconId = settings.USE_MAP_MARKERS.get() + ? R.drawable.map_action_flag_dark : R.drawable.map_action_waypoint; } } @@ -745,20 +762,25 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } public void buttonWaypointPressed() { - if (pointDescription.isDestination()) { - mapActivity.getMapActions().editWaypoints(); - } else if (settings.USE_MAP_MARKERS.get()) { - if (pointDescription.isMapMarker()) { - hide(); - MapActivity.clearPrevActivityIntent(); - MapMarkersDialogFragment.showInstance(mapActivity); - } else { - mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), - getPointDescriptionForMarker()); - } + if (object != null && object instanceof MapMarker) { + RenameMarkerBottomSheetDialogFragment + .showInstance(mapActivity.getSupportFragmentManager(), (MapMarker) object); } else { - mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(), - getPointDescriptionForTarget()); + if (pointDescription.isDestination()) { + mapActivity.getMapActions().editWaypoints(); + } else if (settings.USE_MAP_MARKERS.get()) { + if (pointDescription.isMapMarker()) { + hide(); + MapActivity.clearPrevActivityIntent(); + MapMarkersDialogFragment.showInstance(mapActivity); + } else { + mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), + getPointDescriptionForMarker()); + } + } else { + mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(), + getPointDescriptionForTarget()); + } } close(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index e116f1e130..6abbc09581 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -455,15 +455,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo }); final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button); - if (getMyApplication().getSettings().USE_MAP_MARKERS.get()) { - buttonWaypoint.setImageDrawable(getIcon(R.drawable.map_action_flag_dark, - !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); - buttonWaypoint.setContentDescription(getString(R.string.shared_string_add_to_map_markers)); - } else { - buttonWaypoint.setImageDrawable(getIcon(R.drawable.map_action_waypoint, - !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); - buttonWaypoint.setContentDescription(getString(R.string.context_menu_item_destination_point)); - } + buttonWaypoint.setImageDrawable(getIcon(menu.getWaypointActionIconId(), + !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); + buttonWaypoint.setContentDescription(getString(menu.getWaypointActionStringId())); AndroidUtils.setDashButtonBackground(getMapActivity(), buttonWaypoint, nightMode); buttonWaypoint.setOnClickListener(new View.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index b5828dc67b..2b58f58a98 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -411,6 +411,16 @@ public abstract class MenuController extends BaseMenuController { return R.string.shared_string_add_to_favorites; } + public int getWaypointActionIconId() { + return getMapActivity().getMyApplication().getSettings().USE_MAP_MARKERS.get() + ? R.drawable.map_action_flag_dark : R.drawable.map_action_waypoint; + } + + public int getWaypointActionStringId() { + return getMapActivity().getMyApplication().getSettings().USE_MAP_MARKERS.get() + ? R.string.shared_string_add_to_map_markers : R.string.context_menu_item_destination_point; + } + public String getTypeStr() { return ""; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java index 3eeaca8c90..7977446d9f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java @@ -94,4 +94,14 @@ public class MapMarkerMenuController extends MenuController { public boolean needStreetName() { return !needTypeStr(); } + + @Override + public int getWaypointActionIconId() { + return R.drawable.map_action_edit_dark; + } + + @Override + public int getWaypointActionStringId() { + return R.string.rename_marker; + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java index 0a4d5084f2..7bddf682ca 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java @@ -134,10 +134,7 @@ public class MarkerMenuOnMapFragment extends BaseOsmAndFragment implements OsmAn public void onClick(View view) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - RenameMarkerBottomSheetDialogFragment fragment = new RenameMarkerBottomSheetDialogFragment(); - fragment.setMarker(marker); - fragment.setRetainInstance(true); - fragment.show(mapActivity.getSupportFragmentManager(), RenameMarkerBottomSheetDialogFragment.TAG); + RenameMarkerBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), marker); } } }); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java index 886c38794e..340563df87 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java @@ -162,4 +162,16 @@ public class RenameMarkerBottomSheetDialogFragment extends BottomSheetDialogFrag } super.onDestroyView(); } + + public static boolean showInstance(FragmentManager fm, MapMarker marker) { + try { + RenameMarkerBottomSheetDialogFragment fragment = new RenameMarkerBottomSheetDialogFragment(); + fragment.setMarker(marker); + fragment.setRetainInstance(true); + fragment.show(fm, RenameMarkerBottomSheetDialogFragment.TAG); + return true; + } catch (Exception e) { + return false; + } + } } From 1df11c1ad8cda9b6742df408146cc4912f12fdd3 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 7 Nov 2017 17:49:52 +0200 Subject: [PATCH 3/5] Fix text color --- .../mapmarkers/RenameMarkerBottomSheetDialogFragment.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java index 340563df87..a3a5aabcbe 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java @@ -7,6 +7,7 @@ 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.view.ContextThemeWrapper; import android.view.Gravity; import android.view.LayoutInflater; @@ -58,6 +59,9 @@ public class RenameMarkerBottomSheetDialogFragment extends BottomSheetDialogFrag } final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text); + if (nightMode) { + nameEditText.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_white)); + } nameEditText.setText(marker.getName(mapActivity)); nameEditText.requestFocus(); final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); From 548f8429217bc142fd77c04a3f0ff00edd5393e8 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 7 Nov 2017 17:59:22 +0200 Subject: [PATCH 4/5] Add padding from status bar --- .../mapcontextmenu/other/MapMultiSelectionMenuFragment.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java index 9a77d5f849..76c19aaa5a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java @@ -55,6 +55,10 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi } ListView listView = (ListView) view.findViewById(R.id.list); + if (menu.isLandscapeLayout() && Build.VERSION.SDK_INT >= 21) { + AndroidUtils.addStatusBarPadding21v(getActivity(), listView); + listView.setClipToPadding(false); + } listAdapter = createAdapter(); listView.setAdapter(listAdapter); listView.setOnItemClickListener(this); From 60009de4df544e6d563975e2bf1979afdc5d5c32 Mon Sep 17 00:00:00 2001 From: sonora Date: Wed, 8 Nov 2017 02:52:46 +0100 Subject: [PATCH 5/5] string cleanup --- .../fragment_plan_route_options_bottom_sheet_dialog.xml | 2 +- OsmAnd/res/values/strings.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml index 14af472791..1c9345234f 100644 --- a/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_plan_route_options_bottom_sheet_dialog.xml @@ -89,7 +89,7 @@ android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" - android:text="@string/shared_string_navigate" + android:text="@string/get_directions" android:textAppearance="@style/TextAppearance.ListItemTitle"/> diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index d7c3bb7104..c3228c7fd0 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -34,7 +34,7 @@ Modify OSM note Add copy of start point as destination. Make round trip - Navigate + Markers Coordinates format Use system keyboard @@ -2303,7 +2303,7 @@ Recorded voice Voice prompts Vector maps were not loaded - Navigate using GPX + No GPX files found in the tracks folder GPX trackā€¦ Error reading GPX data