Implement new SRTM download type
This commit is contained in:
parent
6d0b36b0d9
commit
810f5f8252
8 changed files with 57 additions and 58 deletions
|
@ -13,6 +13,7 @@ public class IndexConstants {
|
|||
public static final String POI_INDEX_EXT = ".poi.odb"; //$NON-NLS-1$
|
||||
public static final String BINARY_MAP_INDEX_EXT = ".obf"; //$NON-NLS-1$
|
||||
public static final String BINARY_SRTM_MAP_INDEX_EXT = ".srtm.obf"; //$NON-NLS-1$
|
||||
public static final String BINARY_SRTM_MAP_INDEX_EXT_ZIP = ".srtm.obf.zip"; //$NON-NLS-1$
|
||||
|
||||
public static final String GEN_LOG_EXT = ".gen.log"; //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -85,13 +85,11 @@
|
|||
<activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.extrasettings.SettingsExtraActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.plus.audionotes.SettingsAudioVideoActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name="net.osmand.access.SettingsAccessibilityActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchActivity" android:label="@string/search_activity" ></activity>
|
||||
<activity android:name="net.osmand.plus.activities.NavigatePointActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.DownloadIndexActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/local_index_download"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.ShowRouteInfoActivity" android:label="@string/show_route"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.FavouritesListActivity" android:label="@string/favourites_list_activity"></activity>
|
||||
|
@ -101,11 +99,7 @@
|
|||
|
||||
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchPOIActivity" android:label="@string/searchpoi_activity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchPoiFilterActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchAddressOnlineActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchAddressActivity" android:label="@string/select_address_activity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchTransportActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchHistoryActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchCityByNameActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchRegionByNameActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.SearchStreetByNameActivity"></activity>
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.ClientContext;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.base.SuggestExternalDirectoryDialog;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadEntry;
|
||||
import net.osmand.plus.download.DownloadIndexAdapter;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.download.IndexItemCategory;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.ActivityNotFoundException;
|
||||
|
@ -42,22 +14,25 @@ import android.os.Bundle;
|
|||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListAdapter;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import android.widget.*;
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.actionbarsherlock.view.SubMenu;
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.*;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.base.SuggestExternalDirectoryDialog;
|
||||
import net.osmand.plus.download.*;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||
|
||||
|
@ -338,7 +313,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
boolean excessLimit = left < 0;
|
||||
if (left < 0)
|
||||
left = 0;
|
||||
if (getType() != DownloadActivityType.HILLSHADE_FILE || getType() != DownloadActivityType.SRTM_FILE) {
|
||||
if (DownloadActivityType.isCountedInDownloads(getType())) {
|
||||
text += " (" + (excessLimit ? "! " : "") + getString(R.string.files_limit, left).toLowerCase() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +343,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
items[i] = getString(R.string.download_regular_maps);
|
||||
} else if (t[i] == DownloadActivityType.ROADS_FILE) {
|
||||
items[i] = getString(R.string.download_roads_only_maps);
|
||||
} else if (t[i] == DownloadActivityType.SRTM_FILE) {
|
||||
} else if (t[i] == DownloadActivityType.SRTM_FILE || t[i] == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
||||
items[i] = getString(R.string.download_srtm_maps);
|
||||
} else if (t[i] == DownloadActivityType.HILLSHADE_FILE) {
|
||||
items[i] = getString(R.string.download_hillshade_maps);
|
||||
|
@ -383,8 +358,9 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
items = new DownloadActivityType[]{
|
||||
DownloadActivityType.NORMAL_FILE,
|
||||
DownloadActivityType.ROADS_FILE,
|
||||
DownloadActivityType.SRTM_FILE,
|
||||
DownloadActivityType.HILLSHADE_FILE};
|
||||
//DownloadActivityType.SRTM_FILE,
|
||||
DownloadActivityType.HILLSHADE_FILE,
|
||||
DownloadActivityType.SRTM_COUNTRY_FILE};
|
||||
} else {
|
||||
items = new DownloadActivityType[]{
|
||||
DownloadActivityType.NORMAL_FILE,
|
||||
|
@ -495,7 +471,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
if (es.getBasename() != null && es.getBasename().contains("_wiki")) {
|
||||
wiki = true;
|
||||
break;
|
||||
} else if (es.getType() != DownloadActivityType.SRTM_FILE) {
|
||||
} else if (DownloadActivityType.isCountedInDownloads(es.getType())) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package net.osmand.plus.download;
|
||||
|
||||
public enum DownloadActivityType {
|
||||
NORMAL_FILE, ROADS_FILE, SRTM_FILE, HILLSHADE_FILE
|
||||
NORMAL_FILE, ROADS_FILE, SRTM_FILE, HILLSHADE_FILE, SRTM_COUNTRY_FILE;
|
||||
|
||||
public static boolean isCountedInDownloads(DownloadActivityType tp) {
|
||||
return tp != SRTM_FILE && tp != HILLSHADE_FILE && tp != SRTM_COUNTRY_FILE;
|
||||
}
|
||||
}
|
|
@ -255,7 +255,8 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
|
|||
item.setTextColor(defaultColor);
|
||||
item.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||
} else {
|
||||
if(e.getType() == DownloadActivityType.SRTM_FILE || e.getType() == DownloadActivityType.HILLSHADE_FILE){
|
||||
if(e.getType() == DownloadActivityType.SRTM_FILE || e.getType() == DownloadActivityType.HILLSHADE_FILE
|
||||
|| e.getType() == DownloadActivityType.SRTM_COUNTRY_FILE){
|
||||
item.setTextColor(okColor); // GREEN
|
||||
item.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||
} else if (e.getDate() != null) {
|
||||
|
|
|
@ -228,7 +228,7 @@ public class DownloadIndexesThread {
|
|||
boolean result = downloadFile(entry, filesToReindex, forceWifi);
|
||||
success = result || success;
|
||||
if (result) {
|
||||
if (entry.type != DownloadActivityType.SRTM_FILE && entry.type != DownloadActivityType.HILLSHADE_FILE) {
|
||||
if (DownloadActivityType.isCountedInDownloads(entry.type)) {
|
||||
downloads.set(downloads.get() + 1);
|
||||
}
|
||||
if (entry.existingBackupFile != null) {
|
||||
|
@ -263,8 +263,7 @@ public class DownloadIndexesThread {
|
|||
|
||||
private boolean exceedsFreelimit(DownloadEntry entry) {
|
||||
return Version.isFreeVersion(app) &&
|
||||
entry.type != DownloadActivityType.SRTM_FILE && entry.type != DownloadActivityType.HILLSHADE_FILE
|
||||
&& downloads.get() >= DownloadIndexActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS;
|
||||
DownloadActivityType.isCountedInDownloads(entry.type) && downloads.get() >= DownloadIndexActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS;
|
||||
}
|
||||
|
||||
private String reindexFiles(List<File> filesToReindex) {
|
||||
|
|
|
@ -125,6 +125,8 @@ public class DownloadOsmandIndexesHelper {
|
|||
return DownloadActivityType.NORMAL_FILE;
|
||||
} else if("road_region".equals(tagName) ) {
|
||||
return DownloadActivityType.ROADS_FILE;
|
||||
} else if("srtmcountry".equals(tagName) ) {
|
||||
return DownloadActivityType.SRTM_COUNTRY_FILE;
|
||||
} else if("hillshade".equals(tagName) ) {
|
||||
return DownloadActivityType.HILLSHADE_FILE;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.download;
|
||||
|
||||
import static net.osmand.IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||
import static net.osmand.IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -53,7 +54,7 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
|
||||
public String getVisibleDescription(ClientContext ctx) {
|
||||
String s = ""; //$NON-NLS-1$
|
||||
if (type == DownloadActivityType.SRTM_FILE) {
|
||||
if (type == DownloadActivityType.SRTM_FILE || type == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
||||
return ctx.getString(R.string.download_srtm_maps);
|
||||
} else if (type == DownloadActivityType.ROADS_FILE) {
|
||||
return ctx.getString(R.string.download_roads_only_item);
|
||||
|
@ -79,6 +80,14 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
if (fileName.endsWith(IndexConstants.EXTRA_ZIP_EXT)) {
|
||||
return fileName.substring(0, fileName.length() - IndexConstants.EXTRA_ZIP_EXT.length());
|
||||
}
|
||||
if (fileName.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP)) {
|
||||
String simple = fileName.substring(0, fileName.length() - IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP.length());
|
||||
int ls = simple.lastIndexOf('_');
|
||||
if (ls >= 0) {
|
||||
return simple.substring(0, ls);
|
||||
}
|
||||
return simple;
|
||||
}
|
||||
if (fileName.endsWith(IndexConstants.SQLITE_EXT)) {
|
||||
return fileName.substring(0, fileName.length() - IndexConstants.SQLITE_EXT.length()).replace('_', ' ');
|
||||
}
|
||||
|
@ -93,6 +102,7 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
// POI index download is not supported any longer
|
||||
if (fileName.endsWith(addVersionToExt(IndexConstants.BINARY_MAP_INDEX_EXT, IndexConstants.BINARY_MAP_VERSION)) //
|
||||
|| fileName.endsWith(addVersionToExt(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION)) //
|
||||
|| fileName.endsWith(addVersionToExt(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION)) //
|
||||
|| fileName.endsWith(addVersionToExt(IndexConstants.VOICE_INDEX_EXT_ZIP, IndexConstants.VOICE_VERSION))
|
||||
|| fileName.endsWith(IndexConstants.EXTRA_ZIP_EXT)
|
||||
|| fileName.endsWith(IndexConstants.SQLITE_EXT)
|
||||
|
@ -136,7 +146,11 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
boolean unzipDir = false;
|
||||
boolean zipStream = false;
|
||||
boolean preventMediaIndexing = false;
|
||||
if (fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||
if (fileName.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT_ZIP)) {
|
||||
parent = ctx.getAppPath(IndexConstants.SRTM_INDEX_DIR);
|
||||
extension = BINARY_SRTM_MAP_INDEX_EXT;
|
||||
zipStream = true;
|
||||
} else if (fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||
parent = ctx.getAppPath(IndexConstants.MAPS_PATH);
|
||||
extension = BINARY_MAP_INDEX_EXT;
|
||||
} else if (fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP)) {
|
||||
|
@ -165,6 +179,8 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
}
|
||||
if (type == DownloadActivityType.ROADS_FILE) {
|
||||
extension = "-roads" + extension;
|
||||
} else if (type == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
||||
// extension = "-srtm" + extension;
|
||||
}
|
||||
if (parent != null) {
|
||||
parent.mkdirs();
|
||||
|
@ -190,6 +206,9 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
if (type == DownloadActivityType.ROADS_FILE) {
|
||||
url += "road=yes&";
|
||||
}
|
||||
if (type == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
||||
url += "srtmcountry=yes&";
|
||||
}
|
||||
if (type == DownloadActivityType.HILLSHADE_FILE) {
|
||||
url += "hillshade=yes&";
|
||||
}
|
||||
|
@ -240,6 +259,9 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
if (getType() == DownloadActivityType.ROADS_FILE) {
|
||||
s += "-roads" ;
|
||||
}
|
||||
if (getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
||||
return s + IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
||||
}
|
||||
s += IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||
return s;
|
||||
} else if(e.endsWith(IndexConstants.SQLITE_EXT)){
|
||||
|
|
Loading…
Reference in a new issue