Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0ed6dc5a13
4 changed files with 77 additions and 24 deletions
|
@ -17,6 +17,7 @@ import android.os.Message;
|
|||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -545,8 +546,8 @@ public class MapActivity extends AccessibleActivity {
|
|||
dashboardOnMap.hideDashboard();
|
||||
}
|
||||
if (mapLabelToShow != null) {
|
||||
contextMenuOnMap.setMapCenter(latLonToShow);
|
||||
contextMenuOnMap.show(latLonToShow, mapLabelToShow, toShow);
|
||||
//mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLabelToShow.getFullPlainName(this));
|
||||
}
|
||||
if (!latLonToShow.equals(cur)) {
|
||||
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(),
|
||||
|
|
|
@ -7,9 +7,11 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
|
@ -34,6 +36,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.activities.OsmAndListFragment;
|
||||
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -190,6 +193,22 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
|
|||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
|
||||
private void selectModelOptions(final HistoryEntry model, View v) {
|
||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||
MenuItem item = optionsMenu.getMenu().add(
|
||||
R.string.shared_string_delete).setIcon(
|
||||
getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
helper.remove(model);
|
||||
historyAdapter.remove(model);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
optionsMenu.show();
|
||||
}
|
||||
|
||||
class HistoryAdapter extends ArrayAdapter<HistoryEntry> {
|
||||
private LatLon location;
|
||||
|
||||
|
@ -222,7 +241,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
|
|||
options.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectModel(historyEntry);
|
||||
selectModelOptions(historyEntry, v);
|
||||
}
|
||||
});
|
||||
return row;
|
||||
|
|
|
@ -37,6 +37,8 @@ public class MapContextMenu {
|
|||
private Object object;
|
||||
MenuController menuController;
|
||||
|
||||
private LatLon mapCenter;
|
||||
|
||||
private int leftIconId;
|
||||
private Drawable leftIcon;
|
||||
private String nameStr;
|
||||
|
@ -55,6 +57,7 @@ public class MapContextMenu {
|
|||
private static final String KEY_CTX_MENU_TYPE_STR = "key_ctx_menu_type_str";
|
||||
private static final String KEY_CTX_MENU_STREET_STR = "key_ctx_menu_street_str";
|
||||
private static final String KEY_CTX_MENU_ADDR_UNKNOWN = "key_ctx_menu_addr_unknown";
|
||||
private static final String KEY_CTX_MENU_MAP_CENTER = "key_ctx_menu_map_center";
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
|
@ -68,6 +71,14 @@ public class MapContextMenu {
|
|||
return latLon;
|
||||
}
|
||||
|
||||
public LatLon getMapCenter() {
|
||||
return mapCenter;
|
||||
}
|
||||
|
||||
public void setMapCenter(LatLon mapCenter) {
|
||||
this.mapCenter = mapCenter;
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
return pointDescription;
|
||||
}
|
||||
|
@ -388,6 +399,7 @@ public class MapContextMenu {
|
|||
bundle.putString(KEY_CTX_MENU_TYPE_STR, typeStr);
|
||||
bundle.putString(KEY_CTX_MENU_STREET_STR, streetStr);
|
||||
bundle.putString(KEY_CTX_MENU_ADDR_UNKNOWN, Boolean.toString(addressUnknown));
|
||||
bundle.putSerializable(KEY_CTX_MENU_MAP_CENTER, mapCenter);
|
||||
}
|
||||
|
||||
public void restoreMenuState(Bundle bundle) {
|
||||
|
@ -406,6 +418,11 @@ public class MapContextMenu {
|
|||
active = false;
|
||||
}
|
||||
|
||||
Object mapCenterObj = bundle.getSerializable(KEY_CTX_MENU_MAP_CENTER);
|
||||
if (mapCenterObj != null) {
|
||||
mapCenter = (LatLon) mapCenterObj;
|
||||
}
|
||||
|
||||
nameStr = bundle.getString(KEY_CTX_MENU_NAME_STR);
|
||||
typeStr = bundle.getString(KEY_CTX_MENU_TYPE_STR);
|
||||
streetStr = bundle.getString(KEY_CTX_MENU_STREET_STR);
|
||||
|
|
|
@ -74,10 +74,10 @@ public class MapContextMenuFragment extends Fragment {
|
|||
private int markerPaddingXPx;
|
||||
|
||||
private OsmandMapTileView map;
|
||||
private double origMapCenterLat;
|
||||
private double origMapCenterLon;
|
||||
private LatLon mapCenter;
|
||||
private int origMarkerX;
|
||||
private int origMarkerY;
|
||||
private boolean customMapCenter;
|
||||
|
||||
private class SingleTapConfirm implements OnGestureListener {
|
||||
|
||||
|
@ -135,13 +135,20 @@ public class MapContextMenuFragment extends Fragment {
|
|||
}
|
||||
|
||||
map = getMapActivity().getMapView();
|
||||
origMapCenterLat = map.getLatitude();
|
||||
origMapCenterLon = map.getLongitude();
|
||||
RotatedTileBox box = map.getCurrentRotatedTileBox();
|
||||
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
|
||||
customMapCenter = menu.getMapCenter() != null;
|
||||
if (!customMapCenter) {
|
||||
mapCenter = box.getCenterLatLon();
|
||||
menu.setMapCenter(mapCenter);
|
||||
double markerLat = menu.getLatLon().getLatitude();
|
||||
double markerLon = menu.getLatLon().getLongitude();
|
||||
origMarkerX = (int)box.getPixXFromLatLon(markerLat, markerLon);
|
||||
origMarkerY = (int)box.getPixYFromLatLon(markerLat, markerLon);
|
||||
} else {
|
||||
mapCenter = menu.getMapCenter();
|
||||
origMarkerX = box.getCenterPixelX();
|
||||
origMarkerY = box.getCenterPixelY();
|
||||
}
|
||||
|
||||
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
|
||||
mainView = view.findViewById(R.id.context_menu_main);
|
||||
|
@ -409,7 +416,8 @@ public class MapContextMenuFragment extends Fragment {
|
|||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
map.setLatLon(origMapCenterLat, origMapCenterLon);
|
||||
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
|
||||
menu.setMapCenter(null);
|
||||
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
|
||||
}
|
||||
|
||||
|
@ -447,6 +455,11 @@ public class MapContextMenuFragment extends Fragment {
|
|||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
|
||||
if (origMarkerX == 0 && origMarkerY == 0) {
|
||||
origMarkerX = view.getWidth() / 2;
|
||||
origMarkerY = view.getHeight() / 2;
|
||||
}
|
||||
|
||||
doLayoutMenu();
|
||||
}
|
||||
|
||||
|
@ -454,25 +467,24 @@ public class MapContextMenuFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void showOnMap(LatLon latLon, boolean updateCoords, boolean ignoreCoef) {
|
||||
MapActivity ctx = getMapActivity();
|
||||
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
|
||||
int fZoom = ctx.getMapView().getZoom();
|
||||
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
|
||||
int fZoom = map.getZoom();
|
||||
double flat = latLon.getLatitude();
|
||||
double flon = latLon.getLongitude();
|
||||
|
||||
RotatedTileBox cp = ctx.getMapView().getCurrentRotatedTileBox().copy();
|
||||
RotatedTileBox cp = map.getCurrentRotatedTileBox().copy();
|
||||
if (ignoreCoef) {
|
||||
cp.setCenterLocation(0.5f, 0.5f);
|
||||
} else {
|
||||
cp.setCenterLocation(0.5f, ctx.getMapView().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);
|
||||
flat = cp.getLatFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
||||
flon = cp.getLonFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
|
||||
|
||||
if (updateCoords) {
|
||||
origMapCenterLat = flat;
|
||||
origMapCenterLon = flon;
|
||||
mapCenter = new LatLon(flat, flon);
|
||||
menu.setMapCenter(mapCenter);
|
||||
origMarkerX = cp.getCenterPixelX();
|
||||
origMarkerY = cp.getCenterPixelY();
|
||||
}
|
||||
|
@ -558,15 +570,19 @@ public class MapContextMenuFragment extends Fragment {
|
|||
mainView.setPadding(0, y, 0, 0);
|
||||
fabView.setPadding(0, getFabY(y), 0, 0);
|
||||
}
|
||||
if (!customMapCenter) {
|
||||
adjustMapPosition(y, animated);
|
||||
} else {
|
||||
customMapCenter = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void adjustMapPosition(int y, boolean animated) {
|
||||
double markerLat = menu.getLatLon().getLatitude();
|
||||
double markerLon = menu.getLatLon().getLongitude();
|
||||
RotatedTileBox box = map.getCurrentRotatedTileBox();
|
||||
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
|
||||
|
||||
LatLon latlon = new LatLon(origMapCenterLat, origMapCenterLon);
|
||||
LatLon latlon = mapCenter;
|
||||
if (menu.isLandscapeLayout()) {
|
||||
int markerX = (int)box.getPixXFromLatLon(markerLat, markerLon);
|
||||
int x = dpToPx(menu.getLandscapeWidthDp());
|
||||
|
|
Loading…
Reference in a new issue