Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
167326e551
3 changed files with 82 additions and 51 deletions
|
@ -229,13 +229,17 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
if (!isVisible()) {
|
if (!isVisible()) {
|
||||||
MapContextMenuFragment.showInstance(mapActivity);
|
if (!MapContextMenuFragment.showInstance(this, mapActivity)) {
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(LatLon latLon, PointDescription pointDescription, Object object) {
|
public void show(LatLon latLon, PointDescription pointDescription, Object object) {
|
||||||
if (init(latLon, pointDescription, object)) {
|
if (init(latLon, pointDescription, object)) {
|
||||||
MapContextMenuFragment.showInstance(mapActivity);
|
if (!MapContextMenuFragment.showInstance(this, mapActivity)) {
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +378,7 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if(defaultVls[0] == 0) {
|
if(defaultVls[0] == 0) {
|
||||||
|
|
|
@ -142,6 +142,12 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
|
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
|
||||||
|
|
||||||
menu = getMapActivity().getContextMenu();
|
menu = getMapActivity().getContextMenu();
|
||||||
|
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
|
||||||
|
if (!menu.isActive()) {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
mainView = view.findViewById(R.id.context_menu_main);
|
||||||
|
|
||||||
leftTitleButtonController = menu.getLeftTitleButtonController();
|
leftTitleButtonController = menu.getLeftTitleButtonController();
|
||||||
rightTitleButtonController = menu.getRightTitleButtonController();
|
rightTitleButtonController = menu.getRightTitleButtonController();
|
||||||
topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
||||||
|
@ -166,9 +172,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
IconsCache iconsCache = getMyApplication().getIconsCache();
|
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||||
boolean light = getMyApplication().getSettings().isLightContent();
|
boolean light = getMyApplication().getSettings().isLightContent();
|
||||||
|
|
||||||
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
|
|
||||||
mainView = view.findViewById(R.id.context_menu_main);
|
|
||||||
|
|
||||||
// Left title button
|
// Left title button
|
||||||
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
||||||
if (leftTitleButtonController != null) {
|
if (leftTitleButtonController != null) {
|
||||||
|
@ -244,14 +247,20 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
private float maxVelocityY;
|
private float maxVelocityY;
|
||||||
|
|
||||||
private boolean hasMoved;
|
private boolean hasMoved;
|
||||||
|
private boolean centered;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
|
||||||
if (singleTapDetector.onTouchEvent(event)) {
|
if (singleTapDetector.onTouchEvent(event)) {
|
||||||
showOnMap(menu.getLatLon(), true, false);
|
int posY = getViewY();
|
||||||
|
if (!centered) {
|
||||||
|
showOnMap(menu.getLatLon(), true, false,
|
||||||
|
map.getCurrentRotatedTileBox().getPixHeight() / 2 < posY - markerPaddingPx);
|
||||||
|
centered = true;
|
||||||
|
}
|
||||||
if (hasMoved) {
|
if (hasMoved) {
|
||||||
applyPosY(getViewY(), false, false, 0, 0);
|
applyPosY(posY, false, false, 0, 0);
|
||||||
}
|
}
|
||||||
openMenuHalfScreen();
|
openMenuHalfScreen();
|
||||||
return true;
|
return true;
|
||||||
|
@ -297,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;
|
||||||
|
|
||||||
|
@ -406,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) {
|
||||||
|
@ -455,26 +464,24 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
.setDuration(200)
|
.setDuration(200)
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
.setInterpolator(new DecelerateInterpolator())
|
||||||
.setListener(new AnimatorListenerAdapter() {
|
.setListener(new AnimatorListenerAdapter() {
|
||||||
|
|
||||||
|
boolean canceled = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationCancel(Animator animation) {
|
public void onAnimationCancel(Animator animation) {
|
||||||
if (needCloseMenu) {
|
canceled = true;
|
||||||
menu.close();
|
|
||||||
} else {
|
|
||||||
updateMainViewLayout(posY);
|
|
||||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
|
||||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
if (needCloseMenu) {
|
if (!canceled) {
|
||||||
menu.close();
|
if (needCloseMenu) {
|
||||||
} else {
|
menu.close();
|
||||||
updateMainViewLayout(posY);
|
} else {
|
||||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
updateMainViewLayout(posY);
|
||||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
||||||
|
doAfterMenuStateChange(previousMenuState, newMenuState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,6 +635,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!menu.isActive()) {
|
||||||
|
dismissMenu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
|
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
|
||||||
if (menu.displayDistanceDirection()) {
|
if (menu.displayDistanceDirection()) {
|
||||||
getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu);
|
getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu);
|
||||||
|
@ -643,7 +654,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
if (mapCenter != null) {
|
||||||
|
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||||
|
}
|
||||||
menu.setMapCenter(null);
|
menu.setMapCenter(null);
|
||||||
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
|
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
|
||||||
}
|
}
|
||||||
|
@ -709,7 +722,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showOnMap(LatLon latLon, boolean updateCoords, boolean ignoreCoef) {
|
private void showOnMap(LatLon latLon, boolean updateCoords, boolean ignoreCoef, boolean needMove) {
|
||||||
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
|
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
|
||||||
int fZoom = map.getZoom();
|
int fZoom = map.getZoom();
|
||||||
double flat = latLon.getLatitude();
|
double flat = latLon.getLatitude();
|
||||||
|
@ -732,7 +745,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
origMarkerY = cp.getCenterPixelY();
|
origMarkerY = cp.getCenterPixelY();
|
||||||
}
|
}
|
||||||
|
|
||||||
thread.startMoving(flat, flon, fZoom, true);
|
if (needMove) {
|
||||||
|
thread.startMoving(flat, flon, fZoom, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAddressLocation() {
|
private void setAddressLocation() {
|
||||||
|
@ -899,7 +914,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animated) {
|
if (animated) {
|
||||||
showOnMap(latlon, false, true);
|
showOnMap(latlon, false, true, true);
|
||||||
} else {
|
} else {
|
||||||
map.setLatLon(latlon.getLatitude(), latlon.getLongitude());
|
map.setLatLon(latlon.getLatitude(), latlon.getLongitude());
|
||||||
}
|
}
|
||||||
|
@ -951,22 +966,32 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
return (OsmandApplication) getActivity().getApplication();
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(final MapActivity mapActivity) {
|
public static boolean showInstance(final MapContextMenu menu, final MapActivity mapActivity) {
|
||||||
|
try {
|
||||||
|
|
||||||
int slideInAnim = R.anim.slide_in_bottom;
|
if (menu.getLatLon() == null) {
|
||||||
int slideOutAnim = R.anim.slide_out_bottom;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
MapContextMenu menu = mapActivity.getContextMenu();
|
int slideInAnim = R.anim.slide_in_bottom;
|
||||||
if (menu.isExtended()) {
|
int slideOutAnim = R.anim.slide_out_bottom;
|
||||||
slideInAnim = menu.getSlideInAnimation();
|
|
||||||
slideOutAnim = menu.getSlideOutAnimation();
|
if (menu.isExtended()) {
|
||||||
|
slideInAnim = menu.getSlideInAnimation();
|
||||||
|
slideOutAnim = menu.getSlideOutAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
MapContextMenuFragment fragment = new MapContextMenuFragment();
|
||||||
|
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||||
|
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||||
|
.add(R.id.fragmentContainer, fragment, TAG)
|
||||||
|
.addToBackStack(TAG).commitAllowingStateLoss();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapContextMenuFragment fragment = new MapContextMenuFragment();
|
|
||||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
|
||||||
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
|
||||||
.add(R.id.fragmentContainer, fragment, TAG)
|
|
||||||
.addToBackStack(TAG).commitAllowingStateLoss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//DownloadEvents
|
//DownloadEvents
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.views;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Cap;
|
import android.graphics.Paint.Cap;
|
||||||
import android.graphics.Paint.Join;
|
import android.graphics.Paint.Join;
|
||||||
|
@ -104,9 +105,9 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
osmandRegions = rm.getOsmandRegions();
|
osmandRegions = rm.getOsmandRegions();
|
||||||
|
|
||||||
paintDownloaded = getPaint(view.getResources().getColor(R.color.region_uptodate));
|
paintDownloaded = getPaint(view.getResources().getColor(R.color.region_uptodate));
|
||||||
paintOutdated = getPaint(view.getResources().getColor(R.color.region_updateable));
|
|
||||||
paintSelected = getPaint(view.getResources().getColor(R.color.region_selected));
|
paintSelected = getPaint(view.getResources().getColor(R.color.region_selected));
|
||||||
paintDownloading = getPaint(view.getResources().getColor(R.color.region_downloading));
|
paintDownloading = getPaint(view.getResources().getColor(R.color.region_downloading));
|
||||||
|
paintOutdated = getPaint(view.getResources().getColor(R.color.region_updateable));
|
||||||
|
|
||||||
textPaint = new TextPaint();
|
textPaint = new TextPaint();
|
||||||
final WindowManager wmgr = (WindowManager) view.getApplication().getSystemService(Context.WINDOW_SERVICE);
|
final WindowManager wmgr = (WindowManager) view.getApplication().getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
@ -122,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) {
|
||||||
|
@ -138,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -252,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();
|
||||||
|
@ -264,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());
|
||||||
|
@ -496,7 +497,8 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
|
|
||||||
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super DownloadMapObject> dataObjects) {
|
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super DownloadMapObject> dataObjects) {
|
||||||
int zoom = tb.getZoom();
|
int zoom = tb.getZoom();
|
||||||
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION && osmandRegions.isInitialized()) {
|
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION
|
||||||
|
&& data.results != null && osmandRegions.isInitialized()) {
|
||||||
LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y);
|
LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y);
|
||||||
int point31x = MapUtils.get31TileNumberX(pointLatLon.getLongitude());
|
int point31x = MapUtils.get31TileNumberX(pointLatLon.getLongitude());
|
||||||
int point31y = MapUtils.get31TileNumberY(pointLatLon.getLatitude());
|
int point31y = MapUtils.get31TileNumberY(pointLatLon.getLatitude());
|
||||||
|
|
Loading…
Reference in a new issue