Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-07-29 20:01:55 +02:00
commit 8dce0fc67b
11 changed files with 69 additions and 11 deletions

View file

@ -42,6 +42,7 @@ public class IndexConstants {
public static final String GPX_RECORDED_INDEX_DIR = GPX_INDEX_DIR + "rec/"; public static final String GPX_RECORDED_INDEX_DIR = GPX_INDEX_DIR + "rec/";
public static final String GPX_IMPORT_DIR = GPX_INDEX_DIR + "import/"; public static final String GPX_IMPORT_DIR = GPX_INDEX_DIR + "import/";
public static final String TILES_INDEX_DIR= "tiles/"; public static final String TILES_INDEX_DIR= "tiles/";
public static final String LIVE_INDEX_DIR= "live/";
public static final String TOURS_INDEX_DIR= "tours/"; public static final String TOURS_INDEX_DIR= "tours/";
public static final String SRTM_INDEX_DIR = "srtm/"; //$NON-NLS-1$ public static final String SRTM_INDEX_DIR = "srtm/"; //$NON-NLS-1$
public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$ public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$

View file

@ -301,9 +301,7 @@ public class MapTileDownloader {
Iterator<WeakReference<IMapDownloaderCallback>> it = callbacks.iterator(); Iterator<WeakReference<IMapDownloaderCallback>> it = callbacks.iterator();
while(it.hasNext()) { while(it.hasNext()) {
IMapDownloaderCallback c = it.next().get(); IMapDownloaderCallback c = it.next().get();
if(c == null) { if(c != null) {
it.remove();
} else {
c.tileDownloaded(request); c.tileDownloaded(request);
} }
} }

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="download_live_updates">Live updates</string>
<string name="rendering_value_default13_name">Default (13)</string> <string name="rendering_value_default13_name">Default (13)</string>
<string name="rendering_value_defaultTranslucentCyan_name">Default (translucent cyan)</string> <string name="rendering_value_defaultTranslucentCyan_name">Default (translucent cyan)</string>
<string name="rendering_attr_currentTrackColor_name">GPX color</string> <string name="rendering_attr_currentTrackColor_name">GPX color</string>

View file

@ -69,7 +69,7 @@ public class TileSourceProxyProvider extends interface_ImageMapLayerProvider {
break; break;
} }
try { try {
tileReadyCallback.getSync().wait(250); tileReadyCallback.getSync().wait(50);
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
} }

View file

@ -860,6 +860,8 @@ public class OsmandSettings {
// temporarily for new version // temporarily for new version
public final CommonPreference<Boolean> DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal(); public final CommonPreference<Boolean> DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal();
public final CommonPreference<Boolean> BETA_TESTING_LIVE_UPDATES = new BooleanPreference("live_updates_beta", false).makeGlobal();
public final OsmandPreference<Boolean> SHOW_TRAFFIC_WARNINGS = new BooleanPreference("show_traffic_warnings", true).makeProfile().cache(); public final OsmandPreference<Boolean> SHOW_TRAFFIC_WARNINGS = new BooleanPreference("show_traffic_warnings", true).makeProfile().cache();
public final CommonPreference<Boolean> SHOW_PEDESTRIAN = new BooleanPreference("show_pedestrian", true).makeProfile().cache(); public final CommonPreference<Boolean> SHOW_PEDESTRIAN = new BooleanPreference("show_pedestrian", true).makeProfile().cache();
public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", false).makeProfile().cache(); public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", false).makeProfile().cache();

View file

@ -114,6 +114,7 @@ public class DownloadTilesDialog {
} }
private volatile boolean cancel = false; private volatile boolean cancel = false;
private IMapDownloaderCallback callback;
public void run(final int zoom, final int progress, final QuadRect latlonRect, final ITileSource map){ public void run(final int zoom, final int progress, final QuadRect latlonRect, final ITileSource map){
cancel = false; cancel = false;
@ -142,14 +143,15 @@ public class DownloadTilesDialog {
final List<IMapDownloaderCallback> previousCallbacks = instance.getDownloaderCallbacks(); final List<IMapDownloaderCallback> previousCallbacks = instance.getDownloaderCallbacks();
instance.clearCallbacks(); instance.clearCallbacks();
instance.addDownloaderCallback(new IMapDownloaderCallback(){ callback = new IMapDownloaderCallback(){
@Override @Override
public void tileDownloaded(DownloadRequest request) { public void tileDownloaded(DownloadRequest request) {
if (request != null) { if (request != null) {
progressDlg.setProgress(progressDlg.getProgress() + 1); progressDlg.setProgress(progressDlg.getProgress() + 1);
} }
} }
}); };
instance.addDownloaderCallback(callback);
Runnable r = new Runnable(){ Runnable r = new Runnable(){
@Override @Override
@ -201,6 +203,7 @@ public class DownloadTilesDialog {
} }
} }
mapView.refreshMap(); mapView.refreshMap();
callback = null;
} catch (Exception e) { } catch (Exception e) {
log.error("Exception while downloading tiles ", e); //$NON-NLS-1$ log.error("Exception while downloading tiles ", e); //$NON-NLS-1$
instance.refuseAllPreviousRequests(); instance.refuseAllPreviousRequests();

View file

@ -116,6 +116,7 @@ public class MapActivity extends AccessibleActivity {
private DashboardOnMap dashboardOnMap = new DashboardOnMap(this); private DashboardOnMap dashboardOnMap = new DashboardOnMap(this);
private AppInitializeListener initListener; private AppInitializeListener initListener;
private IMapDownloaderCallback downloaderCallback;
private Notification getNotification() { private Notification getNotification() {
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
@ -169,7 +170,8 @@ public class MapActivity extends AccessibleActivity {
mapView.setAccessibilityActions(new MapAccessibilityActions(this)); mapView.setAccessibilityActions(new MapAccessibilityActions(this));
mapViewTrackingUtilities.setMapView(mapView); mapViewTrackingUtilities.setMapView(mapView);
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(new IMapDownloaderCallback() { // to not let it gc
downloaderCallback = new IMapDownloaderCallback() {
@Override @Override
public void tileDownloaded(DownloadRequest request) { public void tileDownloaded(DownloadRequest request) {
if (request != null && !request.error && request.fileToSave != null) { if (request != null && !request.error && request.fileToSave != null) {
@ -180,7 +182,8 @@ public class MapActivity extends AccessibleActivity {
mapView.tileDownloaded(request); mapView.tileDownloaded(request);
} }
} }
}); };
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(downloaderCallback);
createProgressBarForRouting(); createProgressBarForRouting();
mapLayers.createLayers(mapView); mapLayers.createLayers(mapView);
// This situtation could be when navigation suddenly crashed and after restarting // This situtation could be when navigation suddenly crashed and after restarting

View file

@ -49,6 +49,9 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS,
R.string.use_magnetic_sensor, R.string.use_magnetic_sensor,
R.string.use_magnetic_sensor_descr)); R.string.use_magnetic_sensor_descr));
cat.addPreference(createCheckBoxPreference(settings.BETA_TESTING_LIVE_UPDATES,
"Live updates", "Beta testing for live updates"));
Preference pref = new Preference(this); Preference pref = new Preference(this);
pref.setTitle(R.string.test_voice_prompts); pref.setTitle(R.string.test_voice_prompts);

View file

@ -34,6 +34,7 @@ public class DownloadActivityType {
public static final DownloadActivityType SRTM_COUNTRY_FILE = new DownloadActivityType(R.string.download_srtm_maps, "srtm_map"); public static final DownloadActivityType SRTM_COUNTRY_FILE = new DownloadActivityType(R.string.download_srtm_maps, "srtm_map");
public static final DownloadActivityType HILLSHADE_FILE = new DownloadActivityType(R.string.download_hillshade_maps, "hillshade"); public static final DownloadActivityType HILLSHADE_FILE = new DownloadActivityType(R.string.download_hillshade_maps, "hillshade");
public static final DownloadActivityType WIKIPEDIA_FILE = new DownloadActivityType(R.string.download_wikipedia_maps, "wikimap"); public static final DownloadActivityType WIKIPEDIA_FILE = new DownloadActivityType(R.string.download_wikipedia_maps, "wikimap");
public static final DownloadActivityType LIVE_UPDATES_FILE = new DownloadActivityType(R.string.download_live_updates, "live_updates");
private int resource; private int resource;
private String[] tags; private String[] tags;
@ -108,6 +109,8 @@ public class DownloadActivityType {
return ctx.getAppPath(IndexConstants.SRTM_INDEX_DIR); return ctx.getAppPath(IndexConstants.SRTM_INDEX_DIR);
} else if (WIKIPEDIA_FILE == this) { } else if (WIKIPEDIA_FILE == this) {
return ctx.getAppPath(IndexConstants.WIKI_INDEX_DIR); return ctx.getAppPath(IndexConstants.WIKI_INDEX_DIR);
} else if (LIVE_UPDATES_FILE == this) {
return ctx.getAppPath(IndexConstants.LIVE_INDEX_DIR);
} else if (HILLSHADE_FILE == this) { } else if (HILLSHADE_FILE == this) {
return ctx.getAppPath(IndexConstants.TILES_INDEX_DIR); return ctx.getAppPath(IndexConstants.TILES_INDEX_DIR);
} }
@ -115,7 +118,7 @@ public class DownloadActivityType {
} }
public boolean isZipStream(OsmandApplication ctx, IndexItem indexItem) { public boolean isZipStream(OsmandApplication ctx, IndexItem indexItem) {
return HILLSHADE_FILE != this; return HILLSHADE_FILE != this && LIVE_UPDATES_FILE != this;
} }
public boolean isZipFolder(OsmandApplication ctx, IndexItem indexItem) { public boolean isZipFolder(OsmandApplication ctx, IndexItem indexItem) {
@ -147,6 +150,8 @@ public class DownloadActivityType {
return IndexConstants.BINARY_SRTM_MAP_INDEX_EXT; return IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
} else if (WIKIPEDIA_FILE == this) { } else if (WIKIPEDIA_FILE == this) {
return IndexConstants.BINARY_WIKI_MAP_INDEX_EXT; return IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
} else if (LIVE_UPDATES_FILE == this) {
return BINARY_MAP_INDEX_EXT;
} else if (HILLSHADE_FILE == this) { } else if (HILLSHADE_FILE == this) {
return IndexConstants.SQLITE_EXT; return IndexConstants.SQLITE_EXT;
} }
@ -265,6 +270,12 @@ public class DownloadActivityType {
return s; return s;
} else if (this == HILLSHADE_FILE) { } else if (this == HILLSHADE_FILE) {
return fileName.replace('_', ' '); return fileName.replace('_', ' ');
} else if (this == LIVE_UPDATES_FILE) {
int l = fileName.lastIndexOf('.');
if (l == -1) {
l = fileName.length();
}
return fileName.substring(0, l) + IndexConstants.BINARY_MAP_INDEX_EXT;
} else if (fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT) } else if (fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)
|| fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP)) { || fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP)) {
int l = fileName.lastIndexOf('_'); int l = fileName.lastIndexOf('_');

View file

@ -57,9 +57,11 @@ import net.osmand.util.Algorithms;
import java.io.File; import java.io.File;
import java.text.Collator; import java.text.Collator;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
@ -1160,6 +1162,26 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
return true; return true;
} }
}); });
if(getMyApplication().getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
item = optionsMenu.getMenu().add("Live updates")
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
String fileName = info.getFileName();
Toast.makeText(getActivity(), fileName, Toast.LENGTH_SHORT).show();
SimpleDateFormat sdf = new SimpleDateFormat("yy_MM_dd");
fileName = fileName.substring(0, fileName.indexOf('.')) + "_" + sdf.format(new Date()) + ".obf";
IndexItem ii =
new IndexItem(fileName, "Incremental update", new Date().getTime(), "1",
1000, 1000, DownloadActivityType.LIVE_UPDATES_FILE);
getDownloadActivity().addToDownload(ii);
return true;
}
});
}
optionsMenu.show(); optionsMenu.show();
} }

