… | |
… | |
185 |
|
185 |
|
186 | import de.oberoner.gpx2navit_txt.MainFrame;
|
186 | import de.oberoner.gpx2navit_txt.MainFrame;
|
187 |
|
187 |
|
188 | public class Navit extends ActionBarActivity implements Handler.Callback, SensorEventListener
|
188 | public class Navit extends ActionBarActivity implements Handler.Callback, SensorEventListener
|
189 | {
|
189 | {
|
190 | public static final String VERSION_TEXT_LONG_INC_REV = "3588";
|
190 | public static final String VERSION_TEXT_LONG_INC_REV = "3651";
|
191 | public static String NavitAppVersion = "0";
|
191 | public static String NavitAppVersion = "0";
|
192 | public static String NavitAppVersion_prev = "-1";
|
192 | public static String NavitAppVersion_prev = "-1";
|
193 | public static String NavitAppVersion_string = "0";
|
193 | public static String NavitAppVersion_string = "0";
|
194 | public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
|
194 | public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
|
195 | public static boolean has_hw_menu_button = false;
|
195 | public static boolean has_hw_menu_button = false;
|
… | |
… | |
361 | final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
|
361 | final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
|
362 | static Boolean unsupported = false;
|
362 | static Boolean unsupported = false;
|
363 | static Boolean Navit_maps_loaded = false;
|
363 | static Boolean Navit_maps_loaded = false;
|
364 | final static int Navit_MAX_RECENT_DESTINATIONS = 50;
|
364 | final static int Navit_MAX_RECENT_DESTINATIONS = 50;
|
365 | static String debug_item_dump = "";
|
365 | static String debug_item_dump = "";
|
|
|
366 | static String global_last_destination_name = "";
|
366 |
|
367 |
|
367 | // for future use ...
|
368 | // for future use ...
|
368 | // public static String NavitDataDirectory = "/sdcard/";
|
369 | // public static String NavitDataDirectory = "/sdcard/";
|
369 | public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
|
370 | public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
|
370 | static File[] NavitDataStorageDirs = null;
|
371 | static File[] NavitDataStorageDirs = null;
|
… | |
… | |
3542 | }
|
3543 | }
|
3543 |
|
3544 |
|
3544 | Navit.destination_set();
|
3545 | Navit.destination_set();
|
3545 |
|
3546 |
|
3546 | // set destination to home location
|
3547 | // set destination to home location
|
3547 | String lat = String.valueOf(map_points.get(home_id).lat);
|
3548 | // String lat = String.valueOf(map_points.get(home_id).lat);
|
3548 | String lon = String.valueOf(map_points.get(home_id).lon);
|
3549 | // String lon = String.valueOf(map_points.get(home_id).lon);
|
3549 | String q = map_points.get(home_id).point_name;
|
3550 | // String q = map_points.get(home_id).point_name;
|
3550 |
|
3551 | route_wrapper(map_points.get(home_id).point_name, 0, 0, false, map_points.get(home_id).lat, map_points.get(home_id).lon, true);
|
3551 | // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
|
|
|
3552 |
|
|
|
3553 | Message msg55 = new Message();
|
|
|
3554 | Bundle b55 = new Bundle();
|
|
|
3555 | b55.putInt("Callback", 3);
|
|
|
3556 | b55.putString("lat", lat);
|
|
|
3557 | b55.putString("lon", lon);
|
|
|
3558 | b55.putString("q", q);
|
|
|
3559 | msg55.setData(b55);
|
|
|
3560 | NavitGraphics.callback_handler.sendMessage(msg55);
|
|
|
3561 |
|
3552 |
|
3562 | final Thread zoom_to_route_001 = new Thread()
|
3553 | final Thread zoom_to_route_001 = new Thread()
|
3563 | {
|
3554 | {
|
3564 | int wait = 1;
|
3555 | int wait = 1;
|
3565 | int count = 0;
|
3556 | int count = 0;
|
… | |
… | |
8265 | }
|
8256 | }
|
8266 | else if (msg.getData().getInt("Callback") == 55503)
|
8257 | else if (msg.getData().getInt("Callback") == 55503)
|
8267 | {
|
8258 | {
|
8268 | try
|
8259 | try
|
8269 | {
|
8260 | {
|
8270 | NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0);
|
8261 | NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0); // CLR
|
8271 | NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
|
8262 | NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
|
8272 | }
|
8263 | }
|
8273 | catch (Exception e)
|
8264 | catch (Exception e)
|
8274 | {
|
8265 | {
|
8275 | }
|
8266 | }
|
… | |
… | |
8283 | }
|
8274 | }
|
8284 | else if (msg.getData().getInt("Callback") == 3)
|
8275 | else if (msg.getData().getInt("Callback") == 3)
|
8285 | {
|
8276 | {
|
8286 | try
|
8277 | try
|
8287 | {
|
8278 | {
|
8288 | NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0);
|
8279 | NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0); // CLR
|
8289 | NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
|
8280 | NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
|
8290 | }
|
8281 | }
|
8291 | catch (Exception e)
|
8282 | catch (Exception e)
|
8292 | {
|
8283 | {
|
8293 | }
|
8284 | }
|
… | |
… | |
8924 | }
|
8915 | }
|
8925 | };
|
8916 | };
|
8926 |
|
8917 |
|
8927 | public Handler progress_handler = new Handler()
|
8918 | public Handler progress_handler = new Handler()
|
8928 | {
|
8919 | {
|
8929 |
|
|
|
8930 | @SuppressLint("NewApi")
|
8920 | @SuppressLint("NewApi")
|
8931 | public void handleMessage(Message msg)
|
8921 | public void handleMessage(Message msg)
|
8932 | {
|
8922 | {
|
8933 | switch (msg.what)
|
8923 | switch (msg.what)
|
8934 | {
|
8924 | {
|
… | |
… | |
9570 | NavitGraphics.params_whats_here_container_wrap.topMargin = NavitGraphics.NavitAOverlay_s.bubble_001.y - NavitGraphics.whats_here_container_wrap.getHeight() + NavitGraphics.dp_to_px(17);
|
9560 | NavitGraphics.params_whats_here_container_wrap.topMargin = NavitGraphics.NavitAOverlay_s.bubble_001.y - NavitGraphics.whats_here_container_wrap.getHeight() + NavitGraphics.dp_to_px(17);
|
9571 | NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
|
9561 | NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
|
9572 | NavitGraphics.whats_here_container_wrap.requestLayout();
|
9562 | NavitGraphics.whats_here_container_wrap.requestLayout();
|
9573 |
|
9563 |
|
9574 | NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
|
9564 | NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
|
9575 | // NavitGraphics.params_whats_here_pointer_image.leftMargin = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
|
9565 | // has some bugs // NavitGraphics.params_whats_here_pointer_image.leftMargin = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
|
9576 | NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
|
9566 | NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
|
9577 | NavitGraphics.whats_here_pointer_image.requestLayout();
|
9567 | NavitGraphics.whats_here_pointer_image.requestLayout();
|
|
|
9568 | NavitGraphics.whats_here_pointer_image.setVisibility(View.INVISIBLE);
|
9578 | }
|
9569 | }
|
9579 | break;
|
9570 | break;
|
9580 | case 37:
|
9571 | case 37:
|
9581 | // set text for point on screen
|
9572 | // set text for point on screen
|
9582 | String dest_name = "Point on Screen";
|
9573 | String dest_name = "Point on Screen";
|
… | |
… | |
9868 | //}
|
9859 | //}
|
9869 | //catch (Exception s)
|
9860 | //catch (Exception s)
|
9870 | //{
|
9861 | //{
|
9871 | // s.printStackTrace();
|
9862 | // s.printStackTrace();
|
9872 | //}
|
9863 | //}
|
|
|
9864 |
|
|
|
9865 | try
|
|
|
9866 | {
|
|
|
9867 | if (p.PREF_enable_debug_write_gpx)
|
|
|
9868 | {
|
|
|
9869 | NavitVehicle.pos_recording_end();
|
|
|
9870 | }
|
|
|
9871 | }
|
|
|
9872 | catch (Exception e)
|
|
|
9873 | {
|
|
|
9874 | }
|
9873 |
|
9875 |
|
9874 | try
|
9876 | try
|
9875 | {
|
9877 | {
|
9876 | mTts.stop();
|
9878 | mTts.stop();
|
9877 | }
|
9879 | }
|
… | |
… | |
10607 | {
|
10609 | {
|
10608 | p.PREF_zoomlevel_num = Navit.GlobalScaleLevel;
|
10610 | p.PREF_zoomlevel_num = Navit.GlobalScaleLevel;
|
10609 | }
|
10611 | }
|
10610 |
|
10612 |
|
10611 | // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
|
10613 | // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
|
|
|
10614 | }
|
|
|
10615 |
|
|
|
10616 | private static void set_TurnRestrictions_layers()
|
|
|
10617 | {
|
|
|
10618 | int on_ = 59; // on
|
|
|
10619 |
|
|
|
10620 | if (!p.PREF_enable_debug_functions)
|
|
|
10621 | {
|
|
|
10622 | on_ = 60; // off
|
|
|
10623 | }
|
|
|
10624 |
|
|
|
10625 | Message msg = new Message();
|
|
|
10626 | Bundle b = new Bundle();
|
|
|
10627 | b.putInt("Callback", on_);
|
|
|
10628 | b.putString("s", "TurnRestrictions");
|
|
|
10629 | msg.setData(b);
|
|
|
10630 | NavitGraphics.callback_handler.sendMessage(msg);
|
10612 | }
|
10631 | }
|
10613 |
|
10632 |
|
10614 | private static void set_poi_layers()
|
10633 | private static void set_poi_layers()
|
10615 | {
|
10634 | {
|
10616 | int on_ = 59;
|
10635 | int on_ = 59;
|
… | |
… | |
11753 | // ---------- set traffic factor for road speeds ------------
|
11772 | // ---------- set traffic factor for road speeds ------------
|
11754 |
|
11773 |
|
11755 | // ------- PREF_show_poi_on_map ---------------------------------
|
11774 | // ------- PREF_show_poi_on_map ---------------------------------
|
11756 | set_poi_layers();
|
11775 | set_poi_layers();
|
11757 | // ------- PREF_show_poi_on_map ---------------------------------
|
11776 | // ------- PREF_show_poi_on_map ---------------------------------
|
|
|
11777 |
|
|
|
11778 | set_TurnRestrictions_layers();
|
11758 |
|
11779 |
|
11759 | // set vars for mapdir change (only really takes effect after restart!)
|
11780 | // set vars for mapdir change (only really takes effect after restart!)
|
11760 | getPrefs_mapdir();
|
11781 | getPrefs_mapdir();
|
11761 |
|
11782 |
|
11762 | if (need_recalc_route)
|
11783 | if (need_recalc_route)
|
… | |
… | |
13699 | {
|
13720 | {
|
13700 | final Thread write_route_to_gpx_file_001 = new Thread()
|
13721 | final Thread write_route_to_gpx_file_001 = new Thread()
|
13701 | {
|
13722 | {
|
13702 | int wait = 1;
|
13723 | int wait = 1;
|
13703 | int count = 0;
|
13724 | int count = 0;
|
13704 | int max_count = 60;
|
13725 | int max_count = 300; // wait 2 minutes for route to be calculated
|
13705 |
|
13726 |
|
13706 | @Override
|
13727 | @Override
|
13707 | public void run()
|
13728 | public void run()
|
13708 | {
|
13729 | {
|
13709 | while (wait == 1)
|
13730 | while (wait == 1)
|
… | |
… | |
14826 | }
|
14847 | }
|
14827 | }
|
14848 | }
|
14828 |
|
14849 |
|
14829 | public static void route_wrapper(String addr, float lat_start, float lon_start, boolean start_coords_valid, double lat_end, double lon_end, boolean remember_dest)
|
14850 | public static void route_wrapper(String addr, float lat_start, float lon_start, boolean start_coords_valid, double lat_end, double lon_end, boolean remember_dest)
|
14830 | {
|
14851 | {
|
|
|
14852 | global_last_destination_name = NavitSpeech2.filter_out_special_chars_for_dest_string(addr);
|
|
|
14853 | // System.out.println("HOME002:" + addr + " = " + global_last_destination_name);
|
|
|
14854 |
|
14831 | if (p.PREF_routing_engine == 1)
|
14855 | if (p.PREF_routing_engine == 1)
|
14832 | {
|
14856 | {
|
14833 | route_online_OSRM(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
|
14857 | route_online_OSRM(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
|
14834 | }
|
14858 | }
|
14835 | else if (p.PREF_routing_engine == 0)
|
14859 | else if (p.PREF_routing_engine == 0)
|
… | |
… | |
15457 | }
|
15481 | }
|
15458 |
|
15482 |
|
15459 | return ret;
|
15483 | return ret;
|
15460 | }
|
15484 | }
|
15461 |
|
15485 |
|
|
|
15486 | static private Cursor c = null;
|
|
|
15487 | static private Uri uri = CR_CONTENT_URI;
|
|
|
15488 |
|
15462 | static private int get_reglevel()
|
15489 | static private int get_reglevel()
|
15463 | {
|
15490 | {
|
15464 | int ret = 0;
|
15491 | int ret = 0;
|
15465 |
|
15492 |
|
15466 | try
|
15493 | try
|
15467 | {
|
15494 | {
|
15468 | Uri uri = CR_CONTENT_URI;
|
15495 | c = null;
|
|
|
15496 | Thread thread = new Thread()
|
|
|
15497 | {
|
|
|
15498 | public void run()
|
|
|
15499 | {
|
|
|
15500 | try
|
|
|
15501 | {
|
15469 | Cursor c = content_resolver.query(uri, null, null, null, null);
|
15502 | c = content_resolver.query(uri, null, null, null, null);
|
|
|
15503 | }
|
|
|
15504 | catch (Exception c1)
|
|
|
15505 | {
|
|
|
15506 | System.out.println("CPVD:reg(e002)=" + c1.getMessage());
|
|
|
15507 | }
|
|
|
15508 | }
|
|
|
15509 | };
|
|
|
15510 | thread.start();
|
|
|
15511 | try
|
|
|
15512 | {
|
|
|
15513 | thread.join();
|
|
|
15514 | }
|
|
|
15515 | catch (InterruptedException e)
|
|
|
15516 | {
|
|
|
15517 | }
|
15470 |
|
15518 |
|
15471 | if (c == null)
|
15519 | if (c == null)
|
15472 | {
|
15520 | {
|
15473 | System.out.println("CPVD:Cursor c == null.");
|
15521 | System.out.println("CPVD:Cursor c == null.");
|
15474 | System.out.println("CPVD:reg(0)=" + ret);
|
15522 | System.out.println("CPVD:reg(0)=" + ret);
|
… | |
… | |
15495 | c.close();
|
15543 | c.close();
|
15496 | }
|
15544 | }
|
15497 | catch (Exception e)
|
15545 | catch (Exception e)
|
15498 | {
|
15546 | {
|
15499 | e.printStackTrace();
|
15547 | e.printStackTrace();
|
|
|
15548 | System.out.println("CPVD:reg(e001)=" + e.getMessage());
|
15500 | }
|
15549 | }
|
15501 |
|
15550 |
|
15502 | System.out.println("CPVD:reg(2)=" + ret);
|
15551 | System.out.println("CPVD:reg(2)=" + ret);
|
15503 | return ret;
|
15552 | return ret;
|
15504 | }
|
15553 | }
|