Merge pull request #4439 from osmandapp/sasha_pasha_branch
Sasha pasha branch
This commit is contained in:
commit
d2b80e5ac1
19 changed files with 655 additions and 99 deletions
|
@ -181,6 +181,36 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/remove_from_markers_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/list_item_height"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/remove_from_markers_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingTop="6dp"
|
||||
android:text="@string/remove_from_map_markers"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/share_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:osmand="http://schemas.android.com/tools"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -23,18 +24,36 @@
|
|||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/map_markers"
|
||||
android:textColor="@color/color_white"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/dialog_header_text_size"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/order_by_mode_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
tools:text="Date added"
|
||||
android:textColor="@color/white_80_transparent"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/options_button"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/marker_order_by_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/order_by_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||
tools:text="@string/order_by"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/distance_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/distance_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_markers_dark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/distance"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/name_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/name_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_sort_by_name"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_name"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/date_added_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/date_added_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_sort_by_date"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date_added_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/date_added"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/close_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_close"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -9,6 +9,11 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="remove_from_map_markers">Remove from Map Markers</string>
|
||||
<string name="descendingly">Descendingly</string>
|
||||
<string name="ascendingly">Ascendingly</string>
|
||||
<string name="date_added">Date added</string>
|
||||
<string name="order_by">Order by:</string>
|
||||
<string name="marker_show_distance_descr">Select how to indicate distance and direction to Map markers on the map screen:</string>
|
||||
<string name="map_orientation_change_in_accordance_with_speed">Map orientation threshold</string>
|
||||
<string name="map_orientation_change_in_accordance_with_speed_descr">Select below which speed the map orientation switches from \'To direction of movement\' to \'To compass\'</string>
|
||||
|
|
|
@ -72,6 +72,16 @@ public class AndroidUtils {
|
|||
|
||||
}
|
||||
|
||||
public static String trimExtension(String src) {
|
||||
if (src != null) {
|
||||
int index = src.lastIndexOf('.');
|
||||
if (index != -1) {
|
||||
return src.substring(0, index);
|
||||
}
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
public static String formatDate(Context ctx, long time) {
|
||||
return DateFormat.getDateFormat(ctx).format(new Date(time));
|
||||
}
|
||||
|
|
|
@ -501,7 +501,6 @@ public class AppInitializer implements IProgress {
|
|||
startBgTime = System.currentTimeMillis();
|
||||
app.favorites.loadFavorites();
|
||||
notifyEvent(InitEvents.FAVORITES_INITIALIZED);
|
||||
app.mapMarkersHelper.syncAllGroups();
|
||||
// init poi types before indexes and before POI
|
||||
initPoiTypes();
|
||||
notifyEvent(InitEvents.POI_TYPES_INITIALIZED);
|
||||
|
@ -522,6 +521,7 @@ public class AppInitializer implements IProgress {
|
|||
notifyEvent(InitEvents.LOAD_GPX_TRACKS);
|
||||
saveGPXTracks();
|
||||
notifyEvent(InitEvents.SAVE_GPX_TRACKS);
|
||||
app.mapMarkersHelper.syncAllGroups();
|
||||
// restore backuped favorites to normal file
|
||||
restoreBackupForFavoritesFiles();
|
||||
notifyEvent(InitEvents.RESTORE_BACKUPS);
|
||||
|
|
|
@ -775,18 +775,17 @@ public class GPXUtilities {
|
|||
|
||||
void clearPoints() {
|
||||
points.clear();
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void addPoint(WptPt point) {
|
||||
points.add(point);
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
void addPoints(Collection<? extends WptPt> collection) {
|
||||
points.addAll(collection);
|
||||
}
|
||||
|
||||
public boolean removePoint(WptPt point) {
|
||||
return points.remove(point);
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isCloudmadeRouteFile() {
|
||||
|
|
|
@ -5,14 +5,16 @@ import android.graphics.Matrix;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.Route;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
|
@ -491,18 +493,31 @@ public class GpxSelectionHelper {
|
|||
|
||||
public void clearPoints(GPXFile gpxFile) {
|
||||
gpxFile.clearPoints();
|
||||
syncGpx(gpxFile);
|
||||
}
|
||||
|
||||
public void addPoint(WptPt point, GPXFile gpxFile) {
|
||||
gpxFile.addPoint(point);
|
||||
syncGpx(gpxFile);
|
||||
}
|
||||
|
||||
public void addPoints(Collection<? extends WptPt> collection, GPXFile gpxFile) {
|
||||
gpxFile.addPoints(collection);
|
||||
syncGpx(gpxFile);
|
||||
}
|
||||
|
||||
public boolean removePoint(WptPt point, GPXFile gpxFile) {
|
||||
return gpxFile.removePoint(point);
|
||||
boolean res = gpxFile.deleteWptPt(point);
|
||||
syncGpx(gpxFile);
|
||||
return res;
|
||||
}
|
||||
|
||||
private void syncGpx(GPXFile gpxFile) {
|
||||
File gpx = new File(gpxFile.path);
|
||||
if (gpx.exists()) {
|
||||
app.getMapMarkersHelper().syncGroup(new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,12 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -222,7 +226,7 @@ public class MapMarkersHelper {
|
|||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
|
||||
List<MapMarker> markersHistory = markersDbHelper.getMarkersHistory();
|
||||
sortMarkers(markersHistory, true);
|
||||
sortHistoryMarkers();
|
||||
mapMarkersHistory.addAll(markersHistory);
|
||||
|
||||
if (!ctx.isApplicationInitializing()) {
|
||||
|
@ -250,23 +254,49 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private void sortMarkers(List<MapMarker> markers, final boolean history) {
|
||||
Collections.sort(markers, new Comparator<MapMarker>() {
|
||||
private void sortHistoryMarkers() {
|
||||
sortMarkers(true, null);
|
||||
}
|
||||
|
||||
private void sortMarkers(final boolean history, final OsmandSettings.MapMarkersOrderByMode orderByMode) {
|
||||
final LatLon location = ctx.getSettings().getLastKnownMapLocation();
|
||||
Collections.sort(history ? mapMarkersHistory : mapMarkers, new Comparator<MapMarker>() {
|
||||
@Override
|
||||
public int compare(MapMarker mapMarker1, MapMarker mapMarker2) {
|
||||
long firstMarkerDate = history ? mapMarker1.visitedDate : mapMarker1.creationDate;
|
||||
long secondMarkerDate = history ? mapMarker2.visitedDate : mapMarker2.creationDate;
|
||||
if (firstMarkerDate > secondMarkerDate) {
|
||||
return -1;
|
||||
} else if (firstMarkerDate == secondMarkerDate) {
|
||||
if (history || orderByMode.isDateAddedDescending() || orderByMode.isDateAddedAscending()) {
|
||||
long t1 = history ? mapMarker1.visitedDate : mapMarker1.creationDate;
|
||||
long t2 = history ? mapMarker2.visitedDate : mapMarker2.creationDate;
|
||||
if (t1 > t2) {
|
||||
return history || orderByMode.isDateAddedDescending() ? -1 : 1;
|
||||
} else if (t1 == t2) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
return history || orderByMode.isDateAddedDescending() ? 1 : -1;
|
||||
}
|
||||
} else if (orderByMode.isDistanceDescending() || orderByMode.isDistanceAscending()) {
|
||||
int d1 = (int) MapUtils.getDistance(location, mapMarker1.getLatitude(), mapMarker1.getLongitude());
|
||||
int d2 = (int) MapUtils.getDistance(location, mapMarker2.getLatitude(), mapMarker2.getLongitude());
|
||||
if (d1 > d2) {
|
||||
return orderByMode.isDistanceDescending() ? -1 : 1;
|
||||
} else if (d1 == d2) {
|
||||
return 0;
|
||||
} else {
|
||||
return orderByMode.isDistanceDescending() ? 1 : -1;
|
||||
}
|
||||
} else {
|
||||
String n1 = mapMarker1.getName(ctx);
|
||||
String n2 = mapMarker2.getName(ctx);
|
||||
return n1.compareToIgnoreCase(n2);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void orderMarkers(OsmandSettings.MapMarkersOrderByMode orderByMode) {
|
||||
sortMarkers(false, orderByMode);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
}
|
||||
|
||||
private void lookupAddress(final MapMarker mapMarker) {
|
||||
if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
|
||||
cancelPointAddressRequests(mapMarker.point);
|
||||
|
@ -287,6 +317,10 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isGroupSynced(String id) {
|
||||
return markersDbHelper.getGroup(id) != null;
|
||||
}
|
||||
|
||||
public void syncAllGroups() {
|
||||
List<MarkersSyncGroup> groups = markersDbHelper.getAllGroups();
|
||||
for (MarkersSyncGroup gr : groups) {
|
||||
|
@ -295,62 +329,91 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
public void syncGroup(MarkersSyncGroup group) {
|
||||
if (markersDbHelper.getGroup(group.getId()) == null) {
|
||||
if (!isGroupSynced(group.getId())) {
|
||||
return;
|
||||
}
|
||||
List<MapMarker> dbMarkers = markersDbHelper.getMarkersFromGroup(group);
|
||||
|
||||
if (group.getType() == MarkersSyncGroup.FAVORITES_TYPE) {
|
||||
FavouritesDbHelper.FavoriteGroup favGroup = ctx.getFavorites().getGroup(group.name);
|
||||
FavouritesDbHelper.FavoriteGroup favGroup = ctx.getFavorites().getGroup(group.getName());
|
||||
if (favGroup == null) {
|
||||
return;
|
||||
}
|
||||
if (!favGroup.visible) {
|
||||
removeActiveMarkersFromSyncGroup(group.id);
|
||||
removeActiveMarkersFromSyncGroup(group.getId());
|
||||
return;
|
||||
}
|
||||
List<FavouritePoint> favPoints = favGroup.points;
|
||||
for (FavouritePoint fp : favPoints) {
|
||||
LatLon fpLatLon = new LatLon(fp.getLatitude(), fp.getLongitude());
|
||||
|
||||
for (FavouritePoint fp : favGroup.points) {
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName());
|
||||
}
|
||||
|
||||
removeOldMarkersIfNeeded(dbMarkers);
|
||||
} else if (group.getType() == MarkersSyncGroup.GPX_TYPE) {
|
||||
GpxSelectionHelper gpxHelper = ctx.getSelectedGpxHelper();
|
||||
File file = new File(group.getId());
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(group.getId());
|
||||
GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile();
|
||||
if (gpx == null) {
|
||||
removeActiveMarkersFromSyncGroup(group.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
List<WptPt> gpxPoints = new LinkedList<>(gpx.getPoints());
|
||||
for (WptPt pt : gpxPoints) {
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(pt.lat, pt.lon), pt.name);
|
||||
}
|
||||
|
||||
removeOldMarkersIfNeeded(dbMarkers);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNewMarkerIfNeeded(MarkersSyncGroup group, List<MapMarker> markers, LatLon latLon, String name) {
|
||||
boolean exists = false;
|
||||
|
||||
for (MapMarker marker : dbMarkers) {
|
||||
if (marker.id.equals(group.getId() + fp.getName(ctx))) {
|
||||
for (MapMarker marker : markers) {
|
||||
if (marker.id.equals(group.getId() + name)) {
|
||||
exists = true;
|
||||
if (!marker.history && !marker.point.equals(fpLatLon)) {
|
||||
if (!marker.history && !marker.point.equals(latLon)) {
|
||||
for (MapMarker m : mapMarkers) {
|
||||
if (m.id.equals(marker.id)) {
|
||||
m.point = fpLatLon;
|
||||
m.point = latLon;
|
||||
updateMapMarker(m, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
dbMarkers.remove(marker);
|
||||
markers.remove(marker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
addMarkers(Collections.singletonList(fpLatLon),
|
||||
Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, fp.getName())), group);
|
||||
addMarkers(Collections.singletonList(latLon),
|
||||
Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, name)), group);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dbMarkers.isEmpty()) {
|
||||
for (MapMarker marker : dbMarkers) {
|
||||
private void removeOldMarkersIfNeeded(List<MapMarker> markers) {
|
||||
if (!markers.isEmpty()) {
|
||||
boolean needRefresh = false;
|
||||
for (MapMarker marker : markers) {
|
||||
if (!marker.history) {
|
||||
markersDbHelper.removeMarker(marker, false);
|
||||
mapMarkers.remove(marker);
|
||||
needRefresh = true;
|
||||
}
|
||||
}
|
||||
if (needRefresh) {
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void moveMapMarkerToHistory(MapMarker marker) {
|
||||
if (marker != null) {
|
||||
|
@ -361,7 +424,7 @@ public class MapMarkersHelper {
|
|||
marker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
|
||||
mapMarkersHistory.add(marker);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
sortMarkers(mapMarkersHistory, true);
|
||||
sortHistoryMarkers();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +434,7 @@ public class MapMarkersHelper {
|
|||
markersDbHelper.addMarker(marker);
|
||||
if (marker.history) {
|
||||
mapMarkersHistory.add(marker);
|
||||
sortMarkers(mapMarkersHistory, true);
|
||||
sortHistoryMarkers();
|
||||
} else {
|
||||
mapMarkers.add(marker);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
|
@ -387,7 +450,7 @@ public class MapMarkersHelper {
|
|||
marker.history = false;
|
||||
mapMarkers.add(position, marker);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
sortMarkers(mapMarkersHistory, true);
|
||||
sortHistoryMarkers();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +464,7 @@ public class MapMarkersHelper {
|
|||
mapMarkers.add(marker);
|
||||
}
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
sortMarkers(mapMarkersHistory, true);
|
||||
sortHistoryMarkers();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +546,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
mapMarkersHistory.addAll(mapMarkers);
|
||||
mapMarkers.clear();
|
||||
sortMarkers(mapMarkersHistory, true);
|
||||
sortHistoryMarkers();
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -515,7 +578,8 @@ public class MapMarkersHelper {
|
|||
if (syncGroupId != null) {
|
||||
markersDbHelper.removeActiveMarkersFromSyncGroup(syncGroupId);
|
||||
for (Iterator<MapMarker> iterator = mapMarkers.iterator(); iterator.hasNext(); ) {
|
||||
if (iterator.next().groupKey.equals(syncGroupId)) {
|
||||
String groupKey = iterator.next().groupKey;
|
||||
if (groupKey != null && groupKey.equals(syncGroupId)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
@ -700,9 +764,9 @@ public class MapMarkersHelper {
|
|||
while (fout.exists()) {
|
||||
fout = new File(dir, fileName + "_" + (++ind) + ".gpx");
|
||||
}
|
||||
GPXUtilities.GPXFile file = new GPXUtilities.GPXFile();
|
||||
GPXFile file = new GPXFile();
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
GPXUtilities.WptPt wpt = new GPXUtilities.WptPt();
|
||||
WptPt wpt = new WptPt();
|
||||
wpt.lat = marker.getLatitude();
|
||||
wpt.lon = marker.getLongitude();
|
||||
wpt.setColor(ctx.getResources().getColor(MapMarker.getColorId(marker.colorIndex)));
|
||||
|
|
|
@ -1320,6 +1320,9 @@ public class OsmandSettings {
|
|||
public final CommonPreference<MapMarkersMode> MAP_MARKERS_MODE =
|
||||
new EnumIntPreference<>("map_markers_mode", MapMarkersMode.TOOLBAR, MapMarkersMode.values());
|
||||
|
||||
public final CommonPreference<MapMarkersOrderByMode> MAP_MARKERS_ORDER_BY_MODE =
|
||||
new EnumIntPreference<>("map_markers_order_by_mode", MapMarkersOrderByMode.DATE_ADDED_DESC, MapMarkersOrderByMode.values());
|
||||
|
||||
{
|
||||
MAP_MARKERS_MODE.makeProfile().cache();
|
||||
MAP_MARKERS_MODE.setModeDefaultValue(ApplicationMode.DEFAULT, MapMarkersMode.TOOLBAR);
|
||||
|
@ -3151,6 +3154,34 @@ public class OsmandSettings {
|
|||
}
|
||||
}
|
||||
|
||||
public enum MapMarkersOrderByMode {
|
||||
DISTANCE_DESC,
|
||||
DISTANCE_ASC,
|
||||
NAME,
|
||||
DATE_ADDED_DESC,
|
||||
DATE_ADDED_ASC;
|
||||
|
||||
public boolean isDistanceDescending() {
|
||||
return this == DISTANCE_DESC;
|
||||
}
|
||||
|
||||
public boolean isDistanceAscending() {
|
||||
return this == DISTANCE_ASC;
|
||||
}
|
||||
|
||||
public boolean isName() {
|
||||
return this == NAME;
|
||||
}
|
||||
|
||||
public boolean isDateAddedDescending() {
|
||||
return this == DATE_ADDED_DESC;
|
||||
}
|
||||
|
||||
public boolean isDateAddedAscending() {
|
||||
return this == DATE_ADDED_ASC;
|
||||
}
|
||||
}
|
||||
|
||||
public enum MapMarkersMode {
|
||||
TOOLBAR(R.string.shared_string_topbar),
|
||||
WIDGETS(R.string.shared_string_widgets),
|
||||
|
|
|
@ -175,21 +175,23 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment {
|
|||
}
|
||||
});
|
||||
|
||||
final MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
||||
final MarkersSyncGroup syncGroup = new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE);
|
||||
boolean groupSyncedWithMarkers = markersHelper.isGroupSynced(syncGroup.getId());
|
||||
|
||||
View addToMarkersView = view.findViewById(R.id.add_to_markers_view);
|
||||
if (app.getSettings().USE_MAP_MARKERS.get() && group.points.size() > 0) {
|
||||
if (app.getSettings().USE_MAP_MARKERS.get() && group.points.size() > 0 && !groupSyncedWithMarkers) {
|
||||
((ImageView) view.findViewById(R.id.add_to_markers_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_flag_dark));
|
||||
addToMarkersView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
||||
List<LatLon> points = new ArrayList<>(group.points.size());
|
||||
List<PointDescription> names = new ArrayList<>(group.points.size());
|
||||
for (FavouritePoint fp : group.points) {
|
||||
points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
|
||||
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
|
||||
}
|
||||
MarkersSyncGroup syncGroup = new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE);
|
||||
markersHelper.addMarkersSyncGroup(syncGroup);
|
||||
markersHelper.addMapMarkers(points, names, syncGroup);
|
||||
dismiss();
|
||||
|
@ -200,6 +202,21 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment {
|
|||
addToMarkersView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
View removeFromMarkersView = view.findViewById(R.id.remove_from_markers_view);
|
||||
if (app.getSettings().USE_MAP_MARKERS.get() && groupSyncedWithMarkers) {
|
||||
removeFromMarkersView.setVisibility(View.VISIBLE);
|
||||
((ImageView) view.findViewById(R.id.remove_from_markers_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_delete_dark));
|
||||
removeFromMarkersView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
markersHelper.removeMarkersSyncGroup(syncGroup.getId(), true);
|
||||
dismiss();
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
View shareView = view.findViewById(R.id.share_view);
|
||||
if (group.points.size() > 0) {
|
||||
((ImageView) view.findViewById(R.id.share_icon))
|
||||
|
|
|
@ -10,19 +10,21 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -175,6 +177,14 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
saved = true;
|
||||
}
|
||||
|
||||
private void syncGpx(GPXFile gpxFile) {
|
||||
File gpx = new File(gpxFile.path);
|
||||
if (gpx.exists()) {
|
||||
getMyApplication().getMapMarkersHelper().syncGroup(new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
private void doAddWpt(String name, String category, String description) {
|
||||
wpt.name = name;
|
||||
wpt.category = category;
|
||||
|
@ -195,12 +205,14 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
addWpt(gpx, description, name, category, color);
|
||||
new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).execute();
|
||||
}
|
||||
syncGpx(gpx);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addWpt(GPXFile gpx, String description, String name, String category, int color) {
|
||||
wpt = gpx.addWptPt(wpt.getLatitude(), wpt.getLongitude(),
|
||||
System.currentTimeMillis(), description, name, category, color);
|
||||
syncGpx(gpx);
|
||||
}
|
||||
|
||||
private void doUpdateWpt(String name, String category, String description) {
|
||||
|
@ -217,6 +229,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
System.currentTimeMillis(), description, name, category, color);
|
||||
new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).execute();
|
||||
}
|
||||
syncGpx(gpx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,6 +250,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
gpx.deleteWptPt(wpt);
|
||||
new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).execute();
|
||||
}
|
||||
syncGpx(gpx);
|
||||
}
|
||||
saved = true;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
|
|||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
|
|
|
@ -9,30 +9,28 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.plus.LockableViewPager;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.MarkerOptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragment {
|
||||
|
||||
|
@ -44,6 +42,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
|
||||
private Snackbar snackbar;
|
||||
private LockableViewPager viewPager;
|
||||
private TextView orderByModeTitle;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -80,18 +79,25 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
}
|
||||
|
||||
FragmentManager fragmentManager = getChildFragmentManager();
|
||||
Fragment markerOptionsFragment = fragmentManager.findFragmentByTag(MarkerOptionsBottomSheetDialogFragment.TAG);
|
||||
if (markerOptionsFragment != null) {
|
||||
((MarkerOptionsBottomSheetDialogFragment) markerOptionsFragment).setListener(createMarkerOptionsFragmentListener());
|
||||
Fragment optionsFragment = fragmentManager.findFragmentByTag(OptionsBottomSheetDialogFragment.TAG);
|
||||
if (optionsFragment != null) {
|
||||
((OptionsBottomSheetDialogFragment) optionsFragment).setListener(createOptionsFragmentListener());
|
||||
}
|
||||
Fragment showDirectionFragment = fragmentManager.findFragmentByTag(ShowDirectionBottomSheetDialogFragment.TAG);
|
||||
if (showDirectionFragment != null) {
|
||||
((ShowDirectionBottomSheetDialogFragment) showDirectionFragment).setListener(createShowDirectionFragmentListener());
|
||||
}
|
||||
final Fragment orderByFragment = fragmentManager.findFragmentByTag(OrderByBottomSheetDialogFragment.TAG);
|
||||
if (orderByFragment != null) {
|
||||
((OrderByBottomSheetDialogFragment) orderByFragment).setListener(createOrderByFragmentListener());
|
||||
}
|
||||
|
||||
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
|
||||
|
||||
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
|
||||
orderByModeTitle = toolbar.findViewById(R.id.order_by_mode_text);
|
||||
setOrderByMode(getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.get());
|
||||
|
||||
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -103,9 +109,9 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
optionsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
MarkerOptionsBottomSheetDialogFragment fragment = new MarkerOptionsBottomSheetDialogFragment();
|
||||
fragment.setListener(createMarkerOptionsFragmentListener());
|
||||
fragment.show(getChildFragmentManager(), MarkerOptionsBottomSheetDialogFragment.TAG);
|
||||
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
||||
fragment.setListener(createOptionsFragmentListener());
|
||||
fragment.show(getChildFragmentManager(), OptionsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -125,6 +131,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
activeFragment.updateAdapter();
|
||||
historyFragment.hideSnackbar();
|
||||
}
|
||||
orderByModeTitle.setVisibility(View.VISIBLE);
|
||||
viewPager.setCurrentItem(0);
|
||||
optionsButton.setVisibility(View.VISIBLE);
|
||||
return true;
|
||||
|
@ -135,6 +142,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
activeFragment.hideSnackbar();
|
||||
historyFragment.hideSnackbar();
|
||||
}
|
||||
orderByModeTitle.setVisibility(View.GONE);
|
||||
viewPager.setCurrentItem(1);
|
||||
optionsButton.setVisibility(View.GONE);
|
||||
return true;
|
||||
|
@ -144,6 +152,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
historyFragment.updateAdapter();
|
||||
activeFragment.hideSnackbar();
|
||||
}
|
||||
orderByModeTitle.setVisibility(View.GONE);
|
||||
viewPager.setCurrentItem(2);
|
||||
optionsButton.setVisibility(View.GONE);
|
||||
return true;
|
||||
|
@ -159,14 +168,16 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
private MarkerOptionsFragmentListener createMarkerOptionsFragmentListener() {
|
||||
private MarkerOptionsFragmentListener createOptionsFragmentListener() {
|
||||
return new MarkerOptionsFragmentListener() {
|
||||
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
|
||||
@Override
|
||||
public void sortByOnClick() {
|
||||
Toast.makeText(getContext(), "Sort by", Toast.LENGTH_SHORT).show();
|
||||
OrderByBottomSheetDialogFragment fragment = new OrderByBottomSheetDialogFragment();
|
||||
fragment.setListener(createOrderByFragmentListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), OrderByBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -223,6 +234,33 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
};
|
||||
}
|
||||
|
||||
private OrderByFragmentListener createOrderByFragmentListener() {
|
||||
return new OrderByFragmentListener() {
|
||||
@Override
|
||||
public void onMapMarkersOrderByModeChanged(MapMarkersOrderByMode orderByMode) {
|
||||
setOrderByMode(orderByMode);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void setOrderByMode(MapMarkersOrderByMode orderByMode) {
|
||||
String modeStr = "";
|
||||
if (orderByMode.isDistanceDescending()) {
|
||||
modeStr = getString(R.string.distance) + " (" + getString(R.string.descendingly) + ")";
|
||||
} else if (orderByMode.isDistanceAscending()) {
|
||||
modeStr = getString(R.string.distance) + " (" + getString(R.string.ascendingly) + ")";
|
||||
} else if (orderByMode.isName()) {
|
||||
modeStr = getString(R.string.shared_string_name);
|
||||
} else if (orderByMode.isDateAddedDescending()) {
|
||||
modeStr = getString(R.string.date_added) + " (" + getString(R.string.descendingly) + ")";
|
||||
} else {
|
||||
modeStr = getString(R.string.date_added) + " (" + getString(R.string.ascendingly) + ")";
|
||||
}
|
||||
orderByModeTitle.setText(modeStr);
|
||||
getMyApplication().getMapMarkersHelper().orderMarkers(orderByMode);
|
||||
activeFragment.updateAdapter();
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
return (MapActivity) getActivity();
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "MarkerOptionsBottomSheetDialogFragment";
|
||||
public final static String TAG = "OptionsBottomSheetDialogFragment";
|
||||
|
||||
private MarkerOptionsFragmentListener listener;
|
||||
private boolean portrait;
|
|
@ -0,0 +1,162 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "OrderByBottomSheetDialogFragment";
|
||||
|
||||
private boolean portrait;
|
||||
private OsmandSettings settings;
|
||||
private OrderByFragmentListener listener;
|
||||
|
||||
public void setListener(OrderByFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
settings = getMyApplication().getSettings();
|
||||
boolean night = !settings.isLightContent();
|
||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_order_by_bottom_sheet_dialog, container);
|
||||
if (portrait) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
}
|
||||
|
||||
if (night) {
|
||||
((TextView) mainView.findViewById(R.id.order_by_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.order_by_title)).setText(getString(R.string.order_by));
|
||||
|
||||
ImageView distanceIcon = (ImageView) mainView.findViewById(R.id.distance_icon);
|
||||
distanceIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_markers_dark));
|
||||
|
||||
ImageView nameIcon = (ImageView) mainView.findViewById(R.id.name_icon);
|
||||
nameIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_name));
|
||||
|
||||
ImageView dateAddedIcon = (ImageView) mainView.findViewById(R.id.date_added_icon);
|
||||
dateAddedIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_sort_by_date));
|
||||
|
||||
mainView.findViewById(R.id.distance_row).setOnClickListener(orderByModeOnClickListener);
|
||||
mainView.findViewById(R.id.name_row).setOnClickListener(orderByModeOnClickListener);
|
||||
mainView.findViewById(R.id.date_added_row).setOnClickListener(orderByModeOnClickListener);
|
||||
|
||||
mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
|
||||
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
|
||||
|
||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
final View scrollView = mainView.findViewById(R.id.marker_order_by_scroll_view);
|
||||
int scrollViewHeight = scrollView.getHeight();
|
||||
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
|
||||
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
|
||||
if (scrollViewHeight > spaceForScrollView) {
|
||||
scrollView.getLayoutParams().height = spaceForScrollView;
|
||||
scrollView.requestLayout();
|
||||
}
|
||||
|
||||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!portrait) {
|
||||
final Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
private View.OnClickListener orderByModeOnClickListener = new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
MapMarkersOrderByMode currentOrderByMode = settings.MAP_MARKERS_ORDER_BY_MODE.get();
|
||||
MapMarkersOrderByMode modeToSet;
|
||||
switch (view.getId()) {
|
||||
case R.id.distance_row:
|
||||
if (currentOrderByMode == MapMarkersOrderByMode.DISTANCE_DESC) {
|
||||
modeToSet = MapMarkersOrderByMode.DISTANCE_ASC;
|
||||
} else {
|
||||
modeToSet = MapMarkersOrderByMode.DISTANCE_DESC;
|
||||
}
|
||||
break;
|
||||
case R.id.name_row:
|
||||
modeToSet = MapMarkersOrderByMode.NAME;
|
||||
break;
|
||||
case R.id.date_added_row:
|
||||
if (currentOrderByMode == MapMarkersOrderByMode.DATE_ADDED_DESC) {
|
||||
modeToSet = MapMarkersOrderByMode.DATE_ADDED_ASC;
|
||||
} else {
|
||||
modeToSet = MapMarkersOrderByMode.DATE_ADDED_DESC;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
modeToSet = currentOrderByMode;
|
||||
}
|
||||
settings.MAP_MARKERS_ORDER_BY_MODE.set(modeToSet);
|
||||
if (listener != null) {
|
||||
listener.onMapMarkersOrderByModeChanged(modeToSet);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
interface OrderByFragmentListener {
|
||||
void onMapMarkersOrderByModeChanged(MapMarkersOrderByMode orderByMode);
|
||||
}
|
||||
}
|
|
@ -609,7 +609,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
File gpx = getGpxDataItem().getFile();
|
||||
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(), trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
|
||||
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
|
||||
markersHelper.addMarkersSyncGroup(syncGroup);
|
||||
markersHelper.addMapMarkers(points, names, syncGroup);
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
|
@ -630,14 +631,6 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private String trimExtension(String src) {
|
||||
int index = src.lastIndexOf('.');
|
||||
if (index != -1) {
|
||||
return src.substring(0, index);
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
private void enterFavoritesMode() {
|
||||
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
for (WptPt pointInTrack : g.getPoints()) {
|
||||
if (pointInTrack.getExtensionsToRead().get("u").equals(
|
||||
point.getExtensionsToRead().get("u"))) {
|
||||
g.removePoint(pointInTrack);
|
||||
g.deleteWptPt(pointInTrack);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
|
@ -34,6 +35,7 @@ import net.osmand.plus.GpxSelectionHelper;
|
|||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -619,11 +621,20 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
position.getLongitude(), System.currentTimeMillis(), objectInMotion.desc,
|
||||
objectInMotion.name, objectInMotion.category, objectInMotion.getColor());
|
||||
new SaveGpxFileAsyncTask(view.getApplication(), callback, objectInMotion).execute(gpxFile);
|
||||
syncGpx(gpxFile);
|
||||
} else if (callback != null) {
|
||||
callback.onApplyMovedObject(false, o);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncGpx(GPXFile gpxFile) {
|
||||
File gpx = new File(gpxFile.path);
|
||||
if (gpx.exists()) {
|
||||
view.getApplication().getMapMarkersHelper().syncGroup(new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
static class SaveGpxFileAsyncTask extends AsyncTask<GPXFile, Void, String> {
|
||||
private final OsmandApplication app;
|
||||
@Nullable
|
||||
|
|
Loading…
Reference in a new issue