Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d98b7a3ba3
6 changed files with 57 additions and 4 deletions
|
@ -158,4 +158,13 @@ public class WorldRegion {
|
||||||
rd.superregion = this;
|
rd.superregion = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
int res = 0;
|
||||||
|
WorldRegion parent = superregion;
|
||||||
|
while (parent != null) {
|
||||||
|
parent = parent.superregion;
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -17,6 +17,7 @@ import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
|
|
||||||
public class MapDataMenuController extends MenuController {
|
public class MapDataMenuController extends MenuController {
|
||||||
private WorldRegion region;
|
private WorldRegion region;
|
||||||
|
private String regionName;
|
||||||
|
|
||||||
public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, final BinaryMapDataObject dataObject) {
|
public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, final BinaryMapDataObject dataObject) {
|
||||||
super(new MenuBuilder(app), mapActivity);
|
super(new MenuBuilder(app), mapActivity);
|
||||||
|
@ -24,6 +25,11 @@ public class MapDataMenuController extends MenuController {
|
||||||
String fullName = osmandRegions.getFullName(dataObject);
|
String fullName = osmandRegions.getFullName(dataObject);
|
||||||
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||||
this.region = region;
|
this.region = region;
|
||||||
|
if (region != null) {
|
||||||
|
regionName = region.getLocaleName();
|
||||||
|
} else {
|
||||||
|
regionName = dataObject.getName();
|
||||||
|
}
|
||||||
titleButtonController = new TitleButtonController() {
|
titleButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed() {
|
public void buttonPressed() {
|
||||||
|
@ -31,7 +37,7 @@ public class MapDataMenuController extends MenuController {
|
||||||
|
|
||||||
final Intent intent = new Intent(getMapActivity(), getMapActivity().getMyApplication()
|
final Intent intent = new Intent(getMapActivity(), getMapActivity().getMyApplication()
|
||||||
.getAppCustomization().getDownloadIndexActivity());
|
.getAppCustomization().getDownloadIndexActivity());
|
||||||
intent.putExtra(DownloadActivity.FILTER_KEY, region.getLocaleName());
|
intent.putExtra(DownloadActivity.FILTER_KEY, regionName);
|
||||||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||||
getMapActivity().startActivity(intent);
|
getMapActivity().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -57,12 +63,12 @@ public class MapDataMenuController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNameStr() {
|
public String getNameStr() {
|
||||||
return region.getLocaleName();
|
return regionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeStr() {
|
public String getTypeStr() {
|
||||||
if (region.getSuperregion() != null) {
|
if (region != null && region.getSuperregion() != null) {
|
||||||
return region.getSuperregion().getLocaleName() + "\n";
|
return region.getSuperregion().getLocaleName() + "\n";
|
||||||
} else {
|
} else {
|
||||||
return getMapActivity().getString(R.string.shared_string_map) + "\n";
|
return getMapActivity().getString(R.string.shared_string_map) + "\n";
|
||||||
|
|
|
@ -103,11 +103,14 @@ public class ObjectSelectionMenu extends BaseMenuController {
|
||||||
|
|
||||||
private void createCollection(Map<Object, IContextMenuProvider> selectedObjects) {
|
private void createCollection(Map<Object, IContextMenuProvider> selectedObjects) {
|
||||||
this.selectedObjects.putAll(selectedObjects);
|
this.selectedObjects.putAll(selectedObjects);
|
||||||
|
int order = Integer.MAX_VALUE;
|
||||||
|
MenuObject topObject = null;
|
||||||
for (Map.Entry<Object, IContextMenuProvider> e : selectedObjects.entrySet()) {
|
for (Map.Entry<Object, IContextMenuProvider> e : selectedObjects.entrySet()) {
|
||||||
Object selectedObj = e.getKey();
|
Object selectedObj = e.getKey();
|
||||||
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
|
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
|
||||||
LatLon ll = null;
|
LatLon ll = null;
|
||||||
PointDescription pointDescription = null;
|
PointDescription pointDescription = null;
|
||||||
|
|
||||||
if (contextObject != null) {
|
if (contextObject != null) {
|
||||||
ll = contextObject.getObjectLocation(selectedObj);
|
ll = contextObject.getObjectLocation(selectedObj);
|
||||||
pointDescription = contextObject.getObjectName(selectedObj);
|
pointDescription = contextObject.getObjectName(selectedObj);
|
||||||
|
@ -121,13 +124,27 @@ public class ObjectSelectionMenu extends BaseMenuController {
|
||||||
|
|
||||||
MenuObject menuObject = new MenuObject(ll, pointDescription, selectedObj, getMapActivity());
|
MenuObject menuObject = new MenuObject(ll, pointDescription, selectedObj, getMapActivity());
|
||||||
objects.add(menuObject);
|
objects.add(menuObject);
|
||||||
|
|
||||||
|
if (contextObject instanceof ContextMenuLayer.IContextMenuProviderSelection) {
|
||||||
|
int i = ((ContextMenuLayer.IContextMenuProviderSelection) contextObject).getOrder(selectedObj);
|
||||||
|
if (i < order) {
|
||||||
|
topObject = menuObject;
|
||||||
|
order = i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(objects, new Comparator<MenuObject>() {
|
Collections.sort(objects, new Comparator<MenuObject>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(MenuObject obj1, MenuObject obj2) {
|
public int compare(MenuObject obj1, MenuObject obj2) {
|
||||||
return obj1.getTitleStr().compareToIgnoreCase(obj2.getTitleStr());
|
return obj1.getTitleStr().compareToIgnoreCase(obj2.getTitleStr());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (topObject != null) {
|
||||||
|
objects.remove(topObject);
|
||||||
|
objects.add(0, topObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void show(LatLon latLon, Map<Object, IContextMenuProvider> selectedObjects, MapActivity mapActivity) {
|
public static void show(LatLon latLon, Map<Object, IContextMenuProvider> selectedObjects, MapActivity mapActivity) {
|
||||||
|
|
|
@ -400,6 +400,11 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
|
||||||
}, 350);
|
}, 350);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder(Object o) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedObject(Object o) {
|
public void setSelectedObject(Object o) {
|
||||||
if(o instanceof OsMoDevice) {
|
if(o instanceof OsMoDevice) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
public interface IContextMenuProviderSelection {
|
public interface IContextMenuProviderSelection {
|
||||||
|
|
||||||
|
int getOrder(Object o);
|
||||||
void setSelectedObject(Object o);
|
void setSelectedObject(Object o);
|
||||||
void clearSelectedObject();
|
void clearSelectedObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,10 +403,25 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder(Object o) {
|
||||||
|
if (o instanceof BinaryMapDataObject) {
|
||||||
|
String fullName = osmandRegions.getFullName((BinaryMapDataObject) o);
|
||||||
|
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||||
|
if (region != null) {
|
||||||
|
return region.getLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedObject(Object o) {
|
public void setSelectedObject(Object o) {
|
||||||
if (o instanceof BinaryMapDataObject) {
|
if (o instanceof BinaryMapDataObject) {
|
||||||
List<BinaryMapDataObject> list = new LinkedList<>();
|
List<BinaryMapDataObject> list = new LinkedList<>();
|
||||||
|
if (selectedObjects != null) {
|
||||||
|
list.addAll(selectedObjects);
|
||||||
|
}
|
||||||
list.add((BinaryMapDataObject) o);
|
list.add((BinaryMapDataObject) o);
|
||||||
selectedObjects = list;
|
selectedObjects = list;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue