From d64c73ce377d3d5598a0153902afa299d20535b7 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 13 Oct 2017 16:00:17 +0300 Subject: [PATCH] Show date and group in marker selection --- OsmAnd/res/layout/map_marker_item.xml | 17 ++++++++++-- .../plus/helpers/MapMarkerDialogHelper.java | 27 ++++++++++++++++--- .../MapMarkerSelectionFragment.java | 2 +- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/layout/map_marker_item.xml b/OsmAnd/res/layout/map_marker_item.xml index 3b70e7b36d..1d09efa89a 100644 --- a/OsmAnd/res/layout/map_marker_item.xml +++ b/OsmAnd/res/layout/map_marker_item.xml @@ -79,15 +79,28 @@ + + diff --git a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java index d4bba497d5..4d7360b6a1 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java @@ -414,7 +414,7 @@ public class MapMarkerDialogHelper { v = mapActivity.getLayoutInflater().inflate(R.layout.map_marker_item, null); } updateMapMarkerInfo(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation, - selectionMode, helperCallbacks, marker); + selectionMode, helperCallbacks, marker, false); final View more = v.findViewById(R.id.all_points); final View move = v.findViewById(R.id.info_move); final View remove = v.findViewById(R.id.info_close); @@ -467,7 +467,7 @@ public class MapMarkerDialogHelper { Float heading, boolean useCenter, boolean nightMode, int screenOrientation, boolean selectionMode, final MapMarkersDialogHelperCallbacks helperCallbacks, - final MapMarker marker) { + final MapMarker marker, boolean showDateAndGroup) { TextView text = (TextView) localView.findViewById(R.id.waypoint_text); TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow); TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist); @@ -476,6 +476,7 @@ public class MapMarkerDialogHelper { TextView waypointDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation); TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text); final CheckBox checkBox = (CheckBox) localView.findViewById(R.id.checkbox); + TextView dateGroupText = (TextView) localView.findViewById(R.id.date_group_text); if (text == null || textDist == null || arrow == null || waypointIcon == null || waypointDeviation == null || descText == null) { @@ -538,6 +539,26 @@ public class MapMarkerDialogHelper { descText.setVisibility(View.GONE); + if (showDateAndGroup) { + Date date = new Date(marker.creationDate); + String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date); + if (month.length() > 1) { + month = Character.toUpperCase(month.charAt(0)) + month.substring(1); + } + month = month.replaceAll("\\.", ""); + String day = new SimpleDateFormat("d", Locale.getDefault()).format(date); + String desc = month + " " + day; + String markerGroupName = marker.groupName; + if (markerGroupName != null) { + if (markerGroupName.equals("")) { + markerGroupName = app.getString(R.string.shared_string_favorites); + } + desc += " • " + markerGroupName; + } + dateGroupText.setVisibility(View.VISIBLE); + dateGroupText.setText(desc); + } + if (selectionMode) { checkBox.setChecked(marker.selected); checkBox.setVisibility(View.VISIBLE); @@ -824,7 +845,7 @@ public class MapMarkerDialogHelper { View v = listView.getChildAt(i - listView.getFirstVisiblePosition()); if (obj == marker) { updateMapMarkerInfo(mapActivity, v, loc, heading, useCenter, nightMode, - screenOrientation, selectionMode, helperCallbacks, marker); + screenOrientation, selectionMode, helperCallbacks, marker, false); } } } catch (Exception e) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java index 2fed05401f..c1f0dd42d7 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java @@ -127,7 +127,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment { convertView = getMapActivity().getLayoutInflater().inflate(R.layout.map_marker_item, null); } MapMarkerDialogHelper.updateMapMarkerInfo(getContext(), convertView, loc, heading, - useCenter, nightMode, screenOrientation, false, null, marker); + useCenter, nightMode, screenOrientation, false, null, marker, true); final View remove = convertView.findViewById(R.id.info_close); remove.setVisibility(View.GONE); AndroidUtils.setListItemBackground(getMapActivity(), convertView, nightMode);