/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/Navit.java
ZANavi

Contents of /navit/navit/android/src/com/zoffcc/applications/zanavi/Navit.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (show annotations) (download)
Wed Jun 22 07:33:35 2016 UTC (7 years, 9 months ago) by zoff99
File size: 475016 byte(s)
v2.0.51
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2015 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2008 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38
39 package com.zoffcc.applications.zanavi;
40
41 import java.io.File;
42 import java.io.FileInputStream;
43 import java.io.FileNotFoundException;
44 import java.io.FileOutputStream;
45 import java.io.IOException;
46 import java.io.InputStream;
47 import java.io.InputStreamReader;
48 import java.io.ObjectInputStream;
49 import java.io.ObjectOutputStream;
50 import java.io.OutputStream;
51 import java.io.OutputStreamWriter;
52 import java.io.PrintWriter;
53 import java.io.Reader;
54 import java.io.Serializable;
55 import java.io.StringWriter;
56 import java.net.URL;
57 import java.net.URLDecoder;
58 import java.nio.channels.FileChannel;
59 import java.text.DecimalFormat;
60 import java.text.SimpleDateFormat;
61 import java.util.ArrayList;
62 import java.util.Calendar;
63 import java.util.Collections;
64 import java.util.Date;
65 import java.util.HashSet;
66 import java.util.Iterator;
67 import java.util.List;
68 import java.util.Locale;
69 import java.util.Map;
70 import java.util.Random;
71 import java.util.Set;
72 import java.util.TimeZone;
73 import java.util.concurrent.LinkedBlockingQueue;
74
75 import org.json.JSONArray;
76 import org.json.JSONObject;
77 import org.xml.sax.InputSource;
78
79 import android.annotation.SuppressLint;
80 import android.annotation.TargetApi;
81 import android.app.Activity;
82 import android.app.AlertDialog;
83 import android.app.Dialog;
84 import android.app.Notification;
85 import android.app.NotificationManager;
86 import android.app.PendingIntent;
87 import android.app.ProgressDialog;
88 import android.app.backup.BackupManager;
89 import android.content.ActivityNotFoundException;
90 import android.content.ComponentName;
91 import android.content.ContentResolver;
92 import android.content.Context;
93 import android.content.DialogInterface;
94 import android.content.DialogInterface.OnCancelListener;
95 import android.content.Intent;
96 import android.content.ServiceConnection;
97 import android.content.SharedPreferences;
98 import android.content.pm.PackageInfo;
99 import android.content.pm.PackageManager.NameNotFoundException;
100 import android.content.res.AssetManager;
101 import android.content.res.Configuration;
102 import android.content.res.Resources;
103 import android.database.Cursor;
104 import android.graphics.Bitmap;
105 import android.graphics.BitmapFactory;
106 import android.graphics.Color;
107 import android.graphics.Paint;
108 import android.graphics.Rect;
109 import android.graphics.RectF;
110 import android.graphics.Typeface;
111 import android.hardware.Sensor;
112 import android.hardware.SensorEvent;
113 import android.hardware.SensorEventListener;
114 import android.hardware.SensorManager;
115 import android.location.Address;
116 import android.location.Geocoder;
117 import android.location.GpsStatus;
118 import android.location.Location;
119 import android.location.LocationManager;
120 import android.media.AudioManager;
121 import android.media.AudioManager.OnAudioFocusChangeListener;
122 import android.media.ToneGenerator;
123 import android.net.Uri;
124 import android.os.AsyncTask;
125 import android.os.Build;
126 import android.os.Bundle;
127 import android.os.Debug;
128 import android.os.Environment;
129 import android.os.Handler;
130 import android.os.IBinder;
131 import android.os.Looper;
132 import android.os.Message;
133 import android.os.PowerManager;
134 import android.os.RemoteException;
135 import android.os.SystemClock;
136 import android.preference.PreferenceManager;
137 import android.speech.tts.TextToSpeech;
138 import android.support.v4.app.FragmentManager;
139 import android.support.v4.app.FragmentTransaction;
140 import android.support.v7.app.ActionBar;
141 import android.support.v7.app.ActionBarActivity;
142 import android.support.v7.widget.Toolbar;
143 import android.text.Html;
144 import android.text.SpannableString;
145 import android.text.method.LinkMovementMethod;
146 import android.text.util.Linkify;
147 import android.util.DisplayMetrics;
148 import android.util.Log;
149 import android.util.TypedValue;
150 import android.view.Display;
151 import android.view.GestureDetector;
152 import android.view.GestureDetector.SimpleOnGestureListener;
153 import android.view.Gravity;
154 import android.view.KeyEvent;
155 import android.view.Menu;
156 import android.view.MenuItem;
157 import android.view.MotionEvent;
158 import android.view.View;
159 import android.view.ViewConfiguration;
160 import android.view.ViewTreeObserver;
161 import android.view.ViewTreeObserver.OnGlobalLayoutListener;
162 import android.view.Window;
163 import android.view.WindowManager;
164 import android.view.animation.Animation;
165 import android.view.animation.Animation.AnimationListener;
166 import android.view.animation.TranslateAnimation;
167 import android.view.inputmethod.InputMethodManager;
168 import android.widget.Button;
169 import android.widget.FrameLayout;
170 import android.widget.ImageView;
171 import android.widget.LinearLayout;
172 import android.widget.RelativeLayout;
173 import android.widget.TextView;
174 import android.widget.Toast;
175 import bpi.sdbm.illuminance.SolarPosition;
176
177 import com.lamerman.FileDialog;
178 import com.lamerman.SelectionMode;
179 import com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator;
180 import com.luckycatlabs.sunrisesunset.calculator.SolarEventCalculator;
181 import com.luckycatlabs.sunrisesunset.dto.Location2;
182 import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
183 import com.zoffcc.applications.zanavi.NavitOSDJava.drawOSDThread;
184 import com.zoffcc.applications.zanavi.NavitVehicle.location_coords;
185 import com.zoffcc.applications.zanavi.ZANaviListViewAdapter.ListViewItem;
186 import com.zoffcc.applications.zanavi_msg.ZanaviCloudApi;
187
188 import de.oberoner.gpx2navit_txt.MainFrame;
189
190 public class Navit extends ActionBarActivity implements Handler.Callback, SensorEventListener
191 {
192 public static final String VERSION_TEXT_LONG_INC_REV = "3891";
193 public static String NavitAppVersion = "0";
194 public static String NavitAppVersion_prev = "-1";
195 public static String NavitAppVersion_string = "0";
196 public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
197 public static boolean has_hw_menu_button = false;
198 static int NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR = 400;
199 static int actionbar_item_width = 100;
200 static int actionbar_items_will_fit = 2;
201 static boolean actionbar_all_items_will_fit = false;
202 static boolean actionabar_download_icon_visible = false;
203 static boolean is_navigating = false;
204 static boolean is_paused = true;
205
206 static int api_version_int = 6;
207
208 static boolean PAINT_OLD_API = true;
209
210 static long SHOWCASEVIEW_ID_001 = 93457181726L;
211
212 //static final int DEFAULT_THEME_DARK = android.R.style.Theme_WithActionBar;
213 //static final int DEFAULT_THEME_LIGHT = android.R.style.Theme_Material_Light;
214 static final int DEFAULT_THEME_OLD_LIGHT = R.style.CustomActionBarThemeLight;
215 static final int DEFAULT_THEME_OLD_DARK = R.style.CustomActionBarTheme;
216
217 static final int DEFAULT_THEME_OLD_LIGHT_M = R.style.CustomActionBarThemeLightM;
218 static final int DEFAULT_THEME_OLD_DARK_M = R.style.CustomActionBarThemeM;
219
220 // GLSurfaceView glSurfaceView;
221
222 static int OSD_blueish_bg_color = 0;
223
224 // ----------------- DEBUG ----------------
225 // ----------------- DEBUG ----------------
226 // ----------------- DEBUG ----------------
227 static final boolean METHOD_DEBUG = false; // for debugging only, set this to "false" on release builds!!
228 static final boolean DEBUG_DRAW_VEHICLE = true; // if "false" then dont draw green vehicle, set this to "true" on release builds!!
229 static final boolean NAVIT_ALWAYS_UNPACK_XMLFILE = false; // always unpacks the navit.xml file, set this to "false" on release builds!!
230 static final boolean NAVIT_DEBUG_TEXT_VIEW = false; // show overlay with debug messages, set this to "false" on release builds!!
231 static final boolean GFX_OVERSPILL = true; // make gfx canvas bigger for rotation and zoom smoothness
232 // ----------------- DEBUG ----------------
233 // ----------------- DEBUG ----------------
234 // ----------------- DEBUG ----------------
235
236 // ----------------------------------------
237 // ----------------------------------------
238 static final boolean FDBL = false;
239 static final int CIDEBUG = 0;
240 static boolean CIRUN = false;
241 // ----------------------------------------
242 // ----------------------------------------
243
244 static final float OVERSPILL_FACTOR = 1.4f; // 20% percent on each side
245
246 // ------------------ BitCoin Addr --------
247 // ------------------ BitCoin Addr --------
248 // ------------------ BitCoin Addr --------
249 final static String BITCOIN_DONATE_ADDR = "1ZANav18WY8ytM7bhnAEBS3bdrTohsD9p";
250 // ------------------ BitCoin Addr --------
251 // ------------------ BitCoin Addr --------
252 // ------------------ BitCoin Addr --------
253
254 private static ZanaviCloudApi plugin_api = null;
255 static final int PLUGIN_MSG_ID = 1;
256 static final int PLUGIN_MSG_CAT_zanavi_version = 1;
257 static final int PLUGIN_MSG_CAT_installed_maps = 2;
258 static final int PLUGIN_MSG_CAT_3d_mode = 3;
259
260 static ZANaviPrefs p = new ZANaviPrefs();
261 static ZANaviPrefs p_old = new ZANaviPrefs();
262 static final int STREET_SEARCH_STRINGS_SAVE_COUNT = 10;
263 static boolean search_ready = false;
264 static boolean search_list_ready = false;
265
266 // static AnimationDrawable mFrameAnimation;
267 static Menu cur_menu = null;
268
269 static long NAVIT_START_INTENT_DRIVE_HOME = 1L;
270
271 static final int NAVIT_BACKBUTTON_TO_EXIT_TIME = 2000; // 2 secs.
272
273 static int NavitOverflowMenuItemID = -1;
274
275 static ContentResolver content_resolver = null;
276 public static final String CR_AUTHORITY = "com.zoffcc.applications.zanavi_udonate.provider";
277 public static final Uri CR_CONTENT_URI = Uri.parse("content://" + CR_AUTHORITY + "/" + "table1");
278
279 public static Intent ZANaviMapDownloaderServiceIntent = null;
280
281 static float last_y_bottom_bar_touch = 0;
282 static float cur_y_margin_bottom_bar_touch = 0;
283 static int map_view_height = 100;
284 static float bottom_y_margin_bottom_bar_touch = 0;
285 static int actionBarHeight = 0;
286 static int bottom_bar_px = 80;
287 static int bottom_bar_slider_shadow_px = 4;
288 static GestureDetector mGestureDetector = null;
289 static int swipeMaxOffPath = 20;
290 static ZANaviRoadbookFragment road_book = null;
291 static FragmentManager fragmentManager = null;
292 static ImageView push_pin_view = null;
293 static List<ListViewItem> road_book_items = null;
294
295 TextToSpeech mTts = null;
296
297 static ToneGenerator toneG = null;
298 static boolean toneG_heared = false;
299
300 public static int Global_Init_Finished = 0; // 0 -> no init
301 // 1 -> all C structures are ready for use
302 public static int Global_Location_update_not_allowed = 0; // 0 -> send location update to C functions
303 // 1 -> DO NOT send location update to C functions, it may crash in this phase
304
305 //static BackupManager backupManager = null;
306 static Object backupManager = null;
307
308 // AlertDialog dialog_info_popup = null;
309 Dialog dialog_info_popup = null;
310 int info_popup_seen_count = 0;
311 final int info_popup_seen_count_max = 2; // must look at the info pop 2 times
312 boolean info_popup_seen_count_end = false;
313
314 static Navit Global_Navit_Object = null;
315 static AssetManager asset_mgr = null;
316
317 static boolean Navit_doubleBackToExitPressedOnce = false;
318
319 // define graphics here (this is bad, please fix me!)
320 public static NavitGraphics N_NavitGraphics = null;
321
322 public static int usedMegs_old = -1;
323 public static String usedMegs_str_old = "";
324 public static int Routgraph_enabled = 0;
325
326 // -------- SUN / MOON ----------
327 long sun_moon__mLastCalcSunMillis = -1L;
328 public double azmiuth_cache = -1;
329 public double zenith_cache = -1;
330 public static String sunrise_cache = "";
331 public static boolean is_night = false;
332 public static boolean is_twilight = false;
333 public static String sunset_cache = "";
334 public static double elevation = 0;
335 public double moon_azimuth_cache = -1;
336 public double moon_evelation_cache = -1;
337 Boolean sun_moon__must_calc_new = true;
338 SunriseSunsetCalculator sun_moon__calc = null;
339 Calendar sun_moon__cx = null;
340 SolarPosition.SunCoordinates sun_moon__sc = null;
341 public static boolean calc_sun_enabled = true;
342 // -------- SUN / MOON ----------
343
344 public static CWorkerThread cwthr = null;
345 public static NavitGraphics NG__map_main = null;
346 public static NavitGraphics NG__vehicle = null;
347 public static NavitVehicle NV = null;
348 public static NavitSpeech2 NSp = null;
349 public static drawOSDThread draw_osd_thread = null;
350
351 public static boolean use_index_search = false;
352 public static boolean index_search_realtime = false;
353
354 static AlertDialog.Builder generic_alert_box = null;
355
356 private Boolean xmlconfig_unpack_file = true;
357 private Boolean write_new_version_file = true;
358 final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
359 final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
360 final static int Navit_Status_NORMAL_STARTUP = 0;
361 static Boolean Navit_DonateVersion_Installed = false;
362 static Boolean Navit_Plugin_001_Installed = false;
363 static Boolean Navit_index_on_but_no_idx_files = false;
364 static Boolean Navit_maps_too_old = false;
365 static Boolean Navit_Largemap_DonateVersion_Installed = false;
366 private int startup_status = Navit_Status_NORMAL_STARTUP;
367 final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
368 static Boolean unsupported = false;
369 static Boolean Navit_maps_loaded = false;
370 final static int Navit_MAX_RECENT_DESTINATIONS = 50;
371 static String debug_item_dump = "";
372 static String global_last_destination_name = "";
373
374 // for future use ...
375 // public static String NavitDataDirectory = "/sdcard/";
376 public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
377 static File[] NavitDataStorageDirs = null;
378
379 public static int GlobalScaleLevel = 0;
380
381 public class CopyFiles
382 {
383 public void copyFiles(File sourceLocation, File targetLocation) throws IOException
384 {
385 if (sourceLocation.isDirectory())
386 {
387 if (!targetLocation.exists())
388 {
389 targetLocation.mkdir();
390 }
391 File[] files = sourceLocation.listFiles();
392 for (File file : files)
393 {
394 InputStream in = new FileInputStream(file);
395 OutputStream out = new FileOutputStream(targetLocation + "/" + file.getName());
396
397 // Copy the bits from input stream to output stream
398 byte[] buf = new byte[1024];
399 int len;
400 while ((len = in.read(buf)) > 0)
401 {
402 out.write(buf, 0, len);
403 }
404 in.close();
405 out.close();
406 }
407
408 }
409 }
410 }
411
412 private static void copyFile(File sourceFile, File destFile) throws IOException
413 {
414 if (!sourceFile.exists())
415 {
416 return;
417 }
418 if (!destFile.exists())
419 {
420 destFile.createNewFile();
421 }
422 FileChannel source = null;
423 FileChannel destination = null;
424 source = new FileInputStream(sourceFile).getChannel();
425 destination = new FileOutputStream(destFile).getChannel();
426 if (destination != null && source != null)
427 {
428 destination.transferFrom(source, 0, source.size());
429 }
430 if (source != null)
431 {
432 source.close();
433 }
434 if (destination != null)
435 {
436 destination.close();
437 }
438
439 }
440
441 public static final class Navit_Address_Result_Struct implements Comparable<Navit_Address_Result_Struct>
442 {
443 String result_type; // TWN,STR,SHN
444 String item_id; // H<ddddd>L<ddddd> -> item.id_hi item.id_lo
445 float lat;
446 float lon;
447 String addr;
448
449 // function to sort address result list
450 public int compareTo(Navit_Address_Result_Struct comp)
451 {
452 return this.addr.toLowerCase().compareTo(comp.addr.toLowerCase());
453 }
454 }
455
456 public static final class Navit_Point_on_Map implements Serializable
457 {
458 /**
459 * struct for a point on the map
460 */
461 private static final long serialVersionUID = 6899215049749155051L;
462 String point_name = "";
463 String addon = null; // null -> normal, "1" -> home location
464 float lat = 0.0f;
465 float lon = 0.0f;
466 }
467
468 static ArrayList<Navit_Point_on_Map> map_points;
469
470 public static Set<String> Navit_Address_Result_double_index = new HashSet<String>();
471
472 public NavitAndroidOverlay NavitAOverlay2;
473 public static NavitAndroidOverlay NavitAOverlay2_s;
474
475 public static final class Navit_OSD_compass
476 {
477 Boolean angle_north_valid = false;
478 float angle_north = 0.0f;
479 Boolean angle_target_valid = false;
480 float angle_target = 0.0f;
481 Boolean direct_distance_to_target_valid = false;
482 String direct_distance_to_target = "";
483 }
484
485 public static final class Navit_OSD_route_001
486 {
487 Boolean driving_distance_to_target_valid = false;
488 String driving_distance_to_target = "";
489 Boolean arriving_time_valid = false;
490 String arriving_time = "";
491 Boolean arriving_secs_to_dest_valid = false;
492 String arriving_secs_to_dest = "";
493 }
494
495 public static final class Navit_OSD_route_nextturn
496 {
497 Boolean nextturn_image_filename_valid = false;
498 String nextturn_image_filename = "";
499 Boolean nextturn_image_valid = false;
500 Bitmap nextturn_image = null;
501 Boolean nextturn_distance_valid = false;
502 String nextturn_distance = "";
503 String nextturn_streetname = "";
504 String nextturn_streetname_systematic = "";
505 }
506
507 public static final class Navit_OSD_scale
508 {
509 Boolean scale_valid = false;
510 String scale_text = "";
511 int base = 0;
512 int var = 0;
513 }
514
515 public static Navit_OSD_compass OSD_compass = new Navit_OSD_compass();
516 public static Navit_OSD_route_001 OSD_route_001 = new Navit_OSD_route_001();
517 public static Navit_OSD_route_nextturn OSD_nextturn = new Navit_OSD_route_nextturn();
518 public static Navit_OSD_scale OSD_scale = new Navit_OSD_scale();
519
520 SimGPS Simulate = null;
521 WatchMem watchmem = null;
522
523 public static int sats = 0;
524 public static int satsInFix = 0;
525
526 // -------------- GPS fix and extrapolation vars -------------
527 // -------------- GPS fix and extrapolation vars -------------
528 // -------------- GPS fix and extrapolation vars -------------
529 static Location mLastLocation = null;
530 static long mLastLocationMillis = -1;
531 static boolean isGPSFix = false;
532 static int pos_is_underground = 0;
533 static boolean tunnel_extrapolation = false;
534 // -------------- GPS fix and extrapolation vars -------------
535 // -------------- GPS fix and extrapolation vars -------------
536 // -------------- GPS fix and extrapolation vars -------------
537
538 // public static Vibrator vibrator = null;
539
540 public Handler handler;
541 static PowerManager.WakeLock wl;
542 static PowerManager.WakeLock wl_cpu;
543 static PowerManager.WakeLock wl_navigating;
544 private NavitActivityResult ActivityResults[];
545 static AudioManager NavitAudioManager = null;
546 public static InputMethodManager mgr = null;
547 public static DisplayMetrics metrics = null;
548 public static Boolean show_soft_keyboard = false;
549 public static Boolean show_soft_keyboard_now_showing = false;
550 public static long last_pressed_menu_key = 0L;
551 public static long time_pressed_menu_key = 0L;
552 private static Intent startup_intent = null;
553 private static long startup_intent_timestamp = 0L;
554 public static String my_display_density = "mdpi";
555 private boolean searchBoxShown = false;
556 public static final int MAPDOWNLOAD_PRI_DIALOG = 1;
557 public static final int MAPDOWNLOAD_SEC_DIALOG = 2;
558 public static final int SEARCHRESULTS_WAIT_DIALOG = 3;
559 public static final int SEARCHRESULTS_WAIT_DIALOG_OFFLINE = 4;
560 public static final int ADDRESS_RESULTS_DIALOG_MAX = 10;
561 public ProgressDialog mapdownloader_dialog_pri = null;
562 public ProgressDialog mapdownloader_dialog_sec = null;
563 public ProgressDialog search_results_wait = null;
564 public ProgressDialog search_results_wait_offline = null;
565 public static Handler Navit_progress_h = null;
566 public static NavitMapDownloader mapdownloader_pri = null;
567 public static NavitMapDownloader mapdownloader_sec = null;
568 public static final int NavitDownloaderPriSelectMap_id = 967;
569 public static final int NavitDownloaderSecSelectMap_id = 968;
570 public static final int NavitDeleteSecSelectMap_id = 969;
571 public static final int NavitRecentDest_id = 970;
572 public static final int NavitGeoCoordEnter_id = 971;
573 public static final int NavitGPXConvChooser_id = 972;
574 public static final int NavitSendFeedback_id = 973;
575 public static final int NavitReplayFileConvChooser_id = 974;
576 public static int download_map_id = 0;
577 ProgressThread progressThread_pri = null;
578 ProgressThread progressThread_sec = null;
579 public static int search_results_towns = 0;
580 public static int search_results_streets = 0;
581 public static int search_results_streets_hn = 0;
582 public static int search_results_poi = 0;
583 public static Boolean search_hide_duplicates = false;
584 public static Boolean NavitStartupAlreadySearching = false;
585 SearchResultsThread searchresultsThread = null;
586 SearchResultsThread searchresultsThread_offline = null;
587 SearchResultsThreadSpinnerThread spinner_thread = null;
588 SearchResultsThreadSpinnerThread spinner_thread_offline = null;
589 public static Boolean NavitAddressSearchSpinnerActive = false;
590 public static final int MAP_NUM_PRIMARY = 11;
591 public static final int NavitAddressSearch_id_offline = 70;
592 public static final int NavitAddressSearch_id_online = 73;
593 public static final int NavitAddressResultList_id = 71;
594 public static final int NavitAddressSearchCountry_id = 74;
595 public static final int NavitMapPreview_id = 75;
596 public static final int NavitAddressSearch_id_gmaps = 76;
597 public static final int NavitAddressSearch_id_sharedest = 77;
598 public static final int ZANaviVoiceInput_id = 78;
599 public static final int NavitDonateFromSearch_id = 79;
600 public static int NavitSearchresultBarIndex = -1;
601 public static String NavitSearchresultBar_title = "";
602 public static String NavitSearchresultBar_text = "";
603 public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();
604
605 public static Boolean DemoVehicle = false;
606
607 static Typeface NavitStreetnameFont = null;
608
609 public SensorManager sensorManager = null;
610 //private static SensorManager sensorManager_ = null;
611
612 public static Context getBaseContext_ = null;
613 public static GpsStatus gps_st = null;
614
615 static Bitmap lane_none = null;
616 static Bitmap lane_left = null;
617 static Bitmap lane_right = null;
618 static Bitmap lane_merge_to_left = null;
619 static Bitmap lane_merge_to_right = null;
620 static String lane_destination = "";
621 static String lanes_text = "";
622 static String lanes_text1 = "";
623 static String lane_choices = "";
624 static String lane_choices1 = "";
625 static String lane_choices2 = "";
626 static int lanes_num = 0;
627 static int lanes_num_forward = 0;
628 static int lanes_num1 = 0;
629 static int lanes_num_forward1 = 0;
630 static int seg_len = 0;
631 static int cur_max_speed = -1;
632 static int cur_max_speed_corr = -1;
633 static boolean your_are_speeding = false;
634
635 // ------- new features -----------
636 // ------- new features -----------
637 // ------- new features -----------
638 // static boolean new_features = false; // for development ONLY !!
639 // ------- new features -----------
640 // ------- new features -----------
641 // ------- new features -----------
642
643 public static Bitmap long_green_arrow = null;
644 public static Bitmap menu_button = null;
645 public static RectF menu_button_rect = new RectF(-100, 1, 1, 1);
646 public static RectF menu_button_rect_touch = new RectF(-100, 1, 1, 1);
647 public static Bitmap follow_on = null;
648 public static Bitmap follow_off = null;
649 public static Bitmap follow_current = null;
650 public static Bitmap zoomin = null;
651 public static Bitmap zoomout = null;
652 // public static Bitmap bigmap_bitmap = null;
653 public static Bitmap oneway_arrow = null;
654 public static Bitmap oneway_bicycle_arrow = null;
655 public static Bitmap nav_arrow_stopped = null;
656 public static Bitmap nav_arrow_stopped_small = null;
657 public static Bitmap nav_arrow_moving = null;
658 public static Bitmap nav_arrow_moving_grey = null;
659 public static Bitmap nav_arrow_moving_small = null;
660 public static Bitmap nav_arrow_moving_shadow = null;
661 public static Bitmap nav_arrow_moving_shadow_small = null;
662
663 public static String Navit_last_address_search_string = "";
664 public static String Navit_last_address_hn_string = "";
665 public static Boolean Navit_last_address_full_file_search = false;
666 public static String Navit_last_address_search_country_iso2_string = "";
667 public static int Navit_last_address_search_country_flags = 3;
668 public static int Navit_last_address_search_country_id = 0;
669 public static Boolean Navit_last_address_partial_match = true;
670 public static Geocoder Navit_Geocoder = null;
671 public static String UserAgentString = null;
672 public static String UserAgentString_bind = null;
673 public static Boolean first_ever_startup = false;
674
675 public static Boolean Navit_Announcer = true;
676
677 public static final int MAP_NUM_SECONDARY = 12;
678 static String MAP_FILENAME_PATH = "/sdcard/zanavi/maps/";
679 static String MAPMD5_FILENAME_PATH = "/sdcard/zanavi/md5/";
680 static String CFG_FILENAME_PATH = "/sdcard/zanavi/";
681 static String NAVIT_DATA_DIR = "/data/data/com.zoffcc.applications.zanavi"; // later use: Context.getFilesDir().getPath();
682 static String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
683 static String NAVIT_DATA_DEBUG_DIR = CFG_FILENAME_PATH + "../debug/";
684 static String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
685 static String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
686 static final String Navit_DEST_FILENAME = "destinations.dat";
687 static final String Navit_CENTER_FILENAME = "center.txt";
688
689 static boolean need_recalc_route = false;
690
691 static Resources res_ = null;
692 static Window app_window = null;
693
694 public static String get_text(String in)
695 {
696 return NavitTextTranslations.get_text(in);
697 }
698
699 private boolean extractRes(String resname, String result)
700 {
701 int slash = -1;
702 boolean needs_update = false;
703 File resultfile;
704 Resources res = getResources();
705 Log.e("Navit", "Res Obj " + res);
706 Log.e("Navit", "Res Name " + resname);
707 Log.e("Navit", "result " + result);
708 int id = res.getIdentifier(resname, "raw", "com.zoffcc.applications.zanavi");
709 // int id = res.getIdentifier(resname, "raw", getPackageName());
710
711 Log.e("Navit", "Res ID " + id);
712
713 if (id == 0)
714 {
715 return false;
716 }
717
718 while ((slash = result.indexOf("/", slash + 1)) != -1)
719 {
720 if (slash != 0)
721 {
722 Log.e("Navit", "Checking " + result.substring(0, slash));
723 resultfile = new File(result.substring(0, slash));
724 if (!resultfile.exists())
725 {
726 Log.e("Navit", "Creating dir");
727 if (!resultfile.mkdir()) return false;
728 needs_update = true;
729 }
730 }
731 }
732
733 resultfile = new File(result);
734
735 if (!resultfile.exists())
736 {
737 needs_update = true;
738 }
739
740 if (!needs_update)
741 {
742 try
743 {
744 InputStream resourcestream = res.openRawResource(id);
745 FileInputStream resultfilestream = new FileInputStream(resultfile);
746 byte[] resourcebuf = new byte[1024];
747 byte[] resultbuf = new byte[1024];
748 int i = 0;
749
750 while ((i = resourcestream.read(resourcebuf)) != -1)
751 {
752 if (resultfilestream.read(resultbuf) != i)
753 {
754 Log.e("Navit", "Result is too short");
755 needs_update = true;
756 break;
757 }
758
759 for (int j = 0; j < i; j++)
760 {
761 if (resourcebuf[j] != resultbuf[j])
762 {
763 Log.e("Navit", "Result is different");
764 needs_update = true;
765 break;
766 }
767 }
768 if (needs_update) break;
769 }
770
771 if (!needs_update && resultfilestream.read(resultbuf) != -1)
772 {
773 Log.e("Navit", "Result is too long");
774 needs_update = true;
775 }
776
777 if (resultfilestream != null)
778 {
779 resultfilestream.close();
780 }
781 }
782 catch (Exception e)
783 {
784 Log.e("Navit", "Exception " + e.getMessage());
785 return false;
786 }
787 }
788
789 if (needs_update)
790 {
791 Log.e("Navit", "Extracting resource");
792 try
793 {
794 InputStream resourcestream = res.openRawResource(id);
795 FileOutputStream resultfilestream = new FileOutputStream(resultfile);
796 byte[] buf = new byte[1024];
797 int i = 0;
798
799 while ((i = resourcestream.read(buf)) != -1)
800 {
801 resultfilestream.write(buf, 0, i);
802 }
803
804 if (resultfilestream != null)
805 {
806 resultfilestream.close();
807 }
808 }
809 catch (Exception e)
810 {
811 Log.e("Navit", "Exception " + e.getMessage());
812 return false;
813 }
814 }
815 return true;
816 }
817
818 static OnAudioFocusChangeListener focusChangeListener = new OnAudioFocusChangeListener()
819 {
820 public void onAudioFocusChange(int focusChange)
821 {
822 // AudioManager am = Navit.NavitAudioManager;
823 switch (focusChange)
824 {
825
826 case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK):
827 // Lower the volume while ducking.
828 //mediaPlayer.setVolume(0.2f, 0.2f);
829 break;
830 case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT):
831 //pause();
832 break;
833
834 case (AudioManager.AUDIOFOCUS_LOSS):
835 //stop();
836 //ComponentName component = new ComponentName(AudioPlayerActivity.this, MediaControlReceiver.class);
837 //am.unregisterMediaButtonEventReceiver(component);
838 break;
839
840 case (AudioManager.AUDIOFOCUS_GAIN):
841 // Return the volume to normal and resume if paused.
842 //mediaPlayer.setVolume(1f, 1f);
843 //mediaPlayer.start();
844 break;
845 default:
846 break;
847 }
848 }
849 };
850
851 // private boolean checkPlayServices()
852
853 // {
854 // int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
855 //
856 // Log.i("PlayServices", "isGooglePlayServicesAvailable=" + status);
857 //
858 // if (status != ConnectionResult.SUCCESS)
859 // {
860 // if (GooglePlayServicesUtil.isUserRecoverableError(status))
861 // {
862 // Toast.makeText(this, "Recoverable error.", Toast.LENGTH_LONG).show();
863 // // showErrorDialog(status);
864 // }
865 // else
866 // {
867 // Toast.makeText(this, "This device is not supported.", Toast.LENGTH_LONG).show();
868 // }
869 // return false;
870 // }
871 // return true;
872 // }
873
874 // ----------------------------------------------------------------------------------------------------------
875 // thanks to: http://stackoverflow.com/questions/843675/how-do-i-find-out-if-the-gps-of-an-android-device-is-enabled
876 // ----------------------------------------------------------------------------------------------------------
877 private void buildAlertMessageNoGps()
878 {
879 try
880 {
881 AlertDialog.Builder builder = new AlertDialog.Builder(this);
882 builder.setMessage(Navit.get_text("Your GPS is disabled, do you want to enable it?")).setCancelable(false).setPositiveButton(Navit.get_text("Yes"), new DialogInterface.OnClickListener()
883 {
884 public void onClick(final DialogInterface dialog, final int id)
885 {
886 startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
887 }
888 }).setNegativeButton(Navit.get_text("No"), new DialogInterface.OnClickListener()
889 {
890 public void onClick(final DialogInterface dialog, final int id)
891 {
892 dialog.cancel();
893 }
894 });
895 AlertDialog alert = builder.create();
896 alert.show();
897 }
898 catch (Exception e)
899 {
900 e.printStackTrace();
901 }
902 }
903
904 /** Called when the activity is first created. */
905
906 // ----------- remove later -------------
907 // ----------- remove later -------------
908 @SuppressLint("NewApi")
909 // ----------- remove later -------------
910 // ----------- remove later -------------
911 @TargetApi(Build.VERSION_CODES.FROYO)
912 @Override
913 public void onCreate(Bundle savedInstanceState)
914 {
915 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
916
917 // ------- only after API level 9 -------
918 // ------- only after API level 9 -------
919 // try
920 // {
921 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDeath().penaltyLog().build());
922 // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
923 //
924 // StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
925 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskWrites().build());
926 // old = StrictMode.getThreadPolicy();
927 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskReads().build());
928 //
929 // }
930 // catch (NoClassDefFoundError e)
931 // {
932 // }
933 // ------- only after API level 9 -------
934 // ------- only after API level 9 -------
935
936 // Log.e("Navit", "OnCreate");
937
938 // if (checkPlayServices())
939 // {
940 // }
941
942 getPrefs_theme();
943 getPrefs_theme_main();
944 Navit.applySharedTheme(this, p.PREF_current_theme_M);
945
946 super.onCreate(savedInstanceState);
947
948 Global_Navit_Object = this;
949 asset_mgr = getAssets();
950
951 OSD_blueish_bg_color = getResources().getColor(R.color.blueish_bg_color);
952
953 // getBaseContext_ = getBaseContext().getApplicationContext();
954 getBaseContext_ = getBaseContext();
955
956 last_orientation = getResources().getConfiguration().orientation;
957
958 content_resolver = getContentResolver();
959 // get_reglevel();
960
961 Display display_ = getWindowManager().getDefaultDisplay();
962 metrics = new DisplayMetrics();
963 display_.getMetrics(Navit.metrics);
964
965 road_book_items = new ArrayList<ListViewItem>();
966 fragmentManager = getSupportFragmentManager();
967
968 setContentView(R.layout.main_layout);
969 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
970 if (toolbar != null)
971 {
972 try
973 {
974 setSupportActionBar(toolbar);
975 // System.out.println("TTT01:" + toolbar);
976 }
977 catch (NoClassDefFoundError e)
978 {
979 }
980 }
981
982 try
983 {
984 getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
985 getSupportActionBar().setDisplayUseLogoEnabled(false);
986 getSupportActionBar().setIcon(R.drawable.icon);
987 getSupportActionBar().setDisplayShowHomeEnabled(true);
988 getSupportActionBar().setDisplayShowTitleEnabled(false);
989 }
990 catch (NoClassDefFoundError e)
991 {
992 }
993 catch (Exception e)
994 {
995 e.printStackTrace();
996 }
997
998 // ------------ bottom bar slider ----------------
999 // ------------ bottom bar slider ----------------
1000 // ------------ bottom bar slider ----------------
1001
1002 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
1003 // System.out.println("VVV:bottom_bar_height:" + bottom_bar_px);
1004 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
1005 // System.out.println("VVV:bottom_bar_slider_shadow_px:" + bottom_bar_slider_shadow_px);
1006
1007 // final RelativeLayout a = (RelativeLayout) findViewById(R.id.bottom_bar_container);
1008 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
1009 final RelativeLayout.LayoutParams pp22 = (RelativeLayout.LayoutParams) a.getLayoutParams();
1010
1011 // Calculate ToolBar height
1012 try
1013 {
1014 TypedValue tv = new TypedValue();
1015 if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
1016 {
1017 actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
1018 System.out.println("VVV:abh:" + actionBarHeight);
1019 }
1020 else
1021 {
1022 actionBarHeight = NavitGraphics.dp_to_px(144);
1023 }
1024 }
1025 catch (Exception e)
1026 {
1027 actionBarHeight = NavitGraphics.dp_to_px(144);
1028 }
1029
1030 final android.support.v7.widget.Toolbar view_toolbar_top = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
1031 ViewTreeObserver vto = view_toolbar_top.getViewTreeObserver();
1032 vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener()
1033 {
1034 @Override
1035 public void onGlobalLayout()
1036 {
1037 view_toolbar_top.getViewTreeObserver().removeGlobalOnLayoutListener(this);
1038 // int width = view_toolbar_top.getMeasuredWidth();
1039 int height = view_toolbar_top.getMeasuredHeight();
1040 Navit.actionBarHeight = height;
1041 // System.out.println("hhh:88=" + Navit.actionBarHeight);
1042 Navit.cur_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
1043
1044 pp22.setMargins(0, (int) Navit.cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1045 a.setLayoutParams(pp22);
1046 a.requestLayout();
1047 }
1048 });
1049
1050 // actionBarHeight = 168;
1051
1052 // final int SWIPE_MIN_DISTANCE = NavitGraphics.dp_to_px(25);
1053 // final float SWIPE_THRESHOLD_VELOCITY = 5.5f;
1054 // final float FLING_PIXELS_PER_SECOND = 100;
1055 // final float maxFlingVelocity = ViewConfiguration.get(this).getScaledMaximumFlingVelocity();
1056 final ViewConfiguration vc = ViewConfiguration.get(this);
1057 final int swipeMinDistance = vc.getScaledPagingTouchSlop();
1058 final int swipeThresholdVelocity = vc.getScaledMinimumFlingVelocity();
1059 swipeMaxOffPath = vc.getScaledTouchSlop();
1060 // (there is also vc.getScaledMaximumFlingVelocity() one could check against)
1061
1062 // setup some values --------
1063 NavitGraphics.long_press_on_screen_max_distance = swipeMaxOffPath;
1064 // setup some values --------
1065
1066 class MyGestureDetector extends SimpleOnGestureListener
1067 {
1068 @Override
1069 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
1070 {
1071 try
1072 {
1073 // float velocityPercentY = velocityY / maxFlingVelocity; // the percent is a value in the range of (0, 1]
1074 // float normalizedVelocityY = velocityPercentY * FLING_PIXELS_PER_SECOND; // where PIXELS_PER_SECOND is a device-independent measurement
1075
1076 // System.out.println("VVV:" + (e1.getY() - e2.getY()) + " " + NavitGraphics.dp_to_px((int) (e1.getY() - e2.getY())) + " " + maxFlingVelocity + " " + velocityY + " " + velocityPercentY + " " + normalizedVelocityY + " " + SWIPE_THRESHOLD_VELOCITY);
1077
1078 // System.out.println("VVV:2:" + swipeMinDistance + " " + swipeThresholdVelocity + " " + swipeMaxOffPath);
1079
1080 // bottom to top
1081 if (e1.getY() - e2.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1082 {
1083 //int featureWidth = getMeasuredWidth();
1084 //mActiveFeature = (mActiveFeature < (mItems.size() - 1)) ? mActiveFeature + 1 : mItems.size() - 1;
1085 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1086 //System.out.println("GS:002:up:" + velocityY + " " + e2.getY() + " " + e1.getY());
1087
1088 animate_bottom_bar_up();
1089
1090 return true;
1091 }
1092 // top to bottom
1093 else if (e2.getY() - e1.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1094 {
1095 //int featureWidth = getMeasuredWidth();
1096 //mActiveFeature = (mActiveFeature > 0) ? mActiveFeature - 1 : 0;
1097 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1098 //System.out.println("GS:003:down:" + velocityY + " " + e1.getY() + " " + e2.getY());
1099
1100 animate_bottom_bar_down();
1101
1102 return true;
1103 }
1104 }
1105 catch (Exception e)
1106 {
1107 //System.out.println("GS:009:EE:" + e.getMessage());
1108 }
1109 return false;
1110 }
1111 }
1112 mGestureDetector = new GestureDetector(new MyGestureDetector());
1113
1114 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
1115 push_pin_view.setOnClickListener(new ImageView.OnClickListener()
1116 {
1117 public void onClick(View v)
1118 {
1119 try
1120 {
1121 toggle_follow_button();
1122 }
1123 catch (Exception e)
1124 {
1125 }
1126 }
1127 });
1128
1129 cur_y_margin_bottom_bar_touch = 0; // try to put view at bottom
1130
1131 a.setOnTouchListener(new View.OnTouchListener()
1132 {
1133 @Override
1134 synchronized public boolean onTouch(View v, MotionEvent m)
1135 {
1136
1137 int action = m.getAction();
1138
1139 if (mGestureDetector.onTouchEvent(m))
1140 {
1141 //System.out.println("GS:001:fling!!");
1142 // System.out.println("FRAG:fling:011");
1143 return true;
1144 }
1145 else if (action == MotionEvent.ACTION_DOWN)
1146 {
1147 last_y_bottom_bar_touch = m.getY();
1148
1149 // put roadbook into layout -----------
1150 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
1151
1152 try
1153 {
1154 if (road_book == null)
1155 {
1156 road_book = new ZANaviRoadbookFragment();
1157 // System.out.println("FRAG:attach:001");
1158 fragmentTransaction.replace(R.id.roadbook_fragment_container, road_book, "");
1159 fragmentTransaction.commitAllowingStateLoss();
1160 // fragmentTransaction.show(road_book);
1161 }
1162 else
1163 {
1164 // System.out.println("FRAG:attached:003");
1165 }
1166 }
1167 catch (Exception ef)
1168 {
1169 }
1170 // put roadbook into layout -----------
1171
1172 return true;
1173 }
1174 else if ((action == MotionEvent.ACTION_UP) || (action == MotionEvent.ACTION_CANCEL))
1175 {
1176 // System.out.println("FRAG:up/cancel:012");
1177
1178 // release
1179 if (cur_y_margin_bottom_bar_touch > (bottom_y_margin_bottom_bar_touch / 2))
1180 {
1181 // snap back to bottom
1182 animate_bottom_bar_down();
1183 }
1184 else
1185 {
1186 // snap top top
1187 animate_bottom_bar_up();
1188 }
1189 }
1190 else
1191 // if (action == MotionEvent.ACTION_MOVE)
1192 {
1193 // System.out.println("FRAG:*else*:012");
1194
1195 if (Math.abs(last_y_bottom_bar_touch - m.getY()) > 2)
1196 {
1197 float last_margin = cur_y_margin_bottom_bar_touch;
1198 cur_y_margin_bottom_bar_touch = cur_y_margin_bottom_bar_touch - (last_y_bottom_bar_touch - m.getY());
1199
1200 if ((cur_y_margin_bottom_bar_touch >= 0) && (cur_y_margin_bottom_bar_touch <= bottom_y_margin_bottom_bar_touch))
1201 {
1202 // System.out.println("VVV:move:" + cur_y_margin_bottom_bar_touch + " " + bottom_y_margin_bottom_bar_touch);
1203
1204 last_y_bottom_bar_touch = m.getY() + (last_y_bottom_bar_touch - m.getY());
1205 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
1206 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1207 a.setLayoutParams(relativeParams);
1208 a.requestLayout();
1209 }
1210 else
1211 {
1212 // System.out.println("VVV:revert");
1213
1214 // revert position
1215 cur_y_margin_bottom_bar_touch = last_margin;
1216 }
1217 }
1218
1219 }
1220 return true;
1221 }
1222 });
1223 // ------------ bottom bar slider ----------------
1224 // ------------ bottom bar slider ----------------
1225 // ------------ bottom bar slider ----------------
1226
1227 // init cancel dialog!! ----------
1228 // init cancel dialog!! ----------
1229 Message msg2 = new Message();
1230 Bundle b2 = new Bundle();
1231 b2.putString("text", "");
1232 msg2.what = 0;
1233 msg2.setData(b2);
1234 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg2);
1235 // init cancel dialog!! ----------
1236 // init cancel dialog!! ----------
1237
1238 app_window = getWindow();
1239
1240 // ---------------- set some directories -----------------
1241 // ---------------- set some directories -----------------
1242 NAVIT_DATA_DIR = this.getFilesDir().getPath();
1243 this.getFilesDir().mkdirs();
1244 // ---
1245 // System.out.println("data dir=" + NAVIT_DATA_DIR);
1246 NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share/";
1247 File tmp3 = new File(NAVIT_DATA_SHARE_DIR);
1248 tmp3.mkdirs();
1249 // ---
1250 FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
1251 VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
1252 // ---------------- set some directories -----------------
1253 // ---------------- set some directories -----------------
1254
1255 try
1256 {
1257 toneG = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
1258 }
1259 catch (Exception e)
1260 {
1261 }
1262
1263 try
1264 {
1265 Class.forName("android.app.backup.BackupManager");
1266 backupManager = new BackupManager(this);
1267 }
1268 catch (ClassNotFoundException e)
1269 {
1270 e.printStackTrace();
1271 }
1272 catch (Exception e)
1273 {
1274 e.printStackTrace();
1275 }
1276
1277 int width_ = display_.getWidth();
1278 int height_ = display_.getHeight();
1279 Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_);
1280 Log.e("Navit", "Navit -> dpi=" + Navit.metrics.densityDpi);
1281 Log.e("Navit", "Navit -> density=" + Navit.metrics.density);
1282 Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);
1283
1284 try
1285 {
1286 // send overspill factor to C-code
1287 Message msg33 = new Message();
1288 Bundle b33 = new Bundle();
1289 b33.putInt("Callback", 104);
1290 msg33.setData(b33);
1291 NavitGraphics.callback_handler.sendMessage(msg33);
1292 }
1293 catch (Exception eee)
1294 {
1295 }
1296
1297 // ----- service -----
1298 // ----- service -----
1299 ZANaviMapDownloaderServiceIntent = new Intent(Navit.getBaseContext_, ZANaviMapDownloaderService.class);
1300 // ----- service -----
1301 // ----- service -----
1302
1303 System.out.println("Navit:onCreate:JTHREAD ID=" + Thread.currentThread().getId());
1304 System.out.println("Navit:onCreate:THREAD ID=" + NavitGraphics.GetThreadId());
1305
1306 // bitmaps for lanes
1307 lane_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_left);
1308 lane_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_right);
1309 lane_merge_to_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_left);
1310 lane_merge_to_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_right);
1311 lane_none = BitmapFactory.decodeResource(getResources(), R.drawable.lane_none);
1312 // bitmaps for lanes
1313
1314 // paint for bitmapdrawing on map
1315 NavitGraphics.paint_for_map_display.setAntiAlias(true);
1316 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
1317
1318 // sky
1319 NavitGraphics.paint_sky_day.setAntiAlias(true);
1320 NavitGraphics.paint_sky_day.setColor(Color.parseColor("#79BAEC"));
1321 NavitGraphics.paint_sky_night.setAntiAlias(true);
1322 NavitGraphics.paint_sky_night.setColor(Color.parseColor("#090909"));
1323 // stars
1324 NavitGraphics.paint_sky_night_stars.setColor(Color.parseColor("#DEDDEF"));
1325 // twilight
1326 NavitGraphics.paint_sky_twilight1.setColor(Color.parseColor("#090909"));
1327 NavitGraphics.paint_sky_twilight2.setColor(Color.parseColor("#113268"));
1328 NavitGraphics.paint_sky_twilight3.setColor(Color.parseColor("#79BAEC"));
1329
1330 Random m = new Random();
1331 int i6 = 0;
1332 for (i6 = 0; i6 < (NavitGraphics.max_stars + 1); i6++)
1333 {
1334 NavitGraphics.stars_x[i6] = m.nextFloat();
1335 NavitGraphics.stars_y[i6] = m.nextFloat();
1336 NavitGraphics.stars_size[i6] = m.nextInt(3) + 1;
1337 }
1338
1339 res_ = getResources();
1340 int ii = 0;
1341 NavitGraphics.dl_thread_cur = 0;
1342 for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
1343 {
1344 NavitGraphics.dl_thread[ii] = null;
1345 }
1346
1347 String font_file_name = "Roboto-Regular.ttf"; // "LiberationSans-Regular.ttf";
1348 NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), font_file_name);
1349 // System.out.println("NavitStreetnameFont" + NavitStreetnameFont);
1350
1351 Navit_maps_loaded = false;
1352
1353 // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
1354 Navit.startup_intent = this.getIntent();
1355 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
1356 Navit.startup_intent_timestamp = System.currentTimeMillis();
1357 Log.e("Navit", "**1**A " + startup_intent.getAction());
1358 Log.e("Navit", "**1**D " + startup_intent.getDataString());
1359 Log.e("Navit", "**1**I " + startup_intent.toString());
1360 try
1361 {
1362 Log.e("Navit", "**1**DH E " + startup_intent.getExtras().describeContents());
1363 }
1364 catch (Exception ee)
1365 {
1366 }
1367
1368 startup_status = Navit_Status_NORMAL_STARTUP;
1369
1370 // glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView_001);
1371 // glSurfaceView.setEGLContextClientVersion(2); // enable OpenGL 2.0
1372 // glSurfaceView.setRenderer(new GlRenderer());
1373 // glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // only render on demand
1374 //
1375 // // draw some sample lines ----
1376 // // draw some sample lines ----
1377 // // draw some sample lines ----
1378 // ZANaviGlLine vertLine = new ZANaviGlLine();
1379 // vertLine.SetVerts(1000f, 1000f, 0f, -1000f, -1000f, 0f);
1380 // vertLine.SetColor(.8f, .8f, 0f, 1.0f);
1381 //
1382 // float[] mMVPMatrix = new float[16];
1383 //
1384 // // Position the eye behind the origin.
1385 // final float eyeX = 0.0f;
1386 // final float eyeY = 0.0f;
1387 // final float eyeZ = 1.5f;
1388 //
1389 // // We are looking toward the distance
1390 // final float lookX = 0.0f;
1391 // final float lookY = 0.0f;
1392 // final float lookZ = -5.0f;
1393 //
1394 // // Set our up vector. This is where our head would be pointing were we holding the camera.
1395 // final float upX = 0.0f;
1396 // final float upY = 1.0f;
1397 // final float upZ = 0.0f;
1398 //
1399 // // Set the view matrix. This matrix can be said to represent the camera position.
1400 // // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
1401 // // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
1402 // Matrix.setLookAtM(mMVPMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
1403 //
1404 // vertLine.draw(mMVPMatrix);
1405 //
1406 // glSurfaceView.postInvalidate();
1407 // glSurfaceView.requestRender();
1408 // glSurfaceView.postInvalidate();
1409 // // draw some sample lines ----
1410 // // draw some sample lines ----
1411 // // draw some sample lines ----
1412
1413 // setup graphics objects
1414 // setup graphics objects
1415 // setup graphics objects
1416 NG__vehicle = new NavitGraphics(this, 1, 0, 0, 50, 50, 65535, 0, 0);
1417 NG__map_main = new NavitGraphics(this, 0, 0, 0, 100, 100, 0, 0, 0);
1418 Navit.N_NavitGraphics = NG__map_main;
1419 // setup graphics objects
1420 // setup graphics objects
1421 // setup graphics objects
1422
1423 NV = new NavitVehicle(this);
1424 NSp = new NavitSpeech2(this);
1425
1426 // init translated text
1427 NavitTextTranslations.init();
1428
1429 // set the new locale here -----------------------------------
1430 getPrefs_loc();
1431 activatePrefs_loc();
1432 // set the new locale here -----------------------------------
1433
1434 // get the local language -------------
1435 Locale locale = java.util.Locale.getDefault();
1436 String lang = locale.getLanguage();
1437 String langu = lang;
1438 String langc = lang;
1439 Log.e("Navit", "lang=" + lang);
1440 int pos = langu.indexOf('_');
1441 if (pos != -1)
1442 {
1443 langc = langu.substring(0, pos);
1444 langu = langc + langu.substring(pos).toUpperCase(locale);
1445 Log.e("Navit", "substring lang " + langu.substring(pos).toUpperCase(locale));
1446 // set lang. for translation
1447 NavitTextTranslations.main_language = langc;
1448 NavitTextTranslations.sub_language = langu.substring(pos).toUpperCase(locale);
1449 }
1450 else
1451 {
1452 String country = locale.getCountry();
1453 Log.e("Navit", "Country1 " + country);
1454 Log.e("Navit", "Country2 " + country.toUpperCase(locale));
1455 langu = langc + "_" + country.toUpperCase(locale);
1456 // set lang. for translation
1457 NavitTextTranslations.main_language = langc;
1458 NavitTextTranslations.sub_language = country.toUpperCase(locale);
1459 }
1460 Log.e("Navit", "Language " + lang);
1461 // get the local language -------------
1462
1463 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
1464 no_maps_text.setText("\n\n\n" + Navit.get_text("No Maps installed") + "\n" + Navit.get_text("Please download a map") + "\n\n");
1465 // no_maps_text.postInvalidate();
1466
1467 // set map cache size here -----------------------------------
1468 getPrefs_mapcache();
1469 activatePrefs_mapcache();
1470 // set map cache size here -----------------------------------
1471
1472 // get map data dir and set it -----------------------------
1473 getPrefs_mapdir();
1474 activatePrefs_mapdir(true);
1475 // get map data dir and set it -----------------------------
1476
1477 // get special prefs here ------------------------------------
1478 get_prefs_highdpi();
1479 // get special prefs here ------------------------------------
1480
1481 // make sure the new path for the navitmap.bin file(s) exist!!
1482 File navit_maps_dir = new File(MAP_FILENAME_PATH);
1483 navit_maps_dir.mkdirs();
1484 // create nomedia files
1485 File nomedia_file = new File(MAP_FILENAME_PATH + ".nomedia");
1486 try
1487 {
1488 nomedia_file.createNewFile();
1489 }
1490 catch (Exception e1)
1491 {
1492 e1.printStackTrace();
1493 }
1494 // create nomedia files
1495
1496 // check if we already have a borders.bin file (if not, then extract the included simplified one)
1497 File b_ = new File(MAP_FILENAME_PATH + "/borders.bin");
1498 try
1499 {
1500 if (!b_.exists())
1501 {
1502 try
1503 {
1504 File c_ = new File(MAPMD5_FILENAME_PATH + "/borders.bin.md5");
1505 c_.delete();
1506 }
1507 catch (Exception e2)
1508 {
1509
1510 }
1511 Log.e("Navit", "trying to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1512 if (!extractRes("borders_simple", MAP_FILENAME_PATH + "/borders.bin"))
1513 {
1514 Log.e("Navit", "Failed to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1515 }
1516 }
1517 }
1518 catch (Exception e)
1519 {
1520
1521 }
1522 // check if we already have a borders.bin file
1523
1524 // make sure the new path for config files exist
1525 File navit_cfg_dir = new File(CFG_FILENAME_PATH);
1526 navit_cfg_dir.mkdirs();
1527
1528 // make sure the new path for the navitmap.bin file(s) exist!!
1529 File navit_mapsmd5_dir = new File(MAPMD5_FILENAME_PATH);
1530 navit_mapsmd5_dir.mkdirs();
1531
1532 // make sure the share dir exists, otherwise the infobox will not show
1533 File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR);
1534 navit_data_share_dir.mkdirs();
1535
1536 File dd = new File(NAVIT_DATA_DEBUG_DIR);
1537 dd.mkdirs();
1538
1539 // try to create cat. file if it does not exist
1540 File navit_maps_catalogue = new File(CFG_FILENAME_PATH + NavitMapDownloader.CAT_FILE);
1541 if (!navit_maps_catalogue.exists())
1542 {
1543 FileOutputStream fos_temp;
1544 try
1545 {
1546 fos_temp = new FileOutputStream(navit_maps_catalogue);
1547 fos_temp.write((NavitMapDownloader.MAP_CAT_HEADER + "\n").getBytes()); // just write header to the file
1548 fos_temp.flush();
1549 fos_temp.close();
1550 }
1551 catch (Exception e)
1552 {
1553 e.printStackTrace();
1554 }
1555 }
1556
1557 // ---------- downloader threads ----------------
1558 NavitMapDownloader.MULTI_NUM_THREADS = 1;
1559 PackageInfo pkgInfo;
1560 Navit_DonateVersion_Installed = false;
1561 try
1562 {
1563 // is the donate version installed?
1564 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_donate", 0);
1565 String sharedUserId = pkgInfo.sharedUserId;
1566 System.out.println("str nd=" + sharedUserId);
1567 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
1568 {
1569 System.out.println("##bonus 001##");
1570 Navit_DonateVersion_Installed = true;
1571 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1572 }
1573 }
1574 catch (NameNotFoundException e)
1575 {
1576 e.printStackTrace();
1577 }
1578 catch (Exception e)
1579 {
1580 e.printStackTrace();
1581 }
1582
1583 try
1584 {
1585 if (get_reglevel() == 1)
1586 {
1587 System.out.println("##U:bonus 001##");
1588 Navit_DonateVersion_Installed = true;
1589 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1590 }
1591 }
1592 catch (Exception e)
1593 {
1594 e.printStackTrace();
1595 }
1596
1597 try
1598 {
1599 // is the "large map" donate version installed?
1600 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0);
1601 String sharedUserId = pkgInfo.sharedUserId;
1602 System.out.println("str lm=" + sharedUserId);
1603
1604 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
1605 {
1606 System.out.println("##bonus 002##");
1607 Navit_DonateVersion_Installed = true;
1608 Navit_Largemap_DonateVersion_Installed = true;
1609 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1610 }
1611 }
1612 catch (NameNotFoundException e)
1613 {
1614 e.printStackTrace();
1615 }
1616 catch (Exception e)
1617 {
1618 e.printStackTrace();
1619 }
1620
1621 try
1622 {
1623 if (get_reglevel() == 1)
1624 {
1625 System.out.println("##U:bonus 002##");
1626 Navit_DonateVersion_Installed = true;
1627 Navit_Largemap_DonateVersion_Installed = true;
1628 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1629 }
1630 }
1631 catch (Exception e)
1632 {
1633 e.printStackTrace();
1634 }
1635
1636 // update map list
1637 NavitMapDownloader.init_maps_without_donate_largemaps();
1638 // ---------- downloader threads ----------------
1639
1640 // ---- detect menu button ----
1641 detect_menu_button();
1642
1643 if (Navit.metrics.densityDpi >= 320) //&& (PREF_shrink_on_high_dpi))
1644 {
1645 Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001);
1646 }
1647 else
1648 {
1649 Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001_small);
1650 }
1651
1652 Navit.long_green_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.long_green_arrow);
1653
1654 Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow);
1655 Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off);
1656 Navit.follow_current = Navit.follow_on;
1657
1658 if ((Navit.metrics.densityDpi >= 320) && (p.PREF_shrink_on_high_dpi))
1659 {
1660 float factor;
1661 factor = (float) NavitGraphics.Global_Scaled_DPI_normal / (float) Navit.metrics.densityDpi;
1662 factor = factor * 1.7f;
1663 //
1664 BitmapFactory.Options o = new BitmapFactory.Options();
1665 o.inDither = true;
1666 //o.inScaled = true;
1667 //o.inTargetDensity = NavitGraphics.Global_Scaled_DPI_normal;
1668 Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped, o);
1669 Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving, o);
1670 Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey, o);
1671 Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow, o);
1672
1673 Navit.nav_arrow_stopped_small = Bitmap.createScaledBitmap(Navit.nav_arrow_stopped, (int) (Navit.nav_arrow_stopped.getWidth() / NavitGraphics.strech_factor_3d_map * factor), (int) (Navit.nav_arrow_stopped.getHeight() / NavitGraphics.strech_factor_3d_map * factor), true);
1674 Navit.nav_arrow_moving_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving, (int) (Navit.nav_arrow_moving.getWidth() / NavitGraphics.strech_factor_3d_map * factor), (int) (Navit.nav_arrow_moving.getHeight() / NavitGraphics.strech_factor_3d_map * factor), true);
1675 Navit.nav_arrow_moving_shadow_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving_shadow, (int) (Navit.nav_arrow_moving_shadow.getWidth() / NavitGraphics.strech_factor_3d_map * factor), (int) (Navit.nav_arrow_moving_shadow.getHeight() / NavitGraphics.strech_factor_3d_map * factor), true);
1676 }
1677 else
1678 {
1679 Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped);
1680 Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving);
1681 Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey);
1682 Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow);
1683
1684 Navit.nav_arrow_stopped_small = Bitmap.createScaledBitmap(Navit.nav_arrow_stopped, (int) (Navit.nav_arrow_stopped.getWidth() / NavitGraphics.strech_factor_3d_map), (int) (Navit.nav_arrow_stopped.getHeight() / NavitGraphics.strech_factor_3d_map), true);
1685 Navit.nav_arrow_moving_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving, (int) (Navit.nav_arrow_moving.getWidth() / NavitGraphics.strech_factor_3d_map), (int) (1.5 * Navit.nav_arrow_moving.getHeight() / NavitGraphics.strech_factor_3d_map), true);
1686 Navit.nav_arrow_moving_shadow_small = Bitmap.createScaledBitmap(Navit.nav_arrow_moving_shadow, (int) (Navit.nav_arrow_moving_shadow.getWidth() / NavitGraphics.strech_factor_3d_map), (int) (1.5 * Navit.nav_arrow_moving_shadow.getHeight() / NavitGraphics.strech_factor_3d_map), true);
1687 }
1688
1689 Navit.zoomin = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_in_32_32);
1690 Navit.zoomout = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_out_32_32);
1691
1692 //Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway);
1693 Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_large);
1694 Navit.oneway_bicycle_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_bicycle_large);
1695
1696 // *******************
1697 // *******************
1698 // *******************
1699 // *******************
1700 // check/init the catalogue file for downloaded maps
1701 NavitMapDownloader.init_cat_file();
1702 // *******************
1703 // *******************
1704 // *******************
1705 // *******************
1706
1707 xmlconfig_unpack_file = false;
1708 write_new_version_file = false;
1709 try
1710 {
1711 NavitAppVersion = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionCode;
1712 NavitAppVersion_string = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
1713 }
1714 catch (NameNotFoundException e)
1715 {
1716 e.printStackTrace();
1717 NavitAppVersion = "1";
1718 NavitAppVersion_string = "1";
1719 }
1720 catch (Exception e)
1721 {
1722 e.printStackTrace();
1723 NavitAppVersion = "2";
1724 NavitAppVersion_string = "2";
1725 }
1726
1727 try
1728 {
1729 File navit_version = new File(VERSION_FILE);
1730 if (!navit_version.exists())
1731 {
1732 System.out.println("version file does not exist");
1733 NavitAppVersion_prev = "-1";
1734 write_new_version_file = true;
1735 }
1736 else
1737 {
1738 // files exists, read in the prev. verison number
1739 System.out.println("version file is here");
1740 FileInputStream fos_temp;
1741 byte[] buffer = new byte[101];
1742 fos_temp = new FileInputStream(navit_version);
1743 int len = fos_temp.read(buffer, 0, 100);
1744 if (len != -1)
1745 {
1746 // use only len bytes to make the string (the rest is garbage!!)
1747 NavitAppVersion_prev = new String(buffer).substring(0, len);
1748 }
1749 else
1750 {
1751 NavitAppVersion_prev = "-1";
1752 write_new_version_file = true;
1753 }
1754 fos_temp.close();
1755 }
1756
1757 }
1758 catch (Exception e)
1759 {
1760 NavitAppVersion_prev = "-1";
1761 write_new_version_file = true;
1762 e.printStackTrace();
1763 }
1764
1765 System.out.println("vprev:" + NavitAppVersion_prev + " vcur:" + NavitAppVersion);
1766
1767 if (NavitAppVersion_prev.compareTo(NavitAppVersion) != 0)
1768 {
1769 // different version
1770 System.out.println("different version!!");
1771 write_new_version_file = true;
1772 xmlconfig_unpack_file = true;
1773
1774 //if ((NavitAppVersion_prev.compareTo("-1") != 0) && (NavitAppVersion.compareTo("-1") != 0))
1775 //{
1776 // user has upgraded to a new version of ZANavi
1777 startup_status = Navit_Status_UPGRADED_TO_NEW_VERSION;
1778 //}
1779 }
1780 else
1781 {
1782 // same version
1783 System.out.println("same version");
1784 xmlconfig_unpack_file = false;
1785 }
1786
1787 // write new version file
1788 if (write_new_version_file)
1789 {
1790 try
1791 {
1792 System.out.println("write version file");
1793 FileOutputStream fos_temp;
1794 File navit_version = new File(VERSION_FILE);
1795 navit_version.delete();
1796 fos_temp = new FileOutputStream(navit_version);
1797 fos_temp.write(NavitAppVersion.getBytes());
1798 fos_temp.flush();
1799 fos_temp.close();
1800 }
1801 catch (Exception e)
1802 {
1803 e.printStackTrace();
1804 }
1805 }
1806
1807 // Sample useragent strings:
1808 //
1809 // Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110616 Firefox/7.0a1 SeaMonkey/2.4a1
1810 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; GT-I9100 Build/GINGERBREAD)
1811 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5830 Build/FROYO)
1812 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Desire S Build/GRI40)
1813 // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-179)
1814 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Wildfire S A510e Build/GRI40)
1815 // Wget/1.10.2
1816 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; sdk Build/GRI34)
1817 // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-164)
1818 // Dalvik/1.2.0 (Linux; U; Android 2.2; GT-I9000 Build/FROYO)
1819 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5570L Build/FROYO)
1820 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-I9000 Build/FROYO)
1821 // Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)
1822 String ANDROID = android.os.Build.VERSION.SDK; //The current development codename, or the string "REL" if this is a release build.
1823 //String BOARD = android.os.Build.BOARD; //The name of the underlying board, like "goldfish".
1824 //String BOOTLOADER = android.os.Build.BOOTLOADER; // The system bootloader version number.
1825 String BRAND = android.os.Build.BRAND; //The brand (e.g., carrier) the software is customized for, if any.
1826 //String CPU_ABI = android.os.Build.CPU_ABI; //The name of the instruction set (CPU type + ABI convention) of native code.
1827 //String CPU_ABI2 = android.os.Build.CPU_ABI2; // The name of the second instruction set (CPU type + ABI convention) of native code.
1828 String DEVICE = android.os.Build.DEVICE; // The name of the industrial design.
1829 String DISPLAY = android.os.Build.DISPLAY; //A build ID string meant for displaying to the user
1830 //String FINGERPRINT = android.os.Build.FINGERPRINT; //A string that uniquely identifies this build.
1831 //String HARDWARE = android.os.Build.HARDWARE; //The name of the hardware (from the kernel command line or /proc).
1832 //String HOST = android.os.Build.HOST;
1833 //String ID = android.os.Build.ID; //Either a changelist number, or a label like "M4-rc20".
1834 String MANUFACTURER = android.os.Build.MANUFACTURER; //The manufacturer of the product/hardware.
1835 //String MODEL = android.os.Build.MODEL; //The end-user-visible name for the end product.
1836 //String PRODUCT = android.os.Build.PRODUCT; //The name of the overall product.
1837 //String RADIO = android.os.Build.RADIO; //The radio firmware version number.
1838 //String TAGS = android.os.Build.TAGS; //Comma-separated tags describing the build, like "unsigned,debug".
1839 //String TYPE = android.os.Build.TYPE; //The type of build, like "user" or "eng".
1840 //String USER = android.os.Build.USER;
1841
1842 String android_version = "Android " + ANDROID;
1843 String android_device = MANUFACTURER + " " + BRAND + " " + DEVICE;
1844
1845 api_version_int = Integer.valueOf(android.os.Build.VERSION.SDK);
1846 System.out.println("XXX:API=" + api_version_int);
1847 if (api_version_int > 10)
1848 {
1849 Navit.PAINT_OLD_API = false;
1850 }
1851 else
1852 {
1853 Navit.PAINT_OLD_API = true;
1854 }
1855
1856 if (MANUFACTURER.equalsIgnoreCase("amazon"))
1857 {
1858 // we are on amazon device
1859 ZANaviNormalDonateActivity.on_amazon_device = true;
1860 }
1861
1862 // debug
1863 // debug
1864 // android_device = "telechips telechips m801";
1865 // debug
1866 // debug
1867
1868 String android_rom_name = DISPLAY;
1869
1870 if (FDBL)
1871 {
1872 android_rom_name = android_rom_name + "; FD";
1873 }
1874
1875 if (Navit_DonateVersion_Installed == false)
1876 {
1877 UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1878 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1879 }
1880 else
1881 {
1882 if (Navit_Largemap_DonateVersion_Installed == false)
1883 {
1884 UserAgentString = "Mozilla/5.0 (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1885 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1886 }
1887 else
1888
1889 {
1890 UserAgentString = "Mozilla/5.0 (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1891 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1892 }
1893 }
1894 // System.out.println("UA=" + UserAgentString);
1895
1896 // --------- enable GPS ? --------------
1897 // --------- enable GPS ? --------------
1898 // try
1899 // {
1900 // final LocationManager llmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
1901 // if (!llmanager.isProviderEnabled(LocationManager.GPS_PROVIDER))
1902 // {
1903 // buildAlertMessageNoGps();
1904 // }
1905 // }
1906 // catch (Exception e)
1907 // {
1908 // e.printStackTrace();
1909 // }
1910 // --------- enable GPS ? --------------
1911 // --------- enable GPS ? --------------
1912
1913 unsupported = false;
1914 try
1915 {
1916 if (android_device.toLowerCase().contains("telechips"))
1917 {
1918 if (android_device.toLowerCase().contains("m801"))
1919 {
1920 // if the donate version is already installed, dont disable the app
1921 if (Navit_DonateVersion_Installed == false)
1922 {
1923 if (Navit_Largemap_DonateVersion_Installed == false)
1924 {
1925 // activate [Weltbild] Cat Nova again (19.12.2011)
1926 // ** // unsupported = true;
1927 }
1928 }
1929 }
1930 }
1931 }
1932 catch (Exception e)
1933 {
1934 e.printStackTrace();
1935 }
1936
1937 try
1938 {
1939 // this hangs the emulator, if emulator < 2.3 (only works in emulator >= 2.3)!!
1940 if (!NAVIT_IS_EMULATOR)
1941 {
1942 sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
1943 }
1944 }
1945 catch (Exception e3)
1946 {
1947 e3.printStackTrace();
1948 }
1949
1950 // try
1951 // {
1952 // vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
1953 // }
1954 // catch (Exception e)
1955 // {
1956 // e.printStackTrace();
1957 // }
1958 //sensorManager_ = sensorManager;
1959
1960 generic_alert_box = new AlertDialog.Builder(this);
1961 /*
1962 * show info box for first time users
1963 */
1964 AlertDialog.Builder infobox = new AlertDialog.Builder(this);
1965 //. english text: Welcome to ZANavi
1966 infobox.setTitle(Navit.get_text("__INFO_BOX_TITLE__")); //TRANS
1967 infobox.setCancelable(false);
1968 final TextView message = new TextView(this);
1969 message.setFadingEdgeLength(20);
1970 message.setVerticalFadingEdgeEnabled(true);
1971 message.setPadding(10, 5, 10, 5);
1972 message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
1973 message.setGravity(Gravity.LEFT);
1974 // message.setScrollBarStyle(TextView.SCROLLBARS_INSIDE_OVERLAY);
1975 // message.setVerticalScrollBarEnabled(true);
1976 RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
1977 rlp.leftMargin = 7;
1978 rlp.rightMargin = 7;
1979
1980 Navit.Navit_Geocoder = null;
1981 try
1982 {
1983 // for online search
1984 Navit.Navit_Geocoder = new Geocoder(this);
1985 }
1986 catch (Exception e)
1987 {
1988 e.printStackTrace();
1989 }
1990
1991 //TRANS
1992 infobox.setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
1993 {
1994 public void onClick(DialogInterface arg0, int arg1)
1995 {
1996 Log.e("Navit", "Ok, user saw the infobox");
1997 }
1998 });
1999
2000 //TRANS
2001 infobox.setNeutralButton(Navit.get_text("More info"), new DialogInterface.OnClickListener()
2002 {
2003 public void onClick(DialogInterface arg0, int arg1)
2004 {
2005 Log.e("Navit", "user wants more info, show the website");
2006 // URL to ZANavi Manual (in english language)
2007 String url = "http://zanavi.cc/index.php/Manual";
2008 if (FDBL)
2009 {
2010 url = "http://fd.zanavi.cc/manual";
2011 }
2012 Intent i = new Intent(Intent.ACTION_VIEW);
2013 i.setData(Uri.parse(url));
2014 startActivity(i);
2015 }
2016 });
2017
2018 info_popup_seen_count_end = false;
2019 File navit_first_startup = new File(FIRST_STARTUP_FILE);
2020 // if file does NOT exist, show the info box
2021 if (!navit_first_startup.exists())
2022 {
2023 // set first-ever-startup flag
2024 first_ever_startup = true;
2025 info_popup_seen_count_end = true; // don't show on first ever start of the app
2026 startup_status = Navit_Status_COMPLETE_NEW_INSTALL;
2027 FileOutputStream fos_temp;
2028 try
2029 {
2030 info_popup_seen_count++;
2031 fos_temp = new FileOutputStream(navit_first_startup);
2032 fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count
2033 fos_temp.flush();
2034 fos_temp.close();
2035
2036 message.setLayoutParams(rlp);
2037 //. TRANSLATORS: multiline info text for first startup of application (see en_US for english text)
2038 final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
2039 Linkify.addLinks(s, Linkify.WEB_URLS);
2040 message.setText(s);
2041 message.setMovementMethod(LinkMovementMethod.getInstance());
2042 infobox.setView(message);
2043
2044 infobox.show();
2045 }
2046 catch (Exception e)
2047 {
2048 e.printStackTrace();
2049 }
2050 }
2051 else
2052 {
2053 FileOutputStream fos_temp;
2054 FileInputStream fis_temp;
2055 try
2056 {
2057 fis_temp = new FileInputStream(navit_first_startup);
2058 info_popup_seen_count = fis_temp.read();
2059 fis_temp.close();
2060
2061 if (info_popup_seen_count < 0)
2062 {
2063 info_popup_seen_count = 0;
2064 }
2065
2066 // we wrote "A" -> (int)65 previously, so account for that
2067 if (info_popup_seen_count == 65)
2068 {
2069 info_popup_seen_count = 0;
2070 }
2071
2072 if (info_popup_seen_count > info_popup_seen_count_max)
2073 {
2074 info_popup_seen_count_end = true;
2075 }
2076 else
2077 {
2078 info_popup_seen_count++;
2079 fos_temp = new FileOutputStream(navit_first_startup);
2080 fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count
2081 fos_temp.flush();
2082 fos_temp.close();
2083 }
2084 }
2085 catch (Exception e)
2086 {
2087 e.printStackTrace();
2088 }
2089 }
2090 /*
2091 * show info box for first time users
2092 */
2093
2094 // show info box for upgrade
2095 // if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
2096 // {
2097 // try
2098 // {
2099 // message.setLayoutParams(rlp);
2100 // // upgrade message
2101 // String upgrade_summary = "\n\n***********\n";
2102 // // upgrade message
2103 // final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
2104 // Linkify.addLinks(s, Linkify.WEB_URLS);
2105 // message.setText(s);
2106 // message.setMovementMethod(LinkMovementMethod.getInstance());
2107 // infobox.setView(message);
2108 //
2109 // infobox.show();
2110 // }
2111 // catch (Exception e)
2112 // {
2113 // e.printStackTrace();
2114 // }
2115 //
2116 // }
2117 // show info box for upgrade
2118
2119 //
2120 // ----------- info popup
2121 // ----------- info popup
2122 // ----------- info popup
2123 // ----------- info popup
2124 //
2125 if ((!info_popup_seen_count_end) || (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION))
2126 {
2127 try
2128 {
2129 //Builder a1 = new AlertDialog.Builder(this);
2130 //dialog_info_popup = a1.show();
2131 dialog_info_popup = new Dialog(this);
2132
2133 dialog_info_popup.setContentView(R.layout.info_popup);
2134 Button b_i1 = (Button) dialog_info_popup.findViewById(R.id.dialogButtonOK_i1);
2135
2136 TextView tv_i1 = (TextView) dialog_info_popup.findViewById(R.id.text_i1);
2137 final String ZANAVI_MSG_PLUGIN_MARKET_LINK = "https://play.google.com/store/apps/details?id=com.zoffcc.applications.zanavi_msg";
2138 final String ZANAVI_UDONATE_LINK = "http://more.zanavi.cc/donate/";
2139 final String ZANAVI_HOWTO_DEBUG_LINK = "http://static.zanavi.cc/be-a-testdriver/be-a-testdriver.html";
2140 final String ZANAVI_HOWTO_UDONTATE_FREE_LINK = "http://static.zanavi.cc/activate-udonate/activate-udonate.html";
2141
2142 if (FDBL)
2143 {
2144 tv_i1.setText(Html.fromHtml("\n<br>Help us to improve ZANavi, be a Testdriver and send in your route debug information.<br>\n<a href=\"" + ZANAVI_HOWTO_DEBUG_LINK + "\">HowTo be a Testdriver</a><br>\n<br>\n" + "And get the uDonate Version for free.<br>\n<a href=\"" + ZANAVI_HOWTO_UDONTATE_FREE_LINK + "\">get free uDonate version</a>\n" + "\n<br>\n<br>"));
2145 }
2146 else
2147 {
2148 tv_i1.setText(Html.fromHtml("\n<br>Help us to improve ZANavi, be a Testdriver and send in your route debug information.<br>\n<a href=\"" + ZANAVI_HOWTO_DEBUG_LINK + "\">HowTo be a Testdriver</a><br>\n<br>\n" + "And get the uDonate Version for free.<br>\n<a href=\"" + ZANAVI_HOWTO_UDONTATE_FREE_LINK + "\">get free uDonate version</a>\n" + "\n<br>\n<br>"));
2149 // tv_i1.setText(Html.fromHtml("\n<br>Try the Donate Version and help us keep the mapservers running.<br>\nyou will activate the super fast index search.\n" + "<br><a href=\"" + ZANAVI_UDONATE_LINK + "\">get the donate version</a>\n<br>\n<br>"));
2150 // tv_i1.setText(Html.fromHtml("\n<br>Try the new Plugin to be notified when there are updates to your downloaded maps.\n" + "<br><a href=\"" + ZANAVI_MSG_PLUGIN_MARKET_LINK + "\">install Plugin</a>\n<br>\n<br>" + "Probier das neue Plugin damit du immer benachrichtigt wirst wenn es Kartenupdates gibt.\n<br>" + "<a href=\"" + ZANAVI_MSG_PLUGIN_MARKET_LINK + "\">Plugin installieren</a>\n<br>"));
2151 }
2152
2153 try
2154 {
2155 tv_i1.setMovementMethod(LinkMovementMethod.getInstance());
2156 }
2157 catch (Exception ee3)
2158 {
2159 }
2160
2161 b_i1.setText("Ok (" + (1 + info_popup_seen_count_max - info_popup_seen_count) + ")");
2162 b_i1.setOnClickListener(new View.OnClickListener()
2163 {
2164 public void onClick(View v)
2165 {
2166 try
2167 {
2168 dialog_info_popup.cancel();
2169 }
2170 catch (Exception e)
2171 {
2172
2173 }
2174
2175 try
2176 {
2177 dialog_info_popup.dismiss();
2178 }
2179 catch (Exception e)
2180 {
2181
2182 }
2183
2184 try
2185 {
2186 // draw map no-async
2187 Message msg = new Message();
2188 Bundle b = new Bundle();
2189 b.putInt("Callback", 64);
2190 msg.setData(b);
2191 NavitGraphics.callback_handler.sendMessage(msg);
2192 }
2193 catch (Exception e)
2194 {
2195 e.printStackTrace();
2196 }
2197
2198 }
2199 });
2200 dialog_info_popup.setCancelable(true);
2201 dialog_info_popup.show();
2202 dialog_info_popup.getWindow().getDecorView().setBackgroundResource(R.drawable.rounded_bg);
2203 if (FDBL)
2204 {
2205 dialog_info_popup.setTitle(" Support us");
2206 }
2207 else
2208 {
2209 // dialog_info_popup.setTitle(" Try the new Plugin");
2210 dialog_info_popup.setTitle(" Support us");
2211 }
2212 }
2213 catch (Exception e)
2214 {
2215 e.printStackTrace();
2216 }
2217 }
2218 //
2219 // ----------- info popup
2220 // ----------- info popup
2221 // ----------- info popup
2222 //
2223
2224 // make handler statically available for use in "msg_to_msg_handler"
2225 Navit_progress_h = this.progress_handler;
2226
2227 // try
2228 // {
2229 // Navit.bigmap_bitmap = BitmapFactory.decodeResource(getResources(), R.raw.bigmap_colors_zanavi2);
2230 // }
2231 // catch (Exception e)
2232 // {
2233 // // when not enough memory is available, then disable large world overview map!
2234 // System.gc();
2235 // Navit.bigmap_bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
2236 // }
2237 // // ------no----- // Navit.bigmap_bitmap.setDensity(120); // set our dpi!!
2238
2239 try
2240 {
2241 setVolumeControlStream(AudioManager.STREAM_MUSIC);
2242 ActivityResults = new NavitActivityResult[16];
2243 }
2244 catch (Exception e)
2245 {
2246 e.printStackTrace();
2247 }
2248
2249 try
2250 {
2251 NavitAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
2252 }
2253 catch (Exception e)
2254 {
2255 e.printStackTrace();
2256 }
2257
2258 PowerManager pm = null;
2259 try
2260 {
2261 pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
2262 }
2263 catch (Exception e)
2264 {
2265 e.printStackTrace();
2266 }
2267
2268 try
2269 {
2270 // -- // pm.wakeUp(SystemClock.uptimeMillis()); // -- //
2271 // **screen always full on** // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2272 // **screen can go off, cpu will stay on** // wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2273
2274 // this works so far, lets the screen dim, but it cpu and screen stays on
2275 wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2276 }
2277 catch (Exception e)
2278 {
2279 e.printStackTrace();
2280 wl = null;
2281 }
2282
2283 try
2284 {
2285 wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ZANaviNeedCpu");
2286 }
2287 catch (Exception e)
2288 {
2289 e.printStackTrace();
2290 wl_cpu = null;
2291 }
2292
2293 try
2294 {
2295 wl_navigating = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "ZANaviNavigationOn");
2296 }
2297 catch (Exception e)
2298 {
2299 Log.e("Navit", "WakeLock NAV: create failed!!");
2300 e.printStackTrace();
2301 wl_navigating = null;
2302 }
2303
2304 // try
2305 // {
2306 // if (wl_navigating != null)
2307 // {
2308 // wl_navigating.acquire();
2309 // Log.e("Navit", "WakeLock NAV: acquire 00");
2310 // }
2311 // }
2312 // catch (Exception e)
2313 // {
2314 // Log.e("Navit", "WakeLock NAV: something wrong 00");
2315 // e.printStackTrace();
2316 // }
2317
2318 // try
2319 // {
2320 // if (wl != null)
2321 // {
2322 // try
2323 // {
2324 // wl.release();
2325 // }
2326 // catch (Exception e2)
2327 // {
2328 // }
2329 // wl.acquire();
2330 // Log.e("Navit", "WakeLock: acquire 1");
2331 // }
2332 // }
2333 // catch (Exception e)
2334 // {
2335 // e.printStackTrace();
2336 // }
2337
2338 // -- extract overview maps --
2339 // -- extract overview maps --
2340
2341 // File navit_worldmap2_file = new File(NAVIT_DATA_DIR + "/share/worldmap2.txt");
2342 File navit_worldmap2_file = new File(MAP_FILENAME_PATH + "/worldmap2.txt");
2343 if (!navit_worldmap2_file.exists())
2344 {
2345 if (!extractRes("worldmap2", MAP_FILENAME_PATH + "/worldmap2.txt"))
2346 {
2347 Log.e("Navit", "Failed to extract worldmap2.txt");
2348 }
2349 }
2350
2351 File navit_worldmap5_file = new File(MAP_FILENAME_PATH + "/worldmap5.txt");
2352 if (!navit_worldmap5_file.exists())
2353 {
2354 if (!extractRes("worldmap5", MAP_FILENAME_PATH + "/worldmap5.txt"))
2355 {
2356 Log.e("Navit", "Failed to extract worldmap5.txt");
2357 }
2358 }
2359 // -- extract overview maps --
2360 // -- extract overview maps --
2361
2362 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
2363 if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
2364 {
2365 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
2366 }
2367
2368 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
2369 if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase(), NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
2370 {
2371 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
2372 }
2373
2374 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language);
2375 if (!extractRes(NavitTextTranslations.main_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo"))
2376 {
2377 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language);
2378 }
2379
2380 // DEBUG - check if language file is on SDCARD -
2381 try
2382 {
2383 File debug_mo_src = new File("/sdcard/zanavi/debug/navit.mo");
2384 File debug_mo_dest = new File(NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo");
2385 //* File navit_debug_dir = new File("/sdcard/zanavi/debug/");
2386 //* navit_debug_dir.mkdirs();
2387 copyFile(debug_mo_src, debug_mo_dest);
2388 }
2389 catch (Exception e)
2390 {
2391 e.printStackTrace();
2392 }
2393 // DEBUG - check if language file is on SDCARD -
2394
2395 File navit_config_xml_file = new File(NAVIT_DATA_SHARE_DIR + "/navit.xml");
2396 if ((!navit_config_xml_file.exists()) || (NAVIT_ALWAYS_UNPACK_XMLFILE))
2397 {
2398 xmlconfig_unpack_file = true;
2399 Log.e("Navit", "navit.xml does not exist, unpacking in any case");
2400 }
2401
2402 my_display_density = "mdpi";
2403 // ldpi display (120 dpi)
2404
2405 NavitGraphics.Global_want_dpi = Navit.metrics.densityDpi;
2406 NavitGraphics.Global_want_dpi_other = Navit.metrics.densityDpi;
2407
2408 if (Navit.metrics.densityDpi <= 120)
2409 {
2410 my_display_density = "ldpi";
2411 if (xmlconfig_unpack_file)
2412 {
2413 if (!extractRes("navitldpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2414 {
2415 Log.e("Navit", "Failed to extract navit.xml for ldpi device(s)");
2416 }
2417 }
2418 }
2419 // mdpi display (160 dpi)
2420 else if ((Navit.metrics.densityDpi > 120) && (Navit.metrics.densityDpi <= 160))
2421 {
2422 my_display_density = "mdpi";
2423 if (xmlconfig_unpack_file)
2424 {
2425 if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2426 {
2427 Log.e("Navit", "Failed to extract navit.xml for mdpi device(s)");
2428 }
2429 }
2430 }
2431 // hdpi display (240 dpi)
2432 else if ((Navit.metrics.densityDpi > 160) && (Navit.metrics.densityDpi < 320))
2433 //else if (Navit.metrics.densityDpi == 240)
2434 {
2435 my_display_density = "hdpi";
2436 if (xmlconfig_unpack_file)
2437 {
2438 if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2439 {
2440 Log.e("Navit", "Failed to extract navit.xml for hdpi device(s)");
2441 }
2442 }
2443 }
2444 // xhdpi display (320 dpi)
2445 else if (Navit.metrics.densityDpi >= 320)
2446 {
2447 // set the map display DPI down. otherwise everything will be very small and unreadable
2448 // and performance will be very low
2449 if (p.PREF_shrink_on_high_dpi)
2450 {
2451 NavitGraphics.Global_want_dpi = NavitGraphics.Global_Scaled_DPI_normal;
2452 }
2453 NavitGraphics.Global_want_dpi_other = NavitGraphics.Global_Scaled_DPI_normal;
2454
2455 Log.e("Navit", "found xhdpi device, this is not fully supported yet");
2456 Log.e("Navit", "using hdpi values for compatibility");
2457 my_display_density = "hdpi";
2458 if (xmlconfig_unpack_file)
2459 {
2460 if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2461 {
2462 Log.e("Navit", "Failed to extract navit.xml for xhdpi device(s)");
2463 }
2464 }
2465 }
2466 else
2467 {
2468 /* default, meaning we just dont know what display this is */
2469 if (xmlconfig_unpack_file)
2470 {
2471 if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2472 {
2473 Log.e("Navit", "Failed to extract navit.xml (default version)");
2474 }
2475 }
2476 }
2477 // Debug.startMethodTracing("calc");
2478
2479 // if (unsupported)
2480 // {
2481 // class CustomListener implements View.OnClickListener
2482 // {
2483 // private final Dialog dialog;
2484 //
2485 // public CustomListener(Dialog dialog)
2486 // {
2487 // this.dialog = dialog;
2488 // }
2489 //
2490 // @Override
2491 // public void onClick(View v)
2492 // {
2493 //
2494 // // Do whatever you want here
2495 //
2496 // // If tou want to close the dialog, uncomment the line below
2497 // //dialog.dismiss();
2498 // }
2499 // }
2500 //
2501 // AlertDialog.Builder dialog = new AlertDialog.Builder(this);
2502 // dialog.setTitle(Navit.get_text("WeltBild Tablet")); //TRANS
2503 // dialog.setCancelable(false);
2504 // dialog.setMessage("Your device is not supported!");
2505 // dialog.show();
2506 // //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
2507 // //theButton.setOnClickListener(new CustomListener(dialog));
2508 // }
2509
2510 int have_dpi = Navit.metrics.densityDpi;
2511
2512 System.out.println("Global_want_dpi[001]=" + NavitGraphics.Global_want_dpi + ":" + Navit.metrics.densityDpi + ":" + NavitGraphics.Global_dpi_factor + ":" + NavitGraphics.Global_dpi_factor_better);
2513
2514 if (NavitGraphics.Global_want_dpi == have_dpi)
2515 {
2516 NavitGraphics.Global_dpi_factor = 1;
2517 NavitGraphics.preview_coord_factor = 1;
2518 }
2519 else
2520 // this was missing??????!!!!!!!!!??????!!!!!!
2521 {
2522 NavitGraphics.Global_dpi_factor = ((float) NavitGraphics.Global_want_dpi / (float) have_dpi);
2523 NavitGraphics.preview_coord_factor = ((float) have_dpi / (float) NavitGraphics.Global_want_dpi);
2524 }
2525
2526 System.out.println("Global_want_dpi[002]=" + NavitGraphics.Global_dpi_factor + ":" + NavitGraphics.preview_coord_factor);
2527
2528 // gggggggggggggggggggggggggg new !!!!!!!!!!!!!!!!!!!!
2529
2530 // --> dont use!! NavitMain(this, langu, android.os.Build.VERSION.SDK_INT);
2531 Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
2532
2533 // -- report share dir back to C-code --
2534 //Message msg2 = new Message();
2535 //Bundle b2 = new Bundle();
2536 //b2.putInt("Callback", 82);
2537 //b2.putString("s", NAVIT_DATA_DIR + "/share/");
2538 //msg2.setData(b2);
2539 //N_NavitGraphics.callback_handler.sendMessage(msg2);
2540 // -- report share dir back to C-code --
2541
2542 // -- report data dir back to C-code --
2543 //msg2 = new Message();
2544 //b2 = new Bundle();
2545 //b2.putInt("Callback", 84);
2546 //b2.putString("s", NAVIT_DATA_DIR + "/");
2547 //msg2.setData(b2);
2548 //N_NavitGraphics.callback_handler.sendMessage(msg2);
2549 // -- report share dir back to C-code --
2550
2551 draw_osd_thread = new drawOSDThread();
2552 draw_osd_thread.start();
2553
2554 cwthr = new CWorkerThread();
2555 cwthr.start();
2556
2557 // --new--
2558 cwthr.StartMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), "" + Navit.metrics.densityDpi, NAVIT_DATA_DIR, NAVIT_DATA_SHARE_DIR);
2559
2560 // --old--
2561 // NavitMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density);
2562 // --old--
2563 // NavitActivity(3);
2564
2565 // CAUTION: don't use android.os.Build.VERSION.SDK_INT if <uses-sdk android:minSdkVersion="3" />
2566 // You will get exception on all devices with Android 1.5 and lower
2567 // because Build.VERSION.SDK_INT is since SDK 4 (Donut 1.6)
2568
2569 // (see: http://developer.android.com/guide/appendix/api-levels.html)
2570 // Platform Version API Level
2571 // =============================================
2572 // Android 4.0.3 15
2573 // Android 4.0, 4.0.1, 4.0.2 14
2574 // Android 3.2 13
2575 // Android 3.1 12
2576 // Android 3.0 11
2577 // Android 2.3.3 10
2578 // Android 2.3.1 9
2579 // Android 2.2 8
2580 // Android 2.1 7
2581 // Android 2.0.1 6
2582 // Android 2.0 5
2583 // Android 1.6 4
2584 // Android 1.5 3
2585 // Android 1.1 2
2586 // Android 1.0 1
2587
2588 Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
2589
2590 //try
2591 //{
2592 // Thread.sleep(2000);
2593 //}
2594 //catch (InterruptedException e)
2595 //{
2596 //}
2597
2598 //getPrefs();
2599 //activatePrefs();
2600
2601 // unpack some localized Strings
2602 // a test now, later we will unpack all needed strings for java, here at this point!!
2603 //String x = NavitGraphics.getLocalizedString("Austria");
2604 //Log.e("Navit", "x=" + x);
2605 Navit.show_mem_used();
2606
2607 /*
2608 * GpsStatus.Listener listener = new GpsStatus.Listener()
2609 * {
2610 * public void onGpsStatusChanged(int event)
2611 * {
2612 * //System.out.println("xxxxx");
2613 * if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS)
2614 * {
2615 * }
2616 * }
2617 * };
2618 */
2619
2620 try
2621 {
2622 Intent sintent = new Intent();
2623 sintent.setPackage("com.zoffcc.applications.zanavi_msg");
2624 sintent.setAction("com.zoffcc.applications.zanavi_msg.ZanaviCloudService");
2625 // ComponentName cname = startService(sintent);
2626 // Log.i("NavitPlugin", "start Service res=" + cname);
2627 // System.out.println("NavitPlugin:bind to Service");
2628 boolean res_bind = bindService(sintent, serviceConnection, Context.BIND_AUTO_CREATE);
2629 // Log.i("NavitPlugin", "bind to Service res=" + res_bind);
2630 }
2631 catch (Exception e)
2632 {
2633 e.printStackTrace();
2634 }
2635 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
2636 }
2637
2638 public static void show_mem_used() // wrapper
2639 {
2640 try
2641 {
2642 Message msg = Navit_progress_h.obtainMessage();
2643 Bundle b = new Bundle();
2644 msg.what = 14;
2645 msg.setData(b);
2646 Navit_progress_h.sendMessage(msg);
2647 }
2648 catch (Exception e)
2649 {
2650 e.printStackTrace();
2651 }
2652 }
2653
2654 public static void show_mem_used_real()
2655 {
2656 try
2657 {
2658 if (p.PREF_show_debug_messages)
2659 {
2660 // --------- OLD method -----------
2661 // --------- OLD method -----------
2662 // int usedMegs;
2663 // //System.gc();
2664 // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
2665 // //Debug.MemoryInfo meminfo = new Debug.MemoryInfo();
2666 // //Debug.getMemoryInfo(meminfo);
2667 //
2668 // if (usedMegs_old != usedMegs)
2669 // {
2670 // String usedMegsString = String.format("Memory Used: %d MB", usedMegs);
2671 // //System.out.println("" + meminfo.dalvikPrivateDirty + " " + meminfo.dalvikPss + " " + meminfo.dalvikSharedDirty + " nP:" + meminfo.nativePrivateDirty + " nPss:" + meminfo.nativePss + " nSh:" + meminfo.nativeSharedDirty + " o1:" + meminfo.otherPrivateDirty + " o2:" + meminfo.otherPss + " o3:" + meminfo.otherSharedDirty);
2672 // Navit.set_debug_messages2(usedMegsString);
2673 // }
2674 // usedMegs_old = usedMegs;
2675 // --------- OLD method -----------
2676 // --------- OLD method -----------
2677
2678 // --------- NEW method -----------
2679 // --------- NEW method -----------
2680 String usedMegs = logHeap(Global_Navit_Object.getClass());
2681 if (usedMegs_str_old.compareTo(usedMegs) != 0)
2682 {
2683 Navit.set_debug_messages2(usedMegs);
2684 }
2685 usedMegs_str_old = usedMegs;
2686 // --------- NEW method -----------
2687 // --------- NEW method -----------
2688 }
2689 }
2690 catch (Exception e)
2691 {
2692 e.printStackTrace();
2693 }
2694 }
2695
2696 public static void set_debug_messages(String texta, String textb, String textc)
2697 {
2698 try
2699 {
2700 NavitGraphics.debug_line_1 = texta;
2701 NavitGraphics.debug_line_2 = textb;
2702 NavitGraphics.debug_line_3 = textc;
2703 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2704 NavitGraphics.NavitMsgTv_.setLines(4);
2705 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2706 //System.out.println("invalidate 022");
2707 NavitGraphics.NavitMsgTv_.postInvalidate();
2708 }
2709 catch (Exception e)
2710 {
2711 e.printStackTrace();
2712 }
2713 }
2714
2715 public static void set_debug_messages1(String text)
2716 {
2717 try
2718 {
2719 NavitGraphics.debug_line_1 = text;
2720 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2721 NavitGraphics.NavitMsgTv_.setLines(4);
2722 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2723 //System.out.println("invalidate 023");
2724 NavitGraphics.NavitMsgTv_.postInvalidate();
2725 }
2726 catch (Exception e)
2727 {
2728 e.printStackTrace();
2729 }
2730 }
2731
2732 public static void set_debug_messages2(String text)
2733 {
2734 try
2735 {
2736 NavitGraphics.debug_line_2 = text;
2737 //NavitGraphics.NavitMsgTv_.setMaxLines(4);
2738 //NavitGraphics.NavitMsgTv_.setLines(4);
2739
2740 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2741 //System.out.println("invalidate 024");
2742 NavitGraphics.NavitMsgTv_.postInvalidate();
2743 }
2744 catch (Exception e)
2745 {
2746 e.printStackTrace();
2747 }
2748 }
2749
2750 public static void set_debug_messages3(String text)
2751 {
2752 try
2753 {
2754 NavitGraphics.debug_line_3 = text;
2755 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2756 NavitGraphics.NavitMsgTv_.setLines(4);
2757 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2758 //System.out.println("invalidate 025");
2759 NavitGraphics.NavitMsgTv_.postInvalidate();
2760 }
2761 catch (Exception e)
2762 {
2763 e.printStackTrace();
2764 }
2765 }
2766
2767 public static void set_debug_messages4(String text)
2768 {
2769 try
2770 {
2771 NavitGraphics.debug_line_4 = text;
2772 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2773 NavitGraphics.NavitMsgTv_.setLines(4);
2774 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2775 //System.out.println("invalidate 026");
2776 NavitGraphics.NavitMsgTv_.postInvalidate();
2777 }
2778 catch (Exception e)
2779 {
2780 e.printStackTrace();
2781 }
2782 }
2783
2784 public static void set_debug_messages3_wrapper(String text)
2785 {
2786 try
2787 {
2788 Message msg = Navit_progress_h.obtainMessage();
2789 Bundle b = new Bundle();
2790 msg.what = 15;
2791 b.putString("text", text);
2792 msg.setData(b);
2793 Navit_progress_h.sendMessage(msg);
2794 }
2795 catch (Exception e)
2796 {
2797 e.printStackTrace();
2798 }
2799 }
2800
2801 public static void set_debug_messages_say_wrapper(String text)
2802 {
2803 try
2804 {
2805 Message msg = Navit_progress_h.obtainMessage();
2806 Bundle b = new Bundle();
2807 msg.what = 30;
2808 b.putString("text", text);
2809 msg.setData(b);
2810 Navit_progress_h.sendMessage(msg);
2811 }
2812 catch (Exception e)
2813 {
2814 e.printStackTrace();
2815 }
2816 }
2817
2818 protected void onNewIntent(Intent intent)
2819 {
2820 super.onNewIntent(intent);
2821
2822 try
2823 {
2824 System.out.println("XXIIXX(2):111");
2825 String mid_str = intent.getExtras().getString("com.zoffcc.applications.zanavi.mid");
2826
2827 System.out.println("XXIIXX(2):111a:mid_str=" + mid_str);
2828
2829 if (mid_str != null)
2830 {
2831 if (mid_str.equals("201:UPDATE-APP"))
2832 {
2833 // a new ZANavi version is available, show something to the user here -------------------
2834 // a new ZANavi version is available, show something to the user here -------------------
2835 // a new ZANavi version is available, show something to the user here -------------------
2836 // a new ZANavi version is available, show something to the user here -------------------
2837 // a new ZANavi version is available, show something to the user here -------------------
2838 // a new ZANavi version is available, show something to the user here -------------------
2839 }
2840 else if (mid_str.startsWith("202:UPDATE-MAP:"))
2841 {
2842 // System.out.println("need to update1:" + mid_str);
2843 // System.out.println("need to update2:" + mid_str.substring(15));
2844
2845 auto_start_update_map(mid_str.substring(15));
2846 }
2847 }
2848
2849 System.out.println("XXIIXX(2):111b:mid_str=" + mid_str);
2850 }
2851 catch (Exception e)
2852 {
2853 e.printStackTrace();
2854 System.out.println("XXIIXX(2):111:EEEE");
2855 }
2856
2857 // ---- Intent dump ----
2858 // ---- Intent dump ----
2859 // ---- Intent dump ----
2860 // ---- Intent dump ----
2861 try
2862 {
2863 System.out.println("XXIIXX(2):" + intent);
2864 Bundle bundle77 = intent.getExtras();
2865 System.out.println("XXIIXX(2):" + intent_flags_to_string(intent.getFlags()));
2866 if (bundle77 == null)
2867 {
2868 System.out.println("XXIIXX(2):" + "null");
2869 }
2870 else
2871 {
2872 for (String key : bundle77.keySet())
2873 {
2874 Object value = bundle77.get(key);
2875 System.out.println("XXIIXX(2):" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
2876 }
2877 }
2878 }
2879 catch (Exception ee22)
2880 {
2881 String exst = Log.getStackTraceString(ee22);
2882 System.out.println("XXIIXX(2):ERR:" + exst);
2883 }
2884 // ---- Intent dump ----
2885 // ---- Intent dump ----
2886 // ---- Intent dump ----
2887 // ---- Intent dump ----
2888
2889 Log.e("Navit", "3:**1**A " + intent.getAction());
2890 Log.e("Navit", "3:**1**D " + intent.getDataString());
2891 Log.e("Navit", "3:**1**S " + intent.toString());
2892 try
2893 {
2894 Log.e("Navit", "3:**1**S " + intent.getExtras().describeContents());
2895 }
2896 catch (Exception ee3)
2897 {
2898 }
2899
2900 // if (Navit.startup_intent == null)
2901 {
2902 try
2903 {
2904 // make a copy of the given intent object
2905 // Navit.startup_intent = intent.cloneFilter();
2906 Navit.startup_intent = intent;
2907
2908 Log.e("Navit", "3a:**1**001");
2909 Bundle extras2 = intent.getExtras();
2910 Log.e("Navit", "3a:**1**002");
2911 try
2912 {
2913 Navit.startup_intent.putExtras(extras2);
2914 Log.e("Navit", "3a:**1**003");
2915 }
2916 catch (Exception e4)
2917 {
2918 if (startup_intent.getDataString() != null)
2919 {
2920 // we have a "geo:" thingy intent, use it
2921 // or "gpx file"
2922 Log.e("Navit", "3c:**1**A " + startup_intent.getAction());
2923 Log.e("Navit", "3c:**1**D " + startup_intent.getDataString());
2924 Log.e("Navit", "3c:**1**S " + startup_intent.toString());
2925 }
2926 else
2927 {
2928 Log.e("Navit", "3X:**1**X ");
2929 Navit.startup_intent = null;
2930 }
2931
2932 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
2933 Navit.startup_intent_timestamp = System.currentTimeMillis();
2934
2935 return;
2936 }
2937
2938 // Intent { act=android.intent.action.VIEW
2939 // cat=[android.intent.category.DEFAULT]
2940 // dat=file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
2941 // cmp=com.zoffcc.applications.zanavi/.Navit }
2942
2943 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
2944 Navit.startup_intent_timestamp = System.currentTimeMillis();
2945 Log.e("Navit", "3a:**1**A " + startup_intent.getAction());
2946 Log.e("Navit", "3a:**1**D " + startup_intent.getDataString());
2947 Log.e("Navit", "3a:**1**S " + startup_intent.toString());
2948 if (extras2 != null)
2949 {
2950 long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
2951 // System.out.println("DH:a007 l=" + l);
2952 if (l != 0L)
2953 {
2954 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
2955 {
2956 // Log.e("Navit", "2:**1** started via drive home");
2957 // we have been called from "drive home" widget
2958
2959 // drive home
2960
2961 // check if we have a home location
2962 int home_id = find_home_point();
2963
2964 if (home_id != -1)
2965 {
2966 Message msg7 = progress_handler.obtainMessage();
2967 Bundle b7 = new Bundle();
2968 msg7.what = 2; // long Toast message
2969 b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
2970 msg7.setData(b7);
2971 progress_handler.sendMessage(msg7);
2972
2973 // clear any previous destinations
2974 Message msg2 = new Message();
2975 Bundle b2 = new Bundle();
2976 b2.putInt("Callback", 7);
2977 msg2.setData(b2);
2978 NavitGraphics.callback_handler.sendMessage(msg2);
2979
2980 // set position to middle of screen -----------------------
2981 // set position to middle of screen -----------------------
2982 // set position to middle of screen -----------------------
2983 // Message msg67 = new Message();
2984 // Bundle b67 = new Bundle();
2985 // b67.putInt("Callback", 51);
2986 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
2987 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
2988 // msg67.setData(b67);
2989 // N_NavitGraphics.callback_handler.sendMessage(msg67);
2990 // set position to middle of screen -----------------------
2991 // set position to middle of screen -----------------------
2992 // set position to middle of screen -----------------------
2993
2994 try
2995 {
2996 Thread.sleep(60);
2997 }
2998 catch (Exception e)
2999 {
3000 }
3001
3002 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);
3003
3004 // Navit.destination_set();
3005 //
3006 // // set destination to home location
3007 // String lat = String.valueOf(map_points.get(home_id).lat);
3008 // String lon = String.valueOf(map_points.get(home_id).lon);
3009 // String q = map_points.get(home_id).point_name;
3010 //
3011 // // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
3012 //
3013 // Message msg55 = new Message();
3014 // Bundle b55 = new Bundle();
3015 // b55.putInt("Callback", 3);
3016 // b55.putString("lat", lat);
3017 // b55.putString("lon", lon);
3018 // b55.putString("q", q);
3019 // msg55.setData(b55);
3020 // NavitGraphics.callback_handler.sendMessage(msg55);
3021
3022 final Thread zoom_to_route_001 = new Thread()
3023 {
3024 int wait = 1;
3025 int count = 0;
3026 int max_count = 60;
3027
3028 @Override
3029 public void run()
3030 {
3031 while (wait == 1)
3032 {
3033 try
3034 {
3035 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3036 {
3037 zoom_to_route();
3038 wait = 0;
3039 }
3040 else
3041 {
3042 wait = 1;
3043 }
3044
3045 count++;
3046 if (count > max_count)
3047 {
3048 wait = 0;
3049 }
3050 else
3051 {
3052 Thread.sleep(400);
3053 }
3054 }
3055 catch (Exception e)
3056 {
3057 }
3058 }
3059 }
3060 };
3061 zoom_to_route_001.start();
3062
3063 // try
3064 // {
3065 // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3066 // }
3067 // catch (Exception e2)
3068 // {
3069 // e2.printStackTrace();
3070 // }
3071
3072 try
3073 {
3074 Navit.follow_button_on();
3075 }
3076 catch (Exception e2)
3077 {
3078 e2.printStackTrace();
3079 }
3080 }
3081 else
3082 {
3083 // no home location set
3084 Message msg = progress_handler.obtainMessage();
3085 Bundle b = new Bundle();
3086 msg.what = 2; // long Toast message
3087 b.putString("text", Navit.get_text("No Home Location set")); //TRANS
3088 msg.setData(b);
3089 progress_handler.sendMessage(msg);
3090 }
3091
3092 }
3093 }
3094 else
3095 {
3096 if (startup_intent.getDataString() != null)
3097 {
3098 // we have a "geo:" thingy intent, use it
3099 // or "gpx file"
3100 }
3101 else
3102 {
3103 Navit.startup_intent = null;
3104 }
3105 }
3106 }
3107 else
3108 {
3109 if (startup_intent.getDataString() != null)
3110 {
3111 // we have a "geo:" thingy intent, use it
3112 }
3113 else
3114 {
3115 Navit.startup_intent = null;
3116 }
3117 }
3118 }
3119 catch (Exception e99)
3120 {
3121 Navit.startup_intent = null;
3122 }
3123
3124 }
3125
3126 }
3127
3128 @Override
3129 public void onStart()
3130 {
3131 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3132
3133 Navit.show_mem_used();
3134
3135 super.onStart();
3136
3137 Log.e("Navit", "OnStart");
3138
3139 while (Global_Init_Finished == 0)
3140 {
3141 Log.e("Navit", "OnStart:Global_Init_Finished==0 !!!!!");
3142 try
3143 {
3144 Thread.sleep(60, 0); // sleep
3145 }
3146 catch (InterruptedException e)
3147 {
3148 }
3149 }
3150
3151 cwthr.NavitActivity2(2);
3152
3153 getPrefs();
3154 activatePrefs();
3155 sun_moon__mLastCalcSunMillis = -1L;
3156
3157 // paint for bitmapdrawing on map
3158 if (p.PREF_use_anti_aliasing)
3159 {
3160 NavitGraphics.paint_for_map_display.setAntiAlias(true);
3161 }
3162 else
3163 {
3164 NavitGraphics.paint_for_map_display.setAntiAlias(false);
3165 }
3166 if (p.PREF_use_map_filtering)
3167 {
3168 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
3169 }
3170 else
3171 {
3172 NavitGraphics.paint_for_map_display.setFilterBitmap(false);
3173 }
3174
3175 // activate gps AFTER 3g-location
3176 NavitVehicle.turn_on_precise_provider();
3177
3178 Navit.show_mem_used();
3179
3180 // restore points
3181 read_map_points();
3182
3183 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3184 }
3185
3186 @Override
3187 public void onRestart()
3188 {
3189 super.onRestart();
3190 Log.e("Navit", "OnRestart");
3191
3192 while (Global_Init_Finished == 0)
3193 {
3194 Log.e("Navit", "onRestart:Global_Init_Finished==0 !!!!!");
3195 try
3196 {
3197 Thread.sleep(60, 0); // sleep
3198 }
3199 catch (InterruptedException e)
3200 {
3201 }
3202 }
3203
3204 cwthr.NavitActivity2(0);
3205 NavitVehicle.turn_on_sat_status();
3206 }
3207
3208 @SuppressLint("NewApi")
3209 @Override
3210 public void onResume()
3211 {
3212 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3213
3214 // System.gc();
3215 super.onResume();
3216
3217 // get the intent fresh !! ----------
3218 startup_intent = this.getIntent();
3219 // get the intent fresh !! ----------
3220
3221 PackageInfo pkgInfo;
3222 Navit_Plugin_001_Installed = false;
3223 try
3224 {
3225 // is the donate version installed?
3226 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_msg", 0);
3227 String sharedUserId = pkgInfo.sharedUserId;
3228 System.out.println("str nd=" + sharedUserId);
3229 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
3230 {
3231 System.out.println("##plugin 001##");
3232 Navit_Plugin_001_Installed = true;
3233 }
3234 }
3235 catch (Exception e)
3236 {
3237 e.printStackTrace();
3238 }
3239
3240 // ---- Intent dump ----
3241 // ---- Intent dump ----
3242 // ---- Intent dump ----
3243 // ---- Intent dump ----
3244
3245 try
3246 {
3247 System.out.println("XXIIXX:111");
3248 String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid");
3249 System.out.println("XXIIXX:111a:mid_str=" + mid_str);
3250
3251 if (mid_str != null)
3252 {
3253 if (mid_str.equals("201:UPDATE-APP"))
3254 {
3255 // a new ZANavi version is available, show something to the user here -------------------
3256 // a new ZANavi version is available, show something to the user here -------------------
3257 // a new ZANavi version is available, show something to the user here -------------------
3258 // a new ZANavi version is available, show something to the user here -------------------
3259 // a new ZANavi version is available, show something to the user here -------------------
3260 // a new ZANavi version is available, show something to the user here -------------------
3261 }
3262 else if (mid_str.startsWith("202:UPDATE-MAP:"))
3263 {
3264 System.out.println("need to update1:" + mid_str);
3265 System.out.println("need to update2:" + mid_str.substring(15));
3266
3267 auto_start_update_map(mid_str.substring(15));
3268 }
3269 }
3270
3271 System.out.println("XXIIXX:111b:mid_str=" + mid_str);
3272 }
3273 catch (Exception e)
3274 {
3275 e.printStackTrace();
3276 System.out.println("XXIIXX:111:EEEE");
3277 }
3278
3279 try
3280 {
3281 System.out.println("XXIIXX:" + this.getIntent());
3282 Bundle bundle77 = this.getIntent().getExtras();
3283 System.out.println("XXIIXX:" + intent_flags_to_string(this.getIntent().getFlags()));
3284 if (bundle77 == null)
3285 {
3286 System.out.println("XXIIXX:" + "null");
3287 }
3288 else
3289 {
3290 for (String key : bundle77.keySet())
3291 {
3292 Object value = bundle77.get(key);
3293 System.out.println("XXIIXX:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
3294 }
3295 }
3296 }
3297 catch (Exception ee22)
3298 {
3299 String exst = Log.getStackTraceString(ee22);
3300 System.out.println("XXIIXX:ERR:" + exst);
3301 }
3302 // ---- Intent dump ----
3303 // ---- Intent dump ----
3304 // ---- Intent dump ----
3305 // ---- Intent dump ----
3306
3307 is_paused = false;
3308
3309 Navit_doubleBackToExitPressedOnce = false;
3310
3311 app_window = getWindow();
3312
3313 Log.e("Navit", "OnResume");
3314
3315 while (Global_Init_Finished == 0)
3316 {
3317 Log.e("Navit", "OnResume:Global_Init_Finished==0 !!!!!");
3318 try
3319 {
3320 Thread.sleep(30, 0); // sleep
3321 }
3322 catch (InterruptedException e)
3323 {
3324 }
3325 }
3326
3327 //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
3328 cwthr.NavitActivity2(1);
3329
3330 try
3331 {
3332 NSp.resume_me();
3333 }
3334 catch (Exception e)
3335 {
3336 e.printStackTrace();
3337 }
3338
3339 NavitVehicle.turn_on_sat_status();
3340
3341 try
3342 {
3343 if (wl != null)
3344 {
3345 // try
3346 // {
3347 // wl.release();
3348 // }
3349 // catch (Exception e2)
3350 // {
3351 // }
3352 wl.acquire();
3353 Log.e("Navit", "WakeLock: acquire 2");
3354 }
3355 }
3356 catch (Exception e)
3357 {
3358 e.printStackTrace();
3359 }
3360
3361 //Intent caller = this.getIntent();
3362 //System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
3363 //System.out.println("C=" + caller.getComponent().flattenToString());
3364
3365 if (unsupported)
3366 {
3367 class CustomListener implements View.OnClickListener
3368 {
3369 private final Dialog dialog;
3370
3371 public CustomListener(Dialog dialog)
3372 {
3373 this.dialog = dialog;
3374 }
3375
3376 @Override
3377 public void onClick(View v)
3378 {
3379
3380 // Do whatever you want here
3381
3382 // If you want to close the dialog, uncomment the line below
3383 //dialog.dismiss();
3384 }
3385 }
3386
3387 AlertDialog.Builder dialog = new AlertDialog.Builder(this);
3388 dialog.setTitle("WeltBild Tablet");
3389 dialog.setCancelable(false);
3390 dialog.setMessage("Your device is not supported!");
3391 dialog.show();
3392 //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
3393 //theButton.setOnClickListener(new CustomListener(dialog));
3394 }
3395
3396 // reset "maps too old" flag
3397 Navit_maps_too_old = false;
3398
3399 if (Navit_maps_loaded == false)
3400 {
3401 Navit_maps_loaded = true;
3402 // activate all maps
3403 Log.e("Navit", "**** LOAD ALL MAPS **** start");
3404 Message msg3 = new Message();
3405 Bundle b3 = new Bundle();
3406 b3.putInt("Callback", 20);
3407 msg3.setData(b3);
3408 NavitGraphics.callback_handler.sendMessage(msg3);
3409 Log.e("Navit", "**** LOAD ALL MAPS **** end");
3410 }
3411
3412 try
3413 {
3414 if (!have_maps_installed())
3415 {
3416 // System.out.println("MMMM=no maps installed");
3417 // show semi transparent box "no maps installed" ------------------
3418 // show semi transparent box "no maps installed" ------------------
3419 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
3420 try
3421 {
3422 NavitGraphics.no_maps_container.setActivated(true);
3423 }
3424 catch (NoSuchMethodError e)
3425 {
3426 }
3427
3428 show_case_001();
3429
3430 // show semi transparent box "no maps installed" ------------------
3431 // show semi transparent box "no maps installed" ------------------
3432 }
3433 else
3434 {
3435 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
3436 try
3437 {
3438 NavitGraphics.no_maps_container.setActivated(false);
3439 }
3440 catch (NoSuchMethodError e)
3441 {
3442 }
3443 }
3444 }
3445 catch (Exception e)
3446 {
3447 e.printStackTrace();
3448 }
3449
3450 try
3451 {
3452 // draw map no-async
3453 Message msg = new Message();
3454 Bundle b = new Bundle();
3455 b.putInt("Callback", 64);
3456 msg.setData(b);
3457 NavitGraphics.callback_handler.sendMessage(msg);
3458 }
3459 catch (Exception e)
3460 {
3461 e.printStackTrace();
3462 }
3463
3464 String intent_data = null;
3465 try
3466 {
3467 //Log.e("Navit", "**9**A " + startup_intent.getAction());
3468 //Log.e("Navit", "**9**D " + startup_intent.getDataString());
3469
3470 int type = 1; // default = assume it's a map coords intent
3471
3472 try
3473 {
3474 String si = startup_intent.getDataString();
3475 String tmp2 = si.split(":", 2)[0];
3476 Log.e("Navit", "**9a**A " + startup_intent.getAction());
3477 Log.e("Navit", "**9a**D " + startup_intent.getDataString() + " " + tmp2);
3478 if (tmp2.equals("file"))
3479 {
3480 Log.e("Navit", "**9b**D " + startup_intent.getDataString() + " " + tmp2);
3481 if (si.toLowerCase().endsWith(".gpx"))
3482 {
3483 Log.e("Navit", "**9c**D " + startup_intent.getDataString() + " " + tmp2);
3484 type = 4;
3485 }
3486 }
3487 }
3488 catch (Exception e2)
3489 {
3490 }
3491
3492 if (type != 4)
3493 {
3494 Bundle extras = startup_intent.getExtras();
3495 // System.out.println("DH:001");
3496 if (extras != null)
3497 {
3498 // System.out.println("DH:002");
3499 long l = extras.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
3500 // System.out.println("DH:003 l=" + l);
3501 if (l != 0L)
3502 {
3503 // System.out.println("DH:004");
3504 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
3505 {
3506 // System.out.println("DH:005");
3507 type = 2; // call from drive-home-widget
3508 }
3509 // ok, now remove that key
3510 extras.remove("com.zoffcc.applications.zanavi");
3511 startup_intent.replaceExtras((Bundle) null);
3512 // System.out.println("DH:006");
3513 }
3514 }
3515 }
3516
3517 // ------------------------ BIG LOOP ------------------------
3518 // ------------------------ BIG LOOP ------------------------
3519 if (type == 2)
3520 {
3521 // drive home
3522
3523 // check if we have a home location
3524 int home_id = find_home_point();
3525
3526 if (home_id != -1)
3527 {
3528 Message msg7 = progress_handler.obtainMessage();
3529 Bundle b7 = new Bundle();
3530 msg7.what = 2; // long Toast message
3531 b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
3532 msg7.setData(b7);
3533 progress_handler.sendMessage(msg7);
3534
3535 // clear any previous destinations
3536 Message msg2 = new Message();
3537 Bundle b2 = new Bundle();
3538 b2.putInt("Callback", 7);
3539 msg2.setData(b2);
3540 NavitGraphics.callback_handler.sendMessage(msg2);
3541
3542 // set position to middle of screen -----------------------
3543 // set position to middle of screen -----------------------
3544 // set position to middle of screen -----------------------
3545 // Message msg67 = new Message();
3546 // Bundle b67 = new Bundle();
3547 // b67.putInt("Callback", 51);
3548 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
3549 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
3550 // msg67.setData(b67);
3551 // N_NavitGraphics.callback_handler.sendMessage(msg67);
3552 // set position to middle of screen -----------------------
3553 // set position to middle of screen -----------------------
3554 // set position to middle of screen -----------------------
3555
3556 try
3557 {
3558 Thread.sleep(60);
3559 }
3560 catch (Exception e)
3561 {
3562 }
3563
3564 Navit.destination_set();
3565
3566 // set destination to home location
3567 // String lat = String.valueOf(map_points.get(home_id).lat);
3568 // String lon = String.valueOf(map_points.get(home_id).lon);
3569 // String q = map_points.get(home_id).point_name;
3570 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);
3571
3572 final Thread zoom_to_route_001 = new Thread()
3573 {
3574 int wait = 1;
3575 int count = 0;
3576 int max_count = 60;
3577
3578 @Override
3579 public void run()
3580 {
3581 while (wait == 1)
3582 {
3583 try
3584 {
3585 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3586 {
3587 zoom_to_route();
3588 wait = 0;
3589 }
3590 else
3591 {
3592 wait = 1;
3593 }
3594
3595 count++;
3596 if (count > max_count)
3597 {
3598 wait = 0;
3599 }
3600 else
3601 {
3602 Thread.sleep(400);
3603 }
3604 }
3605 catch (Exception e)
3606 {
3607 }
3608 }
3609 }
3610 };
3611 zoom_to_route_001.start();
3612
3613 // try
3614 // {
3615 // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3616 // }
3617 // catch (Exception e2)
3618 // {
3619 // e2.printStackTrace();
3620 // }
3621
3622 try
3623 {
3624 Navit.follow_button_on();
3625 }
3626 catch (Exception e2)
3627 {
3628 e2.printStackTrace();
3629 }
3630 }
3631 else
3632 {
3633 // no home location set
3634 Message msg = progress_handler.obtainMessage();
3635 Bundle b = new Bundle();
3636 msg.what = 2; // long Toast message
3637 b.putString("text", Navit.get_text("No Home Location set")); //TRANS
3638 msg.setData(b);
3639 progress_handler.sendMessage(msg);
3640 }
3641 }
3642 else if (type == 4)
3643 {
3644
3645 if (startup_intent != null)
3646 {
3647 // Log.e("Navit", "**7**A " + startup_intent.getAction() + System.currentTimeMillis() + " " + Navit.startup_intent_timestamp);
3648 if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
3649 {
3650 Log.e("Navit", "**7**A " + startup_intent.getAction());
3651 Log.e("Navit", "**7**D " + startup_intent.getDataString());
3652 intent_data = startup_intent.getDataString();
3653 try
3654 {
3655 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
3656 }
3657 catch (Exception e1)
3658 {
3659 e1.printStackTrace();
3660 }
3661
3662 // we consumed the intent, so reset timestamp value to avoid double consuming of event
3663 Navit.startup_intent_timestamp = 0L;
3664
3665 if (intent_data != null)
3666 {
3667 // file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
3668 String tmp1;
3669 tmp1 = intent_data.split(":", 2)[1].substring(2);
3670
3671 Log.e("Navit", "**7**f=" + tmp1);
3672
3673 // convert gpx file ---------------------
3674 convert_gpx_file_real(tmp1);
3675 }
3676 }
3677 }
3678 }
3679 else if (type == 1)
3680 {
3681 if (startup_intent != null)
3682 {
3683 if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
3684 {
3685 Log.e("Navit", "**2**A " + startup_intent.getAction());
3686 Log.e("Navit", "**2**D " + startup_intent.getDataString());
3687 intent_data = startup_intent.getDataString();
3688 // we consumed the intent, so reset timestamp value to avoid double consuming of event
3689 Navit.startup_intent_timestamp = 0L;
3690
3691 if (intent_data != null)
3692 {
3693 // set position to middle of screen -----------------------
3694 // set position to middle of screen -----------------------
3695 // set position to middle of screen -----------------------
3696 // Message msg67 = new Message();
3697 // Bundle b67 = new Bundle();
3698 // b67.putInt("Callback", 51);
3699 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
3700 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
3701 // msg67.setData(b67);
3702 // N_NavitGraphics.callback_handler.sendMessage(msg67);
3703 // set position to middle of screen -----------------------
3704 // set position to middle of screen -----------------------
3705 // set position to middle of screen -----------------------
3706 }
3707 }
3708 else
3709 {
3710 Log.e("Navit", "timestamp for navigate_to expired! not using data");
3711 }
3712 }
3713
3714 System.out.println("SUI:000a " + intent_data);
3715
3716 if ((intent_data != null) && ((substring_without_ioobe(intent_data, 0, 18).equals("google.navigation:")) || (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/")) || (substring_without_ioobe(intent_data, 0, 24).equals("https://maps.google.com/"))))
3717 {
3718
3719 System.out.println("SUI:000b");
3720
3721 // better use regex later, but for now to test this feature its ok :-)
3722 // better use regex later, but for now to test this feature its ok :-)
3723
3724 // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
3725 // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
3726 // b: google.navigation:q=48.25676,16.643
3727 // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
3728 // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
3729 // sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
3730 // -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
3731 // f: google.navigation:ll=48.25676,16.643&...
3732 // c: google.navigation:ll=48.25676,16.643
3733 // h: http://maps.google.com/?q=48.222210,16.387058&z=16
3734 // i: https://maps.google.com/?q=48.222210,16.387058&z=16
3735 // i:,h: https://maps.google.com/maps/place?ftid=0x476d07075e933fc5:0xccbeba7fe1e3dd36&q=48.222210,16.387058&ui=maps_mini
3736 //
3737 // ??!!new??!!: http://maps.google.com/?cid=10549738100504591748&hl=en&gl=gb
3738
3739 String lat;
3740 String lon;
3741 String q;
3742
3743 String temp1 = null;
3744 String temp2 = null;
3745 String temp3 = null;
3746 boolean parsable = false;
3747 boolean unparsable_info_box = true;
3748 try
3749 {
3750 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
3751 }
3752 catch (Exception e1)
3753 {
3754 e1.printStackTrace();
3755 }
3756
3757 // DEBUG
3758 // DEBUG
3759 // DEBUG
3760 // intent_data = "google.navigation:q=Wien Burggasse 27";
3761 // intent_data = "google.navigation:q=48.25676,16.643";
3762 // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
3763 // intent_data = "google.navigation:ll=48.25676,16.643";
3764 // DEBUG
3765 // DEBUG
3766 // DEBUG
3767
3768 try
3769 {
3770 Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
3771 Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
3772 Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
3773 Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
3774 Log.e("Navit", "found DEBUG 4.1: yy" + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
3775 Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
3776 }
3777 catch (Exception e)
3778 {
3779 e.printStackTrace();
3780 }
3781
3782 if (!Navit.NavitStartupAlreadySearching)
3783 {
3784 if (intent_data.length() > 19)
3785 {
3786 // if h: then show target
3787 if (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/"))
3788 {
3789 Uri uri = Uri.parse(intent_data);
3790 Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
3791 parsable = true;
3792 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3793 }
3794 // if i: then show target
3795 else if (substring_without_ioobe(intent_data, 0, 24).equals("https://maps.google.com/"))
3796 {
3797 Uri uri = Uri.parse(intent_data);
3798 Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
3799 parsable = true;
3800 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3801 }
3802 // if d: then start target search
3803 else if ((substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q=")) && ((!substring_without_ioobe(intent_data, 20, 21).equals('+')) && (!substring_without_ioobe(intent_data, 20, 21).equals('-')) && (!substring_without_ioobe(intent_data, 20, 22).matches("[0-9][0-9]"))))
3804 {
3805 Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
3806 Navit.NavitStartupAlreadySearching = true;
3807 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
3808 // dont use this here, already starting search, so set to "false"
3809 parsable = false;
3810 unparsable_info_box = false;
3811 }
3812 // if b: then remodel the input string to look like a:
3813 else if (substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q="))
3814 {
3815 intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
3816 Log.e("Navit", "target found (b): " + intent_data);
3817 parsable = true;
3818 }
3819 // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
3820 else if (substring_without_ioobe(intent_data, 0, 25).equals("google.navigation:///?ll="))
3821 {
3822 intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
3823 Log.e("Navit", "target found (g): " + intent_data);
3824 parsable = true;
3825 }
3826 // if e: then remodel the input string to look like a:
3827 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1) && (substring_without_ioobe(intent_data.split("&")[1], 0, 1).toLowerCase().equals("f")))
3828 {
3829 int idx = intent_data.indexOf("&");
3830 intent_data = substring_without_ioobe(intent_data, 0, idx) + "&q=Target";
3831 Log.e("Navit", "target found (e): " + intent_data);
3832 parsable = true;
3833 }
3834 // if f: then remodel the input string to look like a:
3835 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
3836 {
3837 int idx = intent_data.indexOf("&");
3838 intent_data = intent_data.substring(0, idx) + "&q=Target";
3839 Log.e("Navit", "target found (f): " + intent_data);
3840 parsable = true;
3841 }
3842 // already looks like a: just set flag
3843 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
3844 {
3845 // dummy, just set the flag
3846 Log.e("Navit", "target found (a): " + intent_data);
3847 Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
3848 parsable = true;
3849 }
3850 // if c: then remodel the input string to look like a:
3851 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
3852 {
3853
3854 intent_data = intent_data + "&q=Target";
3855 Log.e("Navit", "target found (c): " + intent_data);
3856 parsable = true;
3857 }
3858 }
3859 }
3860 else
3861 {
3862 Log.e("Navit", "already started search from startup intent");
3863 parsable = false;
3864 unparsable_info_box = false;
3865 }
3866
3867 if (parsable)
3868 {
3869 // now string should be in form --> a:
3870 // now split the parts off
3871 temp1 = intent_data.split("&q=", -1)[0];
3872 try
3873 {
3874 temp3 = temp1.split("ll=", -1)[1];
3875 temp2 = intent_data.split("&q=", -1)[1];
3876 }
3877 catch (Exception e)
3878 {
3879 // java.lang.ArrayIndexOutOfBoundsException most likely
3880 // so let's assume we dont have '&q=xxxx'
3881 temp3 = temp1;
3882 }
3883
3884 if (temp2 == null)
3885 {
3886 // use some default name
3887 temp2 = "Target";
3888 }
3889
3890 lat = temp3.split(",", -1)[0];
3891 lon = temp3.split(",", -1)[1];
3892 q = temp2;
3893 // is the "search name" url-encoded? i think so, lets url-decode it here
3894 q = URLDecoder.decode(q);
3895 // System.out.println();
3896
3897 Navit.remember_destination(q, lat, lon);
3898 Navit.destination_set();
3899
3900 Message msg = new Message();
3901 Bundle b = new Bundle();
3902 b.putInt("Callback", 3);
3903 b.putString("lat", lat);
3904 b.putString("lon", lon);
3905 b.putString("q", q);
3906 msg.setData(b);
3907 NavitGraphics.callback_handler.sendMessage(msg);
3908
3909 final Thread zoom_to_route_002 = new Thread()
3910 {
3911 int wait = 1;
3912 int count = 0;
3913 int max_count = 60;
3914
3915 @Override
3916 public void run()
3917 {
3918 while (wait == 1)
3919 {
3920 try
3921 {
3922 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3923 {
3924 zoom_to_route();
3925 wait = 0;
3926 }
3927 else
3928 {
3929 wait = 1;
3930 }
3931
3932 count++;
3933 if (count > max_count)
3934 {
3935 wait = 0;
3936 }
3937 else
3938 {
3939 Thread.sleep(400);
3940 }
3941 }
3942 catch (Exception e)
3943 {
3944 }
3945 }
3946 }
3947 };
3948 zoom_to_route_002.start();
3949
3950 // try
3951 // {
3952 // Thread.sleep(400);
3953 // }
3954 // catch (InterruptedException e)
3955 // {
3956 // }
3957 //
3958 // // try
3959 // // {
3960 // // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3961 // // }
3962 // // catch (Exception e2)
3963 // // {
3964 // // e2.printStackTrace();
3965 // // }
3966
3967 try
3968 {
3969 Navit.follow_button_on();
3970 }
3971 catch (Exception e2)
3972
3973 {
3974 e2.printStackTrace();
3975 }
3976 }
3977 else
3978 {
3979 if (unparsable_info_box && !searchBoxShown)
3980 {
3981 try
3982 {
3983 searchBoxShown = true;
3984 String searchString = intent_data.split("q=")[1];
3985 searchString = searchString.split("&")[0];
3986 searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
3987 Log.e("Navit", "Search String :" + searchString);
3988 executeSearch(searchString);
3989 }
3990 catch (Exception e)
3991 {
3992 // safety net
3993 try
3994 {
3995 Log.e("Navit", "problem with startup search 7 str=" + intent_data);
3996 }
3997 catch (Exception e2)
3998 {
3999 e2.printStackTrace();
4000 }
4001 }
4002 }
4003 }
4004 }
4005 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 10).equals("geo:0,0?q=")))
4006 {
4007 // g: geo:0,0?q=wien%20burggasse
4008
4009 System.out.println("SUI:001");
4010
4011 boolean parsable = false;
4012 boolean unparsable_info_box = true;
4013 try
4014 {
4015 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
4016 }
4017 catch (Exception e1)
4018 {
4019 e1.printStackTrace();
4020
4021 }
4022
4023 System.out.println("SUI:002");
4024
4025 if (!Navit.NavitStartupAlreadySearching)
4026 {
4027 if (intent_data.length() > 10)
4028 {
4029 // if g: then start target search
4030 Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
4031 Navit.NavitStartupAlreadySearching = true;
4032 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
4033 // dont use this here, already starting search, so set to "false"
4034 parsable = false;
4035 unparsable_info_box = false;
4036 }
4037 }
4038 else
4039 {
4040 Log.e("Navit", "already started search from startup intent");
4041 parsable = false;
4042 unparsable_info_box = false;
4043 }
4044
4045 if (unparsable_info_box && !searchBoxShown)
4046 {
4047 try
4048 {
4049 searchBoxShown = true;
4050 String searchString = intent_data.split("q=")[1];
4051 searchString = searchString.split("&")[0];
4052 searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
4053 Log.e("Navit", "Search String :" + searchString);
4054 executeSearch(searchString);
4055 }
4056 catch (Exception e)
4057 {
4058 // safety net
4059 try
4060 {
4061 Log.e("Navit", "problem with startup search 88 str=" + intent_data);
4062 }
4063 catch (Exception e2)
4064 {
4065 e2.printStackTrace();
4066 }
4067 }
4068 }
4069
4070 }
4071 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 4).equals("geo:")))
4072 {
4073 // g: geo:16.8,46.3?z=15
4074
4075 System.out.println("SUI:002a");
4076
4077 boolean parsable = false;
4078 boolean unparsable_info_box = true;
4079
4080 String tmp1;
4081 String tmp2;
4082 String tmp3;
4083 float lat1 = 0;
4084 float lon1 = 0;
4085 int zoom1 = 15;
4086
4087 try
4088 {
4089 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
4090 }
4091 catch (Exception e1)
4092 {
4093 e1.printStackTrace();
4094 }
4095
4096 if (!Navit.NavitStartupAlreadySearching)
4097 {
4098 try
4099 {
4100 tmp1 = intent_data.split(":", 2)[1];
4101 tmp2 = tmp1.split("\\?", 2)[0];
4102 tmp3 = tmp1.split("\\?", 2)[1];
4103 lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
4104 lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
4105 zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
4106 parsable = true;
4107 }
4108 catch (Exception e4)
4109 {
4110 e4.printStackTrace();
4111 }
4112 }
4113
4114 if (parsable)
4115 {
4116 // geo: intent -> only show destination on map!
4117
4118 // set nice zoomlevel before we show destination
4119 // int zoom_want = zoom1;
4120 // //
4121 // Message msg = new Message();
4122 // Bundle b = new Bundle();
4123 // b.putInt("Callback", 33);
4124 // b.putString("s", Integer.toString(zoom_want));
4125 // msg.setData(b);
4126 // try
4127 // {
4128 // N_NavitGraphics.callback_handler.sendMessage(msg);
4129 // Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
4130 // if ((zoom_want > 8) && (zoom_want < 17))
4131 // {
4132 // Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
4133 // System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
4134 // }
4135 // }
4136 // catch (Exception e)
4137 // {
4138 // e.printStackTrace();
4139 // }
4140 // if (PREF_save_zoomlevel)
4141 // {
4142 // setPrefs_zoomlevel();
4143 // }
4144 // set nice zoomlevel before we show destination
4145
4146 try
4147 {
4148 Navit.follow_button_off();
4149 }
4150 catch (Exception e2)
4151 {
4152 e2.printStackTrace();
4153 }
4154
4155 show_geo_on_screen(lat1, lon1);
4156 // final Thread zoom_to_route_003 = new Thread()
4157 // {
4158 // @Override
4159 // public void run()
4160 // {
4161 // try
4162 // {
4163 // Thread.sleep(200);
4164 // show_geo_on_screen(lat1, lon1);
4165 // }
4166 // catch (Exception e)
4167 // {
4168 // }
4169 // }
4170 // };
4171 // zoom_to_route_003.start();
4172
4173 }
4174 }
4175 }
4176
4177 System.out.println("SUI:099 XX" + substring_without_ioobe(intent_data, 0, 10) + "XX");
4178
4179 // clear intent
4180 startup_intent = null;
4181 // ------------------------ BIG LOOP ------------------------
4182 // ------------------------ BIG LOOP ------------------------
4183 }
4184 catch (Exception e)
4185 {
4186 e.printStackTrace();
4187 System.out.println("SUI:199");
4188 }
4189
4190 // clear intent
4191 startup_intent = null;
4192
4193 // hold all map drawing -----------
4194 Message msg = new Message();
4195 Bundle b = new Bundle();
4196 b.putInt("Callback", 69);
4197 msg.setData(b);
4198 try
4199 {
4200 NavitGraphics.callback_handler.sendMessage(msg);
4201 }
4202 catch (Exception e)
4203 {
4204 }
4205 // hold all map drawing -----------
4206
4207 getPrefs();
4208 activatePrefs();
4209 sun_moon__mLastCalcSunMillis = -1L;
4210
4211 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
4212 if (p.PREF_follow_gps)
4213 {
4214 push_pin_view.setImageResource(R.drawable.pin1_down);
4215 }
4216 else
4217 {
4218 push_pin_view.setImageResource(R.drawable.pin1_up);
4219 }
4220
4221 // paint for bitmapdrawing on map
4222 if (p.PREF_use_anti_aliasing)
4223 {
4224 NavitGraphics.paint_for_map_display.setAntiAlias(true);
4225 }
4226 else
4227 {
4228 NavitGraphics.paint_for_map_display.setAntiAlias(false);
4229 }
4230 if (p.PREF_use_map_filtering)
4231 {
4232 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
4233 }
4234 else
4235 {
4236 NavitGraphics.paint_for_map_display.setFilterBitmap(false);
4237 }
4238
4239 // activate gps AFTER 3g-location
4240 NavitVehicle.turn_on_precise_provider();
4241
4242 // allow all map drawing -----------
4243 msg = new Message();
4244 b = new Bundle();
4245 b.putInt("Callback", 70);
4246 msg.setData(b);
4247 try
4248 {
4249 NavitGraphics.callback_handler.sendMessage(msg);
4250 }
4251 catch (Exception e)
4252 {
4253 }
4254 // allow all map drawing -----------
4255
4256 // --- disabled --- NavitVehicle.set_last_known_pos_fast_provider();
4257
4258 try
4259 {
4260 //Simulate = new SimGPS(NavitVehicle.vehicle_handler_);
4261 //Simulate.start();
4262 }
4263 catch (Exception e)
4264 {
4265 e.printStackTrace();
4266 }
4267
4268 try
4269 {
4270 watchmem = new WatchMem();
4271 watchmem.start();
4272 }
4273 catch (Exception e)
4274 {
4275 e.printStackTrace();
4276 }
4277
4278 // ----- check if we have some index files downloaded -----
4279 if (Navit.have_maps_installed())
4280 {
4281 if (Navit_maps_too_old)
4282 {
4283 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4284 no_maps_text.setText("\n\n\n" + Navit.get_text("Some Maps are too old!") + "\n" + Navit.get_text("Please update your maps") + "\n\n");
4285
4286 try
4287 {
4288 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4289 try
4290 {
4291 NavitGraphics.no_maps_container.setActivated(true);
4292 }
4293 catch (NoSuchMethodError e)
4294 {
4295 }
4296 NavitGraphics.no_maps_container.bringToFront();
4297 }
4298 catch (Exception e)
4299 {
4300 e.printStackTrace();
4301 }
4302 }
4303 else
4304 {
4305 allow_use_index_search();
4306 if (Navit_index_on_but_no_idx_files)
4307 {
4308 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4309 no_maps_text.setText("\n\n\n" + Navit.get_text("No Index for some Maps") + "\n" + Navit.get_text("Please update your maps") + "\n\n");
4310
4311 try
4312 {
4313 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4314 try
4315 {
4316 NavitGraphics.no_maps_container.setActivated(true);
4317 }
4318 catch (NoSuchMethodError e)
4319 {
4320 }
4321 NavitGraphics.no_maps_container.bringToFront();
4322 }
4323 catch (Exception e)
4324 {
4325 e.printStackTrace();
4326 }
4327 }
4328 else
4329 {
4330 try
4331 {
4332 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
4333 try
4334 {
4335 NavitGraphics.no_maps_container.setActivated(false);
4336 }
4337 catch (NoSuchMethodError e)
4338 {
4339 }
4340 }
4341 catch (Exception e)
4342 {
4343 e.printStackTrace();
4344 }
4345 }
4346 }
4347 }
4348 // ----- check if we have some index files downloaded -----
4349
4350 // ---- DEBUG ----
4351 // ---- DEBUG ----
4352 // ---- DEBUG ----
4353 try
4354 {
4355 if (!NavitVehicle.is_pos_recording)
4356 {
4357 if (p.PREF_enable_debug_write_gpx)
4358 {
4359 NavitVehicle.pos_recording_start();
4360 NavitVehicle.pos_recording_add(0, 0, 0, 0, 0, 0);
4361 }
4362 }
4363 }
4364 catch (Exception e)
4365 {
4366 }
4367 // ---- DEBUG ----
4368 // ---- DEBUG ----
4369 // ---- DEBUG ----
4370
4371 // glSurfaceView.onResume();
4372
4373 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
4374
4375 if (Navit.CIDEBUG == 1)
4376 {
4377 new Thread()
4378 {
4379 public void run()
4380 {
4381 try
4382 {
4383 System.out.println("DR_run_all_yaml_tests --> want");
4384
4385 if (CIRUN == false)
4386 {
4387 System.out.println("DR_run_all_yaml_tests --> do");
4388 CIRUN = true;
4389 Thread.sleep(20000); // 20 secs.
4390 ZANaviDebugReceiver.DR_run_all_yaml_tests();
4391 }
4392 }
4393 catch (Exception e)
4394 {
4395 }
4396 }
4397 }.start();
4398 }
4399 }
4400
4401 @TargetApi(Build.VERSION_CODES.FROYO)
4402 @Override
4403 public void onPause()
4404 {
4405
4406 // if COMM stuff is running, stop it!
4407 ZANaviDebugReceiver.stop_me = true;
4408
4409 // ---- DEBUG ----
4410 // ---- DEBUG ----
4411 // ---- DEBUG ----
4412 // -- dump all callbacks --
4413 try
4414 {
4415 if (p.PREF_enable_debug_functions)
4416 {
4417 Message msg99a = new Message();
4418 Bundle b99a = new Bundle();
4419 b99a.putInt("Callback", 100);
4420 msg99a.setData(b99a);
4421 N_NavitGraphics.callback_handler.sendMessage(msg99a);
4422 }
4423 }
4424 catch (Exception e)
4425 {
4426 }
4427 // -- dump all callbacks --
4428 // ---- DEBUG ----
4429 // ---- DEBUG ----
4430 // ---- DEBUG ----
4431
4432 // ---- DEBUG ----
4433 // ---- DEBUG ----
4434 // ---- DEBUG ----
4435 try
4436 {
4437 if (!Navit.is_navigating)
4438 {
4439 if (p.PREF_enable_debug_write_gpx)
4440 {
4441 NavitVehicle.pos_recording_end();
4442 }
4443 }
4444 }
4445 catch (Exception e)
4446 {
4447 }
4448 // ---- DEBUG ----
4449 // ---- DEBUG ----
4450 // ---- DEBUG ----
4451
4452 // System.out.println("@@ onPause @@");
4453 Log.e("Navit", "OnPause");
4454 try
4455 {
4456 setPrefs_zoomlevel();
4457 }
4458 catch (Exception e)
4459 {
4460 e.printStackTrace();
4461 }
4462
4463 try
4464 {
4465 watchmem.stop_me();
4466 }
4467 catch (Exception e)
4468 {
4469 e.printStackTrace();
4470 }
4471
4472 try
4473 {
4474 //watchmem.join();
4475 }
4476 catch (Exception e)
4477 {
4478 e.printStackTrace();
4479 }
4480
4481 try
4482 {
4483 //Simulate.stop_me();
4484 }
4485 catch (Exception e)
4486 {
4487 e.printStackTrace();
4488 }
4489
4490 try
4491 {
4492 //Simulate.join();
4493 }
4494 catch (Exception e)
4495 {
4496 e.printStackTrace();
4497 }
4498
4499 Navit.show_mem_used();
4500
4501 // if (!Navit.is_navigating)
4502 // {
4503 // try
4504 // {
4505 // mTts.stop();
4506 // }
4507 // catch (Exception e)
4508 // {
4509 //
4510 // }
4511 //
4512 // try
4513 // {
4514 // mTts.shutdown();
4515 // }
4516 // catch (Exception e)
4517 // {
4518 //
4519 // }
4520 //
4521 // mTts = null;
4522 // }
4523
4524 super.onPause();
4525
4526 // signal to backupmanager that data "is / could have" changed
4527 try
4528 {
4529 Class.forName("android.app.backup.BackupManager");
4530 BackupManager b = (BackupManager) backupManager;
4531 b.dataChanged();
4532 }
4533 catch (ClassNotFoundException e)
4534 {
4535 e.printStackTrace();
4536 }
4537 catch (Exception e)
4538 {
4539 e.printStackTrace();
4540 }
4541
4542 turn_off_compass();
4543
4544 // System.out.println("XXNAV: onpause:001");
4545 if (!Navit.is_navigating)
4546 {
4547 // System.out.println("XXNAV: onpause:002");
4548 NavitVehicle.turn_off_all_providers();
4549 NavitVehicle.turn_off_sat_status();
4550 // System.out.println("XXNAV: onpause:003");
4551 }
4552
4553 // Log.e("Navit", "OnPause");
4554 cwthr.NavitActivity2(-1);
4555
4556 Navit.show_mem_used();
4557
4558 try
4559 {
4560 if (wl != null)
4561 {
4562 wl.release();
4563 Log.e("Navit", "WakeLock: release 1");
4564 }
4565 }
4566 catch (Exception e)
4567 {
4568 e.printStackTrace();
4569 }
4570
4571 try
4572 {
4573 if (wl_cpu != null)
4574 {
4575 if (wl_cpu.isHeld())
4576 {
4577 wl_cpu.release();
4578 Log.e("Navit", "WakeLock CPU: release 1");
4579 }
4580 }
4581 }
4582 catch (Exception e)
4583 {
4584 e.printStackTrace();
4585 }
4586
4587 // glSurfaceView.onPause();
4588
4589 is_paused = true;
4590 }
4591
4592 @Override
4593 public void onStop()
4594 {
4595 super.onStop();
4596 Log.e("Navit", "OnStop");
4597
4598 if (!Navit.is_navigating)
4599 {
4600 NavitVehicle.turn_off_all_providers();
4601 NavitVehicle.turn_off_sat_status();
4602 }
4603
4604 cwthr.NavitActivity2(-2);
4605 Navit.show_mem_used();
4606
4607 // if (!Navit.is_navigating)
4608 // {
4609 // try
4610 // {
4611 // mTts.stop();
4612 // }
4613 // catch (Exception e)
4614 // {
4615 //
4616 // }
4617 //
4618 // try
4619 // {
4620 // mTts.shutdown();
4621 // }
4622 // catch (Exception e)
4623 // {
4624 //
4625 // }
4626 //
4627 // mTts = null;
4628 // }
4629
4630 // save points
4631 write_map_points();
4632 }
4633
4634 @Override
4635 public void onDestroy()
4636 {
4637 super.onDestroy();
4638 Log.e("Navit", "OnDestroy");
4639
4640 try
4641 {
4642 try
4643 {
4644 plugin_api.removeListener(zclientListener);
4645 }
4646 catch (Exception e)
4647 {
4648 e.printStackTrace();
4649 Log.i("NavitPlugin", "Failed to remove Listener", e);
4650 }
4651 unbindService(serviceConnection);
4652 Log.i("NavitPlugin", "Unbind from the service");
4653 }
4654 catch (Throwable t)
4655 {
4656 // catch any issues, typical for destroy routines
4657 // even if we failed to destroy something, we need to continue destroying
4658 Log.i("NavitPlugin", "Failed to unbind from the service", t);
4659 }
4660
4661 try
4662 {
4663 mTts.stop();
4664 }
4665 catch (Exception e)
4666 {
4667
4668 }
4669
4670 try
4671 {
4672 mTts.shutdown();
4673 }
4674 catch (Exception e)
4675 {
4676
4677 }
4678
4679 mTts = null;
4680
4681 // ----- service stop -----
4682 // ----- service stop -----
4683 System.out.println("Navit:onDestroy -> stop ZANaviMapDownloaderService ---------");
4684 stopService(Navit.ZANaviMapDownloaderServiceIntent);
4685 try
4686 {
4687 Thread.sleep(1000);
4688 }
4689 catch (InterruptedException e)
4690 {
4691 }
4692 // ----- service stop -----
4693 // ----- service stop -----
4694
4695 NavitActivity(-3);
4696 Navit.show_mem_used();
4697 }
4698
4699 public void setActivityResult(int requestCode, NavitActivityResult ActivityResult)
4700 {
4701 Log.e("Navit", "setActivityResult " + requestCode);
4702 ActivityResults[requestCode] = ActivityResult;
4703 }
4704
4705 @Override
4706 public boolean onKeyUp(int keyCode, KeyEvent event)
4707 {
4708 if (keyCode == KeyEvent.KEYCODE_MENU)
4709 {
4710 if (cur_menu != null)
4711 {
4712 // open the overflow menu
4713 cur_menu.performIdentifierAction(R.id.item_overflow, 0);
4714 return true;
4715 }
4716 }
4717 return super.onKeyUp(keyCode, event);
4718 }
4719
4720 // @Override
4721 // public boolean onKeyDown(int keyCode, KeyEvent event)
4722 // {
4723 // if (keyCode == KeyEvent.KEYCODE_MENU)
4724 // {
4725 // return true;
4726 // }
4727 // return super.onKeyUp(keyCode, event);
4728 // }
4729
4730 @Override
4731 public boolean onPrepareOptionsMenu(Menu menu)
4732 {
4733 super.onPrepareOptionsMenu(menu);
4734 //
4735 menu.clear();
4736
4737 // load the menu from XML
4738 getMenuInflater().inflate(R.menu.actionbaricons, menu);
4739
4740 // NavitOverflowMenuItemID = R.id.item_overflow_menu_button;
4741 menu.findItem(R.id.share_menu_destination).setTitle(Navit.get_text("Share Destination"));
4742 menu.findItem(R.id.share_menu_location).setTitle(Navit.get_text("Share my Location"));
4743 menu.findItem(R.id.search_menu_offline).setTitle(get_text("address search (offline)"));
4744 menu.findItem(R.id.search_menu_online).setTitle(get_text("address search (online)"));
4745 menu.findItem(R.id.item_recentdest_menu_button).setTitle(get_text("Recent destinations"));
4746 menu.findItem(R.id.item_settings_menu_button).setTitle(get_text("Settings"));
4747 menu.findItem(R.id.item_search_menu_button).setTitle(get_text("Search"));
4748 menu.findItem(R.id.item_download_menu_button).setTitle(get_text("downloading map"));
4749 //
4750 menu.findItem(R.id.overflow_share_location).setTitle(Navit.get_text("Share my Location"));
4751 menu.findItem(R.id.overflow_share_destination).setTitle(Navit.get_text("Share Destination"));
4752 menu.findItem(R.id.overflow_settings).setTitle(Navit.get_text("Settings"));
4753 menu.findItem(R.id.overflow_zoom_to_route).setTitle(Navit.get_text("Zoom to Route"));
4754
4755 if (ZANaviNormalDonateActivity.on_amazon_device)
4756 {
4757 menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate"));
4758 }
4759 else
4760 {
4761 menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate with Google Play"));
4762 }
4763 menu.findItem(R.id.overflow_donate_bitcoins_item).setTitle(Navit.get_text("Donate with Bitcoin"));
4764 //. TRANSLATORS: text to translate is: exit ZANavi
4765 menu.findItem(R.id.overflow_exit).setTitle(Navit.get_text("exit navit"));
4766 menu.findItem(R.id.overflow_toggle_poi).setTitle(Navit.get_text("toggle POI"));
4767 menu.findItem(R.id.overflow_announcer_on).setTitle(Navit.get_text("Announcer On"));
4768 menu.findItem(R.id.overflow_announcer_off).setTitle(Navit.get_text("Announcer Off"));
4769 menu.findItem(R.id.overflow_download_maps).setTitle(Navit.get_text("download maps"));
4770 menu.findItem(R.id.overflow_delete_maps).setTitle(Navit.get_text("delete maps"));
4771 menu.findItem(R.id.overflow_maps_age).setTitle(Navit.get_text("show Maps age"));
4772 menu.findItem(R.id.overflow_coord_dialog).setTitle(Navit.get_text("Coord Dialog"));
4773 menu.findItem(R.id.overflow_add_traffic_block).setTitle(Navit.get_text("add Traffic block"));
4774 menu.findItem(R.id.overflow_clear_traffic_block).setTitle(Navit.get_text("clear Traffic blocks"));
4775 menu.findItem(R.id.overflow_convert_gpx_file).setTitle(Navit.get_text("convert GPX file"));
4776 menu.findItem(R.id.overflow_replay_gps_file).setTitle(Navit.get_text("replay a ZANavi gps file"));
4777 menu.findItem(R.id.overflow_yaml_tests).setTitle(Navit.get_text("run YAML tests"));
4778 menu.findItem(R.id.overflow_clear_gpx_map).setTitle(Navit.get_text("clear GPX map"));
4779 // menu.findItem(R.id.overflow_dummy2)
4780 menu.findItem(R.id.overflow_demo_v_normal).setTitle(get_text("Demo Vehicle") + " [normal]");
4781 menu.findItem(R.id.overflow_demo_v_fast).setTitle(get_text("Demo Vehicle") + " [fast]");
4782 menu.findItem(R.id.overflow_speech_texts).setTitle(Navit.get_text("Speech Texts"));
4783 menu.findItem(R.id.overflow_nav_commands).setTitle(Navit.get_text("Nav. Commands"));
4784 menu.findItem(R.id.overflow_toggle_route_graph).setTitle(Navit.get_text("toggle Routegraph"));
4785 //menu.findItem(R.id.overflow_dummy1)
4786 menu.findItem(R.id.overflow_export_map_points_to_sdcard).setTitle(Navit.get_text("export Destinations"));
4787 menu.findItem(R.id.overflow_import_map_points_from_sdcard).setTitle(Navit.get_text("import Destinations"));
4788 menu.findItem(R.id.overflow_send_feedback).setTitle(Navit.get_text("send feedback"));
4789 menu.findItem(R.id.overflow_online_help).setTitle(Navit.get_text("online Help"));
4790 //. TRANSLATORS: it means: "show current target in google maps"
4791 //. TRANSLATORS: please keep this text short, to fit in the android menu!
4792 menu.findItem(R.id.overflow_target_in_gmaps).setTitle(Navit.get_text("Target in gmaps"));
4793 //
4794 //
4795 menu.findItem(R.id.item_share_menu_button).setTitle(get_text("Share"));
4796
4797 Display display_ = getWindowManager().getDefaultDisplay();
4798 Log.e("Navit", "Navit width in DP -> " + display_.getWidth() / Navit.metrics.density);
4799 Log.e("Navit", "Navit width in DP -> density=" + Navit.metrics.density);
4800
4801 try
4802 {
4803 View v4 = findViewById(R.id.item_settings_menu_button);
4804 // Log.e("Navit", "Navit width in DP -> v4=" + v4);
4805 if ((v4 != null) && (v4.getWidth() > 0))
4806 {
4807 Log.e("Navit", "Navit width in DP -> v4.w=" + v4.getWidth());
4808 MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
4809 // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
4810 // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
4811 Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
4812 actionbar_item_width = (int) ((v4.getWidth() + (menuItem.getIcon().getIntrinsicWidth() * 1.5f)) / 2);
4813 }
4814 else
4815 {
4816 MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
4817 // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
4818 // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
4819 Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
4820 actionbar_item_width = (int) ((menuItem.getIcon().getIntrinsicWidth()) * 1.7f);
4821 }
4822
4823 actionbar_items_will_fit = display_.getWidth() / actionbar_item_width;
4824 Log.e("Navit", "Navit width in DP -> number of items that will fit=" + actionbar_items_will_fit);
4825 if (actionbar_items_will_fit > 6) // now we need to fit max. 6 items on actionbar
4826 {
4827 actionbar_all_items_will_fit = true;
4828 }
4829 else
4830 {
4831 actionbar_all_items_will_fit = false;
4832 }
4833 }
4834 catch (Exception e)
4835 {
4836 if ((display_.getWidth() / Navit.metrics.density) < NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR)
4837 {
4838 actionbar_all_items_will_fit = false;
4839 }
4840 else
4841 {
4842 actionbar_all_items_will_fit = true;
4843 }
4844 }
4845
4846 if (actionbar_all_items_will_fit == false)
4847 {
4848 menu.findItem(R.id.item_share_menu_button).setVisible(false);
4849 menu.findItem(R.id.overflow_share_location).setVisible(true);
4850 if (NavitGraphics.CallbackDestinationValid2() == 0)
4851 {
4852 menu.findItem(R.id.overflow_share_destination).setVisible(false);
4853 }
4854 else
4855 {
4856 menu.findItem(R.id.overflow_share_destination).setVisible(true);
4857 }
4858
4859 if (actionbar_items_will_fit < 6)
4860 {
4861 // also push the settings icons to overflow menu
4862 menu.findItem(R.id.item_settings_menu_button).setVisible(false);
4863 menu.findItem(R.id.overflow_settings).setVisible(true);
4864 }
4865 else
4866 {
4867 menu.findItem(R.id.item_settings_menu_button).setVisible(true);
4868 menu.findItem(R.id.overflow_settings).setVisible(false);
4869 }
4870 }
4871 else
4872 {
4873 menu.findItem(R.id.item_settings_menu_button).setVisible(true);
4874 menu.findItem(R.id.overflow_settings).setVisible(false);
4875 menu.findItem(R.id.overflow_share_location).setVisible(false);
4876 menu.findItem(R.id.overflow_share_destination).setVisible(false);
4877 menu.findItem(R.id.item_share_menu_button).setVisible(true);
4878 }
4879
4880 cur_menu = menu;
4881
4882 if (actionabar_download_icon_visible)
4883 {
4884 menu.findItem(R.id.item_download_menu_button).setVisible(true);
4885 }
4886 else
4887 {
4888 menu.findItem(R.id.item_download_menu_button).setVisible(false);
4889 }
4890
4891 if (NavitGraphics.CallbackDestinationValid2() > 0)
4892 {
4893 menu.findItem(R.id.item_endnavigation_menu_button).setVisible(true);
4894 menu.findItem(R.id.item_endnavigation_menu_button).setTitle(get_text("Stop Navigation"));
4895 menu.findItem(R.id.overflow_zoom_to_route).setVisible(true);
4896 menu.findItem(R.id.overflow_target_in_gmaps).setVisible(true);
4897 menu.findItem(R.id.share_menu_destination).setVisible(true);
4898 }
4899 else
4900 {
4901 menu.findItem(R.id.item_endnavigation_menu_button).setVisible(false);
4902 menu.findItem(R.id.overflow_zoom_to_route).setVisible(false);
4903 menu.findItem(R.id.overflow_target_in_gmaps).setVisible(false);
4904 menu.findItem(R.id.share_menu_destination).setVisible(false);
4905 }
4906
4907 if (Navit_Announcer == true)
4908 {
4909 menu.findItem(R.id.overflow_announcer_off).setVisible(true);
4910 menu.findItem(R.id.overflow_announcer_on).setVisible(false);
4911 }
4912 else
4913 {
4914 menu.findItem(R.id.overflow_announcer_off).setVisible(false);
4915 menu.findItem(R.id.overflow_announcer_on).setVisible(true);
4916 }
4917
4918 if (p.PREF_enable_debug_functions)
4919 {
4920 menu.findItem(R.id.overflow_dummy2).setVisible(true);
4921 menu.findItem(R.id.overflow_demo_v_normal).setVisible(true);
4922 menu.findItem(R.id.overflow_demo_v_fast).setVisible(true);
4923 menu.findItem(R.id.overflow_speech_texts).setVisible(true);
4924 menu.findItem(R.id.overflow_nav_commands).setVisible(true);
4925 menu.findItem(R.id.overflow_toggle_route_graph).setVisible(true);
4926 menu.findItem(R.id.overflow_replay_gps_file).setVisible(true);
4927 menu.findItem(R.id.overflow_yaml_tests).setVisible(true);
4928 }
4929 else
4930 {
4931 menu.findItem(R.id.overflow_dummy2).setVisible(false);
4932 menu.findItem(R.id.overflow_demo_v_normal).setVisible(false);
4933 menu.findItem(R.id.overflow_demo_v_fast).setVisible(false);
4934 menu.findItem(R.id.overflow_speech_texts).setVisible(false);
4935 menu.findItem(R.id.overflow_nav_commands).setVisible(false);
4936 menu.findItem(R.id.overflow_toggle_route_graph).setVisible(false);
4937 menu.findItem(R.id.overflow_replay_gps_file).setVisible(false);
4938 menu.findItem(R.id.overflow_yaml_tests).setVisible(false);
4939 }
4940
4941 return true;
4942 }
4943
4944 public void start_targetsearch_from_intent(String target_address)
4945 {
4946 Navit_last_address_partial_match = true; // this will overwrite the default setting --> this is not good
4947 Navit_last_address_search_string = target_address;
4948 Navit_last_address_hn_string = "";
4949
4950 // ----------- CONFIG ---------
4951 // ----------- CONFIG ---------
4952 // ----------- CONFIG ---------
4953 Boolean use_online_searchmode_here = true;
4954 Boolean hide_duplicates_searchmode_here = false;
4955 // ----------- CONFIG ---------
4956 // ----------- CONFIG ---------
4957 // ----------- CONFIG ---------
4958
4959 int dialog_num_;
4960
4961 if (use_online_searchmode_here)
4962 {
4963 dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG;
4964 Navit.use_index_search = false;
4965 Log.e("Navit", "*google*:online search");
4966 }
4967 else
4968 {
4969 dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE;
4970 Navit.use_index_search = Navit.allow_use_index_search();
4971 }
4972
4973 // clear results
4974 Navit.NavitAddressResultList_foundItems.clear();
4975 Navit.Navit_Address_Result_double_index.clear();
4976 Navit.NavitSearchresultBarIndex = -1;
4977 Navit.NavitSearchresultBar_title = "";
4978 Navit.NavitSearchresultBar_text = "";
4979 search_hide_duplicates = false;
4980
4981 if (Navit_last_address_search_string.equals(""))
4982 {
4983 // empty search string entered
4984 Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
4985 }
4986 else
4987 {
4988 // show dialog
4989 try
4990 {
4991 Log.e("Navit", "*google*:call-11: (0)num " + dialog_num_);
4992 }
4993 catch (Exception e)
4994 {
4995 e.printStackTrace();
4996 }
4997
4998 if (hide_duplicates_searchmode_here)
4999 {
5000 search_hide_duplicates = true;
5001 // hide duplicates when searching
5002 // hide duplicates when searching
5003 Message msg22 = new Message();
5004 Bundle b22 = new Bundle();
5005 b22.putInt("Callback", 45);
5006 msg22.setData(b22);
5007 NavitGraphics.callback_handler.sendMessage(msg22);
5008 // hide duplicates when searching
5009 // hide duplicates when searching
5010 }
5011
5012 System.out.println("dialog -- 11:002");
5013 Message msg = progress_handler.obtainMessage();
5014 Bundle b = new Bundle();
5015 msg.what = 11;
5016 b.putInt("dialog_num", dialog_num_);
5017 msg.setData(b);
5018 progress_handler.sendMessage(msg);
5019 }
5020 }
5021
5022 @Override
5023 public boolean onCreateOptionsMenu(Menu menu)
5024 {
5025 super.onCreateOptionsMenu(menu);
5026
5027 return true;
5028 }
5029
5030 @Override
5031 public boolean onOptionsItemSelected(MenuItem item)
5032 {
5033 //System.out.println("menu button pressed ID=" + item.getItemId());
5034
5035 if ((item.getItemId() == R.id.share_menu_destination) || (item.getItemId() == R.id.overflow_share_destination) || (item.getItemId() == 23020))
5036 {
5037 // System.out.println("share destination pressed ID=" + item.getItemId());
5038 // ------------
5039 // ------------
5040 // share the current destination with your friends
5041 String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5042 if (current_target_string2.equals("x:x"))
5043 {
5044 Log.e("Navit", "no target set!");
5045 }
5046 else
5047 {
5048 try
5049 {
5050 String tmp[] = current_target_string2.split(":", 2);
5051
5052 if (Navit.OSD_route_001.arriving_time_valid)
5053 {
5054 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
5055 }
5056 else
5057 {
5058 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5059 }
5060
5061 }
5062 catch (Exception e)
5063 {
5064 e.printStackTrace();
5065 Log.e("Navit", "problem with target!");
5066 }
5067 }
5068 return true;
5069 }
5070 else if (item.getItemId() == R.id.item_download_menu_button)
5071 {
5072 // System.out.println("download icon pressed(1) ID=" + item.getItemId());
5073
5074 Intent mapdownload_cancel_activity = new Intent(this, ZANaviDownloadMapCancelActivity.class);
5075 mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
5076 startActivity(mapdownload_cancel_activity);
5077
5078 return true;
5079 }
5080 else if ((item.getItemId() == R.id.share_menu_location) || (item.getItemId() == R.id.overflow_share_location) || (item.getItemId() == 23000))
5081 {
5082 // System.out.println("share location pressed ID=" + item.getItemId());
5083 // ------------
5084 // ------------
5085 // share the current location with your friends
5086 location_coords cur_target = null;
5087 try
5088 {
5089 geo_coord tmp = get_current_vehicle_position();
5090 cur_target.lat = tmp.Latitude;
5091 cur_target.lon = tmp.Longitude;
5092 // cur_target = NavitVehicle.get_last_known_pos();
5093 }
5094 catch (Exception e)
5095 {
5096 }
5097
5098 if (cur_target == null)
5099 {
5100 Log.e("Navit", "no location found!");
5101 }
5102 else
5103 {
5104 try
5105 {
5106 share_location(String.valueOf(cur_target.lat), String.valueOf(cur_target.lon), Navit.get_text("my Location"), Navit.get_text("my Location"), "", false);
5107 }
5108 catch (Exception e)
5109 {
5110 e.printStackTrace();
5111 Log.e("Navit", "problem with location!");
5112 }
5113 }
5114 return true;
5115 }
5116 else if ((item.getItemId() == R.id.item_settings_menu_button) || (item.getItemId() == R.id.overflow_settings) || (item.getItemId() == 490))
5117 {
5118 // open settings menu
5119 Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
5120 startActivity(settingsActivity);
5121
5122 return true;
5123 }
5124 else if (item.getItemId() == R.id.search_menu_offline)
5125 {
5126 // ok startup address search activity (offline binfile search)
5127 Navit.use_index_search = Navit.allow_use_index_search();
5128 Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
5129 search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5130 search_intent2.putExtra("address_string", Navit_last_address_search_string);
5131 search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
5132 search_intent2.putExtra("type", "offline");
5133 search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);
5134
5135 String pm_temp2 = "0";
5136 if (Navit_last_address_partial_match)
5137 {
5138 pm_temp2 = "1";
5139 }
5140
5141 search_intent2.putExtra("partial_match", pm_temp2);
5142
5143 Navit.use_index_search = Navit.allow_use_index_search();
5144 if (Navit.use_index_search)
5145 {
5146 this.startActivityForResult(search_intent2, NavitAddressResultList_id);
5147 }
5148 else
5149 {
5150 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
5151 }
5152
5153 return true;
5154 }
5155 else if (item.getItemId() == R.id.search_menu_online)
5156 {
5157 // ok startup address search activity (online google maps search)
5158 Navit.use_index_search = false;
5159 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
5160 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5161 search_intent.putExtra("address_string", Navit_last_address_search_string);
5162 //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
5163 search_intent.putExtra("type", "online");
5164 String pm_temp = "0";
5165 if (Navit_last_address_partial_match)
5166 {
5167 pm_temp = "1";
5168 }
5169 search_intent.putExtra("partial_match", pm_temp);
5170 this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
5171
5172 return true;
5173 }
5174 else if (item.getItemId() == R.id.item_endnavigation_menu_button)
5175 {
5176 // stop navigation (this menu should only appear when navigation is actually on!)
5177 NavitGraphics.deactivate_nav_wakelock();
5178 Message msg2 = new Message();
5179 Bundle b2 = new Bundle();
5180 b2.putInt("Callback", 7);
5181 msg2.setData(b2);
5182 NavitGraphics.callback_handler.sendMessage(msg2);
5183 Log.e("Navit", "stop navigation");
5184
5185 if (p.PREF_enable_debug_write_gpx)
5186 {
5187 NavitVehicle.speech_recording_end();
5188 }
5189
5190 // redraw all OSD elements
5191 Navit.OSD_route_001.arriving_time_valid = false;
5192 Navit.OSD_route_001.arriving_secs_to_dest_valid = false;
5193 Navit.OSD_route_001.driving_distance_to_target_valid = false;
5194 Navit.OSD_nextturn.nextturn_distance_valid = false;
5195 Navit.OSD_nextturn.nextturn_image_valid = false;
5196 Navit.OSD_compass.direct_distance_to_target_valid = false;
5197 NavitGraphics.OSD_new.postInvalidate();
5198
5199 return true;
5200 }
5201 else if (item.getItemId() == R.id.item_recentdest_menu_button)
5202 {
5203 // show recent destination list
5204 Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
5205 this.startActivityForResult(i2, Navit.NavitRecentDest_id);
5206
5207 return true;
5208 }
5209 else if (item.getItemId() == R.id.overflow_zoom_to_route)
5210 {
5211 return onOptionsItemSelected_wrapper(11);
5212 }
5213 else if (item.getItemId() == R.id.overflow_donate_item)
5214 {
5215 return onOptionsItemSelected_wrapper(26);
5216 }
5217 else if (item.getItemId() == R.id.overflow_donate_bitcoins_item)
5218 {
5219 return onOptionsItemSelected_wrapper(27);
5220 }
5221 else if (item.getItemId() == R.id.overflow_exit)
5222 {
5223 return onOptionsItemSelected_wrapper(99);
5224 }
5225 else if (item.getItemId() == R.id.overflow_toggle_poi)
5226 {
5227 return onOptionsItemSelected_wrapper(5);
5228 }
5229 else if (item.getItemId() == R.id.overflow_announcer_on)
5230 {
5231 return onOptionsItemSelected_wrapper(13);
5232 }
5233 else if (item.getItemId() == R.id.overflow_announcer_off)
5234 {
5235 return onOptionsItemSelected_wrapper(12);
5236 }
5237 else if (item.getItemId() == R.id.overflow_download_maps)
5238 {
5239 return onOptionsItemSelected_wrapper(3);
5240 }
5241 else if (item.getItemId() == R.id.overflow_delete_maps)
5242 {
5243 return onOptionsItemSelected_wrapper(8);
5244 }
5245 else if (item.getItemId() == R.id.overflow_maps_age)
5246 {
5247 return onOptionsItemSelected_wrapper(17);
5248 }
5249 else if (item.getItemId() == R.id.overflow_coord_dialog)
5250 {
5251 return onOptionsItemSelected_wrapper(19);
5252 }
5253 else if (item.getItemId() == R.id.overflow_add_traffic_block)
5254 {
5255 return onOptionsItemSelected_wrapper(21);
5256 }
5257 else if (item.getItemId() == R.id.overflow_clear_traffic_block)
5258 {
5259 return onOptionsItemSelected_wrapper(22);
5260 }
5261 else if (item.getItemId() == R.id.overflow_convert_gpx_file)
5262 {
5263 return onOptionsItemSelected_wrapper(20);
5264 }
5265 else if (item.getItemId() == R.id.overflow_clear_gpx_map)
5266 {
5267 return onOptionsItemSelected_wrapper(23);
5268 }
5269 else if (item.getItemId() == R.id.overflow_replay_gps_file)
5270 {
5271 return onOptionsItemSelected_wrapper(28);
5272 }
5273 else if (item.getItemId() == R.id.overflow_yaml_tests)
5274 {
5275 return onOptionsItemSelected_wrapper(609);
5276 }
5277 else if (item.getItemId() == R.id.overflow_demo_v_normal)
5278 {
5279 return onOptionsItemSelected_wrapper(601);
5280 }
5281 else if (item.getItemId() == R.id.overflow_demo_v_fast)
5282 {
5283 return onOptionsItemSelected_wrapper(604);
5284 }
5285 else if (item.getItemId() == R.id.overflow_speech_texts)
5286 {
5287 return onOptionsItemSelected_wrapper(602);
5288 }
5289 else if (item.getItemId() == R.id.overflow_nav_commands)
5290 {
5291 return onOptionsItemSelected_wrapper(603);
5292 }
5293 else if (item.getItemId() == R.id.overflow_toggle_route_graph)
5294 {
5295 return onOptionsItemSelected_wrapper(605);
5296 }
5297 else if (item.getItemId() == R.id.overflow_export_map_points_to_sdcard)
5298 {
5299 return onOptionsItemSelected_wrapper(607);
5300 }
5301 else if (item.getItemId() == R.id.overflow_import_map_points_from_sdcard)
5302 {
5303 return onOptionsItemSelected_wrapper(608);
5304 }
5305 else if (item.getItemId() == R.id.overflow_send_feedback)
5306 {
5307 return onOptionsItemSelected_wrapper(24);
5308 }
5309 else if (item.getItemId() == R.id.overflow_online_help)
5310 {
5311 return onOptionsItemSelected_wrapper(16);
5312 }
5313 else if (item.getItemId() == R.id.overflow_target_in_gmaps)
5314 {
5315 return onOptionsItemSelected_wrapper(15);
5316 }
5317 // else
5318 // {
5319 // return onOptionsItemSelected_wrapper(item.getItemId());
5320 // }
5321
5322 return false;
5323 }
5324
5325 @SuppressLint("NewApi")
5326 public boolean onOptionsItemSelected_wrapper(int id)
5327 {
5328 // Handle item selection
5329 switch (id)
5330 {
5331 case 1:
5332 // zoom in
5333 Message msg = new Message();
5334 Bundle b = new Bundle();
5335 b.putInt("Callback", 1);
5336 msg.setData(b);
5337 NavitGraphics.callback_handler.sendMessage(msg);
5338 // if we zoom, hide the bubble
5339 if (N_NavitGraphics.NavitAOverlay != null)
5340 {
5341 N_NavitGraphics.NavitAOverlay.hide_bubble();
5342 }
5343 Log.e("Navit", "onOptionsItemSelected -> zoom in");
5344 break;
5345 case 2:
5346 // zoom out
5347 msg = new Message();
5348 b = new Bundle();
5349 b.putInt("Callback", 2);
5350 msg.setData(b);
5351 NavitGraphics.callback_handler.sendMessage(msg);
5352 // if we zoom, hide the bubble
5353 if (N_NavitGraphics.NavitAOverlay != null)
5354 {
5355 N_NavitGraphics.NavitAOverlay.hide_bubble();
5356 }
5357 Log.e("Navit", "onOptionsItemSelected -> zoom out");
5358 break;
5359 case 3:
5360 // map download menu
5361 Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
5362 this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
5363 break;
5364 case 5:
5365 toggle_poi_pref();
5366 set_poi_layers();
5367 draw_map();
5368 break;
5369 case 6:
5370 // ok startup address search activity (online google maps search)
5371 Navit.use_index_search = false;
5372 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
5373 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5374 search_intent.putExtra("address_string", Navit_last_address_search_string);
5375 //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
5376 search_intent.putExtra("type", "online");
5377 String pm_temp = "0";
5378 if (Navit_last_address_partial_match)
5379 {
5380 pm_temp = "1";
5381 }
5382 search_intent.putExtra("partial_match", pm_temp);
5383 this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
5384 break;
5385 case 7:
5386 // ok startup address search activity (offline binfile search)
5387 Navit.use_index_search = Navit.allow_use_index_search();
5388 Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
5389 search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5390 search_intent2.putExtra("address_string", Navit_last_address_search_string);
5391 search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
5392 search_intent2.putExtra("type", "offline");
5393 search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);
5394
5395 String pm_temp2 = "0";
5396 if (Navit_last_address_partial_match)
5397 {
5398 pm_temp2 = "1";
5399 }
5400
5401 search_intent2.putExtra("partial_match", pm_temp2);
5402 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
5403 break;
5404 case 8:
5405 // map delete menu
5406 Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class);
5407 this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id);
5408 break;
5409 case 9:
5410 // stop navigation (this menu should only appear when navigation is actually on!)
5411 Message msg2 = new Message();
5412 Bundle b2 = new Bundle();
5413 b2.putInt("Callback", 7);
5414 msg2.setData(b2);
5415 NavitGraphics.callback_handler.sendMessage(msg2);
5416 Log.e("Navit", "stop navigation");
5417 break;
5418 case 10:
5419 // open settings menu
5420 Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
5421 startActivity(settingsActivity);
5422 break;
5423 case 11:
5424 //zoom_to_route
5425 zoom_to_route();
5426 break;
5427 case 12:
5428 // announcer off
5429 Navit_Announcer = false;
5430 msg = new Message();
5431 b = new Bundle();
5432 b.putInt("Callback", 34);
5433 msg.setData(b);
5434 NavitGraphics.callback_handler.sendMessage(msg);
5435 try
5436 {
5437 invalidateOptionsMenu();
5438 }
5439 catch (Exception e)
5440 {
5441 }
5442 break;
5443 case 13:
5444 // announcer on
5445 Navit_Announcer = true;
5446 msg = new Message();
5447 b = new Bundle();
5448 b.putInt("Callback", 35);
5449 msg.setData(b);
5450 NavitGraphics.callback_handler.sendMessage(msg);
5451 try
5452 {
5453 invalidateOptionsMenu();
5454 }
5455 catch (Exception e)
5456 {
5457 }
5458 break;
5459 case 14:
5460 // show recent destination list
5461 Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
5462 this.startActivityForResult(i2, Navit.NavitRecentDest_id);
5463 break;
5464 case 15:
5465 // show current target on googlemaps
5466 String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5467 // Log.e("Navit", "got target 1: "+current_target_string);
5468 if (current_target_string.equals("x:x"))
5469 {
5470 Log.e("Navit", "no target set!");
5471 }
5472 else
5473 {
5474 try
5475 {
5476 String tmp[] = current_target_string.split(":", 2);
5477 googlemaps_show(tmp[0], tmp[1], "ZANavi Target");
5478 }
5479 catch (Exception e)
5480 {
5481 e.printStackTrace();
5482 Log.e("Navit", "problem with target!");
5483 }
5484 }
5485 break;
5486 case 16:
5487 // show online manual
5488 Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase());
5489 // URL to ZANavi Manual (in english language)
5490 String url = "http://zanavi.cc/index.php/Manual";
5491 if (FDBL)
5492 {
5493 url = "http://fd.zanavi.cc/manual";
5494 }
5495 if (NavitTextTranslations.main_language.toLowerCase().equals("de"))
5496 {
5497 // show german manual
5498 url = "http://zanavi.cc/index.php/Manual/de";
5499 if (FDBL)
5500 {
5501 url = "http://fd.zanavi.cc/manualde";
5502 }
5503 }
5504
5505 Intent i = new Intent(Intent.ACTION_VIEW);
5506 i.setData(Uri.parse(url));
5507 startActivity(i);
5508 break;
5509 case 17:
5510 // show age of maps (online)
5511 Intent i3 = new Intent(Intent.ACTION_VIEW);
5512 i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL));
5513 startActivity(i3);
5514 break;
5515 case 18:
5516 Intent intent_latlon = new Intent(Intent.ACTION_MAIN);
5517 //intent_latlon.setAction("android.intent.action.POINTPICK");
5518 intent_latlon.setPackage("com.cruthu.latlongcalc1");
5519 intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain");
5520 //intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick");
5521 try
5522 {
5523 startActivity(intent_latlon);
5524 }
5525 catch (Exception e88)
5526 {
5527 e88.printStackTrace();
5528 // show install page
5529 try
5530 {
5531 // String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1";
5532 String urlx = "market://details?id=com.cruthu.latlongcalc1";
5533 Intent ix = new Intent(Intent.ACTION_VIEW);
5534 ix.setData(Uri.parse(urlx));
5535 startActivity(ix);
5536 }
5537 catch (Exception ex)
5538 {
5539 ex.printStackTrace();
5540 }
5541 }
5542 break;
5543 case 19:
5544 // GeoCoordEnterDialog
5545 Intent it001 = new Intent(this, GeoCoordEnterDialog.class);
5546 this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id);
5547 break;
5548 case 20:
5549 // convert GPX file
5550 Intent intent77 = new Intent(getBaseContext(), FileDialog.class);
5551 File a = new File(p.PREF_last_selected_dir_gpxfiles);
5552 try
5553 {
5554 // convert the "/../" in the path to normal absolut dir
5555 intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath());
5556 //can user select directories or not
5557 intent77.putExtra(FileDialog.CAN_SELECT_DIR, false);
5558 // disable the "new" button
5559 intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
5560 //alternatively you can set file filter
5561 //intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" });
5562 startActivityForResult(intent77, Navit.NavitGPXConvChooser_id);
5563 }
5564 catch (IOException e1)
5565 {
5566 e1.printStackTrace();
5567 }
5568 break;
5569 case 21:
5570 // add traffic block (like blocked road, or construction site) at current location of crosshair
5571 try
5572 {
5573 String traffic = "";
5574 if (Navit.GFX_OVERSPILL)
5575 {
5576 traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * (NavitGraphics.mCanvasWidth / 2 + NavitGraphics.mCanvasWidth_overspill)), (int) (NavitGraphics.Global_dpi_factor * (NavitGraphics.mCanvasHeight / 2 + NavitGraphics.mCanvasHeight_overspill)));
5577 }
5578 else
5579 {
5580 traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2));
5581 }
5582
5583 // System.out.println("traffic=" + traffic);
5584 File traffic_file_dir = new File(MAP_FILENAME_PATH);
5585 traffic_file_dir.mkdirs();
5586 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
5587 FileOutputStream fOut = null;
5588 OutputStreamWriter osw = null;
5589 try
5590 {
5591 fOut = new FileOutputStream(traffic_file, true);
5592 osw = new OutputStreamWriter(fOut);
5593 osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header
5594 osw.write(traffic); // item coordinates
5595 osw.close();
5596 fOut.close();
5597 }
5598 catch (Exception ef)
5599 {
5600 ef.printStackTrace();
5601 }
5602
5603 // update route, if a route is set
5604 msg = new Message();
5605 b = new Bundle();
5606 b.putInt("Callback", 73);
5607 msg.setData(b);
5608 NavitGraphics.callback_handler.sendMessage(msg);
5609
5610 // draw map no-async
5611 msg = new Message();
5612 b = new Bundle();
5613 b.putInt("Callback", 64);
5614 msg.setData(b);
5615 NavitGraphics.callback_handler.sendMessage(msg);
5616 }
5617 catch (Exception e)
5618 {
5619 e.printStackTrace();
5620 }
5621 break;
5622 case 22:
5623 // clear all traffic blocks
5624 try
5625 {
5626 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
5627 traffic_file.delete();
5628
5629 // update route, if a route is set
5630 msg = new Message();
5631 b = new Bundle();
5632 b.putInt("Callback", 73);
5633 msg.setData(b);
5634 NavitGraphics.callback_handler.sendMessage(msg);
5635
5636 // draw map no-async
5637 msg = new Message();
5638 b = new Bundle();
5639 b.putInt("Callback", 64);
5640 msg.setData(b);
5641 NavitGraphics.callback_handler.sendMessage(msg);
5642 }
5643 catch (Exception e)
5644 {
5645 }
5646 break;
5647 case 23:
5648 // clear all GPX maps
5649 try
5650 {
5651 File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt");
5652 gpx_file.delete();
5653
5654 // draw map no-async
5655 msg = new Message();
5656 b = new Bundle();
5657 b.putInt("Callback", 64);
5658 msg.setData(b);
5659 NavitGraphics.callback_handler.sendMessage(msg);
5660 }
5661 catch (Exception e)
5662 {
5663 }
5664 break;
5665 case 24:
5666 // show feedback form
5667 Intent i4 = new Intent(this, NavitFeedbackFormActivity.class);
5668 this.startActivityForResult(i4, Navit.NavitSendFeedback_id);
5669 break;
5670 case 25:
5671 // share the current destination with your friends
5672 String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5673 if (current_target_string2.equals("x:x"))
5674 {
5675 Log.e("Navit", "no target set!");
5676 }
5677 else
5678 {
5679 try
5680 {
5681 String tmp[] = current_target_string2.split(":", 2);
5682
5683 if (Navit.OSD_route_001.arriving_time_valid)
5684 {
5685 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
5686 }
5687 else
5688 {
5689 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5690 }
5691 }
5692 catch (Exception e)
5693 {
5694 e.printStackTrace();
5695 Log.e("Navit", "problem with target!");
5696 }
5697 }
5698 break;
5699 case 26:
5700 // donate
5701 Log.e("Navit", "start donate app");
5702 donate();
5703 break;
5704 case 27:
5705 // donate
5706 Log.e("Navit", "donate bitcoins");
5707 donate_bitcoins();
5708 break;
5709 case 28:
5710 // replay GPS file
5711 Intent intent771 = new Intent(getBaseContext(), FileDialog.class);
5712 File a1 = new File(Navit.NAVIT_DATA_DEBUG_DIR);
5713 try
5714 {
5715 // convert the "/../" in the path to normal absolut dir
5716 intent771.putExtra(FileDialog.START_PATH, a1.getCanonicalPath());
5717 //can user select directories or not
5718 intent771.putExtra(FileDialog.CAN_SELECT_DIR, false);
5719 // disable the "new" button
5720 intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
5721 //alternatively you can set file filter
5722 intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" });
5723 startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id);
5724 }
5725 catch (IOException e1)
5726 {
5727 e1.printStackTrace();
5728 }
5729 break;
5730
5731 case 88:
5732 // dummy entry, just to make "breaks" in the menu
5733 break;
5734 case 601:
5735 // DEBUG: activate demo vehicle and set position to position to screen center
5736
5737 Navit.DemoVehicle = true;
5738
5739 msg = new Message();
5740 b = new Bundle();
5741 b.putInt("Callback", 101);
5742 msg.setData(b);
5743 NavitGraphics.callback_handler.sendMessage(msg);
5744
5745 final Thread demo_v_001 = new Thread()
5746 {
5747 @Override
5748 public void run()
5749 {
5750 try
5751 {
5752 Thread.sleep(1000); // wait 1 seconds before we start
5753
5754 try
5755 {
5756 float lat = 0;
5757 float lon = 0;
5758
5759 String lat_lon = "";
5760 if (Navit.GFX_OVERSPILL)
5761 {
5762 lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill));
5763 }
5764 else
5765 {
5766 lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
5767 }
5768 String tmp[] = lat_lon.split(":", 2);
5769 //System.out.println("tmp=" + lat_lon);
5770 lat = Float.parseFloat(tmp[0]);
5771 lon = Float.parseFloat(tmp[1]);
5772 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
5773 Location l = null;
5774 l = new Location("ZANavi Demo 001");
5775 l.setLatitude(lat);
5776 l.setLongitude(lon);
5777 l.setBearing(0.0f);
5778 l.setSpeed(0);
5779 l.setAccuracy(4.0f); // accuracy 4 meters
5780 // NavitVehicle.update_compass_heading(0.0f);
5781 NavitVehicle.set_mock_location__fast(l);
5782 }
5783 catch (Exception e)
5784 {
5785 }
5786
5787 Message msg = new Message();
5788 Bundle b = new Bundle();
5789 b.putInt("Callback", 52);
5790 b.putString("s", "45"); // speed in km/h of Demo-Vehicle
5791 // b.putString("s", "20");
5792
5793 msg.setData(b);
5794 NavitGraphics.callback_handler.sendMessage(msg);
5795 }
5796 catch (Exception e)
5797 {
5798 }
5799 }
5800 };
5801 demo_v_001.start();
5802
5803 msg = new Message();
5804 b = new Bundle();
5805 b.putInt("Callback", 51);
5806
5807 if (Navit.GFX_OVERSPILL)
5808 {
5809 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5810 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5811 }
5812 else
5813 {
5814 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
5815 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
5816 }
5817 msg.setData(b);
5818 NavitGraphics.callback_handler.sendMessage(msg);
5819
5820 break;
5821 case 602:
5822 // DEBUG: toggle textview with spoken and translated string (to help with translation)
5823 try
5824 {
5825 if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE)
5826 {
5827 NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE);
5828 NavitGraphics.NavitMsgTv2_.setEnabled(false);
5829 NavitGraphics.NavitMsgTv2sc_.setVisibility(View.GONE);
5830 NavitGraphics.NavitMsgTv2sc_.setEnabled(false);
5831 }
5832 else
5833 {
5834 NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE);
5835 NavitGraphics.NavitMsgTv2sc_.setEnabled(true);
5836 NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
5837 NavitGraphics.NavitMsgTv2_.setEnabled(true);
5838 }
5839 }
5840 catch (Exception e)
5841 {
5842 e.printStackTrace();
5843 }
5844 break;
5845 case 603:
5846 // DEBUG: show all possible navigation commands (also translated)
5847 NavitGraphics.generate_all_speech_commands();
5848 break;
5849 case 604:
5850 // DEBUG: activate FAST driving demo vehicle and set position to screen center
5851
5852 Navit.DemoVehicle = true;
5853
5854 msg = new Message();
5855
5856 b = new Bundle();
5857 b.putInt("Callback", 52);
5858 b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle
5859 msg.setData(b);
5860 NavitGraphics.callback_handler.sendMessage(msg);
5861
5862 msg = new Message();
5863 b = new Bundle();
5864 b.putInt("Callback", 51);
5865 if (Navit.GFX_OVERSPILL)
5866 {
5867 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5868 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5869 }
5870 else
5871 {
5872 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
5873 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
5874 }
5875 msg.setData(b);
5876 NavitGraphics.callback_handler.sendMessage(msg);
5877
5878 try
5879 {
5880 float lat = 0;
5881 float lon = 0;
5882
5883 lat = 0;
5884 lon = 0;
5885 String lat_lon = "";
5886 if (Navit.GFX_OVERSPILL)
5887 {
5888 lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill));
5889 }
5890 else
5891 {
5892 lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
5893 }
5894
5895 String tmp[] = lat_lon.split(":", 2);
5896 //System.out.println("tmp=" + lat_lon);
5897 lat = Float.parseFloat(tmp[0]);
5898 lon = Float.parseFloat(tmp[1]);
5899 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
5900 Location l = null;
5901 l = new Location("ZANavi Demo 001");
5902 l.setLatitude(lat);
5903 l.setLongitude(lon);
5904 l.setBearing(0.0f);
5905 l.setSpeed(0);
5906 l.setAccuracy(4.0f); // accuracy 4 meters
5907 // NavitVehicle.update_compass_heading(0.0f);
5908 NavitVehicle.set_mock_location__fast(l);
5909 }
5910 catch (Exception e)
5911 {
5912 }
5913
5914 break;
5915 case 605:
5916 // DEBUG: toggle Routgraph on/off
5917 msg = new Message();
5918 b = new Bundle();
5919 b.putInt("Callback", 71);
5920 Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled;
5921 b.putString("s", "" + Navit.Routgraph_enabled);
5922 msg.setData(b);
5923 NavitGraphics.callback_handler.sendMessage(msg);
5924 break;
5925 case 606:
5926 // DEBUG: spill contents of index file(s)
5927 msg = new Message();
5928 b = new Bundle();
5929 b.putInt("Callback", 83);
5930 msg.setData(b);
5931 NavitGraphics.callback_handler.sendMessage(msg);
5932 break;
5933 case 607:
5934 export_map_points_to_sdcard();
5935 break;
5936 case 608:
5937 import_map_points_from_sdcard();
5938 break;
5939 case 609:
5940 // run yaml tests
5941 new Thread()
5942 {
5943 public void run()
5944 {
5945 try
5946 {
5947 ZANaviDebugReceiver.DR_run_all_yaml_tests();
5948 }
5949 catch (Exception e)
5950 {
5951 }
5952 }
5953 }.start();
5954 break;
5955 case 99:
5956 try
5957 {
5958 if (wl_navigating != null)
5959 {
5960 //if (wl_navigating.isHeld())
5961 //{
5962 wl_navigating.release();
5963 Log.e("Navit", "WakeLock Nav: release 1");
5964 //}
5965 }
5966 }
5967 catch (Exception e)
5968 {
5969 e.printStackTrace();
5970 }
5971 // exit
5972 this.onPause();
5973 this.onStop();
5974 this.exit();
5975 //msg = new Message();
5976 //b = new Bundle();
5977 //b.putInt("Callback", 5);
5978 //b.putString("cmd", "quit();");
5979 //msg.setData(b);
5980 //N_NavitGraphics.callback_handler.sendMessage(msg);
5981 break;
5982 }
5983 return true;
5984 }
5985
5986 protected void onActivityResult(int requestCode, int resultCode, Intent data)
5987 {
5988 Log.e("Navit", "onActivityResult");
5989 switch (requestCode)
5990 {
5991 case Navit.NavitGPXConvChooser_id:
5992 try
5993 {
5994 Log.e("Navit", "onActivityResult 001");
5995 if (resultCode == ActionBarActivity.RESULT_OK)
5996 {
5997 String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
5998 convert_gpx_file_real(in_);
5999 }
6000 }
6001 catch (Exception e77)
6002 {
6003 e77.printStackTrace();
6004 }
6005 break;
6006
6007 case NavitReplayFileConvChooser_id:
6008 try
6009 {
6010 if (resultCode == ActionBarActivity.RESULT_OK)
6011 {
6012 final String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
6013 final Thread replay_gpx_file_001 = new Thread()
6014 {
6015 @Override
6016 public void run()
6017 {
6018 try
6019 {
6020 Thread.sleep(2000); // wait 2 seconds before we start
6021 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
6022 ZANaviDebugReceiver.DR_replay_gps_file(in_, date);
6023 }
6024 catch (Exception e)
6025 {
6026 }
6027 }
6028 };
6029 replay_gpx_file_001.start();
6030 }
6031 }
6032 catch (Exception e77)
6033 {
6034 e77.printStackTrace();
6035 }
6036 break;
6037
6038 case Navit.NavitDeleteSecSelectMap_id:
6039 try
6040 {
6041 if (resultCode == ActionBarActivity.RESULT_OK)
6042 {
6043 System.out.println("Global_Location_update_not_allowed = 1");
6044 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6045
6046 // remove all sdcard maps
6047 Message msg = new Message();
6048 Bundle b = new Bundle();
6049 b.putInt("Callback", 19);
6050 msg.setData(b);
6051 NavitGraphics.callback_handler.sendMessage(msg);
6052
6053 try
6054 {
6055 Thread.sleep(100);
6056 }
6057 catch (InterruptedException e)
6058 {
6059 }
6060
6061 Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6062 String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
6063 Log.d("Navit", "delete map full line=" + map_full_line);
6064
6065 String del_map_name = MAP_FILENAME_PATH + map_full_line.split(":", 2)[0];
6066 System.out.println("del map file :" + del_map_name);
6067 // remove from cat file
6068 NavitMapDownloader.remove_from_cat_file(map_full_line);
6069 // remove from disk
6070 File del_map_name_file = new File(del_map_name);
6071 del_map_name_file.delete();
6072 for (int jkl = 1; jkl < 51; jkl++)
6073 {
6074 File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl));
6075 del_map_name_fileSplit.delete();
6076 }
6077 // also remove index file
6078 File del_map_name_file_idx = new File(del_map_name + ".idx");
6079 del_map_name_file_idx.delete();
6080 // remove also any MD5 files for this map that may be on disk
6081 try
6082 {
6083 String tmp = map_full_line.split(":", 2)[1];
6084 if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN))
6085 {
6086 tmp = tmp.replace("*", "");
6087 tmp = tmp.replace("/", "");
6088 tmp = tmp.replace("\\", "");
6089 tmp = tmp.replace(" ", "");
6090 tmp = tmp.replace(">", "");
6091 tmp = tmp.replace("<", "");
6092 System.out.println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
6093 File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
6094 md5_final_filename.delete();
6095 }
6096 }
6097 catch (Exception e)
6098 {
6099 e.printStackTrace();
6100 }
6101
6102 // remove map, and zoom out
6103 // ***** onStop();
6104 // ***** onCreate(getIntent().getExtras());
6105
6106 try
6107 {
6108 Thread.sleep(100);
6109 }
6110 catch (InterruptedException e)
6111 {
6112 }
6113
6114 // add all sdcard maps
6115 msg = new Message();
6116 b = new Bundle();
6117 b.putInt("Callback", 20);
6118 msg.setData(b);
6119 NavitGraphics.callback_handler.sendMessage(msg);
6120
6121 final Thread zoom_to_route_004 = new Thread()
6122 {
6123 int wait = 1;
6124 int count = 0;
6125 int max_count = 60;
6126
6127 @Override
6128 public void run()
6129 {
6130 while (wait == 1)
6131 {
6132 try
6133 {
6134 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6135 {
6136 zoom_to_route();
6137 wait = 0;
6138 }
6139 else
6140 {
6141 wait = 1;
6142 }
6143
6144 count++;
6145 if (count > max_count)
6146 {
6147 wait = 0;
6148 }
6149 else
6150 {
6151 Thread.sleep(400);
6152 }
6153 }
6154 catch (Exception e)
6155 {
6156 }
6157 }
6158 }
6159 };
6160 zoom_to_route_004.start();
6161
6162 System.out.println("Global_Location_update_not_allowed = 0");
6163 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
6164 }
6165 }
6166 catch (Exception e)
6167 {
6168 Log.d("Navit", "error on onActivityResult 3");
6169 e.printStackTrace();
6170 }
6171 break;
6172 case Navit.NavitDownloaderPriSelectMap_id:
6173 try
6174 {
6175 if (resultCode == ActionBarActivity.RESULT_OK)
6176 {
6177 try
6178 {
6179 // Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6180 // set map id to download
6181 Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
6182 // show the map download progressbar, and download the map
6183 if (Navit.download_map_id > -1)
6184 {
6185 // --------- start a map download (highest level) ---------
6186 // --------- start a map download (highest level) ---------
6187 // --------- start a map download (highest level) ---------
6188 // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app
6189
6190 // new method in service
6191 Message msg = progress_handler.obtainMessage();
6192 // Bundle b = new Bundle();
6193 msg.what = 22;
6194 progress_handler.sendMessage(msg);
6195
6196 // show license for OSM maps
6197 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
6198 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
6199 // --------- start a map download (highest level) ---------
6200 // --------- start a map download (highest level) ---------
6201 // --------- start a map download (highest level) ---------
6202 }
6203 }
6204 catch (NumberFormatException e)
6205 {
6206 Log.d("Navit", "NumberFormatException selected_id");
6207 }
6208 }
6209 else
6210 {
6211 // user pressed back key
6212 }
6213 }
6214 catch (Exception e)
6215 {
6216 Log.d("Navit", "error on onActivityResult");
6217 e.printStackTrace();
6218 }
6219 break;
6220 case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!!
6221 break;
6222 case ZANaviVoiceInput_id:
6223 if (resultCode == ActionBarActivity.RESULT_OK)
6224 {
6225 try
6226 {
6227 String addr = data.getStringExtra("address_string");
6228 double lat = data.getDoubleExtra("lat", 0);
6229 double lon = data.getDoubleExtra("lon", 0);
6230 String hn = "";
6231
6232 // save last address entry string
6233 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6234 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6235
6236 Boolean partial_match = true;
6237 Navit.use_index_search = false;
6238
6239 Navit_last_address_partial_match = partial_match;
6240 Navit_last_address_search_string = addr;
6241 Navit_last_address_hn_string = hn;
6242
6243 Navit_last_address_full_file_search = false;
6244
6245 // clear results
6246 Navit.NavitAddressResultList_foundItems.clear();
6247 Navit.Navit_Address_Result_double_index.clear();
6248 Navit.NavitSearchresultBarIndex = -1;
6249 Navit.NavitSearchresultBar_title = "";
6250 Navit.NavitSearchresultBar_text = "";
6251 Navit.search_results_towns = 0;
6252 Navit.search_results_streets = 0;
6253 Navit.search_results_streets_hn = 0;
6254 Navit.search_results_poi = 0;
6255
6256 if (addr.equals(""))
6257 {
6258 // empty search string entered
6259 Toast.makeText(getApplicationContext(), Navit.get_text("No search string"), Toast.LENGTH_LONG).show(); //TRANS
6260 }
6261 else
6262 {
6263 System.out.println("Global_Location_update_not_allowed = 1");
6264 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6265
6266 // --> this still does the search // google_online_search_and_set_destination(addr);
6267 result_set_destination(lat, lon, addr);
6268
6269 System.out.println("Global_Location_update_not_allowed = 0");
6270 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
6271 }
6272
6273 }
6274 catch (Exception e)
6275 {
6276
6277 }
6278 }
6279 break;
6280 case NavitAddressSearch_id_online:
6281 case NavitAddressSearch_id_offline:
6282 Log.e("Navit", "NavitAddressSearch_id_:001");
6283 try
6284 {
6285 if (resultCode == ActionBarActivity.RESULT_OK)
6286 {
6287 try
6288 {
6289 String addr = data.getStringExtra("address_string");
6290 String hn = "";
6291 try
6292 {
6293 // only from offline mask!
6294 hn = data.getStringExtra("hn_string");
6295 }
6296 catch (Exception e)
6297 {
6298 hn = "";
6299 }
6300
6301 // save last address entry string
6302 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6303 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6304
6305 Boolean partial_match = false;
6306 try
6307 {
6308 // only from offline mask!
6309 partial_match = data.getStringExtra("partial_match").equals("1");
6310 }
6311 catch (Exception e)
6312 {
6313 }
6314
6315 Message msg2 = new Message();
6316 Bundle b2 = new Bundle();
6317 b2.putInt("Callback", 44);
6318 msg2.setData(b2);
6319 NavitGraphics.callback_handler.sendMessage(msg2);
6320
6321 if (requestCode == NavitAddressSearch_id_offline)
6322 {
6323 search_hide_duplicates = false;
6324 try
6325 {
6326 Boolean hide_dup = data.getStringExtra("hide_dup").equals("1");
6327 if (hide_dup)
6328 {
6329 search_hide_duplicates = true;
6330 Message msg = new Message();
6331 Bundle b = new Bundle();
6332 b.putInt("Callback", 45);
6333 msg.setData(b);
6334 NavitGraphics.callback_handler.sendMessage(msg);
6335 }
6336 }
6337 catch (Exception e)
6338 {
6339 }
6340
6341 if (Navit.CIDEBUG == 0)
6342 {
6343 Navit.use_index_search = Navit.allow_use_index_search();
6344 }
6345 }
6346 else
6347 {
6348 Navit.use_index_search = false;
6349 }
6350
6351 Navit_last_address_partial_match = partial_match;
6352 Navit_last_address_search_string = addr;
6353 Navit_last_address_hn_string = hn;
6354
6355 try
6356 {
6357 // only from offline mask!
6358 Navit_last_address_full_file_search = data.getStringExtra("full_file_search").equals("1");
6359 }
6360 catch (Exception e)
6361 {
6362 Navit_last_address_full_file_search = false;
6363 }
6364
6365 try
6366 {
6367 // only from offline mask!
6368 Navit_last_address_search_country_iso2_string = data.getStringExtra("address_country_iso2");
6369
6370 Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3);
6371 // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags);
6372 Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL*
6373 p.PREF_search_country = Navit_last_address_search_country_id;
6374 setPrefs_search_country();
6375 }
6376 catch (Exception e)
6377 {
6378
6379 }
6380
6381 // clear results
6382 Navit.NavitAddressResultList_foundItems.clear();
6383 Navit.Navit_Address_Result_double_index.clear();
6384 Navit.NavitSearchresultBarIndex = -1;
6385 Navit.NavitSearchresultBar_title = "";
6386 Navit.NavitSearchresultBar_text = "";
6387 Navit.search_results_towns = 0;
6388 Navit.search_results_streets = 0;
6389 Navit.search_results_streets_hn = 0;
6390 Navit.search_results_poi = 0;
6391
6392 if (addr.equals(""))
6393 {
6394 // empty search string entered
6395 Toast.makeText(getApplicationContext(), Navit.get_text("No search string entered"), Toast.LENGTH_LONG).show(); //TRANS
6396 }
6397 else
6398 {
6399 System.out.println("Global_Location_update_not_allowed = 1");
6400 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6401
6402 if (requestCode == NavitAddressSearch_id_online)
6403 {
6404 // online googlemaps search
6405 try
6406 {
6407 Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG);
6408 }
6409 catch (Exception e)
6410 {
6411 e.printStackTrace();
6412 }
6413
6414 System.out.println("dialog -- 11:003");
6415 System.out.println("online googlemaps search");
6416 Message msg = progress_handler.obtainMessage();
6417 Bundle b = new Bundle();
6418 msg.what = 11;
6419 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
6420 msg.setData(b);
6421 progress_handler.sendMessage(msg);
6422 }
6423 else if (requestCode == NavitAddressSearch_id_offline)
6424 {
6425 // offline binfile search
6426
6427 if (!Navit.use_index_search)
6428 {
6429 try
6430 {
6431 Log.e("Navit", "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6432 }
6433 catch (Exception e)
6434 {
6435 e.printStackTrace();
6436 }
6437
6438 // show dialog, and start search for the results
6439 // make it indirect, to give our activity a chance to startup
6440 // (remember we come straight from another activity and ours is still paused!)
6441 System.out.println("dialog -- 11:004");
6442 Message msg = progress_handler.obtainMessage();
6443 Bundle b = new Bundle();
6444 msg.what = 11;
6445 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6446 msg.setData(b);
6447 progress_handler.sendMessage(msg);
6448 }
6449 }
6450 }
6451 }
6452 catch (NumberFormatException e)
6453 {
6454 Log.d("Navit", "NumberFormatException selected_id");
6455 }
6456 }
6457 else
6458 {
6459 // user pressed back key
6460 Log.e("Navit", "NavitAddressSearch_id_:900");
6461 }
6462 }
6463 catch (Exception e)
6464 {
6465 Log.d("Navit", "error on onActivityResult");
6466 e.printStackTrace();
6467 }
6468 Log.e("Navit", "NavitAddressSearch_id_:999");
6469 break;
6470 case Navit.NavitAddressResultList_id:
6471 try
6472 {
6473 if (resultCode == ActionBarActivity.RESULT_OK)
6474 {
6475 try
6476 {
6477 if (data.getStringExtra("what").equals("view"))
6478 {
6479 // get the coords for the destination
6480 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6481
6482 // save last address entry string
6483 String addr = data.getStringExtra("address_string");
6484 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6485 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6486
6487 try
6488 {
6489 Navit.follow_button_off();
6490 }
6491 catch (Exception e2)
6492 {
6493 e2.printStackTrace();
6494 }
6495
6496 System.out.println("XSOM:009");
6497
6498 if (Navit.use_index_search)
6499 {
6500 show_geo_on_screen_with_zoom_and_delay((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
6501 }
6502 else
6503 {
6504 show_geo_on_screen_with_zoom_and_delay(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6505 }
6506 }
6507 else if (data.getStringExtra("what").equals("set"))
6508 {
6509 Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6510
6511 // save last address entry string
6512 String addr = data.getStringExtra("address_string");
6513 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6514 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6515
6516 // get the coords for the destination
6517 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6518
6519 String _addr = "";
6520 double _lat = 0;
6521 double _lon = 0;
6522
6523 // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)
6524 // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)
6525
6526 // ok now set target
6527 try
6528 {
6529 if (Navit.use_index_search)
6530 {
6531 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6532 _lat = Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat);
6533 _lon = Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6534 //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
6535 }
6536 else
6537 {
6538 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6539 _lat = Navit.NavitAddressResultList_foundItems.get(destination_id).lat;
6540 _lon = Navit.NavitAddressResultList_foundItems.get(destination_id).lon;
6541 //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6542 }
6543 // save points
6544 //write_map_points();
6545 }
6546 catch (Exception e)
6547 {
6548 e.printStackTrace();
6549 }
6550
6551 route_wrapper(_addr, 0, 0, false, _lat, _lon, true);
6552
6553 final Thread zoom_to_route_005 = new Thread()
6554 {
6555 int wait = 1;
6556 int count = 0;
6557 int max_count = 60;
6558
6559 @Override
6560 public void run()
6561 {
6562 while (wait == 1)
6563 {
6564 try
6565 {
6566 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6567 {
6568 zoom_to_route();
6569 wait = 0;
6570 }
6571 else
6572 {
6573 wait = 1;
6574 }
6575
6576 count++;
6577 if (count > max_count)
6578 {
6579 wait = 0;
6580 }
6581 else
6582 {
6583 Thread.sleep(400);
6584 }
6585 }
6586 catch (Exception e)
6587 {
6588 }
6589 }
6590 }
6591 };
6592 zoom_to_route_005.start();
6593 // zoom_to_route();
6594
6595 // ---------- DEBUG: write route to file ----------
6596 // ---------- DEBUG: write route to file ----------
6597 // ---------- DEBUG: write route to file ----------
6598 if (p.PREF_enable_debug_write_gpx)
6599 {
6600 write_route_to_gpx_file();
6601 }
6602 // ---------- DEBUG: write route to file ----------
6603 // ---------- DEBUG: write route to file ----------
6604
6605 try
6606 {
6607 Navit.follow_button_on();
6608 }
6609 catch (Exception e2)
6610 {
6611 e2.printStackTrace();
6612 }
6613
6614 // if (Navit.use_index_search)
6615 // {
6616 // show_geo_on_screen((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
6617 // }
6618 // else
6619 // {
6620 // show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6621 // }
6622 }
6623 else
6624 {
6625 // -- nothing --
6626 }
6627 }
6628 catch (NumberFormatException e)
6629 {
6630 Log.d("Navit", "NumberFormatException selected_id");
6631 }
6632 catch (Exception e)
6633 {
6634
6635 }
6636 }
6637 else
6638 {
6639 // user pressed back key
6640 }
6641 }
6642 catch (Exception e)
6643 {
6644 Log.d("Navit", "error on onActivityResult");
6645 e.printStackTrace();
6646 }
6647 break;
6648 case NavitAddressSearch_id_gmaps:
6649 try
6650 {
6651 if (resultCode == ActionBarActivity.RESULT_OK)
6652 {
6653
6654 }
6655 }
6656 catch (Exception e)
6657 {
6658 e.printStackTrace();
6659 }
6660 break;
6661 case NavitAddressSearch_id_sharedest:
6662 try
6663 {
6664 if (resultCode == ActionBarActivity.RESULT_OK)
6665 {
6666
6667 }
6668 Log.d("Navit", "sharedest: finished");
6669 }
6670 catch (Exception e)
6671 {
6672 e.printStackTrace();
6673 }
6674 break;
6675 case NavitGeoCoordEnter_id:
6676 try
6677 {
6678 if (resultCode == ActionBarActivity.RESULT_OK)
6679 {
6680 // lat lon enter activitiy result
6681
6682 try
6683 {
6684 if (data.getStringExtra("what").equals("view"))
6685 {
6686 // get the coords for the destination
6687 float lat = Float.parseFloat(data.getStringExtra("lat"));
6688 float lon = Float.parseFloat(data.getStringExtra("lon"));
6689
6690 // Log.d("Navit", "coord picker: " + lat);
6691 // Log.d("Navit", "coord picker: " + lon);
6692
6693 // set nice zoomlevel before we show destination
6694 // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
6695 // //
6696 // Message msg = new Message();
6697 // Bundle b = new Bundle();
6698 // b.putInt("Callback", 33);
6699 // b.putString("s", Integer.toString(zoom_want));
6700 // msg.setData(b);
6701 // try
6702 // {
6703 // N_NavitGraphics.callback_handler.sendMessage(msg);
6704 // Navit.GlobalScaleLevel = zoom_want;
6705 // }
6706 // catch (Exception e)
6707 // {
6708 // e.printStackTrace();
6709 // }
6710 // if (PREF_save_zoomlevel)
6711 // {
6712 // setPrefs_zoomlevel();
6713 // }
6714 // set nice zoomlevel before we show destination
6715
6716 try
6717 {
6718 Navit.follow_button_off();
6719 }
6720 catch (Exception e2)
6721 {
6722 e2.printStackTrace();
6723 }
6724
6725 show_geo_on_screen(lat, lon);
6726 }
6727 else
6728 {
6729 // get the coords for the destination
6730 float lat = Float.parseFloat(data.getStringExtra("lat"));
6731 float lon = Float.parseFloat(data.getStringExtra("lat"));
6732 String dest_name = "manual coordinates";
6733
6734 // ok now set target
6735 try
6736 {
6737 dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon);
6738 if ((dest_name.equals(" ")) || (dest_name == null))
6739 {
6740 dest_name = "manual coordinates";
6741 }
6742 // Navit.remember_destination(dest_name, lat, lon);
6743 // // save points
6744 // write_map_points();
6745 }
6746 catch (Exception e)
6747 {
6748 e.printStackTrace();
6749 }
6750
6751 // // DEBUG: clear route rectangle list
6752 // NavitGraphics.route_rects.clear();
6753 //
6754 // if (NavitGraphics.navit_route_status == 0)
6755 // {
6756 // Navit.destination_set();
6757 //
6758 // Message msg = new Message();
6759 // Bundle b = new Bundle();
6760 // b.putInt("Callback", 3);
6761 // b.putString("lat", String.valueOf(lat));
6762 // b.putString("lon", String.valueOf(lon));
6763 // b.putString("q", dest_name);
6764 // msg.setData(b);
6765 // NavitGraphics.callback_handler.sendMessage(msg);
6766 // }
6767 // else
6768 // {
6769 // Message msg = new Message();
6770 // Bundle b = new Bundle();
6771 // b.putInt("Callback", 48);
6772 // b.putString("lat", String.valueOf(lat));
6773 // b.putString("lon", String.valueOf(lon));
6774 // b.putString("q", dest_name);
6775 // msg.setData(b);
6776 // NavitGraphics.callback_handler.sendMessage(msg);
6777 // }
6778 //
6779
6780 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
6781
6782 final Thread zoom_to_route_006 = new Thread()
6783 {
6784 int wait = 1;
6785 int count = 0;
6786 int max_count = 60;
6787
6788 @Override
6789 public void run()
6790 {
6791 while (wait == 1)
6792 {
6793 try
6794 {
6795 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6796 {
6797 zoom_to_route();
6798 wait = 0;
6799 }
6800 else
6801 {
6802 wait = 1;
6803 }
6804
6805 count++;
6806 if (count > max_count)
6807 {
6808 wait = 0;
6809 }
6810 else
6811 {
6812 Thread.sleep(400);
6813 }
6814 }
6815 catch (Exception e)
6816 {
6817 }
6818 }
6819 }
6820 };
6821 zoom_to_route_006.start();
6822 // zoom_to_route();
6823
6824 // ---------- DEBUG: write route to file ----------
6825 // ---------- DEBUG: write route to file ----------
6826 // ---------- DEBUG: write route to file ----------
6827 if (p.PREF_enable_debug_write_gpx)
6828 {
6829 write_route_to_gpx_file();
6830 }
6831 // ---------- DEBUG: write route to file ----------
6832 // ---------- DEBUG: write route to file ----------
6833
6834 try
6835 {
6836 Navit.follow_button_on();
6837 }
6838 catch (Exception e2)
6839 {
6840 e2.printStackTrace();
6841 }
6842
6843 // show_geo_on_screen(lat, lon);
6844 }
6845 }
6846 catch (NumberFormatException e)
6847 {
6848 Log.d("Navit", "NumberFormatException selected_id");
6849 }
6850 catch (Exception e)
6851 {
6852
6853 }
6854 }
6855 }
6856 catch (Exception e)
6857 {
6858 e.printStackTrace();
6859 }
6860 break;
6861 case NavitRecentDest_id:
6862 try
6863 {
6864 if (resultCode == ActionBarActivity.RESULT_OK)
6865 {
6866 Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6867 // get the coords for the destination
6868 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6869
6870 if (data.getStringExtra("what").equals("view"))
6871 {
6872 try
6873 {
6874 Navit.follow_button_off();
6875 }
6876 catch (Exception e2)
6877 {
6878 e2.printStackTrace();
6879 }
6880
6881 float lat = Navit.map_points.get(destination_id).lat;
6882 float lon = Navit.map_points.get(destination_id).lon;
6883 show_geo_on_screen_with_zoom_and_delay(lat, lon, 150);
6884 }
6885 else
6886 {
6887 // ok now set target
6888 String dest_name = Navit.map_points.get(destination_id).point_name;
6889 float lat = Navit.map_points.get(destination_id).lat;
6890 float lon = Navit.map_points.get(destination_id).lon;
6891
6892 // System.out.println("XXXXXX:" + lat + " " + lon);
6893
6894 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
6895
6896 final Thread zoom_to_route_007 = new Thread()
6897 {
6898 int wait = 1;
6899 int count = 0;
6900 int max_count = 60;
6901
6902 @Override
6903 public void run()
6904 {
6905 while (wait == 1)
6906 {
6907 try
6908 {
6909 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6910 {
6911 zoom_to_route();
6912 wait = 0;
6913 }
6914 else
6915 {
6916 wait = 1;
6917 }
6918
6919 count++;
6920 if (count > max_count)
6921 {
6922 wait = 0;
6923 }
6924 else
6925 {
6926 Thread.sleep(400);
6927 }
6928 }
6929 catch (Exception e)
6930 {
6931 }
6932 }
6933 }
6934 };
6935 zoom_to_route_007.start();
6936
6937 // ---------- DEBUG: write route to file ----------
6938 // ---------- DEBUG: write route to file ----------
6939 // ---------- DEBUG: write route to file ----------
6940 if (p.PREF_enable_debug_write_gpx)
6941 {
6942 write_route_to_gpx_file();
6943 }
6944 // ---------- DEBUG: write route to file ----------
6945 // ---------- DEBUG: write route to file ----------
6946
6947 try
6948 {
6949 Navit.follow_button_on();
6950 }
6951 catch (Exception e2)
6952 {
6953 e2.printStackTrace();
6954 }
6955
6956 }
6957 }
6958 }
6959 catch (Exception e)
6960 {
6961 e.printStackTrace();
6962 }
6963 break;
6964
6965 case NavitSendFeedback_id:
6966 try
6967 {
6968 if (resultCode == ActionBarActivity.RESULT_OK)
6969 {
6970 String feedback_text = data.getStringExtra("feedback_text");
6971
6972 String subject_d_version = "";
6973 if (Navit_DonateVersion_Installed)
6974 {
6975 subject_d_version = subject_d_version + "D,";
6976 }
6977
6978 if (Navit_Largemap_DonateVersion_Installed)
6979 {
6980 subject_d_version = subject_d_version + "L,";
6981 }
6982
6983 try
6984 {
6985 int rl = get_reglevel();
6986
6987 if (rl > 0)
6988 {
6989 subject_d_version = "U" + rl + ",";
6990 }
6991 }
6992 catch (Exception e)
6993 {
6994 e.printStackTrace();
6995 }
6996
6997 String FD_addon = "";
6998 if (FDBL)
6999 {
7000 FD_addon = ",FD";
7001 }
7002
7003 sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + FD_addon + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text);
7004 }
7005 }
7006 catch (Exception e)
7007 {
7008 e.printStackTrace();
7009 Toast.makeText(getApplicationContext(), Navit.get_text("there was a problem with sending feedback"), Toast.LENGTH_SHORT).show(); //TRANS
7010 }
7011 break;
7012
7013 default:
7014 Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode);
7015 try
7016 {
7017 // ---------- what is this doing ????? ----------
7018 // ---------- what is this doing ????? ----------
7019 // ---------- what is this doing ????? ----------
7020 // ---------- what is this doing ????? ----------
7021 // ---------- what is this doing ????? ----------
7022 // ---------- what is this doing ????? ----------
7023 // ---------- what is this doing ????? ----------
7024 // ---------- what is this doing ????? ----------
7025 // ---------- what is this doing ????? ----------
7026 // ---------- what is this doing ????? ----------
7027 // ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
7028 // ---------- what is this doing ????? ----------
7029 // ---------- what is this doing ????? ----------
7030 // ---------- what is this doing ????? ----------
7031 // ---------- what is this doing ????? ----------
7032 // ---------- what is this doing ????? ----------
7033 // ---------- what is this doing ????? ----------
7034 // ---------- what is this doing ????? ----------
7035 // ---------- what is this doing ????? ----------
7036 }
7037 catch (Exception e)
7038 {
7039 e.printStackTrace();
7040 }
7041 break;
7042 }
7043 Log.e("Navit", "onActivityResult finished");
7044 }
7045
7046 public class SCCB_object
7047 {
7048 int w;
7049 int h;
7050 Bitmap mb;
7051 }
7052
7053 public class CMC_object
7054 {
7055 int i;
7056 String s;
7057 }
7058
7059 public class MCB_object
7060 {
7061 int x1;
7062 int y1;
7063 int x2;
7064
7065 int y2;
7066 }
7067
7068 public class TCB_object
7069 {
7070 int del;
7071 int id;
7072 NavitTimeout nt;
7073 }
7074
7075 public class GeCB_Object
7076 {
7077 int type;
7078 int a;
7079 float b;
7080 float c;
7081 }
7082
7083 public class LowQ_Object
7084 {
7085 String latlonzoom;
7086 int w;
7087 int h;
7088 int fontsize;
7089 int scale;
7090 int selection_range;
7091 }
7092
7093 public class CWorkerThread extends Thread
7094 {
7095 private Boolean running;
7096 Boolean startmain = false;
7097 private CMC_object l2;
7098 private Integer l3;
7099 private MCB_object l4;
7100 private TCB_object l5;
7101 private SCCB_object l6;
7102 private Location l7;
7103 private GeCB_Object l8;
7104 private LowQ_Object l9;
7105
7106 Navit x;
7107 String lang;
7108 int version;
7109 String display_density_string;
7110 int timeout_loop_counter = 0;
7111 String n_datadir;
7112 String n_sharedir;
7113
7114 private final LinkedBlockingQueue<CMC_object> queue = new LinkedBlockingQueue<CMC_object>();
7115 private final LinkedBlockingQueue<Integer> queue2 = new LinkedBlockingQueue<Integer>();
7116 private final LinkedBlockingQueue<MCB_object> queue3 = new LinkedBlockingQueue<MCB_object>();
7117 private final LinkedBlockingQueue<TCB_object> queue4 = new LinkedBlockingQueue<TCB_object>();
7118 private final LinkedBlockingQueue<SCCB_object> queue5 = new LinkedBlockingQueue<SCCB_object>();
7119 private final LinkedBlockingQueue<Location> queue6 = new LinkedBlockingQueue<Location>();
7120 private final LinkedBlockingQueue<GeCB_Object> queue7 = new LinkedBlockingQueue<GeCB_Object>();
7121 private final LinkedBlockingQueue<LowQ_Object> queue8 = new LinkedBlockingQueue<LowQ_Object>();
7122
7123 CWorkerThread()
7124 {
7125 this.running = true;
7126 }
7127
7128 public void DrawLowqualMap_wrapper(String latlonzoom, int w, int h, int fontsize, int scale, int selection_range)
7129 {
7130 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7131
7132 LowQ_Object o = new LowQ_Object();
7133 o.latlonzoom = latlonzoom;
7134 o.w = w;
7135 o.h = h;
7136 o.fontsize = fontsize;
7137 o.scale = scale;
7138 o.selection_range = selection_range;
7139 queue8.offer(o);
7140 this.interrupt();
7141
7142 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7143 }
7144
7145 public void SizeChangedCallback(int w, int h, Bitmap main_map_bitmap)
7146 {
7147 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7148
7149 SCCB_object sccbo = new SCCB_object();
7150 sccbo.w = w;
7151 sccbo.h = h;
7152 sccbo.mb = main_map_bitmap;
7153 queue5.offer(sccbo);
7154 this.interrupt();
7155
7156 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7157 }
7158
7159 public void TimeoutCallback2(NavitTimeout nt, int del, int id)
7160 {
7161 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7162
7163 TCB_object tcbo = new TCB_object();
7164 tcbo.del = del;
7165 tcbo.id = id;
7166 tcbo.nt = nt;
7167 queue4.offer(tcbo);
7168 this.interrupt();
7169 //timeout_loop_counter++;
7170
7171 //if (timeout_loop_counter > 100)
7172 //{
7173 // timeout_loop_counter = 0;
7174 // // run GC at every 100th loop
7175 // // System.gc();
7176 //}
7177 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7178 }
7179
7180 public void CallbackMessageChannel(int i, String s)
7181 {
7182 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0, "id=" + i);
7183 CMC_object cmco = new CMC_object();
7184 cmco.i = i;
7185 cmco.s = s;
7186 queue.offer(cmco);
7187 this.interrupt();
7188 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7189 }
7190
7191 public void MotionCallback(int x1, int y1, int x2, int y2)
7192 {
7193 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7194
7195 //System.out.println("MotionCallback:enter queue=" + queue3.size());
7196 MCB_object mcbo = new MCB_object();
7197 mcbo.x1 = x1;
7198 mcbo.y1 = y1;
7199 mcbo.x2 = x2;
7200 mcbo.y2 = y2;
7201 queue3.offer(mcbo);
7202 this.interrupt();
7203 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7204 }
7205
7206 public void NavitActivity2(int i)
7207 {
7208 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7209
7210 queue2.offer(Integer.valueOf(i));
7211 this.interrupt();
7212 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7213 }
7214
7215 public void CallbackGeoCalc2(int type, int a, float b, float c)
7216 {
7217 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7218
7219 GeCB_Object gcco = new GeCB_Object();
7220 gcco.type = type;
7221 gcco.a = a;
7222 gcco.b = b;
7223 gcco.c = c;
7224 queue7.offer(gcco);
7225 this.interrupt();
7226
7227 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7228 }
7229
7230 public void StartMain(Navit x, String lang, int version, String display_density_string, String n_datadir, String n_sharedir)
7231 {
7232 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7233
7234 //System.out.println("CWorkerThread:StartMain:JTHREAD ID=" + this.getId());
7235 //System.out.println("CWorkerThread:StartMain:THREAD ID=" + NavitGraphics.GetThreadId());
7236
7237 this.startmain = true;
7238 this.x = x;
7239 this.lang = lang;
7240 this.version = version;
7241 this.n_datadir = n_datadir;
7242 this.n_sharedir = n_sharedir;
7243 this.display_density_string = display_density_string;
7244 this.interrupt();
7245
7246 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7247 }
7248
7249 public void VehicleCallback3(Location location)
7250 {
7251 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7252
7253 boolean your_are_speeding_old = Navit.your_are_speeding;
7254
7255 if ((Navit.cur_max_speed != -1) && (Navit.isGPSFix))
7256 {
7257 if ((location.getSpeed() * 3.6f) > ((float) Navit.cur_max_speed * (((float) p.PREF_roadspeed_warning_margin + 100.0f) / 100.0f)))
7258 {
7259 Navit.your_are_speeding = true;
7260
7261 try
7262 {
7263
7264 if (!toneG_heared)
7265 {
7266 // make "beep" sound to indicate we are going to fast!!
7267 if (toneG != null)
7268 {
7269 if (p.PREF_roadspeed_warning)
7270 {
7271 toneG.stopTone();
7272 toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 500);
7273 }
7274 toneG_heared = true;
7275 }
7276
7277 }
7278 }
7279 catch (Exception e)
7280 {
7281 }
7282 }
7283 else
7284 {
7285 // reset "beep" flag
7286 Navit.toneG_heared = false;
7287 Navit.your_are_speeding = false;
7288 }
7289 }
7290 else
7291 {
7292 Navit.your_are_speeding = false;
7293 }
7294
7295 if (your_are_speeding_old != Navit.your_are_speeding)
7296 {
7297 //System.out.println("xx paint 6 xx");
7298 // NavitOSDJava.draw_real_wrapper(false, true);
7299 ZANaviLinearLayout.redraw_OSD(8);
7300 }
7301
7302 if (queue6.size() > 5)
7303 {
7304 while (queue6.size() > 5)
7305 {
7306 try
7307 {
7308 // if too many gps updates are waiting, then only process the last few entry!!
7309 queue6.poll();
7310 }
7311 catch (Exception e)
7312 {
7313 }
7314 }
7315 }
7316
7317 queue6.offer(location);
7318 this.interrupt();
7319
7320 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7321 }
7322
7323 public void calc_sun_stats()
7324 {
7325 //
7326 //
7327 // SUN ----------------
7328 //
7329 //
7330 sun_moon__must_calc_new = (SystemClock.elapsedRealtime() - sun_moon__mLastCalcSunMillis) > (60000 * 3); // calc new every 3 minutes
7331
7332 if ((sun_moon__must_calc_new) || (azmiuth_cache == -1))
7333 {
7334 float lat = 0;
7335 float lon = 0;
7336 try
7337 {
7338 // String lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
7339 String lat_lon = "";
7340 if (Navit.GFX_OVERSPILL)
7341 {
7342 lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill), NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill));
7343 }
7344 else
7345 {
7346 lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2, NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
7347 }
7348
7349 String tmp[] = lat_lon.split(":", 2);
7350 //System.out.println("tmp=" + lat_lon);
7351 lat = Float.parseFloat(tmp[0]);
7352 lon = Float.parseFloat(tmp[1]);
7353 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
7354 }
7355 catch (Exception e)
7356 {
7357 }
7358
7359 try
7360 {
7361 sun_moon__mLastCalcSunMillis = SystemClock.elapsedRealtime();
7362 TimeZone t = TimeZone.getDefault(); // Since the user's time zone changes dynamically, avoid caching this value. Instead, use this method to look it up for each use.
7363 //System.out.println(t.getID());
7364 sun_moon__calc = new SunriseSunsetCalculator(new Location2(String.valueOf(lat), String.valueOf(lon)), t.getID());
7365 sun_moon__cx = Calendar.getInstance();
7366 sun_moon__sc = SolarPosition.getSunPosition(new Date(), lat, lon);
7367
7368 azmiuth_cache = sun_moon__sc.azimuth;
7369 zenith_cache = sun_moon__sc.zenithAngle;
7370 sunrise_cache = sun_moon__calc.getOfficialSunriseForDate(sun_moon__cx);
7371 sunset_cache = sun_moon__calc.getOfficialSunsetForDate(sun_moon__cx);
7372 //System.out.println("calc moon");
7373 SolarEventCalculator.moonCoor_ret moon_stats = sun_moon__calc.computeMoon(sun_moon__cx);
7374 moon_azimuth_cache = moon_stats.az;
7375 moon_evelation_cache = moon_stats.alt;
7376 }
7377 catch (Exception e)
7378 {
7379 }
7380 }
7381 //
7382 elevation = 90 - zenith_cache;
7383 //
7384 // day -> +90.0 to - 0.83
7385 // evening dusk -> - 0.83 to -10.00
7386 if (elevation < -0.83)
7387 {
7388 is_night = true;
7389 if (elevation < -10.00)
7390 {
7391 is_twilight = false;
7392 }
7393 else
7394 {
7395 is_twilight = true;
7396 }
7397 //System.out.println("***NIGHT***");
7398 }
7399 else
7400 {
7401 is_night = false;
7402 //System.out.println("###DAY###");
7403 }
7404 //
7405 // SUN ----------------
7406 //
7407 //
7408 }
7409
7410 public void do_sun_calc()
7411 {
7412 //
7413 //
7414 // SUN ----------------
7415 //
7416 //
7417 try
7418 {
7419 this.calc_sun_stats();
7420 }
7421 catch (Exception e)
7422 {
7423 // on some systems BigInteger seems to crash, or maybe some values are out of range
7424 // until the bug is found, night modus is deactivated
7425 calc_sun_enabled = false;
7426 is_twilight = false;
7427 is_night = false;
7428 }
7429 //System.out.println("sunrise: " + sunrise_cache);
7430 //System.out.println("sunset: " + sunset_cache);
7431 //System.out.println("azimuth: " + roundTwoDecimals(azmiuth_cache));
7432 //System.out.println("elevation: " + elevation);
7433 //
7434 //
7435 // SUN ----------------
7436 //
7437 //
7438 }
7439
7440 public void run()
7441 {
7442 //System.out.println("CWorkerThread -- started --");
7443 while (this.running)
7444 {
7445 if ((queue4.size() == 0) && (queue6.size() == 0))
7446 {
7447 try
7448 {
7449 Thread.sleep(2000); // 2 secs.
7450 }
7451 catch (InterruptedException e)
7452 {
7453 }
7454 }
7455
7456 if (this.startmain)
7457 {
7458 //System.out.println("CWorkerThread:startup_calls:JTHREAD ID=" + this.getId());
7459 //System.out.println("CWorkerThread:startup_calls:THREAD ID=" + NavitGraphics.GetThreadId());
7460
7461 this.startmain = false;
7462 System.out.println("CWorkerThread -- NavitMain --");
7463 NavitMain(x, lang, version, display_density_string, n_datadir, n_sharedir, NavitGraphics.draw_bitmap_s);
7464 System.out.println("CWorkerThread -- NavitActivity(3) --");
7465 NavitActivity(3);
7466
7467 // -- set map detail level (after app startup) --
7468 // -- set map detail level (after app startup) --
7469 // -- set map detail level (after app startup) --
7470 try
7471 {
7472 getPrefs_more_map_detail();
7473 if (p.PREF_more_map_detail > 0)
7474 {
7475 Message msg2 = new Message();
7476 Bundle b2 = new Bundle();
7477 b2.putInt("Callback", 78);
7478 b2.putString("s", "" + p.PREF_more_map_detail);
7479 msg2.setData(b2);
7480 NavitGraphics.callback_handler.sendMessage(msg2);
7481 }
7482 }
7483 catch (Exception e)
7484 {
7485 // e.printStackTrace();
7486 }
7487 // -- set map detail level (after app startup) --
7488 // -- set map detail level (after app startup) --
7489 // -- set map detail level (after app startup) --
7490
7491 // -- set map DPI factor (after app startup) --
7492 // -- set map DPI factor (after app startup) --
7493 // -- set map DPI factor (after app startup) --
7494 try
7495 {
7496 if ((Navit.metrics.densityDpi >= 320) && (!p.PREF_shrink_on_high_dpi))
7497 {
7498 double factor;
7499 factor = (double) Navit.metrics.densityDpi / (double) NavitGraphics.Global_Scaled_DPI_normal;
7500
7501 Message msg2 = new Message();
7502 Bundle b2 = new Bundle();
7503 b2.putInt("Callback", 81);
7504 b2.putString("s", "" + factor);
7505 msg2.setData(b2);
7506 NavitGraphics.callback_handler.sendMessage(msg2);
7507 }
7508 }
7509 catch (Exception e)
7510 {
7511 // e.printStackTrace();
7512 }
7513 // -- set map DPI factor (after app startup) --
7514 // -- set map DPI factor (after app startup) --
7515 // -- set map DPI factor (after app startup) --
7516 Global_Init_Finished = 1;
7517 //x.runOnUiThread(new Runnable()
7518 //{
7519 // public void run()
7520 // {
7521 // NavitActivity(3);
7522 // }
7523 //});
7524
7525 //**getPrefs();
7526 //**activatePrefs();
7527
7528 System.out.println("CWorkerThread -- calling:ready --");
7529 }
7530
7531 try
7532 {
7533 while (queue8.size() > 0)
7534 {
7535 l9 = queue8.poll();
7536 if (l9 != null)
7537 {
7538 // System.out.println("DrawLowqualMap");
7539 NavitGraphics.DrawLowqualMap(l9.latlonzoom, l9.w, l9.h, l9.fontsize, l9.scale, l9.selection_range);
7540 }
7541 }
7542 }
7543 catch (Exception e)
7544 {
7545 }
7546
7547 while (queue6.size() > 0)
7548 {
7549 try
7550 {
7551 // blocking call
7552 // l2 = queue6.take();
7553 // non-blocking call
7554 l7 = queue6.poll();
7555 if (l7 != null)
7556 {
7557 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7558 }
7559 }
7560
7561 catch (Exception e)
7562 {
7563 }
7564
7565 }
7566
7567 while (queue.size() > 0)
7568 {
7569 try
7570 {
7571 // blocking call
7572 // l2 = queue.take();
7573 // non-blocking call
7574 l2 = queue.poll();
7575 if (l2 != null)
7576 {
7577 //System.out.println("CWorkerThread:CallbackMessageChannelReal_call:JTHREAD ID=" + this.getId());
7578 //System.out.println("CWorkerThread:CallbackMessageChannelReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7579 //System.out.println("CWorkerThread:CallbackMessageChannelReal:" + l2.i);
7580 NavitGraphics.CallbackMessageChannelReal(l2.i, l2.s);
7581 //System.out.println("CWorkerThread:CallbackMessageChannelReal:finished");
7582 }
7583 }
7584 catch (Exception e)
7585 {
7586 }
7587
7588 // if GPS updates are pending, process them
7589 if (queue6.size() > 0)
7590 {
7591 try
7592 {
7593 // blocking call
7594 // l2 = queue6.take();
7595 // non-blocking call
7596 l7 = queue6.poll();
7597 if (l7 != null)
7598 {
7599 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7600 }
7601 }
7602 catch (Exception e)
7603 {
7604 }
7605 }
7606
7607 }
7608
7609 while (queue5.size() > 0)
7610 {
7611 try
7612 {
7613 // blocking call
7614 // l6 = queue5.take();
7615 // non-blocking call
7616 l6 = queue5.poll();
7617 if (l6 != null)
7618 {
7619 //System.out.println("CWorkerThread:SizeChangedCallbackReal_call:JTHREAD ID=" + this.getId());
7620 //System.out.println("CWorkerThread:SizeChangedCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7621 NavitGraphics.SizeChangedCallbackReal(l6.w, l6.h, l6.mb);
7622 }
7623 }
7624 catch (Exception e)
7625 {
7626 }
7627
7628 }
7629
7630 int count_timeout_callbacks = 0;
7631 while (count_timeout_callbacks < 10 && queue4.size() > 0)
7632 {
7633 count_timeout_callbacks++;
7634 try
7635 {
7636 // blocking call
7637 // l5 = queue4.take();
7638 // non-blocking call
7639 l5 = queue4.poll();
7640 if (l5 != null)
7641 {
7642 //System.out.println("CWorkerThread:TimeoutCallback_call:JTHREAD ID=" + this.getId());
7643 //System.out.println("CWorkerThread:TimeoutCallback_call:THREAD ID=" + NavitGraphics.GetThreadId());
7644 if ((l5.nt.running) || (!l5.nt.event_multi))
7645 {
7646 NavitGraphics.TimeoutCallback(l5.del, l5.id);
7647 }
7648 else
7649 {
7650 // System.out.println("CWorkerThread:TimeoutCallback_call:running=false! cid=" + l5.id);
7651 }
7652 }
7653 }
7654 catch (Exception e)
7655 {
7656 }
7657
7658 // if GPS updates are pending, process them
7659 if (queue6.size() > 0)
7660 {
7661 try
7662 {
7663 // blocking call
7664 // l2 = queue6.take();
7665 // non-blocking call
7666 l7 = queue6.poll();
7667 if (l7 != null)
7668 {
7669 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7670 }
7671 }
7672 catch (Exception e)
7673 {
7674 }
7675 }
7676
7677 }
7678
7679 while (queue3.size() > 0)
7680 {
7681 try
7682 {
7683 // blocking call
7684 // l4 = queue3.take();
7685 // non-blocking call
7686 l4 = queue3.poll();
7687 if (l4 != null)
7688 {
7689 //System.out.println("CWorkerThread:MotionCallbackReal_call:JTHREAD ID=" + this.getId());
7690 //System.out.println("CWorkerThread:MotionCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7691 if (queue3.size() > 0)
7692 {
7693 // if more moves are queued up, disable map drawing!
7694 NavitGraphics.MotionCallbackReal(l4.x1, l4.y1, l4.x2, l4.y2, 0);
7695 }
7696 else
7697 {
7698 // ok, also draw the map
7699 NavitGraphics.MotionCallbackReal(l4.x1, l4.y1, l4.x2, l4.y2, 1);
7700 }
7701 }
7702 }
7703 catch (Exception e)
7704 {
7705 }
7706
7707 }
7708
7709 while (queue7.size() > 0)
7710 {
7711 try
7712 {
7713
7714 // if GPS updates are pending, process them
7715 if (queue6.size() > 0)
7716 {
7717 try
7718 {
7719 // blocking call
7720 // l2 = queue6.take();
7721 // non-blocking call
7722 l7 = queue6.poll();
7723 if (l7 != null)
7724 {
7725 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7726 }
7727 }
7728 catch (Exception e)
7729 {
7730 }
7731 }
7732
7733 l8 = queue7.poll();
7734 if (l8 != null)
7735 {
7736 if (l8.type == 1)
7737 {
7738 Navit.OSD_nextturn.nextturn_streetname_systematic = "";
7739 Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(8, l8.b, l8.c);
7740 if (p.PREF_item_dump)
7741 {
7742 // -------- DEBUG ------- DEBUG ---------
7743 // -------- DEBUG ------- DEBUG ---------
7744 // -------- DEBUG ------- DEBUG ---------
7745 Navit.debug_item_dump = NavitGraphics.CallbackGeoCalc(9, l8.b, l8.c);
7746 //System.out.println("xx paint 22 xx");
7747 NavitGraphics.NavitAOverlay_s.postInvalidate();
7748 // -------- DEBUG ------- DEBUG ---------
7749 // -------- DEBUG ------- DEBUG ---------
7750 // -------- DEBUG ------- DEBUG ---------
7751 }
7752 //System.out.println("OSD postinvalidate***");
7753 //System.out.println("xx paint 7 xx");
7754 // NavitOSDJava.draw_real_wrapper(true, false);
7755 ZANaviLinearLayout.redraw_OSD(1);
7756 //++ NavitGraphics.NavitAOSDJava_.postInvalidate();
7757 }
7758 else if (l8.type == 2)
7759 {
7760 NavitGraphics.CallbackGeoCalc(l8.a, l8.b, l8.c);
7761 }
7762 else if (l8.type == 13)
7763 {
7764 try
7765 {
7766 // get roadbook
7767 // String road_book_res = NavitGraphics.CallbackGeoCalc(13, l8.b, l8.c);
7768 String[] separated = NavitGraphics.GetRoadBookItems(12345);
7769 // System.out.println("ROADBOOK_RES=" + separated);
7770
7771 // parse roadbook data ------------
7772 road_book_items.clear();
7773 ZANaviListViewAdapter.ListViewItem l = null;
7774
7775 // String[] separated = road_book_res.split("\13");
7776 int jk = 0;
7777 int ResId = 0;
7778 for (jk = 0; jk < separated.length; jk++)
7779 {
7780 if (jk > 1)
7781 {
7782 // System.out.println("ROADBOOK_RES=" + jk + ":" + separated[jk]);
7783 String[] values = new String[5];
7784 String[] values2 = separated[jk].split(":");
7785 values[0] = values2[0];
7786 values[1] = values2[1];
7787 values[2] = values2[2];
7788 values[3] = values2[3];
7789 try
7790 {
7791 values[4] = values2[4];
7792 }
7793 catch (Exception ee)
7794 {
7795 values[4] = "";
7796 }
7797 // 0 string:distance short form
7798 // 1 lat
7799 // 2 lon
7800 // 3 icon name
7801 // 4 text
7802
7803 // System.out.println("RBI:008:img=" + values[3]);
7804
7805 if (values[3].compareTo("nav_waypoint") == 0)
7806 {
7807 try
7808 {
7809 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_waypoint_bk_center", null, null);
7810 }
7811 catch (Exception e_res_id)
7812 {
7813 ResId = 0;
7814 e_res_id.printStackTrace();
7815 }
7816 }
7817 else if (values[3].compareTo("nav_destination") == 0)
7818 {
7819 try
7820 {
7821 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_destination_bk_center", null, null);
7822 }
7823 catch (Exception e_res_id)
7824 {
7825 ResId = 0;
7826 e_res_id.printStackTrace();
7827 }
7828 }
7829 else
7830 {
7831
7832 try
7833 {
7834 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + values[3] + "_bk", null, null);
7835 }
7836 catch (Exception e_res_id)
7837 {
7838 ResId = 0;
7839 e_res_id.printStackTrace();
7840 }
7841 }
7842
7843 try
7844 {
7845 // System.out.println("RBI:008+" + ResId);
7846 if (ResId != 0)
7847 {
7848 l = new ListViewItem(values[0], res_.getDrawable(ResId), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7849 }
7850 else
7851 {
7852 l = new ListViewItem(values[0], res_.getDrawable(R.drawable.mini_roundabout), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7853 }
7854 // System.out.println("RBI:008");
7855 road_book_items.add(l);
7856 // System.out.println("RBI:009");
7857 }
7858 catch (Exception ee)
7859 {
7860 // System.out.println("item=" + separated[jk] + " EEXX:" + ee.getMessage());
7861 }
7862 }
7863 }
7864 // System.out.println("RBI:010");
7865
7866 try
7867 {
7868 Message msg = Navit_progress_h.obtainMessage();
7869 Bundle b = new Bundle();
7870 msg.what = 33;
7871 msg.setData(b);
7872 Navit_progress_h.sendMessage(msg);
7873 }
7874 catch (Exception e)
7875 {
7876 e.printStackTrace();
7877 }
7878 // System.out.println("RBI:011");
7879 }
7880 catch (Exception eerb)
7881 {
7882 eerb.printStackTrace();
7883 }
7884 // parse roadbook data ------------
7885
7886 }
7887 }
7888 }
7889 catch (Exception e)
7890 {
7891 }
7892
7893 }
7894
7895 while (queue2.size() > 0)
7896 {
7897 try
7898 {
7899 // blocking call
7900 // l3 = queue2.take();
7901 // non-blocking call
7902 l3 = queue2.poll();
7903 if (l3 != null)
7904 {
7905 int i3 = l3.intValue();
7906 //System.out.println("CWorkerThread:NavitActivity_call:JTHREAD ID=" + this.getId());
7907 //System.out.println("CWorkerThread:NavitActivity_call:THREAD ID=" + NavitGraphics.GetThreadId());
7908 //System.out.println("CWorkerThread:NavitActivity:" + i3);
7909 NavitActivity(i3);
7910 }
7911 }
7912 catch (Exception e)
7913 {
7914 }
7915 }
7916
7917 // check sun position (and after interval, recalc values)
7918 do_sun_calc();
7919 }
7920 //System.out.println("CWorkerThread -- stopped --");
7921 }
7922
7923 public void stop_me()
7924 {
7925 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7926
7927 this.running = false;
7928 this.interrupt();
7929
7930 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7931 }
7932 }
7933
7934 public class SmoothVehicle extends Thread
7935 {
7936 private Boolean running;
7937
7938 SmoothVehicle()
7939 {
7940 this.running = true;
7941 }
7942
7943 public void run()
7944 {
7945 while (this.running)
7946 {
7947 try
7948 {
7949 Thread.sleep(5000); // 5 secs.
7950 }
7951 catch (InterruptedException e)
7952 {
7953 }
7954 }
7955 }
7956
7957 public void stop_me()
7958 {
7959 this.running = false;
7960 }
7961 }
7962
7963 public class WatchMem extends Thread
7964 {
7965 private Boolean running;
7966
7967 WatchMem()
7968 {
7969 this.running = true;
7970 }
7971
7972 public void run()
7973 {
7974 //System.out.println("WatchMem -- started --");
7975 while (this.running)
7976 {
7977 Navit.show_mem_used();
7978
7979 try
7980 {
7981 Thread.sleep(5000); // 5 secs.
7982 }
7983 catch (InterruptedException e)
7984 {
7985 }
7986 }
7987 //System.out.println("WatchMem -- stopped --");
7988 }
7989
7990 public void stop_me()
7991 {
7992 this.running = false;
7993 }
7994 }
7995
7996 public class SimGPS extends Thread
7997 {
7998 private Boolean running;
7999 private Handler h;
8000
8001 SimGPS(Handler h_)
8002 {
8003 System.out.println("SimGPS -- inited --");
8004 this.h = h_;
8005 this.running = true;
8006 }
8007
8008 public void run()
8009 {
8010 System.out.println("SimGPS -- started --");
8011 while (this.running)
8012 {
8013 float rnd_heading = (float) (Math.random() * 360d);
8014 float lat = 48.216023f;
8015 float lng = 16.391664f;
8016 //Location l = new Location("Network");
8017 //l.setLatitude(lat);
8018 //l.setLongitude(lng);
8019 //l.setBearing(rnd_heading);
8020 // NavitVehicle.set_mock_location__fast(l);
8021 // NavitVehicle.update_compass_heading(rnd_heading);
8022 if (this.h != null)
8023 {
8024 Message msg = this.h.obtainMessage();
8025 Bundle b = new Bundle();
8026 msg.what = 1;
8027 b.putFloat("b", rnd_heading);
8028 b.putFloat("lat", lat);
8029 b.putFloat("lng", lng);
8030 msg.setData(b);
8031 this.h.sendMessage(msg);
8032 }
8033 try
8034 {
8035 Thread.sleep(800);
8036 }
8037 catch (InterruptedException e)
8038 {
8039 }
8040 }
8041 System.out.println("SimGPS -- stopped --");
8042 }
8043
8044 public void stop_me()
8045 {
8046 this.running = false;
8047 }
8048 }
8049
8050 public class SearchResultsThreadSpinnerThread extends Thread
8051 {
8052 int dialog_num;
8053 int spinner_current_value;
8054 private Boolean running;
8055 Handler mHandler;
8056
8057 SearchResultsThreadSpinnerThread(Handler h, int dialog_num)
8058 {
8059 this.dialog_num = dialog_num;
8060 this.mHandler = h;
8061 this.spinner_current_value = 0;
8062
8063 this.running = true;
8064 Log.e("Navit", "SearchResultsThreadSpinnerThread created");
8065 }
8066
8067 public void run()
8068 {
8069 Log.e("Navit", "SearchResultsThreadSpinnerThread started");
8070 while (this.running)
8071 {
8072 if (Navit.NavitAddressSearchSpinnerActive == false)
8073 {
8074 this.running = false;
8075 }
8076 else
8077 {
8078 Message msg = mHandler.obtainMessage();
8079 Bundle b = new Bundle();
8080 msg.what = 10;
8081 b.putInt("dialog_num", this.dialog_num);
8082 b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8083 b.putInt("cur", this.spinner_current_value % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
8084 if ((Navit.NavitSearchresultBar_title.equals("")) && (Navit.NavitSearchresultBar_text.equals("")))
8085 {
8086 b.putString("title", Navit.get_text("getting search results")); //TRANS
8087 b.putString("text", Navit.get_text("searching ...")); //TRANS
8088 }
8089 else
8090 {
8091 b.putString("title", Navit.NavitSearchresultBar_title);
8092 b.putString("text", Navit.NavitSearchresultBar_text);
8093 }
8094 msg.setData(b);
8095 mHandler.sendMessage(msg);
8096 try
8097 {
8098 Thread.sleep(700);
8099 }
8100 catch (InterruptedException e)
8101 {
8102 // e.printStackTrace();
8103 }
8104 this.spinner_current_value++;
8105 }
8106 }
8107 Log.e("Navit", "SearchResultsThreadSpinnerThread ended");
8108 }
8109 }
8110
8111 public class SearchResultsThread extends Thread
8112 {
8113 private Boolean running;
8114 Handler mHandler;
8115 int my_dialog_num;
8116
8117 SearchResultsThread(Handler h, int dialog_num)
8118 {
8119 this.running = true;
8120 this.mHandler = h;
8121 this.my_dialog_num = dialog_num;
8122 Log.e("Navit", "SearchResultsThread created");
8123 }
8124
8125 public void stop_me()
8126 {
8127 this.running = false;
8128 }
8129
8130 public void run()
8131 {
8132 Log.e("Navit", "SearchResultsThread started");
8133
8134 System.out.println("Global_Location_update_not_allowed = 1");
8135 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
8136
8137 // initialize the dialog with sane values
8138 Message msg = mHandler.obtainMessage();
8139 Bundle b = new Bundle();
8140 msg.what = 10;
8141 b.putInt("dialog_num", this.my_dialog_num);
8142 b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8143 b.putInt("cur", 0);
8144 b.putString("title", Navit.get_text("getting search results")); //TRANS
8145 b.putString("text", Navit.get_text("searching ...")); //TRANS
8146 msg.setData(b);
8147 mHandler.sendMessage(msg);
8148
8149 int partial_match_i = 0;
8150 if (Navit_last_address_partial_match)
8151 {
8152 partial_match_i = 1;
8153 }
8154
8155 if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
8156 {
8157 Navit.search_ready = false;
8158
8159 // start the search, this could take a long time!!
8160 Log.e("Navit", "SearchResultsThread run1");
8161 // need lowercase to find stuff !!
8162 Navit_last_address_search_string = filter_bad_chars(Navit_last_address_search_string).toLowerCase();
8163 if ((Navit_last_address_hn_string != null) && (!Navit_last_address_hn_string.equals("")))
8164 {
8165 Navit_last_address_hn_string = filter_bad_chars(Navit_last_address_hn_string).toLowerCase();
8166 }
8167
8168 if (Navit_last_address_full_file_search)
8169 {
8170 // flags (18) -> order level to search at
8171 // ================
8172 // 0#0 0 -> search full world
8173 // lat#lon radius -> search only this area, around lat,lon
8174 // ================
8175 N_NavitGraphics.SearchResultList(3, partial_match_i, Navit_last_address_search_string, "", "", 18, Navit_last_address_search_country_iso2_string, "0#0", 0);
8176 }
8177 else
8178 {
8179 if (Navit.use_index_search)
8180 {
8181 // new method with index search
8182 // -----------------
8183 //Navit_last_address_search_string
8184 String street_ = "";
8185 String town_ = "";
8186 String hn_ = Navit_last_address_hn_string;
8187
8188 int last_space = Navit_last_address_search_string.lastIndexOf(" ");
8189 if (last_space != -1)
8190 {
8191 street_ = Navit_last_address_search_string.substring(0, last_space);
8192 town_ = Navit_last_address_search_string.substring(last_space + 1);
8193 // System.out.println("XX" + street_ + "YY" + town_ + "ZZ");
8194 }
8195 else
8196 {
8197 street_ = Navit_last_address_search_string;
8198 town_ = "";
8199 }
8200
8201 System.out.println("search params1=" + street_ + ":" + town_ + ":" + hn_);
8202 N_NavitGraphics.SearchResultList(2, partial_match_i, street_, town_, hn_, Navit_last_address_search_country_flags, Navit_last_address_search_country_iso2_string, "0#0", 0);
8203
8204 // sort result list
8205 Collections.sort(Navit.NavitAddressResultList_foundItems);
8206 }
8207 else
8208 {
8209 // old method search
8210 // -----------------
8211 // flags --> 3: search all countries
8212 // 2: search <iso2 string> country
8213 // 1: search default country (what you have set as language in prefs)
8214 System.out.println("searching ... 001");
8215
8216 System.out.println("search params2a=" + Navit_last_address_hn_string);
8217
8218 String old_s = Navit_last_address_search_string;
8219 String new_s = Navit_last_address_search_string;
8220 if ((Navit_last_address_hn_string != null) && (!Navit_last_address_hn_string.equals("")))
8221 {
8222 new_s = Navit_last_address_search_string + " " + Navit_last_address_hn_string;
8223 }
8224
8225 System.out.println("search params2=" + new_s + ":" + Navit_last_address_search_country_flags + ":" + Navit_last_address_search_country_iso2_string);
8226
8227 N_NavitGraphics.SearchResultList(29, partial_match_i, new_s, "", "", Navit_last_address_search_country_flags, Navit_last_address_search_country_iso2_string, "0#0", 0);
8228 System.out.println("searching ... 002");
8229
8230 // sort result list
8231 Collections.sort(Navit.NavitAddressResultList_foundItems);
8232
8233 System.out.println("searching ... 099");
8234 Navit.search_ready = true;
8235 }
8236 }
8237 Log.e("Navit", "SearchResultsThread run2");
8238 }
8239 else if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG)
8240 {
8241 // online googlemaps search
8242 // google search
8243 Log.e("Navit", "SearchResultsThread run1 -> online googlemaps search");
8244 String addressInput = filter_bad_chars(Navit_last_address_search_string);
8245 try
8246 {
8247 List<Address> foundAdresses = Navit.Navit_Geocoder.getFromLocationName(addressInput, 3); //Search addresses
8248 System.out.println("found " + foundAdresses.size() + " results");
8249 // System.out.println("addr=" + foundAdresses.get(0).getLatitude() + " " + foundAdresses.get(0).getLongitude() + "" + foundAdresses.get(0).getAddressLine(0));
8250
8251 Navit.NavitAddressSearchSpinnerActive = false;
8252
8253 for (int results_step = 0; results_step < foundAdresses.size(); results_step++)
8254 {
8255 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
8256 tmp_addr.result_type = "STR";
8257 tmp_addr.item_id = "0";
8258 tmp_addr.lat = (float) foundAdresses.get(results_step).getLatitude();
8259 tmp_addr.lon = (float) foundAdresses.get(results_step).getLongitude();
8260 tmp_addr.addr = "";
8261
8262 String c_code = foundAdresses.get(results_step).getCountryCode();
8263 if (c_code != null)
8264 {
8265 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getCountryCode() + ",";
8266 }
8267
8268 String p_code = foundAdresses.get(results_step).getPostalCode();
8269 if (p_code != null)
8270 {
8271 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getPostalCode() + " ";
8272 }
8273
8274 if (foundAdresses.get(results_step).getMaxAddressLineIndex() > -1)
8275 {
8276 for (int addr_line = 0; addr_line < foundAdresses.get(results_step).getMaxAddressLineIndex(); addr_line++)
8277 {
8278 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
8279 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
8280 }
8281 }
8282
8283 Navit.NavitAddressResultList_foundItems.add(tmp_addr);
8284
8285 if (tmp_addr.result_type.equals("TWN"))
8286 {
8287 Navit.search_results_towns++;
8288 }
8289 else if (tmp_addr.result_type.equals("STR"))
8290 {
8291 Navit.search_results_streets++;
8292 }
8293 else if (tmp_addr.result_type.equals("SHN"))
8294 {
8295 Navit.search_results_streets_hn++;
8296 }
8297 else if (tmp_addr.result_type.equals("POI"))
8298 {
8299 Navit.search_results_poi++;
8300 }
8301
8302 // make the dialog move its bar ...
8303 Bundle b2 = new Bundle();
8304 b2.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
8305 b2.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8306 b2.putInt("cur", Navit.NavitAddressResultList_foundItems.size() % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
8307 b2.putString("title", Navit.get_text("loading search results")); //TRANS
8308 b2.putString("text", Navit.get_text("towns") + ":" + Navit.search_results_towns + " " + Navit.get_text("Streets") + ":" + Navit.search_results_streets + "/" + Navit.search_results_streets_hn + " " + Navit.get_text("POI") + ":" + Navit.search_results_poi);
8309
8310 Navit.msg_to_msg_handler(b2, 10);
8311 }
8312 }
8313 catch (Exception e)
8314 {
8315 e.printStackTrace();
8316 System.out.println("seems googlemaps API is not working, try offline search");
8317 }
8318 }
8319
8320 Navit.NavitAddressSearchSpinnerActive = false;
8321
8322 if (Navit.NavitAddressResultList_foundItems.size() > 0)
8323 {
8324 open_search_result_list();
8325 }
8326 else
8327 {
8328 // no results found, show toast
8329 msg = mHandler.obtainMessage();
8330 b = new Bundle();
8331 msg.what = 2;
8332 b.putString("text", Navit.get_text("No Results found!")); //TRANS
8333 msg.setData(b);
8334 mHandler.sendMessage(msg);
8335 }
8336
8337 // ok, remove dialog
8338 Log.e("Navit", "SearchResultsThread:remove dialog (99)");
8339 msg = mHandler.obtainMessage();
8340 b = new Bundle();
8341 msg.what = 99;
8342 b.putInt("dialog_num", this.my_dialog_num);
8343 msg.setData(b);
8344 mHandler.sendMessage(msg);
8345
8346 // reset the startup-search flag
8347 Navit.NavitStartupAlreadySearching = false;
8348
8349 System.out.println("Global_Location_update_not_allowed = 0");
8350 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
8351
8352 Log.e("Navit", "SearchResultsThread ended");
8353 }
8354 }
8355
8356 public static String filter_bad_chars(String in)
8357 {
8358 String out = in;
8359 out = out.replaceAll("\\n", " "); // newline -> space
8360 out = out.replaceAll("\\r", " "); // return -> space
8361 out = out.replaceAll("\\t", " "); // tab -> space
8362 out = out.trim();
8363 return out;
8364 }
8365
8366 public static void msg_to_msg_handler(Bundle b, int id)
8367 {
8368 Message msg = Navit_progress_h.obtainMessage();
8369 msg.what = id;
8370 msg.setData(b);
8371 Navit_progress_h.sendMessage(msg);
8372 }
8373
8374 public void open_search_result_list()
8375 {
8376 // open result list
8377 Intent address_result_list_activity = new Intent(this, NavitAddressResultListActivity.class);
8378 this.startActivityForResult(address_result_list_activity, Navit.NavitAddressResultList_id);
8379 }
8380
8381 public static Handler callback_handler_55 = new Handler()
8382 {
8383 public void handleMessage(Message msg)
8384 {
8385 // handle 111111
8386 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0, "" + msg.getData().getInt("Callback"));
8387
8388 if (msg.getData().getInt("Callback") == 1)
8389 {
8390 // zoom in
8391 NavitGraphics.CallbackMessageChannel(1, "");
8392 }
8393 else if (msg.getData().getInt("Callback") == 2)
8394 {
8395 // zoom out
8396 NavitGraphics.CallbackMessageChannel(2, "");
8397 }
8398 else if (msg.getData().getInt("Callback") == 55599)
8399 {
8400 // calc route after adding points
8401 NavitGraphics.CallbackMessageChannel(55599, "");
8402 }
8403 else if (msg.getData().getInt("Callback") == 55503)
8404 {
8405 try
8406 {
8407 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0); // CLR
8408 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8409 }
8410 catch (Exception e)
8411 {
8412 }
8413
8414 // get values
8415 String lat = msg.getData().getString("lat");
8416 String lon = msg.getData().getString("lon");
8417 String q = msg.getData().getString("q");
8418 // set routing target to lat,lon
8419 NavitGraphics.CallbackMessageChannel(55503, lat + "#" + lon + "#" + q);
8420 }
8421 else if (msg.getData().getInt("Callback") == 3)
8422 {
8423 try
8424 {
8425 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0); // CLR
8426 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8427 }
8428 catch (Exception e)
8429 {
8430 }
8431
8432 // get values
8433 String lat = msg.getData().getString("lat");
8434 String lon = msg.getData().getString("lon");
8435 String q = msg.getData().getString("q");
8436 // set routing target to lat,lon
8437 NavitGraphics.CallbackMessageChannel(3, lat + "#" + lon + "#" + q);
8438 }
8439 else if (msg.getData().getInt("Callback") == 55548)
8440 {
8441 try
8442 {
8443 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8444 }
8445 catch (Exception e)
8446 {
8447 }
8448
8449 // get values
8450 String lat = msg.getData().getString("lat");
8451 String lon = msg.getData().getString("lon");
8452 String q = msg.getData().getString("q");
8453 // append to routing, add waypoint at lat,lon
8454 NavitGraphics.CallbackMessageChannel(55548, lat + "#" + lon + "#" + q);
8455 }
8456 else if (msg.getData().getInt("Callback") == 48)
8457 {
8458 try
8459 {
8460 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8461 }
8462 catch (Exception e)
8463 {
8464 }
8465
8466 // get values
8467 String lat = msg.getData().getString("lat");
8468 String lon = msg.getData().getString("lon");
8469 String q = msg.getData().getString("q");
8470 // append to routing, add waypoint at lat,lon
8471 NavitGraphics.CallbackMessageChannel(48, lat + "#" + lon + "#" + q);
8472 }
8473 else if (msg.getData().getInt("Callback") == 4)
8474 {
8475 // set routing target to pixel x,y
8476 int x = msg.getData().getInt("x");
8477 int y = msg.getData().getInt("y");
8478
8479 NavitGraphics.CallbackMessageChannel(4, "" + x + "#" + y);
8480 try
8481 {
8482 Navit.follow_button_on();
8483 }
8484 catch (Exception e2)
8485 {
8486 e2.printStackTrace();
8487 }
8488 }
8489 else if (msg.getData().getInt("Callback") == 49)
8490 {
8491 // set routing target to pixel x,y
8492 int x = msg.getData().getInt("x");
8493 int y = msg.getData().getInt("y");
8494
8495 NavitGraphics.CallbackMessageChannel(49, "" + x + "#" + y);
8496 try
8497 {
8498 Navit.follow_button_on();
8499 }
8500 catch (Exception e2)
8501 {
8502 e2.printStackTrace();
8503 }
8504 }
8505 else if (msg.getData().getInt("Callback") == 5)
8506 {
8507 // toggle layer on/off
8508 String s = msg.getData().getString("s");
8509 NavitGraphics.CallbackMessageChannel(5, s);
8510 }
8511 else if (msg.getData().getInt("Callback") == 7)
8512 {
8513 NavitGraphics.CallbackMessageChannel(7, "");
8514 }
8515 else if ((msg.getData().getInt("Callback") > 7) && (msg.getData().getInt("Callback") < 21))
8516 {
8517 NavitGraphics.CallbackMessageChannel(msg.getData().getInt("Callback"), "");
8518 }
8519 else if (msg.getData().getInt("Callback") == 21)
8520 {
8521 int x = msg.getData().getInt("x");
8522 int y = msg.getData().getInt("y");
8523 // ??? // ButtonCallback(1, 1, x, y); // down
8524 }
8525 else if (msg.getData().getInt("Callback") == 22)
8526 {
8527 int x = msg.getData().getInt("x");
8528 int y = msg.getData().getInt("y");
8529 // ??? // ButtonCallback(0, 1, x, y); // up
8530 }
8531 else if (msg.getData().getInt("Callback") == 23)
8532 {
8533 int x = msg.getData().getInt("x");
8534 int y = msg.getData().getInt("y");
8535 int x2 = msg.getData().getInt("x2");
8536 int y2 = msg.getData().getInt("y2");
8537 NavitGraphics.MotionCallback(x, y, x2, y2);
8538 }
8539 else if (msg.getData().getInt("Callback") == 24)
8540 {
8541 try
8542 {
8543 NavitGraphics.NavitMsgTv_.setEnabled(true);
8544 NavitGraphics.NavitMsgTv_.setVisibility(View.VISIBLE);
8545 }
8546 catch (Exception e)
8547 {
8548
8549 }
8550 }
8551 else if (msg.getData().getInt("Callback") == 25)
8552 {
8553 try
8554 {
8555 NavitGraphics.NavitMsgTv_.setVisibility(View.INVISIBLE);
8556 NavitGraphics.NavitMsgTv_.setEnabled(false);
8557 NavitGraphics.NavitMsgTv_.setVisibility(View.GONE);
8558 }
8559 catch (Exception e)
8560 {
8561
8562 }
8563 }
8564 else if (msg.getData().getInt("Callback") == 30)
8565 {
8566 // 2D
8567 // String s = msg.getData().getString("s");
8568 NavitGraphics.CallbackMessageChannel(30, "");
8569 }
8570 else if (msg.getData().getInt("Callback") == 31)
8571 {
8572 // 3D
8573 // String s = msg.getData().getString("s");
8574 NavitGraphics.CallbackMessageChannel(31, "");
8575 }
8576 else if (msg.getData().getInt("Callback") == 32)
8577 {
8578 // switch to specific 3D pitch
8579 String s = msg.getData().getString("s");
8580 NavitGraphics.CallbackMessageChannel(32, s);
8581 }
8582 else if (msg.getData().getInt("Callback") == 33)
8583 {
8584 // zoom to specific zoomlevel
8585 String s = msg.getData().getString("s");
8586 NavitGraphics.CallbackMessageChannel(33, s);
8587 }
8588 else if (msg.getData().getInt("Callback") == 34)
8589 {
8590 // announcer voice OFF
8591 NavitGraphics.CallbackMessageChannel(34, "");
8592 }
8593 else if (msg.getData().getInt("Callback") == 35)
8594 {
8595 // announcer voice ON
8596 NavitGraphics.CallbackMessageChannel(35, "");
8597 }
8598 else if (msg.getData().getInt("Callback") == 36)
8599 {
8600 // switch "Lock on road" ON
8601 NavitGraphics.CallbackMessageChannel(36, "");
8602 }
8603 else if (msg.getData().getInt("Callback") == 37)
8604 {
8605 // switch "Lock on road" OFF
8606 NavitGraphics.CallbackMessageChannel(37, "");
8607 }
8608 else if (msg.getData().getInt("Callback") == 38)
8609 {
8610 // switch "Northing" ON
8611 NavitGraphics.CallbackMessageChannel(38, "");
8612 }
8613 else if (msg.getData().getInt("Callback") == 39)
8614 {
8615 // switch "Northing" OFF
8616 NavitGraphics.CallbackMessageChannel(39, "");
8617 }
8618 else if (msg.getData().getInt("Callback") == 40)
8619 {
8620 // switch "Map follows Vehicle" ON
8621 NavitGraphics.CallbackMessageChannel(40, "");
8622 }
8623 else if (msg.getData().getInt("Callback") == 41)
8624 {
8625 // switch "Map follows Vehicle" OFF
8626 NavitGraphics.CallbackMessageChannel(41, "");
8627 }
8628 else if (msg.getData().getInt("Callback") == 42)
8629 {
8630 // routing mode "highways"
8631 NavitGraphics.CallbackMessageChannel(42, "");
8632 }
8633 else if (msg.getData().getInt("Callback") == 43)
8634 {
8635 // routing mode "normal roads"
8636 NavitGraphics.CallbackMessageChannel(43, "");
8637 }
8638 else if (msg.getData().getInt("Callback") == 44)
8639 {
8640 // show duplicates in search results
8641 NavitGraphics.CallbackMessageChannel(44, "");
8642 }
8643 else if (msg.getData().getInt("Callback") == 45)
8644 {
8645 // filter duplicates in search results
8646 NavitGraphics.CallbackMessageChannel(45, "");
8647 }
8648 else if (msg.getData().getInt("Callback") == 46)
8649 {
8650 // stop searching and show results found until now
8651 NavitGraphics.CallbackMessageChannel(46, "");
8652 }
8653 else if (msg.getData().getInt("Callback") == 47)
8654 {
8655 // change maps data dir
8656 String s = msg.getData().getString("s");
8657 NavitGraphics.CallbackMessageChannel(47, s);
8658 }
8659 else if (msg.getData().getInt("Callback") == 50)
8660 {
8661 // we request to stop drawing the map
8662 NavitGraphics.CallbackMessageChannel(50, "");
8663 }
8664 else if (msg.getData().getInt("Callback") == 51)
8665 {
8666 // set position to pixel x,y
8667 int x = msg.getData().getInt("x");
8668 int y = msg.getData().getInt("y");
8669 NavitGraphics.CallbackMessageChannel(51, "" + x + "#" + y);
8670 }
8671 else if (msg.getData().getInt("Callback") == 52)
8672 {
8673 // switch to demo vehicle
8674 String s = msg.getData().getString("s");
8675 NavitGraphics.CallbackMessageChannel(52, s);
8676 }
8677 else if (msg.getData().getInt("Callback") == 53)
8678 {
8679 // dont speak streetnames
8680 NavitGraphics.CallbackMessageChannel(53, "");
8681 }
8682 else if (msg.getData().getInt("Callback") == 54)
8683 {
8684 // speak streetnames
8685 NavitGraphics.CallbackMessageChannel(54, "");
8686 }
8687 else if (msg.getData().getInt("Callback") == 55)
8688 {
8689 // set cache size for (map-)files
8690 String s = msg.getData().getString("s");
8691 NavitGraphics.CallbackMessageChannel(55, s);
8692 }
8693 // else if (msg.getData().getInt("Callback") == 56)
8694 // {
8695 // // draw polylines with/without circles at the end
8696 // String s = msg.getData().getString("s");
8697 // NavitGraphics.CallbackMessageChannel(56, s); // 0 -> draw circles, 1 -> DO NOT draw circles
8698 // }
8699 else if (msg.getData().getInt("Callback") == 57)
8700 {
8701 // keep drawing streets as if at "order" level xxx
8702 String s = msg.getData().getString("s");
8703 NavitGraphics.CallbackMessageChannel(57, s);
8704 }
8705 else if (msg.getData().getInt("Callback") == 58)
8706 {
8707 // street search radius factor (multiplier)
8708 String s = msg.getData().getString("s");
8709 NavitGraphics.CallbackMessageChannel(58, s);
8710 }
8711 else if (msg.getData().getInt("Callback") == 59)
8712 {
8713 // enable layer "name"
8714 String s = msg.getData().getString("s");
8715 NavitGraphics.CallbackMessageChannel(59, s);
8716 }
8717 else if (msg.getData().getInt("Callback") == 60)
8718 {
8719 // disable layer "name"
8720 String s = msg.getData().getString("s");
8721 NavitGraphics.CallbackMessageChannel(60, s);
8722 }
8723 else if (msg.getData().getInt("Callback") == 61)
8724 {
8725 // zoom to specific zoomlevel at given point as center
8726 // pixel-x#pixel-y#zoom-level
8727 String s = msg.getData().getString("s");
8728 NavitGraphics.CallbackMessageChannel(61, s);
8729 }
8730 else if (msg.getData().getInt("Callback") == 62)
8731 {
8732 // disable map drawing
8733 NavitGraphics.CallbackMessageChannel(62, "");
8734 }
8735 else if (msg.getData().getInt("Callback") == 63)
8736 {
8737 // enable map drawing
8738 NavitGraphics.CallbackMessageChannel(63, "");
8739 }
8740 else if (msg.getData().getInt("Callback") == 64)
8741 {
8742 // draw map
8743 NavitGraphics.CallbackMessageChannel(64, "");
8744 }
8745 else if (msg.getData().getInt("Callback") == 65)
8746 {
8747 // draw map async
8748 NavitGraphics.CallbackMessageChannel(65, "");
8749 }
8750 else if (msg.getData().getInt("Callback") == 66)
8751 {
8752 // enable "multipolygons"
8753 NavitGraphics.CallbackMessageChannel(66, "");
8754 }
8755 else if (msg.getData().getInt("Callback") == 67)
8756 {
8757 // disable "multipolygons"
8758 NavitGraphics.CallbackMessageChannel(67, "");
8759 }
8760 else if (msg.getData().getInt("Callback") == 68)
8761 {
8762 // shift "order" by this value (only for drawing objects)
8763 String s = msg.getData().getString("s");
8764 NavitGraphics.CallbackMessageChannel(68, s);
8765 }
8766 else if (msg.getData().getInt("Callback") == 69)
8767 {
8768 // stop drawing map
8769 NavitGraphics.CallbackMessageChannel(69, "");
8770 }
8771 else if (msg.getData().getInt("Callback") == 70)
8772 {
8773 // allow drawing map
8774 NavitGraphics.CallbackMessageChannel(70, "");
8775 }
8776 else if (msg.getData().getInt("Callback") == 71)
8777 {
8778 // activate/deactivate "route graph" display
8779 // 0 -> deactivate
8780 // 1 -> activate
8781 String s = msg.getData().getString("s");
8782 NavitGraphics.CallbackMessageChannel(71, s);
8783 }
8784 else if (msg.getData().getInt("Callback") == 72)
8785 {
8786 // update the route path and route graph (e.g. after setting new roadblocks)
8787 // does not update destinations!!!
8788 NavitGraphics.CallbackMessageChannel(72, "");
8789 }
8790 else if (msg.getData().getInt("Callback") == 73)
8791 {
8792 // update the route path and route graph (e.g. after setting new roadblocks)
8793 // this destroys the route graph and calcs everything totally new!
8794 NavitGraphics.CallbackMessageChannel(73, "");
8795 }
8796
8797 else if (msg.getData().getInt("Callback") == 74)
8798 {
8799 // allow demo vechile to move
8800 NavitGraphics.CallbackMessageChannel(74, "");
8801 }
8802 else if (msg.getData().getInt("Callback") == 75)
8803 {
8804 // stop demo vechile
8805 NavitGraphics.CallbackMessageChannel(75, "");
8806 }
8807 else if (msg.getData().getInt("Callback") == 76)
8808 {
8809 // show route rectangles
8810 NavitGraphics.CallbackMessageChannel(76, "");
8811 }
8812 else if (msg.getData().getInt("Callback") == 77)
8813 {
8814 // do not show route rectangles
8815 NavitGraphics.CallbackMessageChannel(77, "");
8816 }
8817 else if (msg.getData().getInt("Callback") == 78)
8818 {
8819 // shift layout "order" values
8820 String s = msg.getData().getString("s");
8821 NavitGraphics.CallbackMessageChannel(78, s);
8822 }
8823 else if (msg.getData().getInt("Callback") == 79)
8824 {
8825 // set traffic light delay/cost
8826 String s = msg.getData().getString("s");
8827 NavitGraphics.CallbackMessageChannel(79, s);
8828 }
8829 else if (msg.getData().getInt("Callback") == 80)
8830 {
8831 // set autozoom flag to 0 or 1
8832 String s = msg.getData().getString("s");
8833 NavitGraphics.CallbackMessageChannel(80, s);
8834 }
8835 else if (msg.getData().getInt("Callback") == 81)
8836 {
8837 // resize layout items by factor
8838 String s = msg.getData().getString("s");
8839 NavitGraphics.CallbackMessageChannel(81, s);
8840 }
8841 else if (msg.getData().getInt("Callback") == 82)
8842 {
8843 // report share dir
8844 String s = msg.getData().getString("s");
8845 NavitGraphics.CallbackMessageChannel(82, s);
8846 }
8847 else if (msg.getData().getInt("Callback") == 83)
8848 {
8849 // spill all the index files to log output
8850 NavitGraphics.CallbackMessageChannel(83, "");
8851 }
8852 else if (msg.getData().getInt("Callback") == 84)
8853 {
8854 // report data dir
8855 String s = msg.getData().getString("s");
8856 NavitGraphics.CallbackMessageChannel(84, s);
8857 }
8858 else if (msg.getData().getInt("Callback") == 85)
8859 {
8860 // C linedrawing flag
8861 String s = msg.getData().getString("s");
8862 NavitGraphics.CallbackMessageChannel(85, s);
8863 }
8864 else if (msg.getData().getInt("Callback") == 86)
8865 {
8866 // avoid sharp turns flag to 0 or 1
8867 String s = msg.getData().getString("s");
8868 NavitGraphics.CallbackMessageChannel(86, s);
8869 }
8870 else if (msg.getData().getInt("Callback") == 87)
8871 {
8872 // // avoid sharp turns minimum angle. if turn is harder than this angle then set penalty
8873 String s = msg.getData().getString("s");
8874 NavitGraphics.CallbackMessageChannel(87, s);
8875 }
8876 else if (msg.getData().getInt("Callback") == 88)
8877 {
8878 // avoid sharp turns penalty
8879 String s = msg.getData().getString("s");
8880 NavitGraphics.CallbackMessageChannel(88, s);
8881 }
8882 else if (msg.getData().getInt("Callback") == 89)
8883 {
8884 // search radius for housenumbers for streets
8885 String s = msg.getData().getString("s");
8886 NavitGraphics.CallbackMessageChannel(89, s);
8887 }
8888 else if (msg.getData().getInt("Callback") == 90)
8889 {
8890 // set vehicleprofile to value of string s ('car','bike')
8891 String s = msg.getData().getString("s");
8892 NavitGraphics.CallbackMessageChannel(90, s);
8893 }
8894 else if (msg.getData().getInt("Callback") == 91)
8895 {
8896 // change vehicle profile's roadprofile values
8897 String s = msg.getData().getString("s");
8898 NavitGraphics.CallbackMessageChannel(91, s);
8899 }
8900 else if (msg.getData().getInt("Callback") == 92)
8901 {
8902 // change vehicle profile's roadprofile values 2
8903 String s = msg.getData().getString("s");
8904 NavitGraphics.CallbackMessageChannel(92, s);
8905 }
8906 else if (msg.getData().getInt("Callback") == 93)
8907 {
8908 // change vehicle profile's roadprofile values 3
8909 String s = msg.getData().getString("s");
8910 NavitGraphics.CallbackMessageChannel(93, s);
8911 }
8912 else if (msg.getData().getInt("Callback") == 94)
8913 {
8914 // change priority for cycle lanes
8915 String s = msg.getData().getString("s");
8916 NavitGraphics.CallbackMessageChannel(94, s);
8917 }
8918 //else if (msg.getData().getInt("Callback") == 95)
8919 //{
8920 // // change priority for cycle tracks
8921 // String s = msg.getData().getString("s");
8922 // NavitGraphics.CallbackMessageChannel(95, s);
8923 //}
8924 else if (msg.getData().getInt("Callback") == 96)
8925 {
8926 // dump route to GPX file, "s" -> full pathname to output file
8927 String s = msg.getData().getString("s");
8928 NavitGraphics.CallbackMessageChannel(96, s);
8929 }
8930 else if (msg.getData().getInt("Callback") == 97)
8931 {
8932 // set positon to lat#lon#name
8933 String lat = msg.getData().getString("lat");
8934 String lon = msg.getData().getString("lon");
8935 String q = msg.getData().getString("q");
8936 NavitGraphics.CallbackMessageChannel(97, lat + "#" + lon + "#" + q);
8937 }
8938 else if (msg.getData().getInt("Callback") == 98)
8939 {
8940 // set connected_pref value
8941 String s = msg.getData().getString("s");
8942 NavitGraphics.CallbackMessageChannel(98, s);
8943 }
8944 else if (msg.getData().getInt("Callback") == 99)
8945 {
8946 // set angle_pref value
8947 String s = msg.getData().getString("s");
8948 NavitGraphics.CallbackMessageChannel(99, s);
8949 }
8950 else if (msg.getData().getInt("Callback") == 100)
8951 {
8952 // dump callbacks to log
8953 NavitGraphics.CallbackMessageChannel(100, "");
8954 }
8955 else if (msg.getData().getInt("Callback") == 101)
8956 {
8957 // set demo vehicle flag for tracking
8958 NavitGraphics.CallbackMessageChannel(101, "");
8959 }
8960 else if (msg.getData().getInt("Callback") == 102)
8961 {
8962 // set gpsfix flag
8963 String s = msg.getData().getString("s");
8964 NavitGraphics.CallbackMessageChannel(102, s);
8965 }
8966 else if (msg.getData().getInt("Callback") == 103)
8967 {
8968 // draw location of self (car) x% lower than screen center
8969 String s = msg.getData().getString("s");
8970 NavitGraphics.CallbackMessageChannel(103, s);
8971 }
8972 else if (msg.getData().getInt("Callback") == 104)
8973 {
8974 // send OVERSPILL_FACTOR to C-code
8975 String s;
8976 if (Navit.GFX_OVERSPILL)
8977 {
8978 s = "" + (OVERSPILL_FACTOR * 100);
8979 }
8980 else
8981 {
8982 s = "" + 100;
8983 }
8984
8985 NavitGraphics.CallbackMessageChannel(104, s);
8986 }
8987 else if (msg.getData().getInt("Callback") == 105)
8988 {
8989 // zoom to specific zoomlevel without redrawing the map!
8990 String s = msg.getData().getString("s");
8991 NavitGraphics.CallbackMessageChannel(105, s);
8992 }
8993 else if (msg.getData().getInt("Callback") == 106)
8994 {
8995 // factor for routing/road speed
8996 String s = msg.getData().getString("s");
8997 NavitGraphics.CallbackMessageChannel(106, s);
8998 }
8999 else if (msg.getData().getInt("Callback") == 107)
9000 {
9001 // level 0 announcement seconds
9002 String s = msg.getData().getString("s");
9003 NavitGraphics.CallbackMessageChannel(107, s);
9004 }
9005 else if (msg.getData().getInt("Callback") == 108)
9006 {
9007 // level 1 announcement seconds
9008 String s = msg.getData().getString("s");
9009 NavitGraphics.CallbackMessageChannel(108, s);
9010 }
9011 else if (msg.getData().getInt("Callback") == 109)
9012 {
9013 // level 2 announcement seconds
9014 String s = msg.getData().getString("s");
9015 NavitGraphics.CallbackMessageChannel(109, s);
9016 }
9017 else if (msg.getData().getInt("Callback") == 110)
9018 {
9019 // generic int option CallBack [<option name>:<option value "int">]
9020 String s = msg.getData().getString("s");
9021 NavitGraphics.CallbackMessageChannel(110, s);
9022 }
9023 else if (msg.getData().getInt("Callback") == 111)
9024 {
9025 // show real gps position on map
9026 String s = msg.getData().getString("s");
9027 NavitGraphics.CallbackMessageChannel(111, s);
9028 }
9029 else if (msg.getData().getInt("Callback") == 112)
9030 {
9031 // show maps debug view
9032 String s = msg.getData().getString("s");
9033 NavitGraphics.CallbackMessageChannel(112, s);
9034 }
9035 else if (msg.getData().getInt("Callback") == 113)
9036 {
9037 // cancel preview map drawing
9038 NavitGraphics.CallbackMessageChannel(113, "x");
9039 }
9040 else if (msg.getData().getInt("Callback") == 9901)
9041 {
9042 // if follow mode is on, then dont show freeview streetname
9043 //if (!Navit.PREF_follow_gps)
9044 //{
9045 // Navit.cwthr.CallbackGeoCalc2(1, 0, mCanvasWidth / 2, mCanvasHeight / 2);
9046 //}
9047 }
9048 else if (msg.getData().getInt("Callback") == 98001)
9049 {
9050 int id = msg.getData().getInt("id");
9051 int i = msg.getData().getInt("i");
9052 NavitGraphics.return_generic_int_real(id, i);
9053 }
9054 else if (msg.getData().getInt("Callback") == 9001)
9055 {
9056 NavitGraphics.busyspinner_.setVisibility(View.INVISIBLE);
9057 NavitGraphics.busyspinnertext_.setVisibility(View.INVISIBLE);
9058 }
9059 else if (msg.getData().getInt("Callback") == 9002)
9060 {
9061 NavitGraphics.busyspinner_.setVisibility(View.VISIBLE);
9062 NavitGraphics.busyspinnertext_.setVisibility(View.VISIBLE);
9063 }
9064
9065 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
9066 }
9067 };
9068
9069 public Handler progress_handler = new Handler()
9070 {
9071 @SuppressLint("NewApi")
9072 public void handleMessage(Message msg)
9073 {
9074
9075 // System.out.println("progress_handler:msg:" + msg.what + "::" + msg.getData().toString());
9076
9077 switch (msg.what)
9078 {
9079 case 0:
9080 // dismiss dialog, remove dialog
9081 try
9082 {
9083 Log.e("Navit", "0: dismiss dialog num " + msg.getData().getInt("dialog_num"));
9084 }
9085 catch (Exception e)
9086 {
9087 e.printStackTrace();
9088 }
9089
9090 try
9091 {
9092 dismissDialog(msg.getData().getInt("dialog_num"));
9093 removeDialog(msg.getData().getInt("dialog_num"));
9094 }
9095 catch (Exception e)
9096 {
9097 }
9098
9099 // exit_code=0 -> OK, map was downloaded fine
9100 if (msg.getData().getInt("exit_code") == 0)
9101 {
9102 // try to use the new downloaded map (works fine now!)
9103 //Log.d("Navit", "instance count=" + Navit.getInstanceCount()); // where did this go to?
9104
9105 // **** onStop();
9106 // **** onCreate(getIntent().getExtras());
9107
9108 String this_map_name = "map";
9109 try
9110 {
9111 this_map_name = msg.getData().getString("map_name");
9112 }
9113 catch (Exception e)
9114 {
9115 }
9116
9117 // reload sdcard maps
9118 Message msg2 = new Message();
9119 Bundle b2 = new Bundle();
9120 b2.putInt("Callback", 18);
9121 msg2.setData(b2);
9122 NavitGraphics.callback_handler.sendMessage(msg2);
9123
9124 // ----- service stop -----
9125 // ----- service stop -----
9126 Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
9127 // ----- service stop -----
9128 // ----- service stop -----
9129
9130 try
9131 {
9132 // show notification that map is ready
9133 String Notification_header = "ZANavi";
9134 String Notification_text = this_map_name + " ready";
9135
9136 NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
9137 Notification notification = new Notification(R.drawable.icon, "ZANavi download finished", System.currentTimeMillis());
9138 notification.flags = Notification.FLAG_AUTO_CANCEL;
9139 Intent in = new Intent();
9140 in.setClass(getBaseContext_, Navit.class);
9141 in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9142 PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9143 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9144
9145 try
9146 {
9147 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9148 }
9149 catch (Exception e)
9150 {
9151 e.printStackTrace();
9152
9153 try
9154 {
9155 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9156
9157 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9158 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9159 }
9160 catch (Exception e2)
9161 {
9162 e2.printStackTrace();
9163 }
9164 }
9165 }
9166 catch (Exception e)
9167 {
9168 e.printStackTrace();
9169 }
9170
9171 zoom_out_full();
9172
9173 /*
9174 * Intent intent = getIntent();
9175 * System.out.println("ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ**********************");
9176 * startActivity(intent);
9177 * System.out.println("FFFFFFFFFFFFFFFFFFF**********************");
9178 * Log.d("Navit", "instance count=" + Navit.getInstanceCount());
9179 * onStop();
9180 * System.out.println("HHHHHHHHHHHHHHHHHHH**********************");
9181 */
9182
9183 //Message msg2 = new Message();
9184 //Bundle b2 = new Bundle();
9185 //b2.putInt("Callback", 6);
9186 //msg2.setData(b2);
9187 //N_NavitGraphics.callback_handler.sendMessage(msg2);
9188 }
9189 else
9190 {
9191 // there was a problem downloading the map
9192 // ----- service stop -----
9193 // ----- service stop -----
9194 Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
9195 // ----- service stop -----
9196 // ----- service stop -----
9197
9198 String this_map_name = "map";
9199 try
9200 {
9201 this_map_name = msg.getData().getString("map_name");
9202 }
9203 catch (Exception e)
9204 {
9205 }
9206
9207 try
9208 {
9209
9210 // show notification that there was a download problem
9211 String Notification_header = "ZANavi";
9212 String Notification_text = "ERROR while downloading " + this_map_name;
9213
9214 NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
9215 Notification notification = new Notification(R.drawable.icon, "ZANavi download ERROR", System.currentTimeMillis());
9216 notification.flags = Notification.FLAG_AUTO_CANCEL;
9217 Intent in = new Intent();
9218 in.setClass(getBaseContext_, Navit.class);
9219 in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9220 PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9221 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9222
9223 try
9224 {
9225 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9226 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9227 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9228 // {
9229 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9230 // }
9231
9232 }
9233 catch (Exception e)
9234 {
9235 e.printStackTrace();
9236
9237 try
9238 {
9239 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9240
9241 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9242 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9243 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9244 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9245 // {
9246 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9247 // }
9248 }
9249 catch (Exception e2)
9250 {
9251 e2.printStackTrace();
9252 }
9253 }
9254 }
9255 catch (Exception e)
9256 {
9257 e.printStackTrace();
9258 }
9259 }
9260 break;
9261 case 1:
9262 // change progressbar values
9263 try
9264 {
9265 int what_dialog = msg.getData().getInt("dialog_num");
9266 if (what_dialog == MAPDOWNLOAD_PRI_DIALOG)
9267 {
9268 mapdownloader_dialog_pri.setMax(msg.getData().getInt("max"));
9269 mapdownloader_dialog_pri.setProgress(msg.getData().getInt("cur"));
9270 mapdownloader_dialog_pri.setTitle(msg.getData().getString("title"));
9271 mapdownloader_dialog_pri.setMessage(msg.getData().getString("text"));
9272 }
9273 else if (what_dialog == MAPDOWNLOAD_SEC_DIALOG)
9274 {
9275 mapdownloader_dialog_sec.setMax(msg.getData().getInt("max"));
9276 mapdownloader_dialog_sec.setProgress(msg.getData().getInt("cur"));
9277 mapdownloader_dialog_sec.setTitle(msg.getData().getString("title"));
9278 mapdownloader_dialog_sec.setMessage(msg.getData().getString("text"));
9279 }
9280 }
9281 catch (Exception e)
9282 {
9283 }
9284 break;
9285 case 2:
9286 Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
9287 break;
9288 case 3:
9289 Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_LONG).show();
9290 break;
9291 case 10:
9292 // change values - generic
9293 try
9294 {
9295 int what_dialog_generic = msg.getData().getInt("dialog_num");
9296 if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG)
9297 {
9298 search_results_wait.setMax(msg.getData().getInt("max"));
9299 search_results_wait.setProgress(msg.getData().getInt("cur"));
9300 search_results_wait.setTitle(msg.getData().getString("title"));
9301 search_results_wait.setMessage(msg.getData().getString("text"));
9302 }
9303 else if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
9304 {
9305 search_results_wait_offline.setMax(msg.getData().getInt("max"));
9306 search_results_wait_offline.setProgress(msg.getData().getInt("cur"));
9307 search_results_wait_offline.setTitle(msg.getData().getString("title"));
9308 search_results_wait_offline.setMessage(msg.getData().getString("text"));
9309 }
9310 }
9311 catch (Exception e)
9312 {
9313 }
9314 break;
9315 case 11:
9316 // show dialog - generic
9317 try
9318 {
9319 // just in case, remove the dialog if it should be shown already!
9320 dismissDialog(msg.getData().getInt("dialog_num"));
9321 removeDialog(msg.getData().getInt("dialog_num"));
9322 }
9323 catch (Exception e)
9324 {
9325 // System.out.println("Ex D1: " + e.toString());
9326 }
9327 System.out.println("showDialog 001 dialog_num=" + msg.getData().getInt("dialog_num"));
9328 showDialog(msg.getData().getInt("dialog_num"));
9329 break;
9330 case 12:
9331 // turn on compass
9332 turn_on_compass();
9333 break;
9334 case 13:
9335 // turn off compass
9336 turn_off_compass();
9337 break;
9338 case 14:
9339 // set used mem in textview
9340 show_mem_used_real();
9341 break;
9342 case 15:
9343 // set debug text line 3
9344 Navit.set_debug_messages3(msg.getData().getString("text"));
9345 break;
9346 case 16:
9347 // refresh NavitAndriodOverlay
9348 try
9349 {
9350 //Log.e("NavitGraphics", "xx 1");
9351 //System.out.println("invalidate 027");
9352 NavitGraphics.NavitAOverlay_s.invalidate();
9353 //Log.e("NavitGraphics", "xx 2");
9354 }
9355 catch (Exception e)
9356 {
9357 e.printStackTrace();
9358 }
9359 break;
9360 case 17:
9361 try
9362 {
9363
9364 generic_alert_box.setMessage(Navit.get_text("Possibly not enough space on your device!")).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener() // TRANS
9365 {
9366 public void onClick(DialogInterface dialog, int id)
9367 {
9368 // Handle Ok
9369 }
9370 }).create();
9371 generic_alert_box.setCancelable(false);
9372 generic_alert_box.setTitle(Navit.get_text("device space")); // TRANS
9373 generic_alert_box.show();
9374 }
9375 catch (Exception e)
9376 {
9377 e.printStackTrace();
9378 }
9379 break;
9380 // case 18:
9381 // try
9382 // {
9383 // openOptionsMenu_wrapper();
9384 // }
9385 // catch (Exception e)
9386 // {
9387 // }
9388 // break;
9389 case 19:
9390 open_voice_recog_screen();
9391 break;
9392 case 20:
9393 dim_screen();
9394 break;
9395 case 21:
9396 default_brightness_screen();
9397 break;
9398 case 22:
9399 try
9400 {
9401 // ----- service start -----
9402 // ----- service start -----
9403 startService(Navit.ZANaviMapDownloaderServiceIntent);
9404 // ----- service start -----
9405 // ----- service start -----
9406
9407 // try
9408 // {
9409 // Thread.sleep(200);
9410 // }
9411 // catch (InterruptedException e)
9412 // {
9413 // }
9414
9415 // if (!ZANaviMapDownloaderService.service_running)
9416 // {
9417 // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
9418 // try
9419 // {
9420 // Thread.sleep(2000);
9421 // }
9422 // catch (InterruptedException e)
9423 // {
9424 // }
9425 // }
9426 //
9427 // if (!ZANaviMapDownloaderService.service_running)
9428 // {
9429 // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
9430 // try
9431 // {
9432 // Thread.sleep(2000);
9433 // }
9434 // catch (InterruptedException e)
9435 // {
9436 // }
9437 // }
9438
9439 // -------- // ZANaviMapDownloaderService.start_map_download();
9440 }
9441 catch (Exception e)
9442 {
9443 e.printStackTrace();
9444 }
9445 break;
9446 case 23:
9447
9448 // show actionbar download icon
9449 try
9450 {
9451 // show download actionbar icon
9452 //cur_menu.findItem(R.id.item_download_menu_button).setTitle("");
9453 actionabar_download_icon_visible = true;
9454 cur_menu.findItem(R.id.item_download_menu_button).setVisible(true);
9455 //cur_menu.findItem(R.id.item_download_menu_button).setEnabled(true);
9456 // ****** // cur_menu.findItem(R.id.item_download_menu_button).setIcon(R.drawable.anim_download_icon);
9457 // cur_menu.findItem(R.id.item_download_menu_button).setIcon((Drawable) null);
9458 }
9459 catch (Exception e)
9460 {
9461 e.printStackTrace();
9462 }
9463
9464 try
9465 {
9466 show_status_bar();
9467 getSupportActionBar().setDisplayShowTitleEnabled(true);
9468 }
9469 catch (Exception e)
9470 {
9471 e.printStackTrace();
9472 }
9473
9474 // try
9475 // {
9476 // View menuItemView = findViewById(R.id.item_download_menu_button);
9477 // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_2);
9478 // // menuItemView.setOnClickListener(new View.OnClickListener()
9479 // // {
9480 // // public void onClick(View v)
9481 // // {
9482 // // try
9483 // // {
9484 // // //menuItemView.setBackgroundResource(R.drawable.anim_download_icon_1);
9485 // // //AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9486 // // //frameAnimation.start();
9487 // // // menuItemView.setAlpha(100);
9488 // // View menuItemView = findViewById(R.id.item_download_menu_button);
9489 // // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_1);
9490 // //
9491 // // System.out.println("download icon pressed(2)");
9492 // //
9493 // // Intent mapdownload_cancel_activity = new Intent(Navit.getBaseContext_, ZANaviDownloadMapCancelActivity.class);
9494 // // mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9495 // // startActivity(mapdownload_cancel_activity);
9496 // //
9497 // // new Handler().postDelayed(new Runnable()
9498 // // {
9499 // // @Override
9500 // // public void run()
9501 // // {
9502 // // if (Navit.cur_menu.findItem(R.id.item_download_menu_button).isVisible())
9503 // // {
9504 // // View menuItemView = findViewById(R.id.item_download_menu_button);
9505 // // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_2);
9506 // // AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9507 // // frameAnimation.start();
9508 // // }
9509 // // }
9510 // // }, 50);
9511 // // }
9512 // // catch (Exception e)
9513 // // {
9514 // // }
9515 // // }
9516 // // });
9517 // AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9518 // frameAnimation.start();
9519 // }
9520 // catch (Exception e)
9521 // {
9522 // e.printStackTrace();
9523 // }
9524
9525 break;
9526 case 24:
9527 // hide actionbar download icon
9528
9529 // try
9530 // {
9531 // View menuItemView = findViewById(R.id.item_download_menu_button);
9532 // menuItemView.setBackground((Drawable) null);
9533 //
9534 // new Handler().postDelayed(new Runnable()
9535 // {
9536 // @Override
9537 // public void run()
9538 // {
9539 // if (Navit.cur_menu.findItem(R.id.item_download_menu_button).isVisible())
9540 // {
9541 // View menuItemView = findViewById(R.id.item_download_menu_button);
9542 // menuItemView.setBackground((Drawable) null);
9543 // }
9544 // }
9545 // }, 50);
9546 // }
9547 // catch (Exception e)
9548 // {
9549 // e.printStackTrace();
9550 // }
9551
9552 try
9553 {
9554 // hide download actionbar icon
9555 actionabar_download_icon_visible = false;
9556 cur_menu.findItem(R.id.item_download_menu_button).setVisible(false);
9557 //cur_menu.findItem(R.id.item_download_menu_button).setEnabled(false);
9558 // cur_menu.findItem(R.id.item_download_menu_button).setIcon((Drawable) null);
9559 }
9560 catch (Exception e)
9561 {
9562 e.printStackTrace();
9563 }
9564
9565 try
9566 {
9567 getSupportActionBar().setDisplayShowTitleEnabled(false);
9568 }
9569 catch (Exception e)
9570 {
9571 e.printStackTrace();
9572 }
9573
9574 try
9575 {
9576 hide_status_bar();
9577 }
9578 catch (Exception e)
9579 {
9580 e.printStackTrace();
9581 }
9582
9583 break;
9584 case 25:
9585 // Log.e("Navit", "nav: 25");
9586 NavitGraphics.deactivate_nav_wakelock_real();
9587 break;
9588 case 26:
9589 // Log.e("Navit", "nav: 26");
9590 NavitGraphics.activate_nav_wakelock_real();
9591 break;
9592 case 27:
9593 show_status_bar();
9594 break;
9595 case 28:
9596 hide_status_bar();
9597 break;
9598 case 29:
9599 invalidateOptionsMenu();
9600 break;
9601 case 30:
9602 try
9603 {
9604 NavitGraphics.NavitMsgTv2_.append(msg.getData().getString("text"));
9605 }
9606 catch (Exception e)
9607 {
9608 e.printStackTrace();
9609 }
9610 break;
9611 case 31:
9612 try
9613 {
9614 // map download menu
9615 Intent map_download_list_activity = new Intent(getBaseContext_, NavitDownloadSelectMapActivity.class);
9616 startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
9617 }
9618 catch (Exception e)
9619 {
9620 e.printStackTrace();
9621 }
9622 break;
9623 case 32:
9624 try
9625 {
9626 if (p.PREF_follow_gps)
9627 {
9628 push_pin_view.setImageResource(R.drawable.pin1_down);
9629 }
9630 else
9631 {
9632 push_pin_view.setImageResource(R.drawable.pin1_up);
9633 }
9634 }
9635 catch (Exception e)
9636 {
9637 e.printStackTrace();
9638 }
9639 break;
9640 case 33:
9641 if (road_book != null)
9642 {
9643 if (road_book_items != null)
9644 {
9645 try
9646 {
9647 // send new roadbook items to fragment and reload it
9648 road_book.reload_items(road_book_items);
9649 }
9650 catch (Exception e)
9651 {
9652 }
9653 }
9654 }
9655 break;
9656 case 34:
9657 // show bubble
9658 NavitGraphics.whats_here_container_wrap.setVisibility(View.VISIBLE);
9659 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9660 break;
9661 case 35:
9662 // hide bubble
9663 NavitGraphics.whats_here_container_wrap.setVisibility(View.INVISIBLE);
9664 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9665 // and move out of screen
9666
9667 if (!Navit.PAINT_OLD_API)
9668 {
9669 NavitGraphics.whats_here_container_wrap.setX(-2000);
9670 NavitGraphics.whats_here_container_wrap.setY(-2000);
9671 // NavitGraphics.whats_here_container_wrap.requestLayout();
9672
9673 NavitGraphics.whats_here_pointer_image.setX(0);
9674 }
9675 else
9676 {
9677 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9678 NavitGraphics.params_whats_here_container_wrap.leftMargin = -2000;
9679 NavitGraphics.params_whats_here_container_wrap.topMargin = -2000;
9680 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9681 NavitGraphics.whats_here_container_wrap.requestLayout();
9682
9683 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9684 // NavitGraphics.params_whats_here_pointer_image.leftMargin = 0;
9685 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9686 NavitGraphics.whats_here_pointer_image.requestLayout();
9687
9688 }
9689 break;
9690 case 36:
9691 // move bubble to x,y
9692 int width_in_px = getResources().getDimensionPixelSize(R.dimen.whats_here_container_width);
9693 int new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x;
9694 int new_diff = 0;
9695 if ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) > NavitGraphics.mCanvasWidth)
9696 {
9697 new_diff = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9698 new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x - ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth);
9699 }
9700
9701 new_x = new_x - NavitGraphics.dp_to_px(17);
9702
9703 if (!Navit.PAINT_OLD_API)
9704 {
9705 NavitGraphics.whats_here_container_wrap.setX(new_x);
9706 NavitGraphics.whats_here_container_wrap.setY(NavitGraphics.NavitAOverlay_s.bubble_001.y + NavitGraphics.dp_to_px(17));
9707 // NavitGraphics.whats_here_container_wrap.requestLayout();
9708
9709 NavitGraphics.whats_here_pointer_image.setX(new_diff);
9710 }
9711 else
9712 {
9713 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9714 NavitGraphics.params_whats_here_container_wrap.leftMargin = new_x;
9715 NavitGraphics.params_whats_here_container_wrap.topMargin = NavitGraphics.NavitAOverlay_s.bubble_001.y - NavitGraphics.whats_here_container_wrap.getHeight() + NavitGraphics.dp_to_px(17);
9716 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9717 NavitGraphics.whats_here_container_wrap.requestLayout();
9718
9719 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9720 // has some bugs // NavitGraphics.params_whats_here_pointer_image.leftMargin = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9721 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9722 NavitGraphics.whats_here_pointer_image.requestLayout();
9723 NavitGraphics.whats_here_pointer_image.setVisibility(View.INVISIBLE);
9724 }
9725 break;
9726 case 37:
9727 // set text for point on screen
9728 String dest_name = "Point on Screen";
9729
9730 try
9731 {
9732 if (Navit.GFX_OVERSPILL)
9733 {
9734 dest_name = NavitGraphics.CallbackGeoCalc(8, (NavitGraphics.NavitAOverlay_s.bubble_001.x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (NavitGraphics.NavitAOverlay_s.bubble_001.y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
9735 }
9736 else
9737 {
9738 dest_name = NavitGraphics.CallbackGeoCalc(8, NavitGraphics.NavitAOverlay_s.bubble_001.x * NavitGraphics.Global_dpi_factor, NavitGraphics.NavitAOverlay_s.bubble_001.y * NavitGraphics.Global_dpi_factor);
9739 }
9740
9741 if ((dest_name.equals(" ")) || (dest_name == null))
9742 {
9743 dest_name = "Point on Screen";
9744 }
9745 }
9746 catch (Exception e)
9747 {
9748 e.printStackTrace();
9749 }
9750
9751 NavitGraphics.whats_here_text.setText(dest_name);
9752 break;
9753 case 38:
9754 try
9755 {
9756 NavitAddressSearchActivity.adapter.clear();
9757 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9758 // NavitAddressSearchActivity.listview.postInvalidate();
9759 }
9760 catch (Exception e)
9761 {
9762 System.out.println("AAEE:001");
9763 }
9764 break;
9765 case 39:
9766 try
9767 {
9768 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9769 }
9770 catch (Exception e)
9771 {
9772 System.out.println("AAEE:008");
9773 }
9774 break;
9775 case 99:
9776 // dismiss dialog, remove dialog - generic
9777 try
9778 {
9779 Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
9780 }
9781 catch (Exception e)
9782 {
9783 e.printStackTrace();
9784 }
9785 try
9786 {
9787 dismissDialog(msg.getData().getInt("dialog_num"));
9788 }
9789 catch (Exception e)
9790 {
9791 e.printStackTrace();
9792 }
9793 try
9794 {
9795 removeDialog(msg.getData().getInt("dialog_num"));
9796 }
9797 catch (Exception e)
9798 {
9799 e.printStackTrace();
9800 }
9801 break;
9802 }
9803 }
9804 };
9805
9806 @TargetApi(Build.VERSION_CODES.FROYO)
9807 protected Dialog onCreateDialog(int id)
9808 {
9809
9810 System.out.println("onCreateDialog id=" + id);
9811
9812 switch (id)
9813 {
9814 // ==============---------- real search offline (old style) here ----------==============
9815 // ==============---------- real search offline (old style) here ----------==============
9816 // ==============---------- real search offline (old style) here ----------==============
9817 case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
9818 search_results_wait_offline = new ProgressDialog(this);
9819 search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9820 search_results_wait_offline.setTitle("--");
9821 search_results_wait_offline.setMessage("--");
9822 search_results_wait_offline.setCancelable(true); // allow to stop search
9823 search_results_wait_offline.setProgress(0);
9824 search_results_wait_offline.setMax(10);
9825
9826 search_results_wait_offline.setOnCancelListener(new OnCancelListener()
9827 {
9828 public void onCancel(DialogInterface dialog)
9829 {
9830 Message msg = new Message();
9831 Bundle b = new Bundle();
9832 b.putInt("Callback", 46);
9833 msg.setData(b);
9834 try
9835 {
9836 NavitGraphics.callback_handler.sendMessage(msg);
9837 }
9838 catch (Exception e)
9839 {
9840 }
9841 Log.e("Navit", "onCancel: search_results_wait offline");
9842 }
9843 });
9844
9845 /*
9846 * search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
9847 * {
9848 * public void onClick(DialogInterface dialog, int which)
9849 * {
9850 * // Use either finish() or return() to either close the activity or just the dialog
9851 * return;
9852 * }
9853 * });
9854 */
9855
9856 DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener()
9857 {
9858 public void onDismiss(DialogInterface dialog)
9859 {
9860 Log.e("Navit", "onDismiss: search_results_wait offline");
9861 dialog.dismiss();
9862 dialog.cancel();
9863 searchresultsThread_offline.stop_me();
9864 }
9865 };
9866 search_results_wait_offline.setOnDismissListener(mOnDismissListener4);
9867 System.out.println("new SearchResultsThread 001");
9868 searchresultsThread_offline = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
9869 searchresultsThread_offline.start();
9870
9871 NavitAddressSearchSpinnerActive = true;
9872 spinner_thread_offline = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
9873 spinner_thread_offline.start();
9874
9875 return search_results_wait_offline;
9876 case Navit.SEARCHRESULTS_WAIT_DIALOG:
9877 search_results_wait = new ProgressDialog(this);
9878 search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9879 search_results_wait.setTitle("--");
9880 search_results_wait.setMessage("--");
9881 search_results_wait.setCancelable(false);
9882 search_results_wait.setProgress(0);
9883 search_results_wait.setMax(10);
9884
9885 DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener()
9886 {
9887 public void onDismiss(DialogInterface dialog)
9888 {
9889 Log.e("Navit", "onDismiss: search_results_wait");
9890 dialog.dismiss();
9891 dialog.cancel();
9892 searchresultsThread.stop_me();
9893 }
9894 };
9895 search_results_wait.setOnDismissListener(mOnDismissListener3);
9896 System.out.println("new SearchResultsThread 002");
9897 searchresultsThread = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
9898 searchresultsThread.start();
9899
9900 NavitAddressSearchSpinnerActive = true;
9901 spinner_thread = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
9902 spinner_thread.start();
9903
9904 return search_results_wait;
9905 case Navit.MAPDOWNLOAD_PRI_DIALOG:
9906 mapdownloader_dialog_pri = new ProgressDialog(this);
9907 mapdownloader_dialog_pri.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9908 mapdownloader_dialog_pri.setTitle("--");
9909 mapdownloader_dialog_pri.setMessage("--");
9910 mapdownloader_dialog_pri.setCancelable(false);
9911 mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
9912 mapdownloader_dialog_pri.setProgress(0);
9913 mapdownloader_dialog_pri.setMax(200);
9914
9915 WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
9916 dialog_lparams.screenBrightness = 0.1f;
9917 mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);
9918
9919 DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener()
9920 {
9921 public void onDismiss(DialogInterface dialog)
9922 {
9923 android.view.WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
9924 mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
9925 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
9926 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
9927 Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
9928 dialog.dismiss();
9929 dialog.cancel();
9930 progressThread_pri.stop_thread();
9931 }
9932 };
9933
9934 try
9935 {
9936 mapdownloader_dialog_pri.setButton(AlertDialog.BUTTON_NEGATIVE, Navit.get_text("Cancel"), new DialogInterface.OnClickListener()
9937 {
9938 @Override
9939 public void onClick(DialogInterface dialog, int which)
9940 {
9941 mapdownloader_dialog_pri.dismiss();
9942 }
9943 });
9944 }
9945 catch (Exception e)
9946 {
9947 e.printStackTrace();
9948 }
9949
9950 mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
9951 mapdownloader_pri = new NavitMapDownloader(this);
9952 progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
9953 progressThread_pri.start();
9954 //
9955 // show license for OSM maps
9956 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
9957 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
9958 return mapdownloader_dialog_pri;
9959 case Navit.MAPDOWNLOAD_SEC_DIALOG:
9960 mapdownloader_dialog_sec = new ProgressDialog(this);
9961 mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9962 mapdownloader_dialog_sec.setTitle("--");
9963 mapdownloader_dialog_sec.setMessage("--");
9964
9965 mapdownloader_dialog_sec.setCancelable(true);
9966 mapdownloader_dialog_sec.setProgress(0);
9967 mapdownloader_dialog_sec.setMax(200);
9968 DialogInterface.OnDismissListener mOnDismissListener2 = new DialogInterface.OnDismissListener()
9969 {
9970 public void onDismiss(DialogInterface dialog)
9971 {
9972 Log.e("Navit", "onDismiss: mapdownloader_dialog sec");
9973 dialog.dismiss();
9974 dialog.cancel();
9975 progressThread_sec.stop_thread();
9976 }
9977 };
9978 mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
9979 mapdownloader_sec = new NavitMapDownloader(this);
9980 progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
9981 progressThread_sec.start();
9982 //
9983 // show license for OSM maps
9984 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
9985 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
9986 return mapdownloader_dialog_sec;
9987 }
9988 // should never get here!!
9989 return null;
9990 }
9991
9992 public void disableSuspend()
9993 {
9994 // wl.acquire();
9995 // wl.release();
9996 }
9997
9998 public void exit2()
9999 {
10000 System.out.println("in exit2");
10001 }
10002
10003 public void exit()
10004 {
10005 try
10006 {
10007 if (toneG != null)
10008 {
10009 toneG.stopTone();
10010 toneG.release();
10011
10012 }
10013 }
10014 catch (Exception e)
10015 {
10016 }
10017
10018 NavitVehicle.turn_off_all_providers();
10019 //try
10020 //{
10021 // NavitSpeech.stop_me();
10022 //}
10023 //catch (Exception s)
10024 //{
10025 // s.printStackTrace();
10026 //}
10027
10028 try
10029 {
10030 if (p.PREF_enable_debug_write_gpx)
10031 {
10032 NavitVehicle.pos_recording_end();
10033 }
10034 }
10035 catch (Exception e)
10036 {
10037 }
10038
10039 try
10040 {
10041 mTts.stop();
10042 }
10043 catch (Exception e)
10044 {
10045
10046 }
10047
10048 try
10049 {
10050 mTts.shutdown();
10051 }
10052 catch (Exception e)
10053 {
10054
10055 }
10056 mTts = null;
10057
10058 try
10059 {
10060 try
10061 {
10062 plugin_api.removeListener(zclientListener);
10063 }
10064 catch (Exception e)
10065 {
10066 e.printStackTrace();
10067 Log.i("NavitPlugin", "Failed to remove Listener", e);
10068 }
10069 unbindService(serviceConnection);
10070 Log.i("NavitPlugin", "Unbind from the service");
10071 }
10072 catch (Throwable t)
10073 {
10074 // catch any issues, typical for destroy routines
10075 // even if we failed to destroy something, we need to continue destroying
10076 Log.i("NavitPlugin", "Failed to unbind from the service", t);
10077 }
10078
10079 try
10080 {
10081 if (wl_navigating != null)
10082 {
10083 //if (wl_navigating.isHeld())
10084 //{
10085 wl_navigating.release();
10086 Log.e("Navit", "WakeLock Nav: release 1");
10087 //}
10088 }
10089 }
10090 catch (Exception e)
10091 {
10092 e.printStackTrace();
10093 }
10094
10095 Log.e("Navit", "1***************** exit called ****************");
10096 Log.e("Navit", "2***************** exit called ****************");
10097 Log.e("Navit", "3***************** exit called ****************");
10098 Log.e("Navit", "4***************** exit called ****************");
10099 Log.e("Navit", "5***************** exit called ****************");
10100 Log.e("Navit", "6***************** exit called ****************");
10101 Log.e("Navit", "7***************** exit called ****************");
10102 Log.e("Navit", "8***************** exit called ****************");
10103
10104 // try
10105 // {
10106 // // hide download actionbar icon
10107 // Navit.cur_menu.findItem(R.id.item_download_menu_button).setVisible(false);
10108 // Navit.cur_menu.findItem(R.id.item_download_menu_button).setEnabled(false);
10109 // }
10110 // catch (Exception e)
10111 // {
10112 // }
10113
10114 // ----- service stop -----
10115 // ----- service stop -----
10116 System.out.println("Navit:exit -> stop ZANaviMapDownloaderService ---------");
10117 ZANaviMapDownloaderService.stop_downloading();
10118 stopService(Navit.ZANaviMapDownloaderServiceIntent);
10119 // ----- service stop -----
10120 // ----- service stop -----
10121
10122 // +++++ // System.gc();
10123 NavitActivity(-4);
10124 Log.e("Navit", "XX1***************** exit called ****************");
10125 finish();
10126 Log.e("Navit", "XX2***************** exit called ****************");
10127 System.runFinalizersOnExit(true);
10128 Log.e("Navit", "XX3***************** exit called ****************");
10129 System.exit(0);
10130 Log.e("Navit", "XX4***************** exit called ****************");
10131 }
10132
10133 public boolean handleMessage(Message m)
10134 {
10135 //Log.e("Navit", "Handler received message");
10136 return true;
10137 }
10138
10139 public static void set_2d3d_mode_in_settings()
10140 {
10141 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10142 SharedPreferences.Editor editor = prefs.edit();
10143 editor.putBoolean("show_3d_map", p.PREF_show_3d_map);
10144 editor.commit();
10145 }
10146
10147 public static void follow_button_on()
10148 {
10149 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10150 SharedPreferences.Editor editor = prefs.edit();
10151 Navit.follow_current = Navit.follow_on;
10152 p.PREF_follow_gps = true;
10153 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10154 editor.commit();
10155
10156 // hold all map drawing -----------
10157 Message msg = new Message();
10158 Bundle b = new Bundle();
10159 b.putInt("Callback", 69);
10160 msg.setData(b);
10161 try
10162 {
10163 NavitGraphics.callback_handler.sendMessage(msg);
10164 }
10165 catch (Exception e)
10166 {
10167 e.printStackTrace();
10168 }
10169 // hold all map drawing -----------
10170
10171 msg = Navit_progress_h.obtainMessage();
10172 b = new Bundle();
10173 msg.what = 32;
10174 try
10175 {
10176 Navit_progress_h.sendMessage(msg);
10177 }
10178 catch (Exception e)
10179 {
10180 }
10181
10182 getPrefs();
10183 activatePrefs(1);
10184
10185 // follow mode ON -----------
10186 msg = new Message();
10187 b = new Bundle();
10188 b.putInt("Callback", 74);
10189 msg.setData(b);
10190 try
10191 {
10192 NavitGraphics.callback_handler.sendMessage(msg);
10193 }
10194 catch (Exception e)
10195 {
10196 e.printStackTrace();
10197 }
10198 // follow mode ON -----------
10199
10200 // allow all map drawing -----------
10201 msg = new Message();
10202 b = new Bundle();
10203 b.putInt("Callback", 70);
10204 msg.setData(b);
10205 try
10206 {
10207 NavitGraphics.callback_handler.sendMessage(msg);
10208 }
10209 catch (Exception e)
10210 {
10211 }
10212 // allow all map drawing -----------
10213
10214 NavitVehicle.set_last_known_pos_fast_provider();
10215
10216 // JB fix
10217 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10218 //System.out.println("xx paint 12 xx");
10219 NavitGraphics.OSD_new.postInvalidate();
10220 NavitGraphics.NavitAOverlay_s.postInvalidate();
10221 }
10222
10223 public static void follow_button_off()
10224 {
10225 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10226 SharedPreferences.Editor editor = prefs.edit();
10227 Navit.follow_current = Navit.follow_off;
10228 p.PREF_follow_gps = false;
10229 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10230 editor.commit();
10231 getPrefs();
10232 activatePrefs(1);
10233
10234 // follow mode OFF -----------
10235 Message msg = new Message();
10236 Bundle b = new Bundle();
10237 b.putInt("Callback", 75);
10238 msg.setData(b);
10239 try
10240 {
10241 NavitGraphics.callback_handler.sendMessage(msg);
10242 }
10243 catch (Exception e)
10244 {
10245 }
10246 // follow mode OFF -----------
10247
10248 msg = Navit_progress_h.obtainMessage();
10249 b = new Bundle();
10250 msg.what = 32;
10251 try
10252 {
10253 Navit_progress_h.sendMessage(msg);
10254 }
10255 catch (Exception e)
10256 {
10257 }
10258
10259 // JB fix
10260 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10261 //System.out.println("xx paint 13 xx");
10262 NavitGraphics.OSD_new.postInvalidate();
10263 NavitGraphics.NavitAOverlay_s.postInvalidate();
10264
10265 }
10266
10267 public static void toggle_poi_pref()
10268 {
10269 // PREF_show_poi_on_map
10270 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10271 SharedPreferences.Editor editor = prefs.edit();
10272 if (p.PREF_show_poi_on_map)
10273 {
10274 p.PREF_show_poi_on_map = false;
10275 }
10276 else
10277 {
10278 p.PREF_show_poi_on_map = true;
10279 }
10280 editor.putBoolean("show_poi_on_map", p.PREF_show_poi_on_map);
10281 editor.commit();
10282 }
10283
10284 public static void toggle_follow_button()
10285 {
10286 // the "red needle" OSD calls this function only!!
10287 //Log.e("NavitVehicle", "toggle_follow_button");
10288 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10289 SharedPreferences.Editor editor = prefs.edit();
10290 if (p.PREF_follow_gps)
10291 {
10292 Navit.follow_current = Navit.follow_off;
10293 p.PREF_follow_gps = false;
10294
10295 // follow mode OFF -----------
10296 Message msg = new Message();
10297 Bundle b = new Bundle();
10298 b.putInt("Callback", 75);
10299 msg.setData(b);
10300 try
10301 {
10302 NavitGraphics.callback_handler.sendMessage(msg);
10303 }
10304
10305 catch (Exception e)
10306 {
10307 e.printStackTrace();
10308 }
10309 // follow mode OFF -----------
10310 }
10311 else
10312 {
10313 Navit.follow_current = Navit.follow_on;
10314 p.PREF_follow_gps = true;
10315
10316 // follow mode ON -----------
10317 Message msg = new Message();
10318 Bundle b = new Bundle();
10319 b.putInt("Callback", 74);
10320 msg.setData(b);
10321 try
10322 {
10323 NavitGraphics.callback_handler.sendMessage(msg);
10324 }
10325 catch (Exception e)
10326 {
10327 e.printStackTrace();
10328 }
10329 // follow mode ON -----------
10330 }
10331 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10332 editor.commit();
10333 //if (!PREF_follow_gps)
10334 //{
10335 // // no compass turning without follow mode!
10336 // PREF_use_compass_heading_base = false;
10337 //}
10338 //if (!PREF_use_compass_heading_base)
10339 //{
10340 // // child is always "false" when parent is "false" !!
10341 // PREF_use_compass_heading_always = false;
10342 //}
10343
10344 Message msg = Navit_progress_h.obtainMessage();
10345 Bundle b = new Bundle();
10346 msg.what = 32;
10347 try
10348 {
10349 Navit_progress_h.sendMessage(msg);
10350 }
10351 catch (Exception e)
10352 {
10353 }
10354
10355 // hold all map drawing -----------
10356 msg = new Message();
10357 b = new Bundle();
10358 b.putInt("Callback", 69);
10359 msg.setData(b);
10360 try
10361 {
10362 NavitGraphics.callback_handler.sendMessage(msg);
10363 }
10364 catch (Exception e)
10365 {
10366 e.printStackTrace();
10367 }
10368 // hold all map drawing -----------
10369
10370 getPrefs();
10371 activatePrefs(1);
10372
10373 // allow all map drawing -----------
10374 msg = new Message();
10375 b = new Bundle();
10376 b.putInt("Callback", 70);
10377 msg.setData(b);
10378 try
10379 {
10380 NavitGraphics.callback_handler.sendMessage(msg);
10381 }
10382 catch (Exception e)
10383 {
10384 }
10385 // allow all map drawing -----------
10386
10387 NavitVehicle.set_last_known_pos_fast_provider();
10388
10389 // JB fix
10390 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10391 //System.out.println("xx paint 14 xx");
10392 NavitGraphics.OSD_new.postInvalidate();
10393 NavitGraphics.NavitAOverlay_s.postInvalidate();
10394 }
10395
10396 public static void setPrefs_search_country()
10397 {
10398 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10399
10400 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10401 SharedPreferences.Editor editor = prefs.edit();
10402 editor.putInt("search_country_id", p.PREF_search_country);
10403 editor.commit();
10404
10405 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10406 }
10407
10408 public static void setPrefs_zoomlevel()
10409 {
10410 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10411
10412 System.out.println("1 save zoom level: " + Navit.GlobalScaleLevel);
10413 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10414 SharedPreferences.Editor editor = prefs.edit();
10415 editor.putInt("zoomlevel_num", Navit.GlobalScaleLevel);
10416 editor.commit();
10417 //System.out.println("2 save zoom level: " + Navit.GlobalScaleLevel);
10418
10419 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10420 }
10421
10422 public static void setPrefs_selected_gpx_dir()
10423 {
10424 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10425
10426 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10427 SharedPreferences.Editor editor = prefs.edit();
10428 editor.putString("last_selected_dir_gpxfiles", p.PREF_last_selected_dir_gpxfiles);
10429 editor.commit();
10430
10431 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10432 }
10433
10434 private static void getPrefs_more_map_detail()
10435 {
10436 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10437
10438 // int ret = 0;
10439 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10440 try
10441 {
10442 p.PREF_more_map_detail = Integer.parseInt(prefs.getString("more_map_detail", "0"));
10443 }
10444 catch (Exception e)
10445 {
10446 p.PREF_more_map_detail = 0;
10447 }
10448
10449 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10450 }
10451
10452 private static void get_prefs_highdpi()
10453 {
10454 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10455
10456 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10457 try
10458 {
10459 p.PREF_shrink_on_high_dpi = prefs.getBoolean("shrink_on_high_dpi", true);
10460 }
10461 catch (Exception e)
10462 {
10463 p.PREF_shrink_on_high_dpi = true;
10464 }
10465
10466 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10467 }
10468
10469 public static boolean saveArray(String[] array, String arrayName, int size)
10470 {
10471 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10472 SharedPreferences.Editor editor = prefs.edit();
10473 editor.putInt(arrayName + "_size", size);
10474 for (int i = 0; i < array.length; i++)
10475 {
10476 if (array[i] == null)
10477 {
10478 editor.putString(arrayName + "_" + i, "");
10479 }
10480 else
10481 {
10482 editor.putString(arrayName + "_" + i, array[i]);
10483 }
10484 }
10485 return editor.commit();
10486 }
10487
10488 public static String[] loadArray(String arrayName, int size)
10489 {
10490 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10491 String[] array = new String[size];
10492 for (int i = 0; i < size; i++)
10493 {
10494 try
10495
10496 {
10497 array[i] = prefs.getString(arrayName + "_" + i, "");
10498 }
10499 catch (Exception e)
10500 {
10501 array[i] = "";
10502 }
10503 //System.out.println("array" + i + "=" + array[i]);
10504 }
10505
10506 return array;
10507 }
10508
10509 public static String[] pushToArray(String[] array_in, String value, int size)
10510 {
10511 for (int j = 0; j < size; j++)
10512 {
10513 if (array_in[j].equals(value))
10514 {
10515 // our value is already in the array, dont add it twice!
10516 return array_in;
10517 }
10518 }
10519
10520 String[] array = new String[size];
10521 for (int i = size - 1; i > 0; i--)
10522 {
10523 array[i] = array_in[i - 1];
10524 }
10525 array[0] = value;
10526 return array;
10527 }
10528
10529 private static void getPrefs()
10530 {
10531 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10532
10533 // save old pref values ---------------
10534 ZANaviPrefs.deep_copy(p, p_old);
10535 // save old pref values ---------------
10536
10537 // Get the xml/preferences.xml preferences
10538 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10539 p.PREF_use_fast_provider = prefs.getBoolean("use_fast_provider", true);
10540 p.PREF_allow_gui_internal = prefs.getBoolean("allow_gui_internal", false);
10541 p.PREF_follow_gps = prefs.getBoolean("follow_gps", true);
10542 p.PREF_use_compass_heading_base = prefs.getBoolean("use_compass_heading_base", false);
10543 p.PREF_use_compass_heading_always = prefs.getBoolean("use_compass_heading_always", false);
10544 p.PREF_use_compass_heading_fast = prefs.getBoolean("use_compass_heading_fast", false);
10545 p.PREF_use_anti_aliasing = prefs.getBoolean("use_anti_aliasing", true);
10546 p.PREF_use_map_filtering = prefs.getBoolean("use_map_filtering", true);
10547 p.PREF_gui_oneway_arrows = prefs.getBoolean("gui_oneway_arrows", true);
10548 p.PREF_c_linedrawing = prefs.getBoolean("c_linedrawing", false);
10549
10550 p.PREF_show_debug_messages = prefs.getBoolean("show_debug_messages", false);
10551
10552 p.PREF_show_3d_map = prefs.getBoolean("show_3d_map", false);
10553 send_data_to_plugin_bg(PLUGIN_MSG_CAT_3d_mode, String.valueOf(p.PREF_show_3d_map));
10554
10555 p.PREF_use_smooth_drawing = prefs.getBoolean("use_smooth_drawing", true);
10556 p.PREF_use_more_smooth_drawing = prefs.getBoolean("use_more_smooth_drawing", false);
10557 if (p.PREF_use_smooth_drawing == false)
10558 {
10559 p.PREF_use_more_smooth_drawing = false;
10560 }
10561 if (p.PREF_use_more_smooth_drawing == true)
10562 {
10563 p.PREF_use_smooth_drawing = true;
10564 }
10565
10566 boolean b1 = prefs.getBoolean("show_real_gps_pos", false);
10567 if (b1 == false)
10568 {
10569 p.PREF_show_real_gps_pos = 0;
10570 }
10571 else
10572 {
10573 p.PREF_show_real_gps_pos = 1;
10574 }
10575
10576 if (p.PREF_use_more_smooth_drawing)
10577 {
10578 NavitGraphics.Vehicle_delay_real_gps_position = 595;
10579 }
10580 else
10581 {
10582 NavitGraphics.Vehicle_delay_real_gps_position = 450;
10583 }
10584
10585 p.PREF_use_lock_on_roads = prefs.getBoolean("use_lock_on_roads", true);
10586 p.PREF_use_route_highways = prefs.getBoolean("use_route_highways", true);
10587 p.PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true);
10588 p.PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL*
10589 p.PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 174698); // default zoom level = 174698 // shows almost the whole world
10590 p.PREF_show_sat_status = prefs.getBoolean("show_sat_status", true);
10591 p.PREF_use_agps = prefs.getBoolean("use_agps", true);
10592 p.PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false);
10593 p.PREF_show_turn_restrictions = prefs.getBoolean("show_turn_restrictions", false);
10594
10595 try
10596 {
10597 // recreate the menu items
10598 Message msg = Navit_progress_h.obtainMessage();
10599 Bundle b = new Bundle();
10600 msg.what = 29;
10601 msg.setData(b);
10602 Navit_progress_h.sendMessage(msg);
10603 }
10604 catch (Exception e)
10605 {
10606 e.printStackTrace();
10607 }
10608
10609 p.PREF_enable_debug_write_gpx = prefs.getBoolean("enable_debug_write_gpx", false);
10610 p.PREF_enable_debug_enable_comm = prefs.getBoolean("enable_debug_enable_comm", false);
10611
10612 p.PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
10613 p.PREF_use_custom_font = prefs.getBoolean("use_custom_font", true);
10614 p.PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
10615 p.PREF_streetsearch_r = prefs.getString("streetsearch_r", "2");
10616 p.PREF_route_style = prefs.getString("route_style", "3");
10617 p.PREF_item_dump = prefs.getBoolean("item_dump", false);
10618 p.PREF_show_route_rects = prefs.getBoolean("show_route_rects", false);
10619 p.PREF_trafficlights_delay = prefs.getString("trafficlights_delay", "0");
10620 boolean tmp = prefs.getBoolean("avoid_sharp_turns", false);
10621 p.PREF_avoid_sharp_turns = "0";
10622 //if (tmp)
10623 //{
10624 // p.PREF_avoid_sharp_turns = "1";
10625 //}
10626 p.PREF_autozoom_flag = prefs.getBoolean("autozoom_flag", true);
10627
10628 p.PREF_show_multipolygons = prefs.getBoolean("show_multipolygons", true);
10629 p.PREF_use_index_search = true; // prefs.getBoolean("use_index_search", true);
10630
10631 // PREF_show_2d3d_toggle = prefs.getBoolean("show_2d3d_toggle", true);
10632 p.PREF_show_2d3d_toggle = true;
10633
10634 // PREF_show_vehicle_3d = prefs.getBoolean("show_vehicle_3d", true);
10635 p.PREF_show_vehicle_3d = true;
10636
10637 p.PREF_speak_filter_special_chars = prefs.getBoolean("speak_filter_special_chars", true);
10638 try
10639 {
10640 p.PREF_routing_engine = Integer.parseInt(prefs.getString("routing_engine", "0"));
10641 }
10642 catch (Exception e)
10643 {
10644 p.PREF_routing_engine = 0;
10645 }
10646
10647 // send to C code --------
10648 NavitGraphics.CallbackMessageChannel(55598, "" + p.PREF_routing_engine);
10649 // send to C code --------
10650
10651 p.PREF_routing_profile = prefs.getString("routing_profile", "car");
10652 p.PREF_road_priority_001 = (prefs.getInt("road_priority_001", (68 - 10)) + 10); // must ADD minimum value!!
10653 p.PREF_road_priority_002 = (prefs.getInt("road_priority_002", (329 - 10)) + 10); // must ADD minimum value!!
10654 p.PREF_road_priority_003 = (prefs.getInt("road_priority_003", (5000 - 10)) + 10); // must ADD minimum value!!
10655 p.PREF_road_priority_004 = (prefs.getInt("road_priority_004", (5 - 0)) + 0); // must ADD minimum value!!
10656
10657 // p.PREF_road_prio_weight_street_1_city = (prefs.getInt("road_prio_weight_street_1_city", (30 - 10)) + 10); // must ADD minimum value!!
10658
10659 p.PREF_traffic_speed_factor = (prefs.getInt("traffic_speed_factor", (83 - 20)) + 20); // must ADD minimum value!!
10660
10661 p.PREF_tracking_connected_pref = (prefs.getInt("tracking_connected_pref", (250 - 0)) + 0); // must ADD minimum value!!
10662 p.PREF_tracking_angle_pref = (prefs.getInt("tracking_angle_pref", (40 - 0)) + 0); // must ADD minimum value!!
10663
10664 p.PREF_streets_only = prefs.getBoolean("streets_only", false);
10665 p.PREF_show_status_bar = prefs.getBoolean("show_status_bar", true);
10666 p.PREF_show_poi_on_map = prefs.getBoolean("show_poi_on_map", false);
10667 p.PREF_last_selected_dir_gpxfiles = prefs.getString("last_selected_dir_gpxfiles", MAP_FILENAME_PATH + "/../");
10668
10669 p.PREF_roadspeed_warning = prefs.getBoolean("roadspeed_warning", false);
10670 p.PREF_lane_assist = prefs.getBoolean("lane_assist", false);
10671
10672 try
10673 {
10674 p.PREF_roadspeed_warning_margin = Integer.parseInt(prefs.getString("roadspeed_warning_margin", "20"));
10675 }
10676 catch (Exception e)
10677 {
10678 p.PREF_roadspeed_warning_margin = 20;
10679 }
10680
10681 p.PREF_StreetSearchStrings = loadArray("xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
10682
10683 try
10684 {
10685 p.PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
10686 }
10687 catch (Exception e)
10688 {
10689 p.PREF_drawatorder = 0;
10690 }
10691
10692 //try
10693 //{
10694 // PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1"));
10695 //}
10696 //catch (Exception e)
10697 //{
10698 p.PREF_cancel_map_drawing_timeout = 1;
10699 //}
10700
10701 try
10702 {
10703 p.PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "3"));
10704 }
10705 catch (Exception e)
10706 {
10707 p.PREF_map_font_size = 2;
10708 }
10709
10710 Navit_last_address_search_country_id = p.PREF_search_country;
10711 Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[p.PREF_search_country][0];
10712
10713 if (!p.PREF_follow_gps)
10714 {
10715 // no compass turning without follow mode!
10716 p.PREF_use_compass_heading_base = false;
10717 }
10718
10719 if (!p.PREF_use_compass_heading_base)
10720 {
10721 // child is always "false" when parent is "false" !!
10722 p.PREF_use_compass_heading_always = false;
10723 }
10724
10725 p.PREF_show_maps_debug_view = prefs.getBoolean("show_maps_debug_view", false);
10726
10727 p.PREF_show_vehicle_in_center = prefs.getBoolean("show_vehicle_in_center", false);
10728 p.PREF_use_imperial = prefs.getBoolean("use_imperial", false);
10729 Navit.cur_max_speed = -1; // to update speedwarning graphics
10730
10731 // System.out.println("get settings");
10732 // System.out.println("PREF_search_country=" + PREF_search_country);
10733 // System.out.println("PREF_follow_gps=" + PREF_follow_gps);
10734 // System.out.println("PREF_use_fast_provider=" + PREF_use_fast_provider);
10735 // System.out.println("PREF_allow_gui_internal=" + PREF_allow_gui_internal);
10736 // System.out.println("PREF_use_compass_heading_base=" + PREF_use_compass_heading_base);
10737 // System.out.println("PREF_use_compass_heading_always=" + PREF_use_compass_heading_always);
10738 // System.out.println("PREF_show_vehicle_in_center=" + PREF_show_vehicle_in_center);
10739 // System.out.println("PREF_use_imperial=" + PREF_use_imperial);
10740
10741 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10742 }
10743
10744 private static void activatePrefs()
10745 {
10746 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10747
10748 activatePrefs(1);
10749
10750 if (p.PREF_save_zoomlevel)
10751 {
10752 // only if really started, but NOT if returning from our own child activities!!
10753
10754 //System.out.println("3 restore zoom level: " + Navit.GlobalScaleLevel);
10755 //System.out.println("4 restore zoom level: " + PREF_zoomlevel_num);
10756
10757 Message msg = new Message();
10758 Bundle b = new Bundle();
10759 b.putInt("Callback", 33);
10760 b.putString("s", Integer.toString(p.PREF_zoomlevel_num));
10761 msg.setData(b);
10762 try
10763 {
10764 NavitGraphics.callback_handler.sendMessage(msg);
10765 Navit.GlobalScaleLevel = p.PREF_zoomlevel_num;
10766 //System.out.println("5 restore zoom level: " + PREF_zoomlevel_num);
10767 }
10768 catch (Exception e)
10769 {
10770 }
10771 }
10772 else
10773 {
10774 p.PREF_zoomlevel_num = Navit.GlobalScaleLevel;
10775 }
10776
10777 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10778 }
10779
10780 private static void set_TurnRestrictions_layers()
10781 {
10782 int on_ = 59; // on
10783
10784 if (!p.PREF_show_turn_restrictions)
10785 {
10786 on_ = 60; // off
10787 }
10788
10789 Message msg = new Message();
10790 Bundle b = new Bundle();
10791 b.putInt("Callback", on_);
10792 b.putString("s", "TurnRestrictions");
10793 msg.setData(b);
10794 NavitGraphics.callback_handler.sendMessage(msg);
10795 }
10796
10797 private static void set_poi_layers()
10798 {
10799 int on_ = 59;
10800 int off_ = 60;
10801
10802 // System.out.println("POI:1");
10803 if (p.PREF_show_poi_on_map)
10804 {
10805 // System.out.println("POI:2");
10806 on_ = 60;
10807 off_ = 59;
10808 }
10809
10810 // toggle the normal POI layers (to avoid double POIs)
10811 Message msg = new Message();
10812 Bundle b = new Bundle();
10813 b.putInt("Callback", on_);
10814 b.putString("s", "POI Symbols");
10815 msg.setData(b);
10816 NavitGraphics.callback_handler.sendMessage(msg);
10817
10818 msg = new Message();
10819 b = new Bundle();
10820 b.putInt("Callback", on_);
10821 b.putString("s", "POI Labels");
10822 msg.setData(b);
10823 NavitGraphics.callback_handler.sendMessage(msg);
10824
10825 // toggle full POI icons on/off
10826 msg = new Message();
10827 b = new Bundle();
10828 b.putInt("Callback", off_);
10829 b.putString("s", "Android-POI-Icons-full");
10830 msg.setData(b);
10831 NavitGraphics.callback_handler.sendMessage(msg);
10832
10833 msg = new Message();
10834 b = new Bundle();
10835 b.putInt("Callback", off_);
10836 b.putString("s", "Android-POI-Labels-full");
10837 msg.setData(b);
10838 NavitGraphics.callback_handler.sendMessage(msg);
10839
10840 // draw_map();
10841 }
10842
10843 private static void activatePrefs(int dummy)
10844 {
10845
10846 need_recalc_route = false; // do we need to recalc the route?
10847
10848 // call some functions to activate the new settings
10849 if (p.PREF_follow_gps)
10850 {
10851 Navit.follow_current = Navit.follow_on;
10852 }
10853 else
10854 {
10855 Navit.follow_current = Navit.follow_off;
10856 }
10857
10858 if (p.PREF_use_fast_provider)
10859 {
10860 NavitVehicle.turn_on_fast_provider();
10861 }
10862 else
10863 {
10864 NavitVehicle.turn_off_fast_provider();
10865 }
10866
10867 if (p.PREF_show_sat_status)
10868 {
10869 NavitVehicle.turn_on_sat_status();
10870 }
10871 else
10872 {
10873 // status always on !
10874 //
10875 // NavitVehicle.turn_off_sat_status();
10876 NavitVehicle.turn_on_sat_status();
10877 }
10878
10879 if (p.PREF_show_status_bar)
10880 {
10881 show_status_bar_wrapper();
10882 }
10883 else
10884 {
10885 hide_status_bar_wrapper();
10886 }
10887
10888 if (p.PREF_allow_gui_internal)
10889 {
10890 Message msg = new Message();
10891 Bundle b = new Bundle();
10892 b.putInt("Callback", 10);
10893 msg.setData(b);
10894 try
10895 {
10896 NavitGraphics.callback_handler.sendMessage(msg);
10897 }
10898 catch (Exception e)
10899 {
10900 }
10901 }
10902 else
10903 {
10904 Message msg = new Message();
10905 Bundle b = new Bundle();
10906 b.putInt("Callback", 9);
10907 msg.setData(b);
10908 try
10909 {
10910 NavitGraphics.callback_handler.sendMessage(msg);
10911 }
10912 catch (Exception e)
10913 {
10914 }
10915 }
10916
10917 if (p.PREF_use_compass_heading_base)
10918 {
10919 // turn on compass
10920 msg_to_msg_handler(new Bundle(), 12);
10921 Message msg = new Message();
10922 Bundle b = new Bundle();
10923 b.putInt("Callback", 11);
10924 msg.setData(b);
10925 try
10926 {
10927 NavitGraphics.callback_handler.sendMessage(msg);
10928 }
10929 catch (Exception e)
10930 {
10931 }
10932 }
10933 else
10934 {
10935 // turn off compass
10936 msg_to_msg_handler(new Bundle(), 13);
10937 Message msg = new Message();
10938 Bundle b = new Bundle();
10939 b.putInt("Callback", 12);
10940 msg.setData(b);
10941 try
10942 {
10943 NavitGraphics.callback_handler.sendMessage(msg);
10944 }
10945 catch (Exception e)
10946 {
10947 }
10948 }
10949
10950 if (p.PREF_show_maps_debug_view == true)
10951 {
10952 // show real gps pos
10953 Message msg = new Message();
10954 Bundle b = new Bundle();
10955 b.putInt("Callback", 112);
10956 b.putString("s", "1");
10957 msg.setData(b);
10958 try
10959 {
10960 NavitGraphics.callback_handler.sendMessage(msg);
10961 }
10962 catch (Exception e)
10963 {
10964 }
10965 }
10966 else
10967 {
10968 Message msg = new Message();
10969 Bundle b = new Bundle();
10970 b.putInt("Callback", 112);
10971 b.putString("s", "0");
10972 msg.setData(b);
10973 try
10974 {
10975 NavitGraphics.callback_handler.sendMessage(msg);
10976 }
10977 catch (Exception e)
10978 {
10979 }
10980 }
10981
10982 if (p.PREF_show_real_gps_pos == 1)
10983 {
10984 // show real gps pos
10985 Message msg = new Message();
10986 Bundle b = new Bundle();
10987 b.putInt("Callback", 111);
10988 b.putString("s", "1");
10989 msg.setData(b);
10990 try
10991 {
10992 NavitGraphics.callback_handler.sendMessage(msg);
10993 }
10994 catch (Exception e)
10995 {
10996 }
10997 }
10998 else
10999 {
11000 Message msg = new Message();
11001 Bundle b = new Bundle();
11002 b.putInt("Callback", 111);
11003 b.putString("s", "0");
11004 msg.setData(b);
11005 try
11006 {
11007 NavitGraphics.callback_handler.sendMessage(msg);
11008 }
11009 catch (Exception e)
11010 {
11011 }
11012 }
11013
11014 // search radius for housenumbers near streets -----------------
11015 Message msg43 = new Message();
11016 Bundle b43 = new Bundle();
11017 b43.putInt("Callback", 89);
11018 b43.putString("s", "1500");
11019 msg43.setData(b43);
11020 try
11021 {
11022 NavitGraphics.callback_handler.sendMessage(msg43);
11023 }
11024 catch (Exception e)
11025 {
11026 }
11027 // search radius for housenumbers near streets -----------------
11028
11029 // set routing profile -----------------
11030 if (Navit_Largemap_DonateVersion_Installed == true)
11031 {
11032 Message msg43a = new Message();
11033 Bundle b43a = new Bundle();
11034 b43a.putInt("Callback", 90);
11035 b43a.putString("s", p.PREF_routing_profile); // set routing profile
11036 msg43a.setData(b43a);
11037 try
11038 {
11039 NavitGraphics.callback_handler.sendMessage(msg43a);
11040 }
11041 catch (Exception e)
11042 {
11043 }
11044
11045 // need_recalc_route = true;
11046 }
11047 // set routing profile -----------------
11048
11049 Message msg99a = new Message();
11050 Bundle b99a = new Bundle();
11051 b99a.putInt("Callback", 98);
11052 // System.out.println("tracking_connected_pref=" + PREF_tracking_connected_pref);
11053 b99a.putString("s", "" + p.PREF_tracking_connected_pref); // set routing profile
11054 msg99a.setData(b99a);
11055 try
11056 {
11057 NavitGraphics.callback_handler.sendMessage(msg99a);
11058 }
11059 catch (Exception e)
11060 {
11061 }
11062
11063 msg99a = new Message();
11064 b99a = new Bundle();
11065 b99a.putInt("Callback", 99);
11066 // System.out.println("tracking_angle_pref=" + PREF_tracking_angle_pref);
11067 b99a.putString("s", "" + p.PREF_tracking_angle_pref); // set routing profile
11068 msg99a.setData(b99a);
11069 try
11070 {
11071 NavitGraphics.callback_handler.sendMessage(msg99a);
11072 }
11073 catch (Exception e)
11074 {
11075 }
11076
11077 // change road profile -----------------
11078 if (Navit_Largemap_DonateVersion_Installed == true)
11079 {
11080 if (p.PREF_routing_profile.equals("bike-normal"))
11081 {
11082 Message msg43b = new Message();
11083 Bundle b43b = new Bundle();
11084 b43b.putInt("Callback", 91);
11085 System.out.println("road_priority_001=" + p.PREF_road_priority_001);
11086 b43b.putString("s", "" + p.PREF_road_priority_001); // set routing profile
11087 msg43b.setData(b43b);
11088 try
11089 {
11090 NavitGraphics.callback_handler.sendMessage(msg43b);
11091 }
11092 catch (Exception e)
11093 {
11094 }
11095
11096 msg43b = new Message();
11097 b43b = new Bundle();
11098 b43b.putInt("Callback", 92);
11099 System.out.println("road_priority_002=" + p.PREF_road_priority_002);
11100 b43b.putString("s", "" + p.PREF_road_priority_002); // set routing profile
11101 msg43b.setData(b43b);
11102 try
11103 {
11104 NavitGraphics.callback_handler.sendMessage(msg43b);
11105 }
11106 catch (Exception e)
11107 {
11108 }
11109
11110 msg43b = new Message();
11111 b43b = new Bundle();
11112 b43b.putInt("Callback", 93);
11113 System.out.println("road_priority_003=" + p.PREF_road_priority_003);
11114 b43b.putString("s", "" + p.PREF_road_priority_003); // set routing profile
11115 msg43b.setData(b43b);
11116 try
11117 {
11118 NavitGraphics.callback_handler.sendMessage(msg43b);
11119 }
11120 catch (Exception e)
11121 {
11122 }
11123
11124 msg43b = new Message();
11125 b43b = new Bundle();
11126 b43b.putInt("Callback", 94);
11127 System.out.println("road_priority_004=" + p.PREF_road_priority_004);
11128 b43b.putString("s", "" + p.PREF_road_priority_004); // set routing profile
11129 msg43b.setData(b43b);
11130 try
11131 {
11132 NavitGraphics.callback_handler.sendMessage(msg43b);
11133 }
11134 catch (Exception e)
11135 {
11136 }
11137
11138 // switch off layers --------------------
11139 msg43b = new Message();
11140 b43b = new Bundle();
11141 b43b.putInt("Callback", 60);
11142 b43b.putString("s", "POI traffic lights");
11143 msg43b.setData(b43b);
11144 try
11145 {
11146 NavitGraphics.callback_handler.sendMessage(msg43b);
11147 }
11148 catch (Exception e)
11149 {
11150 }
11151 // switch off layers --------------------
11152
11153 // switch ON layers --------------------
11154 msg43b = new Message();
11155 b43b = new Bundle();
11156 b43b.putInt("Callback", 59);
11157 b43b.putString("s", "POI bicycle");
11158 msg43b.setData(b43b);
11159 try
11160 {
11161 NavitGraphics.callback_handler.sendMessage(msg43b);
11162 }
11163 catch (Exception e)
11164 {
11165 }
11166 // switch ON layers --------------------
11167
11168 }
11169 else
11170 {
11171 // switch off layers --------------------
11172 Message msg43b = new Message();
11173 Bundle b43b = new Bundle();
11174 b43b.putInt("Callback", 60);
11175 b43b.putString("s", "POI bicycle");
11176 msg43b.setData(b43b);
11177 try
11178 {
11179 NavitGraphics.callback_handler.sendMessage(msg43b);
11180 }
11181 catch (Exception e)
11182 {
11183 }
11184 // switch off layers --------------------
11185
11186 // switch ON layers --------------------
11187 msg43b = new Message();
11188 b43b = new Bundle();
11189 b43b.putInt("Callback", 59);
11190 b43b.putString("s", "POI traffic lights");
11191 msg43b.setData(b43b);
11192 try
11193 {
11194 NavitGraphics.callback_handler.sendMessage(msg43b);
11195 }
11196 catch (Exception e)
11197 {
11198 }
11199 // switch ON layers --------------------
11200 }
11201 }
11202 // change road profile -----------------
11203
11204 // -- debug -- change some prio weights --
11205 // if ((!p.PREF_routing_profile.equals("bike-normal")) && (!p.PREF_routing_profile.equals("bike-no-oneway")) && (!p.PREF_routing_profile.equals("bike-avoid-roads")))
11206 // {
11207 // Message msg93 = new Message();
11208 // Bundle b93 = new Bundle();
11209 // b93.putInt("Callback", 110);
11210 // b93.putString("s", "street_1_city#route_prio_weight:" + p.PREF_road_prio_weight_street_1_city);
11211 // msg93.setData(b93);
11212 // try
11213 // {
11214 // NavitGraphics.callback_handler.sendMessage(msg93);
11215 // }
11216 // catch (Exception e)
11217 // {
11218 // }
11219 //
11220 // if (p_old.PREF_road_prio_weight_street_1_city != p.PREF_road_prio_weight_street_1_city)
11221 // {
11222 // need_recalc_route = true;
11223 // }
11224 // }
11225 // -- debug -- change some prio weights --
11226
11227 if (NavitGraphics.navit_route_status == 0)
11228 {
11229 if (p.PREF_c_linedrawing)
11230 {
11231 Message msg = new Message();
11232 Bundle b = new Bundle();
11233 b.putInt("Callback", 85);
11234 b.putString("s", "1");
11235 msg.setData(b);
11236 try
11237 {
11238 NavitGraphics.callback_handler.sendMessage(msg);
11239 }
11240 catch (Exception e)
11241 {
11242 }
11243 }
11244 else
11245 {
11246 Message msg = new Message();
11247 Bundle b = new Bundle();
11248 b.putInt("Callback", 85);
11249 b.putString("s", "0");
11250 msg.setData(b);
11251 try
11252 {
11253 NavitGraphics.callback_handler.sendMessage(msg);
11254 }
11255 catch (Exception e)
11256 {
11257 }
11258 }
11259 }
11260
11261 Message msg33 = new Message();
11262 Bundle b33 = new Bundle();
11263 b33.putInt("Callback", 103);
11264 if (p.PREF_show_vehicle_in_center)
11265 {
11266 b33.putString("s", "0");
11267 }
11268 else
11269 {
11270 b33.putString("s", "" + NavitGraphics.lower_than_center_percent);
11271 }
11272 msg33.setData(b33);
11273 try
11274 {
11275 NavitGraphics.callback_handler.sendMessage(msg33);
11276 }
11277 catch (Exception e88)
11278 {
11279 }
11280
11281 if (p.PREF_use_imperial)
11282 {
11283 Message msg = new Message();
11284 Bundle b = new Bundle();
11285 b.putInt("Callback", 16);
11286 msg.setData(b);
11287 try
11288 {
11289 NavitGraphics.callback_handler.sendMessage(msg);
11290 }
11291 catch (Exception e)
11292 {
11293 }
11294 }
11295 else
11296 {
11297 Message msg = new Message();
11298 Bundle b = new Bundle();
11299 b.putInt("Callback", 15);
11300 msg.setData(b);
11301 try
11302 {
11303 NavitGraphics.callback_handler.sendMessage(msg);
11304 }
11305 catch (Exception e)
11306 {
11307 }
11308 }
11309
11310 if (p.PREF_show_debug_messages)
11311 {
11312 Message msg = new Message();
11313 Bundle b = new Bundle();
11314 b.putInt("Callback", 24);
11315 msg.setData(b);
11316 try
11317 {
11318 NavitGraphics.callback_handler.sendMessage(msg);
11319 }
11320 catch (Exception e)
11321 {
11322 }
11323 }
11324 else
11325 {
11326 Message msg = new Message();
11327 Bundle b = new Bundle();
11328 b.putInt("Callback", 25);
11329 msg.setData(b);
11330 try
11331 {
11332 NavitGraphics.callback_handler.sendMessage(msg);
11333 }
11334 catch (Exception e)
11335 {
11336 }
11337 }
11338
11339 // if (PREF_show_3d_map)
11340 // {
11341 // Message msg = new Message();
11342 // Bundle b = new Bundle();
11343 // b.putInt("Callback", 31);
11344 // msg.setData(b);
11345 // try
11346 // {
11347 // N_NavitGraphics.callback_handler.sendMessage(msg);
11348 // }
11349 // catch (Exception e)
11350 // {
11351 // }
11352 // }
11353 // else
11354 // {
11355 // Message msg = new Message();
11356 // Bundle b = new Bundle();
11357 // b.putInt("Callback", 30);
11358 // msg.setData(b);
11359 // try
11360 // {
11361 // N_NavitGraphics.callback_handler.sendMessage(msg);
11362 // }
11363 // catch (Exception e)
11364 // {
11365 // }
11366 // }
11367
11368 if (p.PREF_use_lock_on_roads)
11369 {
11370 Message msg = new Message();
11371 Bundle b = new Bundle();
11372 b.putInt("Callback", 36);
11373 msg.setData(b);
11374 try
11375 {
11376 NavitGraphics.callback_handler.sendMessage(msg);
11377 }
11378 catch (Exception e)
11379 {
11380 }
11381 }
11382 else
11383 {
11384 Message msg = new Message();
11385 Bundle b = new Bundle();
11386 b.putInt("Callback", 37);
11387 msg.setData(b);
11388 try
11389 {
11390 NavitGraphics.callback_handler.sendMessage(msg);
11391 }
11392 catch (Exception e)
11393 {
11394 }
11395 }
11396
11397 // if (PREF_draw_polyline_circles)
11398 // {
11399 // Message msg = new Message();
11400 // Bundle b = new Bundle();
11401 // b.putString("s", "0");
11402 // b.putInt("Callback", 56);
11403 // msg.setData(b);
11404 // try
11405 // {
11406 // N_NavitGraphics.callback_handler.sendMessage(msg);
11407 // }
11408 // catch (Exception e)
11409 // {
11410 // }
11411 // }
11412 // else
11413 // {
11414 // Message msg = new Message();
11415 // Bundle b = new Bundle();
11416 // b.putString("s", "1");
11417 // b.putInt("Callback", 56);
11418 // msg.setData(b);
11419 // try
11420 // {
11421 // N_NavitGraphics.callback_handler.sendMessage(msg);
11422 // }
11423 // catch (Exception e)
11424 // {
11425 // }
11426 // }
11427
11428 if (p.PREF_use_route_highways)
11429 {
11430 Message msg = new Message();
11431 Bundle b = new Bundle();
11432 b.putInt("Callback", 42);
11433 msg.setData(b);
11434 try
11435 {
11436 NavitGraphics.callback_handler.sendMessage(msg);
11437 }
11438 catch (Exception e)
11439 {
11440 }
11441 }
11442 else
11443 {
11444 Message msg = new Message();
11445 Bundle b = new Bundle();
11446 b.putInt("Callback", 43);
11447 msg.setData(b);
11448 try
11449 {
11450 NavitGraphics.callback_handler.sendMessage(msg);
11451 }
11452 catch (Exception e)
11453 {
11454 }
11455 }
11456
11457 Message msg7 = new Message();
11458 Bundle b7 = new Bundle();
11459 b7.putInt("Callback", 57);
11460 b7.putString("s", "" + p.PREF_drawatorder);
11461 msg7.setData(b7);
11462 try
11463 {
11464 NavitGraphics.callback_handler.sendMessage(msg7);
11465 }
11466 catch (Exception e)
11467 {
11468 }
11469
11470 msg7 = new Message();
11471 b7 = new Bundle();
11472 b7.putInt("Callback", 58);
11473 b7.putString("s", p.PREF_streetsearch_r);
11474 msg7.setData(b7);
11475 try
11476 {
11477 NavitGraphics.callback_handler.sendMessage(msg7);
11478 }
11479 catch (Exception e)
11480 {
11481 }
11482
11483 if (p.PREF_speak_street_names)
11484 {
11485 Message msg = new Message();
11486 Bundle b = new Bundle();
11487 b.putInt("Callback", 54);
11488 msg.setData(b);
11489 try
11490 {
11491 NavitGraphics.callback_handler.sendMessage(msg);
11492 }
11493 catch (Exception e)
11494 {
11495 }
11496 }
11497 else
11498 {
11499 Message msg = new Message();
11500 Bundle b = new Bundle();
11501 b.putInt("Callback", 53);
11502 msg.setData(b);
11503 try
11504 {
11505 NavitGraphics.callback_handler.sendMessage(msg);
11506 }
11507 catch (Exception e)
11508 {
11509 }
11510
11511 }
11512
11513 try
11514 {
11515 NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[p.PREF_cancel_map_drawing_timeout];
11516 NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[p.PREF_cancel_map_drawing_timeout];
11517 NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[p.PREF_cancel_map_drawing_timeout];
11518 }
11519 catch (Exception e)
11520 {
11521
11522 }
11523
11524 // route variant
11525 Message msg67 = new Message();
11526 Bundle b67 = new Bundle();
11527 // turn off 1
11528 b67.putInt("Callback", 60);
11529 b67.putString("s", "route_001");
11530 msg67.setData(b67);
11531
11532 try
11533 {
11534 NavitGraphics.callback_handler.sendMessage(msg67);
11535 }
11536 catch (Exception e)
11537 {
11538 }
11539 // turn off 2
11540 msg67 = new Message();
11541 b67 = new Bundle();
11542 b67.putInt("Callback", 60);
11543 b67.putString("s", "route_002");
11544 msg67.setData(b67);
11545 try
11546 {
11547 NavitGraphics.callback_handler.sendMessage(msg67);
11548 }
11549 catch (Exception e)
11550 {
11551 }
11552 // turn off 3
11553 msg67 = new Message();
11554 b67 = new Bundle();
11555 b67.putInt("Callback", 60);
11556 b67.putString("s", "route_003");
11557 msg67.setData(b67);
11558 try
11559 {
11560 NavitGraphics.callback_handler.sendMessage(msg67);
11561 }
11562 catch (Exception e)
11563 {
11564 }
11565
11566 // turn on the wanted route style
11567 msg67 = new Message();
11568 b67 = new Bundle();
11569 b67.putInt("Callback", 59);
11570 b67.putString("s", "route_00" + p.PREF_route_style);
11571 msg67.setData(b67);
11572 try
11573 {
11574 NavitGraphics.callback_handler.sendMessage(msg67);
11575 }
11576 catch (Exception e)
11577 {
11578 }
11579 // route variant
11580
11581 // show route rectanlges -----
11582 if (p.PREF_show_route_rects)
11583 {
11584 msg67 = new Message();
11585 b67 = new Bundle();
11586 b67.putInt("Callback", 76);
11587 msg67.setData(b67);
11588 try
11589 {
11590 NavitGraphics.callback_handler.sendMessage(msg67);
11591 }
11592 catch (Exception e)
11593 {
11594 }
11595 }
11596 else
11597 {
11598 msg67 = new Message();
11599 b67 = new Bundle();
11600 b67.putInt("Callback", 77);
11601 msg67.setData(b67);
11602 try
11603 {
11604 NavitGraphics.callback_handler.sendMessage(msg67);
11605 }
11606 catch (Exception e)
11607 {
11608 }
11609 }
11610 // show route rectanlges -----
11611
11612 // show route multipolygons -----
11613 if (p.PREF_show_multipolygons)
11614 {
11615 msg67 = new Message();
11616 b67 = new Bundle();
11617 b67.putInt("Callback", 66);
11618 msg67.setData(b67);
11619 try
11620 {
11621 NavitGraphics.callback_handler.sendMessage(msg67);
11622 }
11623 catch (Exception e)
11624 {
11625 }
11626 }
11627 else
11628 {
11629 msg67 = new Message();
11630 b67 = new Bundle();
11631 b67.putInt("Callback", 67);
11632 msg67.setData(b67);
11633 try
11634 {
11635 NavitGraphics.callback_handler.sendMessage(msg67);
11636 }
11637 catch (Exception e)
11638 {
11639 }
11640 }
11641 // show route multipolygons -----
11642
11643 // traffic lights delay ----
11644 msg67 = new Message();
11645 b67 = new Bundle();
11646 b67.putInt("Callback", 79);
11647 //System.out.println("traffic lights delay:" + PREF_trafficlights_delay);
11648 // (PREF_trafficlights_delay / 10) seconds delay for each traffic light
11649 b67.putString("s", p.PREF_trafficlights_delay); // (delay in 1/10 of a second)
11650 msg67.setData(b67);
11651 try
11652 {
11653 NavitGraphics.callback_handler.sendMessage(msg67);
11654 }
11655 catch (Exception e)
11656 {
11657 }
11658 // traffic lights delay ----
11659
11660 // avoid sharp turns ----
11661 msg67 = new Message();
11662 b67 = new Bundle();
11663 b67.putInt("Callback", 86);
11664 b67.putString("s", p.PREF_avoid_sharp_turns);
11665 msg67.setData(b67);
11666 try
11667 {
11668 NavitGraphics.callback_handler.sendMessage(msg67);
11669 }
11670 catch (Exception e)
11671 {
11672 }
11673
11674 msg67 = new Message();
11675 b67 = new Bundle();
11676 b67.putInt("Callback", 87);
11677 b67.putString("s", "47"); // **DANGER** sharp turn max angle hardcoded here!! **DANGER**
11678 msg67.setData(b67);
11679 try
11680 {
11681 NavitGraphics.callback_handler.sendMessage(msg67);
11682 }
11683 catch (Exception e)
11684 {
11685 }
11686
11687 msg67 = new Message();
11688 b67 = new Bundle();
11689 b67.putInt("Callback", 88);
11690 b67.putString("s", "6000");
11691 msg67.setData(b67);
11692 try
11693 {
11694 NavitGraphics.callback_handler.sendMessage(msg67);
11695 }
11696 catch (Exception e)
11697 {
11698 }
11699 // avoid sharp turns ----
11700
11701 // autozoom flag ----
11702 msg67 = new Message();
11703 b67 = new Bundle();
11704 b67.putInt("Callback", 80);
11705 if (p.PREF_autozoom_flag)
11706 {
11707 b67.putString("s", "1"); // (0 or 1)
11708 }
11709 else
11710 {
11711 b67.putString("s", "0"); // (0 or 1)
11712 }
11713 msg67.setData(b67);
11714 try
11715 {
11716 NavitGraphics.callback_handler.sendMessage(msg67);
11717 }
11718 catch (Exception e)
11719 {
11720
11721 }
11722 // autozoom flag ----
11723
11724 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed))
11725 {
11726 // use pref
11727 }
11728 else
11729 {
11730 p.PREF_roadspeed_warning = false;
11731 }
11732
11733 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed))
11734 {
11735 // use pref
11736 }
11737 else
11738 {
11739 p.PREF_lane_assist = false;
11740 }
11741
11742 if (p.PREF_streets_only)
11743 {
11744 // ----------------------- streets only pref -------------------
11745 // 59 -> enable
11746 // 60 -> disable
11747 Message msg31 = new Message();
11748 Bundle b31 = new Bundle();
11749 b31.putInt("Callback", 60);
11750 b31.putString("s", "polygons001");
11751 msg31.setData(b31);
11752 NavitGraphics.callback_handler.sendMessage(msg31);
11753
11754 msg31 = new Message();
11755 b31 = new Bundle();
11756 b31.putInt("Callback", 60);
11757 b31.putString("s", "polygons");
11758 msg31.setData(b31);
11759 NavitGraphics.callback_handler.sendMessage(msg31);
11760
11761 msg31 = new Message();
11762 b31 = new Bundle();
11763 b31.putInt("Callback", 60);
11764 b31.putString("s", "POI Symbols");
11765 msg31.setData(b31);
11766 NavitGraphics.callback_handler.sendMessage(msg31);
11767
11768 msg31 = new Message();
11769 b31 = new Bundle();
11770 b31.putInt("Callback", 60);
11771 b31.putString("s", "POI Labels");
11772 msg31.setData(b31);
11773 NavitGraphics.callback_handler.sendMessage(msg31);
11774
11775 msg31 = new Message();
11776 b31 = new Bundle();
11777 b31.putInt("Callback", 60);
11778 b31.putString("s", "Android-POI-Icons-full");
11779 msg31.setData(b31);
11780 NavitGraphics.callback_handler.sendMessage(msg31);
11781
11782 msg31 = new Message();
11783 b31 = new Bundle();
11784 b31.putInt("Callback", 60);
11785 b31.putString("s", "Android-POI-Labels-full");
11786 msg31.setData(b31);
11787 NavitGraphics.callback_handler.sendMessage(msg31);
11788
11789 msg31 = new Message();
11790 b31 = new Bundle();
11791 b31.putInt("Callback", 60);
11792 b31.putString("s", "streets");
11793 msg31.setData(b31);
11794 NavitGraphics.callback_handler.sendMessage(msg31);
11795
11796 msg31 = new Message();
11797 b31 = new Bundle();
11798 b31.putInt("Callback", 60);
11799 b31.putString("s", "streets_1");
11800 msg31.setData(b31);
11801 NavitGraphics.callback_handler.sendMessage(msg31);
11802
11803 msg31 = new Message();
11804 b31 = new Bundle();
11805 b31.putInt("Callback", 60);
11806 b31.putString("s", "streets_2");
11807 msg31.setData(b31);
11808 NavitGraphics.callback_handler.sendMessage(msg31);
11809
11810 msg31 = new Message();
11811 b31 = new Bundle();
11812 b31.putInt("Callback", 59);
11813 b31.putString("s", "streets_STR_ONLY");
11814 msg31.setData(b31);
11815 NavitGraphics.callback_handler.sendMessage(msg31);
11816
11817 msg31 = new Message();
11818 b31 = new Bundle();
11819 b31.putInt("Callback", 59);
11820 b31.putString("s", "streets_1_STR_ONLY");
11821 msg31.setData(b31);
11822 NavitGraphics.callback_handler.sendMessage(msg31);
11823
11824 msg31 = new Message();
11825 b31 = new Bundle();
11826 b31.putInt("Callback", 59);
11827 b31.putString("s", "streets_2_STR_ONLY");
11828 msg31.setData(b31);
11829 NavitGraphics.callback_handler.sendMessage(msg31);
11830 // ----------------------- streets only pref -------------------
11831 }
11832 else
11833 {
11834 // ----------------------- streets only pref -------------------
11835 // 59 -> enable
11836 // 60 -> disable
11837 Message msg31 = new Message();
11838 Bundle b31 = new Bundle();
11839 b31.putInt("Callback", 59);
11840 b31.putString("s", "polygons001");
11841 msg31.setData(b31);
11842 NavitGraphics.callback_handler.sendMessage(msg31);
11843
11844 msg31 = new Message();
11845 b31 = new Bundle();
11846 b31.putInt("Callback", 59);
11847 b31.putString("s", "polygons");
11848 msg31.setData(b31);
11849 NavitGraphics.callback_handler.sendMessage(msg31);
11850
11851 msg31 = new Message();
11852 b31 = new Bundle();
11853 b31.putInt("Callback", 59);
11854 b31.putString("s", "POI Symbols");
11855 msg31.setData(b31);
11856 NavitGraphics.callback_handler.sendMessage(msg31);
11857
11858 msg31 = new Message();
11859 b31 = new Bundle();
11860 b31.putInt("Callback", 59);
11861 b31.putString("s", "POI Labels");
11862 msg31.setData(b31);
11863 NavitGraphics.callback_handler.sendMessage(msg31);
11864
11865 msg31 = new Message();
11866 b31 = new Bundle();
11867 b31.putInt("Callback", 60);
11868 b31.putString("s", "Android-POI-Icons-full");
11869 msg31.setData(b31);
11870 NavitGraphics.callback_handler.sendMessage(msg31);
11871
11872 msg31 = new Message();
11873 b31 = new Bundle();
11874 b31.putInt("Callback", 60);
11875 b31.putString("s", "Android-POI-Labels-full");
11876 msg31.setData(b31);
11877 NavitGraphics.callback_handler.sendMessage(msg31);
11878
11879 msg31 = new Message();
11880 b31 = new Bundle();
11881 b31.putInt("Callback", 59);
11882 b31.putString("s", "streets");
11883 msg31.setData(b31);
11884 NavitGraphics.callback_handler.sendMessage(msg31);
11885
11886 msg31 = new Message();
11887 b31 = new Bundle();
11888 b31.putInt("Callback", 59);
11889 b31.putString("s", "streets_1");
11890 msg31.setData(b31);
11891 NavitGraphics.callback_handler.sendMessage(msg31);
11892
11893 msg31 = new Message();
11894 b31 = new Bundle();
11895 b31.putInt("Callback", 59);
11896 b31.putString("s", "streets_2");
11897 msg31.setData(b31);
11898 NavitGraphics.callback_handler.sendMessage(msg31);
11899
11900 msg31 = new Message();
11901 b31 = new Bundle();
11902 b31.putInt("Callback", 60);
11903 b31.putString("s", "streets_STR_ONLY");
11904 msg31.setData(b31);
11905 NavitGraphics.callback_handler.sendMessage(msg31);
11906
11907 msg31 = new Message();
11908 b31 = new Bundle();
11909 b31.putInt("Callback", 60);
11910 b31.putString("s", "streets_1_STR_ONLY");
11911 msg31.setData(b31);
11912 NavitGraphics.callback_handler.sendMessage(msg31);
11913
11914 msg31 = new Message();
11915 b31 = new Bundle();
11916 b31.putInt("Callback", 60);
11917 b31.putString("s", "streets_2_STR_ONLY");
11918 msg31.setData(b31);
11919 NavitGraphics.callback_handler.sendMessage(msg31);
11920 // ----------------------- streets only pref -------------------
11921 }
11922
11923 // ---------- set traffic factor for road speeds ------------
11924 try
11925 {
11926 Message msg_ss1 = new Message();
11927 Bundle b_ss1 = new Bundle();
11928 b_ss1.putInt("Callback", 106);
11929 b_ss1.putString("s", Integer.toString(p.PREF_traffic_speed_factor));
11930 msg_ss1.setData(b_ss1);
11931 NavitGraphics.callback_handler.sendMessage(msg_ss1);
11932 }
11933 catch (Exception e)
11934 {
11935 }
11936 // ---------- set traffic factor for road speeds ------------
11937
11938 // ------- PREF_show_poi_on_map ---------------------------------
11939 set_poi_layers();
11940 // ------- PREF_show_poi_on_map ---------------------------------
11941
11942 set_TurnRestrictions_layers();
11943
11944 // set vars for mapdir change (only really takes effect after restart!)
11945 getPrefs_mapdir();
11946
11947 if (need_recalc_route)
11948 {
11949 recalculate_route();
11950 need_recalc_route = false;
11951 }
11952
11953 }
11954
11955 @SuppressLint("NewApi")
11956 private static void getPrefs_mapdir()
11957 {
11958 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
11959
11960 // Get the xml/preferences.xml preferences
11961 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
11962 String default_sdcard_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/zanavi/maps/";
11963 String default_sdcard_dir_1 = default_sdcard_dir;
11964 System.out.println("DataStorageDir[s1]=" + default_sdcard_dir_1);
11965
11966 // check for Android KitKat 4.4 ---------------
11967 try
11968 {
11969 if (Integer.valueOf(android.os.Build.VERSION.SDK) > 18)
11970 {
11971 // use app private dir
11972 default_sdcard_dir = Navit.getBaseContext_.getExternalFilesDir(null).getAbsolutePath();
11973 }
11974 }
11975 catch (Exception e)
11976 {
11977 }
11978 // check for Android KitKat 4.4 ---------------
11979
11980 try
11981 {
11982 NavitDataStorageDirs = android.support.v4.content.ContextCompat.getExternalFilesDirs(Navit.getBaseContext_, null);
11983
11984 if (NavitDataStorageDirs.length > 0)
11985 {
11986 // use new method
11987 default_sdcard_dir = NavitDataStorageDirs[0].getAbsolutePath() + "/zanavi/maps/";
11988 System.out.println("DataStorageDir count=" + NavitDataStorageDirs.length);
11989
11990 for (int jj2 = 0; jj2 < NavitDataStorageDirs.length; jj2++)
11991 {
11992 if (NavitDataStorageDirs[jj2] != null)
11993 {
11994 System.out.println("DataStorageDir[" + jj2 + "]=" + NavitDataStorageDirs[jj2].getAbsolutePath() + "/zanavi/maps/");
11995 }
11996 }
11997 }
11998
11999 if (NavitDataStorageDirs.length == 1)
12000 {
12001 File tf = null;
12002 File[] NavitDataStorageDirs_ = new File[NavitDataStorageDirs.length + 1];
12003
12004 try
12005 {
12006 Map<String, File> externalLocations = ExternalStorage.getAllStorageLocations();
12007 // String sdCard__ = externalLocations.get(ExternalStorage.SD_CARD).getAbsolutePath();
12008 String externalSdCard__ = externalLocations.get(ExternalStorage.EXTERNAL_SD_CARD).getAbsolutePath();
12009 // System.out.println("DataStorageDir[sd]=" + sdCard__);
12010 System.out.println("DataStorageDir[external sd]=" + externalSdCard__);
12011
12012 for (int jj2 = 0; jj2 < NavitDataStorageDirs.length; jj2++)
12013 {
12014 if (NavitDataStorageDirs[jj2] == null)
12015 {
12016 NavitDataStorageDirs_[jj2] = null;
12017 }
12018 else
12019 {
12020 NavitDataStorageDirs_[jj2] = new File(NavitDataStorageDirs[jj2].getAbsolutePath() + "/zanavi/maps/");
12021 }
12022 }
12023
12024 tf = new File(externalLocations.get(ExternalStorage.EXTERNAL_SD_CARD).getAbsolutePath() + "/Android/data/com.zoffcc.applications.zanavi/files" + "/zanavi/maps/");
12025 }
12026 catch (Exception e)
12027 {
12028 tf = null;
12029 }
12030
12031 if (tf != null)
12032 {
12033 NavitDataStorageDirs_[NavitDataStorageDirs.length] = tf;
12034 NavitDataStorageDirs = null;
12035 NavitDataStorageDirs = NavitDataStorageDirs_;
12036 }
12037 }
12038
12039 }
12040 catch (Exception e)
12041 {
12042 System.out.println("DataStorageDir Ex002");
12043 e.printStackTrace();
12044 }
12045
12046 //Log.e("Navit", "old sdcard dir=" + NavitDataDirectory_Maps);
12047 //Log.e("Navit", "default sdcard dir=" + default_sdcard_dir);
12048 NavitDataDirectory_Maps = prefs.getString("map_directory", default_sdcard_dir + "/zanavi/maps/");
12049 String Navit_storage_directory_select = prefs.getString("storage_directory", "-1");
12050 int Navit_storage_directory_select_i = 0;
12051 try
12052 {
12053 Navit_storage_directory_select_i = Integer.parseInt(Navit_storage_directory_select);
12054 }
12055 catch (Exception e)
12056 {
12057
12058 }
12059 System.out.println("DataStorageDir[sel 1]=" + NavitDataDirectory_Maps);
12060 System.out.println("DataStorageDir[sel 2]=" + Navit_storage_directory_select);
12061
12062 if (Navit_storage_directory_select_i > 0)
12063 {
12064 NavitDataDirectory_Maps = NavitDataStorageDirs[Navit_storage_directory_select_i - 1].getAbsolutePath();
12065 }
12066 System.out.println("DataStorageDir[*in use*]=" + NavitDataDirectory_Maps);
12067
12068 // Navit_storage_directory_select:
12069 // -1 --> first run -> select best dir for user
12070 // 0 --> use custom directory
12071 // 1..n --> select default dir on SD Card number 1..n
12072
12073 // ** DEBUG ** set dir manually ** // NavitDataDirectory_Maps = default_sdcard_dir + "/zanavi/maps/";
12074 // ** DEBUG ** NavitDataDirectory_Maps = prefs.getString("navit_mapsdir", "/sdcard" + "/zanavi/maps/");
12075 //Log.e("Navit", "new sdcard dir=" + NavitDataDirectory_Maps);
12076
12077 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12078 }
12079
12080 static String sanity_check_maps_dir(String check_dir)
12081 {
12082 String ret = check_dir;
12083 ret = ret.replaceAll("\\n", ""); // newline -> ""
12084 ret = ret.replaceAll("\\r", ""); // return -> ""
12085 ret = ret.replaceAll("\\t", ""); // tab -> ""
12086 ret = ret.replaceAll(" ", ""); // space -> ""
12087 ret = ret.replaceAll("\"", ""); // \" -> ""
12088 ret = ret.replaceAll("'", ""); // \' -> ""
12089 ret = ret.replaceAll("\\\\", ""); // "\" -> ""
12090 if (!ret.endsWith("/"))
12091 {
12092 ret = ret + "/";
12093 }
12094 // System.out.println("sanity check:" + ret);
12095 return ret;
12096 }
12097
12098 private static void activatePrefs_mapdir(Boolean at_startup)
12099 {
12100 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12101
12102 // activate the new directory
12103 NavitDataDirectory_Maps = sanity_check_maps_dir(NavitDataDirectory_Maps);
12104 MAP_FILENAME_PATH = NavitDataDirectory_Maps;
12105 MAPMD5_FILENAME_PATH = NavitDataDirectory_Maps + "/../md5/";
12106 CFG_FILENAME_PATH = NavitDataDirectory_Maps + "/../";
12107 NAVIT_DATA_DEBUG_DIR = CFG_FILENAME_PATH + "../debug/";
12108
12109 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12110 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12111 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12112 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12113 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12114 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12115 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12116 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12117 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12118
12119 Handler h_temp = null;
12120 h_temp = NavitGraphics.callback_handler_s;
12121 //System.out.println("handler 1=" + h_temp.toString());
12122
12123 Message msg1 = new Message();
12124 Bundle b1 = new Bundle();
12125 b1.putInt("Callback", 47);
12126 b1.putString("s", MAP_FILENAME_PATH);
12127 msg1.setData(b1);
12128 h_temp.sendMessage(msg1);
12129
12130 if (!at_startup)
12131 {
12132 Message msg2 = new Message();
12133 Bundle b2 = new Bundle();
12134 b2.putInt("Callback", 18);
12135 msg2.setData(b2);
12136 h_temp.sendMessage(msg2);
12137 }
12138
12139 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12140 }
12141
12142 private void getPrefs_theme()
12143 {
12144 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
12145 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
12146 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
12147 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
12148 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
12149 if (theme_tmp == 1)
12150 {
12151 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_LIGHT;
12152 }
12153 else
12154 {
12155 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
12156 }
12157
12158 }
12159
12160 private void getPrefs_theme_main()
12161 {
12162 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
12163 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
12164 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
12165 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
12166 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
12167 if (theme_tmp == 1)
12168 {
12169 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_LIGHT_M;
12170 }
12171 else
12172 {
12173 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
12174 }
12175
12176 }
12177
12178 private static void getPrefs_loc()
12179 {
12180 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12181
12182 // Get the xml/preferences.xml preferences
12183 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
12184 p.PREF_navit_lang = prefs.getString("navit_lang", "*DEFAULT*");
12185 System.out.println("**** ***** **** pref lang=" + p.PREF_navit_lang);
12186
12187 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12188 }
12189
12190 private static void activatePrefs_loc()
12191 {
12192 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12193
12194 // creating locale
12195 if (!p.PREF_navit_lang.equals("*DEFAULT*"))
12196 {
12197 Locale locale2 = null;
12198 if (p.PREF_navit_lang.contains("_"))
12199 {
12200 String _lang = p.PREF_navit_lang.split("_", 2)[0];
12201 String _country = p.PREF_navit_lang.split("_", 2)[1];
12202 System.out.println("l=" + _lang + " c=" + _country);
12203 locale2 = new Locale(_lang, _country);
12204 }
12205 else
12206 {
12207 locale2 = new Locale(p.PREF_navit_lang);
12208 }
12209 Locale.setDefault(locale2);
12210 Configuration config2 = new Configuration();
12211 config2.locale = locale2;
12212 // updating locale
12213 getBaseContext_.getResources().updateConfiguration(config2, null);
12214 }
12215
12216 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12217 }
12218
12219 private static void getPrefs_mapcache()
12220 {
12221 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
12222 try
12223 {
12224 p.PREF_mapcache = Integer.parseInt(prefs.getString("mapcache", "" + (10 * 1024)));
12225 }
12226 catch (Exception e)
12227 {
12228 e.printStackTrace();
12229 p.PREF_mapcache = 10 * 1024;
12230 }
12231 System.out.println("**** ***** **** pref mapcache=" + p.PREF_mapcache);
12232 }
12233
12234 private static void activatePrefs_mapcache()
12235 {
12236 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12237
12238 Handler h_temp2 = null;
12239 h_temp2 = NavitGraphics.callback_handler_s;
12240 System.out.println("activatePrefs_mapcache " + NavitGraphics.callback_handler_s);
12241 Message msg7 = new Message();
12242 Bundle b7 = new Bundle();
12243 b7.putInt("Callback", 55);
12244 b7.putString("s", String.valueOf(p.PREF_mapcache * 1024));
12245 msg7.setData(b7);
12246 h_temp2.sendMessage(msg7);
12247
12248 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12249 }
12250
12251 public native void NavitMain(Navit x, String lang, int version, String display_density_string, String n_datadir, String n_sharedir, Bitmap main_map_bitmap);
12252
12253 public native void NavitActivity(int activity);
12254
12255 /*
12256 * this is used to load the 'navit' native library on
12257 * application startup. The library has already been unpacked at
12258 * installation time by the package manager.
12259 */
12260 static
12261 {
12262 System.loadLibrary("navit");
12263 }
12264
12265 /*
12266 * Show a search activity with the string "search" filled in
12267 */
12268 private void executeSearch(String search)
12269 {
12270 Navit.use_index_search = Navit.allow_use_index_search();
12271 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
12272 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
12273 search_intent.putExtra("address_string", search);
12274 search_intent.putExtra("type", "offline");
12275 search_intent.putExtra("search_country_id", Navit_last_address_search_country_id);
12276 String pm_temp = "0";
12277 if (Navit_last_address_partial_match)
12278 {
12279 pm_temp = "1";
12280 }
12281 search_intent.putExtra("partial_match", pm_temp);
12282 this.startActivityForResult(search_intent, NavitAddressSearch_id_offline);
12283 }
12284
12285 private void share_location(String lat, String lon, String name, String subject_text, String time_at_destination, boolean is_dest)
12286 {
12287 Intent intent = new Intent(Intent.ACTION_SEND);
12288 intent.setType("text/plain");
12289 String url;
12290 final String map_zoomlevel = "18";
12291 // url = "" + lat + "," + lon + "\n" + name;
12292 url = "http://maps.google.com/?q=" + lat + "," + lon + "&z=" + map_zoomlevel + "\n\n" + name;
12293
12294 if (is_dest)
12295 {
12296 if (time_at_destination.compareTo("") != 0)
12297 {
12298 url = url + " " + time_at_destination;
12299 }
12300 }
12301
12302 intent.putExtra(Intent.EXTRA_TEXT, url);
12303 intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject_text);
12304 //Uri uri = Uri.parse("geo:0,0?z=16&q=" + lat + "," + lon);
12305 //intent.putExtra(Intent.EXTRA_STREAM, uri);
12306
12307 // shut down TTS ---------------
12308 // if (!Navit.is_navigating)
12309 // {
12310 // try
12311 // {
12312 // mTts.stop();
12313 // }
12314 // catch (Exception e)
12315 // {
12316 //
12317 // }
12318 //
12319 // try
12320 // {
12321 // mTts.shutdown();
12322 // }
12323 // catch (Exception e)
12324 // {
12325 //
12326 // }
12327 // }
12328 // shut down TTS ---------------
12329
12330 startActivityForResult(Intent.createChooser(intent, Navit.get_text("Share")), NavitAddressSearch_id_sharedest); // TRANS
12331 }
12332
12333 /*
12334 * open google maps at a given coordinate
12335 */
12336 private void googlemaps_show(String lat, String lon, String name)
12337 {
12338 // geo:latitude,longitude
12339 String url = null;
12340 Intent gmaps_intent = new Intent(Intent.ACTION_VIEW);
12341
12342 //url = "geo:" + lat + "," + lon + "?z=" + "16";
12343 //url = "geo:0,0?q=" + lat + "," + lon + " (" + name + ")";
12344 url = "geo:0,0?z=16&q=" + lat + "," + lon + " (" + name + ")";
12345
12346 gmaps_intent.setData(Uri.parse(url));
12347 this.startActivityForResult(gmaps_intent, NavitAddressSearch_id_gmaps);
12348 }
12349
12350 public void zoom_out_full()
12351 {
12352 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12353
12354 System.out.println("");
12355 System.out.println("*** Zoom out FULL ***");
12356 System.out.println("");
12357 Message msg = new Message();
12358 Bundle b = new Bundle();
12359 b.putInt("Callback", 8);
12360 msg.setData(b);
12361 NavitGraphics.callback_handler.sendMessage(msg);
12362
12363 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12364 }
12365
12366 static public void show_geo_on_screen_with_zoom_and_delay(float lat, float lon)
12367 {
12368 show_geo_on_screen_with_zoom_and_delay(lat, lon, 0);
12369 }
12370
12371 @SuppressLint("NewApi")
12372 static public void show_geo_on_screen_with_zoom_and_delay(final float lat, final float lon, final int millis_start_delay)
12373 {
12374 System.out.println("XSOM:010");
12375
12376 // if (api_version_int < 11)
12377 // {
12378 //
12379 // new AsyncTask<Void, Void, String>()
12380 // {
12381 // @Override
12382 // protected String doInBackground(Void... params)
12383 // {
12384 // System.out.println("XSOM:011");
12385 //
12386 // try
12387 // {
12388 // System.out.println("XSOM:001");
12389 // Thread.sleep((long) millis_start_delay);
12390 // Navit.show_geo_on_screen_no_draw(lat, lon);
12391 // System.out.println("XSOM:002");
12392 // Thread.sleep(100);
12393 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12394 // System.out.println("XSOM:004");
12395 // Thread.sleep(120);
12396 // Navit.draw_map();
12397 // System.out.println("XSOM:005");
12398 // }
12399 // catch (Exception e)
12400 // {
12401 // }
12402 //
12403 // return "";
12404 // }
12405 //
12406 // @Override
12407 // protected void onPostExecute(String msg)
12408 // {
12409 //
12410 // }
12411 // }.execute(null, null, null);
12412 //
12413 // }
12414 // else
12415 // {
12416 // new AsyncTask<Void, Void, String>()
12417 // {
12418 // @Override
12419 // protected String doInBackground(Void... params)
12420 // {
12421 // System.out.println("XSOM:011");
12422 //
12423 // try
12424 // {
12425 // System.out.println("XSOM:001");
12426 // Thread.sleep((long) millis_start_delay);
12427 // Navit.show_geo_on_screen_no_draw(lat, lon);
12428 // System.out.println("XSOM:002");
12429 // Thread.sleep(100);
12430 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12431 // System.out.println("XSOM:004");
12432 // Thread.sleep(120);
12433 // Navit.draw_map();
12434 // System.out.println("XSOM:005");
12435 // }
12436 // catch (Exception e)
12437 // {
12438 // }
12439 //
12440 // return "";
12441 // }
12442 //
12443 // @Override
12444 // protected void onPostExecute(String msg)
12445 // {
12446 //
12447 // }
12448 // }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
12449 //
12450 // }
12451
12452 final Thread temp_work_thread = new Thread()
12453 {
12454 @Override
12455 public void run()
12456 {
12457 try
12458 {
12459 Thread.sleep((long) millis_start_delay);
12460 Navit.show_geo_on_screen_no_draw(lat, lon);
12461 Thread.sleep(500);
12462 Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12463 Thread.sleep(120);
12464 Navit.draw_map();
12465 }
12466 catch (Exception e2)
12467 {
12468 e2.printStackTrace();
12469 }
12470 }
12471 };
12472 temp_work_thread.start();
12473 }
12474
12475 static public void show_geo_on_screen(float lat, float lng)
12476 {
12477 // this function sets screen center to "lat, lon", and just returns a dummy string!
12478 Navit.cwthr.CallbackGeoCalc2(2, 3, lat, lng);
12479 }
12480
12481 static public void show_geo_on_screen_no_draw(float lat, float lng)
12482 {
12483 // this function sets screen center to "lat, lon", and just returns a dummy string!
12484 Navit.cwthr.CallbackGeoCalc2(2, 15, lat, lng);
12485 }
12486
12487 public static void zoom_to_route()
12488 {
12489 try
12490 {
12491 //System.out.println("");
12492 //System.out.println("*** Zoom to ROUTE ***");
12493 //System.out.println("");
12494 Message msg = new Message();
12495 Bundle b = new Bundle();
12496 b.putInt("Callback", 17);
12497 msg.setData(b);
12498 NavitGraphics.callback_handler.sendMessage(msg);
12499
12500 set_map_position_to_screen_center();
12501 }
12502 catch (Exception e)
12503 {
12504 }
12505 }
12506
12507 static void set_map_position_to_screen_center()
12508 {
12509 try
12510 {
12511 Message msg = new Message();
12512 Bundle b = new Bundle();
12513 b.putInt("Callback", 51);
12514
12515 if (Navit.GFX_OVERSPILL)
12516 {
12517 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
12518 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
12519 }
12520 else
12521 {
12522 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
12523 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
12524 }
12525 msg.setData(b);
12526 NavitGraphics.callback_handler.sendMessage(msg);
12527 }
12528 catch (Exception e)
12529 {
12530 }
12531 }
12532
12533 public void turn_on_compass()
12534 {
12535 try
12536 {
12537 if (!p.PREF_use_compass_heading_fast)
12538
12539 {
12540 // Slower
12541 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL);
12542 }
12543 else
12544 {
12545 // FAST
12546 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI);
12547 }
12548 }
12549 catch (Exception e)
12550 {
12551 e.printStackTrace();
12552 }
12553 }
12554
12555 public void turn_off_compass()
12556 {
12557 try
12558 {
12559 sensorManager.unregisterListener(this);
12560 }
12561 catch (Exception e)
12562 {
12563 e.printStackTrace();
12564 }
12565 }
12566
12567 public void onSensorChanged(SensorEvent event)
12568 {
12569
12570 if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD)
12571 {
12572 // System.out.println("Sensor.TYPE_MAGNETIC_FIELD");
12573 return;
12574 }
12575
12576 if (event.sensor.getType() == Sensor.TYPE_ORIENTATION)
12577 {
12578 // System.out.println("Sensor.TYPE_ORIENTATION");
12579
12580 // compass
12581 float myAzimuth = event.values[0];
12582 // double myPitch = event.values[1];
12583 // double myRoll = event.values[2];
12584
12585 //String out = String.format("Azimuth: %.2f", myAzimuth);
12586 //System.out.println("compass: " + out);
12587 NavitVehicle.update_compass_heading(myAzimuth);
12588 }
12589 }
12590
12591 public void onAccuracyChanged(Sensor sensor, int accuracy)
12592 {
12593 // compass
12594 }
12595
12596 public void hide_status_bar()
12597 {
12598 if (!p.PREF_show_status_bar)
12599 {
12600 // Hide the Status Bar
12601 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN);
12602 }
12603 }
12604
12605 public void show_status_bar()
12606 {
12607 // Show the Status Bar
12608 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN);
12609 }
12610
12611 public void hide_title_bar()
12612 {
12613 // -- unsued !!!! --
12614 // -- unsued !!!! --
12615 // -- unsued !!!! --
12616
12617 // Hide the Title Bar - this works ONLY before setcontent in onCreate!!
12618 requestWindowFeature(Window.FEATURE_NO_TITLE);
12619 }
12620
12621 public void show_title_bar()
12622 {
12623 // -- unsued !!!! --
12624 // -- unsued !!!! --
12625 // -- unsued !!!! --
12626
12627 // Hide the Title Bar - this works ONLY before setcontent in onCreate!!
12628 // ?? requestWindowFeature(Window.);
12629 }
12630
12631 public static Boolean downloadGPSXtra(Context context)
12632 {
12633 Boolean ret = false;
12634 Boolean ret2 = false;
12635 try
12636 {
12637 LocationManager locationmanager2 = (LocationManager) context.getSystemService("location");
12638 Bundle bundle = new Bundle();
12639 //ret2 = locationmanager2.sendExtraCommand("gps", "delete_aiding_data", null);
12640 //ret = ret2;
12641 // System.out.println("ret0=" + ret);
12642 ret2 = locationmanager2.sendExtraCommand("gps", "force_xtra_injection", bundle);
12643 ret = ret2;
12644 //System.out.println("ret1=" + ret2);
12645 ret2 = locationmanager2.sendExtraCommand("gps", "force_time_injection", bundle);
12646 ret = ret || ret2;
12647 //System.out.println("ret2=" + ret2);
12648 }
12649 catch (Exception e)
12650 {
12651 //System.out.println("*XX*");
12652 e.printStackTrace();
12653 }
12654 return ret;
12655 }
12656
12657 static void remove_oldest_normal_point()
12658 {
12659 int i;
12660 for (i = 0; i < map_points.size(); i++)
12661 {
12662 Navit_Point_on_Map element_temp = map_points.get(i);
12663 if (element_temp.addon == null)
12664 {
12665 // its a normal (non home, non special item), so can remove it, and return.
12666 break;
12667 }
12668 }
12669 }
12670
12671 static int find_home_point()
12672 {
12673 int home_id = -1;
12674 int i;
12675
12676 for (i = 0; i < map_points.size(); i++)
12677 {
12678 Navit_Point_on_Map element_temp = map_points.get(i);
12679 if (element_temp.addon != null)
12680 {
12681 if (element_temp.addon.equals("1"))
12682 {
12683 // found home
12684 return i;
12685 }
12686 }
12687 }
12688 return home_id;
12689 }
12690
12691 static void readd_home_point()
12692 {
12693 try
12694 {
12695 int home_id = find_home_point();
12696 if (home_id != -1)
12697 {
12698 Navit_Point_on_Map element_old = map_points.get(home_id);
12699 map_points.remove(home_id);
12700 map_points.add(element_old);
12701 }
12702 }
12703 catch (Exception e)
12704 {
12705 }
12706 }
12707
12708 static void add_map_point(Navit_Point_on_Map element)
12709 {
12710 if (element == null)
12711 {
12712 return;
12713 }
12714
12715 if (map_points == null)
12716 {
12717 map_points = new ArrayList<Navit_Point_on_Map>();
12718 }
12719
12720 int el_pos = get_destination_pos(element);
12721 // int home_id = find_home_point();
12722 boolean is_home = is_home_element(element);
12723
12724 // System.out.println("EEPOS:el_pos=" + el_pos + " is_home=" + is_home);
12725
12726 if (is_home)
12727 {
12728 // its the "home" destination
12729 return;
12730 }
12731
12732 if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
12733 {
12734 try
12735 {
12736 // map_points.remove(0);
12737 remove_oldest_normal_point();
12738 }
12739 catch (Exception e)
12740 {
12741 }
12742 }
12743
12744 if (el_pos == -1)
12745 {
12746 // if not duplicate, then add
12747 map_points.add(element);
12748 readd_home_point();
12749 write_map_points();
12750 }
12751 else
12752 {
12753 try
12754 {
12755 // if already in list, then first remove and add again
12756 // that moves it to the top of the list
12757 Navit_Point_on_Map element_old = map_points.get(el_pos);
12758 map_points.remove(el_pos);
12759 map_points.add(element_old);
12760 readd_home_point();
12761 write_map_points();
12762 }
12763 catch (Exception e)
12764 {
12765 e.printStackTrace();
12766 }
12767 }
12768 }
12769
12770 void read_map_points()
12771 {
12772 deserialize_map_points();
12773 }
12774
12775 static void write_map_points()
12776 {
12777 if (map_points != null)
12778 {
12779 serialize_map_points();
12780 }
12781 }
12782
12783 private static void serialize_map_points()
12784 {
12785 FileOutputStream fos;
12786 try
12787 {
12788 fos = new FileOutputStream(NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME);
12789 // openFileOutput(CFG_FILENAME_PATH + Navit_DEST_FILENAME, Context.MODE_PRIVATE);
12790 ObjectOutputStream oos = new ObjectOutputStream(fos);
12791 oos.writeObject(map_points);
12792 oos.close();
12793 }
12794 catch (FileNotFoundException e)
12795 {
12796 e.printStackTrace();
12797 }
12798 catch (IOException e)
12799 {
12800 e.printStackTrace();
12801 }
12802 catch (Exception e)
12803 {
12804 e.printStackTrace();
12805 }
12806 }
12807
12808 private void export_map_points_to_sdcard()
12809 {
12810 String orig_file = NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME;
12811 String dest_file_dir = CFG_FILENAME_PATH + "../export/";
12812
12813 try
12814 {
12815 File dir = new File(dest_file_dir);
12816 dir.mkdirs();
12817 }
12818 catch (Exception e)
12819 {
12820 e.printStackTrace();
12821 }
12822
12823 try
12824 {
12825 File source = new File(orig_file);
12826 File destination = new File(dest_file_dir + Navit_DEST_FILENAME);
12827
12828 if (source.exists())
12829 {
12830 FileInputStream fi = new FileInputStream(source);
12831 FileOutputStream fo = new FileOutputStream(destination);
12832 FileChannel src = fi.getChannel();
12833 FileChannel dst = fo.getChannel();
12834 dst.transferFrom(src, 0, src.size());
12835 src.close();
12836 dst.close();
12837 fi.close();
12838 fo.close();
12839 }
12840 }
12841 catch (Exception e)
12842 {
12843 e.printStackTrace();
12844 }
12845 }
12846
12847 private void import_map_points_from_sdcard()
12848 {
12849 String orig_file = NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME;
12850 String dest_file_dir = CFG_FILENAME_PATH + "../export/";
12851
12852 try
12853 {
12854 File source = new File(dest_file_dir + Navit_DEST_FILENAME);
12855 File destination = new File(orig_file);
12856
12857 if (source.exists())
12858 {
12859 FileInputStream fi = new FileInputStream(source);
12860 FileOutputStream fo = new FileOutputStream(destination);
12861 FileChannel src = fi.getChannel();
12862 FileChannel dst = fo.getChannel();
12863 dst.transferFrom(src, 0, src.size());
12864 src.close();
12865 dst.close();
12866 fi.close();
12867 fo.close();
12868 }
12869 }
12870 catch (Exception e)
12871 {
12872 e.printStackTrace();
12873 }
12874
12875 read_map_points();
12876 }
12877
12878 //@SuppressWarnings("unchecked")
12879 private void deserialize_map_points()
12880 {
12881 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12882
12883 FileInputStream fis = null;
12884 ObjectInputStream ois = null;
12885
12886 try
12887 {
12888 fis = new FileInputStream(NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME);
12889 // openFileInput(CFG_FILENAME_PATH + Navit_DEST_FILENAME);
12890 ois = new ObjectInputStream(fis);
12891 map_points = (ArrayList<Navit_Point_on_Map>) ois.readObject();
12892 }
12893 catch (FileNotFoundException e)
12894 {
12895 e.printStackTrace();
12896 map_points = new ArrayList<Navit_Point_on_Map>();
12897 }
12898 catch (IOException e)
12899 {
12900 e.printStackTrace();
12901 map_points = new ArrayList<Navit_Point_on_Map>();
12902 }
12903 catch (ClassNotFoundException e)
12904 {
12905 e.printStackTrace();
12906 map_points = new ArrayList<Navit_Point_on_Map>();
12907 }
12908 catch (Exception e)
12909 {
12910 e.printStackTrace();
12911 map_points = new ArrayList<Navit_Point_on_Map>();
12912 }
12913
12914 try
12915 {
12916 if (ois != null)
12917 {
12918 ois.close();
12919 }
12920 }
12921 catch (Exception e)
12922 {
12923 }
12924
12925 try
12926 {
12927 if (fis != null)
12928 {
12929 ois.close();
12930 }
12931 }
12932 catch (Exception e)
12933 {
12934 }
12935
12936 // for (int j = 0; j < map_points.size(); j++)
12937 // {
12938 // System.out.println("####******************" + j + ":" + map_points.get(j).point_name);
12939 // }
12940
12941 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12942
12943 }
12944
12945 static void remember_destination_xy(String name, int x, int y)
12946 {
12947 // i=1 -> pixel a,b (x,y) -> geo string "lat(float):lng(float)"
12948 // i=2 -> geo a,b (lat,lng) -> pixel string "x(int):y(int)"
12949 String lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
12950 try
12951 {
12952 String tmp[] = lat_lon.split(":", 2);
12953 //System.out.println("tmp=" + lat_lon);
12954 float lat = Float.parseFloat(tmp[0]);
12955 float lon = Float.parseFloat(tmp[1]);
12956 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
12957 remember_destination(name, lat, lon);
12958 }
12959 catch (Exception e)
12960 {
12961 e.printStackTrace();
12962
12963 }
12964 }
12965
12966 static void remember_destination(String name, String lat, String lon)
12967 {
12968 try
12969 {
12970 //System.out.println("22 **## " + name + " " + lat + " " + lon + " ##**");
12971 remember_destination(name, Float.parseFloat(lat), Float.parseFloat(lon));
12972 }
12973 catch (Exception e)
12974 {
12975 e.printStackTrace();
12976 }
12977 }
12978
12979 static void remember_destination(String name, float lat, float lon)
12980 {
12981 //System.out.println("11 **## " + name + " " + lat + " " + lon + " ##**");
12982 Navit_Point_on_Map t = new Navit_Point_on_Map();
12983 t.point_name = name;
12984 t.lat = lat;
12985 t.lon = lon;
12986 add_map_point(t);
12987 }
12988
12989 static void destination_set()
12990 {
12991 // status = "destination set"
12992 NavitGraphics.navit_route_status = 1;
12993 }
12994
12995 static Boolean check_dup_destination(Navit_Point_on_Map element)
12996 {
12997 Boolean ret = false;
12998 Navit_Point_on_Map t;
12999 for (int i = 0; i < map_points.size(); i++)
13000 {
13001 t = map_points.get(i);
13002 if (t.addon == null)
13003 {
13004 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
13005 {
13006 return true;
13007 }
13008 }
13009 else
13010 {
13011 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
13012 {
13013 return true;
13014 }
13015 }
13016 }
13017 return ret;
13018 }
13019
13020 static int get_destination_pos(Navit_Point_on_Map element)
13021 {
13022 int ret = -1;
13023 Navit_Point_on_Map t;
13024 for (int i = 0; i < map_points.size(); i++)
13025 {
13026 t = map_points.get(i);
13027 if (t.addon == null)
13028 {
13029 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
13030 {
13031 return i;
13032 }
13033 }
13034 else
13035 {
13036 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
13037 {
13038 return i;
13039 }
13040 }
13041 }
13042 return ret;
13043 }
13044
13045 static boolean is_home_element(Navit_Point_on_Map element)
13046 {
13047 int home_id = find_home_point();
13048 if (home_id != -1)
13049 {
13050 Navit_Point_on_Map home_element = map_points.get(home_id);
13051
13052 if ((home_element.point_name.equals(element.point_name)) && (home_element.lat == element.lat) && (home_element.lon == element.lon))
13053 {
13054 return true;
13055 }
13056
13057 }
13058
13059 return false;
13060 }
13061
13062 static NavitSpeech2 get_speech_object()
13063 {
13064 System.out.println("get_speech_object");
13065 return NSp;
13066 }
13067
13068 static NavitVehicle get_vehicle_object()
13069 {
13070 System.out.println("get_vehicle_object");
13071 return NV;
13072 }
13073
13074 static NavitGraphics get_graphics_object_by_name(String name)
13075 {
13076 System.out.println("get_graphics_object_by_name:*" + name + "*");
13077
13078 if (name.equals("type:map-main"))
13079 {
13080 System.out.println("map-main");
13081 return NG__map_main;
13082 }
13083 else
13084 {
13085 System.out.println("vehicle");
13086 return NG__vehicle;
13087 }
13088 }
13089
13090 public static Handler vehicle_handler = new Handler()
13091 {
13092 public void handleMessage(Message msg)
13093 {
13094 //System.out.println("vehicle_handler:handleMessage:JTHREAD ID=" + Thread.currentThread().getId());
13095 //System.out.println("vehicle_handler:handleMessage:THREAD ID=" + NavitGraphics.GetThreadId());
13096
13097 switch (msg.what)
13098 {
13099 case 1:
13100 Location l = new Location("Network");
13101 l.setLatitude(msg.getData().getFloat("lat"));
13102 l.setLongitude(msg.getData().getFloat("lng"));
13103 l.setBearing(msg.getData().getFloat("b"));
13104 l.setSpeed(0.8f);
13105 NavitVehicle.set_mock_location__fast(l);
13106 break;
13107 case 2:
13108 if (NavitVehicle.update_location_in_progress)
13109 {
13110 }
13111 else
13112 {
13113 NavitVehicle.update_location_in_progress = true;
13114 NavitVehicle.VehicleCallback2(NavitVehicle.last_location);
13115 NavitVehicle.update_location_in_progress = false;
13116 }
13117 break;
13118 }
13119 }
13120 };
13121
13122 public String roundTwoDecimals(double d)
13123 {
13124 return String.format(Locale.US, "%.2f", d);
13125 }
13126
13127 /* ZZ GEO TRANS ZZ */
13128 static double __EARTH_RADIUS__ = 6378137.000;
13129 static double __GEO_ACCURACY_FACTOR__ = 2.000;
13130 final static double M_PI_div_360 = 0.008726646259971647884618;
13131 final static double M_PI_div_180 = 0.01745329251994329576;
13132 final static double M_PI_mul_360 = 1130.97335529232556584560;
13133 final static double M_PI_mul_180 = 565.48667764616278292280;
13134
13135 /* ZZ GEO TRANS ZZ */
13136
13137 public static int transform_from_geo_lat(double lat)
13138 {
13139 /* ZZ GEO TRANS ZZ */
13140 int ret = (int) ((Math.log(Math.tan((Math.PI / 4f) + lat * M_PI_div_360)) * __EARTH_RADIUS__) * __GEO_ACCURACY_FACTOR__);
13141 return ret;
13142 }
13143
13144 public static int transform_from_geo_lon(double lon)
13145 {
13146 /* ZZ GEO TRANS ZZ */
13147 int ret = (int) ((lon * __EARTH_RADIUS__ * M_PI_div_180) * __GEO_ACCURACY_FACTOR__);
13148
13149 return ret;
13150 }
13151
13152 public static double transform_to_geo_lat(float y) // y
13153 {
13154 /* ZZ GEO TRANS ZZ */
13155 return (Math.atan(Math.exp((y / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__)) / M_PI_div_360 - 90);
13156 }
13157
13158 public static double transform_to_geo_lon(float x) // x
13159 {
13160 /* ZZ GEO TRANS ZZ */
13161 return ((x / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__ / M_PI_div_180);
13162 }
13163
13164 public static boolean allow_use_index_search()
13165 {
13166 if ((!Navit_DonateVersion_Installed) && (!Navit_Largemap_DonateVersion_Installed))
13167 {
13168 // no donate version installed
13169 Log.e("Navit", "no donate version installed");
13170
13171 Navit_index_on_but_no_idx_files = false;
13172 return false;
13173 }
13174
13175 boolean ret = false;
13176
13177 // MAP_FILENAME_PATH
13178 File folder = new File(MAP_FILENAME_PATH);
13179 File[] listOfFiles = folder.listFiles();
13180 File idx = null;
13181 File md5_file = null;
13182 FileOutputStream fos = null;
13183
13184 int files = 0;
13185 int file_without_index = 0;
13186
13187 for (File file : listOfFiles)
13188 {
13189 if (file.isFile())
13190 {
13191 // System.out.println("FFNN:" + file.getName());
13192
13193 if (file.getName().endsWith(".bin"))
13194 {
13195 if (!file.getName().equals("borders.bin"))
13196 {
13197 if (!file.getName().equals("coastline.bin"))
13198 {
13199 files++;
13200 idx = new File(folder, file.getName() + ".idx");
13201 if (idx.exists())
13202 {
13203 }
13204 else
13205 {
13206 file_without_index++;
13207
13208 String servername = "";
13209 try
13210 {
13211 servername = NavitMapDownloader.is_in_cat_file_disk_name(file.getName()).split(":", 2)[1];
13212 }
13213 catch (Exception ee)
13214 {
13215 }
13216
13217 if (!servername.equals(""))
13218 {
13219
13220 // index for this map is missing. hack MD5 file so we can download it again
13221 md5_file = new File(Navit.MAPMD5_FILENAME_PATH + "/" + servername + ".md5");
13222
13223 // System.out.println("FFNN:hack MD5:" + md5_file.getAbsolutePath() + " s=" + servername);
13224
13225 if ((md5_file.exists()) && (md5_file.canWrite()))
13226 {
13227 try
13228 {
13229 fos = new FileOutputStream(md5_file);
13230 fos.write(65);
13231 fos.write(65);
13232 fos.write(65);
13233 fos.close();
13234 }
13235 catch (Exception e1)
13236 {
13237 // System.out.println("FFNN:EEEEEEEEEEEEEE");
13238 }
13239 }
13240 }
13241 }
13242 }
13243 }
13244 }
13245
13246 if (file.getName().endsWith(".bin.idx"))
13247 {
13248 ret = true;
13249 }
13250 }
13251 }
13252
13253 if (files > 0)
13254 {
13255 if (file_without_index > 0)
13256 {
13257 Navit_index_on_but_no_idx_files = true;
13258 }
13259 else
13260 {
13261 Navit_index_on_but_no_idx_files = false;
13262 }
13263 }
13264
13265 return ret;
13266 }
13267
13268 private void sendEmail(String recipient, String subject, String message)
13269 {
13270 try
13271 {
13272 final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
13273 emailIntent.setType("plain/text");
13274 if (recipient != null) emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { recipient });
13275 if (subject != null) emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
13276 if (message != null) emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
13277
13278 startActivity(Intent.createChooser(emailIntent, Navit.get_text("Send feedback via email ...")));
13279
13280 }
13281 catch (ActivityNotFoundException e)
13282 {
13283 // cannot send email for some reason
13284 }
13285 }
13286
13287 @SuppressLint("NewApi")
13288 void detect_menu_button()
13289 {
13290 // default: we dont have a real menu button
13291 has_hw_menu_button = false;
13292
13293 try
13294 {
13295 if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 14)
13296 {
13297 if (ViewConfiguration.get(getApplicationContext()).hasPermanentMenuKey())
13298 {
13299 has_hw_menu_button = true;
13300 }
13301 else
13302 {
13303 has_hw_menu_button = false;
13304 }
13305 }
13306 else
13307 {
13308 has_hw_menu_button = true;
13309 }
13310 }
13311 catch (Exception e)
13312 {
13313 // on error we must be on android API < 14 and therfore we have a menu button (that is what we assume)
13314 has_hw_menu_button = true;
13315 }
13316
13317 // now always show menu button icon
13318 has_hw_menu_button = false;
13319 }
13320
13321 public void onBackPressed()
13322 {
13323 // do something on back.
13324 //System.out.println("no back key!");
13325 // super.onBackPressed();
13326 // !!disable the back key otherwise!!
13327
13328 if (Navit_doubleBackToExitPressedOnce)
13329 {
13330
13331 try
13332 {
13333 if (wl_navigating != null)
13334 {
13335 //if (wl_navigating.isHeld())
13336 //{
13337 wl_navigating.release();
13338 Log.e("Navit", "WakeLock Nav: release 1");
13339 //}
13340 }
13341 }
13342 catch (Exception e)
13343 {
13344 e.printStackTrace();
13345 }
13346
13347 // super.onBackPressed(); --> this would only put the app in background
13348 // --------
13349 // exit the app here
13350 this.onPause();
13351 this.onStop();
13352 this.exit();
13353 // --------
13354 return;
13355 }
13356
13357 try
13358 {
13359 Navit_doubleBackToExitPressedOnce = true;
13360 Toast.makeText(this, Navit.get_text("Please press BACK again to Exit"), Toast.LENGTH_SHORT).show();
13361
13362 new Handler().postDelayed(new Runnable()
13363 {
13364 @Override
13365 public void run()
13366 {
13367 Navit_doubleBackToExitPressedOnce = false;
13368 }
13369 }, NAVIT_BACKBUTTON_TO_EXIT_TIME);
13370 }
13371 catch (Exception e)
13372 {
13373 }
13374
13375 try
13376 {
13377 // if bottom bar is up, animate it down on "back" press
13378 animate_bottom_bar_down();
13379 }
13380 catch (Exception e)
13381 {
13382 }
13383
13384 }
13385
13386 // public void openOptionsMenu_wrapper()
13387 // {
13388 // //openOptionsMenu();
13389 //
13390 // prepare_emu_options_menu();
13391 // NavitGraphics.emu_menu_view.set_adapter(EmulatedMenuView.MenuItemsList2, EmulatedMenuView.MenuItemsIdMapping2);
13392 // NavitGraphics.emu_menu_view.bringToFront();
13393 // NavitGraphics.emu_menu_view.setVisibility(View.VISIBLE);
13394 // }
13395
13396 public static String logHeap(Class clazz)
13397 {
13398 Double allocated = Double.valueOf(Debug.getNativeHeapAllocatedSize()) / Double.valueOf((1048576));
13399 Double sum_size = Double.valueOf(Debug.getNativeHeapSize() / Double.valueOf(1048576.0));
13400 Double free = Double.valueOf(Debug.getNativeHeapFreeSize() / Double.valueOf(1048576.0));
13401 DecimalFormat df = new DecimalFormat();
13402 df.setMaximumFractionDigits(2);
13403 df.setMinimumFractionDigits(2);
13404
13405 // Log.d("Navit", "MemMem:DEBUG: =================================");
13406 Log.d("Navit", "MemMem:DEBUG:heap native: allc " + df.format(allocated) + "MB sum=" + df.format(sum_size) + "MB (" + df.format(free) + "MB free) in [" + clazz.getName().replaceAll("com.zoffcc.applications.zanavi.", "") + "]");
13407 Log.d("Navit", "MemMem:DEBUG:java memory: allc: " + df.format(Double.valueOf(Runtime.getRuntime().totalMemory() / 1048576)) + "MB sum=" + df.format(Double.valueOf(Runtime.getRuntime().maxMemory() / 1048576)) + "MB (" + df.format(Double.valueOf(Runtime.getRuntime().freeMemory() / 1048576)) + "MB free)");
13408
13409 calcAvailableMemory();
13410
13411 String mem_type = "NATIVE";
13412 try
13413 {
13414 if (android.os.Build.VERSION.SDK_INT >= 11)
13415 {
13416 mem_type = "JAVA";
13417 }
13418 }
13419 catch (Exception e)
13420 {
13421 }
13422 return ("" + df.format(allocated) + "/" + df.format(sum_size) + "(" + df.format(free) + ")" + ":" + df.format(Double.valueOf(Runtime.getRuntime().totalMemory() / 1048576)) + "/" + df.format(Double.valueOf(Runtime.getRuntime().maxMemory() / 1048576)) + "(" + df.format(Double.valueOf(Runtime.getRuntime().freeMemory() / 1048576)) + ") " + mem_type);
13423 }
13424
13425 public static String logHeap_for_batch(Class clazz)
13426 {
13427 try
13428 {
13429 Double allocated = Double.valueOf(Debug.getNativeHeapAllocatedSize()) / Double.valueOf((1048576));
13430 Double sum_size = Double.valueOf(Debug.getNativeHeapSize() / Double.valueOf(1048576.0));
13431 Double free = Double.valueOf(Debug.getNativeHeapFreeSize() / Double.valueOf(1048576.0));
13432 DecimalFormat df = new DecimalFormat();
13433 df.setMaximumFractionDigits(2);
13434 df.setMinimumFractionDigits(2);
13435
13436 // Log.d("Navit", "MemMem:DEBUG: =================================");
13437 Log.d("Navit", "MemMem:DEBUG:heap native: allc " + df.format(allocated) + "MB sum=" + df.format(sum_size) + "MB (" + df.format(free) + "MB free) in [" + clazz.getName().replaceAll("com.zoffcc.applications.zanavi.", "") + "]");
13438 Log.d("Navit", "MemMem:DEBUG:java memory: allc: " + df.format(Double.valueOf(Runtime.getRuntime().totalMemory() / 1048576)) + "MB sum=" + df.format(Double.valueOf(Runtime.getRuntime().maxMemory() / 1048576)) + "MB (" + df.format(Double.valueOf(Runtime.getRuntime().freeMemory() / 1048576)) + "MB free)");
13439
13440 // calcAvailableMemory();
13441
13442 String mem_type = "NATIVE";
13443 try
13444 {
13445 if (android.os.Build.VERSION.SDK_INT >= 11)
13446 {
13447 mem_type = "JAVA";
13448 }
13449 }
13450 catch (Exception e)
13451 {
13452 }
13453 // return ("" + df.format(allocated) + "/" + df.format(sum_size) + "(" + df.format(free) + ")" + ":" + df.format(Double.valueOf(Runtime.getRuntime().totalMemory() / 1048576)) + "/" + df.format(Double.valueOf(Runtime.getRuntime().maxMemory() / 1048576)) + "(" + df.format(Double.valueOf(Runtime.getRuntime().freeMemory() / 1048576)) + ") " + mem_type);
13454 return ("==MEM==:" + "J:" + (Double.valueOf(Runtime.getRuntime().totalMemory() / 1048576)) + ":" + (Double.valueOf(Runtime.getRuntime().maxMemory() / 1048576)) + ",N:" + allocated + ":" + sum_size);
13455 }
13456 catch (Exception e2)
13457 {
13458 return ("==MEM==:ERROR");
13459 }
13460 }
13461
13462 private static long calcAvailableMemory()
13463 {
13464 try
13465 {
13466 long value = Runtime.getRuntime().maxMemory();
13467 String type = "";
13468 if (android.os.Build.VERSION.SDK_INT >= 11)
13469 {
13470 value = (value / 1024 / 1024) - (Runtime.getRuntime().totalMemory() / 1024 / 1024);
13471 type = "JAVA";
13472 }
13473 else
13474 {
13475 value = (value / 1024 / 1024) - (Debug.getNativeHeapAllocatedSize() / 1024 / 1024);
13476 type = "NATIVE";
13477 }
13478 Log.i("Navit", "avail.mem size=" + value + "MB, type=" + type);
13479 return value;
13480 }
13481 catch (Exception e)
13482 {
13483 return 0L;
13484 }
13485 }
13486
13487 public void google_online_search_and_set_destination(String address_string)
13488 {
13489 // online googlemaps search
13490 // String addressInput = filter_bad_chars(address_string);
13491 String addressInput = address_string;
13492 try
13493 {
13494 List<Address> foundAdresses = Navit.Navit_Geocoder.getFromLocationName(addressInput, 1); //Search addresses
13495 //System.out.println("found " + foundAdresses.size() + " results");
13496 //System.out.println("addr=" + foundAdresses.get(0).getLatitude() + " " + foundAdresses.get(0).getLongitude() + "" + foundAdresses.get(0).getAddressLine(0));
13497
13498 int results_step = 0;
13499 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
13500 tmp_addr.result_type = "STR";
13501 tmp_addr.item_id = "0";
13502 tmp_addr.lat = (float) foundAdresses.get(results_step).getLatitude();
13503 tmp_addr.lon = (float) foundAdresses.get(results_step).getLongitude();
13504 tmp_addr.addr = "";
13505
13506 String c_code = foundAdresses.get(results_step).getCountryCode();
13507 if (c_code != null)
13508 {
13509 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getCountryCode() + ",";
13510 }
13511
13512 String p_code = foundAdresses.get(results_step).getPostalCode();
13513 if (p_code != null)
13514 {
13515 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getPostalCode() + " ";
13516 }
13517
13518 if (foundAdresses.get(results_step).getMaxAddressLineIndex() > -1)
13519 {
13520 for (int addr_line = 0; addr_line < foundAdresses.get(results_step).getMaxAddressLineIndex(); addr_line++)
13521 {
13522 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
13523 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
13524 }
13525 }
13526
13527 // // DEBUG: clear route rectangle list
13528 // NavitGraphics.route_rects.clear();
13529 //
13530 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
13531 //
13532 // try
13533 // {
13534 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
13535 // // save points
13536 // write_map_points();
13537 // }
13538 // catch (Exception e)
13539 // {
13540 // e.printStackTrace();
13541 // }
13542 //
13543 // if (NavitGraphics.navit_route_status == 0)
13544 // {
13545 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13546 // Navit.destination_set();
13547 //
13548 // Message msg = new Message();
13549 // Bundle b = new Bundle();
13550 // b.putInt("Callback", 3);
13551 // b.putString("lat", String.valueOf(tmp_addr.lat));
13552 // b.putString("lon", String.valueOf(tmp_addr.lon));
13553 // b.putString("q", tmp_addr.addr);
13554 // msg.setData(b);
13555 // NavitGraphics.callback_handler.sendMessage(msg);
13556 // }
13557 // else
13558 // {
13559 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13560 // Message msg = new Message();
13561 // Bundle b = new Bundle();
13562 // b.putInt("Callback", 48);
13563 // b.putString("lat", String.valueOf(tmp_addr.lat));
13564 // b.putString("lon", String.valueOf(tmp_addr.lon));
13565 // b.putString("q", tmp_addr.addr);
13566 // msg.setData(b);
13567 // NavitGraphics.callback_handler.sendMessage(msg);
13568 // }
13569
13570 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
13571
13572 // ---------- DEBUG: write route to file ----------
13573 // ---------- DEBUG: write route to file ----------
13574 // ---------- DEBUG: write route to file ----------
13575 if (p.PREF_enable_debug_write_gpx)
13576 {
13577 write_route_to_gpx_file();
13578 }
13579 // ---------- DEBUG: write route to file ----------
13580 // ---------- DEBUG: write route to file ----------
13581
13582 try
13583 {
13584 Navit.follow_button_on();
13585 }
13586 catch (Exception e2)
13587 {
13588 e2.printStackTrace();
13589 }
13590
13591 show_geo_on_screen(tmp_addr.lat, tmp_addr.lon);
13592
13593 }
13594 catch (Exception e)
13595 {
13596 e.printStackTrace();
13597 Toast.makeText(getApplicationContext(), Navit.get_text("google search API is not working at this moment, try offline search"), Toast.LENGTH_SHORT).show();
13598 }
13599 }
13600
13601 public void result_set_destination(double lat, double lon, String addr)
13602 {
13603 try
13604 {
13605 int results_step = 0;
13606 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
13607 tmp_addr.result_type = "STR";
13608 tmp_addr.item_id = "0";
13609 tmp_addr.lat = (float) lat;
13610 tmp_addr.lon = (float) lon;
13611 tmp_addr.addr = addr;
13612
13613 // // DEBUG: clear route rectangle list
13614 // NavitGraphics.route_rects.clear();
13615 //
13616 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
13617 //
13618 // try
13619 // {
13620 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
13621 // // save points
13622 // write_map_points();
13623 // }
13624 // catch (Exception e)
13625 // {
13626 // e.printStackTrace();
13627 // }
13628 //
13629 // if (NavitGraphics.navit_route_status == 0)
13630 // {
13631 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13632 // Navit.destination_set();
13633 //
13634 // Message msg = new Message();
13635 // Bundle b = new Bundle();
13636 // b.putInt("Callback", 3);
13637 // b.putString("lat", String.valueOf(tmp_addr.lat));
13638 // b.putString("lon", String.valueOf(tmp_addr.lon));
13639 // b.putString("q", tmp_addr.addr);
13640 // msg.setData(b);
13641 // NavitGraphics.callback_handler.sendMessage(msg);
13642 // }
13643 // else
13644 // {
13645 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13646 // Message msg = new Message();
13647 // Bundle b = new Bundle();
13648 // b.putInt("Callback", 48);
13649 // b.putString("lat", String.valueOf(tmp_addr.lat));
13650 // b.putString("lon", String.valueOf(tmp_addr.lon));
13651 // b.putString("q", tmp_addr.addr);
13652 // msg.setData(b);
13653 // NavitGraphics.callback_handler.sendMessage(msg);
13654 // }
13655
13656 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
13657
13658 try
13659 {
13660 Navit.follow_button_on();
13661 }
13662 catch (Exception e2)
13663 {
13664 e2.printStackTrace();
13665 }
13666
13667 // ---------- DEBUG: write route to file ----------
13668 // ---------- DEBUG: write route to file ----------
13669 // ---------- DEBUG: write route to file ----------
13670 if (p.PREF_enable_debug_write_gpx)
13671 {
13672 write_route_to_gpx_file();
13673 }
13674 // ---------- DEBUG: write route to file ----------
13675 // ---------- DEBUG: write route to file ----------
13676
13677 show_geo_on_screen(tmp_addr.lat, tmp_addr.lon);
13678
13679 }
13680 catch (Exception e)
13681 {
13682 e.printStackTrace();
13683 Toast.makeText(getApplicationContext(), Navit.get_text("google search API is not working at this moment, try offline search"), Toast.LENGTH_SHORT).show();
13684 }
13685 }
13686
13687 void open_voice_recog_screen()
13688 {
13689 Intent ii = new Intent(this, ZANaviVoiceInput.class);
13690 this.startActivityForResult(ii, Navit.ZANaviVoiceInput_id);
13691 }
13692
13693 static void dim_screen_wrapper()
13694 {
13695 try
13696 {
13697 Message msg = Navit.Navit_progress_h.obtainMessage();
13698 Bundle b = new Bundle();
13699 msg.what = 20;
13700 msg.setData(b);
13701 Navit.Navit_progress_h.sendMessage(msg);
13702 }
13703 catch (Exception e)
13704 {
13705 e.printStackTrace();
13706 }
13707 }
13708
13709 static void show_status_bar_wrapper()
13710 {
13711 try
13712 {
13713 Message msg = Navit.Navit_progress_h.obtainMessage();
13714 Bundle b = new Bundle();
13715 msg.what = 27;
13716 msg.setData(b);
13717 Navit.Navit_progress_h.sendMessage(msg);
13718 }
13719 catch (Exception e)
13720 {
13721 e.printStackTrace();
13722 }
13723 }
13724
13725 static void hide_status_bar_wrapper()
13726 {
13727 try
13728 {
13729 Message msg = Navit.Navit_progress_h.obtainMessage();
13730 Bundle b = new Bundle();
13731 msg.what = 28;
13732 msg.setData(b);
13733 Navit.Navit_progress_h.sendMessage(msg);
13734 }
13735 catch (Exception e)
13736 {
13737 e.printStackTrace();
13738 }
13739 }
13740
13741 static void default_brightness_screen_wrapper()
13742 {
13743 try
13744 {
13745 Message msg = Navit.Navit_progress_h.obtainMessage();
13746 Bundle b = new Bundle();
13747 msg.what = 21;
13748 msg.setData(b);
13749 Navit.Navit_progress_h.sendMessage(msg);
13750 }
13751 catch (Exception e)
13752 {
13753 e.printStackTrace();
13754 }
13755 }
13756
13757 static void dim_screen()
13758 {
13759 try
13760 {
13761 WindowManager.LayoutParams params_wm = app_window.getAttributes();
13762 // params_wm.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
13763 params_wm.screenBrightness = 0.1f;
13764 app_window.setAttributes(params_wm);
13765 //app_window.addFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
13766 }
13767 catch (Exception e)
13768 {
13769 e.printStackTrace();
13770 }
13771 }
13772
13773 static void default_brightness_screen()
13774 {
13775 try
13776 {
13777 WindowManager.LayoutParams params_wm = app_window.getAttributes();
13778 // params_wm.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
13779 params_wm.screenBrightness = -1f;
13780 app_window.setAttributes(params_wm);
13781 //app_window.clearFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
13782 }
13783 catch (Exception e)
13784 {
13785 e.printStackTrace();
13786 }
13787 }
13788
13789 void donate_bitcoins()
13790 {
13791 try
13792 {
13793 Intent donate_activity = new Intent(this, ZANaviDonateActivity.class);
13794 // donate_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
13795 startActivity(donate_activity);
13796 }
13797 catch (Exception e)
13798 {
13799 }
13800 }
13801
13802 void donate()
13803 {
13804 try
13805 {
13806 Intent donate_activity = new Intent(this, ZANaviNormalDonateActivity.class);
13807 // donate_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
13808 startActivity(donate_activity);
13809 }
13810 catch (Exception e)
13811 {
13812 }
13813 }
13814
13815 static int debug_indent = -1;
13816 static String debug_indent_spaces = " ";
13817
13818 // type: 0 -> enter, 1 -> leave, 2 .. n -> return(#n)
13819 static void my_func_name(int type)
13820 {
13821 int debug_indent2;
13822
13823 // -- switch off !! --
13824 // -- switch off !! --
13825 debug_indent = 0;
13826 // -- switch off !! --
13827 // -- switch off !! --
13828
13829 try
13830 {
13831 StackTraceElement[] a = Thread.currentThread().getStackTrace();
13832 if (type == 0)
13833 {
13834 //debug_indent++;
13835 debug_indent2 = debug_indent;
13836 //if (debug_indent2 > debug_indent_spaces.length())
13837 //{
13838 // debug_indent2 = debug_indent_spaces.length() - 1;
13839 //}
13840 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":enter");
13841 }
13842 else if (type == 1)
13843 {
13844 debug_indent2 = debug_indent;
13845 //if (debug_indent2 > debug_indent_spaces.length())
13846 //{
13847 // debug_indent2 = debug_indent_spaces.length() - 1;
13848 //}
13849 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":leave");
13850 //debug_indent--;
13851 }
13852 else
13853 {
13854 debug_indent2 = debug_indent;
13855 //if (debug_indent2 > debug_indent_spaces.length())
13856 //{
13857 // debug_indent2 = debug_indent_spaces.length() - 1;
13858 //}
13859 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":return(" + type + ")");
13860 //debug_indent--;
13861 }
13862 }
13863 catch (Exception e)
13864 {
13865 e.printStackTrace();
13866 }
13867 }
13868
13869 // type: 0 -> enter, 1 -> leave, 2 .. n -> return(#n)
13870 static void my_func_name(int type, String msg)
13871 {
13872 int debug_indent2;
13873
13874 // -- switch off !! --
13875 // -- switch off !! --
13876 debug_indent = 0;
13877 // -- switch off !! --
13878 // -- switch off !! --
13879
13880 try
13881 {
13882 StackTraceElement[] a = Thread.currentThread().getStackTrace();
13883 if (type == 0)
13884 {
13885 //debug_indent++;
13886 debug_indent2 = debug_indent;
13887 //if (debug_indent2 > debug_indent_spaces.length())
13888 //{
13889 // debug_indent2 = debug_indent_spaces.length() - 1;
13890 //}
13891 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":enter" + ":" + msg);
13892 }
13893 else if (type == 1)
13894 {
13895 debug_indent2 = debug_indent;
13896 //if (debug_indent2 > debug_indent_spaces.length())
13897 //{
13898 // debug_indent2 = debug_indent_spaces.length() - 1;
13899 //}
13900 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":leave" + ":" + msg);
13901 //debug_indent--;
13902 }
13903 else
13904 {
13905 debug_indent2 = debug_indent;
13906 //if (debug_indent2 > debug_indent_spaces.length())
13907 //{
13908 // debug_indent2 = debug_indent_spaces.length() - 1;
13909 //}
13910 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":return(" + type + ")" + ":" + msg);
13911 //debug_indent--;
13912 }
13913 }
13914 catch (Exception e)
13915 {
13916 e.printStackTrace();
13917 }
13918 }
13919
13920 public static void write_route_to_gpx_file()
13921 {
13922 final Thread write_route_to_gpx_file_001 = new Thread()
13923 {
13924 int wait = 1;
13925 int count = 0;
13926 int max_count = 300; // wait 2 minutes for route to be calculated
13927
13928 @Override
13929 public void run()
13930 {
13931 while (wait == 1)
13932 {
13933 try
13934 {
13935 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
13936 {
13937 Message msg = new Message();
13938 Bundle b = new Bundle();
13939 b.putInt("Callback", 96);
13940 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
13941 String filename = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_route_" + date + ".gpx";
13942 b.putString("s", filename);
13943 System.out.println("Debug:" + "file=" + filename);
13944 msg.setData(b);
13945 NavitGraphics.callback_handler.sendMessage(msg);
13946
13947 Message msg7 = Navit_progress_h.obtainMessage();
13948 Bundle b7 = new Bundle();
13949 msg7.what = 2; // long Toast message
13950 b7.putString("text", Navit.get_text("saving route to GPX-file") + " " + filename); //TRANS
13951 msg7.setData(b7);
13952 Navit_progress_h.sendMessage(msg7);
13953
13954 wait = 0;
13955 }
13956 else
13957 {
13958 wait = 1;
13959 }
13960
13961 count++;
13962 if (count > max_count)
13963 {
13964 wait = 0;
13965
13966 Message msg7 = Navit_progress_h.obtainMessage();
13967 Bundle b7 = new Bundle();
13968 msg7.what = 2; // long Toast message
13969 b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS
13970 msg7.setData(b7);
13971 Navit_progress_h.sendMessage(msg7);
13972 }
13973 else
13974 {
13975 Thread.sleep(400);
13976 }
13977 }
13978 catch (Exception e)
13979 {
13980 }
13981 }
13982 }
13983 };
13984 write_route_to_gpx_file_001.start();
13985 }
13986
13987 void convert_gpx_file_real(String gpx_file)
13988 {
13989 File tt2 = new File(gpx_file);
13990 p.PREF_last_selected_dir_gpxfiles = tt2.getParent();
13991 Log.e("Navit", "last_selected_dir_gpxfiles " + p.PREF_last_selected_dir_gpxfiles);
13992 setPrefs_selected_gpx_dir();
13993
13994 String out_ = MAP_FILENAME_PATH + "/gpxtracks.txt";
13995 Log.e("Navit", "onActivityResult 002 " + gpx_file + " " + out_);
13996 MainFrame.do_conversion(gpx_file, out_);
13997
13998 // draw map no-async
13999 Message msg = new Message();
14000 Bundle b = new Bundle();
14001 b.putInt("Callback", 64);
14002 msg.setData(b);
14003 NavitGraphics.callback_handler.sendMessage(msg);
14004 }
14005
14006 String intent_flags_to_string(int flags)
14007 {
14008 String ret = "(" + String.format("%#x", flags) + ") ";
14009
14010 // Intent flags
14011 final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
14012 final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
14013 final int FLAG_FROM_BACKGROUND = 0x00000004;
14014 final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
14015 final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
14016 final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
14017 final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
14018 final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
14019 final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
14020 final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
14021 final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
14022 final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
14023 final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
14024 final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
14025 final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
14026 final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
14027 final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
14028 final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
14029 final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
14030 final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
14031 final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
14032 final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
14033 final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
14034 /*
14035 * final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
14036 * final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
14037 * final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
14038 * final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x08000000;
14039 * final int FLAG_RECEIVER_BOOT_UPGRADE = 0x04000000;
14040 */
14041
14042 int first = 1;
14043 String sep = "";
14044
14045 if ((flags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
14046 {
14047 if (first == 1)
14048 {
14049 first = 0;
14050 sep = "";
14051 }
14052 else
14053 {
14054 sep = ",";
14055 }
14056 ret = ret + sep + "FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS";
14057 }
14058 if ((flags & FLAG_ACTIVITY_BROUGHT_TO_FRONT) == FLAG_ACTIVITY_BROUGHT_TO_FRONT)
14059 {
14060 if (first == 1)
14061 {
14062 first = 0;
14063 sep = "";
14064 }
14065 else
14066 {
14067 sep = ",";
14068 }
14069 ret = ret + sep + "FLAG_ACTIVITY_BROUGHT_TO_FRONT";
14070 }
14071 if ((flags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) == FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
14072 {
14073 if (first == 1)
14074 {
14075 first = 0;
14076 sep = "";
14077 }
14078 else
14079 {
14080 sep = ",";
14081 }
14082 ret = ret + sep + "FLAG_ACTIVITY_RESET_TASK_IF_NEEDED";
14083 }
14084 if ((flags & FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)
14085 {
14086 if (first == 1)
14087 {
14088 first = 0;
14089 sep = "";
14090 }
14091 else
14092 {
14093 sep = ",";
14094 }
14095 ret = ret + sep + "FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY";
14096 }
14097 if ((flags & FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) == FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
14098 {
14099 if (first == 1)
14100 {
14101 first = 0;
14102 sep = "";
14103 }
14104 else
14105 {
14106 sep = ",";
14107 }
14108 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET";
14109 }
14110 if ((flags & FLAG_ACTIVITY_NO_USER_ACTION) == FLAG_ACTIVITY_NO_USER_ACTION)
14111 {
14112 if (first == 1)
14113 {
14114 first = 0;
14115 sep = "";
14116 }
14117 else
14118 {
14119 sep = ",";
14120 }
14121 ret = ret + sep + "FLAG_ACTIVITY_NO_USER_ACTION";
14122 }
14123 if ((flags & FLAG_ACTIVITY_REORDER_TO_FRONT) == FLAG_ACTIVITY_REORDER_TO_FRONT)
14124 {
14125 if (first == 1)
14126 {
14127 first = 0;
14128 sep = "";
14129 }
14130 else
14131 {
14132 sep = ",";
14133 }
14134 ret = ret + sep + "FLAG_ACTIVITY_REORDER_TO_FRONT";
14135 }
14136 if ((flags & FLAG_ACTIVITY_NO_ANIMATION) == FLAG_ACTIVITY_NO_ANIMATION)
14137 {
14138 if (first == 1)
14139 {
14140 first = 0;
14141 sep = "";
14142 }
14143 else
14144 {
14145 sep = ",";
14146 }
14147 ret = ret + sep + "FLAG_ACTIVITY_NO_ANIMATION";
14148 }
14149 if ((flags & FLAG_ACTIVITY_CLEAR_TASK) == FLAG_ACTIVITY_CLEAR_TASK)
14150 {
14151 if (first == 1)
14152 {
14153 first = 0;
14154 sep = "";
14155 }
14156 else
14157 {
14158 sep = ",";
14159 }
14160 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_TASK";
14161 }
14162 if ((flags & FLAG_ACTIVITY_TASK_ON_HOME) == FLAG_ACTIVITY_TASK_ON_HOME)
14163 {
14164 if (first == 1)
14165 {
14166 first = 0;
14167 sep = "";
14168 }
14169 else
14170 {
14171 sep = ",";
14172 }
14173 ret = ret + sep + "FLAG_ACTIVITY_TASK_ON_HOME";
14174 }
14175
14176 if ((flags & FLAG_GRANT_READ_URI_PERMISSION) == FLAG_GRANT_READ_URI_PERMISSION)
14177 {
14178 if (first == 1)
14179 {
14180 first = 0;
14181 sep = "";
14182 }
14183 else
14184 {
14185 sep = ",";
14186 }
14187 ret = ret + sep + "FLAG_GRANT_READ_URI_PERMISSION";
14188 }
14189
14190 if ((flags & FLAG_GRANT_WRITE_URI_PERMISSION) == FLAG_GRANT_WRITE_URI_PERMISSION)
14191 {
14192 if (first == 1)
14193 {
14194 first = 0;
14195 sep = "";
14196 }
14197 else
14198 {
14199 sep = ",";
14200 }
14201 ret = ret + sep + "FLAG_GRANT_WRITE_URI_PERMISSION";
14202 }
14203
14204 if ((flags & FLAG_FROM_BACKGROUND) == FLAG_FROM_BACKGROUND)
14205 {
14206 if (first == 1)
14207 {
14208 first = 0;
14209 sep = "";
14210 }
14211 else
14212 {
14213 sep = ",";
14214 }
14215 ret = ret + sep + "FLAG_FROM_BACKGROUND";
14216 }
14217 if ((flags & FLAG_DEBUG_LOG_RESOLUTION) == FLAG_DEBUG_LOG_RESOLUTION)
14218 {
14219 if (first == 1)
14220 {
14221 first = 0;
14222 sep = "";
14223 }
14224 else
14225 {
14226 sep = ",";
14227 }
14228 ret = ret + sep + "FLAG_DEBUG_LOG_RESOLUTION";
14229 }
14230 if ((flags & FLAG_EXCLUDE_STOPPED_PACKAGES) == FLAG_EXCLUDE_STOPPED_PACKAGES)
14231 {
14232 if (first == 1)
14233 {
14234 first = 0;
14235 sep = "";
14236 }
14237 else
14238 {
14239 sep = ",";
14240 }
14241 ret = ret + sep + "FLAG_EXCLUDE_STOPPED_PACKAGES";
14242 }
14243 if ((flags & FLAG_INCLUDE_STOPPED_PACKAGES) == FLAG_INCLUDE_STOPPED_PACKAGES)
14244 {
14245 if (first == 1)
14246 {
14247 first = 0;
14248 sep = "";
14249 }
14250 else
14251 {
14252 sep = ",";
14253 }
14254 ret = ret + sep + "FLAG_INCLUDE_STOPPED_PACKAGES";
14255 }
14256 if ((flags & FLAG_ACTIVITY_NO_HISTORY) == FLAG_ACTIVITY_NO_HISTORY)
14257 {
14258 if (first == 1)
14259 {
14260 first = 0;
14261 sep = "";
14262 }
14263 else
14264 {
14265 sep = ",";
14266 }
14267 ret = ret + sep + "FLAG_ACTIVITY_NO_HISTORY";
14268 }
14269 if ((flags & FLAG_ACTIVITY_SINGLE_TOP) == FLAG_ACTIVITY_SINGLE_TOP)
14270 {
14271 if (first == 1)
14272 {
14273 first = 0;
14274 sep = "";
14275 }
14276 else
14277 {
14278 sep = ",";
14279 }
14280 ret = ret + sep + "FLAG_ACTIVITY_SINGLE_TOP";
14281 }
14282 if ((flags & FLAG_ACTIVITY_NEW_TASK) == FLAG_ACTIVITY_NEW_TASK)
14283 {
14284 if (first == 1)
14285 {
14286 first = 0;
14287 sep = "";
14288 }
14289 else
14290 {
14291 sep = ",";
14292 }
14293 ret = ret + sep + "FLAG_ACTIVITY_NEW_TASK";
14294 }
14295 if ((flags & FLAG_ACTIVITY_MULTIPLE_TASK) == FLAG_ACTIVITY_MULTIPLE_TASK)
14296 {
14297 if (first == 1)
14298 {
14299 first = 0;
14300 sep = "";
14301 }
14302 else
14303 {
14304 sep = ",";
14305 }
14306 ret = ret + sep + "FLAG_ACTIVITY_MULTIPLE_TASK";
14307 }
14308 if ((flags & FLAG_ACTIVITY_CLEAR_TOP) == FLAG_ACTIVITY_CLEAR_TOP)
14309 {
14310 if (first == 1)
14311 {
14312 first = 0;
14313 sep = "";
14314 }
14315 else
14316 {
14317 sep = ",";
14318 }
14319 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_TOP";
14320 }
14321 if ((flags & FLAG_ACTIVITY_FORWARD_RESULT) == FLAG_ACTIVITY_FORWARD_RESULT)
14322 {
14323 if (first == 1)
14324 {
14325 first = 0;
14326 sep = "";
14327 }
14328 else
14329 {
14330 sep = ",";
14331 }
14332 ret = ret + sep + "FLAG_ACTIVITY_FORWARD_RESULT";
14333 }
14334 if ((flags & FLAG_ACTIVITY_PREVIOUS_IS_TOP) == FLAG_ACTIVITY_PREVIOUS_IS_TOP)
14335 {
14336 if (first == 1)
14337 {
14338 first = 0;
14339 sep = "";
14340 }
14341 else
14342 {
14343 sep = ",";
14344 }
14345 ret = ret + sep + "FLAG_ACTIVITY_PREVIOUS_IS_TOP";
14346 }
14347
14348 return ret;
14349 }
14350
14351 static boolean want_tunnel_extrapolation()
14352 {
14353 if ((!isGPSFix) && (pos_is_underground == 1) && (NavitGraphics.CallbackDestinationValid2() > 0))
14354 {
14355 // gps fix is lost
14356 // and
14357 // our position is underground
14358 // and
14359 // we have a destination set
14360 //
14361 // --> we want tunnel extrapolation
14362 return true;
14363 }
14364
14365 return false;
14366 }
14367
14368 public static void applySharedTheme(Activity act, int Theme_id)
14369 {
14370 act.setTheme(Theme_id);
14371 }
14372
14373 private com.zoffcc.applications.zanavi_msg.ZListener.Stub zclientListener = new com.zoffcc.applications.zanavi_msg.ZListener.Stub()
14374 {
14375 @Override
14376 public String handleUpdated(String data) throws RemoteException
14377 {
14378 // Log.i("NavitPlugin", "update from Plugin=" + data);
14379 return "Navit says:\"PONG\"";
14380 }
14381 };
14382
14383 static Object sync_plugin_send = new Object();
14384
14385 public static void send_data_to_plugin_bg(final int msg_cat, final String data)
14386 {
14387 // send data to plugin (plugin will send to server) in another task! --------------------------
14388 new AsyncTask<Void, Void, String>()
14389 {
14390 @Override
14391 protected String doInBackground(Void... params)
14392 {
14393 synchronized (sync_plugin_send)
14394 {
14395 try
14396 {
14397 if (plugin_api == null)
14398 {
14399 try
14400 {
14401 Thread.sleep(3000); // wait until the service is bound
14402 }
14403 catch (Exception e)
14404 {
14405 }
14406 }
14407
14408 String response = plugin_api.getResult(PLUGIN_MSG_ID, msg_cat, data);
14409
14410 }
14411 catch (RemoteException e)
14412 {
14413 // Log.e("NavitPlugin", "Failed(1) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14414 }
14415 catch (Exception e)
14416 {
14417 // Log.e("NavitPlugin", "Failed(2) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14418 }
14419 }
14420 return "";
14421 }
14422
14423 @Override
14424 protected void onPostExecute(String msg)
14425 {
14426
14427 }
14428 }.execute(null, null, null);
14429 // send data to plugin (plugin will send to server) in another task! --------------------------
14430 }
14431
14432 private ServiceConnection serviceConnection = new ServiceConnection()
14433 {
14434 @Override
14435 public void onServiceConnected(ComponentName name, IBinder service)
14436 {
14437 Log.i("NavitPlugin", "Service connection established");
14438
14439 // that's how we get the client side of the IPC connection
14440 plugin_api = ZanaviCloudApi.Stub.asInterface((IBinder) service);
14441 try
14442 {
14443 plugin_api.addListener(zclientListener);
14444 }
14445 catch (RemoteException e)
14446 {
14447 Log.e("NavitPlugin", "Failed(1) to add listener", e);
14448 }
14449 catch (Exception e)
14450 {
14451 Log.e("NavitPlugin", "Failed(2) to add listener", e);
14452 }
14453
14454 send_installed_maps_to_plugin();
14455 send_data_to_plugin_bg(PLUGIN_MSG_CAT_zanavi_version, Navit.NavitAppVersion);
14456 }
14457
14458 @Override
14459 public void onServiceDisconnected(ComponentName name)
14460 {
14461 plugin_api = null;
14462 Log.i("NavitPlugin", "Service connection closed");
14463 }
14464 };
14465
14466 /**
14467 * send installed maps and download date/time (time up to minute) in UTC to plugin
14468 */
14469 static void send_installed_maps_to_plugin()
14470 {
14471 try
14472 {
14473 /*
14474 * { "201502032311":"austria.bin","201502032312":"germany.bin" }
14475 */
14476
14477 String data = "";
14478
14479 // dirty hardcode JSON data struct
14480 final String maps_and_timestamp_data_start = "{ \"";
14481 final String maps_and_timestamp_data_sep1 = "\":\"";
14482 final String maps_and_timestamp_data_sep2 = "\",\"";
14483 final String maps_and_timestamp_data_end = "\" }";
14484
14485 NavitMapDownloader.init_cat_file_maps_timestamps();
14486
14487 data = data + maps_and_timestamp_data_start;
14488
14489 String map_name = "";
14490 Iterator<String> k = NavitMapDownloader.map_catalogue_date.listIterator();
14491 while (k.hasNext())
14492 {
14493 map_name = k.next();
14494 data = data + map_name.split(":", 2)[1];
14495 data = data + maps_and_timestamp_data_sep1;
14496 data = data + map_name.split(":", 2)[0];
14497 if (k.hasNext())
14498 {
14499 data = data + maps_and_timestamp_data_sep2;
14500 }
14501 }
14502 data = data + maps_and_timestamp_data_end;
14503
14504 // System.out.println("PLUGIN:MAPS:" + data);
14505
14506 send_data_to_plugin_bg(PLUGIN_MSG_CAT_installed_maps, data);
14507 }
14508 catch (Exception e)
14509 {
14510 }
14511 }
14512
14513 static boolean have_maps_installed()
14514 {
14515 int count_maps_installed = NavitMapDownloader.cat_file_maps_have_installed_any();
14516 if (count_maps_installed == 0)
14517 {
14518 return false;
14519 }
14520 else
14521 {
14522 return true;
14523 }
14524 }
14525
14526 /**
14527 * auto start map download/update
14528 *
14529 * @param map_name
14530 * mapfilename with ending ".bin"
14531 */
14532 void auto_start_update_map(String map_name)
14533 {
14534
14535 int count = NavitMapDownloader.z_OSM_MAPS.length;
14536 Navit.download_map_id = -1;
14537 for (int i = 0; i < count; i++)
14538 {
14539 if (!NavitMapDownloader.z_OSM_MAPS[i].is_continent)
14540 {
14541 // System.out.println("mmm1=" + NavitMapDownloader.z_OSM_MAPS[i].url);
14542 if (NavitMapDownloader.z_OSM_MAPS[i].url.equals(map_name))
14543 {
14544 Navit.download_map_id = i;
14545 System.out.println("mMM2=" + NavitMapDownloader.z_OSM_MAPS[i].map_name);
14546 }
14547 }
14548 }
14549
14550 // show the map download progressbar, and download the map
14551 if (Navit.download_map_id > -1)
14552 {
14553 // new method in service
14554 Message msg = progress_handler.obtainMessage();
14555 Bundle b = new Bundle();
14556 msg.what = 22;
14557 progress_handler.sendMessage(msg);
14558 }
14559 }
14560
14561 void show_case_001()
14562 {
14563 // try
14564 // {
14565 // new ShowcaseView.Builder(this).setTarget(new ViewTarget(R.id.no_maps_button, this)).setContentTitle("").setContentText("").singleShot(Navit.SHOWCASEVIEW_ID_001).build();
14566 // }
14567 // catch (Exception e1)
14568 // {
14569 // }
14570 // catch (NoSuchMethodError e2)
14571 // {
14572 // }
14573 // catch (NoClassDefFoundError e3)
14574 // {
14575 // }
14576 }
14577
14578 static void set_zoom_level(int want_zoom_level)
14579 {
14580 try
14581 {
14582 Bundle b = new Bundle();
14583 Message msg = new Message();
14584 b.putInt("Callback", 33);
14585 b.putString("s", Integer.toString(want_zoom_level));
14586 msg.setData(b);
14587 NavitGraphics.callback_handler.sendMessage(msg);
14588 }
14589 catch (Exception e)
14590 {
14591 e.printStackTrace();
14592 }
14593 }
14594
14595 static void set_zoom_level_no_draw(int want_zoom_level)
14596 {
14597 try
14598 {
14599 Bundle b = new Bundle();
14600 Message msg = new Message();
14601 b.putInt("Callback", 105);
14602 b.putString("s", Integer.toString(want_zoom_level));
14603 msg.setData(b);
14604 NavitGraphics.callback_handler.sendMessage(msg);
14605 }
14606 catch (Exception e)
14607 {
14608 e.printStackTrace();
14609 }
14610 }
14611
14612 static void draw_map()
14613 {
14614 try
14615 {
14616 // draw map no-async
14617 Message msg = new Message();
14618 Bundle b = new Bundle();
14619 b.putInt("Callback", 64);
14620 msg.setData(b);
14621 NavitGraphics.callback_handler.sendMessage(msg);
14622 }
14623 catch (Exception e)
14624 {
14625 e.printStackTrace();
14626 }
14627 }
14628
14629 final static int bottom_bar_snap_duration = 190;
14630
14631 void animate_bottom_bar_up()
14632 {
14633 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
14634 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -cur_y_margin_bottom_bar_touch);
14635 animation.setDuration(bottom_bar_snap_duration); // animation duration
14636 animation.setFillAfter(true);
14637 animation.setFillEnabled(true);
14638 animation.setRepeatCount(0); // animation repeat count
14639 animation.setAnimationListener(new AnimationListener()
14640 {
14641 @Override
14642 public void onAnimationStart(Animation animation)
14643 {
14644 }
14645
14646 @Override
14647 public void onAnimationRepeat(Animation animation)
14648 {
14649 }
14650
14651 @Override
14652 public void onAnimationEnd(Animation animation)
14653 {
14654 cur_y_margin_bottom_bar_touch = 0;
14655 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14656 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14657 a.setLayoutParams(relativeParams);
14658 a.requestLayout();
14659
14660 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14661 anim.setFillAfter(true);
14662 anim.setFillEnabled(true);
14663 anim.setDuration(1);
14664 a.startAnimation(anim);
14665 }
14666 });
14667 a.startAnimation(animation);
14668 }
14669
14670 static void animate_bottom_bar_down()
14671 {
14672 final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide);
14673
14674 // System.out.println("FRAG:animate_bottom_bar_down:014");
14675
14676 // set bottom end positon correctly??
14677 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14678
14679 final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch);
14680 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); // new TranslateAnimation(xFrom,xTo, yFrom,yTo)
14681 animation.setDuration(bottom_bar_snap_duration); // animation duration
14682 animation.setFillAfter(true);
14683 animation.setFillEnabled(true);
14684 animation.setRepeatCount(0); // animation repeat count
14685 animation.setAnimationListener(new AnimationListener()
14686 {
14687
14688 @Override
14689 public void onAnimationStart(Animation animation)
14690 {
14691 }
14692
14693 @Override
14694 public void onAnimationRepeat(Animation animation)
14695 {
14696 }
14697
14698 @Override
14699 public void onAnimationEnd(Animation animation)
14700 {
14701 // set bottom end positon correctly??
14702 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14703
14704 cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch;
14705 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14706 relativeParams.setMargins(0, (int) bottom_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14707 a.setLayoutParams(relativeParams);
14708 a.requestLayout();
14709
14710 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14711 anim.setFillAfter(true);
14712 anim.setFillEnabled(true);
14713 anim.setDuration(1);
14714 a.startAnimation(anim);
14715
14716 // remove roadbook fragment -----------
14717 try
14718 {
14719 if (road_book != null)
14720 {
14721 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
14722 // System.out.println("FRAG:dettach:002");
14723 fragmentTransaction.detach(road_book);
14724 fragmentTransaction.remove(road_book).commit();
14725 road_book = null;
14726 }
14727 }
14728 catch (Exception ef)
14729 {
14730 }
14731 // remove roadbook fragment -----------
14732
14733 }
14734 });
14735 a.startAnimation(animation);
14736 }
14737
14738 synchronized static int find_max_font_size_for_height(String sample_text, int height, int max_font_size, int padding_in_dp)
14739 {
14740 String s = sample_text;
14741 int bh = 0;
14742 Paint p = new Paint();
14743 Rect bounds = new Rect();
14744 p.setTextSize(max_font_size);
14745 // p.measureText(s);
14746 p.getTextBounds(s, 0, s.length(), bounds);
14747
14748 int ret_font_size = max_font_size;
14749
14750 int loop_counter_max = 400;
14751 int loop_counter = 0;
14752 int padding_in_px = 0;
14753 if (padding_in_dp > 0)
14754 {
14755 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14756 }
14757
14758 bh = bounds.height();
14759 //System.out.println("bh(1)=" + bh);
14760 while ((bh + padding_in_px) > height)
14761 {
14762 loop_counter++;
14763 if (loop_counter > loop_counter_max)
14764 {
14765 break;
14766 }
14767
14768 ret_font_size--;
14769 p.setTextSize(ret_font_size);
14770 // p.measureText(s);
14771 p.getTextBounds(s, 0, s.length(), bounds);
14772 bh = bounds.height();
14773 }
14774
14775 return ret_font_size;
14776 }
14777
14778 synchronized static int find_max_letters_for_width_and_fontsize(String max_length_text, int width, int max_font_size, int padding_in_dp)
14779 {
14780 int ret_max_letters = 10;
14781
14782 int padding_in_px = 0;
14783 if (padding_in_dp > 0)
14784 {
14785 //System.out.println("aaa2:l:1:x:" + padding_in_dp);
14786 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14787 //System.out.println("aaa2:l:1:x:2=" + padding_in_dp + " " + padding_in_px + " " + NavitGraphics.dp_to_px(padding_in_dp) + " " + NavitGraphics.Global_dpi_factor_better);
14788 }
14789 //System.out.println("aaa2:l:1:x:1=" + padding_in_px);
14790
14791 int c = 0;
14792 Paint p = new Paint();
14793 p.setTextSize(max_font_size);
14794
14795 String s = max_length_text;
14796
14797 if ((s == null) || (s.equals("")))
14798 {
14799 s = "Mlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwo";
14800 }
14801
14802 int l = s.length();
14803 ret_max_letters = l;
14804 float mt = p.measureText(s);
14805 //System.out.println("aaa2:l:1:" + l + " " + s);
14806 //System.out.println("aaa2:l:22:." + mt + " padding_in_px=" + padding_in_px + " " + width);
14807
14808 while (mt + padding_in_px > width)
14809 {
14810 //System.out.println("aaa2:l:22:+" + mt + " " + padding_in_px + " " + width);
14811
14812 c++;
14813 if (c == l)
14814 {
14815 // no more letters
14816 //System.out.println("aaa2:l:1:no more letters:" + l + " " + s);
14817 break;
14818 }
14819 s = s.substring(0, s.length() - 1);
14820 mt = p.measureText(s);
14821 ret_max_letters--;
14822 }
14823
14824 //System.out.println("aaa2:l:1:res=" + ret_max_letters);
14825 return ret_max_letters;
14826 }
14827
14828 synchronized static int find_max_font_size_for_width(String sample_text, int width, int max_font_size, int padding_in_dp)
14829 {
14830 final String s = sample_text;
14831 int bh = 0;
14832 Paint p = new Paint();
14833 Rect bounds = new Rect();
14834 p.setTextSize(max_font_size);
14835 p.getTextBounds(s, 0, s.length(), bounds);
14836
14837 int ret_font_size = max_font_size;
14838
14839 int loop_counter_max = 400;
14840 int loop_counter = 0;
14841 int padding_in_px = 0;
14842 if (padding_in_dp > 0)
14843 {
14844 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14845 }
14846
14847 bh = bounds.width();
14848 while ((bh + padding_in_px) > width)
14849 {
14850 loop_counter++;
14851 if (loop_counter > loop_counter_max)
14852 {
14853 break;
14854 }
14855
14856 ret_font_size--;
14857 p.setTextSize(ret_font_size);
14858 p.getTextBounds(s, 0, s.length(), bounds);
14859 bh = bounds.width();
14860 // mt = p.measureText(s);
14861 }
14862
14863 return ret_font_size;
14864 }
14865
14866 static int last_orientation = Configuration.ORIENTATION_LANDSCAPE;
14867
14868 @Override
14869 public void onConfigurationChanged(Configuration newConfig)
14870 {
14871 super.onConfigurationChanged(newConfig);
14872
14873 if (last_orientation != newConfig.orientation)
14874 {
14875 // Checks the orientation of the screen
14876 if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
14877 {
14878 // setContentView(R.layout.main_layout);
14879
14880 // -- bottom bar --
14881 int h = NavitGraphics.mCanvasHeight;
14882 try
14883 {
14884 int h001;
14885 android.view.ViewGroup.LayoutParams lp001;
14886
14887 View v003 = (View) findViewById(R.id.osd_nextturn_new);
14888 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
14889 lp001 = v003.getLayoutParams();
14890 lp001.height = h001;
14891 v003.requestLayout();
14892
14893 v003 = (View) findViewById(R.id.bottom_bar);
14894 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
14895 lp001 = v003.getLayoutParams();
14896 lp001.height = h001;
14897 v003.requestLayout();
14898
14899 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
14900 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
14901 lp001 = v002.getLayoutParams();
14902 lp001.height = h001;
14903 v002.requestLayout();
14904
14905 v003 = (View) findViewById(R.id.osd_timetodest_new);
14906 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
14907 lp001 = v003.getLayoutParams();
14908 lp001.height = h001;
14909 v003.requestLayout();
14910
14911 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
14912 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
14913 lp001 = v002.getLayoutParams();
14914 lp001.height = h001;
14915 v002.requestLayout();
14916
14917 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
14918 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
14919 lp001 = v001.getLayoutParams();
14920 lp001.height = h001;
14921 v001.requestLayout();
14922
14923 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
14924 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
14925 v003 = (View) findViewById(R.id.view_speeding);
14926 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
14927 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
14928 v003.setLayoutParams(relativeParams_001);
14929 v003.requestLayout();
14930
14931 // Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
14932
14933 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
14934 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
14935
14936 Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
14937 }
14938 catch (Exception e)
14939 {
14940 Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
14941 }
14942 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
14943 // -- bottom bar --
14944 }
14945 else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
14946 {
14947 // setContentView(R.layout.main_layout);
14948
14949 // -- bottom bar --
14950 int h = NavitGraphics.mCanvasHeight;
14951 try
14952 {
14953 int h001;
14954 android.view.ViewGroup.LayoutParams lp001;
14955
14956 View v003 = (View) findViewById(R.id.osd_nextturn_new);
14957 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
14958 lp001 = v003.getLayoutParams();
14959 lp001.height = h001;
14960 v003.requestLayout();
14961
14962 v003 = (View) findViewById(R.id.bottom_bar);
14963 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
14964 lp001 = v003.getLayoutParams();
14965 lp001.height = h001;
14966 v003.requestLayout();
14967
14968 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
14969 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
14970 lp001 = v002.getLayoutParams();
14971 lp001.height = h001;
14972 v002.requestLayout();
14973
14974 v003 = (View) findViewById(R.id.osd_timetodest_new);
14975 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
14976 lp001 = v003.getLayoutParams();
14977 lp001.height = h001;
14978 v003.requestLayout();
14979
14980 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
14981 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
14982 lp001 = v002.getLayoutParams();
14983 lp001.height = h001;
14984 v002.requestLayout();
14985
14986 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
14987 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
14988 lp001 = v001.getLayoutParams();
14989 lp001.height = h001;
14990 v001.requestLayout();
14991
14992 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
14993 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
14994 v003 = (View) findViewById(R.id.view_speeding);
14995 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
14996 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
14997 v003.setLayoutParams(relativeParams_001);
14998 v003.requestLayout();
14999
15000 // Toast.makeText(this, "protrait", Toast.LENGTH_SHORT).show();
15001
15002 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
15003 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
15004
15005 Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
15006 }
15007 catch (Exception e)
15008 {
15009 Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
15010 }
15011 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
15012 // -- bottom bar --
15013 }
15014
15015 last_orientation = newConfig.orientation;
15016 }
15017 }
15018
15019 static void long_toast(String msg)
15020 {
15021 try
15022 {
15023 Message msg7 = Navit_progress_h.obtainMessage();
15024 Bundle b7 = new Bundle();
15025 msg7.what = 2; // long Toast message
15026 b7.putString("text", msg);
15027 msg7.setData(b7);
15028 Navit_progress_h.sendMessage(msg7);
15029 }
15030 catch (Exception e)
15031 {
15032 }
15033 }
15034
15035 static void short_toast(String msg)
15036 {
15037 try
15038 {
15039 Message msg7 = Navit_progress_h.obtainMessage();
15040 Bundle b7 = new Bundle();
15041 msg7.what = 3; // short Toast message
15042 b7.putString("text", msg);
15043 msg7.setData(b7);
15044 Navit_progress_h.sendMessage(msg7);
15045 }
15046 catch (Exception e)
15047 {
15048 }
15049 }
15050
15051 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)
15052 {
15053 global_last_destination_name = NavitSpeech2.filter_out_special_chars_for_dest_string(addr);
15054 // System.out.println("HOME002:" + addr + " = " + global_last_destination_name);
15055
15056 if (p.PREF_routing_engine == 1)
15057 {
15058 route_online_OSRM(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
15059 }
15060 else if (p.PREF_routing_engine == 0)
15061 {
15062 route_offline_ZANavi(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
15063 }
15064 }
15065
15066 public static void route_offline_ZANavi(String addr, float lat_start, float lon_start, boolean start_coords_valid, double lat_end, double lon_end, boolean remember_dest)
15067 {
15068 if (remember_dest)
15069 {
15070 try
15071 {
15072 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
15073 // save points
15074 write_map_points();
15075 }
15076 catch (Exception e)
15077 {
15078 e.printStackTrace();
15079 }
15080 }
15081
15082 // DEBUG: clear route rectangle list
15083 NavitGraphics.route_rects.clear();
15084
15085 if (NavitGraphics.navit_route_status == 0)
15086 {
15087 short_toast(Navit.get_text("setting destination to") + "\n" + addr);
15088
15089 Navit.destination_set();
15090
15091 Message msg = new Message();
15092 Bundle b = new Bundle();
15093 b.putInt("Callback", 3);
15094 b.putString("lat", "" + lat_end);
15095 b.putString("lon", "" + lon_end);
15096 b.putString("q", addr);
15097 msg.setData(b);
15098 NavitGraphics.callback_handler.sendMessage(msg);
15099 }
15100 else
15101 {
15102 short_toast(Navit.get_text("new Waypoint") + "\n" + addr);
15103
15104 Message msg = new Message();
15105 Bundle b = new Bundle();
15106 b.putInt("Callback", 48);
15107 b.putString("lat", "" + lat_end);
15108 b.putString("lon", "" + lon_end);
15109 b.putString("q", addr);
15110 msg.setData(b);
15111 NavitGraphics.callback_handler.sendMessage(msg);
15112 }
15113
15114 }
15115
15116 public static void route_online_OSRM(final String addr, float lat_start, float lon_start, boolean start_coords_valid, final double lat_end, final double lon_end, final boolean remember_dest)
15117 {
15118 // http://router.project-osrm.org/viaroute?loc=46.3456438,17.450&loc=47.34122,17.5332&instructions=false&alt=false
15119
15120 if (!start_coords_valid)
15121 {
15122 location_coords cur_target = new location_coords();
15123 try
15124 {
15125 geo_coord tmp = get_current_vehicle_position();
15126 cur_target.lat = tmp.Latitude;
15127 cur_target.lon = tmp.Longitude;
15128 }
15129 catch (Exception e)
15130 {
15131 }
15132
15133 try
15134 {
15135 lat_start = (float) cur_target.lat;
15136 lon_start = (float) cur_target.lon;
15137 }
15138 catch (Exception e)
15139 {
15140 e.printStackTrace();
15141 Log.e("Navit", "problem with location!");
15142 }
15143 }
15144
15145 final String request_url = String.format(Locale.US, "http://router.project-osrm.org/viaroute?loc=%4.6f,%4.6f&loc=%4.6f,%4.6f&instructions=true&alt=false", lat_start, lon_start, lat_end, lon_end);
15146
15147 // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
15148 // StrictMode.setThreadPolicy(policy);
15149
15150 try
15151 {
15152 // System.out.println("XML:S:001 url=" + request_url);
15153 final URL url = new URL(request_url);
15154 // System.out.println("XML:S:002");
15155 // SAXParserFactory factory = SAXParserFactory.newInstance();
15156 // System.out.println("XML:S:003");
15157 // SAXParser parser = factory.newSAXParser();
15158 // System.out.println("XML:S:004");
15159 // XMLReader xmlreader = parser.getXMLReader();
15160 // System.out.println("XML:S:005");
15161 // xmlreader.setContentHandler(new ZANaviXMLHandler());
15162 // System.out.println("XML:S:006");
15163
15164 final Thread add_to_route = new Thread()
15165 {
15166 @Override
15167 public void run()
15168 {
15169 try
15170 {
15171
15172 // --------------
15173 // --------------
15174 // --------------
15175 // ------- allow this HTTPS cert ---
15176 // --------------
15177 // --------------
15178 // --------------
15179 // X509HostnameVerifier hnv = new X509HostnameVerifier()
15180 // {
15181 //
15182 // @Override
15183 // public void verify(String hostname, SSLSocket arg1) throws IOException
15184 // {
15185 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15186 // }
15187 //
15188 // @Override
15189 // public void verify(String hostname, X509Certificate cert) throws SSLException
15190 // {
15191 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15192 // }
15193 //
15194 // @Override
15195 // public void verify(String hostname, String[] cns, String[] subjectAlts) throws SSLException
15196 // {
15197 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15198 // }
15199 //
15200 // @Override
15201 // public boolean verify(String hostname, SSLSession session)
15202 // {
15203 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15204 // return true;
15205 // }
15206 // };
15207 //
15208 // SSLContext context = SSLContext.getInstance("TLS");
15209 // context.init(null, new X509TrustManager[] { new X509TrustManager()
15210 // {
15211 // public java.security.cert.X509Certificate[] getAcceptedIssuers()
15212 // {
15213 // return new java.security.cert.X509Certificate[0];
15214 // }
15215 //
15216 // @Override
15217 // public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
15218 // {
15219 // }
15220 //
15221 // @Override
15222 // public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
15223 // {
15224 // }
15225 // } }, new SecureRandom());
15226 // javax.net.ssl.SSLSocketFactory sslf = context.getSocketFactory();
15227 //
15228 // HostnameVerifier hnv_default = HttpsURLConnection.getDefaultHostnameVerifier();
15229 // javax.net.ssl.SSLSocketFactory sslf_default = HttpsURLConnection.getDefaultSSLSocketFactory();
15230 // HttpsURLConnection.setDefaultHostnameVerifier(hnv);
15231 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf);
15232 //
15233 // DefaultHttpClient client = new DefaultHttpClient();
15234 //
15235 // SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
15236 // SchemeRegistry registry = new SchemeRegistry();
15237 // registry.register(new Scheme("https", socketFactory, 443));
15238 // ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(client.getParams(), registry);
15239 // DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
15240 //
15241 // socketFactory.setHostnameVerifier(hnv);
15242 //
15243 // HttpGet get_request = new HttpGet(request_url);
15244 // HttpResponse http_response = httpClient.execute(get_request);
15245 // HttpEntity responseEntity = http_response.getEntity();
15246 //
15247 // HttpsURLConnection.setDefaultHostnameVerifier(hnv_default);
15248 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf_default);
15249 // --------------
15250 // --------------
15251 // --------------
15252 // ------- allow this HTTPS cert ---
15253 // --------------
15254 // --------------
15255 // --------------
15256
15257 InputSource is = new InputSource();
15258 is.setEncoding("utf-8");
15259 // is.setByteStream(responseEntity.getContent());
15260 is.setByteStream(url.openStream());
15261 // System.out.println("XML:S:007");
15262
15263 String response = slurp(is.getByteStream(), 16384);
15264 // response = response.replaceAll("&", "&amp;");
15265
15266 // System.out.println("XML:S:007.a res=" + response);
15267
15268 final JSONObject obj = new JSONObject(response);
15269
15270 // System.out.println(person.getInt("id"));
15271
15272 final String route_geometry = obj.getString("route_geometry");
15273 final JSONArray route_instructions_array = obj.getJSONArray("route_instructions");
15274
15275 int loop_i = 0;
15276 JSONArray instruction;
15277 int[] instruction_pos = new int[route_instructions_array.length()];
15278 for (loop_i = 0; loop_i < route_instructions_array.length(); loop_i++)
15279 {
15280 instruction = (JSONArray) route_instructions_array.get(loop_i);
15281 instruction_pos[loop_i] = Integer.parseInt(instruction.get(3).toString());
15282 // System.out.println("XML:instr. pos=" + instruction_pos[loop_i]);
15283 }
15284
15285 // System.out.println("XML:S:009 o=" + route_geometry);
15286
15287 List<geo_coord> gc_list = decode_function(route_geometry, 6);
15288
15289 if (gc_list.size() < 2)
15290 {
15291 // no real route found!! (only 1 point)
15292 }
15293 else
15294 {
15295
15296 Message msg = new Message();
15297 Bundle b = new Bundle();
15298
15299 int loop = 0;
15300
15301 geo_coord cur = new geo_coord();
15302 geo_coord old = new geo_coord();
15303 geo_coord corr = new geo_coord();
15304
15305 cur.Latitude = gc_list.get(loop).Latitude;
15306 cur.Longitude = gc_list.get(loop).Longitude;
15307
15308 int first_found = 1;
15309
15310 if (gc_list.size() > 2)
15311 {
15312 int instr_count = 1;
15313
15314 for (loop = 1; loop < gc_list.size(); loop++)
15315 {
15316
15317 old.Latitude = cur.Latitude;
15318 old.Longitude = cur.Longitude;
15319 cur.Latitude = gc_list.get(loop).Latitude;
15320 cur.Longitude = gc_list.get(loop).Longitude;
15321
15322 if ((instruction_pos[instr_count] == loop) || (loop == (gc_list.size() - 1)))
15323 {
15324
15325 if (loop == (gc_list.size() - 1))
15326 {
15327 corr = cur;
15328 }
15329 else
15330 {
15331 corr = get_point_on_line(old, cur, 70);
15332 }
15333
15334 // -- add waypoint --
15335 // b.putInt("Callback", 55548);
15336 // b.putString("lat", "" + corr.Latitude);
15337 // b.putString("lon", "" + corr.Longitude);
15338 // b.putString("q", " ");
15339 // msg.setData(b);
15340 try
15341 {
15342 // NavitGraphics.callback_handler.sendMessage(msg);
15343 if (first_found == 1)
15344 {
15345 first_found = 0;
15346 NavitGraphics.CallbackMessageChannel(55503, corr.Latitude + "#" + corr.Longitude + "#" + "");
15347 // System.out.println("XML:rR:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15348 }
15349 else
15350 {
15351 NavitGraphics.CallbackMessageChannel(55548, corr.Latitude + "#" + corr.Longitude + "#" + "");
15352 // System.out.println("XML:rw:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15353 }
15354 // Thread.sleep(25);
15355 }
15356 catch (Exception e)
15357 {
15358 e.printStackTrace();
15359 }
15360 // -- add waypoint --
15361
15362 instr_count++;
15363
15364 }
15365
15366 }
15367 }
15368
15369 if (remember_dest)
15370 {
15371 try
15372 {
15373 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
15374 // save points
15375 write_map_points();
15376 }
15377 catch (Exception e)
15378 {
15379 e.printStackTrace();
15380 }
15381 }
15382
15383 b.putInt("Callback", 55599);
15384 msg.setData(b);
15385 try
15386 {
15387 // System.out.println("XML:calc:");
15388 Thread.sleep(10);
15389 NavitGraphics.callback_handler.sendMessage(msg);
15390 }
15391 catch (Exception e)
15392 {
15393 e.printStackTrace();
15394 }
15395
15396 }
15397
15398 }
15399 catch (Exception e2)
15400 {
15401 e2.printStackTrace();
15402 }
15403 }
15404 };
15405 add_to_route.start();
15406
15407 // convert to coords -------------
15408 // convert to coords -------------
15409
15410 }
15411 catch (Exception e)
15412 {
15413 // System.out.println("XML:S:EEE");
15414 e.printStackTrace();
15415 }
15416 }
15417
15418 static List<geo_coord> decode_function(String encoded, double precision)
15419 {
15420
15421 precision = Math.pow(10, -precision);
15422 int len = encoded.length();
15423 int index = 0;
15424 int lat = 0;
15425 int lng = 0;
15426 double lat_f;
15427 double lon_f;
15428
15429 final List<geo_coord> latLongList = new ArrayList<geo_coord>();
15430 latLongList.clear();
15431
15432 while (index < len)
15433 {
15434
15435 int b;
15436 int shift = 0;
15437 int result = 0;
15438
15439 do
15440 {
15441 b = encoded.charAt(index++) - 63;
15442 result |= (b & 0x1f) << shift;
15443 shift += 5;
15444
15445 }
15446 while (b >= 0x20);
15447
15448 int dlat = 0;
15449 if ((result & 1) != 0)
15450 {
15451 dlat = ~(result >> 1);
15452 }
15453 else
15454 {
15455 dlat = (result >> 1);
15456 }
15457
15458 lat += dlat;
15459 shift = 0;
15460 result = 0;
15461
15462 do
15463 {
15464 b = encoded.charAt(index++) - 63;
15465 result |= (b & 0x1f) << shift;
15466 shift += 5;
15467 }
15468 while (b >= 0x20);
15469
15470 int dlng = 0;
15471 if ((result & 1) != 0)
15472 {
15473 dlng = ~(result >> 1);
15474 }
15475 else
15476 {
15477 dlng = (result >> 1);
15478 }
15479
15480 lng += dlng;
15481 //array.push( {lat: lat * precision, lng: lng * precision} );
15482 // array.push( [lat * precision, lng * precision] );
15483
15484 // System.out.println("XML:lat=" + (lat * precision) + " lon=" + (lng * precision));
15485
15486 lat_f = lat * precision;
15487 lon_f = lng * precision;
15488
15489 geo_coord gc = new geo_coord();
15490 gc.Latitude = lat_f;
15491 gc.Longitude = lon_f;
15492 latLongList.add(gc);
15493 }
15494
15495 return latLongList;
15496 }
15497
15498 public static class geo_coord
15499 {
15500 public double Latitude;
15501 public double Longitude;
15502 }
15503
15504 static geo_coord get_current_vehicle_position()
15505 {
15506 geo_coord ret = new geo_coord();
15507 String current_target_string2 = NavitGraphics.CallbackGeoCalc(14, 1, 1);
15508 // System.out.println("GET CUR POS:" + current_target_string2);
15509 ret.Latitude = 0;
15510 ret.Longitude = 0;
15511 try
15512 {
15513 String tmp[] = current_target_string2.split(":", 2);
15514 ret.Latitude = Double.parseDouble(tmp[0]);
15515 ret.Longitude = Double.parseDouble(tmp[1]);
15516 }
15517 catch (Exception e)
15518 {
15519 // System.out.println("GET CUR POS:ERROR " + e.getMessage());
15520 }
15521 return ret;
15522 }
15523
15524 static int[] geo_to_px(float lat, float lon)
15525 {
15526 int[] ret = new int[3];
15527
15528 ret[0] = -100;
15529 ret[1] = -100;
15530 ret[2] = 0; // invalid
15531
15532 try
15533 {
15534 String x_y = NavitGraphics.CallbackGeoCalc(2, lat, lon);
15535
15536 if (Navit.GFX_OVERSPILL)
15537 {
15538 String tmp[] = x_y.split(":", 2);
15539 int x = Integer.parseInt(tmp[0]);
15540 int y = Integer.parseInt(tmp[1]);
15541
15542 ret[0] = (int) (((float) x + (float) NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor);
15543 ret[1] = (int) (((float) y + (float) NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15544
15545 ret[2] = 1; // VALID
15546 }
15547 else
15548 {
15549 String tmp[] = x_y.split(":", 2);
15550 int x = Integer.parseInt(tmp[0]);
15551 int y = Integer.parseInt(tmp[1]);
15552
15553 ret[0] = (int) ((float) x * NavitGraphics.Global_dpi_factor);
15554 ret[1] = (int) ((float) y * NavitGraphics.Global_dpi_factor);
15555
15556 ret[2] = 1; // VALID
15557 }
15558
15559 }
15560 catch (Exception e)
15561 {
15562 }
15563
15564 return ret;
15565 }
15566
15567 static geo_coord px_to_geo(int x, int y)
15568 {
15569 geo_coord out = new geo_coord();
15570 try
15571 {
15572
15573 String lat_lon = "";
15574 if (Navit.GFX_OVERSPILL)
15575 {
15576 lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15577 }
15578 else
15579 {
15580 lat_lon = NavitGraphics.CallbackGeoCalc(1, x * NavitGraphics.Global_dpi_factor, y * NavitGraphics.Global_dpi_factor);
15581 }
15582
15583 String tmp[] = lat_lon.split(":", 2);
15584 out.Latitude = Float.parseFloat(tmp[0]);
15585 out.Longitude = Float.parseFloat(tmp[1]);
15586 }
15587 catch (Exception e)
15588 {
15589 }
15590
15591 return out;
15592 }
15593
15594 static double get_percent_coord(double start, double end, int perecent_pos)
15595 {
15596 double out = start + (end - start) * ((float) perecent_pos / 100.0f);
15597 return out;
15598 }
15599
15600 static geo_coord get_point_on_line(geo_coord start, geo_coord end, int perecent_pos)
15601 {
15602 geo_coord out = new geo_coord();
15603
15604 out.Latitude = start.Latitude + (end.Latitude - start.Latitude) * ((float) perecent_pos / 100.0f);
15605 out.Longitude = start.Longitude + (end.Longitude - start.Longitude) * ((float) perecent_pos / 100.0f);
15606
15607 return out;
15608 }
15609
15610 public static String slurp(final InputStream is, final int bufferSize)
15611 {
15612 final char[] buffer = new char[bufferSize];
15613 final StringBuilder out = new StringBuilder();
15614 Reader in = null;
15615
15616 try
15617 {
15618
15619 in = new InputStreamReader(is, "UTF-8");
15620
15621 for (;;)
15622 {
15623 int rsz;
15624 rsz = in.read(buffer, 0, buffer.length);
15625
15626 if (rsz < 0)
15627 {
15628 break;
15629 }
15630 out.append(buffer, 0, rsz);
15631 }
15632
15633 }
15634 catch (IOException e)
15635 {
15636 }
15637 catch (Exception ex)
15638 {
15639 }
15640
15641 return out.toString();
15642 }
15643
15644 public static Handler UIHandler;
15645 static
15646 {
15647 UIHandler = new Handler(Looper.getMainLooper());
15648 }
15649
15650 public static void recalculate_route()
15651 {
15652 try
15653 {
15654 // update route, if a route is set
15655 Message msg = new Message();
15656 Bundle b = new Bundle();
15657 b.putInt("Callback", 73);
15658 msg.setData(b);
15659 NavitGraphics.callback_handler.sendMessage(msg);
15660 }
15661 catch (Exception e)
15662 {
15663 }
15664 }
15665
15666 public static void runOnUI(Runnable runnable)
15667 {
15668 UIHandler.post(runnable);
15669 }
15670
15671 String substring_without_ioobe(String in, int start, int end)
15672 {
15673 String ret = ";:;:****no match****;:;:";
15674
15675 try
15676 {
15677 ret = in.substring(start, end);
15678 }
15679 catch (Exception e)
15680 {
15681 // return dummy-no-match String
15682 }
15683
15684 return ret;
15685 }
15686
15687 static private Cursor c = null;
15688 static private Uri uri = CR_CONTENT_URI;
15689
15690 static private int get_reglevel()
15691 {
15692 int ret = 0;
15693
15694 try
15695 {
15696 c = null;
15697 Thread thread = new Thread()
15698 {
15699 public void run()
15700 {
15701 try
15702 {
15703 c = content_resolver.query(uri, null, null, null, null);
15704 }
15705 catch (Exception c1)
15706 {
15707 System.out.println("CPVD:reg(e002)=" + c1.getMessage());
15708 }
15709 }
15710 };
15711 thread.start();
15712 try
15713 {
15714 thread.join();
15715 }
15716 catch (InterruptedException e)
15717 {
15718 }
15719
15720 if (c == null)
15721 {
15722 System.out.println("CPVD:Cursor c == null.");
15723 System.out.println("CPVD:reg(0)=" + ret);
15724 return ret;
15725 }
15726
15727 while (c.moveToNext())
15728 {
15729 String column1 = c.getString(0);
15730 String column2 = c.getString(1);
15731 String column3 = c.getString(2);
15732
15733 System.out.println("CPVD:column1=" + column1 + " column2=" + column2 + " column3=" + column3);
15734
15735 if (Integer.parseInt(column1) == 1)
15736 {
15737 if (column2.equals("reg"))
15738 {
15739 ret = Integer.parseInt(column3);
15740 System.out.println("CPVD:reg(1)=" + ret);
15741 }
15742 }
15743 }
15744 c.close();
15745 }
15746 catch (Exception e)
15747 {
15748 e.printStackTrace();
15749 System.out.println("CPVD:reg(e001)=" + e.getMessage());
15750 }
15751
15752 System.out.println("CPVD:reg(2)=" + ret);
15753 return ret;
15754 }
15755
15756 static void take_map_screenshot(String dir_name, String name_base)
15757 {
15758 try
15759 {
15760 View v1 = Navit.N_NavitGraphics.view;
15761 v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
15762 v1.setDrawingCacheEnabled(true);
15763 Bitmap bm = v1.getDrawingCache();
15764
15765 FileOutputStream out = null;
15766 try
15767 {
15768 out = new FileOutputStream(dir_name + "/" + name_base + ".png");
15769 bm.compress(Bitmap.CompressFormat.PNG, 100, out);
15770 }
15771 catch (Exception e)
15772 {
15773 e.printStackTrace();
15774 System.out.println("TSCR:004 " + e.getMessage());
15775 }
15776 finally
15777 {
15778 v1.setDrawingCacheEnabled(false);
15779
15780 try
15781 {
15782 if (out != null)
15783 {
15784 out.close();
15785 }
15786 }
15787 catch (IOException e)
15788 {
15789 e.printStackTrace();
15790 }
15791 }
15792 }
15793 catch (Exception e4)
15794 {
15795 }
15796 }
15797
15798 static void take_phone_screenshot(Activity a, String dir_name, String name_base)
15799 {
15800 try
15801 {
15802 View v1 = a.getWindow().getDecorView().getRootView();
15803 v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
15804 v1.setDrawingCacheEnabled(true);
15805 Bitmap bm = v1.getDrawingCache();
15806
15807 FileOutputStream out = null;
15808 try
15809 {
15810 out = new FileOutputStream(dir_name + "/" + name_base + ".png");
15811 bm.compress(Bitmap.CompressFormat.PNG, 100, out);
15812 }
15813 catch (Exception e)
15814 {
15815 e.printStackTrace();
15816 System.out.println("TSCR:004 " + e.getMessage());
15817 }
15818 finally
15819 {
15820 v1.setDrawingCacheEnabled(false);
15821
15822 try
15823 {
15824 if (out != null)
15825 {
15826 out.close();
15827 }
15828 }
15829 catch (IOException e)
15830 {
15831 e.printStackTrace();
15832 }
15833 }
15834 }
15835 catch (Exception e4)
15836 {
15837 }
15838 }
15839
15840 static String stacktrace_to_string(Exception e)
15841 {
15842 try
15843 {
15844 StringWriter errors = new StringWriter();
15845 e.printStackTrace(new PrintWriter(errors));
15846 return errors.toString();
15847 }
15848 catch (Exception e2)
15849 {
15850 try
15851 {
15852 return e.getMessage();
15853 }
15854 catch (Exception e3)
15855 {
15856 return "xxx";
15857 }
15858 }
15859 }
15860
15861 static void static_show_route_graph(int v)
15862 {
15863 // DEBUG: toggle Routgraph on/off
15864 try
15865 {
15866 if (v == 1)
15867 {
15868 Navit.Routgraph_enabled = 1;
15869
15870 Message msg = new Message();
15871 Bundle b = new Bundle();
15872 b.putInt("Callback", 71);
15873 b.putString("s", "" + Navit.Routgraph_enabled);
15874 msg.setData(b);
15875 NavitGraphics.callback_handler.sendMessage(msg);
15876 }
15877 else if (v == 0)
15878 {
15879 Navit.Routgraph_enabled = 0;
15880
15881 Message msg = new Message();
15882 Bundle b = new Bundle();
15883 b.putInt("Callback", 71);
15884 b.putString("s", "" + Navit.Routgraph_enabled);
15885 msg.setData(b);
15886 NavitGraphics.callback_handler.sendMessage(msg);
15887 }
15888 else
15889 {
15890 Navit.Routgraph_enabled = 0;
15891
15892 Message msg = new Message();
15893 Bundle b = new Bundle();
15894 b.putInt("Callback", 71);
15895 b.putString("s", "" + Navit.Routgraph_enabled);
15896 msg.setData(b);
15897 NavitGraphics.callback_handler.sendMessage(msg);
15898
15899 Thread.sleep(350);
15900
15901 System.out.println("static_show_route_graph:v=" + v);
15902
15903 msg = new Message();
15904 b = new Bundle();
15905 b.putInt("Callback", 71);
15906 b.putString("s", "" + v);
15907 msg.setData(b);
15908 NavitGraphics.callback_handler.sendMessage(msg);
15909 }
15910 }
15911 catch (Exception e)
15912 {
15913 }
15914
15915 }
15916
15917 /*
15918 * start a search with given values
15919 */
15920 static void executeSearch_with_values(String street, String town, String hn, boolean offline, boolean index, boolean partialmatch, boolean hide_dupl)
15921 {
15922 Intent search_intent = new Intent(Global_Navit_Object, NavitAddressSearchActivity.class);
15923 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
15924 String addr1 = "";
15925 String addr2 = "";
15926
15927 if ((town != null) && (street != null))
15928 {
15929 if (index)
15930 {
15931 search_intent.putExtra("address_string", street + " " + town);
15932 addr1 = street + " " + town;
15933 addr2 = street + " " + town;
15934 }
15935 else
15936 {
15937 search_intent.putExtra("address_string", town + " " + street);
15938 addr1 = town + " " + street;
15939 addr2 = town + " " + street;
15940 }
15941 }
15942 else if (town != null)
15943 {
15944 search_intent.putExtra("address_string", town);
15945 addr1 = town;
15946 addr2 = town;
15947 }
15948 else if (street != null)
15949 {
15950 search_intent.putExtra("address_string", street);
15951 addr1 = street;
15952 addr2 = street;
15953 }
15954
15955 if (hn != null)
15956 {
15957 search_intent.putExtra("hn_string", hn);
15958 }
15959
15960 if (offline)
15961 {
15962 search_intent.putExtra("type", "offline");
15963 }
15964 else
15965 {
15966 search_intent.putExtra("type", "online");
15967 }
15968
15969 String pm_temp = "0";
15970 if (partialmatch)
15971 {
15972 pm_temp = "1";
15973 }
15974 search_intent.putExtra("partial_match", pm_temp);
15975
15976 if (index)
15977 {
15978 Navit_last_address_partial_match = partialmatch;
15979 Navit_last_address_search_string = addr2;
15980 Navit_last_address_hn_string = hn;
15981 Navit_last_address_full_file_search = false;
15982 search_hide_duplicates = hide_dupl;
15983 Global_Navit_Object.startActivityForResult(search_intent, NavitAddressSearch_id_offline);
15984 }
15985 else
15986 {
15987 Navit_last_address_partial_match = partialmatch;
15988 Navit_last_address_search_string = addr1;
15989 Navit_last_address_hn_string = hn;
15990 Navit_last_address_full_file_search = false;
15991 search_hide_duplicates = hide_dupl;
15992
15993 // only from offline mask!
15994 // { "*A", "*AA", "*ALL*" }
15995 Navit_last_address_search_country_iso2_string = "*A";
15996 Navit_last_address_search_country_flags = 3;
15997 Navit_last_address_search_country_id = 1; // default=*ALL*
15998 p.PREF_search_country = Navit_last_address_search_country_id;
15999 setPrefs_search_country();
16000
16001 // show duplicates in search ------------
16002 Message msg2 = new Message();
16003 Bundle b2 = new Bundle();
16004 b2.putInt("Callback", 44);
16005 msg2.setData(b2);
16006 NavitGraphics.callback_handler.sendMessage(msg2);
16007 // show duplicates in search ------------
16008
16009 if (hide_dupl)
16010 {
16011 search_hide_duplicates = true;
16012 // hide duplicates when searching
16013 // hide duplicates when searching
16014 Message msg22 = new Message();
16015 Bundle b22 = new Bundle();
16016 b22.putInt("Callback", 45);
16017 msg22.setData(b22);
16018 NavitGraphics.callback_handler.sendMessage(msg22);
16019 // hide duplicates when searching
16020 // hide duplicates when searching
16021 }
16022
16023 System.out.println("dialog -- 11:001");
16024 Message msg = Navit_progress_h.obtainMessage();
16025 Bundle b = new Bundle();
16026 msg.what = 11;
16027 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
16028 msg.setData(b);
16029 Navit_progress_h.sendMessage(msg);
16030 }
16031 }
16032
16033 }

   
Visit the ZANavi Wiki