View file

@ -11,7 +11,6 @@ import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -120,6 +119,8 @@ public class ResourceManager {
protected final Map<String, String> indexFileNames = new ConcurrentHashMap<String, String>(); protected final Map<String, String> indexFileNames = new ConcurrentHashMap<String, String>();
protected final Map<String, String> liveUpdatesFiles = new ConcurrentHashMap<String, String>();
protected final Map<String, String> basemapFileNames = new ConcurrentHashMap<String, String>(); protected final Map<String, String> basemapFileNames = new ConcurrentHashMap<String, String>();
protected final Map<String, BinaryMapIndexReader> routingMapFiles = new ConcurrentHashMap<String, BinaryMapIndexReader>(); protected final Map<String, BinaryMapIndexReader> routingMapFiles = new ConcurrentHashMap<String, BinaryMapIndexReader>();
@ -602,6 +603,10 @@ public class ResourceManager {
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) { if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
} }
if(context.getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
collectFiles(context.getAppPath(IndexConstants.LIVE_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
}
Collections.sort(files, Algorithms.getFileVersionComparator()); Collections.sort(files, Algorithms.getFileVersionComparator());
List<String> warnings = new ArrayList<String>(); List<String> warnings = new ArrayList<String>();
renderer.clearAllResources(); renderer.clearAllResources();
@ -642,7 +647,11 @@ public class ResourceManager {
if (dateCreated == 0) { if (dateCreated == 0) {
dateCreated = f.lastModified(); dateCreated = f.lastModified();
} }
indexFileNames.put(f.getName(), dateFormat.format(dateCreated)); //$NON-NLS-1$ if(f.getParentFile().getName().equals(IndexConstants.LIVE_INDEX_DIR)) {
liveUpdatesFiles.put(f.getName(), dateFormat.format(dateCreated)); //$NON-NLS-1$
} else {
indexFileNames.put(f.getName(), dateFormat.format(dateCreated)); //$NON-NLS-1$
}
for (String rName : index.getRegionNames()) { for (String rName : index.getRegionNames()) {
// skip duplicate names (don't make collision between getName() and name in the map) // skip duplicate names (don't make collision between getName() and name in the map)
// it can be dangerous to use one file to different indexes if it is multithreaded // it can be dangerous to use one file to different indexes if it is multithreaded
@ -930,6 +939,7 @@ public class ResourceManager {
imagesOnFS.clear(); imagesOnFS.clear();
indexFileNames.clear(); indexFileNames.clear();
basemapFileNames.clear(); basemapFileNames.clear();
liveUpdatesFiles.clear();
renderer.clearAllResources(); renderer.clearAllResources();
closeAmenities(); closeAmenities();
closeRouteFiles(); closeRouteFiles();
@ -961,6 +971,10 @@ public class ResourceManager {
return new LinkedHashMap<String, String>(indexFileNames); return new LinkedHashMap<String, String>(indexFileNames);
} }
public Map<String, String> getLiveIndexFileNames() {
return new LinkedHashMap<String, String>(liveUpdatesFiles);
}
public boolean containsBasemap(){ public boolean containsBasemap(){
return !basemapFileNames.isEmpty(); return !basemapFileNames.isEmpty();
} }