… | |
… | |
114 |
|
114 |
|
115 | import de.oberoner.gpx2navit_txt.MainFrame;
|
115 | import de.oberoner.gpx2navit_txt.MainFrame;
|
116 |
|
116 |
|
117 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
117 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
118 | {
|
118 | {
|
119 | public static final String VERSION_TEXT_LONG_INC_REV = "1851";
|
119 | public static final String VERSION_TEXT_LONG_INC_REV = "1937";
|
120 | public static String NavitAppVersion = "0";
|
120 | public static String NavitAppVersion = "0";
|
121 | public static String NavitAppVersion_prev = "-1";
|
121 | public static String NavitAppVersion_prev = "-1";
|
122 | public static String NavitAppVersion_string = "0";
|
122 | public static String NavitAppVersion_string = "0";
|
123 | public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
|
123 | public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
|
124 |
|
124 |
|
125 | // define graphics here (this is bad, please fix me!)
|
125 | // define graphics here (this is bad, please fix me!)
|
126 | public static NavitGraphics N_NavitGraphics = null;
|
126 | public static NavitGraphics N_NavitGraphics = null;
|
127 |
|
127 |
|
128 | AlertDialog.Builder generic_alert_box = null;
|
128 | static AlertDialog.Builder generic_alert_box = null;
|
129 |
|
129 |
|
130 | private Boolean xmlconfig_unpack_file = true;
|
130 | private Boolean xmlconfig_unpack_file = true;
|
131 | private Boolean write_new_version_file = true;
|
131 | private Boolean write_new_version_file = true;
|
132 | final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
|
132 | final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
|
133 | final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
|
133 | final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
|
… | |
… | |
137 | private int startup_status = Navit_Status_NORMAL_STARTUP;
|
137 | private int startup_status = Navit_Status_NORMAL_STARTUP;
|
138 | final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
|
138 | final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
|
139 | static Boolean unsupported = false;
|
139 | static Boolean unsupported = false;
|
140 | static Boolean Navit_maps_loaded = false;
|
140 | static Boolean Navit_maps_loaded = false;
|
141 | final static int Navit_MAX_RECENT_DESTINATIONS = 50;
|
141 | final static int Navit_MAX_RECENT_DESTINATIONS = 50;
|
|
|
142 | static String debug_item_dump = "";
|
142 |
|
143 |
|
143 | // for future use ...
|
144 | // for future use ...
|
144 | // public static String NavitDataDirectory = "/sdcard/";
|
145 | // public static String NavitDataDirectory = "/sdcard/";
|
145 | public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
|
146 | public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
|
146 |
|
147 |
|
… | |
… | |
407 | static int PREF_mapcache = 10 * 1024; // in kbytes
|
408 | static int PREF_mapcache = 10 * 1024; // in kbytes
|
408 | static String PREF_navit_lang;
|
409 | static String PREF_navit_lang;
|
409 | static int PREF_drawatorder = 1;
|
410 | static int PREF_drawatorder = 1;
|
410 | static String PREF_streetsearch_r = "1"; // street search radius factor (multiplier)
|
411 | static String PREF_streetsearch_r = "1"; // street search radius factor (multiplier)
|
411 | static String PREF_route_style = "1"; // 1 -> under green 2 -> on top blue
|
412 | static String PREF_route_style = "1"; // 1 -> under green 2 -> on top blue
|
|
|
413 | static Boolean PREF_item_dump = false;
|
412 |
|
414 |
|
413 | static Resources res_ = null;
|
415 | static Resources res_ = null;
|
414 |
|
416 |
|
415 | public static String get_text(String in)
|
417 | public static String get_text(String in)
|
416 | {
|
418 | {
|
… | |
… | |
527 | super.onCreate(savedInstanceState);
|
529 | super.onCreate(savedInstanceState);
|
528 |
|
530 |
|
529 | getBaseContext_ = getBaseContext();
|
531 | getBaseContext_ = getBaseContext();
|
530 |
|
532 |
|
531 | res_ = getResources();
|
533 | res_ = getResources();
|
|
|
534 | int ii = 0;
|
|
|
535 | NavitGraphics.dl_thread_cur = 0;
|
|
|
536 | for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
|
|
|
537 | {
|
|
|
538 | NavitGraphics.dl_thread[ii] = null;
|
|
|
539 | }
|
532 |
|
540 |
|
533 | String font_file_name = "Roboto-Regular.ttf"; // "LiberationSans-Regular.ttf";
|
541 | String font_file_name = "Roboto-Regular.ttf"; // "LiberationSans-Regular.ttf";
|
534 | NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), font_file_name);
|
542 | NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), font_file_name);
|
|
|
543 | // System.out.println("NavitStreetnameFont" + NavitStreetnameFont);
|
535 |
|
544 |
|
536 | Navit_maps_loaded = false;
|
545 | Navit_maps_loaded = false;
|
537 |
|
546 |
|
538 | // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
|
547 | // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
|
539 | Navit.startup_intent = this.getIntent();
|
548 | Navit.startup_intent = this.getIntent();
|
… | |
… | |
1076 | System.gc();
|
1085 | System.gc();
|
1077 | System.gc();
|
1086 | System.gc();
|
1078 | Navit.bigmap_bitmap = BitmapFactory.decodeResource(getResources(), R.raw.bigmap_colors_zanavi2);
|
1087 | Navit.bigmap_bitmap = BitmapFactory.decodeResource(getResources(), R.raw.bigmap_colors_zanavi2);
|
1079 | // Navit.bigmap_bitmap.setDensity(120); // set our dpi!!
|
1088 | // Navit.bigmap_bitmap.setDensity(120); // set our dpi!!
|
1080 |
|
1089 |
|
|
|
1090 | try
|
|
|
1091 | {
|
1081 | ActivityResults = new NavitActivityResult[16];
|
1092 | ActivityResults = new NavitActivityResult[16];
|
1082 | setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
1093 | setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
|
|
1094 | }
|
|
|
1095 | catch (Exception e)
|
|
|
1096 | {
|
|
|
1097 | e.printStackTrace();
|
|
|
1098 | }
|
|
|
1099 |
|
|
|
1100 | try
|
|
|
1101 | {
|
1083 | PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
1102 | PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
1084 | // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1103 | // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1085 | wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1104 | wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
|
|
1105 | }
|
|
|
1106 | catch (Exception e)
|
|
|
1107 | {
|
|
|
1108 | e.printStackTrace();
|
|
|
1109 | wl = null;
|
|
|
1110 | }
|
|
|
1111 |
|
|
|
1112 | try
|
|
|
1113 | {
|
|
|
1114 | if (wl != null)
|
|
|
1115 | {
|
|
|
1116 | wl.acquire();
|
|
|
1117 | }
|
|
|
1118 | }
|
|
|
1119 | catch (Exception e)
|
|
|
1120 | {
|
|
|
1121 | e.printStackTrace();
|
|
|
1122 | }
|
1086 |
|
1123 |
|
1087 | Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
|
1124 | Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
|
1088 | if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
|
1125 | if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
|
1089 | {
|
1126 | {
|
1090 | Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
|
1127 | Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
|
… | |
… | |
1445 | super.onResume();
|
1482 | super.onResume();
|
1446 |
|
1483 |
|
1447 | Log.e("Navit", "OnResume");
|
1484 | Log.e("Navit", "OnResume");
|
1448 | //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
1485 | //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
1449 | NavitActivity(1);
|
1486 | NavitActivity(1);
|
|
|
1487 |
|
|
|
1488 | try
|
|
|
1489 | {
|
|
|
1490 | if (wl != null)
|
|
|
1491 | {
|
|
|
1492 | wl.acquire();
|
|
|
1493 | }
|
|
|
1494 | }
|
|
|
1495 | catch (Exception e)
|
|
|
1496 | {
|
|
|
1497 | e.printStackTrace();
|
|
|
1498 | }
|
1450 |
|
1499 |
|
1451 | //Intent caller = this.getIntent();
|
1500 | //Intent caller = this.getIntent();
|
1452 | //System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
|
1501 | //System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
|
1453 | //System.out.println("C=" + caller.getComponent().flattenToString());
|
1502 | //System.out.println("C=" + caller.getComponent().flattenToString());
|
1454 |
|
1503 |
|
… | |
… | |
1994 |
|
2043 |
|
1995 | Log.e("Navit", "OnPause");
|
2044 | Log.e("Navit", "OnPause");
|
1996 | NavitActivity(-1);
|
2045 | NavitActivity(-1);
|
1997 |
|
2046 |
|
1998 | Navit.show_mem_used();
|
2047 | Navit.show_mem_used();
|
|
|
2048 |
|
|
|
2049 | try
|
|
|
2050 | {
|
|
|
2051 | if (wl != null)
|
|
|
2052 | {
|
|
|
2053 | wl.release();
|
|
|
2054 | }
|
|
|
2055 | }
|
|
|
2056 | catch (Exception e)
|
|
|
2057 | {
|
|
|
2058 | e.printStackTrace();
|
|
|
2059 | }
|
|
|
2060 |
|
1999 | }
|
2061 | }
|
2000 |
|
2062 |
|
2001 | @Override
|
2063 | @Override
|
2002 | public void onStop()
|
2064 | public void onStop()
|
2003 | {
|
2065 | {
|
… | |
… | |
3127 | String dest_name = "manual coordinates";
|
3189 | String dest_name = "manual coordinates";
|
3128 |
|
3190 |
|
3129 | // ok now set target
|
3191 | // ok now set target
|
3130 | try
|
3192 | try
|
3131 | {
|
3193 | {
|
3132 | dest_name = NavitGraphics.CallbackGeoCalc(6, lat, lon);
|
3194 | dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon);
|
3133 | if ((dest_name.equals(" ")) || (dest_name == null))
|
3195 | if ((dest_name.equals(" ")) || (dest_name == null))
|
3134 | {
|
3196 | {
|
3135 | dest_name = "manual coordinates";
|
3197 | dest_name = "manual coordinates";
|
3136 | }
|
3198 | }
|
3137 | Navit.remember_destination(dest_name, lat, lon);
|
3199 | Navit.remember_destination(dest_name, lat, lon);
|
… | |
… | |
3969 | return null;
|
4031 | return null;
|
3970 | }
|
4032 | }
|
3971 |
|
4033 |
|
3972 | public void disableSuspend()
|
4034 | public void disableSuspend()
|
3973 | {
|
4035 | {
|
3974 | wl.acquire();
|
4036 | // wl.acquire();
|
3975 | wl.release();
|
4037 | // wl.release();
|
3976 |
|
|
|
3977 | }
|
4038 | }
|
3978 |
|
4039 |
|
3979 | public void exit2()
|
4040 | public void exit2()
|
3980 | {
|
4041 | {
|
3981 | System.out.println("in exit2");
|
4042 | System.out.println("in exit2");
|
… | |
… | |
4195 | PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
|
4256 | PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
|
4196 | PREF_use_custom_font = prefs.getBoolean("use_custom_font", true);
|
4257 | PREF_use_custom_font = prefs.getBoolean("use_custom_font", true);
|
4197 | PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
|
4258 | PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
|
4198 | PREF_streetsearch_r = prefs.getString("streetsearch_r", "2");
|
4259 | PREF_streetsearch_r = prefs.getString("streetsearch_r", "2");
|
4199 | PREF_route_style = prefs.getString("route_style", "2");
|
4260 | PREF_route_style = prefs.getString("route_style", "2");
|
|
|
4261 | PREF_item_dump = prefs.getBoolean("item_dump", false);
|
4200 |
|
4262 |
|
4201 | try
|
4263 | try
|
4202 | {
|
4264 | {
|
4203 | PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
|
4265 | PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
|
4204 | }
|
4266 | }
|