Fixes - context menu + download maps layer
This commit is contained in:
parent
fd80843baf
commit
2ff332c49e
2 changed files with 36 additions and 15 deletions
|
@ -222,6 +222,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
updateButtonsAndProgress();
|
updateButtonsAndProgress();
|
||||||
|
|
||||||
if (menu.isLandscapeLayout()) {
|
if (menu.isLandscapeLayout()) {
|
||||||
|
final TypedValue typedValueAttr = new TypedValue();
|
||||||
|
getMapActivity().getTheme().resolveAttribute(R.attr.left_menu_view_bg, typedValueAttr, true);
|
||||||
|
mainView.setBackgroundResource(typedValueAttr.resourceId);
|
||||||
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
|
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
View fabContainer = view.findViewById(R.id.context_menu_fab_container);
|
View fabContainer = view.findViewById(R.id.context_menu_fab_container);
|
||||||
|
@ -303,7 +306,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
int currentY = getViewY();
|
int currentY = getViewY();
|
||||||
|
|
||||||
slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50;
|
slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50;
|
||||||
slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50;
|
slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50;
|
||||||
|
|
||||||
|
@ -339,6 +342,11 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
// FAB
|
// FAB
|
||||||
fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view);
|
fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view);
|
||||||
if (menu.fabVisible()) {
|
if (menu.fabVisible()) {
|
||||||
|
if (menu.isLandscapeLayout()) {
|
||||||
|
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) fabView.getLayoutParams();
|
||||||
|
params.setMargins(0, 0, dpToPx(28f), 0);
|
||||||
|
fabView.setLayoutParams(params);
|
||||||
|
}
|
||||||
fabView.setOnClickListener(new View.OnClickListener() {
|
fabView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -407,7 +415,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
public void openMenuFullScreen() {
|
public void openMenuFullScreen() {
|
||||||
changeMenuState(getViewY(), true, true, false);
|
changeMenuState(getViewY(), true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openMenuHalfScreen() {
|
public void openMenuHalfScreen() {
|
||||||
int oldMenuState = menu.getCurrentMenuState();
|
int oldMenuState = menu.getCurrentMenuState();
|
||||||
if(oldMenuState == MenuState.HEADER_ONLY) {
|
if(oldMenuState == MenuState.HEADER_ONLY) {
|
||||||
|
|
|
@ -123,12 +123,12 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
pathOutdated = new Path();
|
pathOutdated = new Path();
|
||||||
|
|
||||||
data = new MapLayerData<List<BinaryMapDataObject>>() {
|
data = new MapLayerData<List<BinaryMapDataObject>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void layerOnPostExecute() {
|
public void layerOnPostExecute() {
|
||||||
view.refreshMap();
|
view.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
|
public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
|
||||||
if (newBox.getZoom() < ZOOM_TO_SHOW_SELECTION) {
|
if (newBox.getZoom() < ZOOM_TO_SHOW_SELECTION) {
|
||||||
if (queriedData != null && queriedData.getZoom() < ZOOM_TO_SHOW_SELECTION) {
|
if (queriedData != null && queriedData.getZoom() < ZOOM_TO_SHOW_SELECTION) {
|
||||||
|
@ -139,19 +139,19 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
}
|
}
|
||||||
List<BinaryMapDataObject> queriedResults = getResults();
|
List<BinaryMapDataObject> queriedResults = getResults();
|
||||||
if(queriedData != null && queriedData.containsTileBox(newBox) && queriedData.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) {
|
if(queriedData != null && queriedData.containsTileBox(newBox) && queriedData.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) {
|
||||||
if(queriedResults != null && ( queriedResults.isEmpty() ||
|
if(queriedResults != null && ( queriedResults.isEmpty() ||
|
||||||
Math.abs(queriedData.getZoom() - newBox.getZoom()) <= 1)) {
|
Math.abs(queriedData.getZoom() - newBox.getZoom()) <= 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<BinaryMapDataObject> calculateResult(RotatedTileBox tileBox) {
|
protected List<BinaryMapDataObject> calculateResult(RotatedTileBox tileBox) {
|
||||||
return queryData(tileBox);
|
return queryData(tileBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -184,19 +184,19 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
final List<BinaryMapDataObject> selectedObjects = new LinkedList<>(this.selectedObjects);
|
final List<BinaryMapDataObject> selectedObjects = new LinkedList<>(this.selectedObjects);
|
||||||
|
|
||||||
if (selectedObjects.size() > 0) {
|
if (selectedObjects.size() > 0) {
|
||||||
currentObjects.removeAll(selectedObjects);
|
removeObjectsFromList(currentObjects, selectedObjects);
|
||||||
drawBorders(canvas, tileBox, selectedObjects, pathSelected, paintSelected);
|
drawBorders(canvas, tileBox, selectedObjects, pathSelected, paintSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS) {
|
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS) {
|
||||||
downloadingObjects.removeAll(selectedObjects);
|
removeObjectsFromList(downloadingObjects, selectedObjects);
|
||||||
if (downloadingObjects.size() > 0) {
|
if (downloadingObjects.size() > 0) {
|
||||||
currentObjects.removeAll(downloadingObjects);
|
removeObjectsFromList(currentObjects, downloadingObjects);
|
||||||
drawBorders(canvas, tileBox, downloadingObjects, pathDownloading, paintDownloading);
|
drawBorders(canvas, tileBox, downloadingObjects, pathDownloading, paintDownloading);
|
||||||
}
|
}
|
||||||
outdatedObjects.removeAll(selectedObjects);
|
removeObjectsFromList(outdatedObjects, selectedObjects);
|
||||||
if (outdatedObjects.size() > 0) {
|
if (outdatedObjects.size() > 0) {
|
||||||
currentObjects.removeAll(outdatedObjects);
|
removeObjectsFromList(currentObjects, outdatedObjects);
|
||||||
drawBorders(canvas, tileBox, outdatedObjects, pathOutdated, paintOutdated);
|
drawBorders(canvas, tileBox, outdatedObjects, pathOutdated, paintOutdated);
|
||||||
}
|
}
|
||||||
if (currentObjects.size() > 0) {
|
if (currentObjects.size() > 0) {
|
||||||
|
@ -216,6 +216,19 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeObjectsFromList(List<BinaryMapDataObject> list, List<BinaryMapDataObject> objects) {
|
||||||
|
Iterator<BinaryMapDataObject> it = list.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
BinaryMapDataObject o = it.next();
|
||||||
|
for (BinaryMapDataObject obj : objects) {
|
||||||
|
if (o.getId() == obj.getId()) {
|
||||||
|
it.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void drawBorders(Canvas canvas, RotatedTileBox tileBox, final List<BinaryMapDataObject> objects, Path path, Paint paint) {
|
private void drawBorders(Canvas canvas, RotatedTileBox tileBox, final List<BinaryMapDataObject> objects, Path path, Paint paint) {
|
||||||
path.reset();
|
path.reset();
|
||||||
for (BinaryMapDataObject o : objects) {
|
for (BinaryMapDataObject o : objects) {
|
||||||
|
@ -240,11 +253,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private List<BinaryMapDataObject> queryData(RotatedTileBox tileBox) {
|
private List<BinaryMapDataObject> queryData(RotatedTileBox tileBox) {
|
||||||
if (tileBox.getZoom() >= ZOOM_AFTER_BASEMAP) {
|
if (tileBox.getZoom() >= ZOOM_AFTER_BASEMAP) {
|
||||||
if(!checkIfMapEmpty(tileBox)) {
|
if(!checkIfMapEmpty(tileBox)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LatLon lt = tileBox.getLeftTopLatLon();
|
LatLon lt = tileBox.getLeftTopLatLon();
|
||||||
|
@ -252,7 +265,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
// if (tileBox.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) {
|
// if (tileBox.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) {
|
||||||
// lt = rb = tileBox.getCenterLatLon();
|
// lt = rb = tileBox.getCenterLatLon();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
List<BinaryMapDataObject> result = null;
|
List<BinaryMapDataObject> result = null;
|
||||||
int left = MapUtils.get31TileNumberX(lt.getLongitude());
|
int left = MapUtils.get31TileNumberX(lt.getLongitude());
|
||||||
int right = MapUtils.get31TileNumberX(rb.getLongitude());
|
int right = MapUtils.get31TileNumberX(rb.getLongitude());
|
||||||
|
|
Loading…
Reference in a new issue