… | |
… | |
67 | import android.annotation.SuppressLint;
|
67 | import android.annotation.SuppressLint;
|
68 | import android.annotation.TargetApi;
|
68 | import android.annotation.TargetApi;
|
69 | import android.app.Activity;
|
69 | import android.app.Activity;
|
70 | import android.app.AlertDialog;
|
70 | import android.app.AlertDialog;
|
71 | import android.app.Dialog;
|
71 | import android.app.Dialog;
|
|
|
72 | import android.app.Notification;
|
|
|
73 | import android.app.NotificationManager;
|
|
|
74 | import android.app.PendingIntent;
|
72 | import android.app.ProgressDialog;
|
75 | import android.app.ProgressDialog;
|
73 | import android.app.backup.BackupManager;
|
76 | import android.app.backup.BackupManager;
|
74 | import android.content.ActivityNotFoundException;
|
77 | import android.content.ActivityNotFoundException;
|
75 | import android.content.Context;
|
78 | import android.content.Context;
|
76 | import android.content.DialogInterface;
|
79 | import android.content.DialogInterface;
|
… | |
… | |
118 | import android.view.Gravity;
|
121 | import android.view.Gravity;
|
119 | import android.view.Menu;
|
122 | import android.view.Menu;
|
120 | import android.view.MenuItem;
|
123 | import android.view.MenuItem;
|
121 | import android.view.View;
|
124 | import android.view.View;
|
122 | import android.view.ViewConfiguration;
|
125 | import android.view.ViewConfiguration;
|
|
|
126 | import android.view.ViewGroup.LayoutParams;
|
123 | import android.view.Window;
|
127 | import android.view.Window;
|
124 | import android.view.WindowManager;
|
128 | import android.view.WindowManager;
|
125 | import android.view.WindowManager.LayoutParams;
|
|
|
126 | import android.view.inputmethod.InputMethodManager;
|
129 | import android.view.inputmethod.InputMethodManager;
|
127 | import android.widget.Button;
|
130 | import android.widget.Button;
|
128 | import android.widget.RelativeLayout;
|
131 | import android.widget.RelativeLayout;
|
129 | import android.widget.TextView;
|
132 | import android.widget.TextView;
|
130 | import android.widget.Toast;
|
133 | import android.widget.Toast;
|
… | |
… | |
140 |
|
143 |
|
141 | import de.oberoner.gpx2navit_txt.MainFrame;
|
144 | import de.oberoner.gpx2navit_txt.MainFrame;
|
142 |
|
145 |
|
143 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
146 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
144 | {
|
147 | {
|
145 | public static final String VERSION_TEXT_LONG_INC_REV = "1586";
|
148 | public static final String VERSION_TEXT_LONG_INC_REV = "1670";
|
146 | public static String NavitAppVersion = "0";
|
149 | public static String NavitAppVersion = "0";
|
147 | public static String NavitAppVersion_prev = "-1";
|
150 | public static String NavitAppVersion_prev = "-1";
|
148 | public static String NavitAppVersion_string = "0";
|
151 | public static String NavitAppVersion_string = "0";
|
149 | public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
|
152 | public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
|
150 | public static boolean has_hw_menu_button = false;
|
153 | public static boolean has_hw_menu_button = false;
|
|
|
154 |
|
|
|
155 | static long NAVIT_START_INTENT_DRIVE_HOME = 1L;
|
|
|
156 |
|
|
|
157 | public static Intent ZANaviMapDownloaderServiceIntent = null;
|
151 |
|
158 |
|
152 | TextToSpeech mTts = null;
|
159 | TextToSpeech mTts = null;
|
153 |
|
160 |
|
154 | public static int Global_Init_Finished = 0; // 0 -> no init
|
161 | public static int Global_Init_Finished = 0; // 0 -> no init
|
155 | // 1 -> all C structures are ready for use
|
162 | // 1 -> all C structures are ready for use
|
… | |
… | |
304 | /**
|
311 | /**
|
305 | * struct for a point on the map
|
312 | * struct for a point on the map
|
306 | */
|
313 | */
|
307 | private static final long serialVersionUID = 6899215049749155051L;
|
314 | private static final long serialVersionUID = 6899215049749155051L;
|
308 | String point_name = "";
|
315 | String point_name = "";
|
309 | String addon = null;
|
316 | String addon = null; // null -> normal, "1" -> home location
|
310 | float lat = 0.0f;
|
317 | float lat = 0.0f;
|
311 | float lon = 0.0f;
|
318 | float lon = 0.0f;
|
312 | }
|
319 | }
|
313 |
|
320 |
|
314 | static ArrayList<Navit_Point_on_Map> map_points;
|
321 | static ArrayList<Navit_Point_on_Map> map_points;
|
… | |
… | |
368 | public static int satsInFix = 0;
|
375 | public static int satsInFix = 0;
|
369 |
|
376 |
|
370 | // public static Vibrator vibrator = null;
|
377 | // public static Vibrator vibrator = null;
|
371 |
|
378 |
|
372 | public Handler handler;
|
379 | public Handler handler;
|
373 | private PowerManager.WakeLock wl;
|
380 | static PowerManager.WakeLock wl;
|
|
|
381 | static PowerManager.WakeLock wl_cpu;
|
374 | private NavitActivityResult ActivityResults[];
|
382 | private NavitActivityResult ActivityResults[];
|
375 | public static InputMethodManager mgr = null;
|
383 | public static InputMethodManager mgr = null;
|
376 | public static DisplayMetrics metrics = null;
|
384 | public static DisplayMetrics metrics = null;
|
377 | public static Boolean show_soft_keyboard = false;
|
385 | public static Boolean show_soft_keyboard = false;
|
378 | public static Boolean show_soft_keyboard_now_showing = false;
|
386 | public static Boolean show_soft_keyboard_now_showing = false;
|
… | |
… | |
654 | // // or .detectAll() for all detectable problems
|
662 | // // or .detectAll() for all detectable problems
|
655 | // .penaltyLog().build());
|
663 | // .penaltyLog().build());
|
656 | // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
|
664 | // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
|
657 | // }
|
665 | // }
|
658 |
|
666 |
|
|
|
667 | Log.e("Navit", "OnCreate");
|
|
|
668 |
|
659 | super.onCreate(savedInstanceState);
|
669 | super.onCreate(savedInstanceState);
|
|
|
670 |
|
|
|
671 | // init cancel dialog!! ----------
|
|
|
672 | // init cancel dialog!! ----------
|
|
|
673 | Message msg2 = new Message();
|
|
|
674 | Bundle b2 = new Bundle();
|
|
|
675 | b2.putString("text", "");
|
|
|
676 | msg2.what = 0;
|
|
|
677 | msg2.setData(b2);
|
|
|
678 | ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg2);
|
|
|
679 | // init cancel dialog!! ----------
|
|
|
680 | // init cancel dialog!! ----------
|
660 |
|
681 |
|
661 | app_window = getWindow();
|
682 | app_window = getWindow();
|
662 |
|
683 |
|
663 | // ---------------- set some directories -----------------
|
684 | // ---------------- set some directories -----------------
|
664 | // ---------------- set some directories -----------------
|
685 | // ---------------- set some directories -----------------
|
… | |
… | |
692 | Global_Navit_Object = this;
|
713 | Global_Navit_Object = this;
|
693 | asset_mgr = getAssets();
|
714 | asset_mgr = getAssets();
|
694 |
|
715 |
|
695 | getBaseContext_ = getBaseContext();
|
716 | getBaseContext_ = getBaseContext();
|
696 |
|
717 |
|
|
|
718 | // ----- service -----
|
|
|
719 | // ----- service -----
|
|
|
720 | ZANaviMapDownloaderServiceIntent = new Intent(Navit.getBaseContext_, ZANaviMapDownloaderService.class);
|
|
|
721 | // ----- service -----
|
|
|
722 | // ----- service -----
|
|
|
723 |
|
697 | System.out.println("Navit:onCreate:JTHREAD ID=" + Thread.currentThread().getId());
|
724 | System.out.println("Navit:onCreate:JTHREAD ID=" + Thread.currentThread().getId());
|
698 | System.out.println("Navit:onCreate:THREAD ID=" + NavitGraphics.GetThreadId());
|
725 | System.out.println("Navit:onCreate:THREAD ID=" + NavitGraphics.GetThreadId());
|
699 |
|
726 |
|
700 | // paint for bitmapdrawing on map
|
727 | // paint for bitmapdrawing on map
|
701 | NavitGraphics.paint_for_map_display.setAntiAlias(true);
|
728 | NavitGraphics.paint_for_map_display.setAntiAlias(true);
|
… | |
… | |
740 | Navit.startup_intent = this.getIntent();
|
767 | Navit.startup_intent = this.getIntent();
|
741 | // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
768 | // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
742 | Navit.startup_intent_timestamp = System.currentTimeMillis();
|
769 | Navit.startup_intent_timestamp = System.currentTimeMillis();
|
743 | Log.e("Navit", "**1**A " + startup_intent.getAction());
|
770 | Log.e("Navit", "**1**A " + startup_intent.getAction());
|
744 | Log.e("Navit", "**1**D " + startup_intent.getDataString());
|
771 | Log.e("Navit", "**1**D " + startup_intent.getDataString());
|
|
|
772 | Log.e("Navit", "**1**S " + startup_intent.toString());
|
745 |
|
773 |
|
746 | startup_status = Navit_Status_NORMAL_STARTUP;
|
774 | startup_status = Navit_Status_NORMAL_STARTUP;
|
747 |
|
775 |
|
748 | // init translated text
|
776 | // init translated text
|
749 | NavitTextTranslations.init();
|
777 | NavitTextTranslations.init();
|
… | |
… | |
881 | System.out.println("str nd=" + sharedUserId);
|
909 | System.out.println("str nd=" + sharedUserId);
|
882 | if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
910 | if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
883 | {
|
911 | {
|
884 | System.out.println("##bonus 001##");
|
912 | System.out.println("##bonus 001##");
|
885 | Navit_DonateVersion_Installed = true;
|
913 | Navit_DonateVersion_Installed = true;
|
886 | NavitMapDownloader.MULTI_NUM_THREADS = 3;
|
914 | NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
|
887 | }
|
915 | }
|
888 | }
|
916 | }
|
889 | catch (NameNotFoundException e)
|
917 | catch (NameNotFoundException e)
|
890 | {
|
918 | {
|
891 | e.printStackTrace();
|
919 | e.printStackTrace();
|
… | |
… | |
905 | if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
933 | if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
906 | {
|
934 | {
|
907 | System.out.println("##bonus 002##");
|
935 | System.out.println("##bonus 002##");
|
908 | Navit_DonateVersion_Installed = true;
|
936 | Navit_DonateVersion_Installed = true;
|
909 | Navit_Largemap_DonateVersion_Installed = true;
|
937 | Navit_Largemap_DonateVersion_Installed = true;
|
910 | NavitMapDownloader.MULTI_NUM_THREADS = 3;
|
938 | NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
|
911 | }
|
939 | }
|
912 | }
|
940 | }
|
913 | catch (NameNotFoundException e)
|
941 | catch (NameNotFoundException e)
|
914 | {
|
942 | {
|
915 | e.printStackTrace();
|
943 | e.printStackTrace();
|
… | |
… | |
1356 | {
|
1384 | {
|
1357 | try
|
1385 | try
|
1358 | {
|
1386 | {
|
1359 | message.setLayoutParams(rlp);
|
1387 | message.setLayoutParams(rlp);
|
1360 | // upgrade message
|
1388 | // upgrade message
|
1361 | String upgrade_summary = "\n\n*************\n";
|
1389 | String upgrade_summary = "\n\n***********\n";
|
1362 | // upgrade message
|
1390 | // upgrade message
|
1363 | final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
|
1391 | final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
|
1364 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
1392 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
1365 | message.setText(s);
|
1393 | message.setText(s);
|
1366 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
1394 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
… | |
… | |
1455 | catch (Exception e)
|
1483 | catch (Exception e)
|
1456 | {
|
1484 | {
|
1457 | e.printStackTrace();
|
1485 | e.printStackTrace();
|
1458 | }
|
1486 | }
|
1459 |
|
1487 |
|
|
|
1488 | PowerManager pm = null;
|
1460 | try
|
1489 | try
|
1461 | {
|
1490 | {
|
1462 | PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
1491 | pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
|
1492 | }
|
|
|
1493 | catch (Exception e)
|
|
|
1494 | {
|
|
|
1495 | e.printStackTrace();
|
|
|
1496 | }
|
|
|
1497 |
|
|
|
1498 | try
|
|
|
1499 | {
|
|
|
1500 | // -- // pm.wakeUp(SystemClock.uptimeMillis()); // -- //
|
1463 | // **screen always full on** // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1501 | // **screen always full on** // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1464 | // **screen can go off, cpu will stay on** // wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1502 | // **screen can go off, cpu will stay on** // wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1465 |
|
1503 |
|
1466 | // this works so far, lets the screen dim, but it cpu and screen stays on
|
1504 | // this works so far, lets the screen dim, but it cpu and screen stays on
|
1467 | wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1505 | wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1468 | }
|
1506 | }
|
1469 | catch (Exception e)
|
1507 | catch (Exception e)
|
1470 | {
|
1508 | {
|
1471 | e.printStackTrace();
|
1509 | e.printStackTrace();
|
1472 | wl = null;
|
1510 | wl = null;
|
1473 | }
|
1511 | }
|
1474 |
|
1512 |
|
1475 | try
|
1513 | try
|
1476 | {
|
1514 | {
|
1477 | if (wl != null)
|
1515 | wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ZANaviNeedCpu");
|
1478 | {
|
|
|
1479 | wl.acquire();
|
|
|
1480 | }
|
|
|
1481 | }
|
1516 | }
|
1482 | catch (Exception e)
|
1517 | catch (Exception e)
|
1483 | {
|
1518 | {
|
1484 | e.printStackTrace();
|
1519 | e.printStackTrace();
|
|
|
1520 | wl_cpu = null;
|
1485 | }
|
1521 | }
|
|
|
1522 |
|
|
|
1523 | // try
|
|
|
1524 | // {
|
|
|
1525 | // if (wl != null)
|
|
|
1526 | // {
|
|
|
1527 | // try
|
|
|
1528 | // {
|
|
|
1529 | // wl.release();
|
|
|
1530 | // }
|
|
|
1531 | // catch (Exception e2)
|
|
|
1532 | // {
|
|
|
1533 | // }
|
|
|
1534 | // wl.acquire();
|
|
|
1535 | // Log.e("Navit", "WakeLock: acquire 1");
|
|
|
1536 | // }
|
|
|
1537 | // }
|
|
|
1538 | // catch (Exception e)
|
|
|
1539 | // {
|
|
|
1540 | // e.printStackTrace();
|
|
|
1541 | // }
|
1486 |
|
1542 |
|
1487 | // -- extract overview maps --
|
1543 | // -- extract overview maps --
|
1488 | // -- extract overview maps --
|
1544 | // -- extract overview maps --
|
1489 |
|
1545 |
|
1490 | // File navit_worldmap2_file = new File(NAVIT_DATA_DIR + "/share/worldmap2.txt");
|
1546 | // File navit_worldmap2_file = new File(NAVIT_DATA_DIR + "/share/worldmap2.txt");
|
… | |
… | |
1933 | {
|
1989 | {
|
1934 | e.printStackTrace();
|
1990 | e.printStackTrace();
|
1935 | }
|
1991 | }
|
1936 | }
|
1992 | }
|
1937 |
|
1993 |
|
|
|
1994 | protected void onNewIntent(Intent intent)
|
|
|
1995 | {
|
|
|
1996 | super.onNewIntent(intent);
|
|
|
1997 |
|
|
|
1998 | Log.e("Navit", "3:**1**A " + intent.getAction());
|
|
|
1999 | Log.e("Navit", "3:**1**D " + intent.getDataString());
|
|
|
2000 | Log.e("Navit", "3:**1**S " + intent.toString());
|
|
|
2001 |
|
|
|
2002 | if (Navit.startup_intent == null)
|
|
|
2003 | {
|
|
|
2004 | try
|
|
|
2005 | {
|
|
|
2006 | // make a copy of the given intent object
|
|
|
2007 | Navit.startup_intent = intent.cloneFilter();
|
|
|
2008 | Bundle extras2 = intent.getExtras();
|
|
|
2009 | Navit.startup_intent.putExtras(extras2);
|
|
|
2010 |
|
|
|
2011 | // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
|
|
2012 | Navit.startup_intent_timestamp = System.currentTimeMillis();
|
|
|
2013 | Log.e("Navit", "3a:**1**A " + startup_intent.getAction());
|
|
|
2014 | Log.e("Navit", "3a:**1**D " + startup_intent.getDataString());
|
|
|
2015 | Log.e("Navit", "3a:**1**S " + startup_intent.toString());
|
|
|
2016 | if (extras2 != null)
|
|
|
2017 | {
|
|
|
2018 | long l = extras2.getLong("ZANAVI_INTENT_type");
|
|
|
2019 | if (l != 0L)
|
|
|
2020 | {
|
|
|
2021 | // Log.e("Navit", "2:**1** started via drive home");
|
|
|
2022 | // we have been called from "drive home" widget
|
|
|
2023 | }
|
|
|
2024 | else
|
|
|
2025 | {
|
|
|
2026 | if (startup_intent.getDataString() != null)
|
|
|
2027 | {
|
|
|
2028 | // we have a "geo:" thingy intent, use it
|
|
|
2029 | }
|
|
|
2030 | else
|
|
|
2031 | {
|
|
|
2032 | Navit.startup_intent = null;
|
|
|
2033 | }
|
|
|
2034 | }
|
|
|
2035 | }
|
|
|
2036 | else
|
|
|
2037 | {
|
|
|
2038 | if (startup_intent.getDataString() != null)
|
|
|
2039 | {
|
|
|
2040 | // we have a "geo:" thingy intent, use it
|
|
|
2041 | }
|
|
|
2042 | else
|
|
|
2043 | {
|
|
|
2044 | Navit.startup_intent = null;
|
|
|
2045 | }
|
|
|
2046 | }
|
|
|
2047 | }
|
|
|
2048 | catch (Exception e99)
|
|
|
2049 | {
|
|
|
2050 | Navit.startup_intent = null;
|
|
|
2051 | }
|
|
|
2052 |
|
|
|
2053 | }
|
|
|
2054 |
|
|
|
2055 | }
|
|
|
2056 |
|
1938 | @Override
|
2057 | @Override
|
1939 | public void onStart()
|
2058 | public void onStart()
|
1940 | {
|
2059 | {
|
1941 | Navit.show_mem_used();
|
2060 | Navit.show_mem_used();
|
1942 |
|
2061 |
|
… | |
… | |
2049 |
|
2168 |
|
2050 | try
|
2169 | try
|
2051 | {
|
2170 | {
|
2052 | if (wl != null)
|
2171 | if (wl != null)
|
2053 | {
|
2172 | {
|
|
|
2173 | // try
|
|
|
2174 | // {
|
|
|
2175 | // wl.release();
|
|
|
2176 | // }
|
|
|
2177 | // catch (Exception e2)
|
|
|
2178 | // {
|
|
|
2179 | // }
|
2054 | wl.acquire();
|
2180 | wl.acquire();
|
|
|
2181 | Log.e("Navit", "WakeLock: acquire 2");
|
2055 | }
|
2182 | }
|
2056 | }
|
2183 | }
|
2057 | catch (Exception e)
|
2184 | catch (Exception e)
|
2058 | {
|
2185 | {
|
2059 | e.printStackTrace();
|
2186 | e.printStackTrace();
|
… | |
… | |
2078 | public void onClick(View v)
|
2205 | public void onClick(View v)
|
2079 | {
|
2206 | {
|
2080 |
|
2207 |
|
2081 | // Do whatever you want here
|
2208 | // Do whatever you want here
|
2082 |
|
2209 |
|
2083 | // If tou want to close the dialog, uncomment the line below
|
2210 | // If you want to close the dialog, uncomment the line below
|
2084 | //dialog.dismiss();
|
2211 | //dialog.dismiss();
|
2085 | }
|
2212 | }
|
2086 | }
|
2213 | }
|
2087 |
|
2214 |
|
2088 | AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
2215 | AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
… | |
… | |
2106 | N_NavitGraphics.callback_handler.sendMessage(msg3);
|
2233 | N_NavitGraphics.callback_handler.sendMessage(msg3);
|
2107 | Log.e("Navit", "**** LOAD ALL MAPS **** end");
|
2234 | Log.e("Navit", "**** LOAD ALL MAPS **** end");
|
2108 | }
|
2235 | }
|
2109 |
|
2236 |
|
2110 | String intent_data = null;
|
2237 | String intent_data = null;
|
|
|
2238 | try
|
|
|
2239 | {
|
|
|
2240 |
|
|
|
2241 | int type = 1; // default = assume it's a map coords intent
|
|
|
2242 | Bundle extras = startup_intent.getExtras();
|
|
|
2243 | if (extras != null)
|
|
|
2244 | {
|
|
|
2245 | long l = extras.getLong("ZANAVI_INTENT_type");
|
|
|
2246 | if (l != 0L)
|
|
|
2247 | {
|
|
|
2248 | if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
|
|
|
2249 | {
|
|
|
2250 | type = 2; // call from drive-home-widget
|
|
|
2251 | }
|
|
|
2252 | // ok, now remove that key
|
|
|
2253 | extras.remove("ZANAVI_INTENT_type");
|
|
|
2254 | startup_intent.replaceExtras((Bundle) null);
|
|
|
2255 | }
|
|
|
2256 | }
|
|
|
2257 |
|
|
|
2258 | // ------------------------ BIG LOOP ------------------------
|
|
|
2259 | // ------------------------ BIG LOOP ------------------------
|
|
|
2260 | if (type == 2)
|
|
|
2261 | {
|
|
|
2262 | // drive home
|
|
|
2263 |
|
|
|
2264 | // check if we have a home location
|
|
|
2265 | int home_id = find_home_point();
|
|
|
2266 |
|
|
|
2267 | if (home_id != -1)
|
|
|
2268 | {
|
|
|
2269 | Message msg7 = progress_handler.obtainMessage();
|
|
|
2270 | Bundle b7 = new Bundle();
|
|
|
2271 | msg7.what = 3; // long Toast message
|
|
|
2272 | b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
|
|
|
2273 | msg7.setData(b7);
|
|
|
2274 | progress_handler.sendMessage(msg7);
|
|
|
2275 |
|
|
|
2276 | // clear any previous destinations
|
|
|
2277 | Message msg2 = new Message();
|
|
|
2278 | Bundle b2 = new Bundle();
|
|
|
2279 | b2.putInt("Callback", 7);
|
|
|
2280 | msg2.setData(b2);
|
|
|
2281 | N_NavitGraphics.callback_handler.sendMessage(msg2);
|
|
|
2282 |
|
|
|
2283 | // set position to middle of screen -----------------------
|
|
|
2284 | // set position to middle of screen -----------------------
|
|
|
2285 | // set position to middle of screen -----------------------
|
|
|
2286 | Message msg67 = new Message();
|
|
|
2287 | Bundle b67 = new Bundle();
|
|
|
2288 | b67.putInt("Callback", 51);
|
|
|
2289 | b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
|
|
|
2290 | b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
|
|
|
2291 | msg67.setData(b67);
|
|
|
2292 | N_NavitGraphics.callback_handler.sendMessage(msg67);
|
|
|
2293 | // set position to middle of screen -----------------------
|
|
|
2294 | // set position to middle of screen -----------------------
|
|
|
2295 | // set position to middle of screen -----------------------
|
|
|
2296 |
|
|
|
2297 | try
|
|
|
2298 | {
|
|
|
2299 | Thread.sleep(600); // sleep 0.6 second
|
|
|
2300 | }
|
|
|
2301 | catch (Exception e)
|
|
|
2302 | {
|
|
|
2303 | }
|
|
|
2304 |
|
|
|
2305 | Navit.destination_set();
|
|
|
2306 |
|
|
|
2307 | // set destination to home location
|
|
|
2308 | String lat = String.valueOf(map_points.get(home_id).lat);
|
|
|
2309 | String lon = String.valueOf(map_points.get(home_id).lon);
|
|
|
2310 | String q = map_points.get(home_id).point_name;
|
|
|
2311 |
|
|
|
2312 | // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
|
|
|
2313 |
|
|
|
2314 | Message msg55 = new Message();
|
|
|
2315 | Bundle b55 = new Bundle();
|
|
|
2316 | b55.putInt("Callback", 3);
|
|
|
2317 | b55.putString("lat", lat);
|
|
|
2318 | b55.putString("lon", lon);
|
|
|
2319 | b55.putString("q", q);
|
|
|
2320 | msg55.setData(b55);
|
|
|
2321 | N_NavitGraphics.callback_handler.sendMessage(msg55);
|
|
|
2322 |
|
|
|
2323 | // zoom_to_route();
|
|
|
2324 |
|
|
|
2325 | // try
|
|
|
2326 | // {
|
|
|
2327 | // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
|
|
|
2328 | // }
|
|
|
2329 | // catch (Exception e2)
|
|
|
2330 | // {
|
|
|
2331 | // e2.printStackTrace();
|
|
|
2332 | // }
|
|
|
2333 |
|
|
|
2334 | try
|
|
|
2335 | {
|
|
|
2336 | Navit.follow_button_on();
|
|
|
2337 | }
|
|
|
2338 | catch (Exception e2)
|
|
|
2339 | {
|
|
|
2340 | e2.printStackTrace();
|
|
|
2341 | }
|
|
|
2342 | }
|
|
|
2343 | else
|
|
|
2344 | {
|
|
|
2345 | // no home location set
|
|
|
2346 | Message msg = progress_handler.obtainMessage();
|
|
|
2347 | Bundle b = new Bundle();
|
|
|
2348 | msg.what = 3; // long Toast message
|
|
|
2349 | b.putString("text", Navit.get_text("No Home Location set")); //TRANS
|
|
|
2350 | msg.setData(b);
|
|
|
2351 | progress_handler.sendMessage(msg);
|
|
|
2352 | }
|
|
|
2353 | }
|
|
|
2354 | else if (type == 1)
|
|
|
2355 | {
|
2111 | if (startup_intent != null)
|
2356 | if (startup_intent != null)
|
2112 | {
|
2357 | {
|
2113 | if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
|
2358 | if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
|
2114 | {
|
2359 | {
|
2115 | Log.e("Navit", "**2**A " + startup_intent.getAction());
|
2360 | Log.e("Navit", "**2**A " + startup_intent.getAction());
|
2116 | Log.e("Navit", "**2**D " + startup_intent.getDataString());
|
2361 | Log.e("Navit", "**2**D " + startup_intent.getDataString());
|
2117 | intent_data = startup_intent.getDataString();
|
2362 | intent_data = startup_intent.getDataString();
|
2118 | // we consumed the intent, so reset timestamp value to avoid double consuming of event
|
2363 | // we consumed the intent, so reset timestamp value to avoid double consuming of event
|
2119 | Navit.startup_intent_timestamp = 0L;
|
2364 | Navit.startup_intent_timestamp = 0L;
|
|
|
2365 |
|
|
|
2366 | if (intent_data != null)
|
|
|
2367 | {
|
|
|
2368 | // set position to middle of screen -----------------------
|
|
|
2369 | // set position to middle of screen -----------------------
|
|
|
2370 | // set position to middle of screen -----------------------
|
|
|
2371 | Message msg67 = new Message();
|
|
|
2372 | Bundle b67 = new Bundle();
|
|
|
2373 | b67.putInt("Callback", 51);
|
|
|
2374 | b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
|
|
|
2375 | b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
|
|
|
2376 | msg67.setData(b67);
|
|
|
2377 | N_NavitGraphics.callback_handler.sendMessage(msg67);
|
|
|
2378 | // set position to middle of screen -----------------------
|
|
|
2379 | // set position to middle of screen -----------------------
|
|
|
2380 | // set position to middle of screen -----------------------
|
|
|
2381 | }
|
2120 | }
|
2382 | }
|
2121 | else
|
2383 | else
|
2122 | {
|
2384 | {
|
2123 | Log.e("Navit", "timestamp for navigate_to expired! not using data");
|
2385 | Log.e("Navit", "timestamp for navigate_to expired! not using data");
|
|
|
2386 | }
|
2124 | }
|
2387 | }
|
2125 | }
|
|
|
2126 |
|
2388 |
|
2127 | if ((intent_data != null) && ((intent_data.substring(0, 18).equals("google.navigation:")) || (intent_data.substring(0, 23).equals("http://maps.google.com/")) || (intent_data.substring(0, 24).equals("https://maps.google.com/"))))
|
2389 | if ((intent_data != null) && ((intent_data.substring(0, 18).equals("google.navigation:")) || (intent_data.substring(0, 23).equals("http://maps.google.com/")) || (intent_data.substring(0, 24).equals("https://maps.google.com/"))))
|
2128 | {
|
2390 | {
|
2129 | // better use regex later, but for now to test this feature its ok :-)
|
2391 | // better use regex later, but for now to test this feature its ok :-)
|
2130 | // better use regex later, but for now to test this feature its ok :-)
|
2392 | // better use regex later, but for now to test this feature its ok :-)
|
2131 |
|
2393 |
|
2132 | // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
|
2394 | // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
|
2133 | // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
|
2395 | // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
|
2134 | // b: google.navigation:q=48.25676,16.643
|
2396 | // b: google.navigation:q=48.25676,16.643
|
2135 | // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
|
2397 | // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
|
2136 | // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
|
2398 | // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
|
2137 | // sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
|
2399 | // sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
|
2138 | // -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
|
2400 | // -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
|
2139 | // f: google.navigation:ll=48.25676,16.643&...
|
2401 | // f: google.navigation:ll=48.25676,16.643&...
|
2140 | // c: google.navigation:ll=48.25676,16.643
|
2402 | // c: google.navigation:ll=48.25676,16.643
|
2141 | // h: http://maps.google.com/?q=48.222210,16.387058&z=16
|
2403 | // h: http://maps.google.com/?q=48.222210,16.387058&z=16
|
2142 | // i: https://maps.google.com/?q=48.222210,16.387058&z=16
|
2404 | // i: https://maps.google.com/?q=48.222210,16.387058&z=16
|
2143 | // i:,h: https://maps.google.com/maps/place?ftid=0x476d07075e933fc5:0xccbeba7fe1e3dd36&q=48.222210,16.387058&ui=maps_mini
|
2405 | // i:,h: https://maps.google.com/maps/place?ftid=0x476d07075e933fc5:0xccbeba7fe1e3dd36&q=48.222210,16.387058&ui=maps_mini
|
|
|
2406 | //
|
|
|
2407 | // ??!!new??!!: http://maps.google.com/?cid=10549738100504591748&hl=en&gl=gb
|
2144 |
|
2408 |
|
2145 | String lat;
|
2409 | String lat;
|
2146 | String lon;
|
2410 | String lon;
|
2147 | String q;
|
2411 | String q;
|
2148 |
|
2412 |
|
2149 | String temp1 = null;
|
2413 | String temp1 = null;
|
2150 | String temp2 = null;
|
2414 | String temp2 = null;
|
2151 | String temp3 = null;
|
2415 | String temp3 = null;
|
2152 | boolean parsable = false;
|
2416 | boolean parsable = false;
|
2153 | boolean unparsable_info_box = true;
|
2417 | boolean unparsable_info_box = true;
|
2154 | try
|
2418 | try
|
2155 | {
|
2419 | {
|
2156 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
2420 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
2157 | }
|
2421 | }
|
2158 | catch (Exception e1)
|
2422 | catch (Exception e1)
|
2159 | {
|
2423 | {
|
2160 | e1.printStackTrace();
|
2424 | e1.printStackTrace();
|
2161 | }
|
2425 | }
|
2162 |
|
2426 |
|
2163 | // DEBUG
|
2427 | // DEBUG
|
2164 | // DEBUG
|
2428 | // DEBUG
|
2165 | // DEBUG
|
2429 | // DEBUG
|
2166 | // intent_data = "google.navigation:q=Wien Burggasse 27";
|
2430 | // intent_data = "google.navigation:q=Wien Burggasse 27";
|
2167 | // intent_data = "google.navigation:q=48.25676,16.643";
|
2431 | // intent_data = "google.navigation:q=48.25676,16.643";
|
2168 | // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
|
2432 | // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
|
2169 | // intent_data = "google.navigation:ll=48.25676,16.643";
|
2433 | // intent_data = "google.navigation:ll=48.25676,16.643";
|
2170 | // DEBUG
|
2434 | // DEBUG
|
2171 | // DEBUG
|
2435 | // DEBUG
|
2172 | // DEBUG
|
2436 | // DEBUG
|
2173 |
|
2437 |
|
2174 | try
|
2438 | try
|
2175 | {
|
2439 | {
|
2176 | Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
|
2440 | Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
|
2177 | Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
|
2441 | Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
|
2178 | Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
|
2442 | Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
|
2179 | Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
|
2443 | Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
|
2180 | Log.e("Navit", "found DEBUG 4.1: yy" + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
|
2444 | Log.e("Navit", "found DEBUG 4.1: yy" + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
|
2181 | Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
|
2445 | Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
|
2182 | }
|
2446 | }
|
2183 | catch (Exception e)
|
2447 | catch (Exception e)
|
2184 | {
|
2448 | {
|
2185 | e.printStackTrace();
|
2449 | e.printStackTrace();
|
2186 | }
|
2450 | }
|
2187 |
|
2451 |
|
2188 | if (!Navit.NavitStartupAlreadySearching)
|
2452 | if (!Navit.NavitStartupAlreadySearching)
|
2189 | {
|
2453 | {
|
2190 | if (intent_data.length() > 19)
|
2454 | if (intent_data.length() > 19)
|
2191 | {
|
2455 | {
|
2192 | // if h: then show target
|
2456 | // if h: then show target
|
2193 | if (intent_data.substring(0, 23).equals("http://maps.google.com/"))
|
2457 | if (intent_data.substring(0, 23).equals("http://maps.google.com/"))
|
2194 | {
|
2458 | {
|
2195 | Uri uri = Uri.parse(intent_data);
|
2459 | Uri uri = Uri.parse(intent_data);
|
2196 | Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
|
2460 | Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
|
2197 | parsable = true;
|
2461 | parsable = true;
|
2198 | intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
|
2462 | intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
|
2199 | }
|
2463 | }
|
2200 | // if i: then show target
|
2464 | // if i: then show target
|
2201 | else if (intent_data.substring(0, 24).equals("https://maps.google.com/"))
|
2465 | else if (intent_data.substring(0, 24).equals("https://maps.google.com/"))
|
2202 | {
|
2466 | {
|
2203 | Uri uri = Uri.parse(intent_data);
|
2467 | Uri uri = Uri.parse(intent_data);
|
2204 | Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
|
2468 | Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
|
2205 | parsable = true;
|
2469 | parsable = true;
|
2206 | intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
|
2470 | intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
|
2207 | }
|
2471 | }
|
2208 | // if d: then start target search
|
2472 | // if d: then start target search
|
2209 | else 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]"))))
|
2473 | else 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]"))))
|
2210 | {
|
2474 | {
|
2211 | Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
|
2475 | Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
|
2212 | Navit.NavitStartupAlreadySearching = true;
|
2476 | Navit.NavitStartupAlreadySearching = true;
|
2213 | start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
2477 | start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
2214 | // dont use this here, already starting search, so set to "false"
|
2478 | // dont use this here, already starting search, so set to "false"
|
|
|
2479 | parsable = false;
|
|
|
2480 | unparsable_info_box = false;
|
|
|
2481 | }
|
|
|
2482 | // if b: then remodel the input string to look like a:
|
|
|
2483 | else if (intent_data.substring(0, 20).equals("google.navigation:q="))
|
|
|
2484 | {
|
|
|
2485 | intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
|
|
|
2486 | Log.e("Navit", "target found (b): " + intent_data);
|
|
|
2487 | parsable = true;
|
|
|
2488 | }
|
|
|
2489 | // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
|
|
|
2490 | else if (intent_data.substring(0, 25).equals("google.navigation:///?ll="))
|
|
|
2491 | {
|
|
|
2492 | intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
|
|
|
2493 | Log.e("Navit", "target found (g): " + intent_data);
|
|
|
2494 | parsable = true;
|
|
|
2495 | }
|
|
|
2496 | // if e: then remodel the input string to look like a:
|
|
|
2497 | 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")))
|
|
|
2498 | {
|
|
|
2499 | int idx = intent_data.indexOf("&");
|
|
|
2500 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
|
|
2501 | Log.e("Navit", "target found (e): " + intent_data);
|
|
|
2502 | parsable = true;
|
|
|
2503 | }
|
|
|
2504 | // if f: then remodel the input string to look like a:
|
|
|
2505 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
|
|
|
2506 | {
|
|
|
2507 | int idx = intent_data.indexOf("&");
|
|
|
2508 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
|
|
2509 | Log.e("Navit", "target found (f): " + intent_data);
|
|
|
2510 | parsable = true;
|
|
|
2511 | }
|
|
|
2512 | // already looks like a: just set flag
|
|
|
2513 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
|
|
|
2514 | {
|
|
|
2515 | // dummy, just set the flag
|
|
|
2516 | Log.e("Navit", "target found (a): " + intent_data);
|
|
|
2517 | Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
|
|
|
2518 | parsable = true;
|
|
|
2519 | }
|
|
|
2520 | // if c: then remodel the input string to look like a:
|
|
|
2521 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
|
|
|
2522 | {
|
|
|
2523 |
|
|
|
2524 | intent_data = intent_data + "&q=Target";
|
|
|
2525 | Log.e("Navit", "target found (c): " + intent_data);
|
|
|
2526 | parsable = true;
|
|
|
2527 | }
|
|
|
2528 | }
|
|
|
2529 | }
|
|
|
2530 | else
|
|
|
2531 | {
|
|
|
2532 | Log.e("Navit", "already started search from startup intent");
|
2215 | parsable = false;
|
2533 | parsable = false;
|
2216 | unparsable_info_box = false;
|
2534 | unparsable_info_box = false;
|
2217 | }
|
2535 | }
|
2218 | // if b: then remodel the input string to look like a:
|
|
|
2219 | else if (intent_data.substring(0, 20).equals("google.navigation:q="))
|
|
|
2220 | {
|
|
|
2221 | intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
|
|
|
2222 | Log.e("Navit", "target found (b): " + intent_data);
|
|
|
2223 | parsable = true;
|
|
|
2224 | }
|
|
|
2225 | // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
|
|
|
2226 | else if (intent_data.substring(0, 25).equals("google.navigation:///?ll="))
|
|
|
2227 | {
|
|
|
2228 | intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
|
|
|
2229 | Log.e("Navit", "target found (g): " + intent_data);
|
|
|
2230 | parsable = true;
|
|
|
2231 | }
|
|
|
2232 | // if e: then remodel the input string to look like a:
|
|
|
2233 | 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")))
|
|
|
2234 | {
|
|
|
2235 | int idx = intent_data.indexOf("&");
|
|
|
2236 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
|
|
2237 | Log.e("Navit", "target found (e): " + intent_data);
|
|
|
2238 | parsable = true;
|
|
|
2239 | }
|
|
|
2240 | // if f: then remodel the input string to look like a:
|
|
|
2241 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
|
|
|
2242 | {
|
|
|
2243 | int idx = intent_data.indexOf("&");
|
|
|
2244 | intent_data = intent_data.substring(0, idx) + "&q=Target";
|
|
|
2245 | Log.e("Navit", "target found (f): " + intent_data);
|
|
|
2246 | parsable = true;
|
|
|
2247 | }
|
|
|
2248 | // already looks like a: just set flag
|
|
|
2249 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
|
|
|
2250 | {
|
|
|
2251 | // dummy, just set the flag
|
|
|
2252 | Log.e("Navit", "target found (a): " + intent_data);
|
|
|
2253 | Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
|
|
|
2254 | parsable = true;
|
|
|
2255 | }
|
|
|
2256 | // if c: then remodel the input string to look like a:
|
|
|
2257 | else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
|
|
|
2258 | {
|
|
|
2259 |
|
2536 |
|
2260 | intent_data = intent_data + "&q=Target";
|
|
|
2261 | Log.e("Navit", "target found (c): " + intent_data);
|
|
|
2262 | parsable = true;
|
|
|
2263 | }
|
|
|
2264 | }
|
|
|
2265 | }
|
|
|
2266 | else
|
|
|
2267 | {
|
|
|
2268 | Log.e("Navit", "already started search from startup intent");
|
|
|
2269 | parsable = false;
|
|
|
2270 | unparsable_info_box = false;
|
|
|
2271 | }
|
|
|
2272 |
|
|
|
2273 | if (parsable)
|
2537 | if (parsable)
|
2274 | {
|
2538 | {
|
2275 | // now string should be in form --> a:
|
2539 | // now string should be in form --> a:
|
2276 | // now split the parts off
|
2540 | // now split the parts off
|
2277 | temp1 = intent_data.split("&q=", -1)[0];
|
2541 | temp1 = intent_data.split("&q=", -1)[0];
|
2278 | try
|
|
|
2279 | {
|
|
|
2280 | temp3 = temp1.split("ll=", -1)[1];
|
|
|
2281 | temp2 = intent_data.split("&q=", -1)[1];
|
|
|
2282 | }
|
|
|
2283 | catch (Exception e)
|
|
|
2284 | {
|
|
|
2285 | // java.lang.ArrayIndexOutOfBoundsException most likely
|
|
|
2286 | // so let's assume we dont have '&q=xxxx'
|
|
|
2287 | temp3 = temp1;
|
|
|
2288 | }
|
|
|
2289 |
|
|
|
2290 | if (temp2 == null)
|
|
|
2291 | {
|
|
|
2292 | // use some default name
|
|
|
2293 | temp2 = "Target";
|
|
|
2294 | }
|
|
|
2295 |
|
|
|
2296 | lat = temp3.split(",", -1)[0];
|
|
|
2297 | lon = temp3.split(",", -1)[1];
|
|
|
2298 | q = temp2;
|
|
|
2299 | // is the "search name" url-encoded? i think so, lets url-decode it here
|
|
|
2300 | q = URLDecoder.decode(q);
|
|
|
2301 | // System.out.println();
|
|
|
2302 |
|
|
|
2303 | Navit.remember_destination(q, lat, lon);
|
|
|
2304 | Navit.destination_set();
|
|
|
2305 |
|
|
|
2306 | Message msg = new Message();
|
|
|
2307 | Bundle b = new Bundle();
|
|
|
2308 | b.putInt("Callback", 3);
|
|
|
2309 | b.putString("lat", lat);
|
|
|
2310 | b.putString("lon", lon);
|
|
|
2311 | b.putString("q", q);
|
|
|
2312 | msg.setData(b);
|
|
|
2313 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2314 |
|
|
|
2315 | // zoom_to_route();
|
|
|
2316 | try
|
|
|
2317 | {
|
|
|
2318 | Thread.sleep(400);
|
|
|
2319 | }
|
|
|
2320 | catch (InterruptedException e)
|
|
|
2321 | {
|
|
|
2322 | }
|
|
|
2323 |
|
|
|
2324 | try
|
|
|
2325 | {
|
|
|
2326 | show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
|
|
|
2327 | }
|
|
|
2328 | catch (Exception e2)
|
|
|
2329 | {
|
|
|
2330 | e2.printStackTrace();
|
|
|
2331 | }
|
|
|
2332 |
|
|
|
2333 | try
|
|
|
2334 | {
|
|
|
2335 | Navit.follow_button_on();
|
|
|
2336 | }
|
|
|
2337 | catch (Exception e2)
|
|
|
2338 |
|
|
|
2339 | {
|
|
|
2340 | e2.printStackTrace();
|
|
|
2341 | }
|
|
|
2342 | }
|
|
|
2343 | else
|
|
|
2344 | {
|
|
|
2345 | if (unparsable_info_box && !searchBoxShown)
|
|
|
2346 | {
|
|
|
2347 | try
|
|
|
2348 | {
|
|
|
2349 | searchBoxShown = true;
|
|
|
2350 | String searchString = intent_data.split("q=")[1];
|
|
|
2351 | searchString = searchString.split("&")[0];
|
|
|
2352 | searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
|
|
2353 | Log.e("Navit", "Search String :" + searchString);
|
|
|
2354 | executeSearch(searchString);
|
|
|
2355 | }
|
|
|
2356 | catch (Exception e)
|
|
|
2357 | {
|
|
|
2358 | // safety net
|
|
|
2359 | try
|
2542 | try
|
2360 | {
|
2543 | {
|
2361 | Log.e("Navit", "problem with startup search 7 str=" + intent_data);
|
2544 | temp3 = temp1.split("ll=", -1)[1];
|
|
|
2545 | temp2 = intent_data.split("&q=", -1)[1];
|
|
|
2546 | }
|
|
|
2547 | catch (Exception e)
|
|
|
2548 | {
|
|
|
2549 | // java.lang.ArrayIndexOutOfBoundsException most likely
|
|
|
2550 | // so let's assume we dont have '&q=xxxx'
|
|
|
2551 | temp3 = temp1;
|
|
|
2552 | }
|
|
|
2553 |
|
|
|
2554 | if (temp2 == null)
|
|
|
2555 | {
|
|
|
2556 | // use some default name
|
|
|
2557 | temp2 = "Target";
|
|
|
2558 | }
|
|
|
2559 |
|
|
|
2560 | lat = temp3.split(",", -1)[0];
|
|
|
2561 | lon = temp3.split(",", -1)[1];
|
|
|
2562 | q = temp2;
|
|
|
2563 | // is the "search name" url-encoded? i think so, lets url-decode it here
|
|
|
2564 | q = URLDecoder.decode(q);
|
|
|
2565 | // System.out.println();
|
|
|
2566 |
|
|
|
2567 | Navit.remember_destination(q, lat, lon);
|
|
|
2568 | Navit.destination_set();
|
|
|
2569 |
|
|
|
2570 | Message msg = new Message();
|
|
|
2571 | Bundle b = new Bundle();
|
|
|
2572 | b.putInt("Callback", 3);
|
|
|
2573 | b.putString("lat", lat);
|
|
|
2574 | b.putString("lon", lon);
|
|
|
2575 | b.putString("q", q);
|
|
|
2576 | msg.setData(b);
|
|
|
2577 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2578 |
|
|
|
2579 | // zoom_to_route();
|
|
|
2580 | try
|
|
|
2581 | {
|
|
|
2582 | Thread.sleep(400);
|
|
|
2583 | }
|
|
|
2584 | catch (InterruptedException e)
|
|
|
2585 | {
|
|
|
2586 | }
|
|
|
2587 |
|
|
|
2588 | try
|
|
|
2589 | {
|
|
|
2590 | show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
|
2362 | }
|
2591 | }
|
2363 | catch (Exception e2)
|
2592 | catch (Exception e2)
|
2364 | {
|
2593 | {
|
2365 | e2.printStackTrace();
|
2594 | e2.printStackTrace();
|
2366 | }
|
2595 | }
|
|
|
2596 |
|
|
|
2597 | try
|
|
|
2598 | {
|
|
|
2599 | Navit.follow_button_on();
|
2367 | }
|
2600 | }
|
|
|
2601 | catch (Exception e2)
|
|
|
2602 |
|
|
|
2603 | {
|
|
|
2604 | e2.printStackTrace();
|
|
|
2605 | }
|
2368 | }
|
2606 | }
|
|
|
2607 | else
|
|
|
2608 | {
|
|
|
2609 | if (unparsable_info_box && !searchBoxShown)
|
|
|
2610 | {
|
|
|
2611 | try
|
|
|
2612 | {
|
|
|
2613 | searchBoxShown = true;
|
|
|
2614 | String searchString = intent_data.split("q=")[1];
|
|
|
2615 | searchString = searchString.split("&")[0];
|
|
|
2616 | searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
|
|
2617 | Log.e("Navit", "Search String :" + searchString);
|
|
|
2618 | executeSearch(searchString);
|
|
|
2619 | }
|
|
|
2620 | catch (Exception e)
|
|
|
2621 | {
|
|
|
2622 | // safety net
|
|
|
2623 | try
|
|
|
2624 | {
|
|
|
2625 | Log.e("Navit", "problem with startup search 7 str=" + intent_data);
|
|
|
2626 | }
|
|
|
2627 | catch (Exception e2)
|
|
|
2628 | {
|
|
|
2629 | e2.printStackTrace();
|
|
|
2630 | }
|
|
|
2631 | }
|
|
|
2632 | }
|
|
|
2633 | }
|
2369 | }
|
2634 | }
|
2370 | }
|
|
|
2371 | else if ((intent_data != null) && (intent_data.substring(0, 10).equals("geo:0,0?q=")))
|
2635 | else if ((intent_data != null) && (intent_data.substring(0, 10).equals("geo:0,0?q=")))
|
2372 | {
|
2636 | {
|
2373 | // g: geo:0,0?q=wien%20burggasse
|
2637 | // g: geo:0,0?q=wien%20burggasse
|
2374 |
|
2638 |
|
2375 | boolean parsable = false;
|
2639 | boolean parsable = false;
|
2376 | boolean unparsable_info_box = true;
|
2640 | boolean unparsable_info_box = true;
|
2377 | try
|
|
|
2378 | {
|
|
|
2379 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
|
|
2380 | }
|
|
|
2381 | catch (Exception e1)
|
|
|
2382 | {
|
|
|
2383 | e1.printStackTrace();
|
|
|
2384 |
|
|
|
2385 | }
|
|
|
2386 |
|
|
|
2387 | if (!Navit.NavitStartupAlreadySearching)
|
|
|
2388 | {
|
|
|
2389 | if (intent_data.length() > 10)
|
|
|
2390 | {
|
|
|
2391 | // if g: then start target search
|
|
|
2392 | Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
|
|
|
2393 | Navit.NavitStartupAlreadySearching = true;
|
|
|
2394 | start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
|
|
2395 | // dont use this here, already starting search, so set to "false"
|
|
|
2396 | parsable = false;
|
|
|
2397 | unparsable_info_box = false;
|
|
|
2398 | }
|
|
|
2399 | }
|
|
|
2400 | else
|
|
|
2401 | {
|
|
|
2402 | Log.e("Navit", "already started search from startup intent");
|
|
|
2403 | parsable = false;
|
|
|
2404 | unparsable_info_box = false;
|
|
|
2405 | }
|
|
|
2406 |
|
|
|
2407 | if (unparsable_info_box && !searchBoxShown)
|
|
|
2408 | {
|
|
|
2409 | try
|
|
|
2410 | {
|
|
|
2411 | searchBoxShown = true;
|
|
|
2412 | String searchString = intent_data.split("q=")[1];
|
|
|
2413 | searchString = searchString.split("&")[0];
|
|
|
2414 | searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
|
|
2415 | Log.e("Navit", "Search String :" + searchString);
|
|
|
2416 | executeSearch(searchString);
|
|
|
2417 | }
|
|
|
2418 | catch (Exception e)
|
|
|
2419 | {
|
|
|
2420 | // safety net
|
|
|
2421 | try
|
2641 | try
|
2422 | {
|
2642 | {
|
|
|
2643 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
|
|
2644 | }
|
|
|
2645 | catch (Exception e1)
|
|
|
2646 | {
|
|
|
2647 | e1.printStackTrace();
|
|
|
2648 |
|
|
|
2649 | }
|
|
|
2650 |
|
|
|
2651 | if (!Navit.NavitStartupAlreadySearching)
|
|
|
2652 | {
|
|
|
2653 | if (intent_data.length() > 10)
|
|
|
2654 | {
|
|
|
2655 | // if g: then start target search
|
|
|
2656 | Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
|
|
|
2657 | Navit.NavitStartupAlreadySearching = true;
|
|
|
2658 | start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
|
|
2659 | // dont use this here, already starting search, so set to "false"
|
|
|
2660 | parsable = false;
|
|
|
2661 | unparsable_info_box = false;
|
|
|
2662 | }
|
|
|
2663 | }
|
|
|
2664 | else
|
|
|
2665 | {
|
|
|
2666 | Log.e("Navit", "already started search from startup intent");
|
|
|
2667 | parsable = false;
|
|
|
2668 | unparsable_info_box = false;
|
|
|
2669 | }
|
|
|
2670 |
|
|
|
2671 | if (unparsable_info_box && !searchBoxShown)
|
|
|
2672 | {
|
|
|
2673 | try
|
|
|
2674 | {
|
|
|
2675 | searchBoxShown = true;
|
|
|
2676 | String searchString = intent_data.split("q=")[1];
|
|
|
2677 | searchString = searchString.split("&")[0];
|
|
|
2678 | searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
|
|
2679 | Log.e("Navit", "Search String :" + searchString);
|
|
|
2680 | executeSearch(searchString);
|
|
|
2681 | }
|
|
|
2682 | catch (Exception e)
|
|
|
2683 | {
|
|
|
2684 | // safety net
|
|
|
2685 | try
|
|
|
2686 | {
|
2423 | Log.e("Navit", "problem with startup search 88 str=" + intent_data);
|
2687 | Log.e("Navit", "problem with startup search 88 str=" + intent_data);
|
2424 | }
|
2688 | }
|
2425 | catch (Exception e2)
|
2689 | catch (Exception e2)
|
2426 | {
|
2690 | {
|
2427 | e2.printStackTrace();
|
2691 | e2.printStackTrace();
|
|
|
2692 | }
|
2428 | }
|
2693 | }
|
2429 | }
|
2694 | }
|
|
|
2695 |
|
2430 | }
|
2696 | }
|
2431 |
|
|
|
2432 | }
|
|
|
2433 | else if ((intent_data != null) && (intent_data.substring(0, 4).equals("geo:")))
|
2697 | else if ((intent_data != null) && (intent_data.substring(0, 4).equals("geo:")))
|
2434 | {
|
2698 | {
|
2435 | // g: geo:16.8,46.3?z=15
|
2699 | // g: geo:16.8,46.3?z=15
|
2436 |
|
2700 |
|
2437 | boolean parsable = false;
|
2701 | boolean parsable = false;
|
2438 | boolean unparsable_info_box = true;
|
2702 | boolean unparsable_info_box = true;
|
2439 |
|
2703 |
|
2440 | String tmp1;
|
2704 | String tmp1;
|
2441 | String tmp2;
|
2705 | String tmp2;
|
2442 | String tmp3;
|
2706 | String tmp3;
|
2443 | float lat1 = 0;
|
2707 | float lat1 = 0;
|
2444 | float lon1 = 0;
|
2708 | float lon1 = 0;
|
2445 | int zoom1 = 15;
|
2709 | int zoom1 = 15;
|
2446 |
|
2710 |
|
2447 | try
|
2711 | try
|
2448 | {
|
2712 | {
|
2449 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
2713 | intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
2450 | }
|
2714 | }
|
2451 | catch (Exception e1)
|
2715 | catch (Exception e1)
|
2452 | {
|
2716 | {
|
2453 | e1.printStackTrace();
|
2717 | e1.printStackTrace();
|
2454 | }
|
2718 | }
|
2455 |
|
2719 |
|
2456 | if (!Navit.NavitStartupAlreadySearching)
|
2720 | if (!Navit.NavitStartupAlreadySearching)
|
2457 | {
|
|
|
2458 | try
|
|
|
2459 | {
|
2721 | {
|
|
|
2722 | try
|
|
|
2723 | {
|
2460 | tmp1 = intent_data.split(":", 2)[1];
|
2724 | tmp1 = intent_data.split(":", 2)[1];
|
2461 | tmp2 = tmp1.split("\\?", 2)[0];
|
2725 | tmp2 = tmp1.split("\\?", 2)[0];
|
2462 | tmp3 = tmp1.split("\\?", 2)[1];
|
2726 | tmp3 = tmp1.split("\\?", 2)[1];
|
2463 | lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
|
2727 | lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
|
2464 | lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
|
2728 | lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
|
2465 | zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
|
2729 | zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
|
2466 | parsable = true;
|
2730 | parsable = true;
|
2467 | }
|
2731 | }
|
2468 | catch (Exception e4)
|
2732 | catch (Exception e4)
|
2469 | {
|
2733 | {
|
2470 | e4.printStackTrace();
|
2734 | e4.printStackTrace();
|
|
|
2735 | }
|
2471 | }
|
2736 | }
|
2472 | }
|
|
|
2473 |
|
2737 |
|
2474 | if (parsable)
|
2738 | if (parsable)
|
2475 | {
|
2739 | {
|
2476 | // geo: intent -> only show destination on map!
|
2740 | // geo: intent -> only show destination on map!
|
2477 |
|
2741 |
|
2478 | // set zoomlevel before we show destination
|
2742 | // set zoomlevel before we show destination
|
2479 | int zoom_want = zoom1;
|
2743 | int zoom_want = zoom1;
|
2480 | //
|
2744 | //
|
2481 | Message msg = new Message();
|
2745 | Message msg = new Message();
|
2482 | Bundle b = new Bundle();
|
2746 | Bundle b = new Bundle();
|
2483 | b.putInt("Callback", 33);
|
2747 | b.putInt("Callback", 33);
|
2484 | b.putString("s", Integer.toString(zoom_want));
|
2748 | b.putString("s", Integer.toString(zoom_want));
|
2485 | msg.setData(b);
|
2749 | msg.setData(b);
|
2486 | try
|
2750 | try
|
2487 | {
|
2751 | {
|
2488 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
2752 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
2489 | Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
|
2753 | Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
|
2490 | if ((zoom_want > 8) && (zoom_want < 17))
|
2754 | if ((zoom_want > 8) && (zoom_want < 17))
|
2491 | {
|
2755 | {
|
2492 | Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
|
2756 | Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
|
2493 | System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
|
2757 | System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
|
|
|
2758 | }
|
2494 | }
|
2759 | }
|
2495 | }
|
|
|
2496 | catch (Exception e)
|
2760 | catch (Exception e)
|
2497 | {
|
2761 | {
|
2498 | e.printStackTrace();
|
2762 | e.printStackTrace();
|
2499 | }
|
2763 | }
|
2500 | if (PREF_save_zoomlevel)
|
2764 | if (PREF_save_zoomlevel)
|
2501 | {
|
2765 | {
|
2502 | setPrefs_zoomlevel();
|
2766 | setPrefs_zoomlevel();
|
2503 | }
|
2767 | }
|
2504 | // set nice zoomlevel before we show destination
|
2768 | // set nice zoomlevel before we show destination
|
2505 |
|
2769 |
|
2506 | try
|
2770 | try
|
2507 | {
|
2771 | {
|
2508 | Navit.follow_button_off();
|
2772 | Navit.follow_button_off();
|
2509 | }
|
2773 | }
|
2510 | catch (Exception e2)
|
2774 | catch (Exception e2)
|
2511 | {
|
2775 | {
|
2512 | e2.printStackTrace();
|
2776 | e2.printStackTrace();
|
2513 | }
|
2777 | }
|
2514 |
|
2778 |
|
2515 | show_geo_on_screen(lat1, lon1);
|
2779 | show_geo_on_screen(lat1, lon1);
|
|
|
2780 | }
|
2516 | }
|
2781 | }
|
2517 | }
|
2782 | }
|
|
|
2783 |
|
|
|
2784 | // clear intent
|
|
|
2785 | startup_intent = null;
|
|
|
2786 | // ------------------------ BIG LOOP ------------------------
|
|
|
2787 | // ------------------------ BIG LOOP ------------------------
|
|
|
2788 | }
|
|
|
2789 | catch (Exception e)
|
|
|
2790 | {
|
|
|
2791 | // e.printStackTrace();
|
|
|
2792 | }
|
|
|
2793 |
|
|
|
2794 | // clear intent
|
|
|
2795 | startup_intent = null;
|
2518 |
|
2796 |
|
2519 | // hold all map drawing -----------
|
2797 | // hold all map drawing -----------
|
2520 | Message msg = new Message();
|
2798 | Message msg = new Message();
|
2521 | Bundle b = new Bundle();
|
2799 | Bundle b = new Bundle();
|
2522 | b.putInt("Callback", 69);
|
2800 | b.putInt("Callback", 69);
|
… | |
… | |
2594 |
|
2872 |
|
2595 | @TargetApi(Build.VERSION_CODES.FROYO)
|
2873 | @TargetApi(Build.VERSION_CODES.FROYO)
|
2596 | @Override
|
2874 | @Override
|
2597 | public void onPause()
|
2875 | public void onPause()
|
2598 | {
|
2876 | {
|
2599 | //System.out.println("@@ onPause @@");
|
2877 | // System.out.println("@@ onPause @@");
|
|
|
2878 | Log.e("Navit", "OnPause");
|
2600 | try
|
2879 | try
|
2601 | {
|
2880 | {
|
2602 | setPrefs_zoomlevel();
|
2881 | setPrefs_zoomlevel();
|
2603 | }
|
2882 | }
|
2604 | catch (Exception e)
|
2883 | catch (Exception e)
|
… | |
… | |
2682 |
|
2961 |
|
2683 | turn_off_compass();
|
2962 | turn_off_compass();
|
2684 | NavitVehicle.turn_off_all_providers();
|
2963 | NavitVehicle.turn_off_all_providers();
|
2685 | NavitVehicle.turn_off_sat_status();
|
2964 | NavitVehicle.turn_off_sat_status();
|
2686 |
|
2965 |
|
2687 | Log.e("Navit", "OnPause");
|
2966 | // Log.e("Navit", "OnPause");
|
2688 | cwthr.NavitActivity2(-1);
|
2967 | cwthr.NavitActivity2(-1);
|
2689 |
|
2968 |
|
2690 | Navit.show_mem_used();
|
2969 | Navit.show_mem_used();
|
2691 |
|
2970 |
|
2692 | try
|
2971 | try
|
2693 | {
|
2972 | {
|
2694 | if (wl != null)
|
2973 | if (wl != null)
|
2695 | {
|
2974 | {
|
2696 | wl.release();
|
2975 | wl.release();
|
|
|
2976 | Log.e("Navit", "WakeLock: release 1");
|
|
|
2977 | }
|
|
|
2978 | }
|
|
|
2979 | catch (Exception e)
|
|
|
2980 | {
|
|
|
2981 | e.printStackTrace();
|
|
|
2982 | }
|
|
|
2983 |
|
|
|
2984 | try
|
|
|
2985 | {
|
|
|
2986 | if (wl_cpu != null)
|
|
|
2987 | {
|
|
|
2988 | if (wl_cpu.isHeld())
|
|
|
2989 | {
|
|
|
2990 | wl_cpu.release();
|
|
|
2991 | Log.e("Navit", "WakeLock CPU: release 1");
|
|
|
2992 | }
|
2697 | }
|
2993 | }
|
2698 | }
|
2994 | }
|
2699 | catch (Exception e)
|
2995 | catch (Exception e)
|
2700 | {
|
2996 | {
|
2701 | e.printStackTrace();
|
2997 | e.printStackTrace();
|
… | |
… | |
2758 | }
|
3054 | }
|
2759 | catch (Exception e)
|
3055 | catch (Exception e)
|
2760 | {
|
3056 | {
|
2761 |
|
3057 |
|
2762 | }
|
3058 | }
|
|
|
3059 |
|
|
|
3060 | // ----- service stop -----
|
|
|
3061 | // ----- service stop -----
|
|
|
3062 | System.out.println("Navit:onDestroy -> stop ZANaviMapDownloaderService ---------");
|
|
|
3063 | stopService(Navit.ZANaviMapDownloaderServiceIntent);
|
|
|
3064 | try
|
|
|
3065 | {
|
|
|
3066 | Thread.sleep(1000);
|
|
|
3067 | }
|
|
|
3068 | catch (InterruptedException e)
|
|
|
3069 | {
|
|
|
3070 | }
|
|
|
3071 | // ----- service stop -----
|
|
|
3072 | // ----- service stop -----
|
2763 |
|
3073 |
|
2764 | NavitActivity(-3);
|
3074 | NavitActivity(-3);
|
2765 | Navit.show_mem_used();
|
3075 | Navit.show_mem_used();
|
2766 | }
|
3076 | }
|
2767 |
|
3077 |
|
… | |
… | |
3495 |
|
3805 |
|
3496 | msg = new Message();
|
3806 | msg = new Message();
|
3497 | b = new Bundle();
|
3807 | b = new Bundle();
|
3498 | b.putInt("Callback", 51);
|
3808 | b.putInt("Callback", 51);
|
3499 | b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
|
3809 | b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
|
3500 |
|
|
|
3501 | b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
|
3810 | b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
|
3502 | msg.setData(b);
|
3811 | msg.setData(b);
|
3503 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
3812 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
3504 |
|
3813 |
|
3505 | break;
|
3814 | break;
|
… | |
… | |
3691 | // set map id to download
|
4000 | // set map id to download
|
3692 | Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
|
4001 | Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
|
3693 | // show the map download progressbar, and download the map
|
4002 | // show the map download progressbar, and download the map
|
3694 | if (Navit.download_map_id > -1)
|
4003 | if (Navit.download_map_id > -1)
|
3695 | {
|
4004 | {
|
|
|
4005 | // --------- start a map download (highest level) ---------
|
|
|
4006 | // --------- start a map download (highest level) ---------
|
|
|
4007 | // --------- start a map download (highest level) ---------
|
3696 | showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG);
|
4008 | // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app
|
|
|
4009 |
|
|
|
4010 | // new method in service
|
|
|
4011 | Message msg = progress_handler.obtainMessage();
|
|
|
4012 | Bundle b = new Bundle();
|
|
|
4013 | msg.what = 22;
|
|
|
4014 | progress_handler.sendMessage(msg);
|
|
|
4015 |
|
|
|
4016 | // show license for OSM maps
|
|
|
4017 | //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
|
|
|
4018 | Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_LONG).show(); //TRANS
|
|
|
4019 | // --------- start a map download (highest level) ---------
|
|
|
4020 | // --------- start a map download (highest level) ---------
|
|
|
4021 | // --------- start a map download (highest level) ---------
|
3697 | }
|
4022 | }
|
3698 | }
|
4023 | }
|
3699 | catch (NumberFormatException e)
|
4024 | catch (NumberFormatException e)
|
3700 | {
|
4025 | {
|
3701 | Log.d("Navit", "NumberFormatException selected_id");
|
4026 | Log.d("Navit", "NumberFormatException selected_id");
|
… | |
… | |
3710 | {
|
4035 | {
|
3711 | Log.d("Navit", "error on onActivityResult");
|
4036 | Log.d("Navit", "error on onActivityResult");
|
3712 | e.printStackTrace();
|
4037 | e.printStackTrace();
|
3713 | }
|
4038 | }
|
3714 | break;
|
4039 | break;
|
3715 | case Navit.NavitDownloaderSecSelectMap_id:
|
4040 | case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!!
|
3716 | try
|
4041 | // try
|
3717 | {
|
4042 | // {
|
3718 | if (resultCode == Activity.RESULT_OK)
|
4043 | // if (resultCode == Activity.RESULT_OK)
|
3719 | {
|
4044 | // {
|
3720 | try
|
4045 | // try
|
3721 | {
|
4046 | // {
|
3722 | Log.d("Navit", "SEC id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
4047 | // Log.d("Navit", "SEC id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
3723 | // set map id to download
|
4048 | // // set map id to download
|
3724 | Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
|
4049 | // Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
|
3725 | // show the map download progressbar, and download the map
|
4050 | // // show the map download progressbar, and download the map
|
3726 | if (Navit.download_map_id > -1)
|
4051 | // if (Navit.download_map_id > -1)
|
3727 | {
|
4052 | // {
|
3728 | showDialog(Navit.MAPDOWNLOAD_SEC_DIALOG);
|
4053 | // showDialog(Navit.MAPDOWNLOAD_SEC_DIALOG);
|
|
|
4054 | // }
|
3729 | }
|
4055 | // }
|
3730 | }
|
|
|
3731 | catch (NumberFormatException e)
|
4056 | // catch (NumberFormatException e)
|
3732 | {
|
4057 | // {
|
3733 | Log.d("Navit", "NumberFormatException selected_id");
|
4058 | // Log.d("Navit", "NumberFormatException selected_id");
|
|
|
4059 | // }
|
3734 | }
|
4060 | // }
|
3735 | }
|
|
|
3736 | else
|
4061 | // else
|
3737 | {
|
4062 | // {
|
3738 | // user pressed back key
|
4063 | // // user pressed back key
|
|
|
4064 | // }
|
3739 | }
|
4065 | // }
|
3740 | }
|
|
|
3741 | catch (Exception e)
|
4066 | // catch (Exception e)
|
3742 | {
|
4067 | // {
|
3743 | Log.d("Navit", "error on onActivityResult");
|
4068 | // Log.d("Navit", "error on onActivityResult");
|
3744 | e.printStackTrace();
|
4069 | // e.printStackTrace();
|
3745 | }
|
4070 | // }
|
3746 | break;
|
4071 | break;
|
3747 | case ZANaviVoiceInput_id:
|
4072 | case ZANaviVoiceInput_id:
|
3748 | if (resultCode == Activity.RESULT_OK)
|
4073 | if (resultCode == Activity.RESULT_OK)
|
3749 | {
|
4074 | {
|
3750 | try
|
4075 | try
|
… | |
… | |
5502 | }
|
5827 | }
|
5503 | catch (Exception e)
|
5828 | catch (Exception e)
|
5504 | {
|
5829 | {
|
5505 | e.printStackTrace();
|
5830 | e.printStackTrace();
|
5506 | }
|
5831 | }
|
|
|
5832 |
|
|
|
5833 | try
|
|
|
5834 | {
|
5507 | dismissDialog(msg.getData().getInt("dialog_num"));
|
5835 | dismissDialog(msg.getData().getInt("dialog_num"));
|
5508 | removeDialog(msg.getData().getInt("dialog_num"));
|
5836 | removeDialog(msg.getData().getInt("dialog_num"));
|
|
|
5837 | }
|
|
|
5838 | catch (Exception e)
|
|
|
5839 | {
|
|
|
5840 | }
|
5509 |
|
5841 |
|
5510 | // exit_code=0 -> OK, map was downloaded fine
|
5842 | // exit_code=0 -> OK, map was downloaded fine
|
5511 | if (msg.getData().getInt("exit_code") == 0)
|
5843 | if (msg.getData().getInt("exit_code") == 0)
|
5512 | {
|
5844 | {
|
5513 | // try to use the new downloaded map (works fine now!)
|
5845 | // try to use the new downloaded map (works fine now!)
|
5514 | //Log.d("Navit", "instance count=" + Navit.getInstanceCount()); // where did this go to?
|
5846 | //Log.d("Navit", "instance count=" + Navit.getInstanceCount()); // where did this go to?
|
5515 |
|
5847 |
|
5516 | // **** onStop();
|
5848 | // **** onStop();
|
5517 | // **** onCreate(getIntent().getExtras());
|
5849 | // **** onCreate(getIntent().getExtras());
|
|
|
5850 |
|
|
|
5851 | String this_map_name = "map";
|
|
|
5852 | try
|
|
|
5853 | {
|
|
|
5854 | this_map_name = msg.getData().getString("map_name");
|
|
|
5855 | }
|
|
|
5856 | catch (Exception e)
|
|
|
5857 | {
|
|
|
5858 | }
|
5518 |
|
5859 |
|
5519 | // reload sdcard maps
|
5860 | // reload sdcard maps
|
5520 | Message msg2 = new Message();
|
5861 | Message msg2 = new Message();
|
5521 | Bundle b2 = new Bundle();
|
5862 | Bundle b2 = new Bundle();
|
5522 | b2.putInt("Callback", 18);
|
5863 | b2.putInt("Callback", 18);
|
5523 | msg2.setData(b2);
|
5864 | msg2.setData(b2);
|
5524 | N_NavitGraphics.callback_handler.sendMessage(msg2);
|
5865 | N_NavitGraphics.callback_handler.sendMessage(msg2);
|
|
|
5866 |
|
|
|
5867 | // ----- service stop -----
|
|
|
5868 | // ----- service stop -----
|
|
|
5869 | Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
|
|
|
5870 | // ----- service stop -----
|
|
|
5871 | // ----- service stop -----
|
|
|
5872 |
|
|
|
5873 | try
|
|
|
5874 | {
|
|
|
5875 | // show notification that map is ready
|
|
|
5876 | String Notification_header = "ZANavi";
|
|
|
5877 | String Notification_text = this_map_name + " ready";
|
|
|
5878 |
|
|
|
5879 | NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
|
|
5880 | Notification notification = new Notification(R.drawable.icon, "ZANavi download finished", System.currentTimeMillis());
|
|
|
5881 | notification.flags = Notification.FLAG_AUTO_CANCEL;
|
|
|
5882 | Intent in = new Intent();
|
|
|
5883 | in.setClass(getBaseContext_, Navit.class);
|
|
|
5884 | in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
5885 | PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
5886 | notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
|
|
|
5887 |
|
|
|
5888 | try
|
|
|
5889 | {
|
|
|
5890 | nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
|
|
|
5891 | }
|
|
|
5892 | catch (Exception e)
|
|
|
5893 | {
|
|
|
5894 | e.printStackTrace();
|
|
|
5895 |
|
|
|
5896 | try
|
|
|
5897 | {
|
|
|
5898 | p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
5899 |
|
|
|
5900 | notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
|
|
|
5901 | nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
|
|
|
5902 | }
|
|
|
5903 | catch (Exception e2)
|
|
|
5904 | {
|
|
|
5905 | e2.printStackTrace();
|
|
|
5906 | }
|
|
|
5907 | }
|
|
|
5908 | }
|
|
|
5909 | catch (Exception e)
|
|
|
5910 | {
|
|
|
5911 | e.printStackTrace();
|
|
|
5912 | }
|
5525 |
|
5913 |
|
5526 | zoom_out_full();
|
5914 | zoom_out_full();
|
5527 |
|
5915 |
|
5528 | /*
|
5916 | /*
|
5529 | * Intent intent = getIntent();
|
5917 | * Intent intent = getIntent();
|
… | |
… | |
5539 | //Bundle b2 = new Bundle();
|
5927 | //Bundle b2 = new Bundle();
|
5540 | //b2.putInt("Callback", 6);
|
5928 | //b2.putInt("Callback", 6);
|
5541 | //msg2.setData(b2);
|
5929 | //msg2.setData(b2);
|
5542 | //N_NavitGraphics.callback_handler.sendMessage(msg2);
|
5930 | //N_NavitGraphics.callback_handler.sendMessage(msg2);
|
5543 | }
|
5931 | }
|
|
|
5932 | else
|
|
|
5933 | {
|
|
|
5934 | // there was a problem downloading the map
|
|
|
5935 | // ----- service stop -----
|
|
|
5936 | // ----- service stop -----
|
|
|
5937 | Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
|
|
|
5938 | // ----- service stop -----
|
|
|
5939 | // ----- service stop -----
|
|
|
5940 |
|
|
|
5941 | String this_map_name = "map";
|
|
|
5942 | try
|
|
|
5943 | {
|
|
|
5944 | this_map_name = msg.getData().getString("map_name");
|
|
|
5945 | }
|
|
|
5946 | catch (Exception e)
|
|
|
5947 | {
|
|
|
5948 | }
|
|
|
5949 |
|
|
|
5950 | try
|
|
|
5951 | {
|
|
|
5952 |
|
|
|
5953 | // show notification that there was a download problem
|
|
|
5954 | String Notification_header = "ZANavi";
|
|
|
5955 | String Notification_text = "ERROR while downloading " + this_map_name;
|
|
|
5956 |
|
|
|
5957 | NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
|
|
5958 | Notification notification = new Notification(R.drawable.icon, "ZANavi download ERROR", System.currentTimeMillis());
|
|
|
5959 | notification.flags = Notification.FLAG_AUTO_CANCEL;
|
|
|
5960 | Intent in = new Intent();
|
|
|
5961 | in.setClass(getBaseContext_, Navit.class);
|
|
|
5962 | in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
5963 | PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
5964 | notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
|
|
|
5965 |
|
|
|
5966 | try
|
|
|
5967 | {
|
|
|
5968 | nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
|
|
|
5969 | }
|
|
|
5970 | catch (Exception e)
|
|
|
5971 | {
|
|
|
5972 | e.printStackTrace();
|
|
|
5973 |
|
|
|
5974 | try
|
|
|
5975 | {
|
|
|
5976 | p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
5977 |
|
|
|
5978 | notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
|
|
|
5979 | nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
|
|
|
5980 | }
|
|
|
5981 | catch (Exception e2)
|
|
|
5982 | {
|
|
|
5983 | e2.printStackTrace();
|
|
|
5984 | }
|
|
|
5985 | }
|
|
|
5986 | }
|
|
|
5987 | catch (Exception e)
|
|
|
5988 | {
|
|
|
5989 | e.printStackTrace();
|
|
|
5990 | }
|
|
|
5991 | }
|
5544 | break;
|
5992 | break;
|
5545 | case 1:
|
5993 | case 1:
|
5546 | // change progressbar values
|
5994 | // change progressbar values
|
|
|
5995 | try
|
|
|
5996 | {
|
5547 | int what_dialog = msg.getData().getInt("dialog_num");
|
5997 | int what_dialog = msg.getData().getInt("dialog_num");
|
5548 | if (what_dialog == MAPDOWNLOAD_PRI_DIALOG)
|
5998 | if (what_dialog == MAPDOWNLOAD_PRI_DIALOG)
|
5549 | {
|
5999 | {
|
5550 | mapdownloader_dialog_pri.setMax(msg.getData().getInt("max"));
|
6000 | mapdownloader_dialog_pri.setMax(msg.getData().getInt("max"));
|
5551 | mapdownloader_dialog_pri.setProgress(msg.getData().getInt("cur"));
|
6001 | mapdownloader_dialog_pri.setProgress(msg.getData().getInt("cur"));
|
5552 | mapdownloader_dialog_pri.setTitle(msg.getData().getString("title"));
|
6002 | mapdownloader_dialog_pri.setTitle(msg.getData().getString("title"));
|
5553 | mapdownloader_dialog_pri.setMessage(msg.getData().getString("text"));
|
6003 | mapdownloader_dialog_pri.setMessage(msg.getData().getString("text"));
|
5554 | }
|
6004 | }
|
5555 | else if (what_dialog == MAPDOWNLOAD_SEC_DIALOG)
|
6005 | else if (what_dialog == MAPDOWNLOAD_SEC_DIALOG)
|
5556 | {
|
6006 | {
|
5557 | mapdownloader_dialog_sec.setMax(msg.getData().getInt("max"));
|
6007 | mapdownloader_dialog_sec.setMax(msg.getData().getInt("max"));
|
5558 | mapdownloader_dialog_sec.setProgress(msg.getData().getInt("cur"));
|
6008 | mapdownloader_dialog_sec.setProgress(msg.getData().getInt("cur"));
|
5559 | mapdownloader_dialog_sec.setTitle(msg.getData().getString("title"));
|
6009 | mapdownloader_dialog_sec.setTitle(msg.getData().getString("title"));
|
5560 | mapdownloader_dialog_sec.setMessage(msg.getData().getString("text"));
|
6010 | mapdownloader_dialog_sec.setMessage(msg.getData().getString("text"));
|
|
|
6011 | }
|
|
|
6012 | }
|
|
|
6013 | catch (Exception e)
|
|
|
6014 | {
|
5561 | }
|
6015 | }
|
5562 | break;
|
6016 | break;
|
5563 | case 2:
|
6017 | case 2:
|
5564 | Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
|
6018 | Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
|
5565 | break;
|
6019 | break;
|
5566 | case 3:
|
6020 | case 3:
|
5567 | Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_LONG).show();
|
6021 | Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_LONG).show();
|
5568 | break;
|
6022 | break;
|
5569 | case 10:
|
6023 | case 10:
|
5570 | // change values - generic
|
6024 | // change values - generic
|
|
|
6025 | try
|
|
|
6026 | {
|
5571 | int what_dialog_generic = msg.getData().getInt("dialog_num");
|
6027 | int what_dialog_generic = msg.getData().getInt("dialog_num");
|
5572 | if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG)
|
6028 | if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG)
|
5573 | {
|
6029 | {
|
5574 | search_results_wait.setMax(msg.getData().getInt("max"));
|
6030 | search_results_wait.setMax(msg.getData().getInt("max"));
|
5575 | search_results_wait.setProgress(msg.getData().getInt("cur"));
|
6031 | search_results_wait.setProgress(msg.getData().getInt("cur"));
|
5576 | search_results_wait.setTitle(msg.getData().getString("title"));
|
6032 | search_results_wait.setTitle(msg.getData().getString("title"));
|
5577 | search_results_wait.setMessage(msg.getData().getString("text"));
|
6033 | search_results_wait.setMessage(msg.getData().getString("text"));
|
5578 | }
|
6034 | }
|
5579 | else if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
|
6035 | else if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
|
5580 | {
|
6036 | {
|
5581 | search_results_wait_offline.setMax(msg.getData().getInt("max"));
|
6037 | search_results_wait_offline.setMax(msg.getData().getInt("max"));
|
5582 | search_results_wait_offline.setProgress(msg.getData().getInt("cur"));
|
6038 | search_results_wait_offline.setProgress(msg.getData().getInt("cur"));
|
5583 | search_results_wait_offline.setTitle(msg.getData().getString("title"));
|
6039 | search_results_wait_offline.setTitle(msg.getData().getString("title"));
|
5584 | search_results_wait_offline.setMessage(msg.getData().getString("text"));
|
6040 | search_results_wait_offline.setMessage(msg.getData().getString("text"));
|
|
|
6041 | }
|
|
|
6042 | }
|
|
|
6043 | catch (Exception e)
|
|
|
6044 | {
|
5585 | }
|
6045 | }
|
5586 | break;
|
6046 | break;
|
5587 | case 11:
|
6047 | case 11:
|
5588 | // show dialog - generic
|
6048 | // show dialog - generic
|
5589 | try
|
6049 | try
|
… | |
… | |
5664 | dim_screen();
|
6124 | dim_screen();
|
5665 | break;
|
6125 | break;
|
5666 | case 21:
|
6126 | case 21:
|
5667 | default_brightness_screen();
|
6127 | default_brightness_screen();
|
5668 | break;
|
6128 | break;
|
|
|
6129 | case 22:
|
|
|
6130 | try
|
|
|
6131 | {
|
|
|
6132 | // ----- service start -----
|
|
|
6133 | // ----- service start -----
|
|
|
6134 | startService(Navit.ZANaviMapDownloaderServiceIntent);
|
|
|
6135 | // ----- service start -----
|
|
|
6136 | // ----- service start -----
|
|
|
6137 |
|
|
|
6138 | // try
|
|
|
6139 | // {
|
|
|
6140 | // Thread.sleep(200);
|
|
|
6141 | // }
|
|
|
6142 | // catch (InterruptedException e)
|
|
|
6143 | // {
|
|
|
6144 | // }
|
|
|
6145 |
|
|
|
6146 | // if (!ZANaviMapDownloaderService.service_running)
|
|
|
6147 | // {
|
|
|
6148 | // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
|
|
|
6149 | // try
|
|
|
6150 | // {
|
|
|
6151 | // Thread.sleep(2000);
|
|
|
6152 | // }
|
|
|
6153 | // catch (InterruptedException e)
|
|
|
6154 | // {
|
|
|
6155 | // }
|
|
|
6156 | // }
|
|
|
6157 | //
|
|
|
6158 | // if (!ZANaviMapDownloaderService.service_running)
|
|
|
6159 | // {
|
|
|
6160 | // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
|
|
|
6161 | // try
|
|
|
6162 | // {
|
|
|
6163 | // Thread.sleep(2000);
|
|
|
6164 | // }
|
|
|
6165 | // catch (InterruptedException e)
|
|
|
6166 | // {
|
|
|
6167 | // }
|
|
|
6168 | // }
|
|
|
6169 |
|
|
|
6170 | // -------- // ZANaviMapDownloaderService.start_map_download();
|
|
|
6171 | }
|
|
|
6172 | catch (Exception e)
|
|
|
6173 | {
|
|
|
6174 | e.printStackTrace();
|
|
|
6175 | }
|
|
|
6176 | break;
|
5669 | case 99:
|
6177 | case 99:
|
5670 | // dismiss dialog, remove dialog - generic
|
6178 | // dismiss dialog, remove dialog - generic
|
5671 | try
|
6179 | try
|
5672 | {
|
6180 | {
|
5673 | Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
|
6181 | Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
|
… | |
… | |
5796 | mapdownloader_dialog_pri.setCancelable(false);
|
6304 | mapdownloader_dialog_pri.setCancelable(false);
|
5797 | mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
|
6305 | mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
|
5798 | mapdownloader_dialog_pri.setProgress(0);
|
6306 | mapdownloader_dialog_pri.setProgress(0);
|
5799 | mapdownloader_dialog_pri.setMax(200);
|
6307 | mapdownloader_dialog_pri.setMax(200);
|
5800 |
|
6308 |
|
5801 | LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
|
6309 | WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
|
5802 | dialog_lparams.screenBrightness = 0.1f;
|
6310 | dialog_lparams.screenBrightness = 0.1f;
|
5803 | mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);
|
6311 | mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);
|
5804 |
|
6312 |
|
5805 | DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener()
|
6313 | DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener()
|
5806 | {
|
6314 | {
|
5807 | public void onDismiss(DialogInterface dialog)
|
6315 | public void onDismiss(DialogInterface dialog)
|
5808 | {
|
6316 | {
|
5809 | LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
|
6317 | LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
|
5810 | mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);
|
6318 | mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
|
5811 | mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
|
6319 | mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
|
5812 | mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
6320 | mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
5813 | Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
|
6321 | Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
|
5814 | dialog.dismiss();
|
6322 | dialog.dismiss();
|
5815 | dialog.cancel();
|
6323 | dialog.cancel();
|
… | |
… | |
5922 | Log.e("Navit", "4***************** exit called ****************");
|
6430 | Log.e("Navit", "4***************** exit called ****************");
|
5923 | Log.e("Navit", "5***************** exit called ****************");
|
6431 | Log.e("Navit", "5***************** exit called ****************");
|
5924 | Log.e("Navit", "6***************** exit called ****************");
|
6432 | Log.e("Navit", "6***************** exit called ****************");
|
5925 | Log.e("Navit", "7***************** exit called ****************");
|
6433 | Log.e("Navit", "7***************** exit called ****************");
|
5926 | Log.e("Navit", "8***************** exit called ****************");
|
6434 | Log.e("Navit", "8***************** exit called ****************");
|
|
|
6435 |
|
|
|
6436 | // ----- service stop -----
|
|
|
6437 | // ----- service stop -----
|
|
|
6438 | System.out.println("Navit:exit -> stop ZANaviMapDownloaderService ---------");
|
|
|
6439 | ZANaviMapDownloaderService.stop_downloading();
|
|
|
6440 | stopService(Navit.ZANaviMapDownloaderServiceIntent);
|
|
|
6441 | // ----- service stop -----
|
|
|
6442 | // ----- service stop -----
|
5927 |
|
6443 |
|
5928 | // +++++ // System.gc();
|
6444 | // +++++ // System.gc();
|
5929 | NavitActivity(-4);
|
6445 | NavitActivity(-4);
|
5930 | Log.e("Navit", "XX1***************** exit called ****************");
|
6446 | Log.e("Navit", "XX1***************** exit called ****************");
|
5931 | finish();
|
6447 | finish();
|
… | |
… | |
7483 | e.printStackTrace();
|
7999 | e.printStackTrace();
|
7484 | }
|
8000 | }
|
7485 | return ret;
|
8001 | return ret;
|
7486 | }
|
8002 | }
|
7487 |
|
8003 |
|
|
|
8004 | static void remove_oldest_normal_point()
|
|
|
8005 | {
|
|
|
8006 | int i;
|
|
|
8007 | for (i = 0; i < map_points.size(); i++)
|
|
|
8008 | {
|
|
|
8009 | Navit_Point_on_Map element_temp = map_points.get(i);
|
|
|
8010 | if (element_temp.addon == null)
|
|
|
8011 | {
|
|
|
8012 | // its a normal (non home, non special item), so can remove it, and return.
|
|
|
8013 | break;
|
|
|
8014 | }
|
|
|
8015 | }
|
|
|
8016 | }
|
|
|
8017 |
|
|
|
8018 | static int find_home_point()
|
|
|
8019 | {
|
|
|
8020 | int home_id = -1;
|
|
|
8021 | int i;
|
|
|
8022 |
|
|
|
8023 | for (i = 0; i < map_points.size(); i++)
|
|
|
8024 | {
|
|
|
8025 | Navit_Point_on_Map element_temp = map_points.get(i);
|
|
|
8026 | if (element_temp.addon != null)
|
|
|
8027 | {
|
|
|
8028 | if (element_temp.addon.equals("1"))
|
|
|
8029 | {
|
|
|
8030 | // found home
|
|
|
8031 | return i;
|
|
|
8032 | }
|
|
|
8033 | }
|
|
|
8034 | }
|
|
|
8035 | return home_id;
|
|
|
8036 | }
|
|
|
8037 |
|
|
|
8038 | static void readd_home_point()
|
|
|
8039 | {
|
|
|
8040 | try
|
|
|
8041 | {
|
|
|
8042 | int home_id = find_home_point();
|
|
|
8043 | if (home_id != -1)
|
|
|
8044 | {
|
|
|
8045 | Navit_Point_on_Map element_old = map_points.get(home_id);
|
|
|
8046 | map_points.remove(home_id);
|
|
|
8047 | map_points.add(element_old);
|
|
|
8048 | }
|
|
|
8049 | }
|
|
|
8050 | catch (Exception e)
|
|
|
8051 | {
|
|
|
8052 | }
|
|
|
8053 | }
|
|
|
8054 |
|
7488 | static void add_map_point(Navit_Point_on_Map element)
|
8055 | static void add_map_point(Navit_Point_on_Map element)
|
7489 | {
|
8056 | {
|
7490 | if (element == null)
|
8057 | if (element == null)
|
7491 | {
|
8058 | {
|
7492 | return;
|
8059 | return;
|
7493 | }
|
8060 | }
|
|
|
8061 |
|
7494 | if (map_points == null)
|
8062 | if (map_points == null)
|
7495 | {
|
8063 | {
|
7496 | map_points = new ArrayList<Navit_Point_on_Map>();
|
8064 | map_points = new ArrayList<Navit_Point_on_Map>();
|
7497 | }
|
8065 | }
|
|
|
8066 |
|
7498 | if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
|
8067 | if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
|
7499 | {
|
8068 | {
|
7500 | try
|
8069 | try
|
7501 | {
|
8070 | {
|
7502 | map_points.remove(0);
|
8071 | // map_points.remove(0);
|
|
|
8072 | remove_oldest_normal_point();
|
7503 | }
|
8073 | }
|
7504 | catch (Exception e)
|
8074 | catch (Exception e)
|
7505 | {
|
8075 | {
|
7506 | }
|
8076 | }
|
7507 | }
|
8077 | }
|
… | |
… | |
7509 | int el_pos = check_dup_destination_pos(element);
|
8079 | int el_pos = check_dup_destination_pos(element);
|
7510 | if (el_pos == -1)
|
8080 | if (el_pos == -1)
|
7511 | {
|
8081 | {
|
7512 | // if not duplicate, then add
|
8082 | // if not duplicate, then add
|
7513 | map_points.add(element);
|
8083 | map_points.add(element);
|
|
|
8084 | readd_home_point();
|
|
|
8085 | write_map_points();
|
7514 | }
|
8086 | }
|
7515 | else
|
8087 | else
|
7516 | {
|
8088 | {
|
7517 | try
|
8089 | try
|
7518 | {
|
8090 | {
|
7519 | // if already in list, then first remove and add again
|
8091 | // if already in list, then first remove and add again
|
7520 | // that moves it to the top of the list
|
8092 | // that moves it to the top of the list
|
7521 | Navit_Point_on_Map element_old = map_points.get(el_pos);
|
8093 | Navit_Point_on_Map element_old = map_points.get(el_pos);
|
7522 | map_points.remove(el_pos);
|
8094 | map_points.remove(el_pos);
|
7523 | map_points.add(element_old);
|
8095 | map_points.add(element_old);
|
|
|
8096 | readd_home_point();
|
7524 | write_map_points();
|
8097 | write_map_points();
|
7525 | }
|
8098 | }
|
7526 | catch (Exception e)
|
8099 | catch (Exception e)
|
7527 | {
|
8100 | {
|
7528 | e.printStackTrace();
|
8101 | e.printStackTrace();
|
… | |
… | |
7660 | Boolean ret = false;
|
8233 | Boolean ret = false;
|
7661 | Navit_Point_on_Map t;
|
8234 | Navit_Point_on_Map t;
|
7662 | for (int i = 0; i < map_points.size(); i++)
|
8235 | for (int i = 0; i < map_points.size(); i++)
|
7663 | {
|
8236 | {
|
7664 | t = map_points.get(i);
|
8237 | t = map_points.get(i);
|
|
|
8238 | if (t.addon == null)
|
|
|
8239 | {
|
7665 | if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon))
|
8240 | if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
|
7666 | {
|
8241 | {
|
7667 | return true;
|
8242 | return true;
|
|
|
8243 | }
|
|
|
8244 | }
|
|
|
8245 | else
|
|
|
8246 | {
|
|
|
8247 | if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
|
|
|
8248 | {
|
|
|
8249 | return true;
|
|
|
8250 | }
|
7668 | }
|
8251 | }
|
7669 | }
|
8252 | }
|
7670 | return ret;
|
8253 | return ret;
|
7671 | }
|
8254 | }
|
7672 |
|
8255 |
|
… | |
… | |
7675 | int ret = -1;
|
8258 | int ret = -1;
|
7676 | Navit_Point_on_Map t;
|
8259 | Navit_Point_on_Map t;
|
7677 | for (int i = 0; i < map_points.size(); i++)
|
8260 | for (int i = 0; i < map_points.size(); i++)
|
7678 | {
|
8261 | {
|
7679 | t = map_points.get(i);
|
8262 | t = map_points.get(i);
|
|
|
8263 | if (t.addon == null)
|
|
|
8264 | {
|
7680 | if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon))
|
8265 | if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
|
7681 | {
|
8266 | {
|
7682 | return i;
|
8267 | return i;
|
|
|
8268 | }
|
|
|
8269 | }
|
|
|
8270 | else
|
|
|
8271 | {
|
|
|
8272 | if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
|
|
|
8273 | {
|
|
|
8274 | return i;
|
|
|
8275 | }
|
7683 | }
|
8276 | }
|
7684 | }
|
8277 | }
|
7685 | return ret;
|
8278 | return ret;
|
7686 | }
|
8279 | }
|
7687 |
|
8280 |
|