Added compass arrows. Fix bugs
This commit is contained in:
parent
ac4d6b16a4
commit
a8de5408b0
9 changed files with 519 additions and 180 deletions
124
OsmAnd/res/layout/map_marker_item.xml
Normal file
124
OsmAnd/res/layout/map_marker_item.xml
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/view_transparent_selection"
|
||||
android:id="@+id/package_delivered_layout"
|
||||
android:minHeight="50dp"
|
||||
android:descendantFocusability="blocksDescendants">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/waypoint_icon"
|
||||
android:src="@drawable/ic_action_fav_dark"
|
||||
android:layout_height="25dp"
|
||||
android:layout_width="56dp"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/waypoint_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/direction"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="4dp"
|
||||
android:src="@drawable/ic_destination_arrow_white"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/waypoint_dist"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:textColor="@color/color_myloc_distance"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/waypoint_deviation"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:textColor="@color/secondary_text_dark"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:drawablePadding="2dp"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/waypoint_desc_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:textColor="@color/secondary_text_dark"
|
||||
android:textSize="@dimen/default_sub_text_size" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/all_points"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_more"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"
|
||||
android:visibility="gone"
|
||||
android:focusable="false"
|
||||
android:scaleType="center"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:src="@drawable/map_overflow_menu_white" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/info_close"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:focusable="false"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_remove_dark" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/info_move"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_flat_list_dark"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,6 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<color name="marker_blue">#2196f3</color>
|
||||
<color name="marker_green">#73b825</color>
|
||||
<color name="marker_orange">#ff9800</color>
|
||||
<color name="marker_red">#e53935</color>
|
||||
<color name="marker_lt_green">#d7eb23</color>
|
||||
|
||||
<color name="popup_bg_color">#EE666666</color>
|
||||
<color name="popup_separator_color">#BBBBBB</color>
|
||||
<color name="popup_text_color">#FFFFFF</color>
|
||||
|
|
|
@ -2,14 +2,9 @@ package net.osmand.plus;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GeocodingLookupService;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -21,9 +16,14 @@ public class MapMarkersHelper {
|
|||
private List<MapMarker> mapMarkers = new ArrayList<>();
|
||||
private List<MapMarker> mapMarkersHistory = new ArrayList<>();
|
||||
private OsmandSettings settings;
|
||||
private List<StateChangedListener<Void>> listeners = new ArrayList<StateChangedListener<Void>>();
|
||||
private List<MapMarkerChangedListener> listeners = new ArrayList<>();
|
||||
private OsmandApplication ctx;
|
||||
|
||||
public interface MapMarkerChangedListener {
|
||||
void onMapMarkerChanged(MapMarker mapMarker);
|
||||
void onMapMarkersChanged();
|
||||
}
|
||||
|
||||
public static class MapMarker implements LocationPoint {
|
||||
public LatLon point;
|
||||
private PointDescription pointDescription;
|
||||
|
@ -112,7 +112,11 @@ public class MapMarkersHelper {
|
|||
GeocodingLookupService.AddressLookupRequest lookupRequest = new GeocodingLookupService.AddressLookupRequest(mapMarker.point, new GeocodingLookupService.OnAddressLookupResult() {
|
||||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
mapMarker.pointDescription.setName(address);
|
||||
if (Algorithms.isEmpty(address)) {
|
||||
mapMarker.pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx));
|
||||
} else {
|
||||
mapMarker.pointDescription.setName(address);
|
||||
}
|
||||
if (history) {
|
||||
settings.updateMapMarkerHistory(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
|
||||
mapMarker.pointDescription, mapMarker.colorIndex);
|
||||
|
@ -120,7 +124,7 @@ public class MapMarkersHelper {
|
|||
settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(),
|
||||
mapMarker.pointDescription, mapMarker.colorIndex);
|
||||
}
|
||||
refresh();
|
||||
updateMarker(mapMarker);
|
||||
}
|
||||
}, null);
|
||||
ctx.getGeocodingLookupService().lookupAddress(lookupRequest);
|
||||
|
@ -260,18 +264,30 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void addListener(StateChangedListener<Void> l) {
|
||||
listeners.add(l);
|
||||
public void addListener(MapMarkerChangedListener l) {
|
||||
if (!listeners.contains(l)) {
|
||||
listeners.add(l);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateListeners() {
|
||||
for (StateChangedListener<Void> l : listeners) {
|
||||
l.stateChanged(null);
|
||||
public void removeListener(MapMarkerChangedListener l) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
|
||||
private void updateMarker(MapMarker marker) {
|
||||
for (MapMarkerChangedListener l : listeners) {
|
||||
l.onMapMarkerChanged(marker);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMarkers() {
|
||||
for (MapMarkerChangedListener l : listeners) {
|
||||
l.onMapMarkersChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
updateListeners();
|
||||
updateMarkers();
|
||||
}
|
||||
|
||||
private void cancelAddressRequests() {
|
||||
|
|
|
@ -110,7 +110,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
public void addMapMarker(double latitude, double longitude, PointDescription pd) {
|
||||
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
||||
markersHelper.addMapMarker(new LatLon(latitude, longitude), pd);
|
||||
//openMapMarkersActivity();
|
||||
}
|
||||
|
||||
public void editWaypoints() {
|
||||
|
|
|
@ -8,6 +8,8 @@ import net.osmand.StateChangedListener;
|
|||
import net.osmand.ValueHolder;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.map.IMapLocationListener;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
import net.osmand.plus.OsmAndConstants;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
|
@ -17,10 +19,8 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
|
@ -29,7 +29,8 @@ import net.osmand.util.MapUtils;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, IRouteInformationListener {
|
||||
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
|
||||
OsmAndCompassListener, IRouteInformationListener, MapMarkerChangedListener {
|
||||
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
||||
|
||||
private long lastTimeAutoZooming = 0;
|
||||
|
@ -70,15 +71,18 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
}
|
||||
|
||||
private void addMapMarkersListener(OsmandApplication app) {
|
||||
app.getMapMarkersHelper().addListener(new StateChangedListener<Void>() {
|
||||
app.getMapMarkersHelper().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(Void change) {
|
||||
if(mapView != null) {
|
||||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onMapMarkerChanged(MapMarkersHelper.MapMarker mapMarker) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapMarkersChanged() {
|
||||
if (mapView != null) {
|
||||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMapView(OsmandMapTileView mapView) {
|
||||
|
|
|
@ -43,6 +43,7 @@ import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
|||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -87,7 +88,7 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
|||
/**
|
||||
*/
|
||||
public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicListViewCallbacks,
|
||||
IRouteInformationListener, WaypointDialogHelperCallbacks {
|
||||
IRouteInformationListener, WaypointDialogHelperCallbacks, MapMarkerChangedListener {
|
||||
private static final org.apache.commons.logging.Log LOG =
|
||||
PlatformUtil.getLog(DashboardOnMap.class);
|
||||
private static final String TAG = "DashboardOnMap";
|
||||
|
@ -210,128 +211,128 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
// by default they handle touches for their list items... i.e. they're in charge of drawing
|
||||
// the pressed state (the list selector), handling list item clicks, etc.
|
||||
swipeDismissListener = new SwipeDismissListViewTouchListener(
|
||||
listView,
|
||||
new DismissCallbacks() {
|
||||
listView,
|
||||
new DismissCallbacks() {
|
||||
|
||||
private List<Object> deletedMarkers = new ArrayList<>();
|
||||
private List<Object> deletedMarkers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean canDismiss(int position) {
|
||||
boolean res = false;
|
||||
if (listAdapter instanceof StableArrayAdapter) {
|
||||
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
|
||||
Object obj = listAdapter.getItem(position);
|
||||
res = activeObjects.contains(obj);
|
||||
@Override
|
||||
public boolean canDismiss(int position) {
|
||||
boolean res = false;
|
||||
if (listAdapter instanceof StableArrayAdapter) {
|
||||
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
|
||||
Object obj = listAdapter.getItem(position);
|
||||
res = activeObjects.contains(obj);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Undoable onDismiss(final int position) {
|
||||
final Object item;
|
||||
final StableArrayAdapter stableAdapter;
|
||||
final int activeObjPos;
|
||||
if (listAdapter instanceof StableArrayAdapter) {
|
||||
stableAdapter = (StableArrayAdapter) listAdapter;
|
||||
item = stableAdapter.getItem(position);
|
||||
|
||||
if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
if (!((MapMarker) item).history) {
|
||||
deletedMarkers.add(item);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
stableAdapter.setNotifyOnChange(false);
|
||||
stableAdapter.remove(item);
|
||||
stableAdapter.getObjects().remove(item);
|
||||
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
|
||||
stableAdapter.getActiveObjects().remove(item);
|
||||
stableAdapter.refreshData();
|
||||
stableAdapter.notifyDataSetChanged();
|
||||
|
||||
} else {
|
||||
item = null;
|
||||
stableAdapter = null;
|
||||
activeObjPos = 0;
|
||||
}
|
||||
return new Undoable() {
|
||||
@Override
|
||||
public Undoable onDismiss(final int position) {
|
||||
final Object item;
|
||||
final StableArrayAdapter stableAdapter;
|
||||
final int activeObjPos;
|
||||
if (listAdapter instanceof StableArrayAdapter) {
|
||||
stableAdapter = (StableArrayAdapter) listAdapter;
|
||||
item = stableAdapter.getItem(position);
|
||||
|
||||
if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
if (!((MapMarker) item).history) {
|
||||
deletedMarkers.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
if (item != null) {
|
||||
stableAdapter.setNotifyOnChange(false);
|
||||
stableAdapter.remove(item);
|
||||
stableAdapter.getObjects().remove(item);
|
||||
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
|
||||
stableAdapter.getActiveObjects().remove(item);
|
||||
stableAdapter.refreshData();
|
||||
stableAdapter.notifyDataSetChanged();
|
||||
|
||||
} else {
|
||||
item = null;
|
||||
stableAdapter = null;
|
||||
activeObjPos = 0;
|
||||
}
|
||||
return new Undoable() {
|
||||
@Override
|
||||
public void undo() {
|
||||
if (item != null) {
|
||||
stableAdapter.setNotifyOnChange(false);
|
||||
stableAdapter.insert(item, position);
|
||||
stableAdapter.getObjects().add(position, item);
|
||||
stableAdapter.getActiveObjects().add(activeObjPos, item);
|
||||
stableAdapter.refreshData();
|
||||
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
|
||||
onItemsSwapped(stableAdapter.getActiveObjects());
|
||||
} else if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
deletedMarkers.remove(item);
|
||||
updateMapMarkers(stableAdapter.getActiveObjects());
|
||||
reloadAdapter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
if ((visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT)
|
||||
&& (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
|
||||
&& item != null
|
||||
&& stableAdapter.getActiveObjects().size() == 0) {
|
||||
return mapActivity.getResources().getString(R.string.cancel_navigation);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidePopup() {
|
||||
if (listAdapter instanceof StableArrayAdapter) {
|
||||
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
|
||||
stableAdapter.insert(item, position);
|
||||
stableAdapter.getObjects().add(position, item);
|
||||
stableAdapter.getActiveObjects().add(activeObjPos, item);
|
||||
stableAdapter.refreshData();
|
||||
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
|
||||
onItemsSwapped(stableAdapter.getActiveObjects());
|
||||
} else if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
deletedMarkers.remove(item);
|
||||
updateMapMarkers(stableAdapter.getActiveObjects());
|
||||
}
|
||||
if (stableAdapter.getActiveObjects().size() == 0) {
|
||||
hideDashboard();
|
||||
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
|
||||
}
|
||||
} else {
|
||||
if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
reloadAdapter();
|
||||
}
|
||||
reloadAdapter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMapMarkers(List<Object> objects) {
|
||||
List<MapMarker> markers = new ArrayList<>();
|
||||
List<MapMarker> markersHistory = new ArrayList<>();
|
||||
|
||||
for (Object obj : objects) {
|
||||
MapMarker marker = (MapMarker) obj;
|
||||
if (!marker.history) {
|
||||
markers.add(marker);
|
||||
} else {
|
||||
markersHistory.add(marker);
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
if ((visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT)
|
||||
&& (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
|
||||
&& item != null
|
||||
&& stableAdapter.getActiveObjects().size() == 0) {
|
||||
return mapActivity.getResources().getString(R.string.cancel_navigation);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = deletedMarkers.size() - 1; i >= 0; i--) {
|
||||
markersHistory.add(0, (MapMarker) deletedMarkers.get(i));
|
||||
}
|
||||
deletedMarkers.clear();
|
||||
|
||||
getMyApplication().getMapMarkersHelper().saveMapMarkers(markers, markersHistory);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidePopup() {
|
||||
if (listAdapter instanceof StableArrayAdapter) {
|
||||
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
|
||||
stableAdapter.refreshData();
|
||||
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
|
||||
onItemsSwapped(stableAdapter.getActiveObjects());
|
||||
} else if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
updateMapMarkers(stableAdapter.getActiveObjects());
|
||||
}
|
||||
if (stableAdapter.getActiveObjects().size() == 0) {
|
||||
hideDashboard();
|
||||
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
|
||||
}
|
||||
} else {
|
||||
if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
reloadAdapter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMapMarkers(List<Object> objects) {
|
||||
List<MapMarker> markers = new ArrayList<>();
|
||||
List<MapMarker> markersHistory = new ArrayList<>();
|
||||
|
||||
for (Object obj : objects) {
|
||||
MapMarker marker = (MapMarker) obj;
|
||||
if (!marker.history) {
|
||||
markers.add(marker);
|
||||
} else {
|
||||
markersHistory.add(marker);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = deletedMarkers.size() - 1; i >= 0; i--) {
|
||||
markersHistory.add(0, (MapMarker) deletedMarkers.get(i));
|
||||
}
|
||||
deletedMarkers.clear();
|
||||
|
||||
getMyApplication().getMapMarkersHelper().saveMapMarkers(markers, markersHistory);
|
||||
}
|
||||
});
|
||||
|
||||
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
|
||||
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
|
||||
|
@ -373,6 +374,16 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
dashboardView.addView(actionButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapMarkerChanged(MapMarker mapMarker) {
|
||||
if (visible && visibleType == DashboardType.MAP_MARKERS) {
|
||||
mapMarkerDialogHelper.updateMarkerView(listView, mapMarker);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapMarkersChanged() {
|
||||
}
|
||||
|
||||
private void updateListBackgroundHeight() {
|
||||
|
||||
|
@ -682,6 +693,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
updateListBackgroundHeight();
|
||||
}
|
||||
applyDayNightMode();
|
||||
|
||||
if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
getMyApplication().getMapMarkersHelper().addListener(this);
|
||||
}
|
||||
}
|
||||
mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE);
|
||||
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
|
||||
|
@ -699,6 +714,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
// addOrUpdateDashboardFragments();
|
||||
mapActivity.getRoutingHelper().addListener(this);
|
||||
} else {
|
||||
if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
getMyApplication().getMapMarkersHelper().removeListener(this);
|
||||
}
|
||||
if (swipeDismissListener != null) {
|
||||
swipeDismissListener.discardUndo();
|
||||
}
|
||||
|
@ -1012,6 +1030,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
((DashLocationFragment) df.get()).updateLocation(centerChanged, locationChanged, compassChanged);
|
||||
}
|
||||
}
|
||||
if (visibleType == DashboardType.MAP_MARKERS) {
|
||||
mapMarkerDialogHelper.updateLocation(listView, compassChanged);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -11,19 +11,22 @@ import android.widget.AdapterView;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GeocodingLookupService;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
import net.osmand.plus.views.controls.ListDividerShape;
|
||||
import net.osmand.plus.views.controls.StableArrayAdapter;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -40,12 +43,21 @@ public class MapMarkerDialogHelper {
|
|||
|
||||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
private MapMarkersHelper markersHelper;
|
||||
private boolean sorted;
|
||||
private boolean nightMode;
|
||||
|
||||
private boolean useCenter;
|
||||
private LatLon loc;
|
||||
private Float heading;
|
||||
private int screenOrientation;
|
||||
private boolean reloading;
|
||||
private long lastUpdateTime;
|
||||
|
||||
public MapMarkerDialogHelper(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
app = mapActivity.getMyApplication();
|
||||
markersHelper = app.getMapMarkersHelper();
|
||||
}
|
||||
|
||||
public boolean isNightMode() {
|
||||
|
@ -83,11 +95,14 @@ public class MapMarkerDialogHelper {
|
|||
|
||||
public StableArrayAdapter getMapMarkersListAdapter() {
|
||||
|
||||
screenOrientation = DashLocationFragment.getScreenOrientation(mapActivity);
|
||||
calculateLocationParams();
|
||||
|
||||
final List<Object> objects = getListObjects();
|
||||
List<Object> activeObjects = getActiveObjects(objects);
|
||||
|
||||
final StableArrayAdapter listAdapter = new StableArrayAdapter(mapActivity,
|
||||
R.layout.waypoint_reached, R.id.title, objects, activeObjects) {
|
||||
R.layout.map_marker_item, R.id.title, objects, activeObjects) {
|
||||
|
||||
@Override
|
||||
public void buildDividers() {
|
||||
|
@ -124,23 +139,6 @@ public class MapMarkerDialogHelper {
|
|||
}
|
||||
};
|
||||
|
||||
for (Object p : objects) {
|
||||
if (p instanceof MapMarker) {
|
||||
final MapMarker marker = (MapMarker) p;
|
||||
if (marker.getOriginalPointDescription() != null
|
||||
&& marker.getOriginalPointDescription().isSearchingAddress(mapActivity)) {
|
||||
GeocodingLookupService.AddressLookupRequest lookupRequest
|
||||
= new GeocodingLookupService.AddressLookupRequest(marker.point, new GeocodingLookupService.OnAddressLookupResult() {
|
||||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
reloadListAdapter(listAdapter);
|
||||
}
|
||||
}, null);
|
||||
app.getGeocodingLookupService().lookupAddress(lookupRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return listAdapter;
|
||||
}
|
||||
|
||||
|
@ -213,8 +211,12 @@ public class MapMarkerDialogHelper {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
app.getMapMarkersHelper().removeMarkersHistory();
|
||||
reloadListAdapter(listAdapter);
|
||||
markersHelper.removeMarkersHistory();
|
||||
if (markersHelper.getActiveMapMarkers().size() == 0) {
|
||||
mapActivity.getDashboard().hideDashboard();
|
||||
} else {
|
||||
reloadListAdapter(listAdapter);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_no, null)
|
||||
|
@ -226,8 +228,12 @@ public class MapMarkerDialogHelper {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
app.getMapMarkersHelper().removeActiveMarkers();
|
||||
reloadListAdapter(listAdapter);
|
||||
markersHelper.removeActiveMarkers();
|
||||
if (markersHelper.getMapMarkersHistory().size() == 0) {
|
||||
mapActivity.getDashboard().hideDashboard();
|
||||
} else {
|
||||
reloadListAdapter(listAdapter);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_no, null)
|
||||
|
@ -244,7 +250,7 @@ public class MapMarkerDialogHelper {
|
|||
|
||||
protected View updateMapMarkerItemView(View v, final MapMarker marker) {
|
||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
||||
v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
v = mapActivity.getLayoutInflater().inflate(R.layout.map_marker_item, null);
|
||||
}
|
||||
updateMapMarkerInfoView(v, marker);
|
||||
final View more = v.findViewById(R.id.all_points);
|
||||
|
@ -260,20 +266,56 @@ public class MapMarkerDialogHelper {
|
|||
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
|
||||
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
|
||||
if (!marker.history) {
|
||||
((ImageView) localView.findViewById(R.id.waypoint_icon))
|
||||
.setImageDrawable(getMapMarkerIcon(app, marker.colorIndex));
|
||||
AndroidUtils.setTextPrimaryColor(mapActivity, text, nightMode);
|
||||
textDist.setTextColor(mapActivity.getResources().getColor(R.color.color_myloc_distance));
|
||||
ImageView arrow = (ImageView) localView.findViewById(R.id.direction);
|
||||
ImageView waypointIcon = (ImageView) localView.findViewById(R.id.waypoint_icon);
|
||||
TextView waypointDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation);
|
||||
TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text);
|
||||
if (text == null || textDist == null || arrow == null || waypointIcon == null
|
||||
|| waypointDeviation == null || descText == null) {
|
||||
return;
|
||||
}
|
||||
float[] mes = new float[2];
|
||||
if (loc != null && marker.point != null) {
|
||||
Location.distanceBetween(marker.getLatitude(), marker.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes);
|
||||
}
|
||||
boolean newImage = false;
|
||||
int arrowResId = R.drawable.ic_destination_arrow_white;
|
||||
DirectionDrawable dd;
|
||||
if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||
newImage = true;
|
||||
dd = new DirectionDrawable(mapActivity, arrow.getWidth(), arrow.getHeight());
|
||||
} else {
|
||||
((ImageView) localView.findViewById(R.id.waypoint_icon))
|
||||
.setImageDrawable(app.getIconsCache()
|
||||
.getContentIcon(R.drawable.ic_action_flag_dark, !nightMode));
|
||||
dd = (DirectionDrawable) arrow.getDrawable();
|
||||
}
|
||||
if (!marker.history) {
|
||||
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance);
|
||||
} else {
|
||||
dd.setImage(arrowResId, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light);
|
||||
}
|
||||
if (loc == null || heading == null || marker.point == null) {
|
||||
dd.setAngle(0);
|
||||
} else {
|
||||
dd.setAngle(mes[1] - heading + 180 + screenOrientation);
|
||||
}
|
||||
if (newImage) {
|
||||
arrow.setImageDrawable(dd);
|
||||
}
|
||||
arrow.setVisibility(View.VISIBLE);
|
||||
arrow.invalidate();
|
||||
|
||||
if (!marker.history) {
|
||||
waypointIcon.setImageDrawable(getMapMarkerIcon(app, marker.colorIndex));
|
||||
AndroidUtils.setTextPrimaryColor(mapActivity, text, nightMode);
|
||||
textDist.setTextColor(mapActivity.getResources()
|
||||
.getColor(useCenter ? R.color.color_distance : R.color.color_myloc_distance));
|
||||
} else {
|
||||
waypointIcon.setImageDrawable(app.getIconsCache()
|
||||
.getContentIcon(R.drawable.ic_action_flag_dark, !nightMode));
|
||||
AndroidUtils.setTextSecondaryColor(mapActivity, text, nightMode);
|
||||
AndroidUtils.setTextSecondaryColor(mapActivity, textDist, nightMode);
|
||||
}
|
||||
|
||||
int dist = marker.dist;
|
||||
int dist = (int) mes[0];
|
||||
|
||||
//if (dist > 0) {
|
||||
textDist.setText(OsmAndFormatter.getFormattedDistance(dist, app));
|
||||
|
@ -281,7 +323,7 @@ public class MapMarkerDialogHelper {
|
|||
// textDist.setText("");
|
||||
//}
|
||||
|
||||
localView.findViewById(R.id.waypoint_deviation).setVisibility(View.GONE);
|
||||
waypointDeviation.setVisibility(View.GONE);
|
||||
|
||||
String descr;
|
||||
PointDescription pd = marker.getPointDescription(app);
|
||||
|
@ -296,10 +338,9 @@ public class MapMarkerDialogHelper {
|
|||
}
|
||||
text.setText(descr);
|
||||
|
||||
localView.findViewById(R.id.waypoint_desc_text).setVisibility(View.GONE);
|
||||
descText.setVisibility(View.GONE);
|
||||
/*
|
||||
String pointDescription = "";
|
||||
TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text);
|
||||
if (descText != null) {
|
||||
AndroidUtils.setTextSecondaryColor(this, descText, nightMode);
|
||||
pointDescription = marker.getPointDescription(this).getTypeName();
|
||||
|
@ -317,6 +358,44 @@ public class MapMarkerDialogHelper {
|
|||
*/
|
||||
}
|
||||
|
||||
protected void updateMapMarkerArrowDistanceView(View localView, final MapMarker marker) {
|
||||
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
|
||||
ImageView arrow = (ImageView) localView.findViewById(R.id.direction);
|
||||
if (textDist == null || arrow == null) {
|
||||
return;
|
||||
}
|
||||
float[] mes = new float[2];
|
||||
if (loc != null && marker.point != null) {
|
||||
Location.distanceBetween(marker.getLatitude(), marker.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes);
|
||||
}
|
||||
boolean newImage = false;
|
||||
int arrowResId = R.drawable.ic_destination_arrow_white;
|
||||
DirectionDrawable dd;
|
||||
if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||
newImage = true;
|
||||
dd = new DirectionDrawable(mapActivity, arrow.getWidth(), arrow.getHeight());
|
||||
} else {
|
||||
dd = (DirectionDrawable) arrow.getDrawable();
|
||||
}
|
||||
if (!marker.history) {
|
||||
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance);
|
||||
} else {
|
||||
dd.setImage(arrowResId, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light);
|
||||
}
|
||||
if (loc == null || heading == null || marker.point == null) {
|
||||
dd.setAngle(0);
|
||||
} else {
|
||||
dd.setAngle(mes[1] - heading + 180 + screenOrientation);
|
||||
}
|
||||
if (newImage) {
|
||||
arrow.setImageDrawable(dd);
|
||||
}
|
||||
arrow.invalidate();
|
||||
|
||||
int dist = (int) mes[0];
|
||||
textDist.setText(OsmAndFormatter.getFormattedDistance(dist, app));
|
||||
}
|
||||
|
||||
public void showOnMap(MapMarker marker) {
|
||||
app.getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
|
||||
15, marker.getPointDescription(mapActivity), true, marker);
|
||||
|
@ -343,8 +422,9 @@ public class MapMarkerDialogHelper {
|
|||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
public void reloadListAdapter(ArrayAdapter<Object> listAdapter) {
|
||||
reloading = true;
|
||||
listAdapter.setNotifyOnChange(false);
|
||||
listAdapter.clear();
|
||||
List<Object> objects = getListObjects();
|
||||
|
@ -355,6 +435,7 @@ public class MapMarkerDialogHelper {
|
|||
((StableArrayAdapter) listAdapter).updateObjects(objects, getActiveObjects(objects));
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
reloading = false;
|
||||
}
|
||||
|
||||
public void calcDistance(LatLon anchor, List<MapMarker> markers) {
|
||||
|
@ -366,7 +447,6 @@ public class MapMarkerDialogHelper {
|
|||
|
||||
protected List<Object> getListObjects() {
|
||||
final List<Object> objects = new ArrayList<>();
|
||||
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||
|
||||
LatLon mapLocation =
|
||||
new LatLon(mapActivity.getMapView().getLatitude(), mapActivity.getMapView().getLongitude());
|
||||
|
@ -412,20 +492,78 @@ public class MapMarkerDialogHelper {
|
|||
}
|
||||
|
||||
public static Drawable getMapMarkerIcon(OsmandApplication app, int colorIndex) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
int colorId;
|
||||
switch (colorIndex) {
|
||||
case 0:
|
||||
return iconsCache.getIcon(R.drawable.map_marker_blue);
|
||||
colorId = R.color.marker_blue;
|
||||
break;
|
||||
case 1:
|
||||
return iconsCache.getIcon(R.drawable.map_marker_green);
|
||||
colorId = R.color.marker_green;
|
||||
break;
|
||||
case 2:
|
||||
return iconsCache.getIcon(R.drawable.map_marker_orange);
|
||||
colorId = R.color.marker_orange;
|
||||
break;
|
||||
case 3:
|
||||
return iconsCache.getIcon(R.drawable.map_marker_red);
|
||||
colorId = R.color.marker_red;
|
||||
break;
|
||||
case 4:
|
||||
return iconsCache.getIcon(R.drawable.map_marker_yellow);
|
||||
colorId = R.color.marker_lt_green;
|
||||
break;
|
||||
default:
|
||||
return iconsCache.getIcon(R.drawable.map_marker_blue);
|
||||
colorId = R.color.marker_blue;
|
||||
}
|
||||
return app.getIconsCache().getIcon(R.drawable.ic_action_flag_dark, colorId);
|
||||
}
|
||||
|
||||
public void updateLocation(ListView listView, boolean compassChanged) {
|
||||
if ((compassChanged && !mapActivity.getDashboard().isMapLinkedToLocation())
|
||||
|| reloading || System.currentTimeMillis() - lastUpdateTime < 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastUpdateTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
calculateLocationParams();
|
||||
|
||||
for (int i = listView.getFirstVisiblePosition(); i <= listView.getLastVisiblePosition(); i++) {
|
||||
Object obj = listView.getItemAtPosition(i);
|
||||
View v = listView.getChildAt(i - listView.getFirstVisiblePosition());
|
||||
if (obj instanceof MapMarker && v != null) {
|
||||
updateMapMarkerArrowDistanceView(v, (MapMarker) obj);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMarkerView(ListView listView, MapMarker marker) {
|
||||
try {
|
||||
for (int i = listView.getFirstVisiblePosition(); i <= listView.getLastVisiblePosition(); i++) {
|
||||
Object obj = listView.getItemAtPosition(i);
|
||||
View v = listView.getChildAt(i - listView.getFirstVisiblePosition());
|
||||
if (obj == marker) {
|
||||
updateMapMarkerInfoView(v, (MapMarker) obj);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateLocationParams() {
|
||||
DashboardOnMap d = mapActivity.getDashboard();
|
||||
if (d == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
float head = d.getHeading();
|
||||
float mapRotation = d.getMapRotation();
|
||||
LatLon mw = d.getMapViewLocation();
|
||||
Location l = d.getMyLocation();
|
||||
boolean mapLinked = d.isMapLinkedToLocation() && l != null;
|
||||
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
|
||||
useCenter = !mapLinked;
|
||||
loc = (useCenter ? mw : myLoc);
|
||||
heading = useCenter ? -mapRotation : head;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import net.osmand.plus.ContextMenuAdapter;
|
|||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -42,7 +44,8 @@ import net.osmand.util.MapUtils;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode> {
|
||||
public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode>,
|
||||
MapMarkerChangedListener {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private MapMultiSelectionMenu mapMultiSelectionMenu;
|
||||
|
@ -256,6 +259,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
|
||||
mapActivity.refreshMap();
|
||||
|
||||
if (object instanceof MapMarker) {
|
||||
mapActivity.getMyApplication().getMapMarkersHelper().addListener(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -308,6 +315,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
public void close() {
|
||||
if (active) {
|
||||
active = false;
|
||||
if (object instanceof MapMarker) {
|
||||
mapActivity.getMyApplication().getMapMarkersHelper().removeListener(this);
|
||||
}
|
||||
if (this.object != null) {
|
||||
clearSelectedObject(this.object);
|
||||
}
|
||||
|
@ -334,6 +344,22 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapMarkerChanged(MapMarker mapMarker) {
|
||||
if (object == mapMarker) {
|
||||
String address = ((MapMarker) object).getOnlyName();
|
||||
nameStr = address;
|
||||
pointDescription.setName(address);
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null)
|
||||
fragmentRef.get().refreshTitle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapMarkersChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ApplicationMode change) {
|
||||
appModeChanged = active;
|
||||
|
@ -477,7 +503,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS);
|
||||
} else {
|
||||
mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(),
|
||||
pointDescription);
|
||||
getPointDescriptionForTarget());
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
|
|||
//private List<PendingDismissData> mPendingDismisses = new ArrayList<PendingDismissData>();
|
||||
private int mDismissAnimationRefCount = 0;
|
||||
private float mDownX;
|
||||
private float mDownY;
|
||||
private boolean mSwiping;
|
||||
private VelocityTracker mVelocityTracker;
|
||||
private int mDownPosition;
|
||||
|
@ -601,6 +602,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
|
|||
int position = mListView.getPositionForView(mSwipeDownView) - mListView.getHeaderViewsCount();
|
||||
if (mCallbacks == null || mCallbacks.canDismiss(position)) {
|
||||
mDownX = ev.getRawX();
|
||||
mDownY = ev.getRawY();
|
||||
mDownPosition = position;
|
||||
|
||||
mVelocityTracker = VelocityTracker.obtain();
|
||||
|
@ -629,6 +631,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
|
|||
mVelocityTracker.recycle();
|
||||
mVelocityTracker = null;
|
||||
mDownX = 0;
|
||||
mDownY = 0;
|
||||
mSwipeDownView = mSwipeDownChild = null;
|
||||
mDownPosition = ListView.INVALID_POSITION;
|
||||
mSwiping = false;
|
||||
|
@ -669,6 +672,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
|
|||
}
|
||||
mVelocityTracker = null;
|
||||
mDownX = 0;
|
||||
mDownY = 0;
|
||||
mSwipeDownView = null;
|
||||
mSwipeDownChild = null;
|
||||
mDownPosition = AbsListView.INVALID_POSITION;
|
||||
|
@ -683,6 +687,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
|
|||
|
||||
mVelocityTracker.addMovement(ev);
|
||||
float deltaX = ev.getRawX() - mDownX;
|
||||
float deltaY = ev.getRawY() - mDownY;
|
||||
// Only start swipe in correct direction
|
||||
if (isSwipeDirectionValid(deltaX)) {
|
||||
ViewParent parent = mListView.getParent();
|
||||
|
@ -691,7 +696,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
|
|||
// otherwise swipe would not be working.
|
||||
parent.requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
if (Math.abs(deltaX) > mSlop) {
|
||||
if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
|
||||
mSwiping = true;
|
||||
mListView.requestDisallowInterceptTouchEvent(true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue