Fixes
This commit is contained in:
parent
99db5ea8f1
commit
52523d78e2
5 changed files with 99 additions and 47 deletions
|
@ -298,6 +298,17 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateMapMarker(MapMarker marker, boolean refresh) {
|
||||
if (marker != null) {
|
||||
settings.updateMapMarker(marker.getLatitude(), marker.getLongitude(),
|
||||
marker.pointDescription, marker.colorIndex, marker.pos, marker.selected);
|
||||
if (refresh) {
|
||||
readFromSettings();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMapMarker(MapMarker marker) {
|
||||
if (marker != null) {
|
||||
settings.deleteMapMarker(marker.index);
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
|
@ -397,11 +398,26 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
|
||||
private void updateListBackgroundHeight() {
|
||||
|
||||
if (listBackgroundView == null || listBackgroundView.getHeight() > 0) {
|
||||
return;
|
||||
}
|
||||
if (listBackgroundView != null) {
|
||||
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
ViewTreeObserver vto = contentView.getViewTreeObserver();
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
|
||||
ViewTreeObserver obs = contentView.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
listBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
if (contentView.getHeight() > 0) {
|
||||
listBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||
} else {
|
||||
|
@ -415,6 +431,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void updateToolbarActions() {
|
||||
|
@ -725,8 +743,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
refreshContent(false);
|
||||
} else {
|
||||
updateListAdapter();
|
||||
updateListBackgroundHeight();
|
||||
}
|
||||
updateListBackgroundHeight();
|
||||
applyDayNightMode();
|
||||
|
||||
if (visibleType == DashboardType.MAP_MARKERS || visibleType == DashboardType.MAP_MARKERS_SELECTION) {
|
||||
|
@ -1159,7 +1177,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
|| visibleType == DashboardType.WAYPOINTS_FLAT
|
||||
|| visibleType == DashboardType.LIST_MENU
|
||||
|| visibleType == DashboardType.ROUTE_PREFERENCES
|
||||
|| visibleType == DashboardType.CONFIGURE_SCREEN;
|
||||
|| visibleType == DashboardType.CONFIGURE_SCREEN
|
||||
|| visibleType == DashboardType.MAP_MARKERS
|
||||
|| visibleType == DashboardType.MAP_MARKERS_SELECTION;
|
||||
}
|
||||
|
||||
private boolean isBackButtonVisible() {
|
||||
|
|
|
@ -120,6 +120,12 @@ public class MapMarkerDialogHelper {
|
|||
Object obj = listAdapter.getItem(item);
|
||||
if (obj instanceof MapMarker) {
|
||||
MapMarker marker = (MapMarker) obj;
|
||||
if (selectionMode) {
|
||||
CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
|
||||
checkBox.setChecked(!checkBox.isChecked());
|
||||
marker.selected = checkBox.isChecked();
|
||||
markersHelper.updateMapMarker(marker, false);
|
||||
} else {
|
||||
if (!marker.history) {
|
||||
showMarkerOnMap(mapActivity, marker);
|
||||
} else {
|
||||
|
@ -127,6 +133,7 @@ public class MapMarkerDialogHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -397,7 +404,7 @@ public class MapMarkerDialogHelper {
|
|||
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);
|
||||
CheckBox checkBox = (CheckBox) localView.findViewById(R.id.checkbox);
|
||||
final CheckBox checkBox = (CheckBox) localView.findViewById(R.id.checkbox);
|
||||
|
||||
if (text == null || textDist == null || arrow == null || waypointIcon == null
|
||||
|| waypointDeviation == null || descText == null) {
|
||||
|
@ -433,7 +440,7 @@ public class MapMarkerDialogHelper {
|
|||
arrow.setVisibility(View.VISIBLE);
|
||||
arrow.invalidate();
|
||||
|
||||
OsmandApplication app = (OsmandApplication) ctx.getApplicationContext();
|
||||
final OsmandApplication app = (OsmandApplication) ctx.getApplicationContext();
|
||||
|
||||
if (!marker.history) {
|
||||
waypointIcon.setImageDrawable(getMapMarkerIcon(app, marker.colorIndex));
|
||||
|
@ -468,9 +475,18 @@ public class MapMarkerDialogHelper {
|
|||
descText.setVisibility(View.GONE);
|
||||
|
||||
if (selectionMode) {
|
||||
checkBox.setChecked(marker.selected);
|
||||
checkBox.setVisibility(View.VISIBLE);
|
||||
checkBox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
marker.selected = checkBox.isChecked();
|
||||
app.getMapMarkersHelper().updateMapMarker(marker, false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
checkBox.setVisibility(View.GONE);
|
||||
checkBox.setOnClickListener(null);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -601,6 +617,7 @@ public class MapMarkerDialogHelper {
|
|||
objects.add(false);
|
||||
}
|
||||
|
||||
if (!selectionMode) {
|
||||
List<MapMarker> markersHistory = new ArrayList<>(markersHelper.getMapMarkersHistory());
|
||||
calcDistance(mapLocation, markersHistory);
|
||||
if (markersHistory.size() > 0) {
|
||||
|
@ -611,6 +628,7 @@ public class MapMarkerDialogHelper {
|
|||
objects.addAll(markersHistory);
|
||||
objects.add(false);
|
||||
}
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.os.Message;
|
|||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
|
@ -25,7 +26,6 @@ import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
|||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProviderSelection;
|
||||
import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvider, IContextMenuProviderSelection {
|
||||
|
@ -196,7 +196,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
return;
|
||||
}
|
||||
|
||||
List<MapMarker> hiddenMarkers = new ArrayList<>();
|
||||
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
|
||||
List<MapMarker> activeMapMarkers = markersHelper.getActiveMapMarkers();
|
||||
for (int i = 0; i < activeMapMarkers.size(); i++) {
|
||||
|
@ -210,19 +209,18 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
canvas.rotate(-tb.getRotate(), locationX, locationY);
|
||||
canvas.drawBitmap(bmp, locationX - marginX, locationY - marginY, bitmapPaint);
|
||||
canvas.rotate(tb.getRotate(), locationX, locationY);
|
||||
} else if (i < 2) {
|
||||
hiddenMarkers.add(marker);
|
||||
}
|
||||
}
|
||||
|
||||
boolean show = useFingerLocation && map.getMyApplication().getSettings().SHOW_DESTINATION_ARROW.get();
|
||||
if (show && fingerLocation != null) {
|
||||
for (MapMarker marker : hiddenMarkers) {
|
||||
List<MapMarker> sortedMapMarkers = markersHelper.getSortedMapMarkers();
|
||||
int i = 0;
|
||||
for (MapMarker marker : sortedMapMarkers) {
|
||||
if (!isLocationVisible(tb, marker)) {
|
||||
canvas.save();
|
||||
net.osmand.Location.distanceBetween(fingerLocation.getLatitude(), fingerLocation.getLongitude(),
|
||||
marker.getLatitude(), marker.getLongitude(), calculations);
|
||||
//net.osmand.Location.distanceBetween(view.getLatitude(), view.getLongitude(),
|
||||
// marker.getLatitude(), marker.getLongitude(), calculations);
|
||||
float bearing = calculations[1] - 90;
|
||||
float radiusBearing = DIST_TO_SHOW * tb.getDensity();
|
||||
final QuadPoint cp = tb.getCenterPixelPoint();
|
||||
|
@ -231,6 +229,11 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
|
||||
canvas.restore();
|
||||
}
|
||||
i++;
|
||||
if (i > 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ public class MapMarkersWidgetsFactory {
|
|||
|
||||
if (markers.size() > 1) {
|
||||
marker = markers.get(1);
|
||||
if (loc != null) {
|
||||
if (loc != null && customLocation == null) {
|
||||
for (int i = 1; i < markers.size(); i++) {
|
||||
MapMarker m = markers.get(i);
|
||||
m.dist = (int) (MapUtils.getDistance(m.getLatitude(), m.getLongitude(),
|
||||
|
@ -292,7 +292,7 @@ public class MapMarkersWidgetsFactory {
|
|||
boolean res = false;
|
||||
if (markerColorIndex != cachedMarkerColorIndex) {
|
||||
setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getIcon(R.drawable.widget_intermediate_day,
|
||||
.getIcon(R.drawable.widget_marker_day,
|
||||
MapMarkerDialogHelper.getMapMarkerColorId(markerColorIndex)));
|
||||
res = true;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ public class MapMarkersWidgetsFactory {
|
|||
boolean res = false;
|
||||
if (markerColorIndex2nd != cachedMarkerColorIndex) {
|
||||
setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getIcon(R.drawable.widget_intermediate_day,
|
||||
.getIcon(R.drawable.widget_marker_day,
|
||||
MapMarkerDialogHelper.getMapMarkerColorId(markerColorIndex2nd)));
|
||||
res = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue