1 | /**
|
1 | /**
|
2 | * ZANavi, Zoff Android Navigation system.
|
2 | * ZANavi, Zoff Android Navigation system.
|
3 | * Copyright (C) 2011 Zoff <zoff@zoff.cc>
|
3 | * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc>
|
4 | *
|
4 | *
|
5 | * This program is free software; you can redistribute it and/or
|
5 | * This program is free software; you can redistribute it and/or
|
6 | * modify it under the terms of the GNU General Public License
|
6 | * modify it under the terms of the GNU General Public License
|
7 | * version 2 as published by the Free Software Foundation.
|
7 | * version 2 as published by the Free Software Foundation.
|
8 | *
|
8 | *
|
… | |
… | |
44 | import java.io.FileOutputStream;
|
44 | import java.io.FileOutputStream;
|
45 | import java.io.IOException;
|
45 | import java.io.IOException;
|
46 | import java.io.InputStream;
|
46 | import java.io.InputStream;
|
47 | import java.io.ObjectInputStream;
|
47 | import java.io.ObjectInputStream;
|
48 | import java.io.ObjectOutputStream;
|
48 | import java.io.ObjectOutputStream;
|
|
|
49 | import java.io.OutputStream;
|
49 | import java.io.Serializable;
|
50 | import java.io.Serializable;
|
50 | import java.net.URLDecoder;
|
51 | import java.net.URLDecoder;
|
|
|
52 | import java.nio.channels.FileChannel;
|
51 | import java.util.ArrayList;
|
53 | import java.util.ArrayList;
|
52 | import java.util.HashSet;
|
54 | import java.util.HashSet;
|
53 | import java.util.List;
|
55 | import java.util.List;
|
54 | import java.util.Locale;
|
56 | import java.util.Locale;
|
55 | import java.util.Set;
|
57 | import java.util.Set;
|
… | |
… | |
67 | import android.content.pm.PackageManager.NameNotFoundException;
|
69 | import android.content.pm.PackageManager.NameNotFoundException;
|
68 | import android.content.res.Configuration;
|
70 | import android.content.res.Configuration;
|
69 | import android.content.res.Resources;
|
71 | import android.content.res.Resources;
|
70 | import android.graphics.Bitmap;
|
72 | import android.graphics.Bitmap;
|
71 | import android.graphics.BitmapFactory;
|
73 | import android.graphics.BitmapFactory;
|
|
|
74 | import android.graphics.Typeface;
|
72 | import android.hardware.Sensor;
|
75 | import android.hardware.Sensor;
|
73 | import android.hardware.SensorEvent;
|
76 | import android.hardware.SensorEvent;
|
74 | import android.hardware.SensorEventListener;
|
77 | import android.hardware.SensorEventListener;
|
75 | import android.hardware.SensorManager;
|
78 | import android.hardware.SensorManager;
|
76 | import android.location.Address;
|
79 | import android.location.Address;
|
… | |
… | |
79 | import android.location.LocationManager;
|
82 | import android.location.LocationManager;
|
80 | import android.media.AudioManager;
|
83 | import android.media.AudioManager;
|
81 | import android.net.Uri;
|
84 | import android.net.Uri;
|
82 | import android.os.Bundle;
|
85 | import android.os.Bundle;
|
83 | import android.os.Debug;
|
86 | import android.os.Debug;
|
|
|
87 | import android.os.Environment;
|
84 | import android.os.Handler;
|
88 | import android.os.Handler;
|
85 | import android.os.Message;
|
89 | import android.os.Message;
|
86 | import android.os.PowerManager;
|
90 | import android.os.PowerManager;
|
87 | import android.preference.PreferenceManager;
|
91 | import android.preference.PreferenceManager;
|
88 | import android.text.SpannableString;
|
92 | import android.text.SpannableString;
|
… | |
… | |
106 | import com.casadelgato.widgets.NumberPicker;
|
110 | import com.casadelgato.widgets.NumberPicker;
|
107 | import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
|
111 | import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
|
108 |
|
112 |
|
109 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
113 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
110 | {
|
114 | {
|
111 | public static final String VERSION_TEXT_LONG_INC_REV = "954";
|
115 | public static final String VERSION_TEXT_LONG_INC_REV = "1401";
|
112 | public static String NavitAppVersion = "0";
|
116 | public static String NavitAppVersion = "0";
|
113 | public static String NavitAppVersion_prev = "-1";
|
117 | public static String NavitAppVersion_prev = "-1";
|
114 | public static String NavitAppVersion_string = "0";
|
118 | public static String NavitAppVersion_string = "0";
|
115 | private Boolean xmlconfig_unpack_file = true;
|
119 | private Boolean xmlconfig_unpack_file = true;
|
116 | private Boolean write_new_version_file = true;
|
120 | private Boolean write_new_version_file = true;
|
117 | final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
|
121 | final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
|
118 | final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
|
122 | final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
|
119 | final static int Navit_Status_NORMAL_STARTUP = 0;
|
123 | final static int Navit_Status_NORMAL_STARTUP = 0;
|
120 | Boolean Navit_DonateVersion_Installed = false;
|
124 | Boolean Navit_DonateVersion_Installed = false;
|
|
|
125 | static Boolean Navit_Largemap_DonateVersion_Installed = false;
|
121 | private int startup_status = Navit_Status_NORMAL_STARTUP;
|
126 | private int startup_status = Navit_Status_NORMAL_STARTUP;
|
122 | final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
|
127 | final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
|
123 | static Boolean unsupported = false;
|
128 | static Boolean unsupported = false;
|
|
|
129 | static Boolean Navit_maps_loaded = false;
|
|
|
130 | final static int Navit_MAX_RECENT_DESTINATIONS = 50;
|
124 |
|
131 |
|
125 | // for future use ...
|
132 | // for future use ...
|
126 | public static String NavitDataDirectory = "/sdcard/";
|
133 | // public static String NavitDataDirectory = "/sdcard/";
|
|
|
134 | public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
|
127 |
|
135 |
|
128 | public static int GlobalScaleLevel = 0;
|
136 | public static int GlobalScaleLevel = 0;
|
|
|
137 |
|
|
|
138 | public class CopyFiles
|
|
|
139 | {
|
|
|
140 | public void copyFiles(File sourceLocation, File targetLocation) throws IOException
|
|
|
141 | {
|
|
|
142 | if (sourceLocation.isDirectory())
|
|
|
143 | {
|
|
|
144 | if (!targetLocation.exists())
|
|
|
145 | {
|
|
|
146 | targetLocation.mkdir();
|
|
|
147 | }
|
|
|
148 | File[] files = sourceLocation.listFiles();
|
|
|
149 | for (File file : files)
|
|
|
150 | {
|
|
|
151 | InputStream in = new FileInputStream(file);
|
|
|
152 | OutputStream out = new FileOutputStream(targetLocation + "/" + file.getName());
|
|
|
153 |
|
|
|
154 | // Copy the bits from input stream to output stream
|
|
|
155 | byte[] buf = new byte[1024];
|
|
|
156 | int len;
|
|
|
157 | while ((len = in.read(buf)) > 0)
|
|
|
158 | {
|
|
|
159 | out.write(buf, 0, len);
|
|
|
160 | }
|
|
|
161 | in.close();
|
|
|
162 | out.close();
|
|
|
163 | }
|
|
|
164 | }
|
|
|
165 | }
|
|
|
166 | }
|
|
|
167 |
|
|
|
168 | private static void copyFile(File sourceFile, File destFile) throws IOException
|
|
|
169 | {
|
|
|
170 | if (!sourceFile.exists())
|
|
|
171 | {
|
|
|
172 | return;
|
|
|
173 | }
|
|
|
174 | if (!destFile.exists())
|
|
|
175 | {
|
|
|
176 | destFile.createNewFile();
|
|
|
177 | }
|
|
|
178 | FileChannel source = null;
|
|
|
179 | FileChannel destination = null;
|
|
|
180 | source = new FileInputStream(sourceFile).getChannel();
|
|
|
181 | destination = new FileOutputStream(destFile).getChannel();
|
|
|
182 | if (destination != null && source != null)
|
|
|
183 | {
|
|
|
184 | destination.transferFrom(source, 0, source.size());
|
|
|
185 | }
|
|
|
186 | if (source != null)
|
|
|
187 | {
|
|
|
188 | source.close();
|
|
|
189 | }
|
|
|
190 | if (destination != null)
|
|
|
191 | {
|
|
|
192 | destination.close();
|
|
|
193 | }
|
|
|
194 |
|
|
|
195 | }
|
129 |
|
196 |
|
130 | public static final class Navit_Address_Result_Struct
|
197 | public static final class Navit_Address_Result_Struct
|
131 | {
|
198 | {
|
132 | String result_type; // TWN,STR,SHN
|
199 | String result_type; // TWN,STR,SHN
|
133 | String item_id; // H<ddddd>L<ddddd> -> item.id_hi item.id_lo
|
200 | String item_id; // H<ddddd>L<ddddd> -> item.id_hi item.id_lo
|
… | |
… | |
238 | ProgressThread progressThread_pri = null;
|
305 | ProgressThread progressThread_pri = null;
|
239 | ProgressThread progressThread_sec = null;
|
306 | ProgressThread progressThread_sec = null;
|
240 | public static int search_results_towns = 0;
|
307 | public static int search_results_towns = 0;
|
241 | public static int search_results_streets = 0;
|
308 | public static int search_results_streets = 0;
|
242 | public static int search_results_streets_hn = 0;
|
309 | public static int search_results_streets_hn = 0;
|
|
|
310 | public static Boolean NavitStartupAlreadySearching = false;
|
243 | SearchResultsThread searchresultsThread = null;
|
311 | SearchResultsThread searchresultsThread = null;
|
244 | SearchResultsThread searchresultsThread_offline = null;
|
312 | SearchResultsThread searchresultsThread_offline = null;
|
245 | SearchResultsThreadSpinnerThread spinner_thread = null;
|
313 | SearchResultsThreadSpinnerThread spinner_thread = null;
|
246 | SearchResultsThreadSpinnerThread spinner_thread_offline = null;
|
314 | SearchResultsThreadSpinnerThread spinner_thread_offline = null;
|
247 | public static Boolean NavitAddressSearchSpinnerActive = false;
|
315 | public static Boolean NavitAddressSearchSpinnerActive = false;
|
… | |
… | |
254 | public static final int NavitAddressSearch_id_gmaps = 76;
|
322 | public static final int NavitAddressSearch_id_gmaps = 76;
|
255 | public static int NavitSearchresultBarIndex = -1;
|
323 | public static int NavitSearchresultBarIndex = -1;
|
256 | public static String NavitSearchresultBar_title = "";
|
324 | public static String NavitSearchresultBar_title = "";
|
257 | public static String NavitSearchresultBar_text = "";
|
325 | public static String NavitSearchresultBar_text = "";
|
258 | public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();
|
326 | public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();
|
|
|
327 | public static Boolean DemoVehicle = false;
|
|
|
328 |
|
|
|
329 | static Typeface NavitStreetnameFont = null;
|
259 |
|
330 |
|
260 | public SensorManager sensorManager = null;
|
331 | public SensorManager sensorManager = null;
|
261 | //private static SensorManager sensorManager_ = null;
|
332 | //private static SensorManager sensorManager_ = null;
|
262 |
|
333 |
|
263 | public static Context getBaseContext_ = null;
|
334 | public static Context getBaseContext_ = null;
|
… | |
… | |
282 | public static Boolean first_ever_startup = false;
|
353 | public static Boolean first_ever_startup = false;
|
283 |
|
354 |
|
284 | public static Boolean Navit_Announcer = true;
|
355 | public static Boolean Navit_Announcer = true;
|
285 |
|
356 |
|
286 | public static final int MAP_NUM_SECONDARY = 12;
|
357 | public static final int MAP_NUM_SECONDARY = 12;
|
287 | static final String MAP_FILENAME_PATH = "/sdcard/zanavi/maps/";
|
358 | static String MAP_FILENAME_PATH = "/sdcard/zanavi/maps/";
|
288 | static final String MAPMD5_FILENAME_PATH = "/sdcard/zanavi/md5/";
|
359 | static String MAPMD5_FILENAME_PATH = "/sdcard/zanavi/md5/";
|
289 | static final String CFG_FILENAME_PATH = "/sdcard/zanavi/";
|
360 | static String CFG_FILENAME_PATH = "/sdcard/zanavi/";
|
290 | static final String NAVIT_DATA_DIR = "/data/data/com.zoffcc.applications.zanavi";
|
361 | static final String NAVIT_DATA_DIR = "/data/data/com.zoffcc.applications.zanavi";
|
291 | static final String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
|
362 | static final String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
|
292 | static final String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
|
363 | static final String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
|
293 | static final String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
|
364 | static final String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
|
294 | static final String Navit_DEST_FILENAME = "destinations.dat";
|
365 | static final String Navit_DEST_FILENAME = "destinations.dat";
|
… | |
… | |
308 | Resources res = getResources();
|
379 | Resources res = getResources();
|
309 | Log.e("Navit", "Res Name " + resname);
|
380 | Log.e("Navit", "Res Name " + resname);
|
310 | Log.e("Navit", "result " + result);
|
381 | Log.e("Navit", "result " + result);
|
311 | int id = res.getIdentifier(resname, "raw", "com.zoffcc.applications.zanavi");
|
382 | int id = res.getIdentifier(resname, "raw", "com.zoffcc.applications.zanavi");
|
312 | Log.e("Navit", "Res ID " + id);
|
383 | Log.e("Navit", "Res ID " + id);
|
313 | if (id == 0) return false;
|
384 |
|
|
|
385 | if (id == 0)
|
|
|
386 | {
|
|
|
387 | return false;
|
|
|
388 | }
|
|
|
389 |
|
314 | while ((slash = result.indexOf("/", slash + 1)) != -1)
|
390 | while ((slash = result.indexOf("/", slash + 1)) != -1)
|
315 | {
|
391 | {
|
316 | if (slash != 0)
|
392 | if (slash != 0)
|
317 | {
|
393 | {
|
318 | Log.e("Navit", "Checking " + result.substring(0, slash));
|
394 | Log.e("Navit", "Checking " + result.substring(0, slash));
|
… | |
… | |
323 | if (!resultfile.mkdir()) return false;
|
399 | if (!resultfile.mkdir()) return false;
|
324 | needs_update = true;
|
400 | needs_update = true;
|
325 | }
|
401 | }
|
326 | }
|
402 | }
|
327 | }
|
403 | }
|
|
|
404 |
|
328 | resultfile = new File(result);
|
405 | resultfile = new File(result);
|
329 | if (!resultfile.exists()) needs_update = true;
|
406 |
|
|
|
407 | if (!resultfile.exists())
|
|
|
408 | {
|
|
|
409 | needs_update = true;
|
|
|
410 | }
|
|
|
411 |
|
330 | if (!needs_update)
|
412 | if (!needs_update)
|
331 | {
|
413 | {
|
332 | try
|
414 | try
|
333 | {
|
415 | {
|
334 | InputStream resourcestream = res.openRawResource(id);
|
416 | InputStream resourcestream = res.openRawResource(id);
|
… | |
… | |
366 | {
|
448 | {
|
367 | Log.e("Navit", "Exception " + e.getMessage());
|
449 | Log.e("Navit", "Exception " + e.getMessage());
|
368 | return false;
|
450 | return false;
|
369 | }
|
451 | }
|
370 | }
|
452 | }
|
|
|
453 |
|
371 | if (needs_update)
|
454 | if (needs_update)
|
372 | {
|
455 | {
|
373 | Log.e("Navit", "Extracting resource");
|
456 | Log.e("Navit", "Extracting resource");
|
374 |
|
|
|
375 | try
|
457 | try
|
376 | {
|
458 | {
|
377 | InputStream resourcestream = res.openRawResource(id);
|
459 | InputStream resourcestream = res.openRawResource(id);
|
378 | FileOutputStream resultfilestream = new FileOutputStream(resultfile);
|
460 | FileOutputStream resultfilestream = new FileOutputStream(resultfile);
|
379 | byte[] buf = new byte[1024];
|
461 | byte[] buf = new byte[1024];
|
… | |
… | |
399 | super.onCreate(savedInstanceState);
|
481 | super.onCreate(savedInstanceState);
|
400 |
|
482 |
|
401 | getBaseContext_ = getBaseContext();
|
483 | getBaseContext_ = getBaseContext();
|
402 |
|
484 |
|
403 | res_ = getResources();
|
485 | res_ = getResources();
|
|
|
486 |
|
|
|
487 | NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), "Soutane Regular.ttf");
|
|
|
488 |
|
|
|
489 | Navit_maps_loaded = false;
|
404 |
|
490 |
|
405 | // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
|
491 | // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
|
406 | Navit.startup_intent = this.getIntent();
|
492 | Navit.startup_intent = this.getIntent();
|
407 | // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
493 | // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
408 | Navit.startup_intent_timestamp = System.currentTimeMillis();
|
494 | Navit.startup_intent_timestamp = System.currentTimeMillis();
|
… | |
… | |
416 |
|
502 |
|
417 | // set the new locale here -----------------------------------
|
503 | // set the new locale here -----------------------------------
|
418 | getPrefs_loc();
|
504 | getPrefs_loc();
|
419 | activatePrefs_loc();
|
505 | activatePrefs_loc();
|
420 | // set the new locale here -----------------------------------
|
506 | // set the new locale here -----------------------------------
|
|
|
507 |
|
|
|
508 | // set map cache size here -----------------------------------
|
|
|
509 | getPrefs_mapcache();
|
|
|
510 | activatePrefs_mapcache();
|
|
|
511 | // set map cache size here -----------------------------------
|
|
|
512 |
|
|
|
513 | // get map data dir and set it -----------------------------
|
|
|
514 | getPrefs_mapdir();
|
|
|
515 | activatePrefs_mapdir(true);
|
|
|
516 | // get map data dir and set it -----------------------------
|
421 |
|
517 |
|
422 | // get the local language -------------
|
518 | // get the local language -------------
|
423 | Locale locale = java.util.Locale.getDefault();
|
519 | Locale locale = java.util.Locale.getDefault();
|
424 | String lang = locale.getLanguage();
|
520 | String lang = locale.getLanguage();
|
425 | String langu = lang;
|
521 | String langu = lang;
|
… | |
… | |
466 |
|
562 |
|
467 | // try to create cat. file if it does not exist
|
563 | // try to create cat. file if it does not exist
|
468 | File navit_maps_catalogue = new File(CFG_FILENAME_PATH + NavitMapDownloader.CAT_FILE);
|
564 | File navit_maps_catalogue = new File(CFG_FILENAME_PATH + NavitMapDownloader.CAT_FILE);
|
469 | if (!navit_maps_catalogue.exists())
|
565 | if (!navit_maps_catalogue.exists())
|
470 | {
|
566 | {
|
471 | // only on complete new start (cat file doesnt yet exist)
|
|
|
472 | // when user puts old files in dir later on, its users problem
|
|
|
473 | // because we dont want to overwrite new/good map files in new mapdir
|
|
|
474 | File old_map1 = new File(CFG_FILENAME_PATH + "navitmap.bin");
|
|
|
475 | File old_map2 = new File(CFG_FILENAME_PATH + "navitmap_002.bin");
|
|
|
476 | if (old_map1.exists())
|
|
|
477 | {
|
|
|
478 | // move it to new dir
|
|
|
479 | old_map1.renameTo(new File(MAP_FILENAME_PATH + "/navitmap_001.bin"));
|
|
|
480 | }
|
|
|
481 | if (old_map2.exists())
|
|
|
482 | {
|
|
|
483 | // move it to new dir
|
|
|
484 | old_map2.renameTo(new File(MAP_FILENAME_PATH + "/navitmap_002.bin"));
|
|
|
485 | }
|
|
|
486 |
|
|
|
487 | FileOutputStream fos_temp;
|
567 | FileOutputStream fos_temp;
|
488 | try
|
568 | try
|
489 | {
|
569 | {
|
490 | fos_temp = new FileOutputStream(navit_maps_catalogue);
|
570 | fos_temp = new FileOutputStream(navit_maps_catalogue);
|
491 | fos_temp.write((NavitMapDownloader.MAP_CAT_HEADER + "\n").getBytes()); // just write header to the file
|
571 | fos_temp.write((NavitMapDownloader.MAP_CAT_HEADER + "\n").getBytes()); // just write header to the file
|
… | |
… | |
496 | {
|
576 | {
|
497 | e.printStackTrace();
|
577 | e.printStackTrace();
|
498 | }
|
578 | }
|
499 | }
|
579 | }
|
500 |
|
580 |
|
501 | // downloader threads
|
581 | // ---------- downloader threads ----------------
|
502 | NavitMapDownloader.MULTI_NUM_THREADS = 1;
|
582 | NavitMapDownloader.MULTI_NUM_THREADS = 1;
|
503 | PackageInfo pkgInfo;
|
583 | PackageInfo pkgInfo;
|
504 | Navit_DonateVersion_Installed = false;
|
584 | Navit_DonateVersion_Installed = false;
|
505 | try
|
585 | try
|
506 | {
|
586 | {
|
507 | // is the donate version installed?
|
587 | // is the donate version installed?
|
508 | pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_donate", 0);
|
588 | pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_donate", 0);
|
509 | String sharedUserId = pkgInfo.sharedUserId;
|
589 | String sharedUserId = pkgInfo.sharedUserId;
|
510 | System.out.println("str=" + sharedUserId);
|
590 | System.out.println("str nd=" + sharedUserId);
|
511 | if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
591 | if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
512 | {
|
592 | {
|
513 | System.out.println("##bonus 001##");
|
593 | System.out.println("##bonus 001##");
|
514 | Navit_DonateVersion_Installed = true;
|
594 | Navit_DonateVersion_Installed = true;
|
515 | NavitMapDownloader.MULTI_NUM_THREADS = 4;
|
595 | NavitMapDownloader.MULTI_NUM_THREADS = 3;
|
516 | }
|
596 | }
|
517 | }
|
597 | }
|
518 | catch (NameNotFoundException e)
|
598 | catch (NameNotFoundException e)
|
519 | {
|
599 | {
|
520 | e.printStackTrace();
|
600 | e.printStackTrace();
|
521 | }
|
601 | }
|
522 | catch (Exception e)
|
602 | catch (Exception e)
|
523 | {
|
603 | {
|
524 | e.printStackTrace();
|
604 | e.printStackTrace();
|
525 | }
|
605 | }
|
526 | // downloader threads
|
606 |
|
|
|
607 | try
|
|
|
608 | {
|
|
|
609 | // is the "large map" donate version installed?
|
|
|
610 | pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0);
|
|
|
611 | String sharedUserId = pkgInfo.sharedUserId;
|
|
|
612 | System.out.println("str lm=" + sharedUserId);
|
|
|
613 | if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
|
|
614 | {
|
|
|
615 | System.out.println("##bonus 002##");
|
|
|
616 | Navit_DonateVersion_Installed = true;
|
|
|
617 | Navit_Largemap_DonateVersion_Installed = true;
|
|
|
618 | NavitMapDownloader.MULTI_NUM_THREADS = 3;
|
|
|
619 | }
|
|
|
620 | }
|
|
|
621 | catch (NameNotFoundException e)
|
|
|
622 | {
|
|
|
623 | e.printStackTrace();
|
|
|
624 | }
|
|
|
625 | catch (Exception e)
|
|
|
626 | {
|
|
|
627 | e.printStackTrace();
|
|
|
628 | }
|
|
|
629 | // update map list
|
|
|
630 | NavitMapDownloader.init_maps_without_donate_largemaps();
|
|
|
631 | // ---------- downloader threads ----------------
|
527 |
|
632 |
|
528 | Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow);
|
633 | Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow);
|
529 | Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off);
|
634 | Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off);
|
530 | Navit.follow_current = Navit.follow_on;
|
635 | Navit.follow_current = Navit.follow_on;
|
531 |
|
636 |
|
… | |
… | |
694 | {
|
799 | {
|
695 | UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
800 | UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
696 | }
|
801 | }
|
697 | else
|
802 | else
|
698 | {
|
803 | {
|
|
|
804 | if (Navit_Largemap_DonateVersion_Installed == false)
|
|
|
805 | {
|
699 | UserAgentString = "Mozilla/5.0 (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
806 | UserAgentString = "Mozilla/5.0 (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
700 | }
|
807 | }
|
|
|
808 | else
|
|
|
809 | {
|
|
|
810 | UserAgentString = "Mozilla/5.0 (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
|
|
811 | }
|
|
|
812 | }
|
701 | System.out.println("UA=" + UserAgentString);
|
813 | // System.out.println("UA=" + UserAgentString);
|
702 |
|
814 |
|
703 | unsupported = false;
|
815 | unsupported = false;
|
704 | try
|
816 | try
|
705 | {
|
817 | {
|
706 | if (android_device.toLowerCase().contains("telechips"))
|
818 | if (android_device.toLowerCase().contains("telechips"))
|
… | |
… | |
708 | if (android_device.toLowerCase().contains("m801"))
|
820 | if (android_device.toLowerCase().contains("m801"))
|
709 | {
|
821 | {
|
710 | // if the donate version is already installed, dont disable the app
|
822 | // if the donate version is already installed, dont disable the app
|
711 | if (Navit_DonateVersion_Installed == false)
|
823 | if (Navit_DonateVersion_Installed == false)
|
712 | {
|
824 | {
|
|
|
825 | if (Navit_Largemap_DonateVersion_Installed == false)
|
|
|
826 | {
|
|
|
827 | // activate [Weltbild] Cat Nova again (19.12.2011)
|
713 | unsupported = true;
|
828 | // ** // unsupported = true;
|
|
|
829 | }
|
714 | }
|
830 | }
|
715 | }
|
831 | }
|
716 | }
|
832 | }
|
717 | }
|
833 | }
|
718 | catch (Exception e)
|
834 | catch (Exception e)
|
… | |
… | |
720 | e.printStackTrace();
|
836 | e.printStackTrace();
|
721 | }
|
837 | }
|
722 |
|
838 |
|
723 | try
|
839 | try
|
724 | {
|
840 | {
|
|
|
841 | // this hangs the emulator, if emulator < 2.3 (only works in emulator >= 2.3)!!
|
725 | sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
842 | sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
726 | }
|
843 | }
|
727 | catch (Exception e3)
|
844 | catch (Exception e3)
|
728 | {
|
845 | {
|
729 | e3.printStackTrace();
|
846 | e3.printStackTrace();
|
… | |
… | |
741 |
|
858 |
|
742 | /*
|
859 | /*
|
743 | * show info box for first time users
|
860 | * show info box for first time users
|
744 | */
|
861 | */
|
745 | AlertDialog.Builder infobox = new AlertDialog.Builder(this);
|
862 | AlertDialog.Builder infobox = new AlertDialog.Builder(this);
|
|
|
863 | //. english text: Welcome to ZANavi
|
746 | infobox.setTitle(Navit.get_text("__INFO_BOX_TITLE__")); //TRANS
|
864 | infobox.setTitle(Navit.get_text("__INFO_BOX_TITLE__")); //TRANS
|
747 | infobox.setCancelable(false);
|
865 | infobox.setCancelable(false);
|
748 | final TextView message = new TextView(this);
|
866 | final TextView message = new TextView(this);
|
749 | message.setFadingEdgeLength(20);
|
867 | message.setFadingEdgeLength(20);
|
750 | message.setVerticalFadingEdgeEnabled(true);
|
868 | message.setVerticalFadingEdgeEnabled(true);
|
… | |
… | |
805 | fos_temp.write((int) 65); // just write an "A" to the file, but it really doesnt matter
|
923 | fos_temp.write((int) 65); // just write an "A" to the file, but it really doesnt matter
|
806 | fos_temp.flush();
|
924 | fos_temp.flush();
|
807 | fos_temp.close();
|
925 | fos_temp.close();
|
808 |
|
926 |
|
809 | message.setLayoutParams(rlp);
|
927 | message.setLayoutParams(rlp);
|
|
|
928 | //. TRANSLATORS: multiline info text for first startup of application (see en_US for english text)
|
810 | final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
|
929 | final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
|
811 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
930 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
812 | message.setText(s);
|
931 | message.setText(s);
|
813 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
932 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
814 | infobox.setView(message);
|
933 | infobox.setView(message);
|
… | |
… | |
828 | if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
|
947 | if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
|
829 | {
|
948 | {
|
830 | try
|
949 | try
|
831 | {
|
950 | {
|
832 | message.setLayoutParams(rlp);
|
951 | message.setLayoutParams(rlp);
|
|
|
952 | // upgrade message
|
|
|
953 | String upgrade_summary = "\n\n********\n";
|
|
|
954 | // upgrade message
|
833 | final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded");
|
955 | final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
|
834 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
956 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
835 | message.setText(s);
|
957 | message.setText(s);
|
836 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
958 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
837 | infobox.setView(message);
|
959 | infobox.setView(message);
|
838 |
|
960 |
|
… | |
… | |
885 | if (!extractRes(NavitTextTranslations.main_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo"))
|
1007 | if (!extractRes(NavitTextTranslations.main_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo"))
|
886 | {
|
1008 | {
|
887 | Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language);
|
1009 | Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language);
|
888 | }
|
1010 | }
|
889 |
|
1011 |
|
|
|
1012 | // DEBUG - check if language file is on SDCARD -
|
|
|
1013 | try
|
|
|
1014 | {
|
|
|
1015 | File debug_mo_src = new File("/sdcard/zanavi/debug/navit.mo");
|
|
|
1016 | File debug_mo_dest = new File(NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo");
|
|
|
1017 | //* File navit_debug_dir = new File("/sdcard/zanavi/debug/");
|
|
|
1018 | //* navit_debug_dir.mkdirs();
|
|
|
1019 | copyFile(debug_mo_src, debug_mo_dest);
|
|
|
1020 | }
|
|
|
1021 | catch (Exception e)
|
|
|
1022 | {
|
|
|
1023 | e.printStackTrace();
|
|
|
1024 | }
|
|
|
1025 | // DEBUG - check if language file is on SDCARD -
|
|
|
1026 |
|
890 | File navit_config_xml_file = new File(NAVIT_DATA_DIR + "/share/navit.xml");
|
1027 | File navit_config_xml_file = new File(NAVIT_DATA_DIR + "/share/navit.xml");
|
891 | if (!navit_config_xml_file.exists())
|
1028 | if (!navit_config_xml_file.exists())
|
892 | {
|
1029 | {
|
893 | xmlconfig_unpack_file = true;
|
1030 | xmlconfig_unpack_file = true;
|
894 | Log.e("Navit", "navit.xml does not exist, unpacking in any case");
|
1031 | Log.e("Navit", "navit.xml does not exist, unpacking in any case");
|
895 | }
|
1032 | }
|
896 |
|
1033 |
|
897 | my_display_density = "mdpi";
|
1034 | my_display_density = "mdpi";
|
898 | // ldpi display (120 dpi)
|
1035 | // ldpi display (120 dpi)
|
|
|
1036 |
|
899 | if (Navit.metrics.densityDpi <= 120)
|
1037 | if (Navit.metrics.densityDpi <= 120)
|
900 | {
|
1038 | {
|
901 | my_display_density = "ldpi";
|
1039 | my_display_density = "ldpi";
|
902 | if (xmlconfig_unpack_file)
|
1040 | if (xmlconfig_unpack_file)
|
903 | {
|
1041 | {
|
… | |
… | |
995 | NavitMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density);
|
1133 | NavitMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density);
|
996 | // CAUTION: don't use android.os.Build.VERSION.SDK_INT if <uses-sdk android:minSdkVersion="3" />
|
1134 | // CAUTION: don't use android.os.Build.VERSION.SDK_INT if <uses-sdk android:minSdkVersion="3" />
|
997 | // You will get exception on all devices with Android 1.5 and lower
|
1135 | // You will get exception on all devices with Android 1.5 and lower
|
998 | // because Build.VERSION.SDK_INT is since SDK 4 (Donut 1.6)
|
1136 | // because Build.VERSION.SDK_INT is since SDK 4 (Donut 1.6)
|
999 |
|
1137 |
|
|
|
1138 | // (see: http://developer.android.com/guide/appendix/api-levels.html)
|
1000 | // Platform Version API Level
|
1139 | // Platform Version API Level
|
|
|
1140 | // =============================================
|
|
|
1141 | // Android 4.0.3 15
|
|
|
1142 | // Android 4.0, 4.0.1, 4.0.2 14
|
|
|
1143 | // Android 3.2 13
|
1001 | // Android 3.1 12
|
1144 | // Android 3.1 12
|
1002 | // Android 3.0 11
|
1145 | // Android 3.0 11
|
1003 | // Android 2.3.3 10
|
1146 | // Android 2.3.3 10
|
1004 | // Android 2.3.1 9
|
1147 | // Android 2.3.1 9
|
1005 | // Android 2.2 8
|
1148 | // Android 2.2 8
|
1006 | // Android 2.1 7
|
1149 | // Android 2.1 7
|
1007 | // Android 2.0.1 6
|
1150 | // Android 2.0.1 6
|
1008 | // Android 2.0 5
|
1151 | // Android 2.0 5
|
1009 | // Android 1.6 4
|
1152 | // Android 1.6 4
|
1010 | // Android 1.5 3
|
1153 | // Android 1.5 3
|
1011 | // Android 1.1 2
|
1154 | // Android 1.1 2
|
1012 | // Android 1.0 1
|
1155 | // Android 1.0 1
|
1013 |
|
1156 |
|
1014 | NavitActivity(3);
|
1157 | NavitActivity(3);
|
1015 |
|
1158 |
|
1016 | Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
1159 | Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
1017 |
|
1160 |
|
… | |
… | |
1221 | //dialog.dismiss();
|
1364 | //dialog.dismiss();
|
1222 | }
|
1365 | }
|
1223 | }
|
1366 | }
|
1224 |
|
1367 |
|
1225 | AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
1368 | AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
1226 | dialog.setTitle(Navit.get_text("WeltBild Tablet")); //TRANS
|
1369 | dialog.setTitle("WeltBild Tablet");
|
1227 | dialog.setCancelable(false);
|
1370 | dialog.setCancelable(false);
|
1228 | dialog.setMessage("Your device is not supported!");
|
1371 | dialog.setMessage("Your device is not supported!");
|
1229 | dialog.show();
|
1372 | dialog.show();
|
1230 | //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
1373 | //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
1231 | //theButton.setOnClickListener(new CustomListener(dialog));
|
1374 | //theButton.setOnClickListener(new CustomListener(dialog));
|
1232 | }
|
1375 | }
|
1233 |
|
1376 |
|
|
|
1377 | if (Navit_maps_loaded == false)
|
|
|
1378 | {
|
|
|
1379 | Navit_maps_loaded = true;
|
|
|
1380 | // activate all maps
|
|
|
1381 | Log.e("Navit", "**** LOAD ALL MAPS **** start");
|
|
|
1382 | Message msg3 = new Message();
|
|
|
1383 | Bundle b3 = new Bundle();
|
|
|
1384 | b3.putInt("Callback", 20);
|
|
|
1385 | msg3.setData(b3);
|
|
|
1386 | N_NavitGraphics.callback_handler.sendMessage(msg3);
|
|
|
1387 | Log.e("Navit", "**** LOAD ALL MAPS **** end");
|
|
|
1388 | }
|
|
|
1389 |
|
1234 | String intent_data = null;
|
1390 | String intent_data = null;
|
1235 | if (startup_intent != null)
|
1391 | if (startup_intent != null)
|
1236 | {
|
1392 | {
|
1237 | if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
|
1393 | if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
|
1238 | {
|
1394 | {
|
… | |
… | |
1253 |
|
1409 |
|
1254 | // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
|
1410 | // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
|
1255 | // b: google.navigation:q=48.25676,16.643
|
1411 | // b: google.navigation:q=48.25676,16.643
|
1256 | // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
|
1412 | // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
|
1257 | // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
|
1413 | // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
|
|
|
1414 | // sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
|
|
|
1415 | // -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
|
1258 | // f: google.navigation:ll=48.25676,16.643&...
|
1416 | // f: google.navigation:ll=48.25676,16.643&...
|
1259 | // c: google.navigation:ll=48.25676,16.643
|
1417 | // c: google.navigation:ll=48.25676,16.643
|
1260 |
|
1418 |
|
1261 | String lat;
|
1419 | String lat;
|
1262 | String lon;
|
1420 | String lon;
|
… | |
… | |
1265 | String temp1 = null;
|
1423 | String temp1 = null;
|
1266 | String temp2 = null;
|
1424 | String temp2 = null;
|
1267 | String temp3 = null;
|
1425 | String temp3 = null;
|
1268 | boolean parsable = false;
|
1426 | boolean parsable = false;
|
1269 | boolean unparsable_info_box = true;
|
1427 | boolean unparsable_info_box = true;
|
|
|
1428 | try
|
|
|
1429 | {
|
|
|
1430 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
|
|
1431 | }
|
|
|
1432 | catch (Exception e1)
|
|
|
1433 | {
|
|
|
1434 | e1.printStackTrace();
|
|
|
1435 | }
|
1270 |
|
1436 |
|
1271 | // DEBUG
|
1437 | // DEBUG
|
1272 | // DEBUG
|
1438 | // DEBUG
|
1273 | // DEBUG
|
1439 | // DEBUG
|
1274 | // intent_data = "google.navigation:q=Wien Burggasse 27";
|
1440 | // intent_data = "google.navigation:q=Wien Burggasse 27";
|
… | |
… | |
1291 | catch (Exception e)
|
1457 | catch (Exception e)
|
1292 | {
|
1458 | {
|
1293 | e.printStackTrace();
|
1459 | e.printStackTrace();
|
1294 | }
|
1460 | }
|
1295 |
|
1461 |
|
|
|
1462 | if (!Navit.NavitStartupAlreadySearching)
|
|
|
1463 | {
|
1296 | if (intent_data.length() > 19)
|
1464 | if (intent_data.length() > 19)
|
1297 | {
|
1465 | {
|
1298 | // if d: then start target search
|
1466 | // if d: then start target search
|
1299 | if ((intent_data.substring(0, 20).equals("google.navigation:q=")) && ((!intent_data.substring(20, 21).equals('+')) && (!intent_data.substring(20, 21).equals('-')) && (!intent_data.substring(20, 22).matches("[0-9][0-9]"))))
|
1467 | if ((intent_data.substring(0, 20).equals("google.navigation:q=")) && ((!intent_data.substring(20, 21).equals('+')) && (!intent_data.substring(20, 21).equals('-')) && (!intent_data.substring(20, 22).matches("[0-9][0-9]"))))
|
1300 | {
|
1468 | {
|
1301 | Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
|
1469 | Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
|
|
|
1470 | Navit.NavitStartupAlreadySearching = true;
|
1302 | start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
1471 | start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
1303 | // dont use this here, already starting search, so set to "false"
|
1472 | // dont use this here, already starting search, so set to "false"
|
1304 | parsable = false;
|
1473 | parsable = false;
|
1305 | unparsable_info_box = false;
|
1474 | unparsable_info_box = false;
|
1306 | }
|
1475 | }
|
1307 | // if b: then remodel the input string to look like a:
|
1476 | // if b: then remodel the input string to look like a:
|
1308 | else if (intent_data.substring(0, 20).equals("google.navigation:q="))
|
1477 | else if (intent_data.substring(0, 20).equals("google.navigation:q="))
|
1309 | {
|
1478 | {
|
1310 | intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
|
1479 | intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
|
1311 | Log.e("Navit", "target found (b): " + intent_data);
|
1480 | Log.e("Navit", "target found (b): " + intent_data);
|
1312 | parsable = true;
|
1481 | parsable = true;
|
1313 | }
|
1482 | }
|
1314 | // if e: then remodel the input string to look like a:
|
1483 | // if e: then remodel the input string to look like a:
|
1315 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1) && (intent_data.split("&")[1].substring(0, 1).toLowerCase().equals("f")))
|
1484 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1) && (intent_data.split("&")[1].substring(0, 1).toLowerCase().equals("f")))
|
1316 | {
|
1485 | {
|
1317 | int idx = intent_data.indexOf("&");
|
1486 | int idx = intent_data.indexOf("&");
|
1318 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
1487 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
1319 | Log.e("Navit", "target found (e): " + intent_data);
|
1488 | Log.e("Navit", "target found (e): " + intent_data);
|
1320 | parsable = true;
|
1489 | parsable = true;
|
1321 | }
|
1490 | }
|
1322 | // if f: then remodel the input string to look like a:
|
1491 | // if f: then remodel the input string to look like a:
|
1323 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
|
1492 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
|
1324 | {
|
1493 | {
|
1325 | int idx = intent_data.indexOf("&");
|
1494 | int idx = intent_data.indexOf("&");
|
1326 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
1495 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
1327 | Log.e("Navit", "target found (f): " + intent_data);
|
1496 | Log.e("Navit", "target found (f): " + intent_data);
|
1328 | parsable = true;
|
1497 | parsable = true;
|
1329 | }
|
1498 | }
|
1330 | // already looks like a: just set flag
|
1499 | // already looks like a: just set flag
|
1331 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
|
1500 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
|
1332 | {
|
1501 | {
|
1333 | // dummy, just set the flag
|
1502 | // dummy, just set the flag
|
1334 | Log.e("Navit", "target found (a): " + intent_data);
|
1503 | Log.e("Navit", "target found (a): " + intent_data);
|
1335 | Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
|
1504 | Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
|
1336 | parsable = true;
|
1505 | parsable = true;
|
1337 | }
|
1506 | }
|
1338 | // if c: then remodel the input string to look like a:
|
1507 | // if c: then remodel the input string to look like a:
|
1339 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
|
1508 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
|
1340 | {
|
1509 | {
|
1341 | intent_data = intent_data + "&q=Target";
|
1510 | intent_data = intent_data + "&q=Target";
|
1342 | Log.e("Navit", "target found (c): " + intent_data);
|
1511 | Log.e("Navit", "target found (c): " + intent_data);
|
1343 | parsable = true;
|
1512 | parsable = true;
|
1344 | }
|
1513 | }
|
|
|
1514 | }
|
|
|
1515 | }
|
|
|
1516 | else
|
|
|
1517 | {
|
|
|
1518 | Log.e("Navit", "already started search from startup intent");
|
|
|
1519 | parsable = false;
|
|
|
1520 | unparsable_info_box = false;
|
1345 | }
|
1521 | }
|
1346 |
|
1522 |
|
1347 | if (parsable)
|
1523 | if (parsable)
|
1348 | {
|
1524 | {
|
1349 | // now string should be in form --> a:
|
1525 | // now string should be in form --> a:
|
… | |
… | |
1368 | }
|
1544 | }
|
1369 |
|
1545 |
|
1370 | lat = temp3.split(",", -1)[0];
|
1546 | lat = temp3.split(",", -1)[0];
|
1371 | lon = temp3.split(",", -1)[1];
|
1547 | lon = temp3.split(",", -1)[1];
|
1372 | q = temp2;
|
1548 | q = temp2;
|
1373 |
|
1549 | // is the "search name" url-encoded? i think so, lets url-decode it here
|
|
|
1550 | q = URLDecoder.decode(q);
|
1374 | // System.out.println();
|
1551 | // System.out.println();
|
1375 |
|
1552 |
|
1376 | Navit.remember_destination(q, lat, lon);
|
1553 | Navit.remember_destination(q, lat, lon);
|
1377 | Navit.destination_set();
|
1554 | Navit.destination_set();
|
1378 |
|
1555 |
|
… | |
… | |
1414 | }
|
1591 | }
|
1415 | else
|
1592 | else
|
1416 | {
|
1593 | {
|
1417 | if (unparsable_info_box && !searchBoxShown)
|
1594 | if (unparsable_info_box && !searchBoxShown)
|
1418 | {
|
1595 | {
|
|
|
1596 | try
|
|
|
1597 | {
|
|
|
1598 | searchBoxShown = true;
|
|
|
1599 | String searchString = intent_data.split("q=")[1];
|
|
|
1600 | searchString = searchString.split("&")[0];
|
|
|
1601 | searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
|
|
1602 | Log.e("Navit", "Search String :" + searchString);
|
|
|
1603 | executeSearch(searchString);
|
|
|
1604 | }
|
|
|
1605 | catch (Exception e)
|
|
|
1606 | {
|
|
|
1607 | // safety net
|
|
|
1608 | try
|
|
|
1609 | {
|
|
|
1610 | Log.e("Navit", "problem with startup search 7 str=" + intent_data);
|
|
|
1611 | }
|
|
|
1612 | catch (Exception e2)
|
|
|
1613 | {
|
|
|
1614 | e2.printStackTrace();
|
|
|
1615 | }
|
|
|
1616 | }
|
|
|
1617 | }
|
|
|
1618 | }
|
|
|
1619 | }
|
|
|
1620 | else if ((intent_data != null) && (intent_data.substring(0, 10).equals("geo:0,0?q=")))
|
|
|
1621 | {
|
|
|
1622 | // g: geo:0,0?q=wien%20burggasse
|
1419 |
|
1623 |
|
|
|
1624 | boolean parsable = false;
|
|
|
1625 | boolean unparsable_info_box = true;
|
|
|
1626 | try
|
|
|
1627 | {
|
|
|
1628 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
|
|
1629 | }
|
|
|
1630 | catch (Exception e1)
|
|
|
1631 | {
|
|
|
1632 | e1.printStackTrace();
|
|
|
1633 | }
|
|
|
1634 |
|
|
|
1635 | if (!Navit.NavitStartupAlreadySearching)
|
|
|
1636 | {
|
|
|
1637 | if (intent_data.length() > 10)
|
|
|
1638 | {
|
|
|
1639 | // if g: then start target search
|
|
|
1640 | Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
|
|
|
1641 | Navit.NavitStartupAlreadySearching = true;
|
|
|
1642 | start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
|
|
1643 | // dont use this here, already starting search, so set to "false"
|
|
|
1644 | parsable = false;
|
|
|
1645 | unparsable_info_box = false;
|
|
|
1646 | }
|
|
|
1647 | }
|
|
|
1648 | else
|
|
|
1649 | {
|
|
|
1650 | Log.e("Navit", "already started search from startup intent");
|
|
|
1651 | parsable = false;
|
|
|
1652 | unparsable_info_box = false;
|
|
|
1653 | }
|
|
|
1654 |
|
|
|
1655 | if (unparsable_info_box && !searchBoxShown)
|
|
|
1656 | {
|
|
|
1657 | try
|
|
|
1658 | {
|
1420 | searchBoxShown = true;
|
1659 | searchBoxShown = true;
|
1421 | String searchString = intent_data.split("q=")[1];
|
1660 | String searchString = intent_data.split("q=")[1];
|
1422 | searchString = searchString.split("&")[0];
|
1661 | searchString = searchString.split("&")[0];
|
1423 | searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
1662 | searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
1424 | Log.e("Navit", "Search String :" + searchString);
|
1663 | Log.e("Navit", "Search String :" + searchString);
|
1425 | executeSearch(searchString);
|
1664 | executeSearch(searchString);
|
1426 |
|
1665 | }
|
|
|
1666 | catch (Exception e)
|
|
|
1667 | {
|
|
|
1668 | // safety net
|
|
|
1669 | try
|
|
|
1670 | {
|
|
|
1671 | Log.e("Navit", "problem with startup search 88 str=" + intent_data);
|
1427 | }
|
1672 | }
|
|
|
1673 | catch (Exception e2)
|
|
|
1674 | {
|
|
|
1675 | e2.printStackTrace();
|
|
|
1676 | }
|
1428 | }
|
1677 | }
|
|
|
1678 | }
|
|
|
1679 |
|
1429 | }
|
1680 | }
|
1430 |
|
1681 |
|
1431 | getPrefs();
|
1682 | getPrefs();
|
1432 | activatePrefs();
|
1683 | activatePrefs();
|
1433 | // activate gps AFTER 3g-location
|
1684 | // activate gps AFTER 3g-location
|
… | |
… | |
1571 | menu.add(1, 6, 300, get_text("address search (online)")); //TRANS
|
1822 | menu.add(1, 6, 300, get_text("address search (online)")); //TRANS
|
1572 | menu.add(1, 7, 310, get_text("address search (offline)")); //TRANS
|
1823 | menu.add(1, 7, 310, get_text("address search (offline)")); //TRANS
|
1573 | if (NavitGraphics.CallbackDestinationValid2() > 0)
|
1824 | if (NavitGraphics.CallbackDestinationValid2() > 0)
|
1574 | {
|
1825 | {
|
1575 | menu.add(1, 9, 450, get_text("Stop Navigation")); //TRANS
|
1826 | menu.add(1, 9, 450, get_text("Stop Navigation")); //TRANS
|
1576 | menu.add(1, 11, 455, get_text("Zoom to Route")); //TRANS
|
1827 | menu.add(1, 11, 455, get_text("Zoom to Route")); //TRANS
|
|
|
1828 | //. TRANSLATORS: it means: "show current target in google maps"
|
|
|
1829 | //. TRANSLATORS: please keep this text short, to fit in the android menu!
|
|
|
1830 | menu.add(1, 15, 457, get_text("Target in gmaps")); //TRANS
|
1577 | }
|
1831 | }
|
|
|
1832 | //. TRANSLATORS: text to translate is: exit ZANavi
|
1578 | menu.add(1, 99, 480, get_text("exit navit")); //TRANS
|
1833 | menu.add(1, 99, 480, get_text("exit navit")); //TRANS
|
1579 | menu.add(1, 5, 485, get_text("toggle POI")); //TRANS
|
1834 | menu.add(1, 5, 485, get_text("toggle POI")); //TRANS
|
1580 | menu.add(1, 10, 490, get_text("Settings")); //TRANS
|
1835 | menu.add(1, 10, 490, get_text("Settings")); //TRANS
|
1581 |
|
1836 |
|
1582 | if (Navit_Announcer == true)
|
1837 | if (Navit_Announcer == true)
|
… | |
… | |
1589 | }
|
1844 | }
|
1590 |
|
1845 |
|
1591 | menu.add(1, 14, 498, get_text("Recent destinations")); //TRANS
|
1846 | menu.add(1, 14, 498, get_text("Recent destinations")); //TRANS
|
1592 | menu.add(1, 3, 500, get_text("download maps")); //TRANS
|
1847 | menu.add(1, 3, 500, get_text("download maps")); //TRANS
|
1593 | menu.add(1, 8, 505, get_text("delete maps")); //TRANS
|
1848 | menu.add(1, 8, 505, get_text("delete maps")); //TRANS
|
|
|
1849 |
|
|
|
1850 | if (PREF_enable_debug_functions)
|
|
|
1851 | {
|
|
|
1852 | menu.add(1, 88, 9001, "--");
|
|
|
1853 | menu.add(1, 601, 9001, get_text("Demo Vehicle")); //TRANS
|
|
|
1854 | menu.add(1, 602, 9002, get_text("Speech Texts")); //TRANS
|
|
|
1855 | menu.add(1, 603, 9003, get_text("Nav. Commands")); //TRANS
|
|
|
1856 | }
|
|
|
1857 |
|
|
|
1858 | menu.add(1, 88, 11000, "--");
|
|
|
1859 | menu.add(1, 16, 11001, get_text("online Help")); //TRANS
|
1594 |
|
1860 |
|
1595 | // menu.add(1, 88, 800, "--");
|
1861 | // menu.add(1, 88, 800, "--");
|
1596 | return true;
|
1862 | return true;
|
1597 | }
|
1863 | }
|
1598 |
|
1864 |
|
… | |
… | |
1620 |
|
1886 |
|
1621 | public void start_targetsearch_from_intent(String target_address)
|
1887 | public void start_targetsearch_from_intent(String target_address)
|
1622 | {
|
1888 | {
|
1623 | Navit_last_address_partial_match = false;
|
1889 | Navit_last_address_partial_match = false;
|
1624 | Navit_last_address_search_string = target_address;
|
1890 | Navit_last_address_search_string = target_address;
|
|
|
1891 |
|
|
|
1892 | // ----------- CONFIG ---------
|
|
|
1893 | // ----------- CONFIG ---------
|
|
|
1894 | // ----------- CONFIG ---------
|
|
|
1895 | Boolean use_online_searchmode_here = false;
|
|
|
1896 | Boolean hide_duplicates_searchmode_here = false;
|
|
|
1897 | // ----------- CONFIG ---------
|
|
|
1898 | // ----------- CONFIG ---------
|
|
|
1899 | // ----------- CONFIG ---------
|
|
|
1900 |
|
|
|
1901 | int dialog_num_;
|
|
|
1902 |
|
|
|
1903 | if (use_online_searchmode_here)
|
|
|
1904 | {
|
|
|
1905 | dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG;
|
|
|
1906 | }
|
|
|
1907 | else
|
|
|
1908 | {
|
|
|
1909 | dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE;
|
|
|
1910 | }
|
1625 |
|
1911 |
|
1626 | // clear results
|
1912 | // clear results
|
1627 | Navit.NavitAddressResultList_foundItems.clear();
|
1913 | Navit.NavitAddressResultList_foundItems.clear();
|
1628 | Navit.Navit_Address_Result_double_index.clear();
|
1914 | Navit.Navit_Address_Result_double_index.clear();
|
1629 | Navit.NavitSearchresultBarIndex = -1;
|
1915 | Navit.NavitSearchresultBarIndex = -1;
|
… | |
… | |
1636 | Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
|
1922 | Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
|
1637 | }
|
1923 | }
|
1638 | else
|
1924 | else
|
1639 | {
|
1925 | {
|
1640 | // show dialog
|
1926 | // show dialog
|
|
|
1927 | try
|
|
|
1928 | {
|
|
|
1929 | Log.e("Navit", "call-11: (0)num " + dialog_num_);
|
|
|
1930 | }
|
|
|
1931 | catch (Exception e)
|
|
|
1932 | {
|
|
|
1933 | e.printStackTrace();
|
|
|
1934 | }
|
|
|
1935 |
|
|
|
1936 | if (hide_duplicates_searchmode_here)
|
|
|
1937 | {
|
|
|
1938 | // hide duplicates when searching
|
|
|
1939 | // hide duplicates when searching
|
|
|
1940 | Message msg22 = new Message();
|
|
|
1941 | Bundle b22 = new Bundle();
|
|
|
1942 | b22.putInt("Callback", 45);
|
|
|
1943 | msg22.setData(b22);
|
|
|
1944 | N_NavitGraphics.callback_handler.sendMessage(msg22);
|
|
|
1945 | // hide duplicates when searching
|
|
|
1946 | // hide duplicates when searching
|
|
|
1947 | }
|
|
|
1948 |
|
1641 | Message msg = progress_handler.obtainMessage();
|
1949 | Message msg = progress_handler.obtainMessage();
|
1642 | Bundle b = new Bundle();
|
1950 | Bundle b = new Bundle();
|
1643 | msg.what = 11;
|
1951 | msg.what = 11;
|
1644 | b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
|
1952 | b.putInt("dialog_num", dialog_num_);
|
1645 | msg.setData(b);
|
1953 | msg.setData(b);
|
1646 | progress_handler.sendMessage(msg);
|
1954 | progress_handler.sendMessage(msg);
|
1647 | }
|
1955 | }
|
1648 | }
|
1956 | }
|
1649 |
|
1957 |
|
… | |
… | |
1703 | b = new Bundle();
|
2011 | b = new Bundle();
|
1704 | b.putInt("Callback", 5);
|
2012 | b.putInt("Callback", 5);
|
1705 | b.putString("cmd", "toggle_layer(\"Android-POI-Icons-full\");");
|
2013 | b.putString("cmd", "toggle_layer(\"Android-POI-Icons-full\");");
|
1706 | msg.setData(b);
|
2014 | msg.setData(b);
|
1707 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
2015 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
1708 |
|
|
|
1709 | // DEBUG - // googlemaps_show("48.28696", "16.48816", "XXyy ö2432ä ä3");
|
|
|
1710 |
|
|
|
1711 | break;
|
2016 | break;
|
1712 | case 6:
|
2017 | case 6:
|
1713 | // ok startup address search activity (online google maps search)
|
2018 | // ok startup address search activity (online google maps search)
|
1714 | Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
|
2019 | Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
|
1715 | search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
|
2020 | search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
|
… | |
… | |
1734 | String pm_temp2 = "0";
|
2039 | String pm_temp2 = "0";
|
1735 | if (Navit_last_address_partial_match)
|
2040 | if (Navit_last_address_partial_match)
|
1736 | {
|
2041 | {
|
1737 | pm_temp2 = "1";
|
2042 | pm_temp2 = "1";
|
1738 | }
|
2043 | }
|
|
|
2044 |
|
1739 | search_intent2.putExtra("partial_match", pm_temp2);
|
2045 | search_intent2.putExtra("partial_match", pm_temp2);
|
1740 | this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
|
2046 | this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
|
1741 | break;
|
2047 | break;
|
1742 | case 8:
|
2048 | case 8:
|
1743 | // map delete menu
|
2049 | // map delete menu
|
… | |
… | |
1778 | b.putInt("Callback", 35);
|
2084 | b.putInt("Callback", 35);
|
1779 | msg.setData(b);
|
2085 | msg.setData(b);
|
1780 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
2086 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
1781 | break;
|
2087 | break;
|
1782 | case 14:
|
2088 | case 14:
|
|
|
2089 | // show recent destination list
|
1783 | Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
|
2090 | Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
|
1784 | this.startActivityForResult(i2, Navit.NavitRecentDest_id);
|
2091 | this.startActivityForResult(i2, Navit.NavitRecentDest_id);
|
1785 | break;
|
2092 | break;
|
|
|
2093 | case 15:
|
|
|
2094 | // show current target on googlemaps
|
|
|
2095 | String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1);
|
|
|
2096 | // Log.e("Navit", "got target 1: "+current_target_string);
|
|
|
2097 | if (current_target_string.equals("x:x"))
|
|
|
2098 | {
|
|
|
2099 | Log.e("Navit", "no target set!");
|
|
|
2100 | }
|
|
|
2101 | else
|
|
|
2102 | {
|
|
|
2103 | try
|
|
|
2104 | {
|
|
|
2105 | String tmp[] = current_target_string.split(":", 2);
|
|
|
2106 | googlemaps_show(tmp[0], tmp[1], "ZANavi Target");
|
|
|
2107 | }
|
|
|
2108 | catch (Exception e)
|
|
|
2109 | {
|
|
|
2110 | e.printStackTrace();
|
|
|
2111 | Log.e("Navit", "problem with target!");
|
|
|
2112 | }
|
|
|
2113 | }
|
|
|
2114 | break;
|
|
|
2115 | case 16:
|
|
|
2116 | // show online manual
|
|
|
2117 | Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase());
|
|
|
2118 | // URL to ZANavi Manual (in english language)
|
|
|
2119 | String url = "http://zanavi.cc/index.php/Manual";
|
|
|
2120 | if (NavitTextTranslations.main_language.toLowerCase().equals("de"))
|
|
|
2121 | {
|
|
|
2122 | // show german manual
|
|
|
2123 | url = "http://zanavi.cc/index.php/Manual/de";
|
|
|
2124 | }
|
|
|
2125 |
|
|
|
2126 | Intent i = new Intent(Intent.ACTION_VIEW);
|
|
|
2127 | i.setData(Uri.parse(url));
|
|
|
2128 | startActivity(i);
|
|
|
2129 | break;
|
1786 | case 88:
|
2130 | case 88:
|
1787 | // dummy entry, just to make "breaks" in the menu
|
2131 | // dummy entry, just to make "breaks" in the menu
|
|
|
2132 | break;
|
|
|
2133 | case 601:
|
|
|
2134 | // DEBUG: activate demo vehicle and set position to position 20px-x, 20px-y on screen
|
|
|
2135 |
|
|
|
2136 | Navit.DemoVehicle = true;
|
|
|
2137 |
|
|
|
2138 | msg = new Message();
|
|
|
2139 | b = new Bundle();
|
|
|
2140 | b.putInt("Callback", 52);
|
|
|
2141 | msg.setData(b);
|
|
|
2142 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2143 |
|
|
|
2144 | msg = new Message();
|
|
|
2145 | b = new Bundle();
|
|
|
2146 | b.putInt("Callback", 51);
|
|
|
2147 | b.putInt("x", 20);
|
|
|
2148 | b.putInt("y", 20);
|
|
|
2149 | msg.setData(b);
|
|
|
2150 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2151 |
|
|
|
2152 | break;
|
|
|
2153 | case 602:
|
|
|
2154 | // DEBUG: toggle textview with spoken and translated string (to help with translation)
|
|
|
2155 | try
|
|
|
2156 | {
|
|
|
2157 | if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE)
|
|
|
2158 | {
|
|
|
2159 | NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE);
|
|
|
2160 | NavitGraphics.NavitMsgTv2_.setEnabled(false);
|
|
|
2161 | }
|
|
|
2162 | else
|
|
|
2163 | {
|
|
|
2164 | NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
|
|
|
2165 | NavitGraphics.NavitMsgTv2_.setEnabled(true);
|
|
|
2166 | }
|
|
|
2167 | }
|
|
|
2168 | catch (Exception e)
|
|
|
2169 | {
|
|
|
2170 | e.printStackTrace();
|
|
|
2171 | }
|
|
|
2172 | break;
|
|
|
2173 | case 603:
|
|
|
2174 | // DEBUG: show all possible navigation commands (also translated)
|
|
|
2175 | NavitGraphics.generate_all_speech_commands();
|
1788 | break;
|
2176 | break;
|
1789 | case 99:
|
2177 | case 99:
|
1790 | // exit
|
2178 | // exit
|
1791 | this.onStop();
|
2179 | this.onStop();
|
1792 | this.exit();
|
2180 | this.exit();
|
… | |
… | |
1840 | // remove from cat file
|
2228 | // remove from cat file
|
1841 | NavitMapDownloader.remove_from_cat_file(map_full_line);
|
2229 | NavitMapDownloader.remove_from_cat_file(map_full_line);
|
1842 | // remove from disk
|
2230 | // remove from disk
|
1843 | File del_map_name_file = new File(del_map_name);
|
2231 | File del_map_name_file = new File(del_map_name);
|
1844 | del_map_name_file.delete();
|
2232 | del_map_name_file.delete();
|
|
|
2233 | for (int jkl = 1; jkl < 51; jkl++)
|
|
|
2234 | {
|
|
|
2235 | File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl));
|
|
|
2236 | del_map_name_fileSplit.delete();
|
|
|
2237 | }
|
1845 | // remove also any MD5 files for this map that may be on disk
|
2238 | // remove also any MD5 files for this map that may be on disk
|
1846 | try
|
2239 | try
|
1847 | {
|
2240 | {
|
1848 | String tmp = map_full_line.split(":", 2)[1];
|
2241 | String tmp = map_full_line.split(":", 2)[1];
|
1849 | if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN))
|
2242 | if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN))
|
… | |
… | |
2038 | else
|
2431 | else
|
2039 | {
|
2432 | {
|
2040 | if (requestCode == NavitAddressSearch_id_online)
|
2433 | if (requestCode == NavitAddressSearch_id_online)
|
2041 | {
|
2434 | {
|
2042 | // online googlemaps search
|
2435 | // online googlemaps search
|
|
|
2436 | try
|
|
|
2437 | {
|
|
|
2438 | Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG);
|
|
|
2439 | }
|
|
|
2440 | catch (Exception e)
|
|
|
2441 | {
|
|
|
2442 | e.printStackTrace();
|
|
|
2443 | }
|
|
|
2444 |
|
2043 | System.out.println("online googlemaps search");
|
2445 | System.out.println("online googlemaps search");
|
2044 | Message msg = progress_handler.obtainMessage();
|
2446 | Message msg = progress_handler.obtainMessage();
|
2045 | Bundle b = new Bundle();
|
2447 | Bundle b = new Bundle();
|
2046 | msg.what = 11;
|
2448 | msg.what = 11;
|
2047 | b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
|
2449 | b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
|
… | |
… | |
2049 | progress_handler.sendMessage(msg);
|
2451 | progress_handler.sendMessage(msg);
|
2050 | }
|
2452 | }
|
2051 | else if (requestCode == NavitAddressSearch_id_offline)
|
2453 | else if (requestCode == NavitAddressSearch_id_offline)
|
2052 | {
|
2454 | {
|
2053 | // offline binfile search
|
2455 | // offline binfile search
|
|
|
2456 | try
|
|
|
2457 | {
|
|
|
2458 | Log.e("Navit", "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
|
|
|
2459 | }
|
|
|
2460 | catch (Exception e)
|
|
|
2461 | {
|
|
|
2462 | e.printStackTrace();
|
|
|
2463 | }
|
2054 |
|
2464 |
|
2055 | // show dialog, and start search for the results
|
2465 | // show dialog, and start search for the results
|
2056 | // make it indirect, to give our activity a chance to startup
|
2466 | // make it indirect, to give our activity a chance to startup
|
2057 | // (remember we come straight from another activity and ours is still paused!)
|
2467 | // (remember we come straight from another activity and ours is still paused!)
|
2058 | Message msg = progress_handler.obtainMessage();
|
2468 | Message msg = progress_handler.obtainMessage();
|
… | |
… | |
2131 | Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
2541 | Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
2132 | // get the coords for the destination
|
2542 | // get the coords for the destination
|
2133 | int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
|
2543 | int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
|
2134 |
|
2544 |
|
2135 | // ok now set target
|
2545 | // ok now set target
|
2136 | Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Toast.LENGTH_LONG).show(); //TRANS
|
|
|
2137 |
|
|
|
2138 | try
|
2546 | try
|
2139 | {
|
2547 | {
|
2140 | Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
|
2548 | Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
|
2141 | // save points
|
2549 | // save points
|
2142 | write_map_points();
|
2550 | write_map_points();
|
2143 | }
|
2551 | }
|
2144 | catch (Exception e)
|
2552 | catch (Exception e)
|
2145 | {
|
2553 | {
|
2146 | e.printStackTrace();
|
2554 | e.printStackTrace();
|
2147 | }
|
2555 | }
|
|
|
2556 |
|
|
|
2557 | if (NavitGraphics.navit_route_status == 0)
|
|
|
2558 | {
|
|
|
2559 | Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Toast.LENGTH_LONG).show(); //TRANS
|
2148 | Navit.destination_set();
|
2560 | Navit.destination_set();
|
2149 |
|
2561 |
|
2150 | Message msg = new Message();
|
2562 | Message msg = new Message();
|
2151 | Bundle b = new Bundle();
|
2563 | Bundle b = new Bundle();
|
2152 | b.putInt("Callback", 3);
|
2564 | b.putInt("Callback", 3);
|
2153 | b.putString("lat", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lat));
|
2565 | b.putString("lat", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lat));
|
2154 | b.putString("lon", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
|
2566 | b.putString("lon", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
|
2155 | b.putString("q", Navit.NavitAddressResultList_foundItems.get(destination_id).addr);
|
2567 | b.putString("q", Navit.NavitAddressResultList_foundItems.get(destination_id).addr);
|
2156 | msg.setData(b);
|
2568 | msg.setData(b);
|
2157 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
2569 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2570 | }
|
|
|
2571 | else
|
|
|
2572 | {
|
|
|
2573 | Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Toast.LENGTH_LONG).show(); //TRANS
|
|
|
2574 | Message msg = new Message();
|
|
|
2575 | Bundle b = new Bundle();
|
|
|
2576 | b.putInt("Callback", 48);
|
|
|
2577 | b.putString("lat", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lat));
|
|
|
2578 | b.putString("lon", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
|
|
|
2579 | b.putString("q", Navit.NavitAddressResultList_foundItems.get(destination_id).addr);
|
|
|
2580 | msg.setData(b);
|
|
|
2581 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2582 | }
|
2158 |
|
2583 |
|
2159 | // zoom_to_route();
|
2584 | // zoom_to_route();
|
2160 | try
|
2585 | try
|
2161 | {
|
2586 | {
|
2162 | Thread.sleep(400);
|
2587 | Thread.sleep(400);
|
… | |
… | |
2234 |
|
2659 |
|
2235 | // ok now set target
|
2660 | // ok now set target
|
2236 | String dest_name = Navit.map_points.get(destination_id).point_name;
|
2661 | String dest_name = Navit.map_points.get(destination_id).point_name;
|
2237 | float lat = Navit.map_points.get(destination_id).lat;
|
2662 | float lat = Navit.map_points.get(destination_id).lat;
|
2238 | float lon = Navit.map_points.get(destination_id).lon;
|
2663 | float lon = Navit.map_points.get(destination_id).lon;
|
|
|
2664 |
|
|
|
2665 | if (NavitGraphics.navit_route_status == 0)
|
|
|
2666 | {
|
2239 | Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + dest_name, Toast.LENGTH_LONG).show(); //TRANS
|
2667 | Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + dest_name, Toast.LENGTH_LONG).show(); //TRANS
|
2240 |
|
|
|
2241 | Navit.destination_set();
|
2668 | Navit.destination_set();
|
2242 |
|
2669 |
|
2243 | Message msg = new Message();
|
2670 | Message msg = new Message();
|
2244 | Bundle b = new Bundle();
|
2671 | Bundle b = new Bundle();
|
2245 | b.putInt("Callback", 3);
|
2672 | b.putInt("Callback", 3);
|
2246 | b.putString("lat", String.valueOf(lat));
|
2673 | b.putString("lat", String.valueOf(lat));
|
2247 | b.putString("lon", String.valueOf(lon));
|
2674 | b.putString("lon", String.valueOf(lon));
|
2248 | b.putString("q", dest_name);
|
2675 | b.putString("q", dest_name);
|
2249 | msg.setData(b);
|
2676 | msg.setData(b);
|
2250 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
2677 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2678 | }
|
|
|
2679 | else
|
|
|
2680 | {
|
|
|
2681 | Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + dest_name, Toast.LENGTH_LONG).show(); //TRANS
|
|
|
2682 | Message msg = new Message();
|
|
|
2683 | Bundle b = new Bundle();
|
|
|
2684 | b.putInt("Callback", 48);
|
|
|
2685 | b.putString("lat", String.valueOf(lat));
|
|
|
2686 | b.putString("lon", String.valueOf(lon));
|
|
|
2687 | b.putString("q", dest_name);
|
|
|
2688 | msg.setData(b);
|
|
|
2689 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2690 | }
|
2251 |
|
2691 |
|
2252 | // zoom_to_route();
|
2692 | // zoom_to_route();
|
2253 | try
|
2693 | try
|
2254 | {
|
2694 | {
|
2255 | Thread.sleep(400);
|
2695 | Thread.sleep(400);
|
… | |
… | |
2573 | Navit.msg_to_msg_handler(b2, 10);
|
3013 | Navit.msg_to_msg_handler(b2, 10);
|
2574 | }
|
3014 | }
|
2575 | }
|
3015 | }
|
2576 | catch (Exception e)
|
3016 | catch (Exception e)
|
2577 | {
|
3017 | {
|
|
|
3018 | e.printStackTrace();
|
2578 | System.out.println("seems googlemaps API is not working, try offline search");
|
3019 | System.out.println("seems googlemaps API is not working, try offline search");
|
2579 | }
|
3020 | }
|
2580 | }
|
3021 | }
|
2581 |
|
3022 |
|
2582 | Navit.NavitAddressSearchSpinnerActive = false;
|
3023 | Navit.NavitAddressSearchSpinnerActive = false;
|
… | |
… | |
2602 | msg.what = 99;
|
3043 | msg.what = 99;
|
2603 | b.putInt("dialog_num", this.my_dialog_num);
|
3044 | b.putInt("dialog_num", this.my_dialog_num);
|
2604 | msg.setData(b);
|
3045 | msg.setData(b);
|
2605 | mHandler.sendMessage(msg);
|
3046 | mHandler.sendMessage(msg);
|
2606 |
|
3047 |
|
|
|
3048 | // reset the startup-search flag
|
|
|
3049 | Navit.NavitStartupAlreadySearching = false;
|
|
|
3050 |
|
2607 | Log.e("Navit", "SearchResultsThread ended");
|
3051 | Log.e("Navit", "SearchResultsThread ended");
|
2608 | }
|
3052 | }
|
2609 | }
|
3053 | }
|
2610 |
|
3054 |
|
2611 | public static String filter_bad_chars(String in)
|
3055 | public static String filter_bad_chars(String in)
|
… | |
… | |
2638 | {
|
3082 | {
|
2639 | switch (msg.what)
|
3083 | switch (msg.what)
|
2640 | {
|
3084 | {
|
2641 | case 0:
|
3085 | case 0:
|
2642 | // dismiss dialog, remove dialog
|
3086 | // dismiss dialog, remove dialog
|
|
|
3087 | try
|
|
|
3088 | {
|
|
|
3089 | Log.e("Navit", "0: dismiss dialog num " + msg.getData().getInt("dialog_num"));
|
|
|
3090 | }
|
|
|
3091 | catch (Exception e)
|
|
|
3092 | {
|
|
|
3093 | e.printStackTrace();
|
|
|
3094 | }
|
2643 | dismissDialog(msg.getData().getInt("dialog_num"));
|
3095 | dismissDialog(msg.getData().getInt("dialog_num"));
|
2644 | removeDialog(msg.getData().getInt("dialog_num"));
|
3096 | removeDialog(msg.getData().getInt("dialog_num"));
|
2645 |
|
3097 |
|
2646 | // exit_code=0 -> OK, map was downloaded fine
|
3098 | // exit_code=0 -> OK, map was downloaded fine
|
2647 | if (msg.getData().getInt("exit_code") == 0)
|
3099 | if (msg.getData().getInt("exit_code") == 0)
|
… | |
… | |
2763 | e.printStackTrace();
|
3215 | e.printStackTrace();
|
2764 | }
|
3216 | }
|
2765 | break;
|
3217 | break;
|
2766 | case 99:
|
3218 | case 99:
|
2767 | // dismiss dialog, remove dialog - generic
|
3219 | // dismiss dialog, remove dialog - generic
|
|
|
3220 | try
|
|
|
3221 | {
|
|
|
3222 | Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
|
|
|
3223 | }
|
|
|
3224 | catch (Exception e)
|
|
|
3225 | {
|
|
|
3226 | e.printStackTrace();
|
|
|
3227 | }
|
|
|
3228 | try
|
|
|
3229 | {
|
2768 | dismissDialog(msg.getData().getInt("dialog_num"));
|
3230 | dismissDialog(msg.getData().getInt("dialog_num"));
|
|
|
3231 | }
|
|
|
3232 | catch (Exception e)
|
|
|
3233 | {
|
|
|
3234 | e.printStackTrace();
|
|
|
3235 | }
|
|
|
3236 | try
|
|
|
3237 | {
|
2769 | removeDialog(msg.getData().getInt("dialog_num"));
|
3238 | removeDialog(msg.getData().getInt("dialog_num"));
|
|
|
3239 | }
|
|
|
3240 | catch (Exception e)
|
|
|
3241 | {
|
|
|
3242 | e.printStackTrace();
|
|
|
3243 | }
|
2770 | break;
|
3244 | break;
|
2771 | }
|
3245 | }
|
2772 | }
|
3246 | }
|
2773 | };
|
3247 | };
|
2774 |
|
3248 |
|
… | |
… | |
2883 | mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
|
3357 | mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
|
2884 | mapdownloader_pri = new NavitMapDownloader(this);
|
3358 | mapdownloader_pri = new NavitMapDownloader(this);
|
2885 | progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
|
3359 | progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
|
2886 | progressThread_pri.start();
|
3360 | progressThread_pri.start();
|
2887 | // show license for OSM maps
|
3361 | // show license for OSM maps
|
|
|
3362 | //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
|
2888 | Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_LONG).show(); //TRANS
|
3363 | Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_LONG).show(); //TRANS
|
2889 | return mapdownloader_dialog_pri;
|
3364 | return mapdownloader_dialog_pri;
|
2890 | case Navit.MAPDOWNLOAD_SEC_DIALOG:
|
3365 | case Navit.MAPDOWNLOAD_SEC_DIALOG:
|
2891 | mapdownloader_dialog_sec = new ProgressDialog(this);
|
3366 | mapdownloader_dialog_sec = new ProgressDialog(this);
|
2892 | mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
3367 | mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
… | |
… | |
2908 | mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
|
3383 | mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
|
2909 | mapdownloader_sec = new NavitMapDownloader(this);
|
3384 | mapdownloader_sec = new NavitMapDownloader(this);
|
2910 | progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
|
3385 | progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
|
2911 | progressThread_sec.start();
|
3386 | progressThread_sec.start();
|
2912 | // show license for OSM maps
|
3387 | // show license for OSM maps
|
|
|
3388 | //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
|
2913 | Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_LONG).show(); //TRANS
|
3389 | Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_LONG).show(); //TRANS
|
2914 | return mapdownloader_dialog_sec;
|
3390 | return mapdownloader_dialog_sec;
|
2915 | }
|
3391 | }
|
2916 | // should never get here!!
|
3392 | // should never get here!!
|
2917 | return null;
|
3393 | return null;
|
… | |
… | |
2951 | Log.e("Navit", "4***************** exit called ****************");
|
3427 | Log.e("Navit", "4***************** exit called ****************");
|
2952 | Log.e("Navit", "5***************** exit called ****************");
|
3428 | Log.e("Navit", "5***************** exit called ****************");
|
2953 | Log.e("Navit", "6***************** exit called ****************");
|
3429 | Log.e("Navit", "6***************** exit called ****************");
|
2954 | Log.e("Navit", "7***************** exit called ****************");
|
3430 | Log.e("Navit", "7***************** exit called ****************");
|
2955 | Log.e("Navit", "8***************** exit called ****************");
|
3431 | Log.e("Navit", "8***************** exit called ****************");
|
2956 | // NavitActivity(-3);
|
|
|
2957 | System.gc();
|
3432 | System.gc();
|
|
|
3433 | NavitActivity(-4);
|
2958 | finish();
|
3434 | finish();
|
2959 | }
|
3435 | }
|
2960 |
|
3436 |
|
2961 | public boolean handleMessage(Message m)
|
3437 | public boolean handleMessage(Message m)
|
2962 | {
|
3438 | {
|
… | |
… | |
3044 | static boolean PREF_use_lock_on_roads;
|
3520 | static boolean PREF_use_lock_on_roads;
|
3045 | static boolean PREF_use_route_highways;
|
3521 | static boolean PREF_use_route_highways;
|
3046 | static boolean PREF_save_zoomlevel;
|
3522 | static boolean PREF_save_zoomlevel;
|
3047 | static boolean PREF_show_sat_status;
|
3523 | static boolean PREF_show_sat_status;
|
3048 | static boolean PREF_use_agps;
|
3524 | static boolean PREF_use_agps;
|
|
|
3525 | static boolean PREF_enable_debug_functions;
|
|
|
3526 | static boolean PREF_speak_street_names;
|
3049 | static int PREF_search_country = 1; // default=*ALL*
|
3527 | static int PREF_search_country = 1; // default=*ALL*
|
3050 | static int PREF_zoomlevel_num = 2 * 2 * 2 * 2 * 2;
|
3528 | static int PREF_zoomlevel_num = 2 * 2 * 2 * 2 * 2;
|
|
|
3529 | static boolean PREF_use_custom_font = false;
|
|
|
3530 | static int PREF_map_font_size = 2; // 1 -> small, 2 -> normal, 3 -> large, 4-> extra large, 4-> mega large
|
|
|
3531 | static int PREF_cancel_map_drawing_timeout = 1; // 0 -> short, 1-> normal, 2-> long, 3-> almost unlimited
|
|
|
3532 | static boolean PREF_draw_polyline_circles = true; // true -> yes (default) false -> no
|
|
|
3533 | static int PREF_mapcache = 10 * 1024; // in kbytes
|
|
|
3534 | static String PREF_navit_lang;
|
|
|
3535 | static int PREF_drawatorder = 1;
|
|
|
3536 | static String PREF_streetsearch_r = "1"; // street search radius factor (multiplier)
|
3051 |
|
3537 |
|
3052 | public static void setPrefs_search_country()
|
3538 | public static void setPrefs_search_country()
|
3053 | {
|
3539 | {
|
3054 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
3540 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
3055 | SharedPreferences.Editor editor = prefs.edit();
|
3541 | SharedPreferences.Editor editor = prefs.edit();
|
… | |
… | |
3086 | PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true);
|
3572 | PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true);
|
3087 | PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL*
|
3573 | PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL*
|
3088 | PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 2 * 2 * 2 * 2 * 2);
|
3574 | PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 2 * 2 * 2 * 2 * 2);
|
3089 | PREF_show_sat_status = prefs.getBoolean("show_sat_status", false);
|
3575 | PREF_show_sat_status = prefs.getBoolean("show_sat_status", false);
|
3090 | PREF_use_agps = prefs.getBoolean("use_agps", false);
|
3576 | PREF_use_agps = prefs.getBoolean("use_agps", false);
|
|
|
3577 | PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false);
|
|
|
3578 | PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
|
|
|
3579 | PREF_use_custom_font = prefs.getBoolean("use_custom_font", false);
|
|
|
3580 | PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
|
|
|
3581 | PREF_streetsearch_r = prefs.getString("streetsearch_r", "1");
|
|
|
3582 |
|
|
|
3583 | try
|
|
|
3584 | {
|
|
|
3585 | PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
|
|
|
3586 | }
|
|
|
3587 | catch (Exception e)
|
|
|
3588 | {
|
|
|
3589 | PREF_drawatorder = 0;
|
|
|
3590 | }
|
|
|
3591 |
|
|
|
3592 | try
|
|
|
3593 | {
|
|
|
3594 | PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1"));
|
|
|
3595 | }
|
|
|
3596 | catch (Exception e)
|
|
|
3597 | {
|
|
|
3598 | PREF_cancel_map_drawing_timeout = 1;
|
|
|
3599 | }
|
|
|
3600 |
|
|
|
3601 | try
|
|
|
3602 | {
|
|
|
3603 | PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "2"));
|
|
|
3604 | }
|
|
|
3605 | catch (Exception e)
|
|
|
3606 | {
|
|
|
3607 | PREF_map_font_size = 2;
|
|
|
3608 | }
|
3091 |
|
3609 |
|
3092 | Navit_last_address_search_country_id = PREF_search_country;
|
3610 | Navit_last_address_search_country_id = PREF_search_country;
|
3093 | Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[PREF_search_country][0];
|
3611 | Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[PREF_search_country][0];
|
3094 |
|
3612 |
|
3095 | if (!PREF_follow_gps)
|
3613 | if (!PREF_follow_gps)
|
… | |
… | |
3173 | {
|
3691 | {
|
3174 | NavitVehicle.turn_on_sat_status();
|
3692 | NavitVehicle.turn_on_sat_status();
|
3175 | }
|
3693 | }
|
3176 | else
|
3694 | else
|
3177 | {
|
3695 | {
|
|
|
3696 | // status always on !
|
|
|
3697 | //
|
3178 | NavitVehicle.turn_off_sat_status();
|
3698 | // NavitVehicle.turn_off_sat_status();
|
|
|
3699 | NavitVehicle.turn_on_sat_status();
|
3179 | }
|
3700 | }
|
3180 |
|
3701 |
|
3181 | if (PREF_allow_gui_internal)
|
3702 | if (PREF_allow_gui_internal)
|
3182 | {
|
3703 | {
|
3183 | Message msg = new Message();
|
3704 | Message msg = new Message();
|
… | |
… | |
3383 | catch (Exception e)
|
3904 | catch (Exception e)
|
3384 | {
|
3905 | {
|
3385 | }
|
3906 | }
|
3386 | }
|
3907 | }
|
3387 |
|
3908 |
|
|
|
3909 | // if (PREF_draw_polyline_circles)
|
|
|
3910 | // {
|
|
|
3911 | // Message msg = new Message();
|
|
|
3912 | // Bundle b = new Bundle();
|
|
|
3913 | // b.putString("s", "0");
|
|
|
3914 | // b.putInt("Callback", 56);
|
|
|
3915 | // msg.setData(b);
|
|
|
3916 | // try
|
|
|
3917 | // {
|
|
|
3918 | // N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
3919 | // }
|
|
|
3920 | // catch (Exception e)
|
|
|
3921 | // {
|
|
|
3922 | // }
|
|
|
3923 | // }
|
|
|
3924 | // else
|
|
|
3925 | // {
|
|
|
3926 | // Message msg = new Message();
|
|
|
3927 | // Bundle b = new Bundle();
|
|
|
3928 | // b.putString("s", "1");
|
|
|
3929 | // b.putInt("Callback", 56);
|
|
|
3930 | // msg.setData(b);
|
|
|
3931 | // try
|
|
|
3932 | // {
|
|
|
3933 | // N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
3934 | // }
|
|
|
3935 | // catch (Exception e)
|
|
|
3936 | // {
|
|
|
3937 | // }
|
|
|
3938 | // }
|
|
|
3939 |
|
3388 | if (PREF_use_route_highways)
|
3940 | if (PREF_use_route_highways)
|
3389 | {
|
3941 | {
|
3390 | Message msg = new Message();
|
3942 | Message msg = new Message();
|
3391 | Bundle b = new Bundle();
|
3943 | Bundle b = new Bundle();
|
3392 | b.putInt("Callback", 42);
|
3944 | b.putInt("Callback", 42);
|
… | |
… | |
3411 | }
|
3963 | }
|
3412 | catch (Exception e)
|
3964 | catch (Exception e)
|
3413 | {
|
3965 | {
|
3414 | }
|
3966 | }
|
3415 | }
|
3967 | }
|
|
|
3968 |
|
|
|
3969 | Message msg7 = new Message();
|
|
|
3970 | Bundle b7 = new Bundle();
|
|
|
3971 | b7.putInt("Callback", 57);
|
|
|
3972 | b7.putString("s", "" + PREF_drawatorder);
|
|
|
3973 | msg7.setData(b7);
|
|
|
3974 | try
|
|
|
3975 | {
|
|
|
3976 | N_NavitGraphics.callback_handler.sendMessage(msg7);
|
3416 | }
|
3977 | }
|
|
|
3978 | catch (Exception e)
|
|
|
3979 | {
|
|
|
3980 | }
|
3417 |
|
3981 |
|
3418 | static String PREF_navit_lang;
|
3982 | msg7 = new Message();
|
|
|
3983 | b7 = new Bundle();
|
|
|
3984 | b7.putInt("Callback", 58);
|
|
|
3985 | b7.putString("s", PREF_streetsearch_r);
|
|
|
3986 | msg7.setData(b7);
|
|
|
3987 | try
|
|
|
3988 | {
|
|
|
3989 | N_NavitGraphics.callback_handler.sendMessage(msg7);
|
|
|
3990 | }
|
|
|
3991 | catch (Exception e)
|
|
|
3992 | {
|
|
|
3993 | }
|
|
|
3994 |
|
|
|
3995 | if (PREF_speak_street_names)
|
|
|
3996 | {
|
|
|
3997 | Message msg = new Message();
|
|
|
3998 | Bundle b = new Bundle();
|
|
|
3999 | b.putInt("Callback", 54);
|
|
|
4000 | msg.setData(b);
|
|
|
4001 | try
|
|
|
4002 | {
|
|
|
4003 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
4004 | }
|
|
|
4005 | catch (Exception e)
|
|
|
4006 | {
|
|
|
4007 | }
|
|
|
4008 | }
|
|
|
4009 | else
|
|
|
4010 | {
|
|
|
4011 | Message msg = new Message();
|
|
|
4012 | Bundle b = new Bundle();
|
|
|
4013 | b.putInt("Callback", 53);
|
|
|
4014 | msg.setData(b);
|
|
|
4015 | try
|
|
|
4016 | {
|
|
|
4017 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
4018 | }
|
|
|
4019 | catch (Exception e)
|
|
|
4020 | {
|
|
|
4021 | }
|
|
|
4022 | }
|
|
|
4023 |
|
|
|
4024 | try
|
|
|
4025 | {
|
|
|
4026 | NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[PREF_cancel_map_drawing_timeout];
|
|
|
4027 | NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[PREF_cancel_map_drawing_timeout];
|
|
|
4028 | NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[PREF_cancel_map_drawing_timeout];
|
|
|
4029 | }
|
|
|
4030 | catch (Exception e)
|
|
|
4031 | {
|
|
|
4032 |
|
|
|
4033 | }
|
|
|
4034 |
|
|
|
4035 | // set vars for mapdir change (only really takes effect after restart!)
|
|
|
4036 | getPrefs_mapdir();
|
|
|
4037 | }
|
|
|
4038 |
|
|
|
4039 | private static void getPrefs_mapdir()
|
|
|
4040 | {
|
|
|
4041 | // Get the xml/preferences.xml preferences
|
|
|
4042 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
|
|
4043 | String default_sdcard_dir = Environment.getExternalStorageDirectory().getAbsolutePath();
|
|
|
4044 | Log.e("Navit", "old sdcard dir=" + NavitDataDirectory_Maps);
|
|
|
4045 | Log.e("Navit", "default sdcard dir=" + default_sdcard_dir);
|
|
|
4046 | NavitDataDirectory_Maps = prefs.getString("map_directory", default_sdcard_dir + "/zanavi/maps/");
|
|
|
4047 | // ** DEBUG ** NavitDataDirectory_Maps = prefs.getString("navit_mapsdir", "/sdcard" + "/zanavi/maps/");
|
|
|
4048 | Log.e("Navit", "new sdcard dir=" + NavitDataDirectory_Maps);
|
|
|
4049 | }
|
|
|
4050 |
|
|
|
4051 | static String sanity_check_maps_dir(String check_dir)
|
|
|
4052 | {
|
|
|
4053 | String ret = check_dir;
|
|
|
4054 | ret = ret.replaceAll("\\n", ""); // newline -> ""
|
|
|
4055 | ret = ret.replaceAll("\\r", ""); // return -> ""
|
|
|
4056 | ret = ret.replaceAll("\\t", ""); // tab -> ""
|
|
|
4057 | ret = ret.replaceAll(" ", ""); // space -> ""
|
|
|
4058 | ret = ret.replaceAll("\"", ""); // \" -> ""
|
|
|
4059 | ret = ret.replaceAll("'", ""); // \' -> ""
|
|
|
4060 | ret = ret.replaceAll("\\\\", ""); // "\" -> ""
|
|
|
4061 | if (!ret.endsWith("/"))
|
|
|
4062 | {
|
|
|
4063 | ret = ret + "/";
|
|
|
4064 | }
|
|
|
4065 | System.out.println("sanity check:" + ret);
|
|
|
4066 | return ret;
|
|
|
4067 | }
|
|
|
4068 |
|
|
|
4069 | private static void activatePrefs_mapdir(Boolean at_startup)
|
|
|
4070 | {
|
|
|
4071 | // activate the new directory
|
|
|
4072 | NavitDataDirectory_Maps = sanity_check_maps_dir(NavitDataDirectory_Maps);
|
|
|
4073 | MAP_FILENAME_PATH = NavitDataDirectory_Maps;
|
|
|
4074 | MAPMD5_FILENAME_PATH = NavitDataDirectory_Maps + "/../md5/";
|
|
|
4075 | CFG_FILENAME_PATH = NavitDataDirectory_Maps + "/../";
|
|
|
4076 |
|
|
|
4077 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4078 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4079 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4080 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4081 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4082 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4083 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4084 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4085 | System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
|
|
4086 |
|
|
|
4087 | Handler h_temp = null;
|
|
|
4088 | h_temp = NavitGraphics.callback_handler_s;
|
|
|
4089 | System.out.println("handler 1=" + h_temp.toString());
|
|
|
4090 |
|
|
|
4091 | Message msg1 = new Message();
|
|
|
4092 | Bundle b1 = new Bundle();
|
|
|
4093 | b1.putInt("Callback", 47);
|
|
|
4094 | b1.putString("s", MAP_FILENAME_PATH);
|
|
|
4095 | msg1.setData(b1);
|
|
|
4096 | h_temp.sendMessage(msg1);
|
|
|
4097 |
|
|
|
4098 | if (!at_startup)
|
|
|
4099 | {
|
|
|
4100 | Message msg2 = new Message();
|
|
|
4101 | Bundle b2 = new Bundle();
|
|
|
4102 | b2.putInt("Callback", 18);
|
|
|
4103 | msg2.setData(b2);
|
|
|
4104 | h_temp.sendMessage(msg2);
|
|
|
4105 | }
|
|
|
4106 | }
|
3419 |
|
4107 |
|
3420 | private static void getPrefs_loc()
|
4108 | private static void getPrefs_loc()
|
3421 | {
|
4109 | {
|
3422 | // Get the xml/preferences.xml preferences
|
4110 | // Get the xml/preferences.xml preferences
|
3423 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
4111 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
… | |
… | |
3446 | Configuration config2 = new Configuration();
|
4134 | Configuration config2 = new Configuration();
|
3447 | config2.locale = locale2;
|
4135 | config2.locale = locale2;
|
3448 | // updating locale
|
4136 | // updating locale
|
3449 | getBaseContext_.getResources().updateConfiguration(config2, null);
|
4137 | getBaseContext_.getResources().updateConfiguration(config2, null);
|
3450 | }
|
4138 | }
|
|
|
4139 | }
|
|
|
4140 |
|
|
|
4141 | private static void getPrefs_mapcache()
|
|
|
4142 | {
|
|
|
4143 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
|
|
4144 | try
|
|
|
4145 | {
|
|
|
4146 | PREF_mapcache = Integer.parseInt(prefs.getString("mapcache", "" + (10 * 1024)));
|
|
|
4147 | }
|
|
|
4148 | catch (Exception e)
|
|
|
4149 | {
|
|
|
4150 | e.printStackTrace();
|
|
|
4151 | PREF_mapcache = 10 * 1024;
|
|
|
4152 | }
|
|
|
4153 | System.out.println("**** ***** **** pref mapcache=" + PREF_mapcache);
|
|
|
4154 | }
|
|
|
4155 |
|
|
|
4156 | private static void activatePrefs_mapcache()
|
|
|
4157 | {
|
|
|
4158 | Handler h_temp2 = null;
|
|
|
4159 | h_temp2 = NavitGraphics.callback_handler_s;
|
|
|
4160 | Message msg7 = new Message();
|
|
|
4161 | Bundle b7 = new Bundle();
|
|
|
4162 | b7.putInt("Callback", 55);
|
|
|
4163 | b7.putString("s", String.valueOf(PREF_mapcache * 1024));
|
|
|
4164 | msg7.setData(b7);
|
|
|
4165 | h_temp2.sendMessage(msg7);
|
3451 | }
|
4166 | }
|
3452 |
|
4167 |
|
3453 | public native void NavitMain(Navit x, String lang, int version, String display_density_string);
|
4168 | public native void NavitMain(Navit x, String lang, int version, String display_density_string);
|
3454 |
|
4169 |
|
3455 | public native void NavitActivity(int activity);
|
4170 | public native void NavitActivity(int activity);
|
… | |
… | |
3487 | * open google maps at a given coordinate
|
4202 | * open google maps at a given coordinate
|
3488 | */
|
4203 | */
|
3489 | private void googlemaps_show(String lat, String lon, String name)
|
4204 | private void googlemaps_show(String lat, String lon, String name)
|
3490 | {
|
4205 | {
|
3491 | // geo:latitude,longitude
|
4206 | // geo:latitude,longitude
|
3492 | String url = "geo:" + lat + "," + lon + "?z=" + "16";
|
4207 | String url = null;
|
3493 | Intent gmaps_intent = new Intent(Intent.ACTION_VIEW);
|
4208 | Intent gmaps_intent = new Intent(Intent.ACTION_VIEW);
|
|
|
4209 |
|
|
|
4210 | //url = "geo:" + lat + "," + lon + "?z=" + "16";
|
|
|
4211 | //url = "geo:0,0?q=" + lat + "," + lon + " (" + name + ")";
|
|
|
4212 | url = "geo:0,0?z=16&q=" + lat + "," + lon + " (" + name + ")";
|
|
|
4213 |
|
3494 | gmaps_intent.setData(Uri.parse(url));
|
4214 | gmaps_intent.setData(Uri.parse(url));
|
3495 | this.startActivityForResult(gmaps_intent, NavitAddressSearch_id_gmaps);
|
4215 | this.startActivityForResult(gmaps_intent, NavitAddressSearch_id_gmaps);
|
3496 | }
|
4216 | }
|
3497 |
|
4217 |
|
3498 | public void zoom_out_full()
|
4218 | public void zoom_out_full()
|
… | |
… | |
3508 | }
|
4228 | }
|
3509 |
|
4229 |
|
3510 | public void show_geo_on_screen(float lat, float lng)
|
4230 | public void show_geo_on_screen(float lat, float lng)
|
3511 | {
|
4231 | {
|
3512 | // -> let follow mode stay as it now is ### Navit.follow_button_off();
|
4232 | // -> let follow mode stay as it now is ### Navit.follow_button_off();
|
|
|
4233 |
|
|
|
4234 | // this function sets screen center to "lat, lon", and just returns a dummy string!
|
3513 | String nix = NavitGraphics.CallbackGeoCalc(3, lat, lng);
|
4235 | String nix = NavitGraphics.CallbackGeoCalc(3, lat, lng);
|
3514 | }
|
4236 | }
|
3515 |
|
4237 |
|
3516 | public void zoom_to_route()
|
4238 | public void zoom_to_route()
|
3517 | {
|
4239 | {
|
… | |
… | |
3644 | }
|
4366 | }
|
3645 | if (map_points == null)
|
4367 | if (map_points == null)
|
3646 | {
|
4368 | {
|
3647 | map_points = new ArrayList<Navit_Point_on_Map>();
|
4369 | map_points = new ArrayList<Navit_Point_on_Map>();
|
3648 | }
|
4370 | }
|
3649 | int max_points = 10;
|
4371 | if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
|
3650 | if (map_points.size() > max_points)
|
|
|
3651 | {
|
4372 | {
|
3652 | try
|
4373 | try
|
3653 | {
|
4374 | {
|
3654 | map_points.remove(0);
|
4375 | map_points.remove(0);
|
3655 | }
|
4376 | }
|