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,23 +398,40 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
|
||||
private void updateListBackgroundHeight() {
|
||||
if (listBackgroundView != null) {
|
||||
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
ViewTreeObserver vto = contentView.getViewTreeObserver();
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
|
||||
if (listBackgroundView == null || listBackgroundView.getHeight() > 0) {
|
||||
return;
|
||||
}
|
||||
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
if (contentView.getHeight() > 0) {
|
||||
listBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||
} else {
|
||||
contentView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// mListBackgroundView's should fill its parent vertically
|
||||
// but the height of the content view is 0 on 'onCreate'.
|
||||
// So we should get it with post().
|
||||
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 {
|
||||
contentView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// mListBackgroundView's should fill its parent vertically
|
||||
// but the height of the content view is 0 on 'onCreate'.
|
||||
// So we should get it with post().
|
||||
listBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,10 +120,17 @@ public class MapMarkerDialogHelper {
|
|||
Object obj = listAdapter.getItem(item);
|
||||
if (obj instanceof MapMarker) {
|
||||
MapMarker marker = (MapMarker) obj;
|
||||
if (!marker.history) {
|
||||
showMarkerOnMap(mapActivity, marker);
|
||||
if (selectionMode) {
|
||||
CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
|
||||
checkBox.setChecked(!checkBox.isChecked());
|
||||
marker.selected = checkBox.isChecked();
|
||||
markersHelper.updateMapMarker(marker, false);
|
||||
} else {
|
||||
showHistoryOnMap(marker);
|
||||
if (!marker.history) {
|
||||
showMarkerOnMap(mapActivity, marker);
|
||||
} else {
|
||||
showHistoryOnMap(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,15 +617,17 @@ public class MapMarkerDialogHelper {
|
|||
objects.add(false);
|
||||
}
|
||||
|
||||
List<MapMarker> markersHistory = new ArrayList<>(markersHelper.getMapMarkersHistory());
|
||||
calcDistance(mapLocation, markersHistory);
|
||||
if (markersHistory.size() > 0) {
|
||||
if (activeMarkers.size() > 0) {
|
||||
objects.add(true);
|
||||
if (!selectionMode) {
|
||||
List<MapMarker> markersHistory = new ArrayList<>(markersHelper.getMapMarkersHistory());
|
||||
calcDistance(mapLocation, markersHistory);
|
||||
if (markersHistory.size() > 0) {
|
||||
if (activeMarkers.size() > 0) {
|
||||
objects.add(true);
|
||||
}
|
||||
objects.add(MARKERS_HISTORY);
|
||||
objects.addAll(markersHistory);
|
||||
objects.add(false);
|
||||
}
|
||||
objects.add(MARKERS_HISTORY);
|
||||
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,26 +209,30 @@ 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) {
|
||||
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();
|
||||
canvas.rotate(bearing, cp.x, cp.y);
|
||||
canvas.translate(-24 * tb.getDensity() + radiusBearing, -22 * tb.getDensity());
|
||||
canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
|
||||
canvas.restore();
|
||||
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);
|
||||
float bearing = calculations[1] - 90;
|
||||
float radiusBearing = DIST_TO_SHOW * tb.getDensity();
|
||||
final QuadPoint cp = tb.getCenterPixelPoint();
|
||||
canvas.rotate(bearing, cp.x, cp.y);
|
||||
canvas.translate(-24 * tb.getDensity() + radiusBearing, -22 * tb.getDensity());
|
||||
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