This commit is contained in:
Chumva 2018-09-18 13:23:48 +03:00
parent 0b335eae2f
commit 40a8d0e8ab
6 changed files with 16 additions and 53 deletions

View file

@ -1,6 +1,7 @@
package net.osmand.plus; package net.osmand.plus;
import android.content.Context; import android.content.Context;
import android.text.format.DateUtils;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.City.CityType; 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); 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) { public static double calculateRoundedDist(double distInMeters, OsmandApplication ctx) {
OsmandSettings settings = ctx.getSettings(); OsmandSettings settings = ctx.getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get(); MetricsConstants mc = settings.METRIC_SYSTEM.get();

View file

@ -16,9 +16,6 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.views.DirectionDrawable; import net.osmand.plus.views.DirectionDrawable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class MapMarkerDialogHelper { public class MapMarkerDialogHelper {
@ -101,14 +98,7 @@ public class MapMarkerDialogHelper {
descText.setVisibility(View.GONE); descText.setVisibility(View.GONE);
Date date = new Date(marker.creationDate); String desc = OsmAndFormatter.getFormattedDate(app, 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; String markerGroupName = marker.groupName;
if (markerGroupName != null) { if (markerGroupName != null) {
if (markerGroupName.equals("")) { if (markerGroupName.equals("")) {

View file

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; 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.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.text.SimpleDateFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder>
implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter { implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter {
@ -136,14 +133,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
descr = mapActivity.getString(R.string.shared_string_favorites); descr = mapActivity.getString(R.string.shared_string_favorites);
} }
} else { } else {
Date date = new Date(marker.creationDate); descr = OsmAndFormatter.getFormattedDate(mapActivity, 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);
descr = month + " " + day;
} }
if (marker.wptPt != null && !Algorithms.isEmpty(marker.wptPt.category)) { if (marker.wptPt != null && !Algorithms.isEmpty(marker.wptPt.category)) {
descr = marker.wptPt.category + ", " + descr; descr = marker.wptPt.category + ", " + descr;

View file

@ -17,6 +17,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.GroupHeader; import net.osmand.plus.MapMarkersHelper.GroupHeader;
@ -27,7 +28,6 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.mapmarkers.SelectWptCategoriesBottomSheetDialogFragment; import net.osmand.plus.mapmarkers.SelectWptCategoriesBottomSheetDialogFragment;
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelArticle;
@ -38,7 +38,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -318,19 +317,13 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
if (markerInHistory || createdEarly) { if (markerInHistory || createdEarly) {
itemViewHolder.point.setVisibility(View.VISIBLE); itemViewHolder.point.setVisibility(View.VISIBLE);
itemViewHolder.description.setVisibility(View.VISIBLE); itemViewHolder.description.setVisibility(View.VISIBLE);
Date date; long date;
if (markerInHistory) { if (markerInHistory) {
date = new Date(marker.visitedDate); date = marker.visitedDate;
} else { } else {
date = new Date(marker.creationDate); date = marker.creationDate;
} }
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date); itemViewHolder.description.setText(app.getString(R.string.passed, OsmAndFormatter.getFormattedDate(app, 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);
itemViewHolder.description.setText(app.getString(R.string.passed, month + " " + day));
} else { } else {
itemViewHolder.point.setVisibility(View.GONE); itemViewHolder.point.setVisibility(View.GONE);
itemViewHolder.description.setVisibility(View.GONE); itemViewHolder.description.setVisibility(View.GONE);

View file

@ -8,6 +8,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -122,14 +123,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
itemViewHolder.title.setText(marker.getName(app)); itemViewHolder.title.setText(marker.getName(app));
Date date = new Date(marker.visitedDate); String desc = app.getString(R.string.passed, OsmAndFormatter.getFormattedDate(app, marker.visitedDate));
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 = app.getString(R.string.passed, month + " " + day);
String markerGroupName = marker.groupName; String markerGroupName = marker.groupName;
if (markerGroupName != null) { if (markerGroupName != null) {
if (markerGroupName.equals("")) { if (markerGroupName.equals("")) {

View file

@ -24,12 +24,9 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.text.SimpleDateFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder>
@ -203,13 +200,7 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
descr = mapActivity.getString(R.string.shared_string_favorites); descr = mapActivity.getString(R.string.shared_string_favorites);
} }
} else { } else {
Date date = new Date(marker.creationDate); descr = OsmAndFormatter.getFormattedDate(app, marker.creationDate);
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
if (month.length() > 1) {
month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
}
String day = new SimpleDateFormat("d", Locale.getDefault()).format(date);
descr = month + " " + day;
} }
holder.description.setText(descr); holder.description.setText(descr);
} }