Merge branch 'master' of github.com:osmandapp/Osmand
Conflicts: OsmAnd/res/values-ru/strings.xml OsmAnd/res/values-zh-rTW/strings.xml OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
This commit is contained in:
commit
91b55d06d7
9 changed files with 210 additions and 111 deletions
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?><resources>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
<string name="rendering_attr_hideProposed_name">Скрыть планируемые объекты</string>
|
<string name="rendering_attr_hideProposed_name">Скрыть планируемые объекты</string>
|
||||||
<string name="osmo_use_https_descr">Использовать безопасное подключение к серверу</string>
|
<string name="osmo_use_https_descr">Использовать безопасное подключение к серверу</string>
|
||||||
<string name="osmo_use_https">Использовать HTTPS</string>
|
<string name="osmo_use_https">Использовать HTTPS</string>
|
||||||
|
@ -1969,4 +1970,5 @@
|
||||||
<string name="other_menu_group">Прочее</string>
|
<string name="other_menu_group">Прочее</string>
|
||||||
<string name="plugins_menu_group">Плагины</string>
|
<string name="plugins_menu_group">Плагины</string>
|
||||||
<string name="map_legend">Легенда</string>
|
<string name="map_legend">Легенда</string>
|
||||||
</resources>
|
<string name="shared_string_update">Обновить</string>
|
||||||
|
</resources>
|
||||||
|
|
|
@ -1965,4 +1965,5 @@
|
||||||
|
|
||||||
|
|
||||||
<string name="shared_string_update">更新</string>
|
<string name="shared_string_update">更新</string>
|
||||||
</resources>
|
<string name="rendering_attr_hideProposed_name">隱藏已提出的物件</string>
|
||||||
|
</resources>
|
||||||
|
|
|
@ -61,9 +61,11 @@ import net.osmand.plus.base.FailSafeFuntions;
|
||||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.dialogs.WhatsNewDialogFragment;
|
import net.osmand.plus.dialogs.WhatsNewDialogFragment;
|
||||||
|
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
||||||
import net.osmand.plus.helpers.GpxImportHelper;
|
import net.osmand.plus.helpers.GpxImportHelper;
|
||||||
import net.osmand.plus.helpers.WakeLockHelper;
|
import net.osmand.plus.helpers.WakeLockHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||||
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
|
import net.osmand.plus.mapcontextmenu.editors.PointEditor;
|
||||||
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||||
|
@ -91,7 +93,7 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class MapActivity extends AccessibleActivity {
|
public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
||||||
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
|
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
|
||||||
private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2;
|
private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2;
|
||||||
private static final int LONG_KEYPRESS_DELAY = 500;
|
private static final int LONG_KEYPRESS_DELAY = 500;
|
||||||
|
@ -480,11 +482,16 @@ public class MapActivity extends AccessibleActivity {
|
||||||
app.getResourceManager().setBusyIndicator(new BusyIndicator(this, progress));
|
app.getResourceManager().setBusyIndicator(new BusyIndicator(this, progress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMapLayers().getDownloadedRegionsLayer().updateObjects();
|
||||||
|
|
||||||
OsmandPlugin.onMapActivityResume(this);
|
OsmandPlugin.onMapActivityResume(this);
|
||||||
mapView.refreshMap(true);
|
mapView.refreshMap(true);
|
||||||
if (atlasMapRendererView != null) {
|
if (atlasMapRendererView != null) {
|
||||||
atlasMapRendererView.handleOnResume();
|
atlasMapRendererView.handleOnResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.getDownloadThread().setUiActivity(this);
|
||||||
|
|
||||||
getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this);
|
getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this);
|
||||||
if (System.currentTimeMillis() - tm > 50) {
|
if (System.currentTimeMillis() - tm > 50) {
|
||||||
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
|
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
|
||||||
|
@ -710,6 +717,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
app.getDownloadThread().resetUiActivity(this);
|
||||||
if (atlasMapRendererView != null) {
|
if (atlasMapRendererView != null) {
|
||||||
atlasMapRendererView.handleOnPause();
|
atlasMapRendererView.handleOnPause();
|
||||||
}
|
}
|
||||||
|
@ -1021,4 +1029,38 @@ public class MapActivity extends AccessibleActivity {
|
||||||
openDrawer();
|
openDrawer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DownloadEvents
|
||||||
|
@Override
|
||||||
|
public void newDownloadIndexes() {
|
||||||
|
MapContextMenuFragment contextMenuFragment = getContextMenu().findMenuFragment();
|
||||||
|
if (contextMenuFragment != null) {
|
||||||
|
contextMenuFragment.newDownloadIndexes();
|
||||||
|
}
|
||||||
|
if (getMapLayers().getDownloadedRegionsLayer().updateObjects()) {
|
||||||
|
refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadInProgress() {
|
||||||
|
MapContextMenuFragment contextMenuFragment = getContextMenu().findMenuFragment();
|
||||||
|
if (contextMenuFragment != null) {
|
||||||
|
contextMenuFragment.downloadInProgress();
|
||||||
|
}
|
||||||
|
if (getMapLayers().getDownloadedRegionsLayer().updateObjects()) {
|
||||||
|
refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadHasFinished() {
|
||||||
|
MapContextMenuFragment contextMenuFragment = getContextMenu().findMenuFragment();
|
||||||
|
if (contextMenuFragment != null) {
|
||||||
|
contextMenuFragment.downloadHasFinished();
|
||||||
|
}
|
||||||
|
if (getMapLayers().getDownloadedRegionsLayer().updateObjects()) {
|
||||||
|
refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,5 +466,8 @@ public class MapActivityLayers {
|
||||||
public TransportInfoLayer getTransportInfoLayer() {
|
public TransportInfoLayer getTransportInfoLayer() {
|
||||||
return transportInfoLayer;
|
return transportInfoLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DownloadedRegionsLayer getDownloadedRegionsLayer() {
|
||||||
|
return downloadedRegionsLayer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,12 +232,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
String desc = getDescriptionName(fileName);
|
String desc = getDescriptionName(fileName);
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
return desc;
|
return desc;
|
||||||
} else if (this.isAudio()) {
|
return formatDateTime(ctx, file.lastModified());
|
||||||
return ctx.getString(R.string.shared_string_audio) + " " + formatDateTime(ctx, file.lastModified());
|
|
||||||
} else if (this.isVideo()) {
|
} else if (this.isVideo()) {
|
||||||
return ctx.getString(R.string.shared_string_video) + " " + formatDateTime(ctx, file.lastModified());
|
return formatDateTime(ctx, file.lastModified());
|
||||||
} else if (this.isPhoto()) {
|
} else if (this.isPhoto()) {
|
||||||
return ctx.getString(R.string.shared_string_photo) + " " + formatDateTime(ctx, file.lastModified());
|
return formatDateTime(ctx, file.lastModified());
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
private Map<String, String> indexFileNames = new LinkedHashMap<>();
|
private Map<String, String> indexFileNames = new LinkedHashMap<>();
|
||||||
private Map<String, String> indexActivatedFileNames = new LinkedHashMap<>();
|
private Map<String, String> indexActivatedFileNames = new LinkedHashMap<>();
|
||||||
private List<IndexItem> rawResources;
|
private List<IndexItem> rawResources;
|
||||||
|
private Map<WorldRegion, List<IndexItem> > groupByRegion;
|
||||||
private List<IndexItem> itemsToUpdate = new ArrayList<>();
|
private List<IndexItem> itemsToUpdate = new ArrayList<>();
|
||||||
public static final String WORLD_SEAMARKS_KEY = "world_seamarks_basemap";
|
public static final String WORLD_SEAMARKS_KEY = "world_seamarks_basemap";
|
||||||
|
|
||||||
|
@ -67,17 +68,14 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IndexItem> getIndexItems(String fileNamePrefix) {
|
public List<IndexItem> getIndexItems(WorldRegion region) {
|
||||||
List<IndexItem> res = new LinkedList<>();
|
if (groupByRegion != null) {
|
||||||
if (rawResources == null) {
|
List<IndexItem> res = groupByRegion.get(region);
|
||||||
return res;
|
if (res != null) {
|
||||||
}
|
return res;
|
||||||
for (IndexItem item : rawResources) {
|
|
||||||
if (item.getFileName().toLowerCase().startsWith(fileNamePrefix)) {
|
|
||||||
res.add(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLoadedFiles() {
|
public void updateLoadedFiles() {
|
||||||
|
@ -276,6 +274,8 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.groupByRegion = groupByRegion;
|
||||||
|
|
||||||
LinkedList<WorldRegion> queue = new LinkedList<WorldRegion>();
|
LinkedList<WorldRegion> queue = new LinkedList<WorldRegion>();
|
||||||
LinkedList<DownloadResourceGroup> parent = new LinkedList<DownloadResourceGroup>();
|
LinkedList<DownloadResourceGroup> parent = new LinkedList<DownloadResourceGroup>();
|
||||||
DownloadResourceGroup worldSubregions = new DownloadResourceGroup(this, DownloadResourceGroupType.SUBREGIONS);
|
DownloadResourceGroup worldSubregions = new DownloadResourceGroup(this, DownloadResourceGroupType.SUBREGIONS);
|
||||||
|
|
|
@ -550,18 +550,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
getMyApplication().getDownloadThread().setUiActivity(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
getMyApplication().getDownloadThread().resetUiActivity(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
|
@ -23,6 +23,8 @@ import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MapDataMenuController extends MenuController {
|
public class MapDataMenuController extends MenuController {
|
||||||
|
@ -146,11 +148,13 @@ public class MapDataMenuController extends MenuController {
|
||||||
@Override
|
@Override
|
||||||
public void updateData() {
|
public void updateData() {
|
||||||
if (indexItem == null) {
|
if (indexItem == null) {
|
||||||
otherIndexItems = downloadThread.getIndexes().getIndexItems(region.getRegionDownloadNameLC());
|
otherIndexItems = new LinkedList<>(downloadThread.getIndexes().getIndexItems(region));
|
||||||
for (IndexItem i : otherIndexItems) {
|
Iterator<IndexItem> it = otherIndexItems.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
IndexItem i = it.next();
|
||||||
if (i.getType() == DownloadActivityType.NORMAL_FILE) {
|
if (i.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||||
indexItem = i;
|
indexItem = i;
|
||||||
otherIndexItems.remove(i);
|
it.remove();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,6 +230,7 @@ public class MapDataMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
|
getMapActivity().getMapLayers().getDownloadedRegionsLayer().updateObjects();
|
||||||
getMapActivity().refreshMap();
|
getMapActivity().refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,10 @@ import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.map.OsmandRegions;
|
import net.osmand.map.OsmandRegions;
|
||||||
import net.osmand.map.WorldRegion;
|
import net.osmand.map.WorldRegion;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
|
import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProviderSelection;
|
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProviderSelection;
|
||||||
|
@ -39,44 +42,45 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
|
|
||||||
private static final int ZOOM_THRESHOLD = 2;
|
private static final int ZOOM_THRESHOLD = 2;
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
private Paint paint;
|
private Paint paintDownloaded;
|
||||||
|
private Path pathDownloaded;
|
||||||
private Paint paintSelected;
|
private Paint paintSelected;
|
||||||
private Path path;
|
|
||||||
private Path pathSelected;
|
private Path pathSelected;
|
||||||
|
private Paint paintDownloading;
|
||||||
|
private Path pathDownloading;
|
||||||
|
private Paint paintOutdated;
|
||||||
|
private Path pathOutdated;
|
||||||
private OsmandRegions osmandRegions;
|
private OsmandRegions osmandRegions;
|
||||||
|
|
||||||
|
|
||||||
private TextPaint textPaint;
|
private TextPaint textPaint;
|
||||||
private ResourceManager rm;
|
private ResourceManager rm;
|
||||||
|
|
||||||
private MapLayerData<List<BinaryMapDataObject>> data;
|
private MapLayerData<List<BinaryMapDataObject>> data;
|
||||||
private List<BinaryMapDataObject> selectedObjects;
|
private List<BinaryMapDataObject> outdatedObjects = new LinkedList<>();
|
||||||
|
private List<BinaryMapDataObject> downloadingObjects = new LinkedList<>();
|
||||||
|
private List<BinaryMapDataObject> selectedObjects = new LinkedList<>();
|
||||||
|
|
||||||
private static int ZOOM_TO_SHOW_MAP_NAMES = 6;
|
private static int ZOOM_TO_SHOW_MAP_NAMES = 6;
|
||||||
private static int ZOOM_AFTER_BASEMAP = 12;
|
private static int ZOOM_AFTER_BASEMAP = 12;
|
||||||
|
|
||||||
|
private static int ZOOM_TO_SHOW_BORDERS_ST = 5;
|
||||||
|
private static int ZOOM_TO_SHOW_BORDERS = 7;
|
||||||
|
private static int ZOOM_TO_SHOW_SELECTION_ST = 3;
|
||||||
|
private static int ZOOM_TO_SHOW_SELECTION = 10;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initLayer(final OsmandMapTileView view) {
|
public void initLayer(final OsmandMapTileView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
rm = view.getApplication().getResourceManager();
|
app = view.getApplication();
|
||||||
|
rm = app.getResourceManager();
|
||||||
osmandRegions = rm.getOsmandRegions();
|
osmandRegions = rm.getOsmandRegions();
|
||||||
|
|
||||||
paint = new Paint();
|
paintDownloaded = getPaint(Color.argb(100, 50, 200, 50));
|
||||||
paint.setStyle(Style.FILL_AND_STROKE);
|
paintSelected = getPaint(Color.argb(100, 255, 143, 0));
|
||||||
paint.setStrokeWidth(1);
|
paintDownloading = getPaint(Color.argb(40, 50, 200, 50));
|
||||||
paint.setColor(Color.argb(100, 50, 200, 50));
|
paintOutdated = getPaint(Color.argb(100, 0, 128, 255));
|
||||||
paint.setAntiAlias(true);
|
|
||||||
paint.setStrokeCap(Cap.ROUND);
|
|
||||||
paint.setStrokeJoin(Join.ROUND);
|
|
||||||
|
|
||||||
paintSelected = new Paint();
|
|
||||||
paintSelected.setStyle(Style.FILL_AND_STROKE);
|
|
||||||
paintSelected.setStrokeWidth(1);
|
|
||||||
paintSelected.setColor(Color.argb(100, 255, 143, 0));
|
|
||||||
paintSelected.setAntiAlias(true);
|
|
||||||
paintSelected.setStrokeCap(Cap.ROUND);
|
|
||||||
paintSelected.setStrokeJoin(Join.ROUND);
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -86,8 +90,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
textPaint.setAntiAlias(true);
|
textPaint.setAntiAlias(true);
|
||||||
textPaint.setTextAlign(Paint.Align.CENTER);
|
textPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
|
|
||||||
path = new Path();
|
pathDownloaded = new Path();
|
||||||
pathSelected = new Path();
|
pathSelected = new Path();
|
||||||
|
pathDownloading = new Path();
|
||||||
|
pathOutdated = new Path();
|
||||||
|
|
||||||
data = new MapLayerData<List<BinaryMapDataObject>>() {
|
data = new MapLayerData<List<BinaryMapDataObject>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,9 +103,9 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
|
public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
|
||||||
if (newBox.getZoom() < ZOOM_TO_SHOW_BORDERS) {
|
if (newBox.getZoom() < ZOOM_TO_SHOW_SELECTION) {
|
||||||
if (queriedData != null && queriedData.getZoom() < ZOOM_TO_SHOW_BORDERS) {
|
if (queriedData != null && queriedData.getZoom() < ZOOM_TO_SHOW_SELECTION) {
|
||||||
return queriedData != null && queriedData.containsTileBox(newBox);
|
return queriedData.containsTileBox(newBox);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -121,10 +128,17 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
private static int ZOOM_TO_SHOW_BORDERS_ST = 5;
|
|
||||||
private static int ZOOM_TO_SHOW_BORDERS = 7;
|
private Paint getPaint(int color) {
|
||||||
private static int ZOOM_TO_SHOW_SELECTION_ST = 3;
|
Paint paint = new Paint();
|
||||||
private static int ZOOM_TO_SHOW_SELECTION = 10;
|
paint.setStyle(Style.FILL_AND_STROKE);
|
||||||
|
paint.setStrokeWidth(1);
|
||||||
|
paint.setColor(color);
|
||||||
|
paint.setAntiAlias(true);
|
||||||
|
paint.setStrokeCap(Cap.ROUND);
|
||||||
|
paint.setStrokeJoin(Join.ROUND);
|
||||||
|
return paint;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
|
@ -133,47 +147,62 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// draw objects
|
// draw objects
|
||||||
final List<BinaryMapDataObject> currentObjects = data.results;
|
if (osmandRegions.isInitialized() && zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION) {
|
||||||
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized() &&
|
final List<BinaryMapDataObject> currentObjects = new LinkedList<>();
|
||||||
currentObjects != null) {
|
if (data.results != null) {
|
||||||
path.reset();
|
currentObjects.addAll(data.results);
|
||||||
for (BinaryMapDataObject o : currentObjects) {
|
|
||||||
String downloadName = osmandRegions.getDownloadName(o);
|
|
||||||
boolean downloaded = checkIfObjectDownloaded(downloadName);
|
|
||||||
if (!downloaded) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
double lat = MapUtils.get31LatitudeY(o.getPoint31YTile(0));
|
|
||||||
double lon = MapUtils.get31LongitudeX(o.getPoint31XTile(0));
|
|
||||||
path.moveTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
|
||||||
for (int j = 1; j < o.getPointsLength(); j++) {
|
|
||||||
lat = MapUtils.get31LatitudeY(o.getPoint31YTile(j));
|
|
||||||
lon = MapUtils.get31LongitudeX(o.getPoint31XTile(j));
|
|
||||||
path.lineTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
canvas.drawPath(path, paint);
|
final List<BinaryMapDataObject> downloadingObjects = new LinkedList<>(this.downloadingObjects);
|
||||||
}
|
final List<BinaryMapDataObject> outdatedObjects = new LinkedList<>(this.outdatedObjects);
|
||||||
|
final List<BinaryMapDataObject> selectedObjects = new LinkedList<>(this.selectedObjects);
|
||||||
|
|
||||||
final List<BinaryMapDataObject> selectedObjects = this.selectedObjects;
|
if (selectedObjects.size() > 0) {
|
||||||
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION && osmandRegions.isInitialized() &&
|
currentObjects.removeAll(selectedObjects);
|
||||||
selectedObjects != null) {
|
drawBorders(canvas, tileBox, selectedObjects, pathSelected, paintSelected);
|
||||||
pathSelected.reset();
|
}
|
||||||
for (BinaryMapDataObject o : selectedObjects) {
|
|
||||||
double lat = MapUtils.get31LatitudeY(o.getPoint31YTile(0));
|
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS) {
|
||||||
double lon = MapUtils.get31LongitudeX(o.getPoint31XTile(0));
|
downloadingObjects.removeAll(selectedObjects);
|
||||||
pathSelected.moveTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
if (downloadingObjects.size() > 0) {
|
||||||
for (int j = 1; j < o.getPointsLength(); j++) {
|
currentObjects.removeAll(downloadingObjects);
|
||||||
lat = MapUtils.get31LatitudeY(o.getPoint31YTile(j));
|
drawBorders(canvas, tileBox, downloadingObjects, pathDownloading, paintDownloading);
|
||||||
lon = MapUtils.get31LongitudeX(o.getPoint31XTile(j));
|
}
|
||||||
pathSelected.lineTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
outdatedObjects.removeAll(selectedObjects);
|
||||||
|
if (outdatedObjects.size() > 0) {
|
||||||
|
currentObjects.removeAll(outdatedObjects);
|
||||||
|
drawBorders(canvas, tileBox, outdatedObjects, pathOutdated, paintOutdated);
|
||||||
|
}
|
||||||
|
if (currentObjects.size() > 0) {
|
||||||
|
Iterator<BinaryMapDataObject> it = currentObjects.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
BinaryMapDataObject o = it.next();
|
||||||
|
boolean downloaded = checkIfObjectDownloaded(osmandRegions.getDownloadName(o));
|
||||||
|
if (!downloaded) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentObjects.size() > 0) {
|
||||||
|
drawBorders(canvas, tileBox, currentObjects, pathDownloaded, paintDownloaded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
canvas.drawPath(pathSelected, paintSelected);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawBorders(Canvas canvas, RotatedTileBox tileBox, final List<BinaryMapDataObject> objects, Path path, Paint paint) {
|
||||||
|
path.reset();
|
||||||
|
for (BinaryMapDataObject o : objects) {
|
||||||
|
double lat = MapUtils.get31LatitudeY(o.getPoint31YTile(0));
|
||||||
|
double lon = MapUtils.get31LongitudeX(o.getPoint31XTile(0));
|
||||||
|
path.moveTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
||||||
|
for (int j = 1; j < o.getPointsLength(); j++) {
|
||||||
|
lat = MapUtils.get31LatitudeY(o.getPoint31YTile(j));
|
||||||
|
lon = MapUtils.get31LongitudeX(o.getPoint31XTile(j));
|
||||||
|
path.lineTo(tileBox.getPixXFromLonNoRot(lon), tileBox.getPixYFromLatNoRot(lat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
canvas.drawPath(path, paint);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkIfObjectDownloaded(String downloadName) {
|
private boolean checkIfObjectDownloaded(String downloadName) {
|
||||||
final String regionName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName)
|
final String regionName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName)
|
||||||
|
@ -208,21 +237,62 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<BinaryMapDataObject> it = result.iterator();
|
Iterator<BinaryMapDataObject> it = result.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
BinaryMapDataObject o = it.next();
|
BinaryMapDataObject o = it.next();
|
||||||
if (tileBox.getZoom() < ZOOM_TO_SHOW_BORDERS) {
|
if (tileBox.getZoom() < ZOOM_TO_SHOW_SELECTION) {
|
||||||
//
|
//
|
||||||
} else {
|
} else {
|
||||||
if (!osmandRegions.contain(o, left / 2 + right / 2, top / 2 + bottom / 2)) {
|
if (!osmandRegions.contain(o, left / 2 + right / 2, top / 2 + bottom / 2)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateObjects(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean updateObjects() {
|
||||||
|
int zoom = view.getZoom();
|
||||||
|
if (osmandRegions.isInitialized() && data.results != null
|
||||||
|
&& zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION) {
|
||||||
|
return updateObjects(data.results);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean updateObjects(List<BinaryMapDataObject> objects) {
|
||||||
|
List<BinaryMapDataObject> outdatedObjects = new LinkedList<>();
|
||||||
|
List<BinaryMapDataObject> downloadingObjects = new LinkedList<>();
|
||||||
|
for (BinaryMapDataObject o : objects) {
|
||||||
|
String fullName = osmandRegions.getFullName(o);
|
||||||
|
WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||||
|
if (region != null && region.getRegionDownloadName() != null) {
|
||||||
|
List<IndexItem> indexItems = app.getDownloadThread().getIndexes().getIndexItems(region);
|
||||||
|
for (IndexItem item : indexItems) {
|
||||||
|
if (item.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||||
|
if (app.getDownloadThread().isDownloading(item)) {
|
||||||
|
downloadingObjects.add(o);
|
||||||
|
} else if (item.isOutdated()) {
|
||||||
|
outdatedObjects.add(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean res = !this.downloadingObjects.equals(downloadingObjects)
|
||||||
|
|| !this.outdatedObjects.equals(outdatedObjects);
|
||||||
|
|
||||||
|
this.downloadingObjects = downloadingObjects;
|
||||||
|
this.outdatedObjects = outdatedObjects;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkIfMapEmpty(RotatedTileBox tileBox) {
|
private boolean checkIfMapEmpty(RotatedTileBox tileBox) {
|
||||||
// RotatedTileBox cb = rm.getRenderer().getCheckedBox();
|
// RotatedTileBox cb = rm.getRenderer().getCheckedBox();
|
||||||
|
@ -388,18 +458,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
int point31x = MapUtils.get31TileNumberX(pointLatLon.getLongitude());
|
int point31x = MapUtils.get31TileNumberX(pointLatLon.getLongitude());
|
||||||
int point31y = MapUtils.get31TileNumberY(pointLatLon.getLatitude());
|
int point31y = MapUtils.get31TileNumberY(pointLatLon.getLatitude());
|
||||||
|
|
||||||
int left = MapUtils.get31TileNumberX(tb.getLeftTopLatLon().getLongitude());
|
List<BinaryMapDataObject> result = new LinkedList<>(data.results);
|
||||||
int right = MapUtils.get31TileNumberX(tb.getRightBottomLatLon().getLongitude());
|
|
||||||
int top = MapUtils.get31TileNumberY(tb.getLeftTopLatLon().getLatitude());
|
|
||||||
int bottom = MapUtils.get31TileNumberY(tb.getRightBottomLatLon().getLatitude());
|
|
||||||
|
|
||||||
List<BinaryMapDataObject> result;
|
|
||||||
try {
|
|
||||||
result = osmandRegions.queryBbox(left, right, top, bottom);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator<BinaryMapDataObject> it = result.iterator();
|
Iterator<BinaryMapDataObject> it = result.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
BinaryMapDataObject o = it.next();
|
BinaryMapDataObject o = it.next();
|
||||||
|
@ -422,7 +481,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
String fullName = osmandRegions.getFullName((BinaryMapDataObject) o);
|
String fullName = osmandRegions.getFullName((BinaryMapDataObject) o);
|
||||||
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
return region.getLevel();
|
return region.getLevel() - 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -432,7 +491,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
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) {
|
if (selectedObjects. size() > 0) {
|
||||||
list.addAll(selectedObjects);
|
list.addAll(selectedObjects);
|
||||||
}
|
}
|
||||||
list.add((BinaryMapDataObject) o);
|
list.add((BinaryMapDataObject) o);
|
||||||
|
@ -442,6 +501,6 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearSelectedObject() {
|
public void clearSelectedObject() {
|
||||||
selectedObjects = null;
|
selectedObjects = new LinkedList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue