From dd825737b4284e19ebdd1fcbd9d4805e6d6594a8 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 5 Jul 2010 08:46:03 +0000 Subject: [PATCH] fix small issues git-svn-id: https://osmand.googlecode.com/svn/trunk@284 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- .../src/com/osmand/ToDoConstants.java | 6 +-- OsmAnd/res/values-ru-rRU/strings.xml | 1 + OsmAnd/res/values/strings.xml | 1 + .../activities/DownloadIndexActivity.java | 46 +++++++++++++------ 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java index b5e99a192e..b1390b8187 100644 --- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java @@ -18,14 +18,11 @@ public class ToDoConstants { // 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions. // Some icons are not fine (as back menu from map - it is blured). // Got by Andrei + // 50. Invent opening hours editor in order to edit POI hours better on device - // GOT by Olga - // 60. Audio guidance for routing // 61. Provide route information for YOURS (calclate turns/angle/expected time). // Fix some missing turns in CloudMade (for secondary roads wo name). Add them (if dist to prev/next turn > 150m) [dacha] - - // 43. Enable poi filter by name // 58. Upload/Download zip-index from site & unzip them on phone @@ -43,7 +40,6 @@ public class ToDoConstants { // FIXME BUGS Android // FIXME !!!! Check agains ID is not unique ! (for relation/node/way - it could be the same) - checked for data extraction & index creator // REFACTOR Settings activity ( for check box properties!) - // Download index show current index information // Fix bugs with test data (bug with follow turn / left time / add turn) // Fix description on android // Improvement : Show stops in the transport route diff --git a/OsmAnd/res/values-ru-rRU/strings.xml b/OsmAnd/res/values-ru-rRU/strings.xml index e65fce3c9b..7d0476fb82 100644 --- a/OsmAnd/res/values-ru-rRU/strings.xml +++ b/OsmAnd/res/values-ru-rRU/strings.xml @@ -51,6 +51,7 @@ Прокладка маршрута Директория на SD карточка не доступна для сохранения Вы хотите загрузить {0} - {1} ? + Индекс для {0} уже существует ({1}). Вы хотите его обновить ({2}) ? Адрес Индекс успешно загружен Произошла ошибка ввода/вывода. diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f20a41e53d..6bd2045600 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -51,6 +51,7 @@ Routing Directory on SD card to save index is not accessible Do you want to download {0} - {1} ? + Index for {0} already exists ({1}). Do you want to update it ({2}) ? Address Index downloaded successfully Input/output error occured. diff --git a/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java b/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java index 919d19268e..7588fefdb6 100644 --- a/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java @@ -8,7 +8,9 @@ import java.net.URL; import java.net.URLConnection; import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; @@ -87,29 +89,42 @@ public class DownloadIndexActivity extends ListActivity { } } - + private final static int MB = 1 << 20; @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); final Entry e = ((DownloadIndexAdapter)getListAdapter()).getItem(position); - Builder builder = new AlertDialog.Builder(this); + int ls = e.getKey().lastIndexOf('_'); final String regionName = e.getKey().substring(0, ls); - builder.setMessage(MessageFormat.format(getString(R.string.download_question), regionName, e.getValue())); - builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener(){ - @Override - public void onClick(DialogInterface dialog, int which) { - downloadFile(e.getKey(), regionName); + final File fileToSave = resolveFileName(e.getKey(), regionName); + if (fileToSave != null) { + Builder builder = new AlertDialog.Builder(this); + if(!fileToSave.exists()){ + builder.setMessage(MessageFormat.format(getString(R.string.download_question), regionName, e.getValue())); + } else { + MessageFormat format = new MessageFormat("{0,date,dd.MM.yyyy} : {1, number,##.#} MB", Locale.US); //$NON-NLS-1$ + String description = format.format(new Object[]{new Date(fileToSave.lastModified()), ((float)fileToSave.length() / MB)}); + builder.setMessage(MessageFormat.format(getString(R.string.download_question_exist), regionName, description, e.getValue())); + } - }); - builder.setNegativeButton(R.string.default_buttons_no, null); - builder.show(); + + + builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + downloadFile(e.getKey(), fileToSave); + } + }); + builder.setNegativeButton(R.string.default_buttons_no, null); + builder.show(); + } } private static final int BUFFER_SIZE = 32256; - protected void downloadFile(final String key, String regionName) { + private File resolveFileName(String key, String regionName){ File parent = null; if(key.endsWith(IndexConstants.ADDRESS_INDEX_EXT)){ parent = new File(Environment.getExternalStorageDirectory(), ResourceManager.ADDRESS_PATH); @@ -126,9 +141,14 @@ public class DownloadIndexActivity extends ListActivity { } if(parent == null || !parent.exists()){ Toast.makeText(DownloadIndexActivity.this, getString(R.string.download_sd_dir_not_accessible), Toast.LENGTH_LONG); - return; + return null; } - final File file = new File(parent, regionName); + File file = new File(parent, regionName); + return file; + } + + protected void downloadFile(final String key, final File file) { + final ProgressDialog dlg = ProgressDialog.show(this, getString(R.string.downloading), getString(R.string.downloading_file), true, true); dlg.show(); final ProgressDialogImplementation impl = new ProgressDialogImplementation(dlg, true);