Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bfb4989217
3 changed files with 53 additions and 13 deletions
|
@ -20,6 +20,7 @@ import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.NotificationCompat.Builder;
|
import android.support.v4.app.NotificationCompat.Builder;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.NotificationCompat;
|
import android.support.v7.app.NotificationCompat;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -176,8 +177,17 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
||||||
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
mapView = new OsmandMapTileView(this, getWindow().getDecorView().getWidth(),
|
int statusBarHeight = 0;
|
||||||
getWindow().getDecorView().getHeight());
|
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||||
|
if (resourceId > 0) {
|
||||||
|
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
||||||
|
}
|
||||||
|
DisplayMetrics dm = new DisplayMetrics();
|
||||||
|
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||||
|
int w = dm.widthPixels;
|
||||||
|
int h = dm.heightPixels - statusBarHeight;
|
||||||
|
|
||||||
|
mapView = new OsmandMapTileView(this, w, h);
|
||||||
if (app.getAppInitializer().checkAppVersionChanged(this)) {
|
if (app.getAppInitializer().checkAppVersionChanged(this)) {
|
||||||
new WhatsNewDialogFragment().show(getSupportFragmentManager(), null);
|
new WhatsNewDialogFragment().show(getSupportFragmentManager(), null);
|
||||||
}
|
}
|
||||||
|
@ -552,22 +562,24 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
||||||
if (dashboardOnMap.isVisible()) {
|
if (dashboardOnMap.isVisible()) {
|
||||||
dashboardOnMap.hideDashboard();
|
dashboardOnMap.hideDashboard();
|
||||||
}
|
}
|
||||||
|
// remember if map should come back to isMapLinkedToLocation=true
|
||||||
|
mapViewTrackingUtilities.setMapLinkedToLocation(false);
|
||||||
|
|
||||||
if (mapLabelToShow != null && !mapLabelToShow.contextMenuDisabled()) {
|
if (mapLabelToShow != null && !mapLabelToShow.contextMenuDisabled()) {
|
||||||
mapContextMenu.setMapCenter(latLonToShow);
|
mapContextMenu.setMapCenter(latLonToShow);
|
||||||
mapContextMenu.setMapPosition(mapView.getMapPosition());
|
mapContextMenu.setMapPosition(mapView.getMapPosition());
|
||||||
|
mapContextMenu.setCenterMarker(true);
|
||||||
|
mapContextMenu.setMapZoom(settings.getMapZoomToShow());
|
||||||
if (mapLayers.getMapControlsLayer().getMapRouteInfoMenu().isVisible()) {
|
if (mapLayers.getMapControlsLayer().getMapRouteInfoMenu().isVisible()) {
|
||||||
mapContextMenu.showMinimized(latLonToShow, mapLabelToShow, toShow);
|
mapContextMenu.showMinimized(latLonToShow, mapLabelToShow, toShow);
|
||||||
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateMenu();
|
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateMenu();
|
||||||
} else {
|
} else {
|
||||||
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
||||||
}
|
}
|
||||||
}
|
} else if (!latLonToShow.equals(cur)) {
|
||||||
if (!latLonToShow.equals(cur)) {
|
|
||||||
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(),
|
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(),
|
||||||
latLonToShow.getLongitude(), settings.getMapZoomToShow(), true);
|
latLonToShow.getLongitude(), settings.getMapZoomToShow(), true);
|
||||||
}
|
}
|
||||||
// remember if map should come back to isMapLinkedToLocation=true
|
|
||||||
mapViewTrackingUtilities.setMapLinkedToLocation(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
|
|
||||||
private LatLon mapCenter;
|
private LatLon mapCenter;
|
||||||
private int mapPosition = 0;
|
private int mapPosition = 0;
|
||||||
|
private boolean centerMarker;
|
||||||
|
private int mapZoom;
|
||||||
|
|
||||||
private LatLon myLocation;
|
private LatLon myLocation;
|
||||||
private Float heading;
|
private Float heading;
|
||||||
|
@ -149,6 +151,18 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
this.mapCenter = mapCenter;
|
this.mapCenter = mapCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCenterMarker(boolean centerMarker) {
|
||||||
|
this.centerMarker = centerMarker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMapZoom() {
|
||||||
|
return mapZoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapZoom(int mapZoom) {
|
||||||
|
this.mapZoom = mapZoom;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateMapCenter(LatLon mapCenter) {
|
public void updateMapCenter(LatLon mapCenter) {
|
||||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||||
if (fragmentRef != null) {
|
if (fragmentRef != null) {
|
||||||
|
@ -261,9 +275,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
|
|
||||||
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)) {
|
||||||
if (!MapContextMenuFragment.showInstance(this, mapActivity, false)) {
|
if (!MapContextMenuFragment.showInstance(this, mapActivity, centerMarker)) {
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
centerMarker = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
private boolean moving;
|
private boolean moving;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private boolean centered;
|
private boolean centered;
|
||||||
|
private boolean initLayout = true;
|
||||||
|
|
||||||
private float skipHalfScreenStateLimit;
|
private float skipHalfScreenStateLimit;
|
||||||
|
|
||||||
|
@ -705,6 +706,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||||
}
|
}
|
||||||
menu.setMapCenter(null);
|
menu.setMapCenter(null);
|
||||||
|
menu.setMapZoom(0);
|
||||||
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
|
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,6 +768,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
if (!moving) {
|
if (!moving) {
|
||||||
doLayoutMenu();
|
doLayoutMenu();
|
||||||
}
|
}
|
||||||
|
initLayout = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -776,15 +779,24 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
showOnMap(menu.getLatLon(), true, true, false);
|
showOnMap(menu.getLatLon(), true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getZoom() {
|
||||||
|
int zoom = menu.getMapZoom();
|
||||||
|
if (zoom == 0) {
|
||||||
|
zoom = map.getZoom();
|
||||||
|
}
|
||||||
|
return zoom;
|
||||||
|
}
|
||||||
|
|
||||||
private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted) {
|
private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted) {
|
||||||
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
|
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
|
||||||
int fZoom = map.getZoom();
|
int fZoom = getZoom();
|
||||||
double flat = latLon.getLatitude();
|
double flat = latLon.getLatitude();
|
||||||
double flon = latLon.getLongitude();
|
double flon = latLon.getLongitude();
|
||||||
|
|
||||||
RotatedTileBox cp = map.getCurrentRotatedTileBox().copy();
|
RotatedTileBox cp = map.getCurrentRotatedTileBox().copy();
|
||||||
cp.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f);
|
cp.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f);
|
||||||
cp.setLatLonCenter(flat, flon);
|
cp.setLatLonCenter(flat, flon);
|
||||||
|
cp.setZoom(fZoom);
|
||||||
flat = cp.getLatFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
flat = cp.getLatFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
||||||
flon = cp.getLonFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
flon = cp.getLonFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
||||||
|
|
||||||
|
@ -796,7 +808,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alreadyAdjusted) {
|
if (!alreadyAdjusted) {
|
||||||
LatLon adjustedLatLon = getAdjustedMarkerLocation(getPosY(), new LatLon(flat, flon), true);
|
LatLon adjustedLatLon = getAdjustedMarkerLocation(getPosY(), new LatLon(flat, flon), true, fZoom);
|
||||||
flat = adjustedLatLon.getLatitude();
|
flat = adjustedLatLon.getLatitude();
|
||||||
flon = adjustedLatLon.getLongitude();
|
flon = adjustedLatLon.getLongitude();
|
||||||
}
|
}
|
||||||
|
@ -937,7 +949,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustMapPosition(int y, boolean animated, boolean center) {
|
private void adjustMapPosition(int y, boolean animated, boolean center) {
|
||||||
LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center);
|
map.getAnimatedDraggingThread().stopAnimatingSync();
|
||||||
|
LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, getZoom());
|
||||||
|
|
||||||
if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude()) {
|
if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude()) {
|
||||||
return;
|
return;
|
||||||
|
@ -950,11 +963,12 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LatLon getAdjustedMarkerLocation(int y, LatLon reqMarkerLocation, boolean center) {
|
private LatLon getAdjustedMarkerLocation(int y, LatLon reqMarkerLocation, boolean center, int zoom) {
|
||||||
double markerLat = reqMarkerLocation.getLatitude();
|
double markerLat = reqMarkerLocation.getLatitude();
|
||||||
double markerLon = reqMarkerLocation.getLongitude();
|
double markerLon = reqMarkerLocation.getLongitude();
|
||||||
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
|
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
|
||||||
box.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f);
|
box.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f);
|
||||||
|
box.setZoom(zoom);
|
||||||
int markerMapCenterX = (int)box.getPixXFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
int markerMapCenterX = (int)box.getPixXFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||||
int markerMapCenterY = (int)box.getPixYFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
int markerMapCenterY = (int)box.getPixYFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||||
float cpyOrig = box.getCenterPixelPoint().y;
|
float cpyOrig = box.getCenterPixelPoint().y;
|
||||||
|
@ -1021,9 +1035,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
|
|
||||||
private void doLayoutMenu() {
|
private void doLayoutMenu() {
|
||||||
final int posY = getPosY();
|
final int posY = getPosY();
|
||||||
setViewY(posY, true, true);
|
setViewY(posY, true, !initLayout || !centered);
|
||||||
updateMainViewLayout(posY);
|
updateMainViewLayout(posY);
|
||||||
// centering = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dismissMenu() {
|
public void dismissMenu() {
|
||||||
|
|
Loading…
Reference in a new issue