diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 84fcbb11d7..e7e5fdaeb4 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -1,6 +1,7 @@ package net.osmand.plus; import android.content.Context; +import android.text.format.DateUtils; import net.osmand.data.Amenity; import net.osmand.data.City.CityType; @@ -52,6 +53,10 @@ public class OsmAndFormatter { return hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (sec < 10 ? "0" + sec : sec); } + public static String getFormattedDate(Context context, long milliseconds) { + return DateUtils.formatDateTime(context, milliseconds, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); + } + public static double calculateRoundedDist(double distInMeters, OsmandApplication ctx) { OsmandSettings settings = ctx.getSettings(); MetricsConstants mc = settings.METRIC_SYSTEM.get(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java index ba03ff372d..7fee517a1c 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java @@ -16,9 +16,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.views.DirectionDrawable; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; public class MapMarkerDialogHelper { @@ -101,14 +98,7 @@ public class MapMarkerDialogHelper { descText.setVisibility(View.GONE); - 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 desc = OsmAndFormatter.getFormattedDate(app, marker.creationDate); String markerGroupName = marker.groupName; if (markerGroupName != null) { if (markerGroupName.equals("")) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 7c554c4c4e..99f626b93c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.widget.ImageView; import net.osmand.AndroidUtils; import net.osmand.data.LatLon; +import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.UiUtilities; import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MapMarker; @@ -18,14 +19,10 @@ import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; import net.osmand.plus.R; import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.util.Algorithms; -import java.text.SimpleDateFormat; import java.util.Collections; -import java.util.Date; import java.util.List; -import java.util.Locale; public class MapMarkersActiveAdapter extends RecyclerView.Adapter implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter { @@ -136,14 +133,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter 1) { - month = Character.toUpperCase(month.charAt(0)) + month.substring(1); - } - month = month.replaceAll("\\.", ""); - String day = new SimpleDateFormat("d", Locale.getDefault()).format(date); - descr = month + " " + day; + descr = OsmAndFormatter.getFormattedDate(mapActivity, marker.creationDate); } if (marker.wptPt != null && !Algorithms.isEmpty(marker.wptPt.category)) { descr = marker.wptPt.category + ", " + descr; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index d8aa980092..65ededa04f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -17,6 +17,7 @@ import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GPXUtilities; +import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.UiUtilities; import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.GroupHeader; @@ -27,7 +28,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.dashboard.DashLocationFragment; import net.osmand.plus.mapmarkers.SelectWptCategoriesBottomSheetDialogFragment; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelArticle; @@ -38,7 +38,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -318,19 +317,13 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter 1) { - month = Character.toUpperCase(month.charAt(0)) + month.substring(1); - } - month = month.replaceAll("\\.", ""); - String day = new SimpleDateFormat("d", Locale.getDefault()).format(date); - itemViewHolder.description.setText(app.getString(R.string.passed, month + " " + day)); + itemViewHolder.description.setText(app.getString(R.string.passed, OsmAndFormatter.getFormattedDate(app, date))); } else { itemViewHolder.point.setVisibility(View.GONE); itemViewHolder.description.setVisibility(View.GONE); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java index e92753543b..356994fb77 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java @@ -8,6 +8,7 @@ import android.view.View; import android.view.ViewGroup; import net.osmand.AndroidUtils; +import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.UiUtilities; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; @@ -122,14 +123,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter 1) { - month = Character.toUpperCase(month.charAt(0)) + month.substring(1); - } - month = month.replaceAll("\\.", ""); - String day = new SimpleDateFormat("d", Locale.getDefault()).format(date); - String desc = app.getString(R.string.passed, month + " " + day); + String desc = app.getString(R.string.passed, OsmAndFormatter.getFormattedDate(app, marker.visitedDate)); String markerGroupName = marker.groupName; if (markerGroupName != null) { if (markerGroupName.equals("")) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java index 7e8f730cac..c2a0f75879 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersListAdapter.java @@ -24,12 +24,9 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.util.MapUtils; -import java.text.SimpleDateFormat; import java.util.Collections; -import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Locale; import java.util.Map; public class MapMarkersListAdapter extends RecyclerView.Adapter @@ -203,13 +200,7 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter 1) { - month = Character.toUpperCase(month.charAt(0)) + month.substring(1); - } - String day = new SimpleDateFormat("d", Locale.getDefault()).format(date); - descr = month + " " + day; + descr = OsmAndFormatter.getFormattedDate(app, marker.creationDate); } holder.description.setText(descr); }