Improve download usability
This commit is contained in:
parent
bc9787e2e5
commit
1cfaf71c10
6 changed files with 110 additions and 30 deletions
|
@ -8,12 +8,15 @@
|
||||||
If you are making/correcting english translations make sure :
|
If you are making/correcting english translations make sure :
|
||||||
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
|
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
|
||||||
-->
|
-->
|
||||||
|
<string name="confirm_interrupt_download">Do you want to interrupt file downloading?</string>
|
||||||
|
<string name="first_time_msg">To use the major features of this application, you need some regional offline data, which you can download (use Settings, Offline Data). Afterwards, you will be able to search by address, look up POIs and find public transportation.</string>
|
||||||
|
<string name="basemap_was_selected_to_download">Basemap is required for proper application functioning and was selected to download.</string>
|
||||||
<string name="select_index_file_to_download">Nothing was found. If you can\'t find your region manually, you can make it yourself (see osmand.net).</string>
|
<string name="select_index_file_to_download">Nothing was found. If you can\'t find your region manually, you can make it yourself (see osmand.net).</string>
|
||||||
<string name="local_indexes_cat_tile">Online Map data</string>
|
<string name="local_indexes_cat_tile">Online Map data</string>
|
||||||
<string name="local_indexes_cat_map">Offline Map data</string>
|
<string name="local_indexes_cat_map">Offline Map data</string>
|
||||||
<string name="gpx_index_settings_descr"> (includes GPX analyzer)</string>
|
<string name="gpx_index_settings_descr"> (includes GPX analyzer)</string>
|
||||||
<string name="index_settings_descr">Download, view details and manage offline maps</string>
|
<string name="index_settings_descr">Download, view details and manage offline maps</string>
|
||||||
<string name="local_index_description">Download, (de-)activate, or delete offline data. \nTo see more details click on the item. \nCurrent data on device (%1$s free):</string>
|
<string name="local_index_description">Download or update offline data. \nTo see more details click on the item, to deactivate or delete offline data press and hold. \nCurrent data on device (%1$s free):</string>
|
||||||
<string name="map_online_plugin_is_not_installed">Enable online maps plugin to select different map sources</string>
|
<string name="map_online_plugin_is_not_installed">Enable online maps plugin to select different map sources</string>
|
||||||
<string name="map_online_data">Online maps</string>
|
<string name="map_online_data">Online maps</string>
|
||||||
<string name="map_online_data_descr">Use online maps (download and save them on sdcard)</string>
|
<string name="map_online_data_descr">Use online maps (download and save them on sdcard)</string>
|
||||||
|
@ -722,7 +725,6 @@
|
||||||
<string name="route_head">Head</string>
|
<string name="route_head">Head</string>
|
||||||
<string name="first_time_continue">Later</string>
|
<string name="first_time_continue">Later</string>
|
||||||
<string name="first_time_download">Download regions</string>
|
<string name="first_time_download">Download regions</string>
|
||||||
<string name="first_time_msg">Thank you for choosing OsmAnd. \nTo use the major features of this application, you will need some regional offline data, which you can download (use Settings, Offline Data). Afterwards, you will be able to search by address, look up POIs and find public transportation.</string>
|
|
||||||
<string name="search_poi_location">Searching for signal…</string>
|
<string name="search_poi_location">Searching for signal…</string>
|
||||||
<string name="search_near_map">Search near last map location</string>
|
<string name="search_near_map">Search near last map location</string>
|
||||||
<string name="search_nearby">Search nearby</string>
|
<string name="search_nearby">Search nearby</string>
|
||||||
|
|
|
@ -14,8 +14,8 @@ import net.osmand.plus.DownloadOsmandIndexesHelper.IndexItem;
|
||||||
public class IndexFileList implements Serializable {
|
public class IndexFileList implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
IndexItem basemap;
|
||||||
TreeMap<String, IndexItem> indexFiles = new TreeMap<String, IndexItem>(new Comparator<String>(){
|
TreeMap<String, IndexItem> indexFiles = new TreeMap<String, IndexItem>(new Comparator<String>(){
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(String object1, String object2) {
|
public int compare(String object1, String object2) {
|
||||||
|
@ -45,6 +45,9 @@ public class IndexFileList implements Serializable {
|
||||||
if (indexItem.isAccepted()) {
|
if (indexItem.isAccepted()) {
|
||||||
indexFiles.put(name, indexItem);
|
indexFiles.put(name, indexItem);
|
||||||
}
|
}
|
||||||
|
if(name.toLowerCase().startsWith("world_basemap")) {
|
||||||
|
basemap = indexItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAcceptable() {
|
public boolean isAcceptable() {
|
||||||
|
@ -54,6 +57,10 @@ public class IndexFileList implements Serializable {
|
||||||
public Map<String, IndexItem> getIndexFiles() {
|
public Map<String, IndexItem> getIndexFiles() {
|
||||||
return indexFiles;
|
return indexFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IndexItem getBasemap() {
|
||||||
|
return basemap;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isIncreasedMapVersion() {
|
public boolean isIncreasedMapVersion() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -63,9 +63,23 @@ public class ProgressDialogImplementation implements IProgress {
|
||||||
public ProgressDialogImplementation(final ProgressDialog dlg){
|
public ProgressDialogImplementation(final ProgressDialog dlg){
|
||||||
this(dlg, false);
|
this(dlg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ProgressDialogImplementation createProgressDialog(Context ctx, String title, String message, int style) {
|
public static ProgressDialogImplementation createProgressDialog(Context ctx, String title, String message, int style) {
|
||||||
ProgressDialog dlg = new ProgressDialog(ctx);
|
return createProgressDialog(ctx, title, message, style, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProgressDialogImplementation createProgressDialog(Context ctx, String title, String message, int style, final DialogInterface.OnCancelListener listener) {
|
||||||
|
ProgressDialog dlg = new ProgressDialog(ctx) {
|
||||||
|
@Override
|
||||||
|
public void cancel() {
|
||||||
|
if(listener != null) {
|
||||||
|
listener.onCancel(this);
|
||||||
|
} else {
|
||||||
|
super.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
dlg.setTitle(title);
|
dlg.setTitle(title);
|
||||||
dlg.setMessage(message);
|
dlg.setMessage(message);
|
||||||
dlg.setIndeterminate(style == ProgressDialog.STYLE_HORIZONTAL); // re-set in mViewUpdateHandler.handleMessage above
|
dlg.setIndeterminate(style == ProgressDialog.STYLE_HORIZONTAL); // re-set in mViewUpdateHandler.handleMessage above
|
||||||
|
|
|
@ -12,8 +12,10 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import net.osmand.Algoritms;
|
import net.osmand.Algoritms;
|
||||||
|
@ -102,6 +104,8 @@ public class ResourceManager {
|
||||||
|
|
||||||
protected final Map<String, String> indexFileNames = new LinkedHashMap<String, String>();
|
protected final Map<String, String> indexFileNames = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
|
protected final Set<String> basemapFileNames = new LinkedHashSet<String>();
|
||||||
|
|
||||||
protected final Map<String, BinaryMapIndexReader> routingMapFiles = new LinkedHashMap<String, BinaryMapIndexReader>();
|
protected final Map<String, BinaryMapIndexReader> routingMapFiles = new LinkedHashMap<String, BinaryMapIndexReader>();
|
||||||
|
|
||||||
protected final MapRenderRepositories renderer;
|
protected final MapRenderRepositories renderer;
|
||||||
|
@ -507,6 +511,9 @@ public class ResourceManager {
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$
|
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
|
if(index.isBasemap()) {
|
||||||
|
basemapFileNames.add(f.getName());
|
||||||
|
}
|
||||||
indexFileNames.put(f.getName(), MessageFormat.format("{0,date,dd.MM.yyyy}", new Date(f.lastModified()))); //$NON-NLS-1$
|
indexFileNames.put(f.getName(), MessageFormat.format("{0,date,dd.MM.yyyy}", new Date(f.lastModified()))); //$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)
|
||||||
|
@ -810,6 +817,7 @@ public class ResourceManager {
|
||||||
public synchronized void close(){
|
public synchronized void close(){
|
||||||
imagesOnFS.clear();
|
imagesOnFS.clear();
|
||||||
indexFileNames.clear();
|
indexFileNames.clear();
|
||||||
|
basemapFileNames.clear();
|
||||||
renderer.clearAllResources();
|
renderer.clearAllResources();
|
||||||
closeAmenities();
|
closeAmenities();
|
||||||
closeRouteFiles();
|
closeRouteFiles();
|
||||||
|
@ -841,6 +849,10 @@ public class ResourceManager {
|
||||||
return new LinkedHashMap<String, String>(indexFileNames);
|
return new LinkedHashMap<String, String>(indexFileNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean containsBasemap(){
|
||||||
|
return !basemapFileNames.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getBackupIndexes(Map<String, String> map) {
|
public Map<String, String> getBackupIndexes(Map<String, String> map) {
|
||||||
File file = context.getSettings().extendOsmandPath(BACKUP_PATH);
|
File file = context.getSettings().extendOsmandPath(BACKUP_PATH);
|
||||||
if (file != null && file.isDirectory()) {
|
if (file != null && file.isDirectory()) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ import android.app.ProgressDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -264,6 +265,14 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (indexFiles != null) {
|
if (indexFiles != null) {
|
||||||
|
boolean basemapExists = ((OsmandApplication) uiActivity.getApplication()).getResourceManager().containsBasemap();
|
||||||
|
if(!basemapExists && indexFiles.getBasemap() != null) {
|
||||||
|
uiActivity.entriesToDownload.put(indexFiles.getBasemap().getFileName(),
|
||||||
|
indexFiles.getBasemap().createDownloadEntry(ctx));
|
||||||
|
AccessibleToast.makeText(uiActivity, R.string.basemap_was_selected_to_download,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
uiActivity.findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
uiActivity.setListAdapter(uiActivity.new DownloadIndexAdapter(indexFiles.getIndexFiles()));
|
uiActivity.setListAdapter(uiActivity.new DownloadIndexAdapter(indexFiles.getIndexFiles()));
|
||||||
if (indexFiles.isIncreasedMapVersion()) {
|
if (indexFiles.isIncreasedMapVersion()) {
|
||||||
uiActivity.showDialog(DownloadIndexActivity.DIALOG_MAP_VERSION_UPDATE);
|
uiActivity.showDialog(DownloadIndexActivity.DIALOG_MAP_VERSION_UPDATE);
|
||||||
|
@ -311,19 +320,18 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
DownloadIndexActivity.this,
|
DownloadIndexActivity.this,
|
||||||
getString(R.string.downloading),
|
getString(R.string.downloading),
|
||||||
getString(R.string.downloading_file),
|
getString(R.string.downloading_file),
|
||||||
ProgressDialog.STYLE_HORIZONTAL);
|
ProgressDialog.STYLE_HORIZONTAL,
|
||||||
|
new DialogInterface.OnCancelListener() {
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
makeSureUserCancelDownload(dialog);
|
||||||
|
}
|
||||||
|
});
|
||||||
progressFileDlg = progress.getDialog();
|
progressFileDlg = progress.getDialog();
|
||||||
progressFileDlg.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
downloadFileHelper.setInterruptDownloading(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
progressFileDlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
progressFileDlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
downloadFileHelper.setInterruptDownloading(true);
|
downloadFileHelper.setInterruptDownloading(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return progress.getDialog();
|
return progress.getDialog();
|
||||||
|
@ -361,6 +369,20 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
return super.getExpandableListAdapter();
|
return super.getExpandableListAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void makeSureUserCancelDownload(final DialogInterface dlg) {
|
||||||
|
Builder bld = new AlertDialog.Builder(this);
|
||||||
|
bld.setTitle(getString(R.string.default_buttons_cancel));
|
||||||
|
bld.setMessage(R.string.confirm_interrupt_download);
|
||||||
|
bld.setPositiveButton(R.string.default_buttons_yes, new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dlg.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.setNegativeButton(R.string.default_buttons_no, null);
|
||||||
|
bld.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
|
@ -769,10 +791,33 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
public DownloadIndexAdapter(Map<String, IndexItem> indexFiles) {
|
public DownloadIndexAdapter(Map<String, IndexItem> indexFiles) {
|
||||||
this.indexFiles = new LinkedHashMap<String, IndexItem>(indexFiles);
|
this.indexFiles = new LinkedHashMap<String, IndexItem>(indexFiles);
|
||||||
list.clear();
|
List<IndexItemCategory> cats = categorizeIndexItems(indexFiles.values());
|
||||||
list.addAll(categorizeIndexItems(indexFiles.values()));
|
synchronized (this) {
|
||||||
|
list.clear();
|
||||||
|
list.addAll(cats);
|
||||||
|
}
|
||||||
getFilter().filter(filterText.getText());
|
getFilter().filter(filterText.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void collapseTrees(final CharSequence constraint){
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
synchronized (DownloadIndexAdapter.this) {
|
||||||
|
final ExpandableListView expandableListView = getExpandableListView();
|
||||||
|
for (int i = 0; i < getGroupCount(); i++) {
|
||||||
|
int cp = getChildrenCount(i);
|
||||||
|
if (cp < 7) {
|
||||||
|
expandableListView.expandGroup(i);
|
||||||
|
} else {
|
||||||
|
expandableListView.collapseGroup(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, IndexItem> getIndexFiles() {
|
public Map<String, IndexItem> getIndexFiles() {
|
||||||
return indexFiles;
|
return indexFiles;
|
||||||
|
@ -783,8 +828,11 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
for(IndexItem i : indexFiles) {
|
for(IndexItem i : indexFiles) {
|
||||||
this.indexFiles.put(i.getFileName(), i);
|
this.indexFiles.put(i.getFileName(), i);
|
||||||
}
|
}
|
||||||
list.clear();
|
List<IndexItemCategory> cats = categorizeIndexItems(indexFiles);
|
||||||
list.addAll(categorizeIndexItems(indexFiles));
|
synchronized (this) {
|
||||||
|
list.clear();
|
||||||
|
list.addAll(cats);
|
||||||
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -830,18 +878,21 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
list.clear();
|
synchronized (DownloadIndexAdapter.this) {
|
||||||
Collection<IndexItem> items = (Collection<IndexItem>) results.values;
|
list.clear();
|
||||||
if (items != null && !items.isEmpty()) {
|
Collection<IndexItem> items = (Collection<IndexItem>) results.values;
|
||||||
list.addAll(categorizeIndexItems(items));
|
if (items != null && !items.isEmpty()) {
|
||||||
} else {
|
list.addAll(categorizeIndexItems(items));
|
||||||
list.add(new IndexItemCategory(getResources().getString(R.string.select_index_file_to_download),1));
|
} else {
|
||||||
|
list.add(new IndexItemCategory(getResources().getString(R.string.select_index_file_to_download), 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
collapseTrees(constraint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,12 +944,6 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
||||||
item.setText(group.name);
|
item.setText(group.name);
|
||||||
item.setLinkTextColor(Color.YELLOW);
|
item.setLinkTextColor(Color.YELLOW);
|
||||||
adjustIndicator(groupPosition, isExpanded, v);
|
adjustIndicator(groupPosition, isExpanded, v);
|
||||||
int cp = getChildrenCount(groupPosition);
|
|
||||||
if(cp < 10 && !isExpanded) {
|
|
||||||
getExpandableListView().expandGroup(groupPosition);
|
|
||||||
} else if(cp > 50 && isExpanded){
|
|
||||||
getExpandableListView().collapseGroup(groupPosition);
|
|
||||||
}
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -678,7 +678,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
}
|
}
|
||||||
TextView ds = (TextView) findViewById(R.id.DescriptionText);
|
TextView ds = (TextView) findViewById(R.id.DescriptionText);
|
||||||
String text = getString(R.string.local_index_description, size);
|
String text = getString(R.string.local_index_description, size);
|
||||||
int l = text.indexOf(',');
|
int l = text.indexOf('.');
|
||||||
if(l == -1) {
|
if(l == -1) {
|
||||||
l = text.length();
|
l = text.length();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue