fix small issues

git-svn-id: https://osmand.googlecode.com/svn/trunk@284 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-05 08:46:03 +00:00
parent ead4b86aab
commit dd825737b4
4 changed files with 36 additions and 18 deletions

View file

@ -18,15 +18,12 @@ 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
// 50. Invent opening hours editor in order to edit POI hours better on device
// 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
// 45. Get clear <Use internet> settings. Move that setting on top settings screen.
@ -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

View file

@ -51,6 +51,7 @@
<string name="router_service">Прокладка маршрута</string>
<string name="download_sd_dir_not_accessible">Директория на SD карточка не доступна для сохранения</string>
<string name="download_question">Вы хотите загрузить {0} - {1} ?</string>
<string name="download_question_exist">Индекс для {0} уже существует ({1}). Вы хотите его обновить ({2}) ?</string>
<string name="address">Адрес</string>
<string name="download_index_success">Индекс успешно загружен</string>
<string name="error_io_error">Произошла ошибка ввода/вывода.</string>

View file

@ -51,6 +51,7 @@
<string name="router_service">Routing</string>
<string name="download_sd_dir_not_accessible">Directory on SD card to save index is not accessible</string>
<string name="download_question">Do you want to download {0} - {1} ?</string>
<string name="download_question_exist">Index for {0} already exists ({1}). Do you want to update it ({2}) ?</string>
<string name="address">Address</string>
<string name="download_index_success">Index downloaded successfully</string>
<string name="error_io_error">Input/output error occured.</string>

View file

@ -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<String, String> e = ((DownloadIndexAdapter)getListAdapter()).getItem(position);
Builder builder = new AlertDialog.Builder(this);
int ls = e.getKey().lastIndexOf('_');
final String regionName = e.getKey().substring(0, ls);
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.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
downloadFile(e.getKey(), regionName);
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);