From 20a99ac9c6aa4914d84a16d9eb38492ce64c57df Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 28 Sep 2017 14:54:20 +0300 Subject: [PATCH] Replace Use My Location card with location item --- OsmAnd/res/layout/use_location_card.xml | 110 ------------ OsmAnd/res/values/strings.xml | 3 - .../src/net/osmand/plus/MapMarkersHelper.java | 4 +- .../plus/mapmarkers/PlanRouteFragment.java | 20 +-- .../adapters/MapMarkersListAdapter.java | 170 +++++++----------- 5 files changed, 73 insertions(+), 234 deletions(-) delete mode 100644 OsmAnd/res/layout/use_location_card.xml diff --git a/OsmAnd/res/layout/use_location_card.xml b/OsmAnd/res/layout/use_location_card.xml deleted file mode 100644 index 2401f4df67..0000000000 --- a/OsmAnd/res/layout/use_location_card.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 82b48f1fb2..4a25aa9adc 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,9 +11,6 @@ --> Choose oordinate format before start. YOu can always change it by tapping Options. Fast Coordinates input - Use location - Add your location as first point to plan perfect route. - My Location Finish Plan route Sort diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index fa6ff570d2..09fef6e6c1 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -225,7 +225,7 @@ public class MapMarkersHelper { this.ctx = ctx; settings = ctx.getSettings(); markersDbHelper = ctx.getMapMarkersDbHelper(); -// startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get(); + startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get(); removeDisabledGroups(); loadMarkers(); createMapMarkersGroups(); @@ -237,7 +237,7 @@ public class MapMarkersHelper { public void setStartFromMyLocation(boolean startFromMyLocation) { this.startFromMyLocation = startFromMyLocation; -// settings.ROUTE_MAP_MARKERS_START_MY_LOC.set(startFromMyLocation); + settings.ROUTE_MAP_MARKERS_START_MY_LOC.set(startFromMyLocation); } public void lookupAddressAll() { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index 7872a00953..fdc5c4ec1b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -196,9 +196,13 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene @Override public void onItemClick(View view) { int pos = markersRv.getChildAdapterPosition(view); - MapMarker marker = adapter.getItem(pos); - selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1; - marker.selected = !marker.selected; + if (pos == 0) { + Toast.makeText(mapActivity, "location selected", Toast.LENGTH_SHORT).show(); + } else { + MapMarker marker = adapter.getItem(pos); + selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1; + marker.selected = !marker.selected; + } adapter.notifyItemChanged(pos); updateSelectButton(); showMarkersRouteOnMap(); @@ -225,16 +229,6 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene } } } - - @Override - public void onUseLocationClick() { - Toast.makeText(mapActivity, "use location", Toast.LENGTH_SHORT).show(); - } - - @Override - public void onDoNotUseLocationClick() { - Toast.makeText(mapActivity, "do not use location", Toast.LENGTH_SHORT).show(); - } }); boolean isSmartphone = getResources().getConfiguration().smallestScreenWidthDp < 600; markersRv.setPadding(0, 0, 0, AndroidUtils.dpToPx(mapActivity, isSmartphone ? 72 : 108)); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java index 17bdbc117b..edb94ecb51 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java @@ -22,15 +22,11 @@ import java.util.Date; import java.util.List; import java.util.Locale; -public class MapMarkersListAdapter extends RecyclerView.Adapter +public class MapMarkersListAdapter extends RecyclerView.Adapter implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter { - private static final int USE_LOCATION_CARD_TYPE = 1; - private static final int MARKER_ITEM_TYPE = 2; - private MapActivity mapActivity; private List markers; - private boolean locationCardDisplayed = true; private MapMarkersListAdapterListener listener; private LatLon location; @@ -54,102 +50,79 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter