This commit is contained in:
crimean 2018-09-18 16:36:13 +03:00
commit 00d2af079e
71 changed files with 88 additions and 181 deletions

View file

@ -284,6 +284,12 @@ task copyStyleIcons(type: Copy) {
include "**/*.png" include "**/*.png"
} }
task copyWidgetIcons(type: Exec) {
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'sh', file("./copy_widget_icons.sh").getAbsolutePath()
}
}
task collectExternalResources { task collectExternalResources {
dependsOn collectVoiceAssets, dependsOn collectVoiceAssets,
collectFonts, collectFonts,
@ -291,7 +297,8 @@ task collectExternalResources {
collectHelpContentsStyle, collectHelpContentsStyle,
copyStyleIcons, copyStyleIcons,
updateNoTranslate, updateNoTranslate,
validateTranslate validateTranslate,
copyWidgetIcons
} }
// Legacy core build // Legacy core build

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -950,6 +950,7 @@
<string name="rendering_value_pink_name">Pink</string> <string name="rendering_value_pink_name">Pink</string>
<string name="rendering_value_translucent_pink_name">Translucent pink</string> <string name="rendering_value_translucent_pink_name">Translucent pink</string>
<string name="rendering_value_brown_name">Brown</string> <string name="rendering_value_brown_name">Brown</string>
<string name="rendering_value_black_name">Black</string>
<string name="rendering_value_translucent_purple_name">Translucent purple</string> <string name="rendering_value_translucent_purple_name">Translucent purple</string>
<string name="restart_is_required">Restart the app manually to apply all changes.</string> <string name="restart_is_required">Restart the app manually to apply all changes.</string>
<string name="light_theme">Light</string> <string name="light_theme">Light</string>

View file

@ -653,6 +653,7 @@ public class AppInitializer implements IProgress {
notifyEvent(InitEvents.RESTORE_BACKUPS); notifyEvent(InitEvents.RESTORE_BACKUPS);
app.mapMarkersHelper.syncAllGroupsAsync(); app.mapMarkersHelper.syncAllGroupsAsync();
app.searchUICore.initSearchUICore(); app.searchUICore.initSearchUICore();
app.avoidSpecificRoads.initRouteObjects();
checkLiveUpdatesAlerts(); checkLiveUpdatesAlerts();

View file

@ -36,6 +36,7 @@ public class GpxSelectionHelper {
private static final String CURRENT_TRACK = "currentTrack"; private static final String CURRENT_TRACK = "currentTrack";
private static final String FILE = "file"; private static final String FILE = "file";
private static final String COLOR = "color"; private static final String COLOR = "color";
private static final String SELECTED_BY_USER = "selected_by_user";
private OsmandApplication app; private OsmandApplication app;
@NonNull @NonNull
private List<SelectedGpxFile> selectedGPXFiles = new java.util.ArrayList<>(); private List<SelectedGpxFile> selectedGPXFiles = new java.util.ArrayList<>();
@ -410,7 +411,7 @@ public class GpxSelectionHelper {
public void setGpxFileToDisplay(GPXFile... gpxs) { public void setGpxFileToDisplay(GPXFile... gpxs) {
// special case for gpx current route // special case for gpx current route
for (GPXFile gpx : gpxs) { for (GPXFile gpx : gpxs) {
selectGpxFileImpl(gpx, true, false, true); selectGpxFileImpl(gpx, true, false, true, true);
} }
saveCurrentSelections(); saveCurrentSelections();
} }
@ -423,6 +424,7 @@ public class GpxSelectionHelper {
boolean save = false; boolean save = false;
for (int i = 0; i < ar.length(); i++) { for (int i = 0; i < ar.length(); i++) {
JSONObject obj = ar.getJSONObject(i); JSONObject obj = ar.getJSONObject(i);
boolean selectedByUser = obj.optBoolean(SELECTED_BY_USER, true);
if (obj.has(FILE)) { if (obj.has(FILE)) {
File fl = new File(obj.getString(FILE)); File fl = new File(obj.getString(FILE));
if (p != null) { if (p != null) {
@ -436,10 +438,12 @@ public class GpxSelectionHelper {
if (gpx.warning != null) { if (gpx.warning != null) {
save = true; save = true;
} else { } else {
selectGpxFile(gpx, true, false); selectGpxFile(gpx, true, false, true, selectedByUser);
} }
} else if (obj.has(CURRENT_TRACK)) { } else if (obj.has(CURRENT_TRACK)) {
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack()); SelectedGpxFile file = savingTrackHelper.getCurrentTrack();
file.selectedByUser = selectedByUser;
selectedGPXFiles.add(file);
} }
} }
processSplit(); processSplit();
@ -467,6 +471,7 @@ public class GpxSelectionHelper {
obj.put(COLOR, Algorithms.colorToString(s.gpxFile.getColor(0))); obj.put(COLOR, Algorithms.colorToString(s.gpxFile.getColor(0)));
} }
} }
obj.put(SELECTED_BY_USER, s.selectedByUser);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -476,13 +481,16 @@ public class GpxSelectionHelper {
app.getSettings().SELECTED_GPX.set(ar.toString()); app.getSettings().SELECTED_GPX.set(ar.toString());
} }
private SelectedGpxFile selectGpxFileImpl(GPXFile gpx, boolean show, boolean notShowNavigationDialog, boolean syncGroup) { private SelectedGpxFile selectGpxFileImpl(GPXFile gpx, boolean show, boolean notShowNavigationDialog, boolean syncGroup, boolean selectedByUser) {
boolean displayed; boolean displayed;
SelectedGpxFile sf; SelectedGpxFile sf;
if (gpx != null && gpx.showCurrentTrack) { if (gpx != null && gpx.showCurrentTrack) {
sf = savingTrackHelper.getCurrentTrack(); sf = savingTrackHelper.getCurrentTrack();
sf.notShowNavigationDialog = notShowNavigationDialog; sf.notShowNavigationDialog = notShowNavigationDialog;
displayed = selectedGPXFiles.contains(sf); displayed = selectedGPXFiles.contains(sf);
if (!displayed && show) {
sf.selectedByUser = selectedByUser;
}
} else { } else {
assert gpx != null; assert gpx != null;
sf = getSelectedFileByPath(gpx.path); sf = getSelectedFileByPath(gpx.path);
@ -491,6 +499,7 @@ public class GpxSelectionHelper {
sf = new SelectedGpxFile(); sf = new SelectedGpxFile();
sf.setGpxFile(gpx); sf.setGpxFile(gpx);
sf.notShowNavigationDialog = notShowNavigationDialog; sf.notShowNavigationDialog = notShowNavigationDialog;
sf.selectedByUser = selectedByUser;
} }
} }
if (displayed != show) { if (displayed != show) {
@ -507,11 +516,11 @@ public class GpxSelectionHelper {
} }
public SelectedGpxFile selectGpxFile(GPXFile gpx, boolean show, boolean notShowNavigationDialog) { public SelectedGpxFile selectGpxFile(GPXFile gpx, boolean show, boolean notShowNavigationDialog) {
return selectGpxFile(gpx, show, notShowNavigationDialog, true); return selectGpxFile(gpx, show, notShowNavigationDialog, true, true);
} }
public SelectedGpxFile selectGpxFile(GPXFile gpx, boolean show, boolean notShowNavigationDialog, boolean syncGroup) { public SelectedGpxFile selectGpxFile(GPXFile gpx, boolean show, boolean notShowNavigationDialog, boolean syncGroup, boolean selectedByUser) {
SelectedGpxFile sf = selectGpxFileImpl(gpx, show, notShowNavigationDialog, syncGroup); SelectedGpxFile sf = selectGpxFileImpl(gpx, show, notShowNavigationDialog, syncGroup, selectedByUser);
saveCurrentSelections(); saveCurrentSelections();
return sf; return sf;
} }
@ -549,6 +558,7 @@ public class GpxSelectionHelper {
public static class SelectedGpxFile { public static class SelectedGpxFile {
public boolean notShowNavigationDialog = false; public boolean notShowNavigationDialog = false;
public boolean selectedByUser = true;
private boolean showCurrentTrack; private boolean showCurrentTrack;
private GPXFile gpxFile; private GPXFile gpxFile;

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

@ -1481,6 +1481,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
LOG.error("error", e); LOG.error("error", e);
} }
} }
setIntent(null);
} }
} }
} }

View file

@ -21,7 +21,6 @@ import net.osmand.ResultMatcher;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -47,34 +46,13 @@ public class AvoidSpecificRoads {
for (LatLon latLon : app.getSettings().getImpassableRoadPoints()) { for (LatLon latLon : app.getSettings().getImpassableRoadPoints()) {
impassableRoads.put(latLon, null); impassableRoads.put(latLon, null);
} }
if (app.isApplicationInitializing()) {
app.runInUIThread(new Runnable() {
@Override
public void run() {
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
@Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
}
@Override
public void onFinish(AppInitializer init) {
initRouteObjects();
init.removeListener(this);
}
});
}
});
} else {
initRouteObjects();
}
} }
public Map<LatLon, RouteDataObject> getImpassableRoads() { public Map<LatLon, RouteDataObject> getImpassableRoads() {
return impassableRoads; return impassableRoads;
} }
private void initRouteObjects() { public void initRouteObjects() {
for (LatLon latLon : impassableRoads.keySet()) { for (LatLon latLon : impassableRoads.keySet()) {
addImpassableRoad(null, latLon, false, true); addImpassableRoad(null, latLon, false, true);
} }

View file

@ -38,7 +38,8 @@ public class ColorDialogs {
R.string.rendering_value_blue_name, R.string.rendering_value_blue_name,
R.string.rendering_value_purple_name, R.string.rendering_value_purple_name,
R.string.rendering_value_pink_name, R.string.rendering_value_pink_name,
R.string.rendering_value_brown_name R.string.rendering_value_brown_name,
R.string.rendering_value_black_name
}; };
public static int[] pallette = new int[] { public static int[] pallette = new int[] {
@ -52,7 +53,8 @@ public class ColorDialogs {
0xb41010a0, 0xb41010a0,
0xb4a71de1, 0xb4a71de1,
0xb4e044bb, 0xb4e044bb,
0xb48e2512 0xb48e2512,
0xff000001
}; };
public static String[] paletteColorTags = new String[] { public static String[] paletteColorTags = new String[] {
@ -66,7 +68,8 @@ public class ColorDialogs {
"blue", "blue",
"purple", "purple",
"pink", "pink",
"brown" "brown",
"black"
}; };
private static double getDistanceBetweenColors(int color1, int color2) { private static double getDistanceBetweenColors(int color1, int color2) {

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

@ -16,8 +16,6 @@ import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis; import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.mapmarkers.adapters.GroupsAdapter; import net.osmand.plus.mapmarkers.adapters.GroupsAdapter;
@ -68,15 +66,21 @@ public class AddTracksGroupBottomSheetDialogFragment extends AddGroupBottomSheet
fragment.setArguments(args); fragment.setArguments(args);
fragment.setUsedOnMap(false); fragment.setUsedOnMap(false);
fragment.show(getParentFragment().getChildFragmentManager(), SelectWptCategoriesBottomSheetDialogFragment.TAG); fragment.show(getParentFragment().getChildFragmentManager(), SelectWptCategoriesBottomSheetDialogFragment.TAG);
dismiss(); } else {
} else if(dataItem.getFile() != null) { OsmandApplication app = getMyApplication();
getMyApplication().getMapMarkersHelper().addOrEnableGpxGroup(dataItem.getFile()); if (app != null) {
dismiss(); GpxSelectionHelper selectionHelper = app.getSelectedGpxHelper();
File gpx = dataItem.getFile();
if (selectionHelper.getSelectedFileByPath(gpx.getAbsolutePath()) == null) {
GPXFile res = GPXUtilities.loadGPXFile(app, gpx);
selectionHelper.selectGpxFile(res, true, false, false, false);
}
app.getMapMarkersHelper().addOrEnableGpxGroup(gpx);
}
} }
dismiss();
} }
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
public class ProcessGpxTask extends AsyncTask<Void, GpxDataItem, Void> { public class ProcessGpxTask extends AsyncTask<Void, GpxDataItem, Void> {

View file

@ -136,7 +136,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
SelectedGpxFile selectedGpxFile = gpxSelectionHelper.getSelectedFileByPath(gpxFile.path); SelectedGpxFile selectedGpxFile = gpxSelectionHelper.getSelectedFileByPath(gpxFile.path);
if (selectedGpxFile == null) { if (selectedGpxFile == null) {
gpxSelectionHelper.selectGpxFile(gpxFile, true, false); gpxSelectionHelper.selectGpxFile(gpxFile, true, false, false, false);
} }
MapMarkersGroup group = mapMarkersHelper.getMarkersGroup(gpxFile); MapMarkersGroup group = mapMarkersHelper.getMarkersGroup(gpxFile);
if (group == null) { if (group == null) {

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

@ -2,6 +2,7 @@ package net.osmand.plus.mapmarkers.adapters;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@ -17,6 +18,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 +29,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 +39,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 +318,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);
@ -471,13 +465,13 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
if (disabled) { if (disabled) {
if (selectedGpxFile != null) { if (selectedGpxFile != null) {
gpxFile[0] = selectedGpxFile.getGpxFile(); gpxFile[0] = selectedGpxFile.getGpxFile();
switchGpxVisibility(gpxFile[0], false); switchGpxVisibility(gpxFile[0], selectedGpxFile, false);
} }
} else { } else {
if (selectedGpxFile == null) { if (selectedGpxFile == null) {
// TODO IO load in another thread ? // TODO IO load in another thread ?
gpxFile[0] = GPXUtilities.loadGPXFile(app, new File(gpxPath)); gpxFile[0] = GPXUtilities.loadGPXFile(app, new File(gpxPath));
switchGpxVisibility(gpxFile[0], true); switchGpxVisibility(gpxFile[0], null, true);
} }
} }
} }
@ -494,7 +488,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (group.getType() == MapMarkersGroup.GPX_TYPE && gpxFile[0] != null) { if (group.getType() == MapMarkersGroup.GPX_TYPE && gpxFile[0] != null) {
switchGpxVisibility(gpxFile[0], true); switchGpxVisibility(gpxFile[0], null, true);
} }
mapMarkersHelper.enableGroup(group); mapMarkersHelper.enableGroup(group);
} }
@ -564,9 +558,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
} }
} }
private void switchGpxVisibility(@NonNull GPXFile gpxFile, boolean visible) { private void switchGpxVisibility(@NonNull GPXFile gpxFile, @Nullable SelectedGpxFile selectedGpxFile, boolean visible) {
GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper(); GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper();
gpxHelper.selectGpxFile(gpxFile, visible, false, false); if (!visible && selectedGpxFile != null && selectedGpxFile.selectedByUser) {
return;
}
gpxHelper.selectGpxFile(gpxFile, visible, false, false, false);
} }
public void hideSnackbar() { public void hideSnackbar() {

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);
} }

View file

@ -45,10 +45,6 @@ import net.osmand.util.MapUtils;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -65,8 +61,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -79,14 +73,15 @@ public class RouteProvider {
private static final int MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT = 60; private static final int MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT = 60;
public enum RouteService { public enum RouteService {
OSMAND("OsmAnd (offline)"), YOURS("YOURS"), OSMAND("OsmAnd (offline)"),
// ORS("OpenRouteService"), // disable ors due to no public rest service (testing2015 doesn't seem stable) //ORS("OpenRouteService"), // disable ors due to no public rest service (testing2015 doesn't seem stable)
OSRM("OSRM (only car)"), OSRM("OSRM (only car)"),
BROUTER("BRouter (offline)"), STRAIGHT("Straight line"); BROUTER("BRouter (offline)"),
STRAIGHT("Straight line");
private final String name; private final String name;
private RouteService(String name) { RouteService(String name) {
this.name = name; this.name = name;
} }
@ -106,8 +101,8 @@ public class RouteProvider {
} }
public static RouteService[] getAvailableRouters(OsmandApplication ctx) { public static RouteService[] getAvailableRouters(OsmandApplication ctx) {
List<RouteService> list = new ArrayList<RouteProvider.RouteService>(); List<RouteService> list = new ArrayList<>();
for(RouteService r : values()) { for (RouteService r : values()) {
if (r.isAvailable(ctx)) { if (r.isAvailable(ctx)) {
list.add(r); list.add(r);
} }
@ -311,8 +306,6 @@ public class RouteProvider {
res = findVectorMapsRoute(params, calcGPXRoute); res = findVectorMapsRoute(params, calcGPXRoute);
} else if (params.type == RouteService.BROUTER) { } else if (params.type == RouteService.BROUTER) {
res = findBROUTERRoute(params); res = findBROUTERRoute(params);
} else if (params.type == RouteService.YOURS) {
res = findYOURSRoute(params);
// } else if (params.type == RouteService.ORS) { // } else if (params.type == RouteService.ORS) {
// res = findORSRoute(params); // res = findORSRoute(params);
} else if (params.type == RouteService.OSRM) { } else if (params.type == RouteService.OSRM) {
@ -596,66 +589,6 @@ public class RouteProvider {
return ctx.getString(resId); return ctx.getString(resId);
} }
protected RouteCalculationResult findYOURSRoute(RouteCalculationParams params) throws MalformedURLException, IOException,
ParserConfigurationException, FactoryConfigurationError, SAXException {
List<Location> res = new ArrayList<Location>();
StringBuilder uri = new StringBuilder();
uri.append("http://www.yournavigation.org/api/1.0/gosmore.php?format=kml"); //$NON-NLS-1$
uri.append("&flat=").append(params.start.getLatitude()); //$NON-NLS-1$
uri.append("&flon=").append(params.start.getLongitude()); //$NON-NLS-1$
uri.append("&tlat=").append(params.end.getLatitude()); //$NON-NLS-1$
uri.append("&tlon=").append(params.end.getLongitude()); //$NON-NLS-1$
if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
uri.append("&v=bicycle") ; //$NON-NLS-1$
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
uri.append("&v=foot") ; //$NON-NLS-1$
} else if(params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)){
uri.append("&v=motorcar"); //$NON-NLS-1$
} else {
return applicationModeNotSupported(params);
}
uri.append("&fast=").append(params.fast ? "1" : "0").append("&layer=mapnik"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
log.info("URL route " + uri);
URLConnection connection = NetworkUtils.getHttpURLConnection(uri.toString());
connection.setRequestProperty("User-Agent", Version.getFullVersion(params.ctx));
DocumentBuilder dom = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = dom.parse(new InputSource(new InputStreamReader(connection.getInputStream())));
NodeList list = doc.getElementsByTagName("coordinates"); //$NON-NLS-1$
for(int i=0; i<list.getLength(); i++){
Node item = list.item(i);
String str = item.getFirstChild().getNodeValue();
if(str == null){
continue;
}
int st = 0;
int next = 0;
while((next = str.indexOf('\n', st)) != -1){
String coordinate = str.substring(st, next + 1);
int s = coordinate.indexOf(',');
if (s != -1) {
try {
double lon = Double.parseDouble(coordinate.substring(0, s));
double lat = Double.parseDouble(coordinate.substring(s + 1));
Location l = new Location("router"); //$NON-NLS-1$
l.setLatitude(lat);
l.setLongitude(lon);
res.add(l);
} catch (NumberFormatException e) {
}
}
st = next + 1;
}
}
if(list.getLength() == 0){
if(doc.getChildNodes().getLength() == 1){
Node item = doc.getChildNodes().item(0);
return new RouteCalculationResult(item.getNodeValue());
}
}
params.intermediates = null;
return new RouteCalculationResult(res, null, params, null, true);
}
protected RouteCalculationResult findVectorMapsRoute(final RouteCalculationParams params, boolean calcGPXRoute) throws IOException { protected RouteCalculationResult findVectorMapsRoute(final RouteCalculationParams params, boolean calcGPXRoute) throws IOException {
BinaryMapIndexReader[] files = params.ctx.getResourceManager().getRoutingMapFiles(); BinaryMapIndexReader[] files = params.ctx.getResourceManager().getRoutingMapFiles();
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(); RoutePlannerFrontEnd router = new RoutePlannerFrontEnd();

View file

@ -233,11 +233,12 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
final DownloadIndexesThread downloadThread = app.getDownloadThread(); final DownloadIndexesThread downloadThread = app.getDownloadThread();
boolean outdated = mainIndexItem != null && mainIndexItem.isOutdated(); boolean outdated = mainIndexItem != null && mainIndexItem.isOutdated();
boolean needsDownloading = mainIndexItem != null && !mainIndexItem.isDownloaded();
File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook(); File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook();
if (selectedTravelBook == null || (outdated && app.getSettings().SHOW_TRAVEL_UPDATE_CARD.get())) { if (selectedTravelBook == null || needsDownloading || (outdated && app.getSettings().SHOW_TRAVEL_UPDATE_CARD.get())) {
boolean showOtherMaps = false; boolean showOtherMaps = false;
if (selectedTravelBook == null) { if (needsDownloading) {
List<IndexItem> items = downloadThread.getIndexes().getWikivoyageItems(); List<IndexItem> items = downloadThread.getIndexes().getWikivoyageItems();
showOtherMaps = items != null && items.size() > 1; showOtherMaps = items != null && items.size() > 1;
} }
@ -341,9 +342,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
@NonNull @NonNull
private String getWikivoyageFileName() { private String getWikivoyageFileName() {
OsmandApplication app = getMyApplication(); // OsmandApplication app = getMyApplication();
File selectedTravelBook = app != null ? app.getTravelDbHelper().getSelectedTravelBook() : null; // File selectedTravelBook = app != null ? app.getTravelDbHelper().getSelectedTravelBook() : null;
return selectedTravelBook == null ? WORLD_WIKIVOYAGE_FILE_NAME : selectedTravelBook.getName(); // return selectedTravelBook == null ? WORLD_WIKIVOYAGE_FILE_NAME : selectedTravelBook.getName();
return WORLD_WIKIVOYAGE_FILE_NAME;
} }
private void removeDownloadUpdateCard() { private void removeDownloadUpdateCard() {