Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
28361c86d7
30 changed files with 1080 additions and 469 deletions
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/color_dialog_buttons_dark" android:state_checked="true"/>
|
||||
<item android:color="@color/ctx_menu_info_text_dark" android:state_checked="false"/>
|
||||
</selector>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/dashboard_blue" android:state_checked="true"/>
|
||||
<item android:color="@color/icon_color" android:state_checked="false"/>
|
||||
</selector>
|
|
@ -98,7 +98,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
app:itemBackground="?attr/bg_color"
|
||||
app:itemIconTint="@drawable/bottom_navigation_color_selector"
|
||||
app:itemTextColor="@drawable/bottom_navigation_color_selector"
|
||||
app:itemIconTint="@color/bottom_navigation_color_selector_light"
|
||||
app:itemTextColor="@color/bottom_navigation_color_selector_light"
|
||||
app:menu="@menu/map_markers_bottom_navigation"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -115,6 +115,73 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/show_arrows_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/show_arrows_on_the_map"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/show_arrows_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/show_guide_line_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:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/show_guide_line"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/show_guide_line_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_content_padding_small"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/top_bar_row"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -148,15 +215,15 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<RadioButton
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
android:background="@null"
|
||||
android:id="@+id/top_bar_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"/>
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -192,15 +259,15 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<RadioButton
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
android:background="@null"
|
||||
android:id="@+id/widget_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"/>
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -235,15 +302,15 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<RadioButton
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
android:background="@null"
|
||||
android:id="@+id/none_radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"/>
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -14,24 +14,35 @@
|
|||
android:orientation="horizontal"
|
||||
android:background="?attr/bg_color">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="48dp"
|
||||
tools:src="@drawable/ic_action_fav_dark"
|
||||
tools:visibility="visible"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/icon_space"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/date_title"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:gravity="center_vertical"
|
||||
tools:text="Today"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/date_options_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:background="@null"
|
||||
android:focusableInTouchMode="true"
|
||||
tools:src="@drawable/ic_overflow_menu_white"/>
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/disable_group_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:focusableInTouchMode="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
android:layout_height="28dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:id="@+id/map_marker_title"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -69,7 +68,6 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
|
25
OsmAnd/res/layout/map_marker_item_show_hide_history.xml
Normal file
25
OsmAnd/res/layout/map_marker_item_show_hide_history.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/bg_color"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/show_hide_history_title"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="56dp"
|
||||
android:paddingStart="56dp"
|
||||
android:textAllCaps="true"
|
||||
android:gravity="center_vertical"
|
||||
tools:text="Show passed"
|
||||
android:textSize="12sp"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textColor="@color/dashboard_blue"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -110,11 +110,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:maxLines="1"
|
||||
tools:text="City" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/time_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
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="show_guide_line">Show guide line</string>
|
||||
<string name="show_arrows_on_the_map">Show arrows on the map</string>
|
||||
<string name="show_passed">Show passed</string>
|
||||
<string name="hide_passed">Hide passed</string>
|
||||
<string name="remove_from_map_markers">Remove from Map Markers</string>
|
||||
<string name="descendingly">Descendingly</string>
|
||||
<string name="ascendingly">Ascendingly</string>
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
|||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.helpers.ColorDialogs;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -40,6 +39,7 @@ public class MapMarkersHelper {
|
|||
|
||||
private List<MapMarker> mapMarkers = new LinkedList<>();
|
||||
private List<MapMarker> mapMarkersHistory = new LinkedList<>();
|
||||
private List<MapMarkersGroup> mapMarkersGroups = new ArrayList<>();
|
||||
private OsmandSettings settings;
|
||||
private List<MapMarkerChangedListener> listeners = new ArrayList<>();
|
||||
private OsmandApplication ctx;
|
||||
|
@ -175,6 +175,11 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MarkersSyncGroup getGroup(String id) {
|
||||
return markersDbHelper.getGroup(id);
|
||||
}
|
||||
|
||||
public static class MarkersSyncGroup {
|
||||
|
||||
public static final int FAVORITES_TYPE = 0;
|
||||
|
@ -214,6 +219,10 @@ public class MapMarkersHelper {
|
|||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
public MapMarkersHelper(OsmandApplication ctx) {
|
||||
|
@ -222,6 +231,7 @@ public class MapMarkersHelper {
|
|||
markersDbHelper = ctx.getMapMarkersDbHelper();
|
||||
startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get();
|
||||
loadMarkers();
|
||||
createMapMarkersGroups();
|
||||
}
|
||||
|
||||
public boolean isStartFromMyLocation() {
|
||||
|
@ -251,7 +261,7 @@ public class MapMarkersHelper {
|
|||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
|
||||
List<MapMarker> markersHistory = markersDbHelper.getMarkersHistory();
|
||||
sortHistoryMarkers();
|
||||
sortMarkers(markersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
mapMarkersHistory.addAll(markersHistory);
|
||||
|
||||
if (!ctx.isApplicationInitializing()) {
|
||||
|
@ -279,73 +289,20 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public List<MapMarker> getMarkersSortedByGroup() {
|
||||
Map<String, MapMarkerGroup> groupsMap = new LinkedHashMap<>();
|
||||
List<MapMarker> noGroup = new ArrayList<>();
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
String groupName = marker.groupName;
|
||||
if (groupName == null) {
|
||||
noGroup.add(marker);
|
||||
} else {
|
||||
MapMarkerGroup group = groupsMap.get(groupName);
|
||||
if (group == null) {
|
||||
group = new MapMarkerGroup(groupName, marker.creationDate);
|
||||
groupsMap.put(groupName, group);
|
||||
} else {
|
||||
long markerCreationDate = marker.creationDate;
|
||||
if (markerCreationDate < group.getCreationDate()) {
|
||||
group.setCreationDate(markerCreationDate);
|
||||
}
|
||||
}
|
||||
group.getMapMarkers().add(marker);
|
||||
}
|
||||
}
|
||||
List<MapMarkerGroup> groups = new ArrayList<>(groupsMap.values());
|
||||
sortGroups(groups);
|
||||
|
||||
List<MapMarker> markers = new ArrayList<>();
|
||||
markers.addAll(noGroup);
|
||||
for (MapMarkerGroup group : groups) {
|
||||
markers.addAll(group.getMapMarkers());
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
|
||||
private void sortGroups(List<MapMarkerGroup> groups) {
|
||||
Collections.sort(groups, new Comparator<MapMarkerGroup>() {
|
||||
@Override
|
||||
public int compare(MapMarkerGroup group1, MapMarkerGroup group2) {
|
||||
long t1 = group1.creationDate;
|
||||
long t2 = group2.creationDate;
|
||||
if (t1 > t2) {
|
||||
return -1;
|
||||
} else if (t1 == t2) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sortHistoryMarkers() {
|
||||
sortMarkers(true, null);
|
||||
}
|
||||
|
||||
private void sortMarkers(final boolean history, final OsmandSettings.MapMarkersOrderByMode orderByMode) {
|
||||
public void sortMarkers(List<MapMarker> markers, final boolean visited, final OsmandSettings.MapMarkersOrderByMode orderByMode) {
|
||||
final LatLon location = ctx.getSettings().getLastKnownMapLocation();
|
||||
Collections.sort(history ? mapMarkersHistory : mapMarkers, new Comparator<MapMarker>() {
|
||||
Collections.sort(markers, new Comparator<MapMarker>() {
|
||||
@Override
|
||||
public int compare(MapMarker mapMarker1, MapMarker mapMarker2) {
|
||||
if (history || orderByMode.isDateAddedDescending() || orderByMode.isDateAddedAscending()) {
|
||||
long t1 = history ? mapMarker1.visitedDate : mapMarker1.creationDate;
|
||||
long t2 = history ? mapMarker2.visitedDate : mapMarker2.creationDate;
|
||||
if (orderByMode.isDateAddedDescending() || orderByMode.isDateAddedAscending()) {
|
||||
long t1 = visited ? mapMarker1.visitedDate : mapMarker1.creationDate;
|
||||
long t2 = visited ? mapMarker2.visitedDate : mapMarker2.creationDate;
|
||||
if (t1 > t2) {
|
||||
return history || orderByMode.isDateAddedDescending() ? -1 : 1;
|
||||
return orderByMode.isDateAddedDescending() ? -1 : 1;
|
||||
} else if (t1 == t2) {
|
||||
return 0;
|
||||
} else {
|
||||
return history || orderByMode.isDateAddedDescending() ? 1 : -1;
|
||||
return orderByMode.isDateAddedDescending() ? 1 : -1;
|
||||
}
|
||||
} else if (orderByMode.isDistanceDescending() || orderByMode.isDistanceAscending()) {
|
||||
int d1 = (int) MapUtils.getDistance(location, mapMarker1.getLatitude(), mapMarker1.getLongitude());
|
||||
|
@ -367,7 +324,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
public void orderMarkers(OsmandSettings.MapMarkersOrderByMode orderByMode) {
|
||||
sortMarkers(false, orderByMode);
|
||||
sortMarkers(getMapMarkers(), false, orderByMode);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
}
|
||||
|
||||
|
@ -417,6 +374,9 @@ public class MapMarkersHelper {
|
|||
removeActiveMarkersFromSyncGroup(group.getId());
|
||||
return;
|
||||
}
|
||||
if (group.getColor() == -1) {
|
||||
group.setColor(favGroup.color);
|
||||
}
|
||||
|
||||
for (FavouritePoint fp : favGroup.points) {
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName());
|
||||
|
@ -438,7 +398,9 @@ public class MapMarkersHelper {
|
|||
}
|
||||
|
||||
List<WptPt> gpxPoints = new LinkedList<>(gpx.getPoints());
|
||||
int defColor = ContextCompat.getColor(ctx, R.color.marker_red);
|
||||
for (WptPt pt : gpxPoints) {
|
||||
group.setColor(pt.getColor(defColor));
|
||||
addNewMarkerIfNeeded(group, dbMarkers, new LatLon(pt.lat, pt.lon), pt.name);
|
||||
}
|
||||
|
||||
|
@ -452,13 +414,10 @@ public class MapMarkersHelper {
|
|||
for (MapMarker marker : markers) {
|
||||
if (marker.id.equals(group.getId() + name)) {
|
||||
exists = true;
|
||||
int colorIndex = MapMarker.getColorIndex(ctx, ColorDialogs.getNearestColor(group.getColor(), MapMarker.getColors(ctx)));
|
||||
boolean updateColor = group.getColor() != -1 && marker.colorIndex != colorIndex;
|
||||
if (!marker.history && (!marker.point.equals(latLon) || updateColor)) {
|
||||
if (!marker.history && (!marker.point.equals(latLon))) {
|
||||
for (MapMarker m : mapMarkers) {
|
||||
if (m.id.equals(marker.id)) {
|
||||
m.point = latLon;
|
||||
m.colorIndex = colorIndex;
|
||||
updateMapMarker(m, true);
|
||||
break;
|
||||
}
|
||||
|
@ -501,7 +460,7 @@ public class MapMarkersHelper {
|
|||
marker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
|
||||
mapMarkersHistory.add(marker);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
sortHistoryMarkers();
|
||||
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -511,11 +470,12 @@ public class MapMarkersHelper {
|
|||
markersDbHelper.addMarker(marker);
|
||||
if (marker.history) {
|
||||
mapMarkersHistory.add(marker);
|
||||
sortHistoryMarkers();
|
||||
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
} else {
|
||||
mapMarkers.add(marker);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
}
|
||||
addMarkerToGroup(marker);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +487,7 @@ public class MapMarkersHelper {
|
|||
marker.history = false;
|
||||
mapMarkers.add(position, marker);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
sortHistoryMarkers();
|
||||
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +501,7 @@ public class MapMarkersHelper {
|
|||
mapMarkers.add(marker);
|
||||
}
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
sortHistoryMarkers();
|
||||
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -551,6 +511,7 @@ public class MapMarkersHelper {
|
|||
markersDbHelper.removeMarker(marker, true);
|
||||
mapMarkersHistory.remove(marker);
|
||||
refresh();
|
||||
removeMarkerFromGroup(marker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,7 +584,7 @@ public class MapMarkersHelper {
|
|||
}
|
||||
mapMarkersHistory.addAll(mapMarkers);
|
||||
mapMarkers.clear();
|
||||
sortHistoryMarkers();
|
||||
sortMarkers(mapMarkersHistory, true, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -632,6 +593,7 @@ public class MapMarkersHelper {
|
|||
markersDbHelper.clearAllMarkersHistory();
|
||||
mapMarkersHistory.clear();
|
||||
refresh();
|
||||
removeHistoryMarkersFromGroups();
|
||||
}
|
||||
|
||||
public void addMarkersSyncGroup(MarkersSyncGroup group) {
|
||||
|
@ -675,8 +637,7 @@ public class MapMarkersHelper {
|
|||
|
||||
private void addMarkers(List<LatLon> points, List<PointDescription> historyNames, @Nullable MarkersSyncGroup group) {
|
||||
if (points.size() > 0) {
|
||||
boolean randomColor = group == null || group.getColor() == -1;
|
||||
int colorIndex = randomColor ? -1 : MapMarker.getColorIndex(ctx, ColorDialogs.getNearestColor(group.getColor(), MapMarker.getColors(ctx)));
|
||||
int colorIndex = -1;
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
LatLon point = points.get(i);
|
||||
PointDescription historyName = historyNames.get(i);
|
||||
|
@ -689,16 +650,14 @@ public class MapMarkersHelper {
|
|||
if (pointDescription.isLocation() && Algorithms.isEmpty(pointDescription.getName())) {
|
||||
pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
|
||||
}
|
||||
if (randomColor) {
|
||||
if (colorIndex == -1) {
|
||||
if (mapMarkers.size() > 0) {
|
||||
colorIndex = (mapMarkers.get(mapMarkers.size() - 1).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
|
||||
} else {
|
||||
colorIndex = 0;
|
||||
}
|
||||
if (colorIndex == -1) {
|
||||
if (mapMarkers.size() > 0) {
|
||||
colorIndex = (mapMarkers.get(mapMarkers.size() - 1).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
|
||||
} else {
|
||||
colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
|
||||
colorIndex = 0;
|
||||
}
|
||||
} else {
|
||||
colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
|
||||
}
|
||||
|
||||
MapMarker marker = new MapMarker(point, pointDescription, colorIndex, false, 0);
|
||||
|
@ -714,6 +673,7 @@ public class MapMarkersHelper {
|
|||
marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
|
||||
markersDbHelper.addMarker(marker);
|
||||
mapMarkers.add(marker);
|
||||
addMarkerToGroup(marker);
|
||||
checkAndFixActiveMarkersOrderIfNeeded();
|
||||
}
|
||||
}
|
||||
|
@ -856,15 +816,165 @@ public class MapMarkersHelper {
|
|||
GPXUtilities.writeGpxFile(fout, file, ctx);
|
||||
}
|
||||
|
||||
public static class MapMarkerGroup {
|
||||
private String name;
|
||||
private List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
private long creationDate;
|
||||
|
||||
public MapMarkerGroup(String name, long creationDate) {
|
||||
this.name = name;
|
||||
this.creationDate = creationDate;
|
||||
private void removeHistoryMarkersFromGroups() {
|
||||
for (MapMarkersGroup markersGroup : mapMarkersGroups) {
|
||||
List<MapMarker> activeMarkers = new ArrayList<>();
|
||||
for (MapMarker marker : markersGroup.getMarkers()) {
|
||||
if (!marker.history) {
|
||||
activeMarkers.add(marker);
|
||||
}
|
||||
}
|
||||
markersGroup.setMarkers(activeMarkers);
|
||||
updateShowHideHistoryButtonInGroup(markersGroup);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShowHideHistoryButtonInGroup(MapMarkersGroup mapMarkersGroup) {
|
||||
int historyMarkersCount = mapMarkersGroup.getHistoryMarkers().size();
|
||||
ShowHideHistoryButton showHideHistoryButton = mapMarkersGroup.getShowHideHistoryButton();
|
||||
if (showHideHistoryButton != null && historyMarkersCount == 0) {
|
||||
mapMarkersGroup.setShowHideHistoryButton(null);
|
||||
} else if (historyMarkersCount > 0) {
|
||||
showHideHistoryButton = new ShowHideHistoryButton();
|
||||
showHideHistoryButton.setShowHistory(false);
|
||||
showHideHistoryButton.setMarkerGroup(mapMarkersGroup);
|
||||
mapMarkersGroup.setShowHideHistoryButton(showHideHistoryButton);
|
||||
}
|
||||
}
|
||||
|
||||
private void addMarkerToGroup(MapMarker marker) {
|
||||
if (marker != null) {
|
||||
MapMarkersGroup mapMarkersGroup = getMapMarkerGroupByName(marker.groupName);
|
||||
if (mapMarkersGroup != null) {
|
||||
mapMarkersGroup.getMarkers().add(marker);
|
||||
updateShowHideHistoryButtonInGroup(mapMarkersGroup);
|
||||
if (mapMarkersGroup.getName() == null) {
|
||||
sortMarkers(mapMarkersGroup.getMarkers(), false, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
}
|
||||
} else {
|
||||
MapMarkersGroup group = createMapMarkerGroup(marker);
|
||||
group.getMarkers().add(marker);
|
||||
createHeaderAndHistoryButtonInGroup(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MapMarkersGroup createMapMarkerGroup(MapMarker marker) {
|
||||
MapMarkersGroup group = new MapMarkersGroup();
|
||||
group.setName(marker.groupName);
|
||||
MapMarkersHelper.MarkersSyncGroup syncGroup = getGroup(marker.groupKey);
|
||||
if (syncGroup != null) {
|
||||
group.setType(syncGroup.getType());
|
||||
}
|
||||
group.setColor(MapMarker.getColorId(marker.colorIndex));
|
||||
group.setCreationDate(marker.creationDate);
|
||||
mapMarkersGroups.add(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
private void createHeaderAndHistoryButtonInGroup(MapMarkersGroup group) {
|
||||
GroupHeader header = new GroupHeader();
|
||||
int type = group.getType();
|
||||
if (type != -1) {
|
||||
header.setIconRes(type == MapMarkersHelper.MarkersSyncGroup.FAVORITES_TYPE ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_track_16);
|
||||
}
|
||||
header.setGroup(group);
|
||||
group.setGroupHeader(header);
|
||||
updateShowHideHistoryButtonInGroup(group);
|
||||
}
|
||||
|
||||
private void removeMarkerFromGroup(MapMarker marker) {
|
||||
if (marker != null) {
|
||||
MapMarkersGroup mapMarkersGroup = getMapMarkerGroupByName(marker.groupName);
|
||||
if (mapMarkersGroup != null) {
|
||||
mapMarkersGroup.getMarkers().remove(marker);
|
||||
updateShowHideHistoryButtonInGroup(mapMarkersGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<MapMarkersGroup> getMapMarkersGroups() {
|
||||
return mapMarkersGroups;
|
||||
}
|
||||
|
||||
private void createMapMarkersGroups() {
|
||||
List<MapMarker> markers = new ArrayList<>();
|
||||
markers.addAll(mapMarkers);
|
||||
markers.addAll(mapMarkersHistory);
|
||||
|
||||
Map<String, MapMarkersGroup> groupsMap = new LinkedHashMap<>();
|
||||
MapMarkersGroup noGroup = null;
|
||||
for (MapMarker marker : markers) {
|
||||
String groupName = marker.groupName;
|
||||
if (groupName == null) {
|
||||
if (noGroup == null) {
|
||||
noGroup = new MapMarkersGroup();
|
||||
noGroup.setCreationDate(marker.creationDate);
|
||||
}
|
||||
noGroup.getMarkers().add(marker);
|
||||
} else {
|
||||
MapMarkersGroup group = groupsMap.get(groupName);
|
||||
if (group == null) {
|
||||
group = createMapMarkerGroup(marker);
|
||||
groupsMap.put(groupName, group);
|
||||
} else {
|
||||
long markerCreationDate = marker.creationDate;
|
||||
if (markerCreationDate < group.getCreationDate()) {
|
||||
group.setCreationDate(markerCreationDate);
|
||||
}
|
||||
}
|
||||
group.getMarkers().add(marker);
|
||||
}
|
||||
}
|
||||
mapMarkersGroups = new ArrayList<>(groupsMap.values());
|
||||
sortGroups(mapMarkersGroups);
|
||||
|
||||
for (MapMarkersGroup group : mapMarkersGroups) {
|
||||
createHeaderAndHistoryButtonInGroup(group);
|
||||
}
|
||||
|
||||
if (noGroup != null) {
|
||||
sortMarkers(noGroup.getMarkers(), false, OsmandSettings.MapMarkersOrderByMode.DATE_ADDED_DESC);
|
||||
mapMarkersGroups.add(0, noGroup);
|
||||
}
|
||||
}
|
||||
|
||||
private void sortGroups(List<MapMarkersGroup> groups) {
|
||||
Collections.sort(groups, new Comparator<MapMarkersGroup>() {
|
||||
@Override
|
||||
public int compare(MapMarkersGroup group1, MapMarkersGroup group2) {
|
||||
long t1 = group1.getCreationDate();
|
||||
long t2 = group2.getCreationDate();
|
||||
if (t1 > t2) {
|
||||
return -1;
|
||||
} else if (t1 == t2) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public MapMarkersGroup getMapMarkerGroupByName(String name) {
|
||||
for (MapMarkersGroup group : mapMarkersGroups) {
|
||||
if ((name == null && group.getName() == null)
|
||||
|| (group.getName() != null && group.getName().equals(name))) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class MapMarkersGroup {
|
||||
private String name;
|
||||
private GroupHeader header;
|
||||
private int type = -1;
|
||||
private List<MapMarker> markers = new ArrayList<>();
|
||||
private long creationDate;
|
||||
private ShowHideHistoryButton showHideHistoryButton;
|
||||
private int color;
|
||||
private boolean disabled;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
|
@ -874,12 +984,48 @@ public class MapMarkersHelper {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public List<MapMarker> getMapMarkers() {
|
||||
return mapMarkers;
|
||||
public GroupHeader getGroupHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setMapMarkers(List<MapMarker> mapMarkers) {
|
||||
this.mapMarkers = mapMarkers;
|
||||
public void setGroupHeader(GroupHeader header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<MapMarker> getActiveMarkers() {
|
||||
List<MapMarker> activeMarkers = new ArrayList<>();
|
||||
for (MapMarker marker : markers) {
|
||||
if (!marker.history) {
|
||||
activeMarkers.add(marker);
|
||||
}
|
||||
}
|
||||
return activeMarkers;
|
||||
}
|
||||
|
||||
public List<MapMarker> getHistoryMarkers() {
|
||||
List<MapMarker> historyMarkers = new ArrayList<>();
|
||||
for (MapMarker marker : markers) {
|
||||
if (marker.history) {
|
||||
historyMarkers.add(marker);
|
||||
}
|
||||
}
|
||||
return historyMarkers;
|
||||
}
|
||||
|
||||
public List<MapMarker> getMarkers() {
|
||||
return markers;
|
||||
}
|
||||
|
||||
public void setMarkers(List<MapMarker> markers) {
|
||||
this.markers = markers;
|
||||
}
|
||||
|
||||
public long getCreationDate() {
|
||||
|
@ -889,5 +1035,71 @@ public class MapMarkersHelper {
|
|||
public void setCreationDate(long creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
public ShowHideHistoryButton getShowHideHistoryButton() {
|
||||
return showHideHistoryButton;
|
||||
}
|
||||
|
||||
public void setShowHideHistoryButton(ShowHideHistoryButton showHideHistoryButton) {
|
||||
this.showHideHistoryButton = showHideHistoryButton;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShowHideHistoryButton {
|
||||
private boolean showHistory;
|
||||
private MapMarkersGroup group;
|
||||
|
||||
public boolean isShowHistory() {
|
||||
return showHistory;
|
||||
}
|
||||
|
||||
public void setShowHistory(boolean showHistory) {
|
||||
this.showHistory = showHistory;
|
||||
}
|
||||
|
||||
public MapMarkersGroup getMapMarkerGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setMarkerGroup(MapMarkersGroup group) {
|
||||
this.group = group;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GroupHeader {
|
||||
private int iconRes;
|
||||
private MapMarkersGroup group;
|
||||
|
||||
public int getIconRes() {
|
||||
return iconRes;
|
||||
}
|
||||
|
||||
public void setIconRes(int iconRes) {
|
||||
this.iconRes = iconRes;
|
||||
}
|
||||
|
||||
public MapMarkersGroup getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(MapMarkersGroup group) {
|
||||
this.group = group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import android.location.LocationManager;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
|
@ -69,11 +70,14 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
private static final int GPS_DIST_REQUEST = 0;
|
||||
private static final int NOT_SWITCH_TO_NETWORK_WHEN_GPS_LOST_MS = 12000;
|
||||
|
||||
private static final long STALE_LOCATION_TIMEOUT = 1000 * 60 * 60; // 60 minutes
|
||||
public static final long STALE_LOCATION_TIMEOUT_FOR_ICON = 1000 * 60 * 5; // 5 minutes
|
||||
private static final long STALE_LOCATION_TIMEOUT = 1000 * 60 * 5; // 5 minutes
|
||||
private static final long STALE_LOCATION_TIMEOUT_FOR_UI = 1000 * 60 * 15; // 15 minutes
|
||||
|
||||
private static final int UPDATES_BEFORE_CHECK_LOCATION = 100;
|
||||
private int updatesCounter;
|
||||
private int updatesCounterUi;
|
||||
|
||||
private net.osmand.Location cachedLocation;
|
||||
|
||||
private long lastTimeGPSLocationFixed = 0;
|
||||
private boolean gpsSignalLost;
|
||||
|
@ -877,6 +881,26 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
return location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public net.osmand.Location getLastStaleKnownLocation() {
|
||||
if (updatesCounterUi == 0) {
|
||||
net.osmand.Location newLoc = getLastKnownLocation();
|
||||
if (newLoc == null) {
|
||||
if (cachedLocation != null && System.currentTimeMillis() - cachedLocation.getTime() > STALE_LOCATION_TIMEOUT_FOR_UI) {
|
||||
cachedLocation = null;
|
||||
}
|
||||
} else {
|
||||
cachedLocation = newLoc;
|
||||
}
|
||||
}
|
||||
if (updatesCounterUi == UPDATES_BEFORE_CHECK_LOCATION) {
|
||||
updatesCounterUi = 0;
|
||||
} else {
|
||||
updatesCounterUi++;
|
||||
}
|
||||
return cachedLocation;
|
||||
}
|
||||
|
||||
|
||||
public void showNavigationInfo(TargetPoint pointToNavigate, Context uiActivity) {
|
||||
getNavigationInfo().show(pointToNavigate, getHeading(), uiActivity);
|
||||
|
|
|
@ -713,6 +713,9 @@ public class OsmandSettings {
|
|||
|
||||
public final CommonPreference<RulerMode> RULER_MODE = new EnumIntPreference<>("ruler_mode", RulerMode.FIRST, RulerMode.values()).makeGlobal();
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeGlobal();
|
||||
public final CommonPreference<Boolean> SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeGlobal();
|
||||
|
||||
public final CommonPreference<Boolean> USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal();
|
||||
public final CommonPreference<String> MAPILLARY_FILTER_USERNAME = new StringPreference("mapillary_filter_username", "").makeGlobal();
|
||||
|
|
|
@ -16,7 +16,9 @@ import android.view.LayoutInflater;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.View.OnLayoutChangeListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.Button;
|
||||
|
@ -67,6 +69,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
ImageView fabView;
|
||||
|
||||
private MapContextMenu menu;
|
||||
private OnLayoutChangeListener containerLayoutListener;
|
||||
|
||||
private int menuTopViewHeight;
|
||||
private int menuTopShadowHeight;
|
||||
|
@ -108,10 +111,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
||||
skipHalfScreenStateLimit = screenHeight * SKIP_HALF_SCREEN_STATE_KOEF;
|
||||
|
||||
viewHeight = screenHeight - AndroidUtils.getStatusBarHeight(getMapActivity());
|
||||
processScreenHeight(container);
|
||||
|
||||
fabPaddingTopPx = dpToPx(FAB_PADDING_TOP_DP);
|
||||
markerPaddingPx = dpToPx(MARKER_PADDING_DP);
|
||||
|
@ -464,10 +464,34 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
|
||||
//getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
containerLayoutListener = new OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View view, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
if (bottom != oldBottom) {
|
||||
processScreenHeight(view.getParent());
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
created = true;
|
||||
return view;
|
||||
}
|
||||
|
||||
private void processScreenHeight(ViewParent parent) {
|
||||
View container = (View)parent;
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity());
|
||||
} else {
|
||||
screenHeight = AndroidUtils.getScreenHeight(getActivity());
|
||||
}
|
||||
skipHalfScreenStateLimit = screenHeight * SKIP_HALF_SCREEN_STATE_KOEF;
|
||||
viewHeight = screenHeight - AndroidUtils.getStatusBarHeight(getMapActivity());
|
||||
}
|
||||
|
||||
public void openMenuFullScreen() {
|
||||
changeMenuState(getViewY(), true, true, false);
|
||||
}
|
||||
|
@ -762,10 +786,19 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
if (!wasDrawerDisabled) {
|
||||
getMapActivity().disableDrawer();
|
||||
}
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent != null && containerLayoutListener != null) {
|
||||
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent != null && containerLayoutListener != null) {
|
||||
((View) parent).removeOnLayoutChangeListener(containerLayoutListener);
|
||||
}
|
||||
getMapActivity().getMapViewTrackingUtilities().setContextMenu(null);
|
||||
getMapActivity().getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
if (!wasDrawerDisabled) {
|
||||
|
|
|
@ -24,9 +24,9 @@ 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.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -44,12 +44,14 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
private LockableViewPager viewPager;
|
||||
private TextView orderByModeTitle;
|
||||
|
||||
private boolean lightTheme;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
OsmandApplication app = getMyApplication();
|
||||
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
lightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
setStyle(STYLE_NO_FRAME, themeId);
|
||||
}
|
||||
|
||||
|
@ -95,6 +97,9 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
|
||||
|
||||
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.map_markers_toolbar);
|
||||
if (!lightTheme) {
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.actionbar_dark_color));
|
||||
}
|
||||
orderByModeTitle = toolbar.findViewById(R.id.order_by_mode_text);
|
||||
setOrderByMode(getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.get());
|
||||
|
||||
|
@ -121,6 +126,10 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
viewPager.setAdapter(adapter);
|
||||
|
||||
BottomNavigationView bottomNav = mainView.findViewById(R.id.map_markers_bottom_navigation);
|
||||
if (!lightTheme) {
|
||||
bottomNav.setItemIconTintList(ContextCompat.getColorStateList(getContext(), R.color.bottom_navigation_color_selector_dark));
|
||||
bottomNav.setItemTextColor(ContextCompat.getColorStateList(getContext(), R.color.bottom_navigation_color_selector_dark));
|
||||
}
|
||||
bottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
||||
|
|
|
@ -22,43 +22,45 @@ import net.osmand.util.MapUtils;
|
|||
|
||||
public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener {
|
||||
|
||||
public static final String TAG = "MapMarkersGroupsFragment";
|
||||
public static final String TAG = "MapMarkersGroupsFragment";
|
||||
|
||||
private MapMarkersGroupsAdapter adapter;
|
||||
private MapMarkersGroupsAdapter adapter;
|
||||
private Float heading;
|
||||
private Location location;
|
||||
private boolean locationUpdateStarted;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final RecyclerView recyclerView = new RecyclerView(getContext());
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final RecyclerView recyclerView = new RecyclerView(getContext());
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
|
||||
adapter = new MapMarkersGroupsAdapter(mapActivity);
|
||||
adapter = new MapMarkersGroupsAdapter(mapActivity);
|
||||
recyclerView.setAdapter(adapter);
|
||||
return recyclerView;
|
||||
}
|
||||
return recyclerView;
|
||||
}
|
||||
|
||||
void updateAdapter() {
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
void updateAdapter() {
|
||||
if (adapter != null) {
|
||||
adapter.createDisplayGroups();
|
||||
adapter.updateShowDirectionMarkers();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
|
||||
startLocationUpdate();
|
||||
}
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
adapter.setScreenOrientation(DashLocationFragment.getScreenOrientation(getActivity()));
|
||||
startLocationUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
stopLocationUpdate();
|
||||
}
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
stopLocationUpdate();
|
||||
}
|
||||
|
||||
void startLocationUpdate() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -43,7 +45,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
}
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.sort_by_icon))
|
||||
.setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color));
|
||||
.setImageDrawable(getContentIcon(R.drawable.ic_sort_waypoint_dark));
|
||||
OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
|
||||
ImageView showDirectionIcon = (ImageView) mainView.findViewById(R.id.show_direction_icon);
|
||||
int imageResId = 0;
|
||||
|
@ -55,16 +57,16 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
imageResId = R.drawable.ic_action_device_widget;
|
||||
break;
|
||||
}
|
||||
showDirectionIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
|
||||
showDirectionIcon.setBackgroundDrawable(getContentIcon(R.drawable.ic_action_device_top));
|
||||
if (imageResId != 0) {
|
||||
showDirectionIcon.setImageDrawable(getIcon(imageResId, R.color.dashboard_blue));
|
||||
}
|
||||
((ImageView) mainView.findViewById(R.id.build_route_icon))
|
||||
.setImageDrawable(getIcon(R.drawable.map_directions, R.color.on_map_icon_color));
|
||||
.setImageDrawable(getContentIcon(R.drawable.map_directions));
|
||||
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon))
|
||||
.setImageDrawable(getIcon(R.drawable.ic_action_polygom_dark, R.color.on_map_icon_color));
|
||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
|
||||
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon))
|
||||
.setImageDrawable(getIcon(R.drawable.ic_action_history2, R.color.on_map_icon_color));
|
||||
.setImageDrawable(getContentIcon(R.drawable.ic_action_history2));
|
||||
|
||||
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText(getMyApplication().getSettings().MAP_MARKERS_MODE.get().toHumanString(getActivity()));
|
||||
|
||||
|
@ -171,6 +173,11 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
return getIcon(id, getMyApplication().getSettings().isLightContent() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark);
|
||||
}
|
||||
|
||||
interface MarkerOptionsFragmentListener {
|
||||
|
||||
void sortByOnClick();
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -121,6 +123,11 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
return getIcon(id, settings.isLightContent() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark);
|
||||
}
|
||||
|
||||
private View.OnClickListener orderByModeOnClickListener = new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
@ -12,6 +15,7 @@ import android.view.ViewGroup;
|
|||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
@ -19,6 +23,7 @@ import android.widget.TextView;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
|
@ -38,8 +43,9 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final OsmandSettings settings = getMyApplication().getSettings();
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
night = !getMyApplication().getSettings().isLightContent();
|
||||
night = !settings.isLightContent();
|
||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_show_direction_bottom_sheet_dialog, container);
|
||||
|
@ -47,7 +53,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
}
|
||||
|
||||
OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
|
||||
OsmandSettings.MapMarkersMode mode = settings.MAP_MARKERS_MODE.get();
|
||||
highlightSelectedItem(mode, true);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
|
@ -84,16 +90,44 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
((TextView) mainView.findViewById(R.id.show_direction_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||
}
|
||||
|
||||
final CompoundButton showArrowsToggle = (CompoundButton) mainView.findViewById(R.id.show_arrows_switch);
|
||||
showArrowsToggle.setChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS.get());
|
||||
mainView.findViewById(R.id.show_arrows_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean newState = !settings.SHOW_ARROWS_TO_FIRST_MARKERS.get();
|
||||
settings.SHOW_ARROWS_TO_FIRST_MARKERS.set(newState);
|
||||
showArrowsToggle.setChecked(newState);
|
||||
if (getMapActivity() != null) {
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final CompoundButton showLinesToggle = (CompoundButton) mainView.findViewById(R.id.show_guide_line_switch);
|
||||
showLinesToggle.setChecked(settings.SHOW_LINES_TO_FIRST_MARKERS.get());
|
||||
mainView.findViewById(R.id.show_guide_line_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean newState = !settings.SHOW_LINES_TO_FIRST_MARKERS.get();
|
||||
settings.SHOW_LINES_TO_FIRST_MARKERS.set(newState);
|
||||
showLinesToggle.setChecked(newState);
|
||||
if (getMapActivity() != null) {
|
||||
getMapActivity().refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ImageView topBarIcon = (ImageView) mainView.findViewById(R.id.top_bar_icon);
|
||||
topBarIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
|
||||
topBarIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue));
|
||||
topBarIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_device_topbar));
|
||||
|
||||
ImageView widgetIcon = (ImageView) mainView.findViewById(R.id.widget_icon);
|
||||
widgetIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
|
||||
widgetIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_widget, R.color.dashboard_blue));
|
||||
widgetIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_device_widget));
|
||||
|
||||
ImageView noneIcon = (ImageView) mainView.findViewById(R.id.none_icon);
|
||||
noneIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
|
||||
noneIcon.setBackgroundDrawable(getContentIcon(R.drawable.ic_action_device_top));
|
||||
|
||||
mainView.findViewById(R.id.top_bar_row).setOnClickListener(showDirectionOnClickListener);
|
||||
mainView.findViewById(R.id.widget_row).setOnClickListener(showDirectionOnClickListener);
|
||||
|
@ -157,6 +191,19 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
return (MapActivity) activity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void highlightSelectedItem(OsmandSettings.MapMarkersMode mode, boolean check) {
|
||||
int iconBgColor = check ? R.color.dashboard_blue : R.color.on_map_icon_color;
|
||||
int iconColor = check ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue;
|
||||
|
|
|
@ -1,20 +1,26 @@
|
|||
package net.osmand.plus.mapmarkers.adapters;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class MapMarkerHeaderViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
final TextView date;
|
||||
final ImageButton optionsBtn;
|
||||
final ImageView icon;
|
||||
final View iconSpace;
|
||||
final TextView title;
|
||||
final SwitchCompat disableGroupSwitch;
|
||||
|
||||
public MapMarkerHeaderViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
date = itemView.findViewById(R.id.date_title);
|
||||
optionsBtn = itemView.findViewById(R.id.date_options_button);
|
||||
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
iconSpace = itemView.findViewById(R.id.icon_space);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
disableGroupSwitch = (SwitchCompat) itemView.findViewById(R.id.disable_group_switch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
|
|||
holder.iconDirection.setVisibility(View.GONE);
|
||||
|
||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_arrow_marker_diretion, markerColor));
|
||||
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.markers_top_bar_background));
|
||||
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.list_divider_dark : R.color.markers_top_bar_background));
|
||||
holder.title.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_white));
|
||||
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_divider_color));
|
||||
holder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.marker_circle_background_on_map_with_inset));
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
package net.osmand.plus.mapmarkers.adapters;
|
||||
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||
import net.osmand.plus.MapMarkersHelper.GroupHeader;
|
||||
import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -23,152 +31,251 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
|
||||
private static final int HEADER_TYPE = 1;
|
||||
private static final int MARKER_TYPE = 2;
|
||||
private static final int SHOW_HIDE_HISTORY_TYPE = 3;
|
||||
|
||||
private static final int TODAY_HEADER = 56;
|
||||
private static final int YESTERDAY_HEADER = 57;
|
||||
private static final int LAST_SEVEN_DAYS_HEADER = 58;
|
||||
private static final int THIS_YEAR_HEADER = 59;
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
private List<Object> items = new ArrayList<>();
|
||||
private boolean night;
|
||||
private int screenOrientation;
|
||||
private LatLon location;
|
||||
private Float heading;
|
||||
private boolean useCenter;
|
||||
private List<Object> items = new ArrayList<>();
|
||||
private boolean night;
|
||||
private int screenOrientation;
|
||||
private LatLon location;
|
||||
private Float heading;
|
||||
private boolean useCenter;
|
||||
private boolean showDirectionEnabled;
|
||||
private List<MapMarker> showDirectionMarkers;
|
||||
|
||||
public MapMarkersGroupsAdapter(MapActivity mapActivity) {
|
||||
this.app = mapActivity.getMyApplication();
|
||||
night = !mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
public MapMarkersGroupsAdapter(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
app = mapActivity.getMyApplication();
|
||||
night = !mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
updateShowDirectionMarkers();
|
||||
createDisplayGroups();
|
||||
}
|
||||
}
|
||||
|
||||
public void createDisplayGroups() {
|
||||
public void updateShowDirectionMarkers() {
|
||||
showDirectionEnabled = app.getSettings().MAP_MARKERS_MODE.get() != OsmandSettings.MapMarkersMode.NONE;;
|
||||
List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkers();
|
||||
int markersCount = mapMarkers.size();
|
||||
showDirectionMarkers = new ArrayList<>(mapMarkers.subList(0, markersCount > 0 ? markersCount > 1 ? 2 : 1 : 0));
|
||||
}
|
||||
|
||||
public void createDisplayGroups() {
|
||||
items.clear();
|
||||
List<MapMarkersGroup> groups = app.getMapMarkersHelper().getMapMarkersGroups();
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
MapMarkersGroup group = groups.get(i);
|
||||
String markerGroupName = group.getName();
|
||||
if (markerGroupName == null) {
|
||||
int previousDateHeader = -1;
|
||||
int monthsDisplayed = 0;
|
||||
|
||||
List<MapMarker> markersHistory = app.getMapMarkersHelper().getMarkersSortedByGroup();
|
||||
|
||||
int previousDateHeader = -1;
|
||||
String previousNameHeader = "";
|
||||
int monthsDisplayed = 0;
|
||||
|
||||
Calendar currentDateCalendar = Calendar.getInstance();
|
||||
currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
|
||||
int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
|
||||
int currentMonth = currentDateCalendar.get(Calendar.MONTH);
|
||||
int currentYear = currentDateCalendar.get(Calendar.YEAR);
|
||||
Calendar markerCalendar = Calendar.getInstance();
|
||||
for (int i = 0; i < markersHistory.size(); i++) {
|
||||
MapMarker marker = markersHistory.get(i);
|
||||
markerCalendar.setTimeInMillis(marker.creationDate);
|
||||
int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
|
||||
int markerMonth = markerCalendar.get(Calendar.MONTH);
|
||||
int markerYear = markerCalendar.get(Calendar.YEAR);
|
||||
String markerGroupName = marker.groupName;
|
||||
if (markerGroupName != null && markerGroupName.equals("")) {
|
||||
markerGroupName = app.getString(R.string.shared_string_favorites);
|
||||
}
|
||||
if (markerGroupName == null && markerYear == currentYear) {
|
||||
if (markerDay == currentDay && previousDateHeader != TODAY_HEADER) {
|
||||
items.add(TODAY_HEADER);
|
||||
previousDateHeader = TODAY_HEADER;
|
||||
} else if (markerDay == currentDay - 1 && previousDateHeader != YESTERDAY_HEADER) {
|
||||
items.add(YESTERDAY_HEADER);
|
||||
previousDateHeader = YESTERDAY_HEADER;
|
||||
} else if (currentDay - markerDay >= 2 && currentDay - markerDay <= 8 && previousDateHeader != LAST_SEVEN_DAYS_HEADER) {
|
||||
items.add(LAST_SEVEN_DAYS_HEADER);
|
||||
previousDateHeader = LAST_SEVEN_DAYS_HEADER;
|
||||
} else if (currentDay - markerDay > 8 && monthsDisplayed < 3 && previousDateHeader != markerMonth) {
|
||||
items.add(markerMonth);
|
||||
previousDateHeader = markerMonth;
|
||||
monthsDisplayed += 1;
|
||||
} else if (currentMonth - markerMonth >= 4 && previousDateHeader != THIS_YEAR_HEADER) {
|
||||
items.add(THIS_YEAR_HEADER);
|
||||
previousDateHeader = THIS_YEAR_HEADER;
|
||||
Calendar currentDateCalendar = Calendar.getInstance();
|
||||
currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
|
||||
int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
|
||||
int currentMonth = currentDateCalendar.get(Calendar.MONTH);
|
||||
int currentYear = currentDateCalendar.get(Calendar.YEAR);
|
||||
Calendar markerCalendar = Calendar.getInstance();
|
||||
List<MapMarker> groupMarkers = group.getActiveMarkers();
|
||||
for (int j = 0; j < groupMarkers.size(); j++) {
|
||||
MapMarker marker = groupMarkers.get(j);
|
||||
markerCalendar.setTimeInMillis(marker.creationDate);
|
||||
int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
|
||||
int markerMonth = markerCalendar.get(Calendar.MONTH);
|
||||
int markerYear = markerCalendar.get(Calendar.YEAR);
|
||||
if (markerYear == currentYear) {
|
||||
if (markerDay == currentDay && previousDateHeader != TODAY_HEADER) {
|
||||
items.add(TODAY_HEADER);
|
||||
previousDateHeader = TODAY_HEADER;
|
||||
} else if (markerDay == currentDay - 1 && previousDateHeader != YESTERDAY_HEADER) {
|
||||
items.add(YESTERDAY_HEADER);
|
||||
previousDateHeader = YESTERDAY_HEADER;
|
||||
} else if (currentDay - markerDay >= 2 && currentDay - markerDay <= 8 && previousDateHeader != LAST_SEVEN_DAYS_HEADER) {
|
||||
items.add(LAST_SEVEN_DAYS_HEADER);
|
||||
previousDateHeader = LAST_SEVEN_DAYS_HEADER;
|
||||
} else if (currentDay - markerDay > 8 && monthsDisplayed < 3 && previousDateHeader != markerMonth) {
|
||||
items.add(markerMonth);
|
||||
previousDateHeader = markerMonth;
|
||||
monthsDisplayed += 1;
|
||||
} else if (currentMonth - markerMonth >= 4 && previousDateHeader != THIS_YEAR_HEADER) {
|
||||
items.add(THIS_YEAR_HEADER);
|
||||
previousDateHeader = THIS_YEAR_HEADER;
|
||||
}
|
||||
} else if (previousDateHeader != markerYear) {
|
||||
items.add(markerYear);
|
||||
previousDateHeader = markerYear;
|
||||
}
|
||||
items.add(marker);
|
||||
}
|
||||
} else {
|
||||
GroupHeader header = group.getGroupHeader();
|
||||
items.add(header);
|
||||
ShowHideHistoryButton showHideHistoryButton = group.getShowHideHistoryButton();
|
||||
if (showHideHistoryButton != null && showHideHistoryButton.isShowHistory()) {
|
||||
items.addAll(group.getMarkers());
|
||||
} else {
|
||||
items.addAll(group.getActiveMarkers());
|
||||
}
|
||||
if (showHideHistoryButton != null) {
|
||||
items.add(showHideHistoryButton);
|
||||
}
|
||||
} else if (markerGroupName == null && previousDateHeader != markerYear) {
|
||||
items.add(markerYear);
|
||||
previousDateHeader = markerYear;
|
||||
} else if (markerGroupName != null && !previousNameHeader.equals(markerGroupName)) {
|
||||
items.add(markerGroupName);
|
||||
previousNameHeader = markerGroupName;
|
||||
}
|
||||
items.add(marker);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocation(LatLon location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setLocation(LatLon location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void setHeading(Float heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
public void setHeading(Float heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public void setUseCenter(boolean useCenter) {
|
||||
this.useCenter = useCenter;
|
||||
}
|
||||
public void setUseCenter(boolean useCenter) {
|
||||
this.useCenter = useCenter;
|
||||
}
|
||||
|
||||
public void setScreenOrientation(int screenOrientation) {
|
||||
this.screenOrientation = screenOrientation;
|
||||
}
|
||||
public void setScreenOrientation(int screenOrientation) {
|
||||
this.screenOrientation = screenOrientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
if (viewType == MARKER_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||
return new MapMarkerItemViewHolder(view);
|
||||
} else if (viewType == HEADER_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_header, viewGroup, false);
|
||||
return new MapMarkerHeaderViewHolder(view);
|
||||
} else if (viewType == SHOW_HIDE_HISTORY_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_show_hide_history, viewGroup, false);
|
||||
return new MapMarkersShowHideHistoryViewHolder(view);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported view type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
@Override
|
||||
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
if (holder instanceof MapMarkerItemViewHolder) {
|
||||
final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
|
||||
final MapMarker marker = (MapMarker) getItem(position);
|
||||
itemViewHolder.iconReorder.setVisibility(View.GONE);
|
||||
|
||||
final boolean markerInHistory = marker.history;
|
||||
|
||||
int color = MapMarker.getColorId(marker.colorIndex);
|
||||
itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
||||
ImageView markerImageViewToUpdate;
|
||||
int drawableResToUpdate;
|
||||
final boolean markerToHighlight = showDirectionMarkers.contains(marker);
|
||||
if (showDirectionEnabled && markerToHighlight) {
|
||||
itemViewHolder.iconDirection.setVisibility(View.GONE);
|
||||
|
||||
itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_arrow_marker_diretion, color));
|
||||
itemViewHolder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.list_divider_dark : R.color.markers_top_bar_background));
|
||||
itemViewHolder.title.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_white));
|
||||
itemViewHolder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_divider_color));
|
||||
itemViewHolder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.marker_circle_background_on_map_with_inset));
|
||||
itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getIcon(markerInHistory ? R.drawable.ic_action_reset_to_default_dark : R.drawable.ic_action_marker_passed, R.color.color_white));
|
||||
itemViewHolder.description.setTextColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_color));
|
||||
|
||||
drawableResToUpdate = R.drawable.ic_arrow_marker_diretion;
|
||||
markerImageViewToUpdate = itemViewHolder.icon;
|
||||
} else {
|
||||
itemViewHolder.iconDirection.setVisibility(View.VISIBLE);
|
||||
|
||||
itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
|
||||
itemViewHolder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.bg_color_dark : R.color.bg_color_light));
|
||||
itemViewHolder.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_white : R.color.color_black));
|
||||
itemViewHolder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.dashboard_divider_dark : R.color.dashboard_divider_light));
|
||||
itemViewHolder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.marker_circle_background_light_with_inset));
|
||||
itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(markerInHistory ? R.drawable.ic_action_reset_to_default_dark : R.drawable.ic_action_marker_passed));
|
||||
itemViewHolder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
|
||||
|
||||
drawableResToUpdate = R.drawable.ic_direction_arrow;
|
||||
markerImageViewToUpdate = itemViewHolder.iconDirection;
|
||||
}
|
||||
|
||||
itemViewHolder.title.setText(marker.getName(app));
|
||||
|
||||
itemViewHolder.description.setText(app.getString(R.string.passed, new SimpleDateFormat("MMM dd", Locale.getDefault()).format(new Date(marker.visitedDate))));
|
||||
if (markerInHistory) {
|
||||
itemViewHolder.point.setVisibility(View.VISIBLE);
|
||||
itemViewHolder.description.setVisibility(View.VISIBLE);
|
||||
itemViewHolder.description.setText(app.getString(R.string.passed, new SimpleDateFormat("MMM dd", Locale.getDefault()).format(new Date(marker.visitedDate))));
|
||||
} else {
|
||||
itemViewHolder.point.setVisibility(View.GONE);
|
||||
itemViewHolder.description.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reset_to_default_dark));
|
||||
String markerGroupName = marker.groupName;
|
||||
final MapMarkersGroup group = app.getMapMarkersHelper().getMapMarkerGroupByName(markerGroupName);
|
||||
itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// int position = itemViewHolder.getAdapterPosition();
|
||||
// if (position < 0) {
|
||||
// return;
|
||||
// }
|
||||
// app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
|
||||
// notifyItemRemoved(position);
|
||||
int position = itemViewHolder.getAdapterPosition();
|
||||
if (position < 0) {
|
||||
return;
|
||||
}
|
||||
if (markerInHistory) {
|
||||
app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
|
||||
if (group != null) {
|
||||
ShowHideHistoryButton showHideHistoryButton = group.getShowHideHistoryButton();
|
||||
if (showHideHistoryButton != null) {
|
||||
if (group.getHistoryMarkers().size() == 0) {
|
||||
items.remove(showHideHistoryButton);
|
||||
group.setShowHideHistoryButton(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
app.getMapMarkersHelper().moveMapMarkerToHistory(marker);
|
||||
if (group != null) {
|
||||
ShowHideHistoryButton showHideHistoryButton = group.getShowHideHistoryButton();
|
||||
if (showHideHistoryButton == null) {
|
||||
items.remove(marker);
|
||||
showHideHistoryButton = new ShowHideHistoryButton();
|
||||
showHideHistoryButton.setShowHistory(false);
|
||||
showHideHistoryButton.setMarkerGroup(group);
|
||||
int index = getLastDisplayItemIndexOfGroup(group);
|
||||
if (index != -1) {
|
||||
items.add(index + 1, showHideHistoryButton);
|
||||
group.setShowHideHistoryButton(showHideHistoryButton);
|
||||
}
|
||||
} else if (!showHideHistoryButton.isShowHistory()) {
|
||||
items.remove(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateShowDirectionMarkers();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
itemViewHolder.iconReorder.setVisibility(View.GONE);
|
||||
itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE);
|
||||
itemViewHolder.iconDirection.setVisibility(View.GONE);
|
||||
itemViewHolder.leftPointSpace.setVisibility(View.GONE);
|
||||
itemViewHolder.rightPointSpace.setVisibility(View.GONE);
|
||||
if (position == getItemCount() - 1) {
|
||||
itemViewHolder.bottomShadow.setVisibility(View.VISIBLE);
|
||||
boolean lastItem = position == getItemCount() - 1;
|
||||
if ((getItemCount() > position + 1 && getItemViewType(position + 1) == HEADER_TYPE) || lastItem) {
|
||||
itemViewHolder.divider.setVisibility(View.GONE);
|
||||
} else {
|
||||
itemViewHolder.bottomShadow.setVisibility(View.GONE);
|
||||
itemViewHolder.divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
itemViewHolder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
|
||||
|
||||
LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude());
|
||||
DashLocationFragment.updateLocationView(useCenter, location,
|
||||
heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0,
|
||||
itemViewHolder.distance, markerLatLon,
|
||||
screenOrientation, app, mapActivity, true);
|
||||
} else if (holder instanceof MapMarkerHeaderViewHolder) {
|
||||
final MapMarkerHeaderViewHolder dateViewHolder = (MapMarkerHeaderViewHolder) holder;
|
||||
final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder;
|
||||
final Object header = getItem(position);
|
||||
String headerString;
|
||||
if (header instanceof Integer) {
|
||||
headerViewHolder.icon.setVisibility(View.GONE);
|
||||
headerViewHolder.iconSpace.setVisibility(View.VISIBLE);
|
||||
Integer dateHeader = (Integer) header;
|
||||
if (dateHeader == TODAY_HEADER) {
|
||||
headerString = app.getString(R.string.today);
|
||||
|
@ -183,35 +290,77 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
} else {
|
||||
headerString = String.valueOf(dateHeader);
|
||||
}
|
||||
} else if (header instanceof String) {
|
||||
headerString = (String) header;
|
||||
headerViewHolder.disableGroupSwitch.setVisibility(View.GONE);
|
||||
} else if (header instanceof GroupHeader) {
|
||||
final GroupHeader groupHeader = (GroupHeader) header;
|
||||
String groupName = groupHeader.getGroup().getName();
|
||||
if (groupName.equals("")) {
|
||||
groupName = app.getString(R.string.shared_string_favorites);
|
||||
}
|
||||
headerString = groupName + " \u2014 "
|
||||
+ groupHeader.getGroup().getActiveMarkers().size()
|
||||
+ "/" + groupHeader.getGroup().getMarkers().size();
|
||||
headerViewHolder.icon.setVisibility(View.VISIBLE);
|
||||
headerViewHolder.iconSpace.setVisibility(View.GONE);
|
||||
headerViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes(), R.color.divider_color));
|
||||
boolean groupIsDisabled = groupHeader.getGroup().isDisabled();
|
||||
headerViewHolder.disableGroupSwitch.setChecked(!groupIsDisabled);
|
||||
headerViewHolder.disableGroupSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
groupHeader.getGroup().setDisabled(!b);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported header");
|
||||
}
|
||||
dateViewHolder.date.setText(headerString);
|
||||
headerViewHolder.title.setText(headerString);
|
||||
} else if (holder instanceof MapMarkersShowHideHistoryViewHolder) {
|
||||
final MapMarkersShowHideHistoryViewHolder showHideHistoryViewHolder = (MapMarkersShowHideHistoryViewHolder) holder;
|
||||
final ShowHideHistoryButton showHideHistoryButton = (ShowHideHistoryButton) getItem(position);
|
||||
final boolean showHistory = showHideHistoryButton.isShowHistory();
|
||||
showHideHistoryViewHolder.title.setText(app.getString(showHistory ? R.string.hide_passed : R.string.show_passed));
|
||||
showHideHistoryViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
List<MapMarker> historyMarkers = showHideHistoryButton.getMapMarkerGroup().getHistoryMarkers();
|
||||
int pos = holder.getAdapterPosition();
|
||||
if (showHistory) {
|
||||
showHideHistoryButton.setShowHistory(false);
|
||||
items.removeAll(historyMarkers);
|
||||
} else {
|
||||
showHideHistoryButton.setShowHistory(true);
|
||||
items.addAll(pos, historyMarkers);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
Object item = items.get(position);
|
||||
if (item instanceof MapMarker) {
|
||||
return MARKER_TYPE;
|
||||
} else if (item instanceof String || item instanceof Integer) {
|
||||
} else if (item instanceof GroupHeader || item instanceof Integer) {
|
||||
return HEADER_TYPE;
|
||||
} else if (item instanceof ShowHideHistoryButton) {
|
||||
return SHOW_HIDE_HISTORY_TYPE;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported view type");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
public Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
public Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
|
||||
private String getMonth(int month) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("LLLL", Locale.getDefault());
|
||||
|
@ -219,4 +368,22 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
date.setMonth(month);
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
private int getLastDisplayItemIndexOfGroup(MapMarkersGroup group) {
|
||||
List<MapMarker> markers = group.getActiveMarkers();
|
||||
int index = -1;
|
||||
for (MapMarker marker : markers) {
|
||||
int markerIndex = items.indexOf(marker);
|
||||
if (markerIndex > index) {
|
||||
index = markerIndex;
|
||||
}
|
||||
}
|
||||
if (index == -1) {
|
||||
GroupHeader header = group.getGroupHeader();
|
||||
if (header != null) {
|
||||
index = items.indexOf(group.getGroupHeader());
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,8 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||
} else {
|
||||
dateString = String.valueOf(dateHeader);
|
||||
}
|
||||
dateViewHolder.date.setText(dateString);
|
||||
dateViewHolder.disableGroupSwitch.setVisibility(View.GONE);
|
||||
dateViewHolder.title.setText(dateString);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package net.osmand.plus.mapmarkers.adapters;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
public class MapMarkersShowHideHistoryViewHolder extends RecyclerView.ViewHolder {
|
||||
final TextView title;
|
||||
|
||||
public MapMarkersShowHideHistoryViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
title = (TextView) itemView.findViewById(R.id.show_hide_history_title);
|
||||
}
|
||||
}
|
|
@ -69,6 +69,7 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -90,7 +91,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
final private PointGPXAdapter adapter = new PointGPXAdapter();
|
||||
private GpxDisplayItemType[] filterTypes = { GpxDisplayItemType.TRACK_POINTS, GpxDisplayItemType.TRACK_ROUTE_POINTS };
|
||||
private boolean selectionMode = false;
|
||||
private Set<GpxDisplayItem> selectedItems = new LinkedHashSet<>();
|
||||
private LinkedHashMap<GpxDisplayItemType, Set<GpxDisplayItem>> selectedItems = new LinkedHashMap<>();
|
||||
private Set<Integer> selectedGroups = new LinkedHashSet<>();
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
|
@ -213,6 +214,26 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
private int getSelectedItemsCount() {
|
||||
int count = 0;
|
||||
for (Set<GpxDisplayItem> set : selectedItems.values()) {
|
||||
if (set != null) {
|
||||
count += set.size();
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private Set<GpxDisplayItem> getSelectedItems() {
|
||||
Set<GpxDisplayItem> result = new LinkedHashSet<>();
|
||||
for (Set<GpxDisplayItem> set : selectedItems.values()) {
|
||||
if (set != null) {
|
||||
result.addAll(set);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addPoint(PointDescription pointDescription) {
|
||||
getTrackActivity().addPoint(pointDescription);
|
||||
}
|
||||
|
@ -488,9 +509,10 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
private void deleteItemsAction() {
|
||||
if (selectedItems.size() > 0) {
|
||||
int size = getSelectedItemsCount();
|
||||
if (size > 0) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
||||
b.setMessage(getString(R.string.points_delete_multiple, selectedItems.size()));
|
||||
b.setMessage(getString(R.string.points_delete_multiple, size));
|
||||
b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -524,7 +546,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
GPXFile gpx = getGpx();
|
||||
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
||||
if (gpx != null) {
|
||||
for (GpxDisplayItem item : selectedItems) {
|
||||
for (GpxDisplayItem item : getSelectedItems()) {
|
||||
if (gpx.showCurrentTrack) {
|
||||
savingTrackHelper.deletePointData(item.locationStart);
|
||||
} else {
|
||||
|
@ -606,26 +628,32 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
private void selectMapMarkersImpl() {
|
||||
if (!selectedItems.isEmpty()) {
|
||||
if (getSelectedItemsCount() > 0) {
|
||||
if (getSettings().USE_MAP_MARKERS.get()) {
|
||||
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||
List<LatLon> points = new ArrayList<>();
|
||||
List<PointDescription> names = new ArrayList<>();
|
||||
for(GpxDisplayItem i : selectedItems) {
|
||||
if (i.locationStart != null) {
|
||||
points.add(new LatLon(i.locationStart.lat, i.locationStart.lon));
|
||||
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, i.name));
|
||||
List<LatLon> points = new LinkedList<>();
|
||||
List<PointDescription> names = new LinkedList<>();
|
||||
for (Map.Entry<GpxDisplayItemType, Set<GpxDisplayItem>> entry : selectedItems.entrySet()) {
|
||||
if (entry.getKey() == GpxDisplayItemType.TRACK_POINTS) {
|
||||
File gpx = getGpxDataItem().getFile();
|
||||
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
|
||||
markersHelper.addMarkersSyncGroup(syncGroup);
|
||||
markersHelper.syncGroup(syncGroup);
|
||||
} else {
|
||||
for (GpxDisplayItem i : entry.getValue()) {
|
||||
if (i.locationStart != null) {
|
||||
points.add(new LatLon(i.locationStart.lat, i.locationStart.lon));
|
||||
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, i.name));
|
||||
}
|
||||
}
|
||||
markersHelper.addMapMarkers(points, names, null);
|
||||
}
|
||||
}
|
||||
File gpx = getGpxDataItem().getFile();
|
||||
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(),
|
||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
|
||||
markersHelper.addMarkersSyncGroup(syncGroup);
|
||||
markersHelper.addMapMarkers(points, names, syncGroup);
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
} else {
|
||||
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
|
||||
for (GpxDisplayItem i : selectedItems) {
|
||||
for (GpxDisplayItem i : getSelectedItems()) {
|
||||
if (i.locationStart != null) {
|
||||
targetPointsHelper.navigateToPoint(new LatLon(i.locationStart.lat, i.locationStart.lon), false,
|
||||
targetPointsHelper.getIntermediatePoints().size() + 1,
|
||||
|
@ -679,10 +707,10 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
private void selectFavoritesImpl() {
|
||||
if (!selectedItems.isEmpty()) {
|
||||
if (getSelectedItemsCount() > 0) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(getTrackActivity());
|
||||
final EditText editText = new EditText(getTrackActivity());
|
||||
String name = selectedItems.iterator().next().group.getName();
|
||||
String name = getSelectedItems().iterator().next().group.getName();
|
||||
if(name.indexOf('\n') > 0) {
|
||||
name = name.substring(0, name.indexOf('\n'));
|
||||
}
|
||||
|
@ -700,7 +728,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
actionMode.finish();
|
||||
}
|
||||
FavouritesDbHelper fdb = app.getFavorites();
|
||||
for(GpxDisplayItem i : selectedItems) {
|
||||
for(GpxDisplayItem i : getSelectedItems()) {
|
||||
if (i.locationStart != null) {
|
||||
FavouritePoint fp = new FavouritePoint(i.locationStart.lat, i.locationStart.lon, i.name, editText.getText().toString());
|
||||
if (!Algorithms.isEmpty(i.description)) {
|
||||
|
@ -719,8 +747,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
private void updateSelectionMode(ActionMode m) {
|
||||
if (selectedItems.size() > 0) {
|
||||
m.setTitle(selectedItems.size() + " " + getMyApplication().getString(R.string.shared_string_selected_lowercase));
|
||||
int size = getSelectedItemsCount();
|
||||
if (size > 0) {
|
||||
m.setTitle(size + " " + getMyApplication().getString(R.string.shared_string_selected_lowercase));
|
||||
} else {
|
||||
m.setTitle("");
|
||||
}
|
||||
|
@ -733,9 +762,19 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
|
||||
ch.setChecked(!ch.isChecked());
|
||||
if (ch.isChecked()) {
|
||||
selectedItems.add(item);
|
||||
Set<GpxDisplayItem> set = selectedItems.get(item.group.getType());
|
||||
if (set != null) {
|
||||
set.add(item);
|
||||
} else {
|
||||
set = new LinkedHashSet<>();
|
||||
set.add(item);
|
||||
selectedItems.put(item.group.getType(), set);
|
||||
}
|
||||
} else {
|
||||
selectedItems.remove(item);
|
||||
Set<GpxDisplayItem> set = selectedItems.get(item.group.getType());
|
||||
if (set != null) {
|
||||
set.remove(item);
|
||||
}
|
||||
}
|
||||
updateSelectionMode(actionMode);
|
||||
} else {
|
||||
|
@ -876,13 +915,17 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
if (ch.isChecked()) {
|
||||
selectedGroups.add(groupPosition);
|
||||
if (items != null) {
|
||||
selectedItems.addAll(items);
|
||||
Set<GpxDisplayItem> set = selectedItems.get(group.getType());
|
||||
if (set != null) {
|
||||
set.addAll(items);
|
||||
} else {
|
||||
set = new LinkedHashSet<>(items);
|
||||
selectedItems.put(group.getType(), set);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedGroups.remove(groupPosition);
|
||||
if (items != null) {
|
||||
selectedItems.removeAll(items);
|
||||
}
|
||||
selectedItems.remove(group.getType());
|
||||
}
|
||||
adapter.notifyDataSetInvalidated();
|
||||
updateSelectionMode(actionMode);
|
||||
|
@ -979,7 +1022,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||
if (selectionMode) {
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
ch.setChecked(selectedItems.contains(gpxItem));
|
||||
ch.setChecked(selectedItems.get(gpxItem.group.getType()) != null && selectedItems.get(gpxItem.group.getType()).contains(gpxItem));
|
||||
row.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
options.setVisibility(View.GONE);
|
||||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -987,9 +1030,19 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (ch.isChecked()) {
|
||||
selectedItems.add(gpxItem);
|
||||
Set<GpxDisplayItem> set = selectedItems.get(gpxItem.group.getType());
|
||||
if (set != null) {
|
||||
set.add(gpxItem);
|
||||
} else {
|
||||
set = new LinkedHashSet<>();
|
||||
set.add(gpxItem);
|
||||
selectedItems.put(gpxItem.group.getType(), set);
|
||||
}
|
||||
} else {
|
||||
selectedItems.remove(gpxItem);
|
||||
Set<GpxDisplayItem> set = selectedItems.get(gpxItem.group.getType());
|
||||
if (set != null) {
|
||||
set.remove(gpxItem);
|
||||
}
|
||||
}
|
||||
updateSelectionMode(actionMode);
|
||||
}
|
||||
|
|
|
@ -1519,7 +1519,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
results.add(object);
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -358,6 +358,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
group.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout timeLayout = (LinearLayout) view.findViewById(R.id.time_layout);
|
||||
TextView timeText = (TextView) view.findViewById(R.id.time);
|
||||
ImageView timeIcon = (ImageView) view.findViewById(R.id.time_icon);
|
||||
if (listItem.getSearchResult().object instanceof Amenity
|
||||
|
@ -372,19 +373,16 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
|
|||
boolean worksLater = rs.isOpenedForTime(inst);
|
||||
int colorId = worksNow ? worksLater ? R.color.color_ok : R.color.color_intermediate : R.color.color_warning;
|
||||
|
||||
timeIcon.setVisibility(View.VISIBLE);
|
||||
timeText.setVisibility(View.VISIBLE);
|
||||
timeLayout.setVisibility(View.VISIBLE);
|
||||
timeIcon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_small_time, colorId));
|
||||
timeText.setTextColor(app.getResources().getColor(colorId));
|
||||
String rt = rs.getCurrentRuleTime(inst);
|
||||
timeText.setText(rt == null ? "" : rt);
|
||||
} else {
|
||||
timeIcon.setVisibility(View.GONE);
|
||||
timeText.setVisibility(View.GONE);
|
||||
timeLayout.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
timeIcon.setVisibility(View.GONE);
|
||||
timeText.setVisibility(View.GONE);
|
||||
timeLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
updateCompassVisibility(view, listItem);
|
||||
|
|
|
@ -797,7 +797,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) {
|
||||
Location lastKnownLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
boolean enabled = lastKnownLocation != null && !isLocationOutdated(lastKnownLocation);
|
||||
boolean enabled = lastKnownLocation != null;
|
||||
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
|
||||
if (!enabled) {
|
||||
|
|
|
@ -8,13 +8,9 @@ import android.graphics.Path;
|
|||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -23,7 +19,6 @@ import net.osmand.data.QuadPoint;
|
|||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
|
@ -36,11 +31,12 @@ import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvider,
|
||||
IContextMenuProviderSelection, ContextMenuLayer.IMoveObjectProvider {
|
||||
|
||||
protected static final int DIST_TO_SHOW = 80;
|
||||
protected static final long USE_FINGER_LOCATION_DELAY = 1000;
|
||||
private static final int MAP_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 6;
|
||||
|
||||
private final MapActivity map;
|
||||
private OsmandMapTileView view;
|
||||
|
@ -66,16 +62,14 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
private Bitmap arrowToDestination;
|
||||
private float[] calculations = new float[2];
|
||||
|
||||
private final RenderingLineAttributes lineAttrs = new RenderingLineAttributes("measureDistanceLine");
|
||||
private Paint paint;
|
||||
private Path path;
|
||||
private List<LatLon> route = new ArrayList<>();
|
||||
|
||||
private LatLon fingerLocation;
|
||||
private boolean hasMoved;
|
||||
private boolean moving;
|
||||
private boolean useFingerLocation;
|
||||
private GestureDetector longTapDetector;
|
||||
private Handler handler;
|
||||
private TIntArrayList tx = new TIntArrayList();
|
||||
private TIntArrayList ty = new TIntArrayList();
|
||||
private Path linePath = new Path();
|
||||
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
|
||||
|
@ -190,50 +184,23 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
@Override
|
||||
public void initLayer(OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
handler = new Handler();
|
||||
initUI();
|
||||
longTapDetector = new GestureDetector(view.getContext(), new GestureDetector.OnGestureListener() {
|
||||
@Override
|
||||
public boolean onDown(MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowPress(MotionEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
cancelFingerAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
|
||||
widgetsFactory.updateInfo(useFingerLocation ? fingerLocation : null, tileBox.getZoom());
|
||||
Location myLoc = map.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
|
||||
widgetsFactory.updateInfo(myLoc == null
|
||||
? tileBox.getCenterLatLon() : new LatLon(myLoc.getLatitude(), myLoc.getLongitude()), tileBox.getZoom());
|
||||
OsmandSettings settings = map.getMyApplication().getSettings();
|
||||
|
||||
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) {
|
||||
if (tileBox.getZoom() < 3 || !settings.USE_MAP_MARKERS.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
lineAttrs.updatePaints(view, nightMode, tileBox);
|
||||
|
||||
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
|
||||
if (route.size() > 0) {
|
||||
path.reset();
|
||||
|
@ -259,6 +226,30 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
|
||||
List<MapMarker> activeMapMarkers = markersHelper.getMapMarkers();
|
||||
|
||||
if (settings.SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) {
|
||||
int locX = tileBox.getPixXFromLonNoRot(myLoc.getLongitude());
|
||||
int locY = tileBox.getPixYFromLatNoRot(myLoc.getLatitude());
|
||||
int[] colors = MapMarker.getColors(map);
|
||||
for (int i = 0; i < activeMapMarkers.size() && i < 2; i++) {
|
||||
MapMarker marker = activeMapMarkers.get(i);
|
||||
int markerX = tileBox.getPixXFromLonNoRot(marker.getLongitude());
|
||||
int markerY = tileBox.getPixYFromLatNoRot(marker.getLatitude());
|
||||
linePath.reset();
|
||||
tx.clear();
|
||||
ty.clear();
|
||||
linePath.moveTo(locX, locY);
|
||||
linePath.lineTo(markerX, markerY);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
tx.add(markerX);
|
||||
ty.add(markerY);
|
||||
calculatePath(tileBox, tx, ty, linePath);
|
||||
lineAttrs.paint.setColor(colors[marker.colorIndex]);
|
||||
canvas.drawPath(linePath, lineAttrs.paint);
|
||||
}
|
||||
}
|
||||
|
||||
for (MapMarker marker : activeMapMarkers) {
|
||||
if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker)
|
||||
&& !isInMotion(marker)) {
|
||||
|
@ -273,34 +264,26 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
}
|
||||
|
||||
boolean show = useFingerLocation ||
|
||||
(map.getMyApplication().getSettings().MAP_MARKERS_MODE.get() == OsmandSettings.MapMarkersMode.WIDGETS
|
||||
&& map.getMyApplication().getSettings().SHOW_DESTINATION_ARROW.get());
|
||||
if (show) {
|
||||
LatLon loc = fingerLocation;
|
||||
if (!useFingerLocation) {
|
||||
loc = tileBox.getCenterLatLon();
|
||||
}
|
||||
if (loc != null) {
|
||||
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
|
||||
int i = 0;
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
|
||||
canvas.save();
|
||||
net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(),
|
||||
marker.getLatitude(), marker.getLongitude(), calculations);
|
||||
float bearing = calculations[1] - 90;
|
||||
float radiusBearing = DIST_TO_SHOW * tileBox.getDensity();
|
||||
final QuadPoint cp = tileBox.getCenterPixelPoint();
|
||||
canvas.rotate(bearing, cp.x, cp.y);
|
||||
canvas.translate(-24 * tileBox.getDensity() + radiusBearing, -22 * tileBox.getDensity());
|
||||
canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
|
||||
canvas.restore();
|
||||
}
|
||||
i++;
|
||||
if (i > 1) {
|
||||
break;
|
||||
}
|
||||
if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
|
||||
LatLon loc = tileBox.getCenterLatLon();
|
||||
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
|
||||
int i = 0;
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
|
||||
canvas.save();
|
||||
net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(),
|
||||
marker.getLatitude(), marker.getLongitude(), calculations);
|
||||
float bearing = calculations[1] - 90;
|
||||
float radiusBearing = DIST_TO_SHOW * tileBox.getDensity();
|
||||
final QuadPoint cp = tileBox.getCenterPixelPoint();
|
||||
canvas.rotate(bearing, cp.x, cp.y);
|
||||
canvas.translate(-24 * tileBox.getDensity() + radiusBearing, -22 * tileBox.getDensity());
|
||||
canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
|
||||
canvas.restore();
|
||||
}
|
||||
i++;
|
||||
if (i > 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -354,57 +337,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
public void destroyLayer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
|
||||
if (!longTapDetector.onTouchEvent(event)) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
fingerLocation = tileBox.getLatLonFromPixel(x, y);
|
||||
hasMoved = false;
|
||||
moving = true;
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (!hasMoved) {
|
||||
if (!handler.hasMessages(MAP_REFRESH_MESSAGE)) {
|
||||
Message msg = Message.obtain(handler, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handler.removeMessages(MAP_REFRESH_MESSAGE);
|
||||
if (moving) {
|
||||
if (!useFingerLocation) {
|
||||
useFingerLocation = true;
|
||||
map.refreshMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
msg.what = MAP_REFRESH_MESSAGE;
|
||||
handler.sendMessageDelayed(msg, USE_FINGER_LOCATION_DELAY);
|
||||
}
|
||||
hasMoved = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
cancelFingerAction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(event, tileBox);
|
||||
}
|
||||
|
||||
private void cancelFingerAction() {
|
||||
handler.removeMessages(MAP_REFRESH_MESSAGE);
|
||||
useFingerLocation = false;
|
||||
moving = false;
|
||||
fingerLocation = null;
|
||||
map.refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawInScreenPixels() {
|
||||
return false;
|
||||
|
|
|
@ -16,13 +16,11 @@ import android.os.Build;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.render.OsmandRenderer;
|
||||
|
@ -40,8 +38,6 @@ import gnu.trove.list.array.TIntArrayList;
|
|||
|
||||
public abstract class OsmandMapLayer {
|
||||
|
||||
protected static final int UPDATES_BEFORE_CHECK_LOCATION = 40;
|
||||
|
||||
protected List<LatLon> fullObjectsLatLon;
|
||||
protected List<LatLon> smallObjectsLatLon;
|
||||
|
||||
|
@ -51,22 +47,6 @@ public abstract class OsmandMapLayer {
|
|||
TWO_POINTERS_ZOOM_OUT
|
||||
}
|
||||
|
||||
private int updatesCounter;
|
||||
private boolean locationOutdated;
|
||||
|
||||
boolean isLocationOutdated(Location location) {
|
||||
if (location != null && updatesCounter == 0) {
|
||||
locationOutdated = System.currentTimeMillis() - location.getTime() >
|
||||
OsmAndLocationProvider.STALE_LOCATION_TIMEOUT_FOR_ICON;
|
||||
}
|
||||
if (updatesCounter == UPDATES_BEFORE_CHECK_LOCATION) {
|
||||
updatesCounter = 0;
|
||||
} else {
|
||||
updatesCounter++;
|
||||
}
|
||||
return locationOutdated;
|
||||
}
|
||||
|
||||
public boolean isMapGestureAllowed(MapGestureType type) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
aroundArea.setAntiAlias(true);
|
||||
|
||||
locationProvider = view.getApplication().getLocationProvider();
|
||||
updateIcons(view.getSettings().getApplicationMode(), false,
|
||||
isLocationOutdated(locationProvider.getLastKnownLocation()));
|
||||
updateIcons(view.getSettings().getApplicationMode(), false, locationProvider.getLastKnownLocation() == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,9 +85,9 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
}
|
||||
// draw
|
||||
boolean nm = nightMode != null && nightMode.isNightMode();
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
Location lastKnownLocation = locationProvider.getLastStaleKnownLocation();
|
||||
updateIcons(view.getSettings().getApplicationMode(), nm,
|
||||
isLocationOutdated(lastKnownLocation));
|
||||
view.getApplication().getLocationProvider().getLastKnownLocation() == null);
|
||||
if(lastKnownLocation == null || view == null){
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue