2 * Navit, a modular navigation system.
\r
3 * Copyright (C) 2005-2008 Navit Team
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * version 2 as published by the Free Software Foundation.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program; if not, write to the
\r
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
\r
17 * Boston, MA 02110-1301, USA.
\r
20 package org.navitproject.navit;
\r
22 import java.io.BufferedInputStream;
\r
23 import java.io.BufferedOutputStream;
\r
24 import java.io.File;
\r
25 import java.io.FileOutputStream;
\r
26 import java.io.IOException;
\r
27 import java.io.InputStream;
\r
28 import java.net.HttpURLConnection;
\r
29 import java.net.URL;
\r
30 import java.text.DecimalFormat;
\r
31 import java.text.NumberFormat;
\r
33 import android.os.Bundle;
\r
34 import android.os.Handler;
\r
35 import android.os.Message;
\r
36 import android.util.Log;
\r
38 public class NavitMapDownloader
\r
40 public static class osm_map_values
\r
46 String map_name = "";
\r
47 long est_size_bytes = 0;
\r
48 String est_size_bytes_human_string = "";
\r
49 String text_for_select_list = "";
\r
50 Boolean is_continent = false;
\r
51 int continent_id = 0;
\r
54 public osm_map_values(String mapname, String lon_1, String lat_1, String lon_2, String lat_2,
\r
55 long bytes_est, Boolean is_con, int con_id)
\r
57 this.is_continent = is_con;
\r
58 this.continent_id = con_id;
\r
59 this.map_name = mapname;
\r
64 this.est_size_bytes = bytes_est;
\r
65 this.est_size_bytes_human_string = " ca. "
\r
66 + (int) ((float) (this.est_size_bytes) / 1024f / 1024f) + "MB";
\r
67 this.text_for_select_list = this.map_name + " " + this.est_size_bytes_human_string;
\r
71 // define the maps here
\r
73 static final osm_map_values[] osm_maps = {
\r
74 new osm_map_values("Whole Planet", "-180", "-90", "180", "90", 5985878379L, true, 0),
\r
75 new osm_map_values("Africa", "-20.8", "-35.2", "52.5", "37.4", 180836389L, true, 1),
\r
76 new osm_map_values("Angola", "11.4", "-18.1", "24.2", "-5.3", 56041641L, false, 1),
\r
77 new osm_map_values("Burundi", "28.9", "-4.5", "30.9", "-2.2", 56512924L, false, 1),
\r
78 new osm_map_values("Democratic Republic of the Congo", "11.7", "-13.6", "31.5", "5.7",65026791L, false, 1),
\r
79 new osm_map_values("Kenya", "33.8","-5.2", "42.4", "4.9", 58545273L, false, 1),
\r
80 new osm_map_values("Lesotho", "26.9", "-30.7", "29.6","-28.4", 54791041L, false, 1),
\r
81 new osm_map_values("Madagascar", "43.0","-25.8", "50.8","-11.8", 56801099L, false, 1),
\r
82 new osm_map_values("Nambia+Botswana","11.4", "-29.1","29.5", "-16.9", 61807049L, false, 1),
\r
83 new osm_map_values("Reunion", "55.2","-21.4", "55.9","-20.9", 58537419L, false, 1),
\r
84 new osm_map_values("Rwanda", "28.8","-2.9", "30.9","-1.0", 56313710L, false, 1),
\r
85 new osm_map_values("South Africa","15.6", "-35.2","33.3", "-21.9", 73545245L, false, 1),
\r
86 new osm_map_values("Uganda", "29.3","-1.6", "35.1","4.3", 57376589L, false, 1),
\r
87 new osm_map_values("Asia", "23.8","0.1", "195.0","82.4", 797725952L, true, 2),
\r
88 new osm_map_values("China", "67.3","5.3", "135.0","54.5", 259945160L, false, 2),
\r
89 new osm_map_values("Cyprus", "32.0","34.5", "34.9","35.8", 58585278L, false, 2),
\r
90 new osm_map_values("India+Nepal","67.9", "5.5","89.6", "36.0", 82819344L, false, 2),
\r
91 new osm_map_values("Indonesia", "93.7","-17.3", "155.5","7.6", 74648081L, false, 2),
\r
92 new osm_map_values("Iran", "43.5","24.4", "63.6","40.4", 69561312L, false, 2),
\r
93 new osm_map_values("Iraq", "38.7","28.5", "49.2","37.4", 59146383L, false, 2),
\r
94 new osm_map_values("Israel", "33.99","29.8", "35.95","33.4", 65065351L, false, 2),
\r
95 new osm_map_values("Japan+Korea+Taiwan","117.6", "20.5","151.3", "47.1", 305538751L, false, 2),
\r
96 new osm_map_values("Malasia+Singapore","94.3", "-5.9","108.6", "6.8", 58849792L, false, 2),
\r
97 new osm_map_values("Mongolia", "87.5","41.4", "120.3","52.7", 60871187L, false, 2),
\r
98 new osm_map_values("Thailand", "97.5","5.7", "105.2","19.7", 62422864L, false, 2),
\r
99 new osm_map_values("Turkey", "25.1","35.8", "46.4","42.8", 81758047L, false, 2),
\r
100 new osm_map_values("UAE+Other", "51.5","22.6", "56.7","26.5", 57419510L, false, 2),
\r
101 new osm_map_values("Australia", "110.5","-44.2", "154.9","-9.2", 128502185L, true, 3),
\r
102 new osm_map_values("Australia", "110.5","-44.2", "154.9","-9.2", 128502185L, false, 3),
\r
103 new osm_map_values("Tasmania", "144.0","-45.1", "155.3","-24.8", 103573989L, false, 3),
\r
104 new osm_map_values("Victoria+New South Wales","140.7", "-39.4","153.7", "-26.9", 99307594L, false, 3),
\r
105 new osm_map_values("New Zealand","165.2", "-47.6","179.1", "-33.7", 64757454L, false, 3),
\r
106 new osm_map_values("Europe", "-12.97","33.59", "34.15","72.10", 2753910015L, true, 4),
\r
107 new osm_map_values("Western Europe","-17.6", "34.5","42.9", "70.9", 2832986851L, false, 4),
\r
108 new osm_map_values("Austria", "9.4","46.32", "17.21","49.1", 222359992L, false, 4),
\r
109 new osm_map_values("BeNeLux", "2.08","48.87", "7.78","54.52", 533865194L, false, 4),
\r
110 new osm_map_values("Faroe Islands","-7.8", "61.3","-6.1", "62.5", 54526101L, false, 4),
\r
111 new osm_map_values("France", "-5.45","42.00", "8.44","51.68", 1112047845L, false, 4),
\r
112 new osm_map_values("Germany", "5.18","46.84", "15.47","55.64", 944716238L, false, 4),
\r
113 new osm_map_values("Bavaria", "10.3","47.8", "13.6","49.7", 131799419L, false, 4),
\r
114 new osm_map_values("Saxonia", "11.8","50.1", "15.0","51.7", 112073909L, false, 4),
\r
115 new osm_map_values("Germany+Austria+Switzerland","3.4", "44.5","18.6", "55.1", 1385785353L, false, 4),
\r
116 new osm_map_values("Iceland", "-25.3","62.8", "-11.4","67.5", 57281405L, false, 4),
\r
117 new osm_map_values("Ireland", "-11.17","51.25", "-5.23","55.9", 70186936L, false, 4),
\r
118 new osm_map_values("Italy", "6.52","36.38", "18.96","47.19", 291401314L, false, 4),
\r
119 new osm_map_values("Spain+Portugal","-11.04", "34.87","4.62", "44.41", 292407746L, false, 4),
\r
120 new osm_map_values("Mallorca", "2.2","38.8", "4.7","40.2", 59700600L, false, 4),
\r
121 new osm_map_values("Galicia", "-10.0","41.7", "-6.3","44.1", 64605237L, false, 4),
\r
122 new osm_map_values("Scandinavia", "4.0","54.4", "32.1","71.5", 299021928L, false, 4),
\r
123 new osm_map_values("Finland", "18.6","59.2", "32.3","70.3", 128871467L, false, 4),
\r
124 new osm_map_values("Denmark", "7.49","54.33", "13.05","57.88", 120025875L, false, 4),
\r
125 new osm_map_values("Switzerland","5.79", "45.74","10.59", "47.84", 162616817L, false, 4),
\r
126 new osm_map_values("UK", "-9.7", "49.6","2.2", "61.2", 245161510L, false, 4),
\r
127 new osm_map_values("Bulgaria", "24.7","42.1", "24.8","42.1", 56607427L, false, 4),
\r
128 new osm_map_values("Czech Republic","11.91", "48.48","19.02", "51.17", 234138824L, false, 4),
\r
129 new osm_map_values("Croatia", "13.4","42.1", "19.4","46.9", 99183280L, false, 4),
\r
130 new osm_map_values("Estonia", "21.5","57.5", "28.2","59.6", 79276178L, false, 4),
\r
131 new osm_map_values("Greece", "28.9","37.8", "29.0","37.8", 55486527L, false, 4),
\r
132 new osm_map_values("Crete", "23.3","34.5", "26.8","36.0", 57032630L, false, 4),
\r
133 new osm_map_values("Hungary", "16.08","45.57", "23.03","48.39", 109831319L, false, 4),
\r
134 new osm_map_values("Latvia", "20.7","55.6", "28.3","58.1", 71490706L, false, 4),
\r
135 new osm_map_values("Lithuania", "20.9","53.8", "26.9","56.5", 67992457L, false, 4),
\r
136 new osm_map_values("Poland", "13.6","48.8", "24.5","55.0", 266136768L, false, 4),
\r
137 new osm_map_values("Romania", "20.3","43.5", "29.9","48.4", 134525863L, false, 4),
\r
138 new osm_map_values("North America","-178.1", "6.5","-10.4", "84.0", 2477309662L, true, 5),
\r
139 new osm_map_values("Alaska", "-179.5","49.5", "-129","71.6", 72320027L, false, 5),
\r
140 new osm_map_values("Canada", "-141.3","41.5", "-52.2","70.2", 937813467L, false, 5),
\r
141 new osm_map_values("Hawaii", "-161.07","18.49", "-154.45","22.85", 57311788L, false, 5),
\r
142 new osm_map_values("USA (except Alaska and Hawaii)","-125.4", "24.3","-66.5", "49.3", 2216912004L, false, 5),
\r
143 new osm_map_values("Nevada", "-120.2","35.0", "-113.8","42.1", 136754975L, false, 5),
\r
144 new osm_map_values("Oregon", "-124.8","41.8", "-116.3","46.3", 101627308L, false, 5),
\r
145 new osm_map_values("Washington State","-125.0", "45.5","-116.9", "49.0", 98178877L, false, 5),
\r
146 new osm_map_values("South+Middle America","-83.5", "-56.3","-30.8", "13.7", 159615197L, true, 6),
\r
147 new osm_map_values("Argentina", "-73.9","-57.3", "-51.6","-21.0", 87516152L, false, 6),
\r
148 new osm_map_values("Argentina+Chile","-77.2", "-56.3","-52.7", "-16.1", 91976696L, false, 6),
\r
149 new osm_map_values("Bolivia", "-70.5","-23.1", "-57.3","-9.3", 58242168L, false, 6),
\r
150 new osm_map_values("Brazil", "-71.4","-34.7", "-32.8","5.4", 105527899L, false, 6),
\r
151 new osm_map_values("Cuba", "-85.3","19.6", "-74.0","23.6", 56608942L, false, 6),
\r
152 new osm_map_values("Colombia", "-79.1","-4.0", "-66.7","12.6", 78658454L, false, 6),
\r
153 new osm_map_values("Ecuador", "-82.6","-5.4", "-74.4","2.3", 61501914L, false, 6),
\r
154 new osm_map_values("Guyana+Suriname+Guyane Francaise","-62.0", "1.0","-51.2", "8.9", 57040689L, false, 6),
\r
155 new osm_map_values("Haiti+Republica Dominicana","-74.8", "17.3","-68.2", "20.1", 63528584L, false, 6),
\r
156 new osm_map_values("Jamaica", "-78.6","17.4", "-75.9","18.9", 53958307L, false, 6),
\r
157 new osm_map_values("Mexico", "-117.6","14.1", "-86.4","32.8", 251108617L, false, 6),
\r
158 new osm_map_values("Paraguay", "-63.8","-28.1", "-53.6","-18.8", 57188715L, false, 6),
\r
159 new osm_map_values("Peru", "-82.4","-18.1", "-67.5","0.4", 65421441L, false, 6),
\r
160 new osm_map_values("Uruguay", "-59.2","-36.5", "-51.7","-29.7", 63542225L, false, 6),
\r
161 new osm_map_values("Venezuela", "-73.6","0.4", "-59.7","12.8", 64838882L, false, 6)
\r
164 public static String[] OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE = null;
\r
166 public static int[] OSM_MAP_NAME_ORIG_ID_LIST = null;
\r
168 private static Boolean already_inited = false;
\r
170 public Boolean stop_me = false;
\r
171 static final int SOCKET_CONNECT_TIMEOUT = 25000; // 25 secs.
\r
172 static final int SOCKET_READ_TIMEOUT = 15000; // 15 secs.
\r
173 static final int MAP_WRITE_FILE_BUFFER = 1024 * 64;
\r
174 static final int MAP_WRITE_MEM_BUFFER = 1024 * 64;
\r
175 static final int MAP_READ_FILE_BUFFER = 1024 * 64;
\r
176 static final int UPDATE_PROGRESS_EVERY_CYCLE = 8;
\r
178 static final String DOWNLOAD_FILENAME = "navitmap.tmp";
\r
179 static final String MAP_FILENAME_PRI = "navitmap.bin";
\r
180 static final String MAP_FILENAME_SEC = "navitmap_002.bin";
\r
181 static final String MAP_FILENAME_PATH = Navit.MAP_FILENAME_PATH;
\r
183 static final int MAX_MAP_COUNT = 200;
\r
185 public class ProgressThread extends Thread
\r
188 osm_map_values map_values;
\r
192 ProgressThread(Handler h, osm_map_values map_values, int map_num2)
\r
195 this.map_values = map_values;
\r
196 this.map_num = map_num2;
\r
197 if (this.map_num == Navit.MAP_NUM_PRIMARY)
\r
199 this.my_dialog_num = Navit.MAPDOWNLOAD_PRI_DIALOG;
\r
201 else if (this.map_num == Navit.MAP_NUM_SECONDARY)
\r
203 this.my_dialog_num = Navit.MAPDOWNLOAD_SEC_DIALOG;
\r
210 int exit_code = download_osm_map(mHandler, map_values, this.map_num);
\r
212 // ok, remove dialog
\r
213 Message msg = mHandler.obtainMessage();
\r
214 Bundle b = new Bundle();
\r
216 b.putInt("dialog_num", this.my_dialog_num);
\r
217 b.putInt("exit_code", exit_code);
\r
219 mHandler.sendMessage(msg);
\r
222 public void stop_thread()
\r
225 Log.d("NavitMapDownloader", "stop_me -> true");
\r
229 public Navit navit_jmain = null;
\r
231 public NavitMapDownloader(Navit main)
\r
233 this.navit_jmain = main;
\r
236 public static void init()
\r
238 // need only init once
\r
239 if (already_inited) { return; }
\r
241 //String[] temp_m = new String[MAX_MAP_COUNT];
\r
242 String[] temp_ml = new String[MAX_MAP_COUNT];
\r
243 int[] temp_i = new int[MAX_MAP_COUNT];
\r
244 Boolean[] already_added = new Boolean[osm_maps.length];
\r
245 int cur_continent = -1;
\r
247 Log.v("NavitMapDownloader", "init maps");
\r
248 for (int i = 0; i < osm_maps.length; i++)
\r
250 already_added[i] = false;
\r
252 for (int i = 0; i < osm_maps.length; i++)
\r
254 //Log.v("NavitMapDownloader", "i=" + i);
\r
255 // look for continents only
\r
256 if (osm_maps[i].is_continent)
\r
260 // add a break into list
\r
261 //temp_m[count] = "*break*";
\r
262 temp_ml[count] = "======";
\r
263 temp_i[count] = -1;
\r
267 cur_continent = osm_maps[i].continent_id;
\r
268 //Log.v("NavitMapDownloader", "found cont=" + cur_continent);
\r
270 //temp_m[count] = OSM_MAPS[i].map_name;
\r
271 temp_ml[count] = osm_maps[i].text_for_select_list;
\r
274 already_added[i] = true;
\r
275 for (int j = 0; j < osm_maps.length; j++)
\r
277 // if (already_added[j] == null)
\r
278 if (!already_added[j])
\r
280 // look for maps in that continent
\r
281 if ((osm_maps[j].continent_id == cur_continent) && (!osm_maps[j].is_continent))
\r
283 //Log.v("NavitMapDownloader", "found map=" + j + " c=" + cur_continent);
\r
285 //temp_m[count] = OSM_MAPS[j].map_name;
\r
286 temp_ml[count] = " * " + osm_maps[j].text_for_select_list;
\r
289 already_added[j] = true;
\r
295 // add the rest of the list (dont have a continent)
\r
296 cur_continent = 9999; // unknown
\r
298 for (int i = 0; i < osm_maps.length; i++)
\r
300 if (!already_added[i])
\r
305 // add a break into list
\r
306 //temp_m[count] = "*break*";
\r
307 temp_ml[count] = "======";
\r
308 temp_i[count] = -1;
\r
312 //Log.v("NavitMapDownloader", "found map(loose)=" + i + " c=" + cur_continent);
\r
314 //temp_m[count] = OSM_MAPS[i].map_name;
\r
315 temp_ml[count] = " # " + osm_maps[i].text_for_select_list;
\r
318 already_added[i] = true;
\r
322 Log.e("NavitMapDownloader", "count=" + count);
\r
323 Log.e("NavitMapDownloader", "size1 " + osm_maps.length);
\r
324 //Log.e("NavitMapDownloader", "size2 " + temp_m.length);
\r
325 Log.e("NavitMapDownloader", "size3 " + temp_ml.length);
\r
327 //OSM_MAP_NAME_LIST = new String[count];
\r
328 OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE = new String[count];
\r
329 OSM_MAP_NAME_ORIG_ID_LIST = new int[count];
\r
331 for (int i = 0; i < count; i++)
\r
333 //OSM_MAP_NAME_LIST[i] = temp_m[i];
\r
334 OSM_MAP_NAME_ORIG_ID_LIST[i] = temp_i[i];
\r
335 OSM_MAP_NAME_LIST_inkl_SIZE_ESTIMATE[i] = temp_ml[i];
\r
338 already_inited = true;
\r
341 public int download_osm_map(Handler handler, osm_map_values map_values, int map_num3)
\r
345 //Log.v("NavitMapDownloader", "map_num3=" + map_num3);
\r
346 int my_dialog_num = 0;
\r
347 if (map_num3 == Navit.MAP_NUM_PRIMARY)
\r
349 my_dialog_num = Navit.MAPDOWNLOAD_PRI_DIALOG;
\r
350 //Log.v("NavitMapDownloader", "PRI");
\r
352 else if (map_num3 == Navit.MAP_NUM_SECONDARY)
\r
354 my_dialog_num = Navit.MAPDOWNLOAD_SEC_DIALOG;
\r
355 //Log.v("NavitMapDownloader", "SEC");
\r
357 //Log.v("NavitMapDownloader", "map_num3=" + map_num3);
\r
359 Message msg = handler.obtainMessage();
\r
360 Bundle b = new Bundle();
\r
362 b.putInt("max", 20); // use a dummy number here
\r
363 b.putInt("cur", 0);
\r
364 b.putInt("dialog_num", my_dialog_num);
\r
365 b.putString("title", Navit.get_text("Mapdownload")); //TRANS
\r
366 b.putString("text", Navit.get_text("downloading") + ": " + map_values.map_name); //TRANS
\r
368 handler.sendMessage(msg);
\r
371 // little pause here
\r
374 catch (InterruptedException e1)
\r
379 String PATH = MAP_FILENAME_PATH;
\r
380 String fileName = DOWNLOAD_FILENAME;
\r
381 String final_fileName = "xxx";
\r
382 //Log.v("NavitMapDownloader", "map_num3=" + map_num3);
\r
383 if (map_num3 == Navit.MAP_NUM_SECONDARY)
\r
385 final_fileName = MAP_FILENAME_SEC;
\r
387 else if (map_num3 == Navit.MAP_NUM_PRIMARY)
\r
389 final_fileName = MAP_FILENAME_PRI;
\r
391 // output path for output filename
\r
392 // String PATH = Environment.getExternalStorageDirectory() + "/download/";
\r
396 URL url = new URL("http://maps.navit-project.org/api/map/?bbox=" + map_values.lon1 + ","
\r
397 + map_values.lat1 + "," + map_values.lon2 + "," + map_values.lat2);
\r
398 HttpURLConnection c = (HttpURLConnection) url.openConnection();
\r
399 c.setRequestMethod("GET");
\r
400 c.setDoOutput(true);
\r
401 c.setReadTimeout(SOCKET_READ_TIMEOUT);
\r
402 c.setConnectTimeout(SOCKET_CONNECT_TIMEOUT);
\r
403 long real_size_bytes = c.getContentLength();
\r
406 Log.d("NavitMapDownloader", "real size in bytes: " + real_size_bytes);
\r
407 if (real_size_bytes > 20)
\r
409 // change the estimated filesize to reported filesize
\r
410 map_values.est_size_bytes = real_size_bytes;
\r
412 Log.d("NavitMapDownloader", "size in bytes: " + map_values.est_size_bytes);
\r
414 File file = new File(PATH);
\r
415 File outputFile = new File(file, fileName);
\r
416 File final_outputFile = new File(file, final_fileName);
\r
417 // tests have shown that deleting the file first is sometimes faster -> so we delete it (who knows)
\r
418 outputFile.delete();
\r
419 // seems this command overwrites the output file anyway
\r
420 FileOutputStream fos = new FileOutputStream(outputFile);
\r
421 BufferedOutputStream buf = new BufferedOutputStream(fos, MAP_WRITE_FILE_BUFFER); // buffer
\r
423 InputStream is = c.getInputStream();
\r
424 BufferedInputStream bif = new BufferedInputStream(is, MAP_READ_FILE_BUFFER); // buffer
\r
426 byte[] buffer = new byte[MAP_WRITE_MEM_BUFFER]; // buffer
\r
428 int already_read = 0;
\r
429 int alt = UPDATE_PROGRESS_EVERY_CYCLE; // show progress about every xx cylces
\r
431 String kbytes_per_second = "";
\r
432 long start_timestamp = System.currentTimeMillis();
\r
433 NumberFormat formatter = new DecimalFormat("00000.0");
\r
434 String eta_string = "";
\r
435 float per_second_overall = 0f;
\r
436 long bytes_remaining = 0;
\r
437 int eta_seconds = 0;
\r
438 while ((len1 = bif.read(buffer)) != -1)
\r
442 // ok we need to be stopped! close all files and end
\r
451 already_read = already_read + len1;
\r
457 msg = handler.obtainMessage();
\r
460 b.putInt("max", (int) (map_values.est_size_bytes / 1024));
\r
461 b.putInt("cur", (int) (already_read / 1024));
\r
462 b.putInt("dialog_num", my_dialog_num);
\r
463 b.putString("title", Navit.get_text("Mapdownload")); //TRANS
\r
464 per_second_overall = (float) already_read
\r
465 / (float) ((System.currentTimeMillis() - start_timestamp) / 1000);
\r
466 kbytes_per_second = formatter.format((per_second_overall / 1024f));
\r
467 bytes_remaining = map_values.est_size_bytes - already_read;
\r
468 eta_seconds = (int) ((float) bytes_remaining / (float) per_second_overall);
\r
469 if (eta_seconds > 60)
\r
471 eta_string = (int) (eta_seconds / 60f) + " m";
\r
475 eta_string = eta_seconds + " s";
\r
478 .putString("text", Navit.get_text("downloading") + ": " + map_values.map_name
\r
479 + "\n" + " " + (int) (already_read / 1024f / 1024f) + "Mb / "
\r
480 + (int) (map_values.est_size_bytes / 1024f / 1024f) + "Mb" + "\n" + " "
\r
481 + kbytes_per_second + "kb/s" + " " + Navit.get_text("ETA") + ": "
\r
482 + eta_string); //TRANS
\r
484 handler.sendMessage(msg);
\r
486 buf.write(buffer, 0, len1);
\r
498 // delete an already final filename, first
\r
499 final_outputFile.delete();
\r
500 // rename file to final name
\r
501 outputFile.renameTo(final_outputFile);
\r
503 catch (IOException e)
\r
505 msg = handler.obtainMessage();
\r
508 b.putInt("dialog_num", my_dialog_num);
\r
509 b.putString("text", Navit.get_text("Error downloading map!")); //TRANS
\r
511 handler.sendMessage(msg);
\r
513 Log.d("NavitMapDownloader", "Error: " + e);
\r
516 catch (Exception e)
\r
518 msg = handler.obtainMessage();
\r
521 b.putInt("dialog_num", my_dialog_num);
\r
522 b.putString("text", Navit.get_text("Error downloading map!")); //TRANS
\r
524 handler.sendMessage(msg);
\r
526 Log.d("NavitMapDownloader", "gerneral Error: " + e);
\r
530 msg = handler.obtainMessage();
\r
533 b.putInt("max", (int) (map_values.est_size_bytes / 1024));
\r
534 b.putInt("cur", (int) (map_values.est_size_bytes / 1024));
\r
535 b.putInt("dialog_num", my_dialog_num);
\r
536 b.putString("title", Navit.get_text("Mapdownload")); //TRANS
\r
537 b.putString("text", map_values.map_name + " "+Navit.get_text("ready")); //TRANS
\r
539 handler.sendMessage(msg);
\r
542 Log.d("NavitMapDownloader", "success");
\r