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() {
|
||||
if (!isVisible()) {
|
||||
MapContextMenuFragment.showInstance(mapActivity);
|
||||
if (!MapContextMenuFragment.showInstance(this, mapActivity)) {
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void show(LatLon latLon, PointDescription pointDescription, Object 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() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(defaultVls[0] == 0) {
|
||||
|
|
|
@ -142,6 +142,12 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
|
||||
|
||||
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();
|
||||
rightTitleButtonController = menu.getRightTitleButtonController();
|
||||
topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
||||
|
@ -166,9 +172,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||
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
|
||||
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
||||
if (leftTitleButtonController != null) {
|
||||
|
@ -244,14 +247,20 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
private float maxVelocityY;
|
||||
|
||||
private boolean hasMoved;
|
||||
private boolean centered;
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent 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) {
|
||||
applyPosY(getViewY(), false, false, 0, 0);
|
||||
applyPosY(posY, false, false, 0, 0);
|
||||
}
|
||||
openMenuHalfScreen();
|
||||
return true;
|
||||
|
@ -297,7 +306,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
int currentY = getViewY();
|
||||
|
||||
|
||||
slidingUp = 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() {
|
||||
changeMenuState(getViewY(), true, true, false);
|
||||
}
|
||||
|
||||
|
||||
public void openMenuHalfScreen() {
|
||||
int oldMenuState = menu.getCurrentMenuState();
|
||||
if(oldMenuState == MenuState.HEADER_ONLY) {
|
||||
|
@ -455,26 +464,24 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
.setDuration(200)
|
||||
.setInterpolator(new DecelerateInterpolator())
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
|
||||
boolean canceled = false;
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
if (needCloseMenu) {
|
||||
menu.close();
|
||||
} else {
|
||||
updateMainViewLayout(posY);
|
||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
||||
}
|
||||
}
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (needCloseMenu) {
|
||||
menu.close();
|
||||
} else {
|
||||
updateMainViewLayout(posY);
|
||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
||||
if (!canceled) {
|
||||
if (needCloseMenu) {
|
||||
menu.close();
|
||||
} else {
|
||||
updateMainViewLayout(posY);
|
||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -628,6 +635,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (!menu.isActive()) {
|
||||
dismissMenu();
|
||||
return;
|
||||
}
|
||||
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
|
||||
if (menu.displayDistanceDirection()) {
|
||||
getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu);
|
||||
|
@ -643,7 +654,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||
if (mapCenter != null) {
|
||||
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||
}
|
||||
menu.setMapCenter(null);
|
||||
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();
|
||||
int fZoom = map.getZoom();
|
||||
double flat = latLon.getLatitude();
|
||||
|
@ -732,7 +745,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
origMarkerY = cp.getCenterPixelY();
|
||||
}
|
||||
|
||||
thread.startMoving(flat, flon, fZoom, true);
|
||||
if (needMove) {
|
||||
thread.startMoving(flat, flon, fZoom, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAddressLocation() {
|
||||
|
@ -899,7 +914,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
|
||||
if (animated) {
|
||||
showOnMap(latlon, false, true);
|
||||
showOnMap(latlon, false, true, true);
|
||||
} else {
|
||||
map.setLatLon(latlon.getLatitude(), latlon.getLongitude());
|
||||
}
|
||||
|
@ -951,22 +966,32 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
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;
|
||||
int slideOutAnim = R.anim.slide_out_bottom;
|
||||
if (menu.getLatLon() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MapContextMenu menu = mapActivity.getContextMenu();
|
||||
if (menu.isExtended()) {
|
||||
slideInAnim = menu.getSlideInAnimation();
|
||||
slideOutAnim = menu.getSlideOutAnimation();
|
||||
int slideInAnim = R.anim.slide_in_bottom;
|
||||
int slideOutAnim = R.anim.slide_out_bottom;
|
||||
|
||||
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
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.views;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Cap;
|
||||
import android.graphics.Paint.Join;
|
||||
|
@ -104,9 +105,9 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
osmandRegions = rm.getOsmandRegions();
|
||||
|
||||
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));
|
||||
paintDownloading = getPaint(view.getResources().getColor(R.color.region_downloading));
|
||||
paintOutdated = getPaint(view.getResources().getColor(R.color.region_updateable));
|
||||
|
||||
textPaint = new TextPaint();
|
||||
final WindowManager wmgr = (WindowManager) view.getApplication().getSystemService(Context.WINDOW_SERVICE);
|
||||
|
@ -122,12 +123,12 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
pathOutdated = new Path();
|
||||
|
||||
data = new MapLayerData<List<BinaryMapDataObject>>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void layerOnPostExecute() {
|
||||
view.refreshMap();
|
||||
}
|
||||
|
||||
|
||||
public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
|
||||
if (newBox.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();
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<BinaryMapDataObject> calculateResult(RotatedTileBox tileBox) {
|
||||
return queryData(tileBox);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -252,11 +253,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private List<BinaryMapDataObject> queryData(RotatedTileBox tileBox) {
|
||||
if (tileBox.getZoom() >= ZOOM_AFTER_BASEMAP) {
|
||||
if(!checkIfMapEmpty(tileBox)) {
|
||||
return Collections.emptyList();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
LatLon lt = tileBox.getLeftTopLatLon();
|
||||
|
@ -264,7 +265,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
// if (tileBox.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) {
|
||||
// lt = rb = tileBox.getCenterLatLon();
|
||||
// }
|
||||
|
||||
|
||||
List<BinaryMapDataObject> result = null;
|
||||
int left = MapUtils.get31TileNumberX(lt.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) {
|
||||
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);
|
||||
int point31x = MapUtils.get31TileNumberX(pointLatLon.getLongitude());
|
||||
int point31y = MapUtils.get31TileNumberY(pointLatLon.getLatitude());
|
||||
|
|
Loading…
Reference in a new issue