/[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 45 - (show annotations) (download)
Fri Aug 14 14:29:16 2015 UTC (8 years, 8 months ago) by zoff99
File size: 458581 byte(s)
quick update for message
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.Reader;
53 import java.io.Serializable;
54 import java.net.URL;
55 import java.net.URLDecoder;
56 import java.nio.channels.FileChannel;
57 import java.text.DecimalFormat;
58 import java.text.SimpleDateFormat;
59 import java.util.ArrayList;
60 import java.util.Calendar;
61 import java.util.Collections;
62 import java.util.Date;
63 import java.util.HashSet;
64 import java.util.Iterator;
65 import java.util.List;
66 import java.util.Locale;
67 import java.util.Map;
68 import java.util.Random;
69 import java.util.Set;
70 import java.util.TimeZone;
71 import java.util.concurrent.LinkedBlockingQueue;
72
73 import org.json.JSONArray;
74 import org.json.JSONObject;
75 import org.xml.sax.InputSource;
76
77 import android.annotation.SuppressLint;
78 import android.annotation.TargetApi;
79 import android.app.Activity;
80 import android.app.AlertDialog;
81 import android.app.Dialog;
82 import android.app.Notification;
83 import android.app.NotificationManager;
84 import android.app.PendingIntent;
85 import android.app.ProgressDialog;
86 import android.app.backup.BackupManager;
87 import android.content.ActivityNotFoundException;
88 import android.content.ComponentName;
89 import android.content.ContentResolver;
90 import android.content.Context;
91 import android.content.DialogInterface;
92 import android.content.DialogInterface.OnCancelListener;
93 import android.content.Intent;
94 import android.content.ServiceConnection;
95 import android.content.SharedPreferences;
96 import android.content.pm.PackageInfo;
97 import android.content.pm.PackageManager.NameNotFoundException;
98 import android.content.res.AssetManager;
99 import android.content.res.Configuration;
100 import android.content.res.Resources;
101 import android.database.Cursor;
102 import android.graphics.Bitmap;
103 import android.graphics.BitmapFactory;
104 import android.graphics.Color;
105 import android.graphics.Paint;
106 import android.graphics.Rect;
107 import android.graphics.RectF;
108 import android.graphics.Typeface;
109 import android.hardware.Sensor;
110 import android.hardware.SensorEvent;
111 import android.hardware.SensorEventListener;
112 import android.hardware.SensorManager;
113 import android.location.Address;
114 import android.location.Geocoder;
115 import android.location.GpsStatus;
116 import android.location.Location;
117 import android.location.LocationManager;
118 import android.media.AudioManager;
119 import android.media.AudioManager.OnAudioFocusChangeListener;
120 import android.media.ToneGenerator;
121 import android.net.Uri;
122 import android.os.AsyncTask;
123 import android.os.Build;
124 import android.os.Bundle;
125 import android.os.Debug;
126 import android.os.Environment;
127 import android.os.Handler;
128 import android.os.IBinder;
129 import android.os.Looper;
130 import android.os.Message;
131 import android.os.PowerManager;
132 import android.os.RemoteException;
133 import android.os.SystemClock;
134 import android.preference.PreferenceManager;
135 import android.speech.tts.TextToSpeech;
136 import android.support.v4.app.FragmentManager;
137 import android.support.v4.app.FragmentTransaction;
138 import android.support.v7.app.ActionBar;
139 import android.support.v7.app.ActionBarActivity;
140 import android.support.v7.widget.Toolbar;
141 import android.text.Html;
142 import android.text.SpannableString;
143 import android.text.method.LinkMovementMethod;
144 import android.text.util.Linkify;
145 import android.util.DisplayMetrics;
146 import android.util.Log;
147 import android.util.TypedValue;
148 import android.view.Display;
149 import android.view.GestureDetector;
150 import android.view.GestureDetector.SimpleOnGestureListener;
151 import android.view.Gravity;
152 import android.view.KeyEvent;
153 import android.view.Menu;
154 import android.view.MenuItem;
155 import android.view.MotionEvent;
156 import android.view.View;
157 import android.view.ViewConfiguration;
158 import android.view.ViewTreeObserver;
159 import android.view.ViewTreeObserver.OnGlobalLayoutListener;
160 import android.view.Window;
161 import android.view.WindowManager;
162 import android.view.animation.Animation;
163 import android.view.animation.Animation.AnimationListener;
164 import android.view.animation.TranslateAnimation;
165 import android.view.inputmethod.InputMethodManager;
166 import android.widget.Button;
167 import android.widget.FrameLayout;
168 import android.widget.ImageView;
169 import android.widget.LinearLayout;
170 import android.widget.RelativeLayout;
171 import android.widget.TextView;
172 import android.widget.Toast;
173 import bpi.sdbm.illuminance.SolarPosition;
174
175 import com.lamerman.FileDialog;
176 import com.lamerman.SelectionMode;
177 import com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator;
178 import com.luckycatlabs.sunrisesunset.calculator.SolarEventCalculator;
179 import com.luckycatlabs.sunrisesunset.dto.Location2;
180 import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
181 import com.zoffcc.applications.zanavi.NavitOSDJava.drawOSDThread;
182 import com.zoffcc.applications.zanavi.NavitVehicle.location_coords;
183 import com.zoffcc.applications.zanavi.ZANaviListViewAdapter.ListViewItem;
184 import com.zoffcc.applications.zanavi_msg.ZanaviCloudApi;
185
186 import de.oberoner.gpx2navit_txt.MainFrame;
187
188 public class Navit extends ActionBarActivity implements Handler.Callback, SensorEventListener
189 {
190 public static final String VERSION_TEXT_LONG_INC_REV = "3581";
191 public static String NavitAppVersion = "0";
192 public static String NavitAppVersion_prev = "-1";
193 public static String NavitAppVersion_string = "0";
194 public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
195 public static boolean has_hw_menu_button = false;
196 static int NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR = 400;
197 static int actionbar_item_width = 100;
198 static int actionbar_items_will_fit = 2;
199 static boolean actionbar_all_items_will_fit = false;
200 static boolean actionabar_download_icon_visible = false;
201 static boolean is_navigating = false;
202 static boolean is_paused = true;
203
204 static int api_version_int = 6;
205
206 static boolean PAINT_OLD_API = true;
207
208 static long SHOWCASEVIEW_ID_001 = 93457181726L;
209
210 //static final int DEFAULT_THEME_DARK = android.R.style.Theme_WithActionBar;
211 //static final int DEFAULT_THEME_LIGHT = android.R.style.Theme_Material_Light;
212 static final int DEFAULT_THEME_OLD_LIGHT = R.style.CustomActionBarThemeLight;
213 static final int DEFAULT_THEME_OLD_DARK = R.style.CustomActionBarTheme;
214
215 static final int DEFAULT_THEME_OLD_LIGHT_M = R.style.CustomActionBarThemeLightM;
216 static final int DEFAULT_THEME_OLD_DARK_M = R.style.CustomActionBarThemeM;
217
218 // GLSurfaceView glSurfaceView;
219
220 static int OSD_blueish_bg_color = 0;
221
222 // ----------------- DEBUG ----------------
223 // ----------------- DEBUG ----------------
224 // ----------------- DEBUG ----------------
225 static final boolean METHOD_DEBUG = false; // for debugging only, set this to "false" on release builds!!
226 static final boolean DEBUG_DRAW_VEHICLE = true; // if "false" then dont draw green vehicle, set this to "true" on release builds!!
227 static final boolean NAVIT_ALWAYS_UNPACK_XMLFILE = false; // always unpacks the navit.xml file, set this to "false" on release builds!!
228 static final boolean NAVIT_DEBUG_TEXT_VIEW = false; // show overlay with debug messages, set this to "false" on release builds!!
229 static final boolean GFX_OVERSPILL = true; // make gfx canvas bigger for rotation and zoom smoothness
230 // ----------------- DEBUG ----------------
231 // ----------------- DEBUG ----------------
232 // ----------------- DEBUG ----------------
233
234 // ----------------------------------------
235 // ----------------------------------------
236 static final boolean FDBL = false;
237 // ----------------------------------------
238 // ----------------------------------------
239
240 static final float OVERSPILL_FACTOR = 1.4f; // 20% percent on each side
241
242 // ------------------ BitCoin Addr --------
243 // ------------------ BitCoin Addr --------
244 // ------------------ BitCoin Addr --------
245 final static String BITCOIN_DONATE_ADDR = "1ZANav18WY8ytM7bhnAEBS3bdrTohsD9p";
246 // ------------------ BitCoin Addr --------
247 // ------------------ BitCoin Addr --------
248 // ------------------ BitCoin Addr --------
249
250 private static ZanaviCloudApi plugin_api = null;
251 static final int PLUGIN_MSG_ID = 1;
252 static final int PLUGIN_MSG_CAT_zanavi_version = 1;
253 static final int PLUGIN_MSG_CAT_installed_maps = 2;
254 static final int PLUGIN_MSG_CAT_3d_mode = 3;
255
256 static ZANaviPrefs p = new ZANaviPrefs();
257 static ZANaviPrefs p_old = new ZANaviPrefs();
258 static final int STREET_SEARCH_STRINGS_SAVE_COUNT = 10;
259
260 // static AnimationDrawable mFrameAnimation;
261 static Menu cur_menu = null;
262
263 static long NAVIT_START_INTENT_DRIVE_HOME = 1L;
264
265 static final int NAVIT_BACKBUTTON_TO_EXIT_TIME = 2000; // 2 secs.
266
267 static int NavitOverflowMenuItemID = -1;
268
269 static ContentResolver content_resolver = null;
270 public static final String CR_AUTHORITY = "com.zoffcc.applications.zanavi_udonate.provider";
271 public static final Uri CR_CONTENT_URI = Uri.parse("content://" + CR_AUTHORITY + "/" + "table1");
272
273 public static Intent ZANaviMapDownloaderServiceIntent = null;
274
275 static float last_y_bottom_bar_touch = 0;
276 static float cur_y_margin_bottom_bar_touch = 0;
277 static int map_view_height = 100;
278 static float bottom_y_margin_bottom_bar_touch = 0;
279 static int actionBarHeight = 0;
280 static int bottom_bar_px = 80;
281 static int bottom_bar_slider_shadow_px = 4;
282 static GestureDetector mGestureDetector = null;
283 static int swipeMaxOffPath = 20;
284 static ZANaviRoadbookFragment road_book = null;
285 static FragmentManager fragmentManager = null;
286 static ImageView push_pin_view = null;
287 static List<ListViewItem> road_book_items = null;
288
289 TextToSpeech mTts = null;
290
291 static ToneGenerator toneG = null;
292 static boolean toneG_heared = false;
293
294 public static int Global_Init_Finished = 0; // 0 -> no init
295 // 1 -> all C structures are ready for use
296 public static int Global_Location_update_not_allowed = 0; // 0 -> send location update to C functions
297 // 1 -> DO NOT send location update to C functions, it may crash in this phase
298
299 //static BackupManager backupManager = null;
300 static Object backupManager = null;
301
302 // AlertDialog dialog_info_popup = null;
303 Dialog dialog_info_popup = null;
304 int info_popup_seen_count = 0;
305 final int info_popup_seen_count_max = 2; // must look at the info pop 2 times
306 boolean info_popup_seen_count_end = false;
307
308 static Navit Global_Navit_Object = null;
309 static AssetManager asset_mgr = null;
310
311 static boolean Navit_doubleBackToExitPressedOnce = false;
312
313 // define graphics here (this is bad, please fix me!)
314 public static NavitGraphics N_NavitGraphics = null;
315
316 public static int usedMegs_old = -1;
317 public static String usedMegs_str_old = "";
318 public static int Routgraph_enabled = 0;
319
320 // -------- SUN / MOON ----------
321 long sun_moon__mLastCalcSunMillis = -1L;
322 public double azmiuth_cache = -1;
323 public double zenith_cache = -1;
324 public static String sunrise_cache = "";
325 public static boolean is_night = false;
326 public static boolean is_twilight = false;
327 public static String sunset_cache = "";
328 public static double elevation = 0;
329 public double moon_azimuth_cache = -1;
330 public double moon_evelation_cache = -1;
331 Boolean sun_moon__must_calc_new = true;
332 SunriseSunsetCalculator sun_moon__calc = null;
333 Calendar sun_moon__cx = null;
334 SolarPosition.SunCoordinates sun_moon__sc = null;
335 public static boolean calc_sun_enabled = true;
336 // -------- SUN / MOON ----------
337
338 public static CWorkerThread cwthr = null;
339 public static NavitGraphics NG__map_main = null;
340 public static NavitGraphics NG__vehicle = null;
341 public static NavitVehicle NV = null;
342 public static NavitSpeech2 NSp = null;
343 public static drawOSDThread draw_osd_thread = null;
344
345 public static boolean use_index_search = false;
346 public static boolean index_search_realtime = false;
347
348 static AlertDialog.Builder generic_alert_box = null;
349
350 private Boolean xmlconfig_unpack_file = true;
351 private Boolean write_new_version_file = true;
352 final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
353 final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
354 final static int Navit_Status_NORMAL_STARTUP = 0;
355 static Boolean Navit_DonateVersion_Installed = false;
356 static Boolean Navit_Plugin_001_Installed = false;
357 static Boolean Navit_index_on_but_no_idx_files = false;
358 static Boolean Navit_maps_too_old = false;
359 static Boolean Navit_Largemap_DonateVersion_Installed = false;
360 private int startup_status = Navit_Status_NORMAL_STARTUP;
361 final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
362 static Boolean unsupported = false;
363 static Boolean Navit_maps_loaded = false;
364 final static int Navit_MAX_RECENT_DESTINATIONS = 50;
365 static String debug_item_dump = "";
366
367 // for future use ...
368 // public static String NavitDataDirectory = "/sdcard/";
369 public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
370 static File[] NavitDataStorageDirs = null;
371
372 public static int GlobalScaleLevel = 0;
373
374 public class CopyFiles
375 {
376 public void copyFiles(File sourceLocation, File targetLocation) throws IOException
377 {
378 if (sourceLocation.isDirectory())
379 {
380 if (!targetLocation.exists())
381 {
382 targetLocation.mkdir();
383 }
384 File[] files = sourceLocation.listFiles();
385 for (File file : files)
386 {
387 InputStream in = new FileInputStream(file);
388 OutputStream out = new FileOutputStream(targetLocation + "/" + file.getName());
389
390 // Copy the bits from input stream to output stream
391 byte[] buf = new byte[1024];
392 int len;
393 while ((len = in.read(buf)) > 0)
394 {
395 out.write(buf, 0, len);
396 }
397 in.close();
398 out.close();
399 }
400
401 }
402 }
403 }
404
405 private static void copyFile(File sourceFile, File destFile) throws IOException
406 {
407 if (!sourceFile.exists())
408 {
409 return;
410 }
411 if (!destFile.exists())
412 {
413 destFile.createNewFile();
414 }
415 FileChannel source = null;
416 FileChannel destination = null;
417 source = new FileInputStream(sourceFile).getChannel();
418 destination = new FileOutputStream(destFile).getChannel();
419 if (destination != null && source != null)
420 {
421 destination.transferFrom(source, 0, source.size());
422 }
423 if (source != null)
424 {
425 source.close();
426 }
427 if (destination != null)
428 {
429 destination.close();
430 }
431
432 }
433
434 public static final class Navit_Address_Result_Struct implements Comparable<Navit_Address_Result_Struct>
435 {
436 String result_type; // TWN,STR,SHN
437 String item_id; // H<ddddd>L<ddddd> -> item.id_hi item.id_lo
438 float lat;
439 float lon;
440 String addr;
441
442 // function to sort address result list
443 public int compareTo(Navit_Address_Result_Struct comp)
444 {
445 return this.addr.toLowerCase().compareTo(comp.addr.toLowerCase());
446 }
447 }
448
449 public static final class Navit_Point_on_Map implements Serializable
450 {
451 /**
452 * struct for a point on the map
453 */
454 private static final long serialVersionUID = 6899215049749155051L;
455 String point_name = "";
456 String addon = null; // null -> normal, "1" -> home location
457 float lat = 0.0f;
458 float lon = 0.0f;
459 }
460
461 static ArrayList<Navit_Point_on_Map> map_points;
462
463 public static Set<String> Navit_Address_Result_double_index = new HashSet<String>();
464
465 public NavitAndroidOverlay NavitAOverlay2;
466 public static NavitAndroidOverlay NavitAOverlay2_s;
467
468 public static final class Navit_OSD_compass
469 {
470 Boolean angle_north_valid = false;
471 float angle_north = 0.0f;
472 Boolean angle_target_valid = false;
473 float angle_target = 0.0f;
474 Boolean direct_distance_to_target_valid = false;
475 String direct_distance_to_target = "";
476 }
477
478 public static final class Navit_OSD_route_001
479 {
480 Boolean driving_distance_to_target_valid = false;
481 String driving_distance_to_target = "";
482 Boolean arriving_time_valid = false;
483 String arriving_time = "";
484 Boolean arriving_secs_to_dest_valid = false;
485 String arriving_secs_to_dest = "";
486 }
487
488 public static final class Navit_OSD_route_nextturn
489 {
490 Boolean nextturn_image_filename_valid = false;
491 String nextturn_image_filename = "";
492 Boolean nextturn_image_valid = false;
493 Bitmap nextturn_image = null;
494 Boolean nextturn_distance_valid = false;
495 String nextturn_distance = "";
496 String nextturn_streetname = "";
497 String nextturn_streetname_systematic = "";
498 }
499
500 public static final class Navit_OSD_scale
501 {
502 Boolean scale_valid = false;
503 String scale_text = "";
504 int base = 0;
505 int var = 0;
506 }
507
508 public static Navit_OSD_compass OSD_compass = new Navit_OSD_compass();
509 public static Navit_OSD_route_001 OSD_route_001 = new Navit_OSD_route_001();
510 public static Navit_OSD_route_nextturn OSD_nextturn = new Navit_OSD_route_nextturn();
511 public static Navit_OSD_scale OSD_scale = new Navit_OSD_scale();
512
513 SimGPS Simulate = null;
514 WatchMem watchmem = null;
515
516 public static int sats = 0;
517 public static int satsInFix = 0;
518
519 // -------------- GPS fix and extrapolation vars -------------
520 // -------------- GPS fix and extrapolation vars -------------
521 // -------------- GPS fix and extrapolation vars -------------
522 static Location mLastLocation = null;
523 static long mLastLocationMillis = -1;
524 static boolean isGPSFix = false;
525 static int pos_is_underground = 0;
526 static boolean tunnel_extrapolation = false;
527 // -------------- GPS fix and extrapolation vars -------------
528 // -------------- GPS fix and extrapolation vars -------------
529 // -------------- GPS fix and extrapolation vars -------------
530
531 // public static Vibrator vibrator = null;
532
533 public Handler handler;
534 static PowerManager.WakeLock wl;
535 static PowerManager.WakeLock wl_cpu;
536 static PowerManager.WakeLock wl_navigating;
537 private NavitActivityResult ActivityResults[];
538 static AudioManager NavitAudioManager = null;
539 public static InputMethodManager mgr = null;
540 public static DisplayMetrics metrics = null;
541 public static Boolean show_soft_keyboard = false;
542 public static Boolean show_soft_keyboard_now_showing = false;
543 public static long last_pressed_menu_key = 0L;
544 public static long time_pressed_menu_key = 0L;
545 private static Intent startup_intent = null;
546 private static long startup_intent_timestamp = 0L;
547 public static String my_display_density = "mdpi";
548 private boolean searchBoxShown = false;
549 public static final int MAPDOWNLOAD_PRI_DIALOG = 1;
550 public static final int MAPDOWNLOAD_SEC_DIALOG = 2;
551 public static final int SEARCHRESULTS_WAIT_DIALOG = 3;
552 public static final int SEARCHRESULTS_WAIT_DIALOG_OFFLINE = 4;
553 public static final int ADDRESS_RESULTS_DIALOG_MAX = 10;
554 public ProgressDialog mapdownloader_dialog_pri = null;
555 public ProgressDialog mapdownloader_dialog_sec = null;
556 public ProgressDialog search_results_wait = null;
557 public ProgressDialog search_results_wait_offline = null;
558 public static Handler Navit_progress_h = null;
559 public static NavitMapDownloader mapdownloader_pri = null;
560 public static NavitMapDownloader mapdownloader_sec = null;
561 public static final int NavitDownloaderPriSelectMap_id = 967;
562 public static final int NavitDownloaderSecSelectMap_id = 968;
563 public static final int NavitDeleteSecSelectMap_id = 969;
564 public static final int NavitRecentDest_id = 970;
565 public static final int NavitGeoCoordEnter_id = 971;
566 public static final int NavitGPXConvChooser_id = 972;
567 public static final int NavitSendFeedback_id = 973;
568 public static final int NavitReplayFileConvChooser_id = 974;
569 public static int download_map_id = 0;
570 ProgressThread progressThread_pri = null;
571 ProgressThread progressThread_sec = null;
572 public static int search_results_towns = 0;
573 public static int search_results_streets = 0;
574 public static int search_results_streets_hn = 0;
575 public static int search_results_poi = 0;
576 public static Boolean search_hide_duplicates = false;
577 public static Boolean NavitStartupAlreadySearching = false;
578 SearchResultsThread searchresultsThread = null;
579 SearchResultsThread searchresultsThread_offline = null;
580 SearchResultsThreadSpinnerThread spinner_thread = null;
581 SearchResultsThreadSpinnerThread spinner_thread_offline = null;
582 public static Boolean NavitAddressSearchSpinnerActive = false;
583 public static final int MAP_NUM_PRIMARY = 11;
584 public static final int NavitAddressSearch_id_offline = 70;
585 public static final int NavitAddressSearch_id_online = 73;
586 public static final int NavitAddressResultList_id = 71;
587 public static final int NavitAddressSearchCountry_id = 74;
588 public static final int NavitMapPreview_id = 75;
589 public static final int NavitAddressSearch_id_gmaps = 76;
590 public static final int NavitAddressSearch_id_sharedest = 77;
591 public static final int ZANaviVoiceInput_id = 78;
592 public static final int NavitDonateFromSearch_id = 79;
593 public static int NavitSearchresultBarIndex = -1;
594 public static String NavitSearchresultBar_title = "";
595 public static String NavitSearchresultBar_text = "";
596 public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();
597
598 public static Boolean DemoVehicle = false;
599
600 static Typeface NavitStreetnameFont = null;
601
602 public SensorManager sensorManager = null;
603 //private static SensorManager sensorManager_ = null;
604
605 public static Context getBaseContext_ = null;
606 public static GpsStatus gps_st = null;
607
608 static Bitmap lane_none = null;
609 static Bitmap lane_left = null;
610 static Bitmap lane_right = null;
611 static Bitmap lane_merge_to_left = null;
612 static Bitmap lane_merge_to_right = null;
613 static String lane_destination = "";
614 static String lanes_text = "";
615 static String lanes_text1 = "";
616 static String lane_choices = "";
617 static String lane_choices1 = "";
618 static String lane_choices2 = "";
619 static int lanes_num = 0;
620 static int lanes_num_forward = 0;
621 static int lanes_num1 = 0;
622 static int lanes_num_forward1 = 0;
623 static int seg_len = 0;
624 static int cur_max_speed = -1;
625 static int cur_max_speed_corr = -1;
626 static boolean your_are_speeding = false;
627
628 // ------- new features -----------
629 // ------- new features -----------
630 // ------- new features -----------
631 // static boolean new_features = false; // for development ONLY !!
632 // ------- new features -----------
633 // ------- new features -----------
634 // ------- new features -----------
635
636 public static Bitmap long_green_arrow = null;
637 public static Bitmap menu_button = null;
638 public static RectF menu_button_rect = new RectF(-100, 1, 1, 1);
639 public static RectF menu_button_rect_touch = new RectF(-100, 1, 1, 1);
640 public static Bitmap follow_on = null;
641 public static Bitmap follow_off = null;
642 public static Bitmap follow_current = null;
643 public static Bitmap zoomin = null;
644 public static Bitmap zoomout = null;
645 // public static Bitmap bigmap_bitmap = null;
646 public static Bitmap oneway_arrow = null;
647 public static Bitmap oneway_bicycle_arrow = null;
648 public static Bitmap nav_arrow_stopped = null;
649 public static Bitmap nav_arrow_stopped_small = null;
650 public static Bitmap nav_arrow_moving = null;
651 public static Bitmap nav_arrow_moving_grey = null;
652 public static Bitmap nav_arrow_moving_small = null;
653 public static Bitmap nav_arrow_moving_shadow = null;
654 public static Bitmap nav_arrow_moving_shadow_small = null;
655
656 public static String Navit_last_address_search_string = "";
657 public static String Navit_last_address_hn_string = "";
658 public static Boolean Navit_last_address_full_file_search = false;
659 public static String Navit_last_address_search_country_iso2_string = "";
660 public static int Navit_last_address_search_country_flags = 3;
661 public static int Navit_last_address_search_country_id = 0;
662 public static Boolean Navit_last_address_partial_match = true;
663 public static Geocoder Navit_Geocoder = null;
664 public static String UserAgentString = null;
665 public static String UserAgentString_bind = null;
666 public static Boolean first_ever_startup = false;
667
668 public static Boolean Navit_Announcer = true;
669
670 public static final int MAP_NUM_SECONDARY = 12;
671 static String MAP_FILENAME_PATH = "/sdcard/zanavi/maps/";
672 static String MAPMD5_FILENAME_PATH = "/sdcard/zanavi/md5/";
673 static String CFG_FILENAME_PATH = "/sdcard/zanavi/";
674 static String NAVIT_DATA_DIR = "/data/data/com.zoffcc.applications.zanavi"; // later use: Context.getFilesDir().getPath();
675 static String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
676 static String NAVIT_DATA_DEBUG_DIR = CFG_FILENAME_PATH + "../debug/";
677 static String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
678 static String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
679 static final String Navit_DEST_FILENAME = "destinations.dat";
680 static final String Navit_CENTER_FILENAME = "center.txt";
681
682 static boolean need_recalc_route = false;
683
684 static Resources res_ = null;
685 static Window app_window = null;
686
687 public static String get_text(String in)
688 {
689 return NavitTextTranslations.get_text(in);
690 }
691
692 private boolean extractRes(String resname, String result)
693 {
694 int slash = -1;
695 boolean needs_update = false;
696 File resultfile;
697 Resources res = getResources();
698 Log.e("Navit", "Res Obj " + res);
699 Log.e("Navit", "Res Name " + resname);
700 Log.e("Navit", "result " + result);
701 int id = res.getIdentifier(resname, "raw", "com.zoffcc.applications.zanavi");
702 // int id = res.getIdentifier(resname, "raw", getPackageName());
703
704 Log.e("Navit", "Res ID " + id);
705
706 if (id == 0)
707 {
708 return false;
709 }
710
711 while ((slash = result.indexOf("/", slash + 1)) != -1)
712 {
713 if (slash != 0)
714 {
715 Log.e("Navit", "Checking " + result.substring(0, slash));
716 resultfile = new File(result.substring(0, slash));
717 if (!resultfile.exists())
718 {
719 Log.e("Navit", "Creating dir");
720 if (!resultfile.mkdir()) return false;
721 needs_update = true;
722 }
723 }
724 }
725
726 resultfile = new File(result);
727
728 if (!resultfile.exists())
729 {
730 needs_update = true;
731 }
732
733 if (!needs_update)
734 {
735 try
736 {
737 InputStream resourcestream = res.openRawResource(id);
738 FileInputStream resultfilestream = new FileInputStream(resultfile);
739 byte[] resourcebuf = new byte[1024];
740 byte[] resultbuf = new byte[1024];
741 int i = 0;
742
743 while ((i = resourcestream.read(resourcebuf)) != -1)
744 {
745 if (resultfilestream.read(resultbuf) != i)
746 {
747 Log.e("Navit", "Result is too short");
748 needs_update = true;
749 break;
750 }
751
752 for (int j = 0; j < i; j++)
753 {
754 if (resourcebuf[j] != resultbuf[j])
755 {
756 Log.e("Navit", "Result is different");
757 needs_update = true;
758 break;
759 }
760 }
761 if (needs_update) break;
762 }
763
764 if (!needs_update && resultfilestream.read(resultbuf) != -1)
765 {
766 Log.e("Navit", "Result is too long");
767 needs_update = true;
768 }
769
770 if (resultfilestream != null)
771 {
772 resultfilestream.close();
773 }
774 }
775 catch (Exception e)
776 {
777 Log.e("Navit", "Exception " + e.getMessage());
778 return false;
779 }
780 }
781
782 if (needs_update)
783 {
784 Log.e("Navit", "Extracting resource");
785 try
786 {
787 InputStream resourcestream = res.openRawResource(id);
788 FileOutputStream resultfilestream = new FileOutputStream(resultfile);
789 byte[] buf = new byte[1024];
790 int i = 0;
791
792 while ((i = resourcestream.read(buf)) != -1)
793 {
794 resultfilestream.write(buf, 0, i);
795 }
796
797 if (resultfilestream != null)
798 {
799 resultfilestream.close();
800 }
801 }
802 catch (Exception e)
803 {
804 Log.e("Navit", "Exception " + e.getMessage());
805 return false;
806 }
807 }
808 return true;
809 }
810
811 static OnAudioFocusChangeListener focusChangeListener = new OnAudioFocusChangeListener()
812 {
813 public void onAudioFocusChange(int focusChange)
814 {
815 // AudioManager am = Navit.NavitAudioManager;
816 switch (focusChange)
817 {
818
819 case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK):
820 // Lower the volume while ducking.
821 //mediaPlayer.setVolume(0.2f, 0.2f);
822 break;
823 case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT):
824 //pause();
825 break;
826
827 case (AudioManager.AUDIOFOCUS_LOSS):
828 //stop();
829 //ComponentName component = new ComponentName(AudioPlayerActivity.this, MediaControlReceiver.class);
830 //am.unregisterMediaButtonEventReceiver(component);
831 break;
832
833 case (AudioManager.AUDIOFOCUS_GAIN):
834 // Return the volume to normal and resume if paused.
835 //mediaPlayer.setVolume(1f, 1f);
836 //mediaPlayer.start();
837 break;
838 default:
839 break;
840 }
841 }
842 };
843
844 // private boolean checkPlayServices()
845
846 // {
847 // int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
848 //
849 // Log.i("PlayServices", "isGooglePlayServicesAvailable=" + status);
850 //
851 // if (status != ConnectionResult.SUCCESS)
852 // {
853 // if (GooglePlayServicesUtil.isUserRecoverableError(status))
854 // {
855 // Toast.makeText(this, "Recoverable error.", Toast.LENGTH_LONG).show();
856 // // showErrorDialog(status);
857 // }
858 // else
859 // {
860 // Toast.makeText(this, "This device is not supported.", Toast.LENGTH_LONG).show();
861 // }
862 // return false;
863 // }
864 // return true;
865 // }
866
867 // ----------------------------------------------------------------------------------------------------------
868 // thanks to: http://stackoverflow.com/questions/843675/how-do-i-find-out-if-the-gps-of-an-android-device-is-enabled
869 // ----------------------------------------------------------------------------------------------------------
870 private void buildAlertMessageNoGps()
871 {
872 try
873 {
874 AlertDialog.Builder builder = new AlertDialog.Builder(this);
875 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()
876 {
877 public void onClick(final DialogInterface dialog, final int id)
878 {
879 startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
880 }
881 }).setNegativeButton(Navit.get_text("No"), new DialogInterface.OnClickListener()
882 {
883 public void onClick(final DialogInterface dialog, final int id)
884 {
885 dialog.cancel();
886 }
887 });
888 AlertDialog alert = builder.create();
889 alert.show();
890 }
891 catch (Exception e)
892 {
893 e.printStackTrace();
894 }
895 }
896
897 /** Called when the activity is first created. */
898
899 // ----------- remove later -------------
900 // ----------- remove later -------------
901 @SuppressLint("NewApi")
902 // ----------- remove later -------------
903 // ----------- remove later -------------
904 @TargetApi(Build.VERSION_CODES.FROYO)
905 @Override
906 public void onCreate(Bundle savedInstanceState)
907 {
908 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
909
910 // ------- only after API level 9 -------
911 // ------- only after API level 9 -------
912 // try
913 // {
914 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDeath().penaltyLog().build());
915 // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
916 //
917 // StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
918 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskWrites().build());
919 // old = StrictMode.getThreadPolicy();
920 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskReads().build());
921 //
922 // }
923 // catch (NoClassDefFoundError e)
924 // {
925 // }
926 // ------- only after API level 9 -------
927 // ------- only after API level 9 -------
928
929 // Log.e("Navit", "OnCreate");
930
931 // if (checkPlayServices())
932 // {
933 // }
934
935 getPrefs_theme();
936 getPrefs_theme_main();
937 Navit.applySharedTheme(this, p.PREF_current_theme_M);
938
939 super.onCreate(savedInstanceState);
940
941 Global_Navit_Object = this;
942 asset_mgr = getAssets();
943
944 OSD_blueish_bg_color = getResources().getColor(R.color.blueish_bg_color);
945
946 // getBaseContext_ = getBaseContext().getApplicationContext();
947 getBaseContext_ = getBaseContext();
948
949 last_orientation = getResources().getConfiguration().orientation;
950
951 content_resolver = getContentResolver();
952 // get_reglevel();
953
954 Display display_ = getWindowManager().getDefaultDisplay();
955 metrics = new DisplayMetrics();
956 display_.getMetrics(Navit.metrics);
957
958 road_book_items = new ArrayList<ListViewItem>();
959 fragmentManager = getSupportFragmentManager();
960
961 setContentView(R.layout.main_layout);
962 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
963 if (toolbar != null)
964 {
965 try
966 {
967 setSupportActionBar(toolbar);
968 // System.out.println("TTT01:" + toolbar);
969 }
970 catch (NoClassDefFoundError e)
971 {
972 }
973 }
974
975 try
976 {
977 getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
978 getSupportActionBar().setDisplayUseLogoEnabled(false);
979 getSupportActionBar().setIcon(R.drawable.icon);
980 getSupportActionBar().setDisplayShowHomeEnabled(true);
981 getSupportActionBar().setDisplayShowTitleEnabled(false);
982 }
983 catch (NoClassDefFoundError e)
984 {
985 }
986 catch (Exception e)
987 {
988 e.printStackTrace();
989 }
990
991 // ------------ bottom bar slider ----------------
992 // ------------ bottom bar slider ----------------
993 // ------------ bottom bar slider ----------------
994
995 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
996 // System.out.println("VVV:bottom_bar_height:" + bottom_bar_px);
997 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
998 // System.out.println("VVV:bottom_bar_slider_shadow_px:" + bottom_bar_slider_shadow_px);
999
1000 // final RelativeLayout a = (RelativeLayout) findViewById(R.id.bottom_bar_container);
1001 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
1002 final RelativeLayout.LayoutParams pp22 = (RelativeLayout.LayoutParams) a.getLayoutParams();
1003
1004 // Calculate ToolBar height
1005 try
1006 {
1007 TypedValue tv = new TypedValue();
1008 if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
1009 {
1010 actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
1011 System.out.println("VVV:abh:" + actionBarHeight);
1012 }
1013 else
1014 {
1015 actionBarHeight = NavitGraphics.dp_to_px(144);
1016 }
1017 }
1018 catch (Exception e)
1019 {
1020 actionBarHeight = NavitGraphics.dp_to_px(144);
1021 }
1022
1023 final android.support.v7.widget.Toolbar view_toolbar_top = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
1024 ViewTreeObserver vto = view_toolbar_top.getViewTreeObserver();
1025 vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener()
1026 {
1027 @Override
1028 public void onGlobalLayout()
1029 {
1030 view_toolbar_top.getViewTreeObserver().removeGlobalOnLayoutListener(this);
1031 // int width = view_toolbar_top.getMeasuredWidth();
1032 int height = view_toolbar_top.getMeasuredHeight();
1033 Navit.actionBarHeight = height;
1034 // System.out.println("hhh:88=" + Navit.actionBarHeight);
1035 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
1036
1037 pp22.setMargins(0, (int) Navit.cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1038 a.setLayoutParams(pp22);
1039 a.requestLayout();
1040 }
1041 });
1042
1043 // actionBarHeight = 168;
1044
1045 // final int SWIPE_MIN_DISTANCE = NavitGraphics.dp_to_px(25);
1046 // final float SWIPE_THRESHOLD_VELOCITY = 5.5f;
1047 // final float FLING_PIXELS_PER_SECOND = 100;
1048 // final float maxFlingVelocity = ViewConfiguration.get(this).getScaledMaximumFlingVelocity();
1049 final ViewConfiguration vc = ViewConfiguration.get(this);
1050 final int swipeMinDistance = vc.getScaledPagingTouchSlop();
1051 final int swipeThresholdVelocity = vc.getScaledMinimumFlingVelocity();
1052 swipeMaxOffPath = vc.getScaledTouchSlop();
1053 // (there is also vc.getScaledMaximumFlingVelocity() one could check against)
1054
1055 // setup some values --------
1056 NavitGraphics.long_press_on_screen_max_distance = swipeMaxOffPath;
1057 // setup some values --------
1058
1059 class MyGestureDetector extends SimpleOnGestureListener
1060 {
1061 @Override
1062 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
1063 {
1064 try
1065 {
1066 // float velocityPercentY = velocityY / maxFlingVelocity; // the percent is a value in the range of (0, 1]
1067 // float normalizedVelocityY = velocityPercentY * FLING_PIXELS_PER_SECOND; // where PIXELS_PER_SECOND is a device-independent measurement
1068
1069 // System.out.println("VVV:" + (e1.getY() - e2.getY()) + " " + NavitGraphics.dp_to_px((int) (e1.getY() - e2.getY())) + " " + maxFlingVelocity + " " + velocityY + " " + velocityPercentY + " " + normalizedVelocityY + " " + SWIPE_THRESHOLD_VELOCITY);
1070
1071 // System.out.println("VVV:2:" + swipeMinDistance + " " + swipeThresholdVelocity + " " + swipeMaxOffPath);
1072
1073 // bottom to top
1074 if (e1.getY() - e2.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1075 {
1076 //int featureWidth = getMeasuredWidth();
1077 //mActiveFeature = (mActiveFeature < (mItems.size() - 1)) ? mActiveFeature + 1 : mItems.size() - 1;
1078 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1079 //System.out.println("GS:002:up:" + velocityY + " " + e2.getY() + " " + e1.getY());
1080
1081 animate_bottom_bar_up();
1082
1083 return true;
1084 }
1085 // top to bottom
1086 else if (e2.getY() - e1.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1087 {
1088 //int featureWidth = getMeasuredWidth();
1089 //mActiveFeature = (mActiveFeature > 0) ? mActiveFeature - 1 : 0;
1090 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1091 //System.out.println("GS:003:down:" + velocityY + " " + e1.getY() + " " + e2.getY());
1092
1093 animate_bottom_bar_down();
1094
1095 return true;
1096 }
1097 }
1098 catch (Exception e)
1099 {
1100 //System.out.println("GS:009:EE:" + e.getMessage());
1101 }
1102 return false;
1103 }
1104 }
1105 mGestureDetector = new GestureDetector(new MyGestureDetector());
1106
1107 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
1108 push_pin_view.setOnClickListener(new ImageView.OnClickListener()
1109 {
1110 public void onClick(View v)
1111 {
1112 try
1113 {
1114 toggle_follow_button();
1115 }
1116 catch (Exception e)
1117 {
1118 }
1119 }
1120 });
1121
1122 cur_y_margin_bottom_bar_touch = 0; // try to put view at bottom
1123
1124 a.setOnTouchListener(new View.OnTouchListener()
1125 {
1126 @Override
1127 synchronized public boolean onTouch(View v, MotionEvent m)
1128 {
1129
1130 int action = m.getAction();
1131
1132 if (mGestureDetector.onTouchEvent(m))
1133 {
1134 //System.out.println("GS:001:fling!!");
1135 // System.out.println("FRAG:fling:011");
1136 return true;
1137 }
1138 else if (action == MotionEvent.ACTION_DOWN)
1139 {
1140 last_y_bottom_bar_touch = m.getY();
1141
1142 // put roadbook into layout -----------
1143 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
1144
1145 try
1146 {
1147 if (road_book == null)
1148 {
1149 road_book = new ZANaviRoadbookFragment();
1150 // System.out.println("FRAG:attach:001");
1151 fragmentTransaction.replace(R.id.roadbook_fragment_container, road_book, "");
1152 fragmentTransaction.commitAllowingStateLoss();
1153 // fragmentTransaction.show(road_book);
1154 }
1155 else
1156 {
1157 // System.out.println("FRAG:attached:003");
1158 }
1159 }
1160 catch (Exception ef)
1161 {
1162 }
1163 // put roadbook into layout -----------
1164
1165 return true;
1166 }
1167 else if ((action == MotionEvent.ACTION_UP) || (action == MotionEvent.ACTION_CANCEL))
1168 {
1169 // System.out.println("FRAG:up/cancel:012");
1170
1171 // release
1172 if (cur_y_margin_bottom_bar_touch > (bottom_y_margin_bottom_bar_touch / 2))
1173 {
1174 // snap back to bottom
1175 animate_bottom_bar_down();
1176 }
1177 else
1178 {
1179 // snap top top
1180 animate_bottom_bar_up();
1181 }
1182 }
1183 else
1184 // if (action == MotionEvent.ACTION_MOVE)
1185 {
1186 // System.out.println("FRAG:*else*:012");
1187
1188 if (Math.abs(last_y_bottom_bar_touch - m.getY()) > 2)
1189 {
1190 float last_margin = cur_y_margin_bottom_bar_touch;
1191 cur_y_margin_bottom_bar_touch = cur_y_margin_bottom_bar_touch - (last_y_bottom_bar_touch - m.getY());
1192
1193 if ((cur_y_margin_bottom_bar_touch >= 0) && (cur_y_margin_bottom_bar_touch <= bottom_y_margin_bottom_bar_touch))
1194 {
1195 // System.out.println("VVV:move:" + cur_y_margin_bottom_bar_touch + " " + bottom_y_margin_bottom_bar_touch);
1196
1197 last_y_bottom_bar_touch = m.getY() + (last_y_bottom_bar_touch - m.getY());
1198 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
1199 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1200 a.setLayoutParams(relativeParams);
1201 a.requestLayout();
1202 }
1203 else
1204 {
1205 // System.out.println("VVV:revert");
1206
1207 // revert position
1208 cur_y_margin_bottom_bar_touch = last_margin;
1209 }
1210 }
1211
1212 }
1213 return true;
1214 }
1215 });
1216 // ------------ bottom bar slider ----------------
1217 // ------------ bottom bar slider ----------------
1218 // ------------ bottom bar slider ----------------
1219
1220 // init cancel dialog!! ----------
1221 // init cancel dialog!! ----------
1222 Message msg2 = new Message();
1223 Bundle b2 = new Bundle();
1224 b2.putString("text", "");
1225 msg2.what = 0;
1226 msg2.setData(b2);
1227 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg2);
1228 // init cancel dialog!! ----------
1229 // init cancel dialog!! ----------
1230
1231 app_window = getWindow();
1232
1233 // ---------------- set some directories -----------------
1234 // ---------------- set some directories -----------------
1235 NAVIT_DATA_DIR = this.getFilesDir().getPath();
1236 this.getFilesDir().mkdirs();
1237 // ---
1238 // System.out.println("data dir=" + NAVIT_DATA_DIR);
1239 NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share/";
1240 File tmp3 = new File(NAVIT_DATA_SHARE_DIR);
1241 tmp3.mkdirs();
1242 // ---
1243 FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
1244 VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
1245 // ---------------- set some directories -----------------
1246 // ---------------- set some directories -----------------
1247
1248 try
1249 {
1250 toneG = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
1251 }
1252 catch (Exception e)
1253 {
1254 }
1255
1256 try
1257 {
1258 Class.forName("android.app.backup.BackupManager");
1259 backupManager = new BackupManager(this);
1260 }
1261 catch (ClassNotFoundException e)
1262 {
1263 e.printStackTrace();
1264 }
1265 catch (Exception e)
1266 {
1267 e.printStackTrace();
1268 }
1269
1270 int width_ = display_.getWidth();
1271 int height_ = display_.getHeight();
1272 Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_);
1273 Log.e("Navit", "Navit -> dpi=" + Navit.metrics.densityDpi);
1274 Log.e("Navit", "Navit -> density=" + Navit.metrics.density);
1275 Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);
1276
1277 try
1278 {
1279 // send overspill factor to C-code
1280 Message msg33 = new Message();
1281 Bundle b33 = new Bundle();
1282 b33.putInt("Callback", 104);
1283 msg33.setData(b33);
1284 NavitGraphics.callback_handler.sendMessage(msg33);
1285 }
1286 catch (Exception eee)
1287 {
1288 }
1289
1290 // ----- service -----
1291 // ----- service -----
1292 ZANaviMapDownloaderServiceIntent = new Intent(Navit.getBaseContext_, ZANaviMapDownloaderService.class);
1293 // ----- service -----
1294 // ----- service -----
1295
1296 System.out.println("Navit:onCreate:JTHREAD ID=" + Thread.currentThread().getId());
1297 System.out.println("Navit:onCreate:THREAD ID=" + NavitGraphics.GetThreadId());
1298
1299 // bitmaps for lanes
1300 lane_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_left);
1301 lane_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_right);
1302 lane_merge_to_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_left);
1303 lane_merge_to_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_right);
1304 lane_none = BitmapFactory.decodeResource(getResources(), R.drawable.lane_none);
1305 // bitmaps for lanes
1306
1307 // paint for bitmapdrawing on map
1308 NavitGraphics.paint_for_map_display.setAntiAlias(true);
1309 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
1310
1311 // sky
1312 NavitGraphics.paint_sky_day.setAntiAlias(true);
1313 NavitGraphics.paint_sky_day.setColor(Color.parseColor("#79BAEC"));
1314 NavitGraphics.paint_sky_night.setAntiAlias(true);
1315 NavitGraphics.paint_sky_night.setColor(Color.parseColor("#090909"));
1316 // stars
1317 NavitGraphics.paint_sky_night_stars.setColor(Color.parseColor("#DEDDEF"));
1318 // twilight
1319 NavitGraphics.paint_sky_twilight1.setColor(Color.parseColor("#090909"));
1320 NavitGraphics.paint_sky_twilight2.setColor(Color.parseColor("#113268"));
1321 NavitGraphics.paint_sky_twilight3.setColor(Color.parseColor("#79BAEC"));
1322
1323 Random m = new Random();
1324 int i6 = 0;
1325 for (i6 = 0; i6 < (NavitGraphics.max_stars + 1); i6++)
1326 {
1327 NavitGraphics.stars_x[i6] = m.nextFloat();
1328 NavitGraphics.stars_y[i6] = m.nextFloat();
1329 NavitGraphics.stars_size[i6] = m.nextInt(3) + 1;
1330 }
1331
1332 res_ = getResources();
1333 int ii = 0;
1334 NavitGraphics.dl_thread_cur = 0;
1335 for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
1336 {
1337 NavitGraphics.dl_thread[ii] = null;
1338 }
1339
1340 String font_file_name = "Roboto-Regular.ttf"; // "LiberationSans-Regular.ttf";
1341 NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), font_file_name);
1342 // System.out.println("NavitStreetnameFont" + NavitStreetnameFont);
1343
1344 Navit_maps_loaded = false;
1345
1346 // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
1347 Navit.startup_intent = this.getIntent();
1348 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
1349 Navit.startup_intent_timestamp = System.currentTimeMillis();
1350 Log.e("Navit", "**1**A " + startup_intent.getAction());
1351 Log.e("Navit", "**1**D " + startup_intent.getDataString());
1352 Log.e("Navit", "**1**I " + startup_intent.toString());
1353 try
1354 {
1355 Log.e("Navit", "**1**DH E " + startup_intent.getExtras().describeContents());
1356 }
1357 catch (Exception ee)
1358 {
1359 }
1360
1361 startup_status = Navit_Status_NORMAL_STARTUP;
1362
1363 // glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView_001);
1364 // glSurfaceView.setEGLContextClientVersion(2); // enable OpenGL 2.0
1365 // glSurfaceView.setRenderer(new GlRenderer());
1366 // glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // only render on demand
1367 //
1368 // // draw some sample lines ----
1369 // // draw some sample lines ----
1370 // // draw some sample lines ----
1371 // ZANaviGlLine vertLine = new ZANaviGlLine();
1372 // vertLine.SetVerts(1000f, 1000f, 0f, -1000f, -1000f, 0f);
1373 // vertLine.SetColor(.8f, .8f, 0f, 1.0f);
1374 //
1375 // float[] mMVPMatrix = new float[16];
1376 //
1377 // // Position the eye behind the origin.
1378 // final float eyeX = 0.0f;
1379 // final float eyeY = 0.0f;
1380 // final float eyeZ = 1.5f;
1381 //
1382 // // We are looking toward the distance
1383 // final float lookX = 0.0f;
1384 // final float lookY = 0.0f;
1385 // final float lookZ = -5.0f;
1386 //
1387 // // Set our up vector. This is where our head would be pointing were we holding the camera.
1388 // final float upX = 0.0f;
1389 // final float upY = 1.0f;
1390 // final float upZ = 0.0f;
1391 //
1392 // // Set the view matrix. This matrix can be said to represent the camera position.
1393 // // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
1394 // // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
1395 // Matrix.setLookAtM(mMVPMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
1396 //
1397 // vertLine.draw(mMVPMatrix);
1398 //
1399 // glSurfaceView.postInvalidate();
1400 // glSurfaceView.requestRender();
1401 // glSurfaceView.postInvalidate();
1402 // // draw some sample lines ----
1403 // // draw some sample lines ----
1404 // // draw some sample lines ----
1405
1406 // setup graphics objects
1407 // setup graphics objects
1408 // setup graphics objects
1409 NG__vehicle = new NavitGraphics(this, 1, 0, 0, 50, 50, 65535, 0, 0);
1410 NG__map_main = new NavitGraphics(this, 0, 0, 0, 100, 100, 0, 0, 0);
1411 Navit.N_NavitGraphics = NG__map_main;
1412 // setup graphics objects
1413 // setup graphics objects
1414 // setup graphics objects
1415
1416 NV = new NavitVehicle(this);
1417 NSp = new NavitSpeech2(this);
1418
1419 // init translated text
1420 NavitTextTranslations.init();
1421
1422 // set the new locale here -----------------------------------
1423 getPrefs_loc();
1424 activatePrefs_loc();
1425 // set the new locale here -----------------------------------
1426
1427 // get the local language -------------
1428 Locale locale = java.util.Locale.getDefault();
1429 String lang = locale.getLanguage();
1430 String langu = lang;
1431 String langc = lang;
1432 Log.e("Navit", "lang=" + lang);
1433 int pos = langu.indexOf('_');
1434 if (pos != -1)
1435 {
1436 langc = langu.substring(0, pos);
1437 langu = langc + langu.substring(pos).toUpperCase(locale);
1438 Log.e("Navit", "substring lang " + langu.substring(pos).toUpperCase(locale));
1439 // set lang. for translation
1440 NavitTextTranslations.main_language = langc;
1441 NavitTextTranslations.sub_language = langu.substring(pos).toUpperCase(locale);
1442 }
1443 else
1444 {
1445 String country = locale.getCountry();
1446 Log.e("Navit", "Country1 " + country);
1447 Log.e("Navit", "Country2 " + country.toUpperCase(locale));
1448 langu = langc + "_" + country.toUpperCase(locale);
1449 // set lang. for translation
1450 NavitTextTranslations.main_language = langc;
1451 NavitTextTranslations.sub_language = country.toUpperCase(locale);
1452 }
1453 Log.e("Navit", "Language " + lang);
1454 // get the local language -------------
1455
1456 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
1457 no_maps_text.setText("\n\n\n" + Navit.get_text("No Maps installed") + "\n" + Navit.get_text("Please download a map") + "\n\n");
1458 // no_maps_text.postInvalidate();
1459
1460 // set map cache size here -----------------------------------
1461 getPrefs_mapcache();
1462 activatePrefs_mapcache();
1463 // set map cache size here -----------------------------------
1464
1465 // get map data dir and set it -----------------------------
1466 getPrefs_mapdir();
1467 activatePrefs_mapdir(true);
1468 // get map data dir and set it -----------------------------
1469
1470 // get special prefs here ------------------------------------
1471 get_prefs_highdpi();
1472 // get special prefs here ------------------------------------
1473
1474 // make sure the new path for the navitmap.bin file(s) exist!!
1475 File navit_maps_dir = new File(MAP_FILENAME_PATH);
1476 navit_maps_dir.mkdirs();
1477 // create nomedia files
1478 File nomedia_file = new File(MAP_FILENAME_PATH + ".nomedia");
1479 try
1480 {
1481 nomedia_file.createNewFile();
1482 }
1483 catch (Exception e1)
1484 {
1485 e1.printStackTrace();
1486 }
1487 // create nomedia files
1488
1489 // check if we already have a borders.bin file (if not, then extract the included simplified one)
1490 File b_ = new File(MAP_FILENAME_PATH + "/borders.bin");
1491 try
1492 {
1493 if (!b_.exists())
1494 {
1495 try
1496 {
1497 File c_ = new File(MAPMD5_FILENAME_PATH + "/borders.bin.md5");
1498 c_.delete();
1499 }
1500 catch (Exception e2)
1501 {
1502
1503 }
1504 Log.e("Navit", "trying to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1505 if (!extractRes("borders_simple", MAP_FILENAME_PATH + "/borders.bin"))
1506 {
1507 Log.e("Navit", "Failed to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1508 }
1509 }
1510 }
1511 catch (Exception e)
1512 {
1513
1514 }
1515 // check if we already have a borders.bin file
1516
1517 // make sure the new path for config files exist
1518 File navit_cfg_dir = new File(CFG_FILENAME_PATH);
1519 navit_cfg_dir.mkdirs();
1520
1521 // make sure the new path for the navitmap.bin file(s) exist!!
1522 File navit_mapsmd5_dir = new File(MAPMD5_FILENAME_PATH);
1523 navit_mapsmd5_dir.mkdirs();
1524
1525 // make sure the share dir exists, otherwise the infobox will not show
1526 File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR);
1527 navit_data_share_dir.mkdirs();
1528
1529 File dd = new File(NAVIT_DATA_DEBUG_DIR);
1530 dd.mkdirs();
1531
1532 // try to create cat. file if it does not exist
1533 File navit_maps_catalogue = new File(CFG_FILENAME_PATH + NavitMapDownloader.CAT_FILE);
1534 if (!navit_maps_catalogue.exists())
1535 {
1536 FileOutputStream fos_temp;
1537 try
1538 {
1539 fos_temp = new FileOutputStream(navit_maps_catalogue);
1540 fos_temp.write((NavitMapDownloader.MAP_CAT_HEADER + "\n").getBytes()); // just write header to the file
1541 fos_temp.flush();
1542 fos_temp.close();
1543 }
1544 catch (Exception e)
1545 {
1546 e.printStackTrace();
1547 }
1548 }
1549
1550 // ---------- downloader threads ----------------
1551 NavitMapDownloader.MULTI_NUM_THREADS = 1;
1552 PackageInfo pkgInfo;
1553 Navit_DonateVersion_Installed = false;
1554 try
1555 {
1556 // is the donate version installed?
1557 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_donate", 0);
1558 String sharedUserId = pkgInfo.sharedUserId;
1559 System.out.println("str nd=" + sharedUserId);
1560 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
1561 {
1562 System.out.println("##bonus 001##");
1563 Navit_DonateVersion_Installed = true;
1564 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1565 }
1566 }
1567 catch (NameNotFoundException e)
1568 {
1569 e.printStackTrace();
1570 }
1571 catch (Exception e)
1572 {
1573 e.printStackTrace();
1574 }
1575
1576 try
1577 {
1578 if (get_reglevel() == 1)
1579 {
1580 System.out.println("##U:bonus 001##");
1581 Navit_DonateVersion_Installed = true;
1582 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1583 }
1584 }
1585 catch (Exception e)
1586 {
1587 e.printStackTrace();
1588 }
1589
1590 try
1591 {
1592 // is the "large map" donate version installed?
1593 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0);
1594 String sharedUserId = pkgInfo.sharedUserId;
1595 System.out.println("str lm=" + sharedUserId);
1596
1597 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
1598 {
1599 System.out.println("##bonus 002##");
1600 Navit_DonateVersion_Installed = true;
1601 Navit_Largemap_DonateVersion_Installed = true;
1602 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1603 }
1604 }
1605 catch (NameNotFoundException e)
1606 {
1607 e.printStackTrace();
1608 }
1609 catch (Exception e)
1610 {
1611 e.printStackTrace();
1612 }
1613
1614 try
1615 {
1616 if (get_reglevel() == 1)
1617 {
1618 System.out.println("##U:bonus 002##");
1619 Navit_DonateVersion_Installed = true;
1620 Navit_Largemap_DonateVersion_Installed = true;
1621 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1622 }
1623 }
1624 catch (Exception e)
1625 {
1626 e.printStackTrace();
1627 }
1628
1629 // update map list
1630 NavitMapDownloader.init_maps_without_donate_largemaps();
1631 // ---------- downloader threads ----------------
1632
1633 // ---- detect menu button ----
1634 detect_menu_button();
1635
1636 if (Navit.metrics.densityDpi >= 320) //&& (PREF_shrink_on_high_dpi))
1637 {
1638 Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001);
1639 }
1640 else
1641 {
1642 Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001_small);
1643 }
1644
1645 Navit.long_green_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.long_green_arrow);
1646
1647 Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow);
1648 Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off);
1649 Navit.follow_current = Navit.follow_on;
1650
1651 if ((Navit.metrics.densityDpi >= 320) && (p.PREF_shrink_on_high_dpi))
1652 {
1653 float factor;
1654 factor = (float) NavitGraphics.Global_Scaled_DPI_normal / (float) Navit.metrics.densityDpi;
1655 factor = factor * 1.7f;
1656 //
1657 BitmapFactory.Options o = new BitmapFactory.Options();
1658 o.inDither = true;
1659 //o.inScaled = true;
1660 //o.inTargetDensity = NavitGraphics.Global_Scaled_DPI_normal;
1661 Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped, o);
1662 Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving, o);
1663 Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey, o);
1664 Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow, o);
1665
1666 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);
1667 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);
1668 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);
1669 }
1670 else
1671 {
1672 Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped);
1673 Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving);
1674 Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey);
1675 Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow);
1676
1677 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);
1678 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);
1679 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);
1680 }
1681
1682 Navit.zoomin = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_in_32_32);
1683 Navit.zoomout = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_out_32_32);
1684
1685 //Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway);
1686 Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_large);
1687 Navit.oneway_bicycle_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_bicycle_large);
1688
1689 // *******************
1690 // *******************
1691 // *******************
1692 // *******************
1693 // check/init the catalogue file for downloaded maps
1694 NavitMapDownloader.init_cat_file();
1695 // *******************
1696 // *******************
1697 // *******************
1698 // *******************
1699
1700 xmlconfig_unpack_file = false;
1701 write_new_version_file = false;
1702 try
1703 {
1704 NavitAppVersion = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionCode;
1705 NavitAppVersion_string = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
1706 }
1707 catch (NameNotFoundException e)
1708 {
1709 e.printStackTrace();
1710 NavitAppVersion = "1";
1711 NavitAppVersion_string = "1";
1712 }
1713 catch (Exception e)
1714 {
1715 e.printStackTrace();
1716 NavitAppVersion = "2";
1717 NavitAppVersion_string = "2";
1718 }
1719
1720 try
1721 {
1722 File navit_version = new File(VERSION_FILE);
1723 if (!navit_version.exists())
1724 {
1725 System.out.println("version file does not exist");
1726 NavitAppVersion_prev = "-1";
1727 write_new_version_file = true;
1728 }
1729 else
1730 {
1731 // files exists, read in the prev. verison number
1732 System.out.println("version file is here");
1733 FileInputStream fos_temp;
1734 byte[] buffer = new byte[101];
1735 fos_temp = new FileInputStream(navit_version);
1736 int len = fos_temp.read(buffer, 0, 100);
1737 if (len != -1)
1738 {
1739 // use only len bytes to make the string (the rest is garbage!!)
1740 NavitAppVersion_prev = new String(buffer).substring(0, len);
1741 }
1742 else
1743 {
1744 NavitAppVersion_prev = "-1";
1745 write_new_version_file = true;
1746 }
1747 fos_temp.close();
1748 }
1749
1750 }
1751 catch (Exception e)
1752 {
1753 NavitAppVersion_prev = "-1";
1754 write_new_version_file = true;
1755 e.printStackTrace();
1756 }
1757
1758 System.out.println("vprev:" + NavitAppVersion_prev + " vcur:" + NavitAppVersion);
1759
1760 if (NavitAppVersion_prev.compareTo(NavitAppVersion) != 0)
1761 {
1762 // different version
1763 System.out.println("different version!!");
1764 write_new_version_file = true;
1765 xmlconfig_unpack_file = true;
1766
1767 //if ((NavitAppVersion_prev.compareTo("-1") != 0) && (NavitAppVersion.compareTo("-1") != 0))
1768 //{
1769 // user has upgraded to a new version of ZANavi
1770 startup_status = Navit_Status_UPGRADED_TO_NEW_VERSION;
1771 //}
1772 }
1773 else
1774 {
1775 // same version
1776 System.out.println("same version");
1777 xmlconfig_unpack_file = false;
1778 }
1779
1780 // write new version file
1781 if (write_new_version_file)
1782 {
1783 try
1784 {
1785 System.out.println("write version file");
1786 FileOutputStream fos_temp;
1787 File navit_version = new File(VERSION_FILE);
1788 navit_version.delete();
1789 fos_temp = new FileOutputStream(navit_version);
1790 fos_temp.write(NavitAppVersion.getBytes());
1791 fos_temp.flush();
1792 fos_temp.close();
1793 }
1794 catch (Exception e)
1795 {
1796 e.printStackTrace();
1797 }
1798 }
1799
1800 // Sample useragent strings:
1801 //
1802 // Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110616 Firefox/7.0a1 SeaMonkey/2.4a1
1803 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; GT-I9100 Build/GINGERBREAD)
1804 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5830 Build/FROYO)
1805 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Desire S Build/GRI40)
1806 // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-179)
1807 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Wildfire S A510e Build/GRI40)
1808 // Wget/1.10.2
1809 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; sdk Build/GRI34)
1810 // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-164)
1811 // Dalvik/1.2.0 (Linux; U; Android 2.2; GT-I9000 Build/FROYO)
1812 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5570L Build/FROYO)
1813 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-I9000 Build/FROYO)
1814 // Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)
1815 String ANDROID = android.os.Build.VERSION.SDK; //The current development codename, or the string "REL" if this is a release build.
1816 //String BOARD = android.os.Build.BOARD; //The name of the underlying board, like "goldfish".
1817 //String BOOTLOADER = android.os.Build.BOOTLOADER; // The system bootloader version number.
1818 String BRAND = android.os.Build.BRAND; //The brand (e.g., carrier) the software is customized for, if any.
1819 //String CPU_ABI = android.os.Build.CPU_ABI; //The name of the instruction set (CPU type + ABI convention) of native code.
1820 //String CPU_ABI2 = android.os.Build.CPU_ABI2; // The name of the second instruction set (CPU type + ABI convention) of native code.
1821 String DEVICE = android.os.Build.DEVICE; // The name of the industrial design.
1822 String DISPLAY = android.os.Build.DISPLAY; //A build ID string meant for displaying to the user
1823 //String FINGERPRINT = android.os.Build.FINGERPRINT; //A string that uniquely identifies this build.
1824 //String HARDWARE = android.os.Build.HARDWARE; //The name of the hardware (from the kernel command line or /proc).
1825 //String HOST = android.os.Build.HOST;
1826 //String ID = android.os.Build.ID; //Either a changelist number, or a label like "M4-rc20".
1827 String MANUFACTURER = android.os.Build.MANUFACTURER; //The manufacturer of the product/hardware.
1828 //String MODEL = android.os.Build.MODEL; //The end-user-visible name for the end product.
1829 //String PRODUCT = android.os.Build.PRODUCT; //The name of the overall product.
1830 //String RADIO = android.os.Build.RADIO; //The radio firmware version number.
1831 //String TAGS = android.os.Build.TAGS; //Comma-separated tags describing the build, like "unsigned,debug".
1832 //String TYPE = android.os.Build.TYPE; //The type of build, like "user" or "eng".
1833 //String USER = android.os.Build.USER;
1834
1835 String android_version = "Android " + ANDROID;
1836 String android_device = MANUFACTURER + " " + BRAND + " " + DEVICE;
1837
1838 api_version_int = Integer.valueOf(android.os.Build.VERSION.SDK);
1839 System.out.println("XXX:API=" + api_version_int);
1840 if (api_version_int > 10)
1841 {
1842 Navit.PAINT_OLD_API = false;
1843 }
1844 else
1845 {
1846 Navit.PAINT_OLD_API = true;
1847 }
1848
1849 if (MANUFACTURER.equalsIgnoreCase("amazon"))
1850 {
1851 // we are on amazon device
1852 ZANaviNormalDonateActivity.on_amazon_device = true;
1853 }
1854
1855 // debug
1856 // debug
1857 // android_device = "telechips telechips m801";
1858 // debug
1859 // debug
1860
1861 String android_rom_name = DISPLAY;
1862
1863 if (FDBL)
1864 {
1865 android_rom_name = android_rom_name + "; FD";
1866 }
1867
1868 if (Navit_DonateVersion_Installed == false)
1869 {
1870 UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1871 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1872 }
1873 else
1874 {
1875 if (Navit_Largemap_DonateVersion_Installed == false)
1876 {
1877 UserAgentString = "Mozilla/5.0 (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1878 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1879 }
1880 else
1881
1882 {
1883 UserAgentString = "Mozilla/5.0 (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1884 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1885 }
1886 }
1887 // System.out.println("UA=" + UserAgentString);
1888
1889 // --------- enable GPS ? --------------
1890 // --------- enable GPS ? --------------
1891 // try
1892 // {
1893 // final LocationManager llmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
1894 // if (!llmanager.isProviderEnabled(LocationManager.GPS_PROVIDER))
1895 // {
1896 // buildAlertMessageNoGps();
1897 // }
1898 // }
1899 // catch (Exception e)
1900 // {
1901 // e.printStackTrace();
1902 // }
1903 // --------- enable GPS ? --------------
1904 // --------- enable GPS ? --------------
1905
1906 unsupported = false;
1907 try
1908 {
1909 if (android_device.toLowerCase().contains("telechips"))
1910 {
1911 if (android_device.toLowerCase().contains("m801"))
1912 {
1913 // if the donate version is already installed, dont disable the app
1914 if (Navit_DonateVersion_Installed == false)
1915 {
1916 if (Navit_Largemap_DonateVersion_Installed == false)
1917 {
1918 // activate [Weltbild] Cat Nova again (19.12.2011)
1919 // ** // unsupported = true;
1920 }
1921 }
1922 }
1923 }
1924 }
1925 catch (Exception e)
1926 {
1927 e.printStackTrace();
1928 }
1929
1930 try
1931 {
1932 // this hangs the emulator, if emulator < 2.3 (only works in emulator >= 2.3)!!
1933 if (!NAVIT_IS_EMULATOR)
1934 {
1935 sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
1936 }
1937 }
1938 catch (Exception e3)
1939 {
1940 e3.printStackTrace();
1941 }
1942
1943 // try
1944 // {
1945 // vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
1946 // }
1947 // catch (Exception e)
1948 // {
1949 // e.printStackTrace();
1950 // }
1951 //sensorManager_ = sensorManager;
1952
1953 generic_alert_box = new AlertDialog.Builder(this);
1954 /*
1955 * show info box for first time users
1956 */
1957 AlertDialog.Builder infobox = new AlertDialog.Builder(this);
1958 //. english text: Welcome to ZANavi
1959 infobox.setTitle(Navit.get_text("__INFO_BOX_TITLE__")); //TRANS
1960 infobox.setCancelable(false);
1961 final TextView message = new TextView(this);
1962 message.setFadingEdgeLength(20);
1963 message.setVerticalFadingEdgeEnabled(true);
1964 message.setPadding(10, 5, 10, 5);
1965 message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
1966 message.setGravity(Gravity.LEFT);
1967 // message.setScrollBarStyle(TextView.SCROLLBARS_INSIDE_OVERLAY);
1968 // message.setVerticalScrollBarEnabled(true);
1969 RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
1970 rlp.leftMargin = 7;
1971 rlp.rightMargin = 7;
1972
1973 Navit.Navit_Geocoder = null;
1974 try
1975 {
1976 // for online search
1977 Navit.Navit_Geocoder = new Geocoder(this);
1978 }
1979 catch (Exception e)
1980 {
1981 e.printStackTrace();
1982 }
1983
1984 //TRANS
1985 infobox.setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
1986 {
1987 public void onClick(DialogInterface arg0, int arg1)
1988 {
1989 Log.e("Navit", "Ok, user saw the infobox");
1990 }
1991 });
1992
1993 //TRANS
1994 infobox.setNeutralButton(Navit.get_text("More info"), new DialogInterface.OnClickListener()
1995 {
1996 public void onClick(DialogInterface arg0, int arg1)
1997 {
1998 Log.e("Navit", "user wants more info, show the website");
1999 // URL to ZANavi Manual (in english language)
2000 String url = "http://zanavi.cc/index.php/Manual";
2001 if (FDBL)
2002 {
2003 url = "http://fd.zanavi.cc/manual";
2004 }
2005 Intent i = new Intent(Intent.ACTION_VIEW);
2006 i.setData(Uri.parse(url));
2007 startActivity(i);
2008 }
2009 });
2010
2011 info_popup_seen_count_end = false;
2012 File navit_first_startup = new File(FIRST_STARTUP_FILE);
2013 // if file does NOT exist, show the info box
2014 if (!navit_first_startup.exists())
2015 {
2016 // set first-ever-startup flag
2017 first_ever_startup = true;
2018 info_popup_seen_count_end = true; // don't show on first ever start of the app
2019 startup_status = Navit_Status_COMPLETE_NEW_INSTALL;
2020 FileOutputStream fos_temp;
2021 try
2022 {
2023 info_popup_seen_count++;
2024 fos_temp = new FileOutputStream(navit_first_startup);
2025 fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count
2026 fos_temp.flush();
2027 fos_temp.close();
2028
2029 message.setLayoutParams(rlp);
2030 //. TRANSLATORS: multiline info text for first startup of application (see en_US for english text)
2031 final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
2032 Linkify.addLinks(s, Linkify.WEB_URLS);
2033 message.setText(s);
2034 message.setMovementMethod(LinkMovementMethod.getInstance());
2035 infobox.setView(message);
2036
2037 infobox.show();
2038 }
2039 catch (Exception e)
2040 {
2041 e.printStackTrace();
2042 }
2043 }
2044 else
2045 {
2046 FileOutputStream fos_temp;
2047 FileInputStream fis_temp;
2048 try
2049 {
2050 fis_temp = new FileInputStream(navit_first_startup);
2051 info_popup_seen_count = fis_temp.read();
2052 fis_temp.close();
2053
2054 if (info_popup_seen_count < 0)
2055 {
2056 info_popup_seen_count = 0;
2057 }
2058
2059 // we wrote "A" -> (int)65 previously, so account for that
2060 if (info_popup_seen_count == 65)
2061 {
2062 info_popup_seen_count = 0;
2063 }
2064
2065 if (info_popup_seen_count > info_popup_seen_count_max)
2066 {
2067 info_popup_seen_count_end = true;
2068 }
2069 else
2070 {
2071 info_popup_seen_count++;
2072 fos_temp = new FileOutputStream(navit_first_startup);
2073 fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count
2074 fos_temp.flush();
2075 fos_temp.close();
2076 }
2077 }
2078 catch (Exception e)
2079 {
2080 e.printStackTrace();
2081 }
2082 }
2083 /*
2084 * show info box for first time users
2085 */
2086
2087 // show info box for upgrade
2088 // if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
2089 // {
2090 // try
2091 // {
2092 // message.setLayoutParams(rlp);
2093 // // upgrade message
2094 // String upgrade_summary = "\n\n***********\n";
2095 // // upgrade message
2096 // final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
2097 // Linkify.addLinks(s, Linkify.WEB_URLS);
2098 // message.setText(s);
2099 // message.setMovementMethod(LinkMovementMethod.getInstance());
2100 // infobox.setView(message);
2101 //
2102 // infobox.show();
2103 // }
2104 // catch (Exception e)
2105 // {
2106 // e.printStackTrace();
2107 // }
2108 //
2109 // }
2110 // show info box for upgrade
2111
2112 //
2113 // ----------- info popup
2114 // ----------- info popup
2115 // ----------- info popup
2116 // ----------- info popup
2117 //
2118 if ((!info_popup_seen_count_end) || (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION))
2119 {
2120 try
2121 {
2122 //Builder a1 = new AlertDialog.Builder(this);
2123 //dialog_info_popup = a1.show();
2124 dialog_info_popup = new Dialog(this);
2125
2126 dialog_info_popup.setContentView(R.layout.info_popup);
2127 Button b_i1 = (Button) dialog_info_popup.findViewById(R.id.dialogButtonOK_i1);
2128
2129 TextView tv_i1 = (TextView) dialog_info_popup.findViewById(R.id.text_i1);
2130 final String ZANAVI_MSG_PLUGIN_MARKET_LINK = "https://play.google.com/store/apps/details?id=com.zoffcc.applications.zanavi_msg";
2131 final String ZANAVI_UDONATE_LINK = "http://more.zanavi.cc/donate/";
2132
2133 if (FDBL)
2134 {
2135 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>"));
2136 }
2137 else
2138 {
2139 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>"));
2140 }
2141
2142 try
2143 {
2144 tv_i1.setMovementMethod(LinkMovementMethod.getInstance());
2145 }
2146 catch (Exception ee3)
2147 {
2148 }
2149
2150 b_i1.setText("Ok (" + (1 + info_popup_seen_count_max - info_popup_seen_count) + ")");
2151 b_i1.setOnClickListener(new View.OnClickListener()
2152 {
2153 public void onClick(View v)
2154 {
2155 try
2156 {
2157 dialog_info_popup.cancel();
2158 }
2159 catch (Exception e)
2160 {
2161
2162 }
2163
2164 try
2165 {
2166 dialog_info_popup.dismiss();
2167 }
2168 catch (Exception e)
2169 {
2170
2171 }
2172
2173 try
2174 {
2175 // draw map no-async
2176 Message msg = new Message();
2177 Bundle b = new Bundle();
2178 b.putInt("Callback", 64);
2179 msg.setData(b);
2180 NavitGraphics.callback_handler.sendMessage(msg);
2181 }
2182 catch (Exception e)
2183 {
2184 e.printStackTrace();
2185 }
2186
2187 }
2188 });
2189 dialog_info_popup.setCancelable(true);
2190 dialog_info_popup.show();
2191 dialog_info_popup.getWindow().getDecorView().setBackgroundResource(R.drawable.rounded_bg);
2192 dialog_info_popup.setTitle(" Try the new Plugin");
2193 }
2194 catch (Exception e)
2195 {
2196 e.printStackTrace();
2197 }
2198 }
2199 //
2200 // ----------- info popup
2201 // ----------- info popup
2202 // ----------- info popup
2203 //
2204
2205 // make handler statically available for use in "msg_to_msg_handler"
2206 Navit_progress_h = this.progress_handler;
2207
2208 // try
2209 // {
2210 // Navit.bigmap_bitmap = BitmapFactory.decodeResource(getResources(), R.raw.bigmap_colors_zanavi2);
2211 // }
2212 // catch (Exception e)
2213 // {
2214 // // when not enough memory is available, then disable large world overview map!
2215 // System.gc();
2216 // Navit.bigmap_bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
2217 // }
2218 // // ------no----- // Navit.bigmap_bitmap.setDensity(120); // set our dpi!!
2219
2220 try
2221 {
2222 setVolumeControlStream(AudioManager.STREAM_MUSIC);
2223 ActivityResults = new NavitActivityResult[16];
2224 }
2225 catch (Exception e)
2226 {
2227 e.printStackTrace();
2228 }
2229
2230 try
2231 {
2232 NavitAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
2233 }
2234 catch (Exception e)
2235 {
2236 e.printStackTrace();
2237 }
2238
2239 PowerManager pm = null;
2240 try
2241 {
2242 pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
2243 }
2244 catch (Exception e)
2245 {
2246 e.printStackTrace();
2247 }
2248
2249 try
2250 {
2251 // -- // pm.wakeUp(SystemClock.uptimeMillis()); // -- //
2252 // **screen always full on** // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2253 // **screen can go off, cpu will stay on** // wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2254
2255 // this works so far, lets the screen dim, but it cpu and screen stays on
2256 wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2257 }
2258 catch (Exception e)
2259 {
2260 e.printStackTrace();
2261 wl = null;
2262 }
2263
2264 try
2265 {
2266 wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ZANaviNeedCpu");
2267 }
2268 catch (Exception e)
2269 {
2270 e.printStackTrace();
2271 wl_cpu = null;
2272 }
2273
2274 try
2275 {
2276 wl_navigating = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "ZANaviNavigationOn");
2277 }
2278 catch (Exception e)
2279 {
2280 Log.e("Navit", "WakeLock NAV: create failed!!");
2281 e.printStackTrace();
2282 wl_navigating = null;
2283 }
2284
2285 // try
2286 // {
2287 // if (wl_navigating != null)
2288 // {
2289 // wl_navigating.acquire();
2290 // Log.e("Navit", "WakeLock NAV: acquire 00");
2291 // }
2292 // }
2293 // catch (Exception e)
2294 // {
2295 // Log.e("Navit", "WakeLock NAV: something wrong 00");
2296 // e.printStackTrace();
2297 // }
2298
2299 // try
2300 // {
2301 // if (wl != null)
2302 // {
2303 // try
2304 // {
2305 // wl.release();
2306 // }
2307 // catch (Exception e2)
2308 // {
2309 // }
2310 // wl.acquire();
2311 // Log.e("Navit", "WakeLock: acquire 1");
2312 // }
2313 // }
2314 // catch (Exception e)
2315 // {
2316 // e.printStackTrace();
2317 // }
2318
2319 // -- extract overview maps --
2320 // -- extract overview maps --
2321
2322 // File navit_worldmap2_file = new File(NAVIT_DATA_DIR + "/share/worldmap2.txt");
2323 File navit_worldmap2_file = new File(MAP_FILENAME_PATH + "/worldmap2.txt");
2324 if (!navit_worldmap2_file.exists())
2325 {
2326 if (!extractRes("worldmap2", MAP_FILENAME_PATH + "/worldmap2.txt"))
2327 {
2328 Log.e("Navit", "Failed to extract worldmap2.txt");
2329 }
2330 }
2331
2332 File navit_worldmap5_file = new File(MAP_FILENAME_PATH + "/worldmap5.txt");
2333 if (!navit_worldmap5_file.exists())
2334 {
2335 if (!extractRes("worldmap5", MAP_FILENAME_PATH + "/worldmap5.txt"))
2336 {
2337 Log.e("Navit", "Failed to extract worldmap5.txt");
2338 }
2339 }
2340 // -- extract overview maps --
2341 // -- extract overview maps --
2342
2343 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
2344 if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
2345 {
2346 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
2347 }
2348
2349 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
2350 if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase(), NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
2351 {
2352 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
2353 }
2354
2355 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language);
2356 if (!extractRes(NavitTextTranslations.main_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo"))
2357 {
2358 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language);
2359 }
2360
2361 // DEBUG - check if language file is on SDCARD -
2362 try
2363 {
2364 File debug_mo_src = new File("/sdcard/zanavi/debug/navit.mo");
2365 File debug_mo_dest = new File(NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo");
2366 //* File navit_debug_dir = new File("/sdcard/zanavi/debug/");
2367 //* navit_debug_dir.mkdirs();
2368 copyFile(debug_mo_src, debug_mo_dest);
2369 }
2370 catch (Exception e)
2371 {
2372 e.printStackTrace();
2373 }
2374 // DEBUG - check if language file is on SDCARD -
2375
2376 File navit_config_xml_file = new File(NAVIT_DATA_SHARE_DIR + "/navit.xml");
2377 if ((!navit_config_xml_file.exists()) || (NAVIT_ALWAYS_UNPACK_XMLFILE))
2378 {
2379 xmlconfig_unpack_file = true;
2380 Log.e("Navit", "navit.xml does not exist, unpacking in any case");
2381 }
2382
2383 my_display_density = "mdpi";
2384 // ldpi display (120 dpi)
2385
2386 NavitGraphics.Global_want_dpi = Navit.metrics.densityDpi;
2387 NavitGraphics.Global_want_dpi_other = Navit.metrics.densityDpi;
2388
2389 if (Navit.metrics.densityDpi <= 120)
2390 {
2391 my_display_density = "ldpi";
2392 if (xmlconfig_unpack_file)
2393 {
2394 if (!extractRes("navitldpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2395 {
2396 Log.e("Navit", "Failed to extract navit.xml for ldpi device(s)");
2397 }
2398 }
2399 }
2400 // mdpi display (160 dpi)
2401 else if ((Navit.metrics.densityDpi > 120) && (Navit.metrics.densityDpi <= 160))
2402 {
2403 my_display_density = "mdpi";
2404 if (xmlconfig_unpack_file)
2405 {
2406 if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2407 {
2408 Log.e("Navit", "Failed to extract navit.xml for mdpi device(s)");
2409 }
2410 }
2411 }
2412 // hdpi display (240 dpi)
2413 else if ((Navit.metrics.densityDpi > 160) && (Navit.metrics.densityDpi < 320))
2414 //else if (Navit.metrics.densityDpi == 240)
2415 {
2416 my_display_density = "hdpi";
2417 if (xmlconfig_unpack_file)
2418 {
2419 if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2420 {
2421 Log.e("Navit", "Failed to extract navit.xml for hdpi device(s)");
2422 }
2423 }
2424 }
2425 // xhdpi display (320 dpi)
2426 else if (Navit.metrics.densityDpi >= 320)
2427 {
2428 // set the map display DPI down. otherwise everything will be very small and unreadable
2429 // and performance will be very low
2430 if (p.PREF_shrink_on_high_dpi)
2431 {
2432 NavitGraphics.Global_want_dpi = NavitGraphics.Global_Scaled_DPI_normal;
2433 }
2434 NavitGraphics.Global_want_dpi_other = NavitGraphics.Global_Scaled_DPI_normal;
2435
2436 Log.e("Navit", "found xhdpi device, this is not fully supported yet");
2437 Log.e("Navit", "using hdpi values for compatibility");
2438 my_display_density = "hdpi";
2439 if (xmlconfig_unpack_file)
2440 {
2441 if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2442 {
2443 Log.e("Navit", "Failed to extract navit.xml for xhdpi device(s)");
2444 }
2445 }
2446 }
2447 else
2448 {
2449 /* default, meaning we just dont know what display this is */
2450 if (xmlconfig_unpack_file)
2451 {
2452 if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2453 {
2454 Log.e("Navit", "Failed to extract navit.xml (default version)");
2455 }
2456 }
2457 }
2458 // Debug.startMethodTracing("calc");
2459
2460 // if (unsupported)
2461 // {
2462 // class CustomListener implements View.OnClickListener
2463 // {
2464 // private final Dialog dialog;
2465 //
2466 // public CustomListener(Dialog dialog)
2467 // {
2468 // this.dialog = dialog;
2469 // }
2470 //
2471 // @Override
2472 // public void onClick(View v)
2473 // {
2474 //
2475 // // Do whatever you want here
2476 //
2477 // // If tou want to close the dialog, uncomment the line below
2478 // //dialog.dismiss();
2479 // }
2480 // }
2481 //
2482 // AlertDialog.Builder dialog = new AlertDialog.Builder(this);
2483 // dialog.setTitle(Navit.get_text("WeltBild Tablet")); //TRANS
2484 // dialog.setCancelable(false);
2485 // dialog.setMessage("Your device is not supported!");
2486 // dialog.show();
2487 // //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
2488 // //theButton.setOnClickListener(new CustomListener(dialog));
2489 // }
2490
2491 int have_dpi = Navit.metrics.densityDpi;
2492 if (NavitGraphics.Global_want_dpi == have_dpi)
2493 {
2494 NavitGraphics.Global_dpi_factor = 1;
2495 }
2496 {
2497 NavitGraphics.Global_dpi_factor = ((float) NavitGraphics.Global_want_dpi / (float) have_dpi);
2498 }
2499
2500 // gggggggggggggggggggggggggg new !!!!!!!!!!!!!!!!!!!!
2501
2502 // --> dont use!! NavitMain(this, langu, android.os.Build.VERSION.SDK_INT);
2503 Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
2504
2505 // -- report share dir back to C-code --
2506 //Message msg2 = new Message();
2507 //Bundle b2 = new Bundle();
2508 //b2.putInt("Callback", 82);
2509 //b2.putString("s", NAVIT_DATA_DIR + "/share/");
2510 //msg2.setData(b2);
2511 //N_NavitGraphics.callback_handler.sendMessage(msg2);
2512 // -- report share dir back to C-code --
2513
2514 // -- report data dir back to C-code --
2515 //msg2 = new Message();
2516 //b2 = new Bundle();
2517 //b2.putInt("Callback", 84);
2518 //b2.putString("s", NAVIT_DATA_DIR + "/");
2519 //msg2.setData(b2);
2520 //N_NavitGraphics.callback_handler.sendMessage(msg2);
2521 // -- report share dir back to C-code --
2522
2523 draw_osd_thread = new drawOSDThread();
2524 draw_osd_thread.start();
2525
2526 cwthr = new CWorkerThread();
2527 cwthr.start();
2528
2529 // --new--
2530 cwthr.StartMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), "" + Navit.metrics.densityDpi, NAVIT_DATA_DIR, NAVIT_DATA_SHARE_DIR);
2531
2532 // --old--
2533 // NavitMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density);
2534 // --old--
2535 // NavitActivity(3);
2536
2537 // CAUTION: don't use android.os.Build.VERSION.SDK_INT if <uses-sdk android:minSdkVersion="3" />
2538 // You will get exception on all devices with Android 1.5 and lower
2539 // because Build.VERSION.SDK_INT is since SDK 4 (Donut 1.6)
2540
2541 // (see: http://developer.android.com/guide/appendix/api-levels.html)
2542 // Platform Version API Level
2543 // =============================================
2544 // Android 4.0.3 15
2545 // Android 4.0, 4.0.1, 4.0.2 14
2546 // Android 3.2 13
2547 // Android 3.1 12
2548 // Android 3.0 11
2549 // Android 2.3.3 10
2550 // Android 2.3.1 9
2551 // Android 2.2 8
2552 // Android 2.1 7
2553 // Android 2.0.1 6
2554 // Android 2.0 5
2555 // Android 1.6 4
2556 // Android 1.5 3
2557 // Android 1.1 2
2558 // Android 1.0 1
2559
2560 Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
2561
2562 //try
2563 //{
2564 // Thread.sleep(2000);
2565 //}
2566 //catch (InterruptedException e)
2567 //{
2568 //}
2569
2570 //getPrefs();
2571 //activatePrefs();
2572
2573 // unpack some localized Strings
2574 // a test now, later we will unpack all needed strings for java, here at this point!!
2575 //String x = NavitGraphics.getLocalizedString("Austria");
2576 //Log.e("Navit", "x=" + x);
2577 Navit.show_mem_used();
2578
2579 /*
2580 * GpsStatus.Listener listener = new GpsStatus.Listener()
2581 * {
2582 * public void onGpsStatusChanged(int event)
2583 * {
2584 * //System.out.println("xxxxx");
2585 * if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS)
2586 * {
2587 * }
2588 * }
2589 * };
2590 */
2591
2592 try
2593 {
2594 Intent sintent = new Intent();
2595 sintent.setPackage("com.zoffcc.applications.zanavi_msg");
2596 sintent.setAction("com.zoffcc.applications.zanavi_msg.ZanaviCloudService");
2597 // ComponentName cname = startService(sintent);
2598 // Log.i("NavitPlugin", "start Service res=" + cname);
2599 // System.out.println("NavitPlugin:bind to Service");
2600 boolean res_bind = bindService(sintent, serviceConnection, Context.BIND_AUTO_CREATE);
2601 // Log.i("NavitPlugin", "bind to Service res=" + res_bind);
2602 }
2603 catch (Exception e)
2604 {
2605 e.printStackTrace();
2606 }
2607 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
2608 }
2609
2610 public static void show_mem_used() // wrapper
2611 {
2612 try
2613 {
2614 Message msg = Navit_progress_h.obtainMessage();
2615 Bundle b = new Bundle();
2616 msg.what = 14;
2617 msg.setData(b);
2618 Navit_progress_h.sendMessage(msg);
2619 }
2620 catch (Exception e)
2621 {
2622 e.printStackTrace();
2623 }
2624 }
2625
2626 public static void show_mem_used_real()
2627 {
2628 try
2629 {
2630 if (p.PREF_show_debug_messages)
2631 {
2632 // --------- OLD method -----------
2633 // --------- OLD method -----------
2634 // int usedMegs;
2635 // //System.gc();
2636 // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
2637 // //Debug.MemoryInfo meminfo = new Debug.MemoryInfo();
2638 // //Debug.getMemoryInfo(meminfo);
2639 //
2640 // if (usedMegs_old != usedMegs)
2641 // {
2642 // String usedMegsString = String.format("Memory Used: %d MB", usedMegs);
2643 // //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);
2644 // Navit.set_debug_messages2(usedMegsString);
2645 // }
2646 // usedMegs_old = usedMegs;
2647 // --------- OLD method -----------
2648 // --------- OLD method -----------
2649
2650 // --------- NEW method -----------
2651 // --------- NEW method -----------
2652 String usedMegs = logHeap(Global_Navit_Object.getClass());
2653 if (usedMegs_str_old.compareTo(usedMegs) != 0)
2654 {
2655 Navit.set_debug_messages2(usedMegs);
2656 }
2657 usedMegs_str_old = usedMegs;
2658 // --------- NEW method -----------
2659 // --------- NEW method -----------
2660 }
2661 }
2662 catch (Exception e)
2663 {
2664 e.printStackTrace();
2665 }
2666 }
2667
2668 public static void set_debug_messages(String texta, String textb, String textc)
2669 {
2670 try
2671 {
2672 NavitGraphics.debug_line_1 = texta;
2673 NavitGraphics.debug_line_2 = textb;
2674 NavitGraphics.debug_line_3 = textc;
2675 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2676 NavitGraphics.NavitMsgTv_.setLines(4);
2677 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2678 //System.out.println("invalidate 022");
2679 NavitGraphics.NavitMsgTv_.postInvalidate();
2680 }
2681 catch (Exception e)
2682 {
2683 e.printStackTrace();
2684 }
2685 }
2686
2687 public static void set_debug_messages1(String text)
2688 {
2689 try
2690 {
2691 NavitGraphics.debug_line_1 = text;
2692 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2693 NavitGraphics.NavitMsgTv_.setLines(4);
2694 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2695 //System.out.println("invalidate 023");
2696 NavitGraphics.NavitMsgTv_.postInvalidate();
2697 }
2698 catch (Exception e)
2699 {
2700 e.printStackTrace();
2701 }
2702 }
2703
2704 public static void set_debug_messages2(String text)
2705 {
2706 try
2707 {
2708 NavitGraphics.debug_line_2 = text;
2709 //NavitGraphics.NavitMsgTv_.setMaxLines(4);
2710 //NavitGraphics.NavitMsgTv_.setLines(4);
2711
2712 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2713 //System.out.println("invalidate 024");
2714 NavitGraphics.NavitMsgTv_.postInvalidate();
2715 }
2716 catch (Exception e)
2717 {
2718 e.printStackTrace();
2719 }
2720 }
2721
2722 public static void set_debug_messages3(String text)
2723 {
2724 try
2725 {
2726 NavitGraphics.debug_line_3 = text;
2727 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2728 NavitGraphics.NavitMsgTv_.setLines(4);
2729 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2730 //System.out.println("invalidate 025");
2731 NavitGraphics.NavitMsgTv_.postInvalidate();
2732 }
2733 catch (Exception e)
2734 {
2735 e.printStackTrace();
2736 }
2737 }
2738
2739 public static void set_debug_messages4(String text)
2740 {
2741 try
2742 {
2743 NavitGraphics.debug_line_4 = text;
2744 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2745 NavitGraphics.NavitMsgTv_.setLines(4);
2746 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2747 //System.out.println("invalidate 026");
2748 NavitGraphics.NavitMsgTv_.postInvalidate();
2749 }
2750 catch (Exception e)
2751 {
2752 e.printStackTrace();
2753 }
2754 }
2755
2756 public static void set_debug_messages3_wrapper(String text)
2757 {
2758 try
2759 {
2760 Message msg = Navit_progress_h.obtainMessage();
2761 Bundle b = new Bundle();
2762 msg.what = 15;
2763 b.putString("text", text);
2764 msg.setData(b);
2765 Navit_progress_h.sendMessage(msg);
2766 }
2767 catch (Exception e)
2768 {
2769 e.printStackTrace();
2770 }
2771 }
2772
2773 public static void set_debug_messages_say_wrapper(String text)
2774 {
2775 try
2776 {
2777 Message msg = Navit_progress_h.obtainMessage();
2778 Bundle b = new Bundle();
2779 msg.what = 30;
2780 b.putString("text", text);
2781 msg.setData(b);
2782 Navit_progress_h.sendMessage(msg);
2783 }
2784 catch (Exception e)
2785 {
2786 e.printStackTrace();
2787 }
2788 }
2789
2790 protected void onNewIntent(Intent intent)
2791 {
2792 super.onNewIntent(intent);
2793
2794 try
2795 {
2796 System.out.println("XXIIXX(2):111");
2797 String mid_str = intent.getExtras().getString("com.zoffcc.applications.zanavi.mid");
2798
2799 System.out.println("XXIIXX(2):111a:mid_str=" + mid_str);
2800
2801 if (mid_str != null)
2802 {
2803 if (mid_str.equals("201:UPDATE-APP"))
2804 {
2805 // a new ZANavi version is available, show something to the user here -------------------
2806 // a new ZANavi version is available, show something to the user here -------------------
2807 // a new ZANavi version is available, show something to the user here -------------------
2808 // a new ZANavi version is available, show something to the user here -------------------
2809 // a new ZANavi version is available, show something to the user here -------------------
2810 // a new ZANavi version is available, show something to the user here -------------------
2811 }
2812 else if (mid_str.startsWith("202:UPDATE-MAP:"))
2813 {
2814 // System.out.println("need to update1:" + mid_str);
2815 // System.out.println("need to update2:" + mid_str.substring(15));
2816
2817 auto_start_update_map(mid_str.substring(15));
2818 }
2819 }
2820
2821 System.out.println("XXIIXX(2):111b:mid_str=" + mid_str);
2822 }
2823 catch (Exception e)
2824 {
2825 e.printStackTrace();
2826 System.out.println("XXIIXX(2):111:EEEE");
2827 }
2828
2829 // ---- Intent dump ----
2830 // ---- Intent dump ----
2831 // ---- Intent dump ----
2832 // ---- Intent dump ----
2833 try
2834 {
2835 System.out.println("XXIIXX(2):" + intent);
2836 Bundle bundle77 = intent.getExtras();
2837 System.out.println("XXIIXX(2):" + intent_flags_to_string(intent.getFlags()));
2838 if (bundle77 == null)
2839 {
2840 System.out.println("XXIIXX(2):" + "null");
2841 }
2842 else
2843 {
2844 for (String key : bundle77.keySet())
2845 {
2846 Object value = bundle77.get(key);
2847 System.out.println("XXIIXX(2):" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
2848 }
2849 }
2850 }
2851 catch (Exception ee22)
2852 {
2853 String exst = Log.getStackTraceString(ee22);
2854 System.out.println("XXIIXX(2):ERR:" + exst);
2855 }
2856 // ---- Intent dump ----
2857 // ---- Intent dump ----
2858 // ---- Intent dump ----
2859 // ---- Intent dump ----
2860
2861 Log.e("Navit", "3:**1**A " + intent.getAction());
2862 Log.e("Navit", "3:**1**D " + intent.getDataString());
2863 Log.e("Navit", "3:**1**S " + intent.toString());
2864 try
2865 {
2866 Log.e("Navit", "3:**1**S " + intent.getExtras().describeContents());
2867 }
2868 catch (Exception ee3)
2869 {
2870 }
2871
2872 // if (Navit.startup_intent == null)
2873 {
2874 try
2875 {
2876 // make a copy of the given intent object
2877 // Navit.startup_intent = intent.cloneFilter();
2878 Navit.startup_intent = intent;
2879
2880 Log.e("Navit", "3a:**1**001");
2881 Bundle extras2 = intent.getExtras();
2882 Log.e("Navit", "3a:**1**002");
2883 try
2884 {
2885 Navit.startup_intent.putExtras(extras2);
2886 Log.e("Navit", "3a:**1**003");
2887 }
2888 catch (Exception e4)
2889 {
2890 if (startup_intent.getDataString() != null)
2891 {
2892 // we have a "geo:" thingy intent, use it
2893 // or "gpx file"
2894 Log.e("Navit", "3c:**1**A " + startup_intent.getAction());
2895 Log.e("Navit", "3c:**1**D " + startup_intent.getDataString());
2896 Log.e("Navit", "3c:**1**S " + startup_intent.toString());
2897 }
2898 else
2899 {
2900 Log.e("Navit", "3X:**1**X ");
2901 Navit.startup_intent = null;
2902 }
2903
2904 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
2905 Navit.startup_intent_timestamp = System.currentTimeMillis();
2906
2907 return;
2908 }
2909
2910 // Intent { act=android.intent.action.VIEW
2911 // cat=[android.intent.category.DEFAULT]
2912 // dat=file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
2913 // cmp=com.zoffcc.applications.zanavi/.Navit }
2914
2915 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
2916 Navit.startup_intent_timestamp = System.currentTimeMillis();
2917 Log.e("Navit", "3a:**1**A " + startup_intent.getAction());
2918 Log.e("Navit", "3a:**1**D " + startup_intent.getDataString());
2919 Log.e("Navit", "3a:**1**S " + startup_intent.toString());
2920 if (extras2 != null)
2921 {
2922 long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
2923 // System.out.println("DH:a007 l=" + l);
2924 if (l != 0L)
2925 {
2926 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
2927 {
2928 // Log.e("Navit", "2:**1** started via drive home");
2929 // we have been called from "drive home" widget
2930
2931 // drive home
2932
2933 // check if we have a home location
2934 int home_id = find_home_point();
2935
2936 if (home_id != -1)
2937 {
2938 Message msg7 = progress_handler.obtainMessage();
2939 Bundle b7 = new Bundle();
2940 msg7.what = 2; // long Toast message
2941 b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
2942 msg7.setData(b7);
2943 progress_handler.sendMessage(msg7);
2944
2945 // clear any previous destinations
2946 Message msg2 = new Message();
2947 Bundle b2 = new Bundle();
2948 b2.putInt("Callback", 7);
2949 msg2.setData(b2);
2950 NavitGraphics.callback_handler.sendMessage(msg2);
2951
2952 // set position to middle of screen -----------------------
2953 // set position to middle of screen -----------------------
2954 // set position to middle of screen -----------------------
2955 // Message msg67 = new Message();
2956 // Bundle b67 = new Bundle();
2957 // b67.putInt("Callback", 51);
2958 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
2959 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
2960 // msg67.setData(b67);
2961 // N_NavitGraphics.callback_handler.sendMessage(msg67);
2962 // set position to middle of screen -----------------------
2963 // set position to middle of screen -----------------------
2964 // set position to middle of screen -----------------------
2965
2966 try
2967 {
2968 Thread.sleep(60);
2969 }
2970 catch (Exception e)
2971 {
2972 }
2973
2974 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);
2975
2976 // Navit.destination_set();
2977 //
2978 // // set destination to home location
2979 // String lat = String.valueOf(map_points.get(home_id).lat);
2980 // String lon = String.valueOf(map_points.get(home_id).lon);
2981 // String q = map_points.get(home_id).point_name;
2982 //
2983 // // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
2984 //
2985 // Message msg55 = new Message();
2986 // Bundle b55 = new Bundle();
2987 // b55.putInt("Callback", 3);
2988 // b55.putString("lat", lat);
2989 // b55.putString("lon", lon);
2990 // b55.putString("q", q);
2991 // msg55.setData(b55);
2992 // NavitGraphics.callback_handler.sendMessage(msg55);
2993
2994 final Thread zoom_to_route_001 = new Thread()
2995 {
2996 int wait = 1;
2997 int count = 0;
2998 int max_count = 60;
2999
3000 @Override
3001 public void run()
3002 {
3003 while (wait == 1)
3004 {
3005 try
3006 {
3007 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3008 {
3009 zoom_to_route();
3010 wait = 0;
3011 }
3012 else
3013 {
3014 wait = 1;
3015 }
3016
3017 count++;
3018 if (count > max_count)
3019 {
3020 wait = 0;
3021 }
3022 else
3023 {
3024 Thread.sleep(400);
3025 }
3026 }
3027 catch (Exception e)
3028 {
3029 }
3030 }
3031 }
3032 };
3033 zoom_to_route_001.start();
3034
3035 // try
3036 // {
3037 // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3038 // }
3039 // catch (Exception e2)
3040 // {
3041 // e2.printStackTrace();
3042 // }
3043
3044 try
3045 {
3046 Navit.follow_button_on();
3047 }
3048 catch (Exception e2)
3049 {
3050 e2.printStackTrace();
3051 }
3052 }
3053 else
3054 {
3055 // no home location set
3056 Message msg = progress_handler.obtainMessage();
3057 Bundle b = new Bundle();
3058 msg.what = 2; // long Toast message
3059 b.putString("text", Navit.get_text("No Home Location set")); //TRANS
3060 msg.setData(b);
3061 progress_handler.sendMessage(msg);
3062 }
3063
3064 }
3065 }
3066 else
3067 {
3068 if (startup_intent.getDataString() != null)
3069 {
3070 // we have a "geo:" thingy intent, use it
3071 // or "gpx file"
3072 }
3073 else
3074 {
3075 Navit.startup_intent = null;
3076 }
3077 }
3078 }
3079 else
3080 {
3081 if (startup_intent.getDataString() != null)
3082 {
3083 // we have a "geo:" thingy intent, use it
3084 }
3085 else
3086 {
3087 Navit.startup_intent = null;
3088 }
3089 }
3090 }
3091 catch (Exception e99)
3092 {
3093 Navit.startup_intent = null;
3094 }
3095
3096 }
3097
3098 }
3099
3100 @Override
3101 public void onStart()
3102 {
3103 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3104
3105 Navit.show_mem_used();
3106
3107 super.onStart();
3108
3109 Log.e("Navit", "OnStart");
3110
3111 while (Global_Init_Finished == 0)
3112 {
3113 Log.e("Navit", "OnStart:Global_Init_Finished==0 !!!!!");
3114 try
3115 {
3116 Thread.sleep(60, 0); // sleep
3117 }
3118 catch (InterruptedException e)
3119 {
3120 }
3121 }
3122
3123 cwthr.NavitActivity2(2);
3124
3125 getPrefs();
3126 activatePrefs();
3127 sun_moon__mLastCalcSunMillis = -1L;
3128
3129 // paint for bitmapdrawing on map
3130 if (p.PREF_use_anti_aliasing)
3131 {
3132 NavitGraphics.paint_for_map_display.setAntiAlias(true);
3133 }
3134 else
3135 {
3136 NavitGraphics.paint_for_map_display.setAntiAlias(false);
3137 }
3138 if (p.PREF_use_map_filtering)
3139 {
3140 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
3141 }
3142 else
3143 {
3144 NavitGraphics.paint_for_map_display.setFilterBitmap(false);
3145 }
3146
3147 // activate gps AFTER 3g-location
3148 NavitVehicle.turn_on_precise_provider();
3149
3150 Navit.show_mem_used();
3151
3152 // restore points
3153 read_map_points();
3154
3155 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3156 }
3157
3158 @Override
3159 public void onRestart()
3160 {
3161 super.onRestart();
3162 Log.e("Navit", "OnRestart");
3163
3164 while (Global_Init_Finished == 0)
3165 {
3166 Log.e("Navit", "onRestart:Global_Init_Finished==0 !!!!!");
3167 try
3168 {
3169 Thread.sleep(60, 0); // sleep
3170 }
3171 catch (InterruptedException e)
3172 {
3173 }
3174 }
3175
3176 cwthr.NavitActivity2(0);
3177 NavitVehicle.turn_on_sat_status();
3178 }
3179
3180 @SuppressLint("NewApi")
3181 @Override
3182 public void onResume()
3183 {
3184 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3185
3186 // System.gc();
3187 super.onResume();
3188
3189 // get the intent fresh !! ----------
3190 startup_intent = this.getIntent();
3191 // get the intent fresh !! ----------
3192
3193 PackageInfo pkgInfo;
3194 Navit_Plugin_001_Installed = false;
3195 try
3196 {
3197 // is the donate version installed?
3198 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_msg", 0);
3199 String sharedUserId = pkgInfo.sharedUserId;
3200 System.out.println("str nd=" + sharedUserId);
3201 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
3202 {
3203 System.out.println("##plugin 001##");
3204 Navit_Plugin_001_Installed = true;
3205 }
3206 }
3207 catch (Exception e)
3208 {
3209 e.printStackTrace();
3210 }
3211
3212 // ---- Intent dump ----
3213 // ---- Intent dump ----
3214 // ---- Intent dump ----
3215 // ---- Intent dump ----
3216
3217 try
3218 {
3219 System.out.println("XXIIXX:111");
3220 String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid");
3221 System.out.println("XXIIXX:111a:mid_str=" + mid_str);
3222
3223 if (mid_str != null)
3224 {
3225 if (mid_str.equals("201:UPDATE-APP"))
3226 {
3227 // a new ZANavi version is available, show something to the user here -------------------
3228 // a new ZANavi version is available, show something to the user here -------------------
3229 // a new ZANavi version is available, show something to the user here -------------------
3230 // a new ZANavi version is available, show something to the user here -------------------
3231 // a new ZANavi version is available, show something to the user here -------------------
3232 // a new ZANavi version is available, show something to the user here -------------------
3233 }
3234 else if (mid_str.startsWith("202:UPDATE-MAP:"))
3235 {
3236 System.out.println("need to update1:" + mid_str);
3237 System.out.println("need to update2:" + mid_str.substring(15));
3238
3239 auto_start_update_map(mid_str.substring(15));
3240 }
3241 }
3242
3243 System.out.println("XXIIXX:111b:mid_str=" + mid_str);
3244 }
3245 catch (Exception e)
3246 {
3247 e.printStackTrace();
3248 System.out.println("XXIIXX:111:EEEE");
3249 }
3250
3251 try
3252 {
3253 System.out.println("XXIIXX:" + this.getIntent());
3254 Bundle bundle77 = this.getIntent().getExtras();
3255 System.out.println("XXIIXX:" + intent_flags_to_string(this.getIntent().getFlags()));
3256 if (bundle77 == null)
3257 {
3258 System.out.println("XXIIXX:" + "null");
3259 }
3260 else
3261 {
3262 for (String key : bundle77.keySet())
3263 {
3264 Object value = bundle77.get(key);
3265 System.out.println("XXIIXX:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
3266 }
3267 }
3268 }
3269 catch (Exception ee22)
3270 {
3271 String exst = Log.getStackTraceString(ee22);
3272 System.out.println("XXIIXX:ERR:" + exst);
3273 }
3274 // ---- Intent dump ----
3275 // ---- Intent dump ----
3276 // ---- Intent dump ----
3277 // ---- Intent dump ----
3278
3279 is_paused = false;
3280
3281 Navit_doubleBackToExitPressedOnce = false;
3282
3283 app_window = getWindow();
3284
3285 Log.e("Navit", "OnResume");
3286
3287 while (Global_Init_Finished == 0)
3288 {
3289 Log.e("Navit", "OnResume:Global_Init_Finished==0 !!!!!");
3290 try
3291 {
3292 Thread.sleep(30, 0); // sleep
3293 }
3294 catch (InterruptedException e)
3295 {
3296 }
3297 }
3298
3299 //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
3300 cwthr.NavitActivity2(1);
3301
3302 try
3303 {
3304 NSp.resume_me();
3305 }
3306 catch (Exception e)
3307 {
3308 e.printStackTrace();
3309 }
3310
3311 NavitVehicle.turn_on_sat_status();
3312
3313 try
3314 {
3315 if (wl != null)
3316 {
3317 // try
3318 // {
3319 // wl.release();
3320 // }
3321 // catch (Exception e2)
3322 // {
3323 // }
3324 wl.acquire();
3325 Log.e("Navit", "WakeLock: acquire 2");
3326 }
3327 }
3328 catch (Exception e)
3329 {
3330 e.printStackTrace();
3331 }
3332
3333 //Intent caller = this.getIntent();
3334 //System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
3335 //System.out.println("C=" + caller.getComponent().flattenToString());
3336
3337 if (unsupported)
3338 {
3339 class CustomListener implements View.OnClickListener
3340 {
3341 private final Dialog dialog;
3342
3343 public CustomListener(Dialog dialog)
3344 {
3345 this.dialog = dialog;
3346 }
3347
3348 @Override
3349 public void onClick(View v)
3350 {
3351
3352 // Do whatever you want here
3353
3354 // If you want to close the dialog, uncomment the line below
3355 //dialog.dismiss();
3356 }
3357 }
3358
3359 AlertDialog.Builder dialog = new AlertDialog.Builder(this);
3360 dialog.setTitle("WeltBild Tablet");
3361 dialog.setCancelable(false);
3362 dialog.setMessage("Your device is not supported!");
3363 dialog.show();
3364 //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
3365 //theButton.setOnClickListener(new CustomListener(dialog));
3366 }
3367
3368 // reset "maps too old" flag
3369 Navit_maps_too_old = false;
3370
3371 if (Navit_maps_loaded == false)
3372 {
3373 Navit_maps_loaded = true;
3374 // activate all maps
3375 Log.e("Navit", "**** LOAD ALL MAPS **** start");
3376 Message msg3 = new Message();
3377 Bundle b3 = new Bundle();
3378 b3.putInt("Callback", 20);
3379 msg3.setData(b3);
3380 NavitGraphics.callback_handler.sendMessage(msg3);
3381 Log.e("Navit", "**** LOAD ALL MAPS **** end");
3382 }
3383
3384 try
3385 {
3386 if (!have_maps_installed())
3387 {
3388 // System.out.println("MMMM=no maps installed");
3389 // show semi transparent box "no maps installed" ------------------
3390 // show semi transparent box "no maps installed" ------------------
3391 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
3392 try
3393 {
3394 NavitGraphics.no_maps_container.setActivated(true);
3395 }
3396 catch (NoSuchMethodError e)
3397 {
3398 }
3399
3400 show_case_001();
3401
3402 // show semi transparent box "no maps installed" ------------------
3403 // show semi transparent box "no maps installed" ------------------
3404 }
3405 else
3406 {
3407 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
3408 try
3409 {
3410 NavitGraphics.no_maps_container.setActivated(false);
3411 }
3412 catch (NoSuchMethodError e)
3413 {
3414 }
3415 }
3416 }
3417 catch (Exception e)
3418 {
3419 e.printStackTrace();
3420 }
3421
3422 try
3423 {
3424 // draw map no-async
3425 Message msg = new Message();
3426 Bundle b = new Bundle();
3427 b.putInt("Callback", 64);
3428 msg.setData(b);
3429 NavitGraphics.callback_handler.sendMessage(msg);
3430 }
3431 catch (Exception e)
3432 {
3433 e.printStackTrace();
3434 }
3435
3436 String intent_data = null;
3437 try
3438 {
3439 //Log.e("Navit", "**9**A " + startup_intent.getAction());
3440 //Log.e("Navit", "**9**D " + startup_intent.getDataString());
3441
3442 int type = 1; // default = assume it's a map coords intent
3443
3444 try
3445 {
3446 String si = startup_intent.getDataString();
3447 String tmp2 = si.split(":", 2)[0];
3448 Log.e("Navit", "**9a**A " + startup_intent.getAction());
3449 Log.e("Navit", "**9a**D " + startup_intent.getDataString() + " " + tmp2);
3450 if (tmp2.equals("file"))
3451 {
3452 Log.e("Navit", "**9b**D " + startup_intent.getDataString() + " " + tmp2);
3453 if (si.toLowerCase().endsWith(".gpx"))
3454 {
3455 Log.e("Navit", "**9c**D " + startup_intent.getDataString() + " " + tmp2);
3456 type = 4;
3457 }
3458 }
3459 }
3460 catch (Exception e2)
3461 {
3462 }
3463
3464 if (type != 4)
3465 {
3466 Bundle extras = startup_intent.getExtras();
3467 // System.out.println("DH:001");
3468 if (extras != null)
3469 {
3470 // System.out.println("DH:002");
3471 long l = extras.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
3472 // System.out.println("DH:003 l=" + l);
3473 if (l != 0L)
3474 {
3475 // System.out.println("DH:004");
3476 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
3477 {
3478 // System.out.println("DH:005");
3479 type = 2; // call from drive-home-widget
3480 }
3481 // ok, now remove that key
3482 extras.remove("com.zoffcc.applications.zanavi");
3483 startup_intent.replaceExtras((Bundle) null);
3484 // System.out.println("DH:006");
3485 }
3486 }
3487 }
3488
3489 // ------------------------ BIG LOOP ------------------------
3490 // ------------------------ BIG LOOP ------------------------
3491 if (type == 2)
3492 {
3493 // drive home
3494
3495 // check if we have a home location
3496 int home_id = find_home_point();
3497
3498 if (home_id != -1)
3499 {
3500 Message msg7 = progress_handler.obtainMessage();
3501 Bundle b7 = new Bundle();
3502 msg7.what = 2; // long Toast message
3503 b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
3504 msg7.setData(b7);
3505 progress_handler.sendMessage(msg7);
3506
3507 // clear any previous destinations
3508 Message msg2 = new Message();
3509 Bundle b2 = new Bundle();
3510 b2.putInt("Callback", 7);
3511 msg2.setData(b2);
3512 NavitGraphics.callback_handler.sendMessage(msg2);
3513
3514 // set position to middle of screen -----------------------
3515 // set position to middle of screen -----------------------
3516 // set position to middle of screen -----------------------
3517 // Message msg67 = new Message();
3518 // Bundle b67 = new Bundle();
3519 // b67.putInt("Callback", 51);
3520 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
3521 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
3522 // msg67.setData(b67);
3523 // N_NavitGraphics.callback_handler.sendMessage(msg67);
3524 // set position to middle of screen -----------------------
3525 // set position to middle of screen -----------------------
3526 // set position to middle of screen -----------------------
3527
3528 try
3529 {
3530 Thread.sleep(60);
3531 }
3532 catch (Exception e)
3533 {
3534 }
3535
3536 Navit.destination_set();
3537
3538 // set destination to home location
3539 String lat = String.valueOf(map_points.get(home_id).lat);
3540 String lon = String.valueOf(map_points.get(home_id).lon);
3541 String q = map_points.get(home_id).point_name;
3542
3543 // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
3544
3545 Message msg55 = new Message();
3546 Bundle b55 = new Bundle();
3547 b55.putInt("Callback", 3);
3548 b55.putString("lat", lat);
3549 b55.putString("lon", lon);
3550 b55.putString("q", q);
3551 msg55.setData(b55);
3552 NavitGraphics.callback_handler.sendMessage(msg55);
3553
3554 final Thread zoom_to_route_001 = new Thread()
3555 {
3556 int wait = 1;
3557 int count = 0;
3558 int max_count = 60;
3559
3560 @Override
3561 public void run()
3562 {
3563 while (wait == 1)
3564 {
3565 try
3566 {
3567 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3568 {
3569 zoom_to_route();
3570 wait = 0;
3571 }
3572 else
3573 {
3574 wait = 1;
3575 }
3576
3577 count++;
3578 if (count > max_count)
3579 {
3580 wait = 0;
3581 }
3582 else
3583 {
3584 Thread.sleep(400);
3585 }
3586 }
3587 catch (Exception e)
3588 {
3589 }
3590 }
3591 }
3592 };
3593 zoom_to_route_001.start();
3594
3595 // try
3596 // {
3597 // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3598 // }
3599 // catch (Exception e2)
3600 // {
3601 // e2.printStackTrace();
3602 // }
3603
3604 try
3605 {
3606 Navit.follow_button_on();
3607 }
3608 catch (Exception e2)
3609 {
3610 e2.printStackTrace();
3611 }
3612 }
3613 else
3614 {
3615 // no home location set
3616 Message msg = progress_handler.obtainMessage();
3617 Bundle b = new Bundle();
3618 msg.what = 2; // long Toast message
3619 b.putString("text", Navit.get_text("No Home Location set")); //TRANS
3620 msg.setData(b);
3621 progress_handler.sendMessage(msg);
3622 }
3623 }
3624 else if (type == 4)
3625 {
3626
3627 if (startup_intent != null)
3628 {
3629 // Log.e("Navit", "**7**A " + startup_intent.getAction() + System.currentTimeMillis() + " " + Navit.startup_intent_timestamp);
3630 if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
3631 {
3632 Log.e("Navit", "**7**A " + startup_intent.getAction());
3633 Log.e("Navit", "**7**D " + startup_intent.getDataString());
3634 intent_data = startup_intent.getDataString();
3635 try
3636 {
3637 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
3638 }
3639 catch (Exception e1)
3640 {
3641 e1.printStackTrace();
3642 }
3643
3644 // we consumed the intent, so reset timestamp value to avoid double consuming of event
3645 Navit.startup_intent_timestamp = 0L;
3646
3647 if (intent_data != null)
3648 {
3649 // file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
3650 String tmp1;
3651 tmp1 = intent_data.split(":", 2)[1].substring(2);
3652
3653 Log.e("Navit", "**7**f=" + tmp1);
3654
3655 // convert gpx file ---------------------
3656 convert_gpx_file_real(tmp1);
3657 }
3658 }
3659 }
3660 }
3661 else if (type == 1)
3662 {
3663 if (startup_intent != null)
3664 {
3665 if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
3666 {
3667 Log.e("Navit", "**2**A " + startup_intent.getAction());
3668 Log.e("Navit", "**2**D " + startup_intent.getDataString());
3669 intent_data = startup_intent.getDataString();
3670 // we consumed the intent, so reset timestamp value to avoid double consuming of event
3671 Navit.startup_intent_timestamp = 0L;
3672
3673 if (intent_data != null)
3674 {
3675 // set position to middle of screen -----------------------
3676 // set position to middle of screen -----------------------
3677 // set position to middle of screen -----------------------
3678 // Message msg67 = new Message();
3679 // Bundle b67 = new Bundle();
3680 // b67.putInt("Callback", 51);
3681 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
3682 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
3683 // msg67.setData(b67);
3684 // N_NavitGraphics.callback_handler.sendMessage(msg67);
3685 // set position to middle of screen -----------------------
3686 // set position to middle of screen -----------------------
3687 // set position to middle of screen -----------------------
3688 }
3689 }
3690 else
3691 {
3692 Log.e("Navit", "timestamp for navigate_to expired! not using data");
3693 }
3694 }
3695
3696 System.out.println("SUI:000a " + intent_data);
3697
3698 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/"))))
3699 {
3700
3701 System.out.println("SUI:000b");
3702
3703 // better use regex later, but for now to test this feature its ok :-)
3704 // better use regex later, but for now to test this feature its ok :-)
3705
3706 // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
3707 // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
3708 // b: google.navigation:q=48.25676,16.643
3709 // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
3710 // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
3711 // sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
3712 // -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
3713 // f: google.navigation:ll=48.25676,16.643&...
3714 // c: google.navigation:ll=48.25676,16.643
3715 // h: http://maps.google.com/?q=48.222210,16.387058&z=16
3716 // i: https://maps.google.com/?q=48.222210,16.387058&z=16
3717 // i:,h: https://maps.google.com/maps/place?ftid=0x476d07075e933fc5:0xccbeba7fe1e3dd36&q=48.222210,16.387058&ui=maps_mini
3718 //
3719 // ??!!new??!!: http://maps.google.com/?cid=10549738100504591748&hl=en&gl=gb
3720
3721 String lat;
3722 String lon;
3723 String q;
3724
3725 String temp1 = null;
3726 String temp2 = null;
3727 String temp3 = null;
3728 boolean parsable = false;
3729 boolean unparsable_info_box = true;
3730 try
3731 {
3732 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
3733 }
3734 catch (Exception e1)
3735 {
3736 e1.printStackTrace();
3737 }
3738
3739 // DEBUG
3740 // DEBUG
3741 // DEBUG
3742 // intent_data = "google.navigation:q=Wien Burggasse 27";
3743 // intent_data = "google.navigation:q=48.25676,16.643";
3744 // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
3745 // intent_data = "google.navigation:ll=48.25676,16.643";
3746 // DEBUG
3747 // DEBUG
3748 // DEBUG
3749
3750 try
3751 {
3752 Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
3753 Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
3754 Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
3755 Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
3756 Log.e("Navit", "found DEBUG 4.1: yy" + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
3757 Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
3758 }
3759 catch (Exception e)
3760 {
3761 e.printStackTrace();
3762 }
3763
3764 if (!Navit.NavitStartupAlreadySearching)
3765 {
3766 if (intent_data.length() > 19)
3767 {
3768 // if h: then show target
3769 if (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/"))
3770 {
3771 Uri uri = Uri.parse(intent_data);
3772 Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
3773 parsable = true;
3774 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3775 }
3776 // if i: then show target
3777 else if (substring_without_ioobe(intent_data, 0, 24).equals("https://maps.google.com/"))
3778 {
3779 Uri uri = Uri.parse(intent_data);
3780 Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
3781 parsable = true;
3782 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3783 }
3784 // if d: then start target search
3785 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]"))))
3786 {
3787 Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
3788 Navit.NavitStartupAlreadySearching = true;
3789 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
3790 // dont use this here, already starting search, so set to "false"
3791 parsable = false;
3792 unparsable_info_box = false;
3793 }
3794 // if b: then remodel the input string to look like a:
3795 else if (substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q="))
3796 {
3797 intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
3798 Log.e("Navit", "target found (b): " + intent_data);
3799 parsable = true;
3800 }
3801 // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
3802 else if (substring_without_ioobe(intent_data, 0, 25).equals("google.navigation:///?ll="))
3803 {
3804 intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
3805 Log.e("Navit", "target found (g): " + intent_data);
3806 parsable = true;
3807 }
3808 // if e: then remodel the input string to look like a:
3809 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")))
3810 {
3811 int idx = intent_data.indexOf("&");
3812 intent_data = substring_without_ioobe(intent_data, 0, idx) + "&q=Target";
3813 Log.e("Navit", "target found (e): " + intent_data);
3814 parsable = true;
3815 }
3816 // if f: then remodel the input string to look like a:
3817 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
3818 {
3819 int idx = intent_data.indexOf("&");
3820 intent_data = intent_data.substring(0, idx) + "&q=Target";
3821 Log.e("Navit", "target found (f): " + intent_data);
3822 parsable = true;
3823 }
3824 // already looks like a: just set flag
3825 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
3826 {
3827 // dummy, just set the flag
3828 Log.e("Navit", "target found (a): " + intent_data);
3829 Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
3830 parsable = true;
3831 }
3832 // if c: then remodel the input string to look like a:
3833 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
3834 {
3835
3836 intent_data = intent_data + "&q=Target";
3837 Log.e("Navit", "target found (c): " + intent_data);
3838 parsable = true;
3839 }
3840 }
3841 }
3842 else
3843 {
3844 Log.e("Navit", "already started search from startup intent");
3845 parsable = false;
3846 unparsable_info_box = false;
3847 }
3848
3849 if (parsable)
3850 {
3851 // now string should be in form --> a:
3852 // now split the parts off
3853 temp1 = intent_data.split("&q=", -1)[0];
3854 try
3855 {
3856 temp3 = temp1.split("ll=", -1)[1];
3857 temp2 = intent_data.split("&q=", -1)[1];
3858 }
3859 catch (Exception e)
3860 {
3861 // java.lang.ArrayIndexOutOfBoundsException most likely
3862 // so let's assume we dont have '&q=xxxx'
3863 temp3 = temp1;
3864 }
3865
3866 if (temp2 == null)
3867 {
3868 // use some default name
3869 temp2 = "Target";
3870 }
3871
3872 lat = temp3.split(",", -1)[0];
3873 lon = temp3.split(",", -1)[1];
3874 q = temp2;
3875 // is the "search name" url-encoded? i think so, lets url-decode it here
3876 q = URLDecoder.decode(q);
3877 // System.out.println();
3878
3879 Navit.remember_destination(q, lat, lon);
3880 Navit.destination_set();
3881
3882 Message msg = new Message();
3883 Bundle b = new Bundle();
3884 b.putInt("Callback", 3);
3885 b.putString("lat", lat);
3886 b.putString("lon", lon);
3887 b.putString("q", q);
3888 msg.setData(b);
3889 NavitGraphics.callback_handler.sendMessage(msg);
3890
3891 final Thread zoom_to_route_002 = new Thread()
3892 {
3893 int wait = 1;
3894 int count = 0;
3895 int max_count = 60;
3896
3897 @Override
3898 public void run()
3899 {
3900 while (wait == 1)
3901 {
3902 try
3903 {
3904 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3905 {
3906 zoom_to_route();
3907 wait = 0;
3908 }
3909 else
3910 {
3911 wait = 1;
3912 }
3913
3914 count++;
3915 if (count > max_count)
3916 {
3917 wait = 0;
3918 }
3919 else
3920 {
3921 Thread.sleep(400);
3922 }
3923 }
3924 catch (Exception e)
3925 {
3926 }
3927 }
3928 }
3929 };
3930 zoom_to_route_002.start();
3931
3932 // try
3933 // {
3934 // Thread.sleep(400);
3935 // }
3936 // catch (InterruptedException e)
3937 // {
3938 // }
3939 //
3940 // // try
3941 // // {
3942 // // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3943 // // }
3944 // // catch (Exception e2)
3945 // // {
3946 // // e2.printStackTrace();
3947 // // }
3948
3949 try
3950 {
3951 Navit.follow_button_on();
3952 }
3953 catch (Exception e2)
3954
3955 {
3956 e2.printStackTrace();
3957 }
3958 }
3959 else
3960 {
3961 if (unparsable_info_box && !searchBoxShown)
3962 {
3963 try
3964 {
3965 searchBoxShown = true;
3966 String searchString = intent_data.split("q=")[1];
3967 searchString = searchString.split("&")[0];
3968 searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
3969 Log.e("Navit", "Search String :" + searchString);
3970 executeSearch(searchString);
3971 }
3972 catch (Exception e)
3973 {
3974 // safety net
3975 try
3976 {
3977 Log.e("Navit", "problem with startup search 7 str=" + intent_data);
3978 }
3979 catch (Exception e2)
3980 {
3981 e2.printStackTrace();
3982 }
3983 }
3984 }
3985 }
3986 }
3987 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 10).equals("geo:0,0?q=")))
3988 {
3989 // g: geo:0,0?q=wien%20burggasse
3990
3991 System.out.println("SUI:001");
3992
3993 boolean parsable = false;
3994 boolean unparsable_info_box = true;
3995 try
3996 {
3997 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
3998 }
3999 catch (Exception e1)
4000 {
4001 e1.printStackTrace();
4002
4003 }
4004
4005 System.out.println("SUI:002");
4006
4007 if (!Navit.NavitStartupAlreadySearching)
4008 {
4009 if (intent_data.length() > 10)
4010 {
4011 // if g: then start target search
4012 Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
4013 Navit.NavitStartupAlreadySearching = true;
4014 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
4015 // dont use this here, already starting search, so set to "false"
4016 parsable = false;
4017 unparsable_info_box = false;
4018 }
4019 }
4020 else
4021 {
4022 Log.e("Navit", "already started search from startup intent");
4023 parsable = false;
4024 unparsable_info_box = false;
4025 }
4026
4027 if (unparsable_info_box && !searchBoxShown)
4028 {
4029 try
4030 {
4031 searchBoxShown = true;
4032 String searchString = intent_data.split("q=")[1];
4033 searchString = searchString.split("&")[0];
4034 searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
4035 Log.e("Navit", "Search String :" + searchString);
4036 executeSearch(searchString);
4037 }
4038 catch (Exception e)
4039 {
4040 // safety net
4041 try
4042 {
4043 Log.e("Navit", "problem with startup search 88 str=" + intent_data);
4044 }
4045 catch (Exception e2)
4046 {
4047 e2.printStackTrace();
4048 }
4049 }
4050 }
4051
4052 }
4053 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 4).equals("geo:")))
4054 {
4055 // g: geo:16.8,46.3?z=15
4056
4057 System.out.println("SUI:002a");
4058
4059 boolean parsable = false;
4060 boolean unparsable_info_box = true;
4061
4062 String tmp1;
4063 String tmp2;
4064 String tmp3;
4065 float lat1 = 0;
4066 float lon1 = 0;
4067 int zoom1 = 15;
4068
4069 try
4070 {
4071 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
4072 }
4073 catch (Exception e1)
4074 {
4075 e1.printStackTrace();
4076 }
4077
4078 if (!Navit.NavitStartupAlreadySearching)
4079 {
4080 try
4081 {
4082 tmp1 = intent_data.split(":", 2)[1];
4083 tmp2 = tmp1.split("\\?", 2)[0];
4084 tmp3 = tmp1.split("\\?", 2)[1];
4085 lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
4086 lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
4087 zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
4088 parsable = true;
4089 }
4090 catch (Exception e4)
4091 {
4092 e4.printStackTrace();
4093 }
4094 }
4095
4096 if (parsable)
4097 {
4098 // geo: intent -> only show destination on map!
4099
4100 // set nice zoomlevel before we show destination
4101 // int zoom_want = zoom1;
4102 // //
4103 // Message msg = new Message();
4104 // Bundle b = new Bundle();
4105 // b.putInt("Callback", 33);
4106 // b.putString("s", Integer.toString(zoom_want));
4107 // msg.setData(b);
4108 // try
4109 // {
4110 // N_NavitGraphics.callback_handler.sendMessage(msg);
4111 // Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
4112 // if ((zoom_want > 8) && (zoom_want < 17))
4113 // {
4114 // Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
4115 // System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
4116 // }
4117 // }
4118 // catch (Exception e)
4119 // {
4120 // e.printStackTrace();
4121 // }
4122 // if (PREF_save_zoomlevel)
4123 // {
4124 // setPrefs_zoomlevel();
4125 // }
4126 // set nice zoomlevel before we show destination
4127
4128 try
4129 {
4130 Navit.follow_button_off();
4131 }
4132 catch (Exception e2)
4133 {
4134 e2.printStackTrace();
4135 }
4136
4137 show_geo_on_screen(lat1, lon1);
4138 // final Thread zoom_to_route_003 = new Thread()
4139 // {
4140 // @Override
4141 // public void run()
4142 // {
4143 // try
4144 // {
4145 // Thread.sleep(200);
4146 // show_geo_on_screen(lat1, lon1);
4147 // }
4148 // catch (Exception e)
4149 // {
4150 // }
4151 // }
4152 // };
4153 // zoom_to_route_003.start();
4154
4155 }
4156 }
4157 }
4158
4159 System.out.println("SUI:099 XX" + substring_without_ioobe(intent_data, 0, 10) + "XX");
4160
4161 // clear intent
4162 startup_intent = null;
4163 // ------------------------ BIG LOOP ------------------------
4164 // ------------------------ BIG LOOP ------------------------
4165 }
4166 catch (Exception e)
4167 {
4168 e.printStackTrace();
4169 System.out.println("SUI:199");
4170 }
4171
4172 // clear intent
4173 startup_intent = null;
4174
4175 // hold all map drawing -----------
4176 Message msg = new Message();
4177 Bundle b = new Bundle();
4178 b.putInt("Callback", 69);
4179 msg.setData(b);
4180 try
4181 {
4182 NavitGraphics.callback_handler.sendMessage(msg);
4183 }
4184 catch (Exception e)
4185 {
4186 }
4187 // hold all map drawing -----------
4188
4189 getPrefs();
4190 activatePrefs();
4191 sun_moon__mLastCalcSunMillis = -1L;
4192
4193 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
4194 if (p.PREF_follow_gps)
4195 {
4196 push_pin_view.setImageResource(R.drawable.pin1_down);
4197 }
4198 else
4199 {
4200 push_pin_view.setImageResource(R.drawable.pin1_up);
4201 }
4202
4203 // paint for bitmapdrawing on map
4204 if (p.PREF_use_anti_aliasing)
4205 {
4206 NavitGraphics.paint_for_map_display.setAntiAlias(true);
4207 }
4208 else
4209 {
4210 NavitGraphics.paint_for_map_display.setAntiAlias(false);
4211 }
4212 if (p.PREF_use_map_filtering)
4213 {
4214 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
4215 }
4216 else
4217 {
4218 NavitGraphics.paint_for_map_display.setFilterBitmap(false);
4219 }
4220
4221 // activate gps AFTER 3g-location
4222 NavitVehicle.turn_on_precise_provider();
4223
4224 // allow all map drawing -----------
4225 msg = new Message();
4226 b = new Bundle();
4227 b.putInt("Callback", 70);
4228 msg.setData(b);
4229 try
4230 {
4231 NavitGraphics.callback_handler.sendMessage(msg);
4232 }
4233 catch (Exception e)
4234 {
4235 }
4236 // allow all map drawing -----------
4237
4238 // --- disabled --- NavitVehicle.set_last_known_pos_fast_provider();
4239
4240 try
4241 {
4242 //Simulate = new SimGPS(NavitVehicle.vehicle_handler_);
4243 //Simulate.start();
4244 }
4245 catch (Exception e)
4246 {
4247 e.printStackTrace();
4248 }
4249
4250 try
4251 {
4252 watchmem = new WatchMem();
4253 watchmem.start();
4254 }
4255 catch (Exception e)
4256 {
4257 e.printStackTrace();
4258 }
4259
4260 // ----- check if we have some index files downloaded -----
4261 if (Navit.have_maps_installed())
4262 {
4263 if (Navit_maps_too_old)
4264 {
4265 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4266 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");
4267
4268 try
4269 {
4270 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4271 try
4272 {
4273 NavitGraphics.no_maps_container.setActivated(true);
4274 }
4275 catch (NoSuchMethodError e)
4276 {
4277 }
4278 NavitGraphics.no_maps_container.bringToFront();
4279 }
4280 catch (Exception e)
4281 {
4282 e.printStackTrace();
4283 }
4284 }
4285 else
4286 {
4287 allow_use_index_search();
4288 if (Navit_index_on_but_no_idx_files)
4289 {
4290 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4291 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");
4292
4293 try
4294 {
4295 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4296 try
4297 {
4298 NavitGraphics.no_maps_container.setActivated(true);
4299 }
4300 catch (NoSuchMethodError e)
4301 {
4302 }
4303 NavitGraphics.no_maps_container.bringToFront();
4304 }
4305 catch (Exception e)
4306 {
4307 e.printStackTrace();
4308 }
4309 }
4310 else
4311 {
4312 try
4313 {
4314 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
4315 try
4316 {
4317 NavitGraphics.no_maps_container.setActivated(false);
4318 }
4319 catch (NoSuchMethodError e)
4320 {
4321 }
4322 }
4323 catch (Exception e)
4324 {
4325 e.printStackTrace();
4326 }
4327 }
4328 }
4329 }
4330 // ----- check if we have some index files downloaded -----
4331
4332 // ---- DEBUG ----
4333 // ---- DEBUG ----
4334 // ---- DEBUG ----
4335 try
4336 {
4337 if (!NavitVehicle.is_pos_recording)
4338 {
4339 if (p.PREF_enable_debug_write_gpx)
4340 {
4341 NavitVehicle.pos_recording_start();
4342 NavitVehicle.pos_recording_add(0, 0, 0, 0, 0, 0);
4343 }
4344 }
4345 }
4346 catch (Exception e)
4347 {
4348 }
4349 // ---- DEBUG ----
4350 // ---- DEBUG ----
4351 // ---- DEBUG ----
4352
4353 // glSurfaceView.onResume();
4354
4355 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
4356 }
4357
4358 @TargetApi(Build.VERSION_CODES.FROYO)
4359 @Override
4360 public void onPause()
4361 {
4362
4363 // if COMM stuff is running, stop it!
4364 ZANaviDebugReceiver.stop_me = true;
4365
4366 // ---- DEBUG ----
4367 // ---- DEBUG ----
4368 // ---- DEBUG ----
4369 // -- dump all callbacks --
4370 try
4371 {
4372 if (p.PREF_enable_debug_functions)
4373 {
4374 Message msg99a = new Message();
4375 Bundle b99a = new Bundle();
4376 b99a.putInt("Callback", 100);
4377 msg99a.setData(b99a);
4378 N_NavitGraphics.callback_handler.sendMessage(msg99a);
4379 }
4380 }
4381 catch (Exception e)
4382 {
4383 }
4384 // -- dump all callbacks --
4385 // ---- DEBUG ----
4386 // ---- DEBUG ----
4387 // ---- DEBUG ----
4388
4389 // ---- DEBUG ----
4390 // ---- DEBUG ----
4391 // ---- DEBUG ----
4392 try
4393 {
4394 if (!Navit.is_navigating)
4395 {
4396 if (p.PREF_enable_debug_write_gpx)
4397 {
4398 NavitVehicle.pos_recording_end();
4399 }
4400 }
4401 }
4402 catch (Exception e)
4403 {
4404 }
4405 // ---- DEBUG ----
4406 // ---- DEBUG ----
4407 // ---- DEBUG ----
4408
4409 // System.out.println("@@ onPause @@");
4410 Log.e("Navit", "OnPause");
4411 try
4412 {
4413 setPrefs_zoomlevel();
4414 }
4415 catch (Exception e)
4416 {
4417 e.printStackTrace();
4418 }
4419
4420 try
4421 {
4422 watchmem.stop_me();
4423 }
4424 catch (Exception e)
4425 {
4426 e.printStackTrace();
4427 }
4428
4429 try
4430 {
4431 //watchmem.join();
4432 }
4433 catch (Exception e)
4434 {
4435 e.printStackTrace();
4436 }
4437
4438 try
4439 {
4440 //Simulate.stop_me();
4441 }
4442 catch (Exception e)
4443 {
4444 e.printStackTrace();
4445 }
4446
4447 try
4448 {
4449 //Simulate.join();
4450 }
4451 catch (Exception e)
4452 {
4453 e.printStackTrace();
4454 }
4455
4456 Navit.show_mem_used();
4457
4458 // if (!Navit.is_navigating)
4459 // {
4460 // try
4461 // {
4462 // mTts.stop();
4463 // }
4464 // catch (Exception e)
4465 // {
4466 //
4467 // }
4468 //
4469 // try
4470 // {
4471 // mTts.shutdown();
4472 // }
4473 // catch (Exception e)
4474 // {
4475 //
4476 // }
4477 //
4478 // mTts = null;
4479 // }
4480
4481 super.onPause();
4482
4483 // signal to backupmanager that data "is / could have" changed
4484 try
4485 {
4486 Class.forName("android.app.backup.BackupManager");
4487 BackupManager b = (BackupManager) backupManager;
4488 b.dataChanged();
4489 }
4490 catch (ClassNotFoundException e)
4491 {
4492 e.printStackTrace();
4493 }
4494 catch (Exception e)
4495 {
4496 e.printStackTrace();
4497 }
4498
4499 turn_off_compass();
4500
4501 // System.out.println("XXNAV: onpause:001");
4502 if (!Navit.is_navigating)
4503 {
4504 // System.out.println("XXNAV: onpause:002");
4505 NavitVehicle.turn_off_all_providers();
4506 NavitVehicle.turn_off_sat_status();
4507 // System.out.println("XXNAV: onpause:003");
4508 }
4509
4510 // Log.e("Navit", "OnPause");
4511 cwthr.NavitActivity2(-1);
4512
4513 Navit.show_mem_used();
4514
4515 try
4516 {
4517 if (wl != null)
4518 {
4519 wl.release();
4520 Log.e("Navit", "WakeLock: release 1");
4521 }
4522 }
4523 catch (Exception e)
4524 {
4525 e.printStackTrace();
4526 }
4527
4528 try
4529 {
4530 if (wl_cpu != null)
4531 {
4532 if (wl_cpu.isHeld())
4533 {
4534 wl_cpu.release();
4535 Log.e("Navit", "WakeLock CPU: release 1");
4536 }
4537 }
4538 }
4539 catch (Exception e)
4540 {
4541 e.printStackTrace();
4542 }
4543
4544 // glSurfaceView.onPause();
4545
4546 is_paused = true;
4547 }
4548
4549 @Override
4550 public void onStop()
4551 {
4552 super.onStop();
4553 Log.e("Navit", "OnStop");
4554
4555 if (!Navit.is_navigating)
4556 {
4557 NavitVehicle.turn_off_all_providers();
4558 NavitVehicle.turn_off_sat_status();
4559 }
4560
4561 cwthr.NavitActivity2(-2);
4562 Navit.show_mem_used();
4563
4564 // if (!Navit.is_navigating)
4565 // {
4566 // try
4567 // {
4568 // mTts.stop();
4569 // }
4570 // catch (Exception e)
4571 // {
4572 //
4573 // }
4574 //
4575 // try
4576 // {
4577 // mTts.shutdown();
4578 // }
4579 // catch (Exception e)
4580 // {
4581 //
4582 // }
4583 //
4584 // mTts = null;
4585 // }
4586
4587 // save points
4588 write_map_points();
4589 }
4590
4591 @Override
4592 public void onDestroy()
4593 {
4594 super.onDestroy();
4595 Log.e("Navit", "OnDestroy");
4596
4597 try
4598 {
4599 try
4600 {
4601 plugin_api.removeListener(zclientListener);
4602 }
4603 catch (Exception e)
4604 {
4605 e.printStackTrace();
4606 Log.i("NavitPlugin", "Failed to remove Listener", e);
4607 }
4608 unbindService(serviceConnection);
4609 Log.i("NavitPlugin", "Unbind from the service");
4610 }
4611 catch (Throwable t)
4612 {
4613 // catch any issues, typical for destroy routines
4614 // even if we failed to destroy something, we need to continue destroying
4615 Log.i("NavitPlugin", "Failed to unbind from the service", t);
4616 }
4617
4618 try
4619 {
4620 mTts.stop();
4621 }
4622 catch (Exception e)
4623 {
4624
4625 }
4626
4627 try
4628 {
4629 mTts.shutdown();
4630 }
4631 catch (Exception e)
4632 {
4633
4634 }
4635
4636 mTts = null;
4637
4638 // ----- service stop -----
4639 // ----- service stop -----
4640 System.out.println("Navit:onDestroy -> stop ZANaviMapDownloaderService ---------");
4641 stopService(Navit.ZANaviMapDownloaderServiceIntent);
4642 try
4643 {
4644 Thread.sleep(1000);
4645 }
4646 catch (InterruptedException e)
4647 {
4648 }
4649 // ----- service stop -----
4650 // ----- service stop -----
4651
4652 NavitActivity(-3);
4653 Navit.show_mem_used();
4654 }
4655
4656 public void setActivityResult(int requestCode, NavitActivityResult ActivityResult)
4657 {
4658 Log.e("Navit", "setActivityResult " + requestCode);
4659 ActivityResults[requestCode] = ActivityResult;
4660 }
4661
4662 @Override
4663 public boolean onKeyUp(int keyCode, KeyEvent event)
4664 {
4665 if (keyCode == KeyEvent.KEYCODE_MENU)
4666 {
4667 if (cur_menu != null)
4668 {
4669 // open the overflow menu
4670 cur_menu.performIdentifierAction(R.id.item_overflow, 0);
4671 return true;
4672 }
4673 }
4674 return super.onKeyUp(keyCode, event);
4675 }
4676
4677 // @Override
4678 // public boolean onKeyDown(int keyCode, KeyEvent event)
4679 // {
4680 // if (keyCode == KeyEvent.KEYCODE_MENU)
4681 // {
4682 // return true;
4683 // }
4684 // return super.onKeyUp(keyCode, event);
4685 // }
4686
4687 @Override
4688 public boolean onPrepareOptionsMenu(Menu menu)
4689 {
4690 super.onPrepareOptionsMenu(menu);
4691 //
4692 menu.clear();
4693
4694 // load the menu from XML
4695 getMenuInflater().inflate(R.menu.actionbaricons, menu);
4696
4697 // NavitOverflowMenuItemID = R.id.item_overflow_menu_button;
4698 menu.findItem(R.id.share_menu_destination).setTitle(Navit.get_text("Share Destination"));
4699 menu.findItem(R.id.share_menu_location).setTitle(Navit.get_text("Share my Location"));
4700 menu.findItem(R.id.search_menu_offline).setTitle(get_text("address search (offline)"));
4701 menu.findItem(R.id.search_menu_online).setTitle(get_text("address search (online)"));
4702 menu.findItem(R.id.item_recentdest_menu_button).setTitle(get_text("Recent destinations"));
4703 menu.findItem(R.id.item_settings_menu_button).setTitle(get_text("Settings"));
4704 menu.findItem(R.id.item_search_menu_button).setTitle(get_text("Search"));
4705 menu.findItem(R.id.item_download_menu_button).setTitle(get_text("downloading map"));
4706 //
4707 menu.findItem(R.id.overflow_share_location).setTitle(Navit.get_text("Share my Location"));
4708 menu.findItem(R.id.overflow_share_destination).setTitle(Navit.get_text("Share Destination"));
4709 menu.findItem(R.id.overflow_settings).setTitle(Navit.get_text("Settings"));
4710 menu.findItem(R.id.overflow_zoom_to_route).setTitle(Navit.get_text("Zoom to Route"));
4711
4712 if (ZANaviNormalDonateActivity.on_amazon_device)
4713 {
4714 menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate"));
4715 }
4716 else
4717 {
4718 menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate with Google Play"));
4719 }
4720 menu.findItem(R.id.overflow_donate_bitcoins_item).setTitle(Navit.get_text("Donate with Bitcoin"));
4721 //. TRANSLATORS: text to translate is: exit ZANavi
4722 menu.findItem(R.id.overflow_exit).setTitle(Navit.get_text("exit navit"));
4723 menu.findItem(R.id.overflow_toggle_poi).setTitle(Navit.get_text("toggle POI"));
4724 menu.findItem(R.id.overflow_announcer_on).setTitle(Navit.get_text("Announcer On"));
4725 menu.findItem(R.id.overflow_announcer_off).setTitle(Navit.get_text("Announcer Off"));
4726 menu.findItem(R.id.overflow_download_maps).setTitle(Navit.get_text("download maps"));
4727 menu.findItem(R.id.overflow_delete_maps).setTitle(Navit.get_text("delete maps"));
4728 menu.findItem(R.id.overflow_maps_age).setTitle(Navit.get_text("show Maps age"));
4729 menu.findItem(R.id.overflow_coord_dialog).setTitle(Navit.get_text("Coord Dialog"));
4730 menu.findItem(R.id.overflow_add_traffic_block).setTitle(Navit.get_text("add Traffic block"));
4731 menu.findItem(R.id.overflow_clear_traffic_block).setTitle(Navit.get_text("clear Traffic blocks"));
4732 menu.findItem(R.id.overflow_convert_gpx_file).setTitle(Navit.get_text("convert GPX file"));
4733 menu.findItem(R.id.overflow_replay_gps_file).setTitle(Navit.get_text("replay a ZANavi gps file"));
4734 menu.findItem(R.id.overflow_clear_gpx_map).setTitle(Navit.get_text("clear GPX map"));
4735 // menu.findItem(R.id.overflow_dummy2)
4736 menu.findItem(R.id.overflow_demo_v_normal).setTitle(get_text("Demo Vehicle") + " [normal]");
4737 menu.findItem(R.id.overflow_demo_v_fast).setTitle(get_text("Demo Vehicle") + " [fast]");
4738 menu.findItem(R.id.overflow_speech_texts).setTitle(Navit.get_text("Speech Texts"));
4739 menu.findItem(R.id.overflow_nav_commands).setTitle(Navit.get_text("Nav. Commands"));
4740 menu.findItem(R.id.overflow_toggle_route_graph).setTitle(Navit.get_text("toggle Routegraph"));
4741 //menu.findItem(R.id.overflow_dummy1)
4742 menu.findItem(R.id.overflow_export_map_points_to_sdcard).setTitle(Navit.get_text("export Destinations"));
4743 menu.findItem(R.id.overflow_import_map_points_from_sdcard).setTitle(Navit.get_text("import Destinations"));
4744 menu.findItem(R.id.overflow_send_feedback).setTitle(Navit.get_text("send feedback"));
4745 menu.findItem(R.id.overflow_online_help).setTitle(Navit.get_text("online Help"));
4746 //. TRANSLATORS: it means: "show current target in google maps"
4747 //. TRANSLATORS: please keep this text short, to fit in the android menu!
4748 menu.findItem(R.id.overflow_target_in_gmaps).setTitle(Navit.get_text("Target in gmaps"));
4749 //
4750 //
4751 menu.findItem(R.id.item_share_menu_button).setTitle(get_text("Share"));
4752
4753 Display display_ = getWindowManager().getDefaultDisplay();
4754 Log.e("Navit", "Navit width in DP -> " + display_.getWidth() / Navit.metrics.density);
4755 Log.e("Navit", "Navit width in DP -> density=" + Navit.metrics.density);
4756
4757 try
4758 {
4759 View v4 = findViewById(R.id.item_settings_menu_button);
4760 // Log.e("Navit", "Navit width in DP -> v4=" + v4);
4761 if ((v4 != null) && (v4.getWidth() > 0))
4762 {
4763 Log.e("Navit", "Navit width in DP -> v4.w=" + v4.getWidth());
4764 MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
4765 // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
4766 // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
4767 Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
4768 actionbar_item_width = (int) ((v4.getWidth() + (menuItem.getIcon().getIntrinsicWidth() * 1.5f)) / 2);
4769 }
4770 else
4771 {
4772 MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
4773 // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
4774 // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
4775 Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
4776 actionbar_item_width = (int) ((menuItem.getIcon().getIntrinsicWidth()) * 1.7f);
4777 }
4778
4779 actionbar_items_will_fit = display_.getWidth() / actionbar_item_width;
4780 Log.e("Navit", "Navit width in DP -> number of items that will fit=" + actionbar_items_will_fit);
4781 if (actionbar_items_will_fit > 6) // now we need to fit max. 6 items on actionbar
4782 {
4783 actionbar_all_items_will_fit = true;
4784 }
4785 else
4786 {
4787 actionbar_all_items_will_fit = false;
4788 }
4789 }
4790 catch (Exception e)
4791 {
4792 if ((display_.getWidth() / Navit.metrics.density) < NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR)
4793 {
4794 actionbar_all_items_will_fit = false;
4795 }
4796 else
4797 {
4798 actionbar_all_items_will_fit = true;
4799 }
4800 }
4801
4802 if (actionbar_all_items_will_fit == false)
4803 {
4804 menu.findItem(R.id.item_share_menu_button).setVisible(false);
4805 menu.findItem(R.id.overflow_share_location).setVisible(true);
4806 if (NavitGraphics.CallbackDestinationValid2() == 0)
4807 {
4808 menu.findItem(R.id.overflow_share_destination).setVisible(false);
4809 }
4810 else
4811 {
4812 menu.findItem(R.id.overflow_share_destination).setVisible(true);
4813 }
4814
4815 if (actionbar_items_will_fit < 6)
4816 {
4817 // also push the settings icons to overflow menu
4818 menu.findItem(R.id.item_settings_menu_button).setVisible(false);
4819 menu.findItem(R.id.overflow_settings).setVisible(true);
4820 }
4821 else
4822 {
4823 menu.findItem(R.id.item_settings_menu_button).setVisible(true);
4824 menu.findItem(R.id.overflow_settings).setVisible(false);
4825 }
4826 }
4827 else
4828 {
4829 menu.findItem(R.id.item_settings_menu_button).setVisible(true);
4830 menu.findItem(R.id.overflow_settings).setVisible(false);
4831 menu.findItem(R.id.overflow_share_location).setVisible(false);
4832 menu.findItem(R.id.overflow_share_destination).setVisible(false);
4833 menu.findItem(R.id.item_share_menu_button).setVisible(true);
4834 }
4835
4836 cur_menu = menu;
4837
4838 if (actionabar_download_icon_visible)
4839 {
4840 menu.findItem(R.id.item_download_menu_button).setVisible(true);
4841 }
4842 else
4843 {
4844 menu.findItem(R.id.item_download_menu_button).setVisible(false);
4845 }
4846
4847 if (NavitGraphics.CallbackDestinationValid2() > 0)
4848 {
4849 menu.findItem(R.id.item_endnavigation_menu_button).setVisible(true);
4850 menu.findItem(R.id.item_endnavigation_menu_button).setTitle(get_text("Stop Navigation"));
4851 menu.findItem(R.id.overflow_zoom_to_route).setVisible(true);
4852 menu.findItem(R.id.overflow_target_in_gmaps).setVisible(true);
4853 menu.findItem(R.id.share_menu_destination).setVisible(true);
4854 }
4855 else
4856 {
4857 menu.findItem(R.id.item_endnavigation_menu_button).setVisible(false);
4858 menu.findItem(R.id.overflow_zoom_to_route).setVisible(false);
4859 menu.findItem(R.id.overflow_target_in_gmaps).setVisible(false);
4860 menu.findItem(R.id.share_menu_destination).setVisible(false);
4861 }
4862
4863 if (Navit_Announcer == true)
4864 {
4865 menu.findItem(R.id.overflow_announcer_off).setVisible(true);
4866 menu.findItem(R.id.overflow_announcer_on).setVisible(false);
4867 }
4868 else
4869 {
4870 menu.findItem(R.id.overflow_announcer_off).setVisible(false);
4871 menu.findItem(R.id.overflow_announcer_on).setVisible(true);
4872 }
4873
4874 if (p.PREF_enable_debug_functions)
4875 {
4876 menu.findItem(R.id.overflow_dummy2).setVisible(true);
4877 menu.findItem(R.id.overflow_demo_v_normal).setVisible(true);
4878 menu.findItem(R.id.overflow_demo_v_fast).setVisible(true);
4879 menu.findItem(R.id.overflow_speech_texts).setVisible(true);
4880 menu.findItem(R.id.overflow_nav_commands).setVisible(true);
4881 menu.findItem(R.id.overflow_toggle_route_graph).setVisible(true);
4882 menu.findItem(R.id.overflow_replay_gps_file).setVisible(true);
4883 }
4884 else
4885 {
4886 menu.findItem(R.id.overflow_dummy2).setVisible(false);
4887 menu.findItem(R.id.overflow_demo_v_normal).setVisible(false);
4888 menu.findItem(R.id.overflow_demo_v_fast).setVisible(false);
4889 menu.findItem(R.id.overflow_speech_texts).setVisible(false);
4890 menu.findItem(R.id.overflow_nav_commands).setVisible(false);
4891 menu.findItem(R.id.overflow_toggle_route_graph).setVisible(false);
4892 menu.findItem(R.id.overflow_replay_gps_file).setVisible(false);
4893 }
4894
4895 return true;
4896 }
4897
4898 public void start_targetsearch_from_intent(String target_address)
4899 {
4900 Navit_last_address_partial_match = true; // this will overwrite the default setting --> this is not good
4901 Navit_last_address_search_string = target_address;
4902 Navit_last_address_hn_string = "";
4903
4904 // ----------- CONFIG ---------
4905 // ----------- CONFIG ---------
4906 // ----------- CONFIG ---------
4907 Boolean use_online_searchmode_here = true;
4908 Boolean hide_duplicates_searchmode_here = false;
4909 // ----------- CONFIG ---------
4910 // ----------- CONFIG ---------
4911 // ----------- CONFIG ---------
4912
4913 int dialog_num_;
4914
4915 if (use_online_searchmode_here)
4916 {
4917 dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG;
4918 Navit.use_index_search = false;
4919 Log.e("Navit", "*google*:online search");
4920 }
4921 else
4922 {
4923 dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE;
4924 Navit.use_index_search = Navit.allow_use_index_search();
4925 }
4926
4927 // clear results
4928 Navit.NavitAddressResultList_foundItems.clear();
4929 Navit.Navit_Address_Result_double_index.clear();
4930 Navit.NavitSearchresultBarIndex = -1;
4931 Navit.NavitSearchresultBar_title = "";
4932 Navit.NavitSearchresultBar_text = "";
4933 search_hide_duplicates = false;
4934
4935 if (Navit_last_address_search_string.equals(""))
4936 {
4937 // empty search string entered
4938 Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
4939 }
4940 else
4941 {
4942 // show dialog
4943 try
4944 {
4945 Log.e("Navit", "*google*:call-11: (0)num " + dialog_num_);
4946 }
4947 catch (Exception e)
4948 {
4949 e.printStackTrace();
4950 }
4951
4952 if (hide_duplicates_searchmode_here)
4953 {
4954 search_hide_duplicates = true;
4955 // hide duplicates when searching
4956 // hide duplicates when searching
4957 Message msg22 = new Message();
4958 Bundle b22 = new Bundle();
4959 b22.putInt("Callback", 45);
4960 msg22.setData(b22);
4961 NavitGraphics.callback_handler.sendMessage(msg22);
4962 // hide duplicates when searching
4963 // hide duplicates when searching
4964 }
4965
4966 Message msg = progress_handler.obtainMessage();
4967 Bundle b = new Bundle();
4968 msg.what = 11;
4969 b.putInt("dialog_num", dialog_num_);
4970 msg.setData(b);
4971 progress_handler.sendMessage(msg);
4972 }
4973 }
4974
4975 @Override
4976 public boolean onCreateOptionsMenu(Menu menu)
4977 {
4978 super.onCreateOptionsMenu(menu);
4979
4980 return true;
4981 }
4982
4983 @Override
4984 public boolean onOptionsItemSelected(MenuItem item)
4985 {
4986 //System.out.println("menu button pressed ID=" + item.getItemId());
4987
4988 if ((item.getItemId() == R.id.share_menu_destination) || (item.getItemId() == R.id.overflow_share_destination) || (item.getItemId() == 23020))
4989 {
4990 // System.out.println("share destination pressed ID=" + item.getItemId());
4991 // ------------
4992 // ------------
4993 // share the current destination with your friends
4994 String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
4995 if (current_target_string2.equals("x:x"))
4996 {
4997 Log.e("Navit", "no target set!");
4998 }
4999 else
5000 {
5001 try
5002 {
5003 String tmp[] = current_target_string2.split(":", 2);
5004
5005 if (Navit.OSD_route_001.arriving_time_valid)
5006 {
5007 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
5008 }
5009 else
5010 {
5011 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5012 }
5013
5014 }
5015 catch (Exception e)
5016 {
5017 e.printStackTrace();
5018 Log.e("Navit", "problem with target!");
5019 }
5020 }
5021 return true;
5022 }
5023 else if (item.getItemId() == R.id.item_download_menu_button)
5024 {
5025 // System.out.println("download icon pressed(1) ID=" + item.getItemId());
5026
5027 Intent mapdownload_cancel_activity = new Intent(this, ZANaviDownloadMapCancelActivity.class);
5028 mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
5029 startActivity(mapdownload_cancel_activity);
5030
5031 return true;
5032 }
5033 else if ((item.getItemId() == R.id.share_menu_location) || (item.getItemId() == R.id.overflow_share_location) || (item.getItemId() == 23000))
5034 {
5035 // System.out.println("share location pressed ID=" + item.getItemId());
5036 // ------------
5037 // ------------
5038 // share the current location with your friends
5039 location_coords cur_target = null;
5040 try
5041 {
5042 geo_coord tmp = get_current_vehicle_position();
5043 cur_target.lat = tmp.Latitude;
5044 cur_target.lon = tmp.Longitude;
5045 // cur_target = NavitVehicle.get_last_known_pos();
5046 }
5047 catch (Exception e)
5048 {
5049 }
5050
5051 if (cur_target == null)
5052 {
5053 Log.e("Navit", "no location found!");
5054 }
5055 else
5056 {
5057 try
5058 {
5059 share_location(String.valueOf(cur_target.lat), String.valueOf(cur_target.lon), Navit.get_text("my Location"), Navit.get_text("my Location"), "", false);
5060 }
5061 catch (Exception e)
5062 {
5063 e.printStackTrace();
5064 Log.e("Navit", "problem with location!");
5065 }
5066 }
5067 return true;
5068 }
5069 else if ((item.getItemId() == R.id.item_settings_menu_button) || (item.getItemId() == R.id.overflow_settings) || (item.getItemId() == 490))
5070 {
5071 // open settings menu
5072 Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
5073 startActivity(settingsActivity);
5074
5075 return true;
5076 }
5077 else if (item.getItemId() == R.id.search_menu_offline)
5078 {
5079 // ok startup address search activity (offline binfile search)
5080 Navit.use_index_search = Navit.allow_use_index_search();
5081 Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
5082 search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5083 search_intent2.putExtra("address_string", Navit_last_address_search_string);
5084 search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
5085 search_intent2.putExtra("type", "offline");
5086 search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);
5087
5088 String pm_temp2 = "0";
5089 if (Navit_last_address_partial_match)
5090 {
5091 pm_temp2 = "1";
5092 }
5093
5094 search_intent2.putExtra("partial_match", pm_temp2);
5095
5096 Navit.use_index_search = Navit.allow_use_index_search();
5097 if (Navit.use_index_search)
5098 {
5099 this.startActivityForResult(search_intent2, NavitAddressResultList_id);
5100 }
5101 else
5102 {
5103 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
5104 }
5105
5106 return true;
5107 }
5108 else if (item.getItemId() == R.id.search_menu_online)
5109 {
5110 // ok startup address search activity (online google maps search)
5111 Navit.use_index_search = false;
5112 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
5113 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5114 search_intent.putExtra("address_string", Navit_last_address_search_string);
5115 //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
5116 search_intent.putExtra("type", "online");
5117 String pm_temp = "0";
5118 if (Navit_last_address_partial_match)
5119 {
5120 pm_temp = "1";
5121 }
5122 search_intent.putExtra("partial_match", pm_temp);
5123 this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
5124
5125 return true;
5126 }
5127 else if (item.getItemId() == R.id.item_endnavigation_menu_button)
5128 {
5129 // stop navigation (this menu should only appear when navigation is actually on!)
5130 NavitGraphics.deactivate_nav_wakelock();
5131 Message msg2 = new Message();
5132 Bundle b2 = new Bundle();
5133 b2.putInt("Callback", 7);
5134 msg2.setData(b2);
5135 NavitGraphics.callback_handler.sendMessage(msg2);
5136 Log.e("Navit", "stop navigation");
5137
5138 if (p.PREF_enable_debug_write_gpx)
5139 {
5140 NavitVehicle.speech_recording_end();
5141 }
5142
5143 // redraw all OSD elements
5144 Navit.OSD_route_001.arriving_time_valid = false;
5145 Navit.OSD_route_001.arriving_secs_to_dest_valid = false;
5146 Navit.OSD_route_001.driving_distance_to_target_valid = false;
5147 Navit.OSD_nextturn.nextturn_distance_valid = false;
5148 Navit.OSD_nextturn.nextturn_image_valid = false;
5149 Navit.OSD_compass.direct_distance_to_target_valid = false;
5150 NavitGraphics.OSD_new.postInvalidate();
5151
5152 return true;
5153 }
5154 else if (item.getItemId() == R.id.item_recentdest_menu_button)
5155 {
5156 // show recent destination list
5157 Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
5158 this.startActivityForResult(i2, Navit.NavitRecentDest_id);
5159
5160 return true;
5161 }
5162 else if (item.getItemId() == R.id.overflow_zoom_to_route)
5163 {
5164 return onOptionsItemSelected_wrapper(11);
5165 }
5166 else if (item.getItemId() == R.id.overflow_donate_item)
5167 {
5168 return onOptionsItemSelected_wrapper(26);
5169 }
5170 else if (item.getItemId() == R.id.overflow_donate_bitcoins_item)
5171 {
5172 return onOptionsItemSelected_wrapper(27);
5173 }
5174 else if (item.getItemId() == R.id.overflow_exit)
5175 {
5176 return onOptionsItemSelected_wrapper(99);
5177 }
5178 else if (item.getItemId() == R.id.overflow_toggle_poi)
5179 {
5180 return onOptionsItemSelected_wrapper(5);
5181 }
5182 else if (item.getItemId() == R.id.overflow_announcer_on)
5183 {
5184 return onOptionsItemSelected_wrapper(13);
5185 }
5186 else if (item.getItemId() == R.id.overflow_announcer_off)
5187 {
5188 return onOptionsItemSelected_wrapper(12);
5189 }
5190 else if (item.getItemId() == R.id.overflow_download_maps)
5191 {
5192 return onOptionsItemSelected_wrapper(3);
5193 }
5194 else if (item.getItemId() == R.id.overflow_delete_maps)
5195 {
5196 return onOptionsItemSelected_wrapper(8);
5197 }
5198 else if (item.getItemId() == R.id.overflow_maps_age)
5199 {
5200 return onOptionsItemSelected_wrapper(17);
5201 }
5202 else if (item.getItemId() == R.id.overflow_coord_dialog)
5203 {
5204 return onOptionsItemSelected_wrapper(19);
5205 }
5206 else if (item.getItemId() == R.id.overflow_add_traffic_block)
5207 {
5208 return onOptionsItemSelected_wrapper(21);
5209 }
5210 else if (item.getItemId() == R.id.overflow_clear_traffic_block)
5211 {
5212 return onOptionsItemSelected_wrapper(22);
5213 }
5214 else if (item.getItemId() == R.id.overflow_convert_gpx_file)
5215 {
5216 return onOptionsItemSelected_wrapper(20);
5217 }
5218 else if (item.getItemId() == R.id.overflow_clear_gpx_map)
5219 {
5220 return onOptionsItemSelected_wrapper(23);
5221 }
5222 else if (item.getItemId() == R.id.overflow_replay_gps_file)
5223 {
5224 return onOptionsItemSelected_wrapper(28);
5225 }
5226 else if (item.getItemId() == R.id.overflow_demo_v_normal)
5227 {
5228 return onOptionsItemSelected_wrapper(601);
5229 }
5230 else if (item.getItemId() == R.id.overflow_demo_v_fast)
5231 {
5232 return onOptionsItemSelected_wrapper(604);
5233 }
5234 else if (item.getItemId() == R.id.overflow_speech_texts)
5235 {
5236 return onOptionsItemSelected_wrapper(602);
5237 }
5238 else if (item.getItemId() == R.id.overflow_nav_commands)
5239 {
5240 return onOptionsItemSelected_wrapper(603);
5241 }
5242 else if (item.getItemId() == R.id.overflow_toggle_route_graph)
5243 {
5244 return onOptionsItemSelected_wrapper(605);
5245 }
5246 else if (item.getItemId() == R.id.overflow_export_map_points_to_sdcard)
5247 {
5248 return onOptionsItemSelected_wrapper(607);
5249 }
5250 else if (item.getItemId() == R.id.overflow_import_map_points_from_sdcard)
5251 {
5252 return onOptionsItemSelected_wrapper(608);
5253 }
5254 else if (item.getItemId() == R.id.overflow_send_feedback)
5255 {
5256 return onOptionsItemSelected_wrapper(24);
5257 }
5258 else if (item.getItemId() == R.id.overflow_online_help)
5259 {
5260 return onOptionsItemSelected_wrapper(16);
5261 }
5262 else if (item.getItemId() == R.id.overflow_target_in_gmaps)
5263 {
5264 return onOptionsItemSelected_wrapper(15);
5265 }
5266 // else
5267 // {
5268 // return onOptionsItemSelected_wrapper(item.getItemId());
5269 // }
5270
5271 return false;
5272 }
5273
5274 @SuppressLint("NewApi")
5275 public boolean onOptionsItemSelected_wrapper(int id)
5276 {
5277 // Handle item selection
5278 switch (id)
5279 {
5280 case 1:
5281 // zoom in
5282 Message msg = new Message();
5283 Bundle b = new Bundle();
5284 b.putInt("Callback", 1);
5285 msg.setData(b);
5286 NavitGraphics.callback_handler.sendMessage(msg);
5287 // if we zoom, hide the bubble
5288 if (N_NavitGraphics.NavitAOverlay != null)
5289 {
5290 N_NavitGraphics.NavitAOverlay.hide_bubble();
5291 }
5292 Log.e("Navit", "onOptionsItemSelected -> zoom in");
5293 break;
5294 case 2:
5295 // zoom out
5296 msg = new Message();
5297 b = new Bundle();
5298 b.putInt("Callback", 2);
5299 msg.setData(b);
5300 NavitGraphics.callback_handler.sendMessage(msg);
5301 // if we zoom, hide the bubble
5302 if (N_NavitGraphics.NavitAOverlay != null)
5303 {
5304 N_NavitGraphics.NavitAOverlay.hide_bubble();
5305 }
5306 Log.e("Navit", "onOptionsItemSelected -> zoom out");
5307 break;
5308 case 3:
5309 // map download menu
5310 Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
5311 this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
5312 break;
5313 case 5:
5314 toggle_poi_pref();
5315 set_poi_layers();
5316 draw_map();
5317 break;
5318 case 6:
5319 // ok startup address search activity (online google maps search)
5320 Navit.use_index_search = false;
5321 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
5322 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5323 search_intent.putExtra("address_string", Navit_last_address_search_string);
5324 //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
5325 search_intent.putExtra("type", "online");
5326 String pm_temp = "0";
5327 if (Navit_last_address_partial_match)
5328 {
5329 pm_temp = "1";
5330 }
5331 search_intent.putExtra("partial_match", pm_temp);
5332 this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
5333 break;
5334 case 7:
5335 // ok startup address search activity (offline binfile search)
5336 Navit.use_index_search = Navit.allow_use_index_search();
5337 Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
5338 search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5339 search_intent2.putExtra("address_string", Navit_last_address_search_string);
5340 search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
5341 search_intent2.putExtra("type", "offline");
5342 search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);
5343
5344 String pm_temp2 = "0";
5345 if (Navit_last_address_partial_match)
5346 {
5347 pm_temp2 = "1";
5348 }
5349
5350 search_intent2.putExtra("partial_match", pm_temp2);
5351 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
5352 break;
5353 case 8:
5354 // map delete menu
5355 Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class);
5356 this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id);
5357 break;
5358 case 9:
5359 // stop navigation (this menu should only appear when navigation is actually on!)
5360 Message msg2 = new Message();
5361 Bundle b2 = new Bundle();
5362 b2.putInt("Callback", 7);
5363 msg2.setData(b2);
5364 NavitGraphics.callback_handler.sendMessage(msg2);
5365 Log.e("Navit", "stop navigation");
5366 break;
5367 case 10:
5368 // open settings menu
5369 Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
5370 startActivity(settingsActivity);
5371 break;
5372 case 11:
5373 //zoom_to_route
5374 zoom_to_route();
5375 break;
5376 case 12:
5377 // announcer off
5378 Navit_Announcer = false;
5379 msg = new Message();
5380 b = new Bundle();
5381 b.putInt("Callback", 34);
5382 msg.setData(b);
5383 NavitGraphics.callback_handler.sendMessage(msg);
5384 try
5385 {
5386 invalidateOptionsMenu();
5387 }
5388 catch (Exception e)
5389 {
5390 }
5391 break;
5392 case 13:
5393 // announcer on
5394 Navit_Announcer = true;
5395 msg = new Message();
5396 b = new Bundle();
5397 b.putInt("Callback", 35);
5398 msg.setData(b);
5399 NavitGraphics.callback_handler.sendMessage(msg);
5400 try
5401 {
5402 invalidateOptionsMenu();
5403 }
5404 catch (Exception e)
5405 {
5406 }
5407 break;
5408 case 14:
5409 // show recent destination list
5410 Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
5411 this.startActivityForResult(i2, Navit.NavitRecentDest_id);
5412 break;
5413 case 15:
5414 // show current target on googlemaps
5415 String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5416 // Log.e("Navit", "got target 1: "+current_target_string);
5417 if (current_target_string.equals("x:x"))
5418 {
5419 Log.e("Navit", "no target set!");
5420 }
5421 else
5422 {
5423 try
5424 {
5425 String tmp[] = current_target_string.split(":", 2);
5426 googlemaps_show(tmp[0], tmp[1], "ZANavi Target");
5427 }
5428 catch (Exception e)
5429 {
5430 e.printStackTrace();
5431 Log.e("Navit", "problem with target!");
5432 }
5433 }
5434 break;
5435 case 16:
5436 // show online manual
5437 Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase());
5438 // URL to ZANavi Manual (in english language)
5439 String url = "http://zanavi.cc/index.php/Manual";
5440 if (FDBL)
5441 {
5442 url = "http://fd.zanavi.cc/manual";
5443 }
5444 if (NavitTextTranslations.main_language.toLowerCase().equals("de"))
5445 {
5446 // show german manual
5447 url = "http://zanavi.cc/index.php/Manual/de";
5448 if (FDBL)
5449 {
5450 url = "http://fd.zanavi.cc/manualde";
5451 }
5452 }
5453
5454 Intent i = new Intent(Intent.ACTION_VIEW);
5455 i.setData(Uri.parse(url));
5456 startActivity(i);
5457 break;
5458 case 17:
5459 // show age of maps (online)
5460 Intent i3 = new Intent(Intent.ACTION_VIEW);
5461 i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL));
5462 startActivity(i3);
5463 break;
5464 case 18:
5465 Intent intent_latlon = new Intent(Intent.ACTION_MAIN);
5466 //intent_latlon.setAction("android.intent.action.POINTPICK");
5467 intent_latlon.setPackage("com.cruthu.latlongcalc1");
5468 intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain");
5469 //intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick");
5470 try
5471 {
5472 startActivity(intent_latlon);
5473 }
5474 catch (Exception e88)
5475 {
5476 e88.printStackTrace();
5477 // show install page
5478 try
5479 {
5480 // String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1";
5481 String urlx = "market://details?id=com.cruthu.latlongcalc1";
5482 Intent ix = new Intent(Intent.ACTION_VIEW);
5483 ix.setData(Uri.parse(urlx));
5484 startActivity(ix);
5485 }
5486 catch (Exception ex)
5487 {
5488 ex.printStackTrace();
5489 }
5490 }
5491 break;
5492 case 19:
5493 // GeoCoordEnterDialog
5494 Intent it001 = new Intent(this, GeoCoordEnterDialog.class);
5495 this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id);
5496 break;
5497 case 20:
5498 // convert GPX file
5499 Intent intent77 = new Intent(getBaseContext(), FileDialog.class);
5500 File a = new File(p.PREF_last_selected_dir_gpxfiles);
5501 try
5502 {
5503 // convert the "/../" in the path to normal absolut dir
5504 intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath());
5505 //can user select directories or not
5506 intent77.putExtra(FileDialog.CAN_SELECT_DIR, false);
5507 // disable the "new" button
5508 intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
5509 //alternatively you can set file filter
5510 //intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" });
5511 startActivityForResult(intent77, Navit.NavitGPXConvChooser_id);
5512 }
5513 catch (IOException e1)
5514 {
5515 e1.printStackTrace();
5516 }
5517 break;
5518 case 21:
5519 // add traffic block (like blocked road, or construction site) at current location of crosshair
5520 try
5521 {
5522 String traffic = "";
5523 if (Navit.GFX_OVERSPILL)
5524 {
5525 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)));
5526 }
5527 else
5528 {
5529 traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2));
5530 }
5531
5532 // System.out.println("traffic=" + traffic);
5533 File traffic_file_dir = new File(MAP_FILENAME_PATH);
5534 traffic_file_dir.mkdirs();
5535 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
5536 FileOutputStream fOut = null;
5537 OutputStreamWriter osw = null;
5538 try
5539 {
5540 fOut = new FileOutputStream(traffic_file, true);
5541 osw = new OutputStreamWriter(fOut);
5542 osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header
5543 osw.write(traffic); // item coordinates
5544 osw.close();
5545 fOut.close();
5546 }
5547 catch (Exception ef)
5548 {
5549 ef.printStackTrace();
5550 }
5551
5552 // update route, if a route is set
5553 msg = new Message();
5554 b = new Bundle();
5555 b.putInt("Callback", 73);
5556 msg.setData(b);
5557 NavitGraphics.callback_handler.sendMessage(msg);
5558
5559 // draw map no-async
5560 msg = new Message();
5561 b = new Bundle();
5562 b.putInt("Callback", 64);
5563 msg.setData(b);
5564 NavitGraphics.callback_handler.sendMessage(msg);
5565 }
5566 catch (Exception e)
5567 {
5568 e.printStackTrace();
5569 }
5570 break;
5571 case 22:
5572 // clear all traffic blocks
5573 try
5574 {
5575 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
5576 traffic_file.delete();
5577
5578 // update route, if a route is set
5579 msg = new Message();
5580 b = new Bundle();
5581 b.putInt("Callback", 73);
5582 msg.setData(b);
5583 NavitGraphics.callback_handler.sendMessage(msg);
5584
5585 // draw map no-async
5586 msg = new Message();
5587 b = new Bundle();
5588 b.putInt("Callback", 64);
5589 msg.setData(b);
5590 NavitGraphics.callback_handler.sendMessage(msg);
5591 }
5592 catch (Exception e)
5593 {
5594 }
5595 break;
5596 case 23:
5597 // clear all GPX maps
5598 try
5599 {
5600 File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt");
5601 gpx_file.delete();
5602
5603 // draw map no-async
5604 msg = new Message();
5605 b = new Bundle();
5606 b.putInt("Callback", 64);
5607 msg.setData(b);
5608 NavitGraphics.callback_handler.sendMessage(msg);
5609 }
5610 catch (Exception e)
5611 {
5612 }
5613 break;
5614 case 24:
5615 // show feedback form
5616 Intent i4 = new Intent(this, NavitFeedbackFormActivity.class);
5617 this.startActivityForResult(i4, Navit.NavitSendFeedback_id);
5618 break;
5619 case 25:
5620 // share the current destination with your friends
5621 String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5622 if (current_target_string2.equals("x:x"))
5623 {
5624 Log.e("Navit", "no target set!");
5625 }
5626 else
5627 {
5628 try
5629 {
5630 String tmp[] = current_target_string2.split(":", 2);
5631
5632 if (Navit.OSD_route_001.arriving_time_valid)
5633 {
5634 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
5635 }
5636 else
5637 {
5638 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5639 }
5640 }
5641 catch (Exception e)
5642 {
5643 e.printStackTrace();
5644 Log.e("Navit", "problem with target!");
5645 }
5646 }
5647 break;
5648 case 26:
5649 // donate
5650 Log.e("Navit", "start donate app");
5651 donate();
5652 break;
5653 case 27:
5654 // donate
5655 Log.e("Navit", "donate bitcoins");
5656 donate_bitcoins();
5657 break;
5658 case 28:
5659 // replay GPS file
5660 Intent intent771 = new Intent(getBaseContext(), FileDialog.class);
5661 File a1 = new File(Navit.NAVIT_DATA_DEBUG_DIR);
5662 try
5663 {
5664 // convert the "/../" in the path to normal absolut dir
5665 intent771.putExtra(FileDialog.START_PATH, a1.getCanonicalPath());
5666 //can user select directories or not
5667 intent771.putExtra(FileDialog.CAN_SELECT_DIR, false);
5668 // disable the "new" button
5669 intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
5670 //alternatively you can set file filter
5671 intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" });
5672 startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id);
5673 }
5674 catch (IOException e1)
5675 {
5676 e1.printStackTrace();
5677 }
5678 break;
5679
5680 case 88:
5681 // dummy entry, just to make "breaks" in the menu
5682 break;
5683 case 601:
5684 // DEBUG: activate demo vehicle and set position to position to screen center
5685
5686 Navit.DemoVehicle = true;
5687
5688 msg = new Message();
5689 b = new Bundle();
5690 b.putInt("Callback", 101);
5691 msg.setData(b);
5692 NavitGraphics.callback_handler.sendMessage(msg);
5693
5694 final Thread demo_v_001 = new Thread()
5695 {
5696 @Override
5697 public void run()
5698 {
5699 try
5700 {
5701 Thread.sleep(1000); // wait 1 seconds before we start
5702
5703 try
5704 {
5705 float lat = 0;
5706 float lon = 0;
5707
5708 String lat_lon = "";
5709 if (Navit.GFX_OVERSPILL)
5710 {
5711 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));
5712 }
5713 else
5714 {
5715 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);
5716 }
5717 String tmp[] = lat_lon.split(":", 2);
5718 //System.out.println("tmp=" + lat_lon);
5719 lat = Float.parseFloat(tmp[0]);
5720 lon = Float.parseFloat(tmp[1]);
5721 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
5722 Location l = null;
5723 l = new Location("ZANavi Demo 001");
5724 l.setLatitude(lat);
5725 l.setLongitude(lon);
5726 l.setBearing(0.0f);
5727 l.setSpeed(0);
5728 l.setAccuracy(4.0f); // accuracy 4 meters
5729 // NavitVehicle.update_compass_heading(0.0f);
5730 NavitVehicle.set_mock_location__fast(l);
5731 }
5732 catch (Exception e)
5733 {
5734 }
5735
5736 Message msg = new Message();
5737 Bundle b = new Bundle();
5738 b.putInt("Callback", 52);
5739 b.putString("s", "45"); // speed in km/h of Demo-Vehicle
5740 // b.putString("s", "20");
5741
5742 msg.setData(b);
5743 NavitGraphics.callback_handler.sendMessage(msg);
5744 }
5745 catch (Exception e)
5746 {
5747 }
5748 }
5749 };
5750 demo_v_001.start();
5751
5752 msg = new Message();
5753 b = new Bundle();
5754 b.putInt("Callback", 51);
5755
5756 if (Navit.GFX_OVERSPILL)
5757 {
5758 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5759 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5760 }
5761 else
5762 {
5763 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
5764 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
5765 }
5766 msg.setData(b);
5767 NavitGraphics.callback_handler.sendMessage(msg);
5768
5769 break;
5770 case 602:
5771 // DEBUG: toggle textview with spoken and translated string (to help with translation)
5772 try
5773 {
5774 if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE)
5775 {
5776 NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE);
5777 NavitGraphics.NavitMsgTv2_.setEnabled(false);
5778 NavitGraphics.NavitMsgTv2sc_.setVisibility(View.GONE);
5779 NavitGraphics.NavitMsgTv2sc_.setEnabled(false);
5780 }
5781 else
5782 {
5783 NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE);
5784 NavitGraphics.NavitMsgTv2sc_.setEnabled(true);
5785 NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
5786 NavitGraphics.NavitMsgTv2_.setEnabled(true);
5787 }
5788 }
5789 catch (Exception e)
5790 {
5791 e.printStackTrace();
5792 }
5793 break;
5794 case 603:
5795 // DEBUG: show all possible navigation commands (also translated)
5796 NavitGraphics.generate_all_speech_commands();
5797 break;
5798 case 604:
5799 // DEBUG: activate FAST driving demo vehicle and set position to screen center
5800
5801 Navit.DemoVehicle = true;
5802
5803 msg = new Message();
5804
5805 b = new Bundle();
5806 b.putInt("Callback", 52);
5807 b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle
5808 msg.setData(b);
5809 NavitGraphics.callback_handler.sendMessage(msg);
5810
5811 msg = new Message();
5812 b = new Bundle();
5813 b.putInt("Callback", 51);
5814 if (Navit.GFX_OVERSPILL)
5815 {
5816 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5817 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5818 }
5819 else
5820 {
5821 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
5822 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
5823 }
5824 msg.setData(b);
5825 NavitGraphics.callback_handler.sendMessage(msg);
5826
5827 try
5828 {
5829 float lat = 0;
5830 float lon = 0;
5831
5832 lat = 0;
5833 lon = 0;
5834 String lat_lon = "";
5835 if (Navit.GFX_OVERSPILL)
5836 {
5837 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));
5838 }
5839 else
5840 {
5841 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);
5842 }
5843
5844 String tmp[] = lat_lon.split(":", 2);
5845 //System.out.println("tmp=" + lat_lon);
5846 lat = Float.parseFloat(tmp[0]);
5847 lon = Float.parseFloat(tmp[1]);
5848 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
5849 Location l = null;
5850 l = new Location("ZANavi Demo 001");
5851 l.setLatitude(lat);
5852 l.setLongitude(lon);
5853 l.setBearing(0.0f);
5854 l.setSpeed(0);
5855 l.setAccuracy(4.0f); // accuracy 4 meters
5856 // NavitVehicle.update_compass_heading(0.0f);
5857 NavitVehicle.set_mock_location__fast(l);
5858 }
5859 catch (Exception e)
5860 {
5861 }
5862
5863 break;
5864 case 605:
5865 // DEBUG: toggle Routgraph on/off
5866 msg = new Message();
5867 b = new Bundle();
5868 b.putInt("Callback", 71);
5869 Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled;
5870 b.putString("s", "" + Navit.Routgraph_enabled);
5871 msg.setData(b);
5872 NavitGraphics.callback_handler.sendMessage(msg);
5873 break;
5874 case 606:
5875 // DEBUG: spill contents of index file(s)
5876 msg = new Message();
5877 b = new Bundle();
5878 b.putInt("Callback", 83);
5879 msg.setData(b);
5880 NavitGraphics.callback_handler.sendMessage(msg);
5881 break;
5882 case 607:
5883 export_map_points_to_sdcard();
5884 break;
5885 case 608:
5886 import_map_points_from_sdcard();
5887 break;
5888 case 99:
5889 try
5890 {
5891 if (wl_navigating != null)
5892 {
5893 //if (wl_navigating.isHeld())
5894 //{
5895 wl_navigating.release();
5896 Log.e("Navit", "WakeLock Nav: release 1");
5897 //}
5898 }
5899 }
5900 catch (Exception e)
5901 {
5902 e.printStackTrace();
5903 }
5904 // exit
5905 this.onPause();
5906 this.onStop();
5907 this.exit();
5908 //msg = new Message();
5909 //b = new Bundle();
5910 //b.putInt("Callback", 5);
5911 //b.putString("cmd", "quit();");
5912 //msg.setData(b);
5913 //N_NavitGraphics.callback_handler.sendMessage(msg);
5914 break;
5915 }
5916 return true;
5917 }
5918
5919 protected void onActivityResult(int requestCode, int resultCode, Intent data)
5920 {
5921 Log.e("Navit", "onActivityResult");
5922 switch (requestCode)
5923 {
5924 case Navit.NavitGPXConvChooser_id:
5925 try
5926 {
5927 Log.e("Navit", "onActivityResult 001");
5928 if (resultCode == ActionBarActivity.RESULT_OK)
5929 {
5930 String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
5931 convert_gpx_file_real(in_);
5932 }
5933 }
5934 catch (Exception e77)
5935 {
5936 e77.printStackTrace();
5937 }
5938 break;
5939
5940 case NavitReplayFileConvChooser_id:
5941 try
5942 {
5943 if (resultCode == ActionBarActivity.RESULT_OK)
5944 {
5945 final String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
5946 final Thread replay_gpx_file_001 = new Thread()
5947 {
5948 @Override
5949 public void run()
5950 {
5951 try
5952 {
5953 Thread.sleep(2000); // wait 2 seconds before we start
5954 ZANaviDebugReceiver.DR_replay_gps_file(in_);
5955 }
5956 catch (Exception e)
5957 {
5958 }
5959 }
5960 };
5961 replay_gpx_file_001.start();
5962 }
5963 }
5964 catch (Exception e77)
5965 {
5966 e77.printStackTrace();
5967 }
5968 break;
5969
5970 case Navit.NavitDeleteSecSelectMap_id:
5971 try
5972 {
5973 if (resultCode == ActionBarActivity.RESULT_OK)
5974 {
5975 System.out.println("Global_Location_update_not_allowed = 1");
5976 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
5977
5978 // remove all sdcard maps
5979 Message msg = new Message();
5980 Bundle b = new Bundle();
5981 b.putInt("Callback", 19);
5982 msg.setData(b);
5983 NavitGraphics.callback_handler.sendMessage(msg);
5984
5985 try
5986 {
5987 Thread.sleep(100);
5988 }
5989 catch (InterruptedException e)
5990 {
5991 }
5992
5993 Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id")));
5994 String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
5995 Log.d("Navit", "delete map full line=" + map_full_line);
5996
5997 String del_map_name = MAP_FILENAME_PATH + map_full_line.split(":", 2)[0];
5998 System.out.println("del map file :" + del_map_name);
5999 // remove from cat file
6000 NavitMapDownloader.remove_from_cat_file(map_full_line);
6001 // remove from disk
6002 File del_map_name_file = new File(del_map_name);
6003 del_map_name_file.delete();
6004 for (int jkl = 1; jkl < 51; jkl++)
6005 {
6006 File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl));
6007 del_map_name_fileSplit.delete();
6008 }
6009 // also remove index file
6010 File del_map_name_file_idx = new File(del_map_name + ".idx");
6011 del_map_name_file_idx.delete();
6012 // remove also any MD5 files for this map that may be on disk
6013 try
6014 {
6015 String tmp = map_full_line.split(":", 2)[1];
6016 if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN))
6017 {
6018 tmp = tmp.replace("*", "");
6019 tmp = tmp.replace("/", "");
6020 tmp = tmp.replace("\\", "");
6021 tmp = tmp.replace(" ", "");
6022 tmp = tmp.replace(">", "");
6023 tmp = tmp.replace("<", "");
6024 System.out.println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
6025 File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
6026 md5_final_filename.delete();
6027 }
6028 }
6029 catch (Exception e)
6030 {
6031 e.printStackTrace();
6032 }
6033
6034 // remove map, and zoom out
6035 // ***** onStop();
6036 // ***** onCreate(getIntent().getExtras());
6037
6038 try
6039 {
6040 Thread.sleep(100);
6041 }
6042 catch (InterruptedException e)
6043 {
6044 }
6045
6046 // add all sdcard maps
6047 msg = new Message();
6048 b = new Bundle();
6049 b.putInt("Callback", 20);
6050 msg.setData(b);
6051 NavitGraphics.callback_handler.sendMessage(msg);
6052
6053 final Thread zoom_to_route_004 = new Thread()
6054 {
6055 int wait = 1;
6056 int count = 0;
6057 int max_count = 60;
6058
6059 @Override
6060 public void run()
6061 {
6062 while (wait == 1)
6063 {
6064 try
6065 {
6066 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6067 {
6068 zoom_to_route();
6069 wait = 0;
6070 }
6071 else
6072 {
6073 wait = 1;
6074 }
6075
6076 count++;
6077 if (count > max_count)
6078 {
6079 wait = 0;
6080 }
6081 else
6082 {
6083 Thread.sleep(400);
6084 }
6085 }
6086 catch (Exception e)
6087 {
6088 }
6089 }
6090 }
6091 };
6092 zoom_to_route_004.start();
6093
6094 System.out.println("Global_Location_update_not_allowed = 0");
6095 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
6096 }
6097 }
6098 catch (Exception e)
6099 {
6100 Log.d("Navit", "error on onActivityResult 3");
6101 e.printStackTrace();
6102 }
6103 break;
6104 case Navit.NavitDownloaderPriSelectMap_id:
6105 try
6106 {
6107 if (resultCode == ActionBarActivity.RESULT_OK)
6108 {
6109 try
6110 {
6111 // Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6112 // set map id to download
6113 Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
6114 // show the map download progressbar, and download the map
6115 if (Navit.download_map_id > -1)
6116 {
6117 // --------- start a map download (highest level) ---------
6118 // --------- start a map download (highest level) ---------
6119 // --------- start a map download (highest level) ---------
6120 // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app
6121
6122 // new method in service
6123 Message msg = progress_handler.obtainMessage();
6124 // Bundle b = new Bundle();
6125 msg.what = 22;
6126 progress_handler.sendMessage(msg);
6127
6128 // show license for OSM maps
6129 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
6130 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
6131 // --------- start a map download (highest level) ---------
6132 // --------- start a map download (highest level) ---------
6133 // --------- start a map download (highest level) ---------
6134 }
6135 }
6136 catch (NumberFormatException e)
6137 {
6138 Log.d("Navit", "NumberFormatException selected_id");
6139 }
6140 }
6141 else
6142 {
6143 // user pressed back key
6144 }
6145 }
6146 catch (Exception e)
6147 {
6148 Log.d("Navit", "error on onActivityResult");
6149 e.printStackTrace();
6150 }
6151 break;
6152 case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!!
6153 break;
6154 case ZANaviVoiceInput_id:
6155 if (resultCode == ActionBarActivity.RESULT_OK)
6156 {
6157 try
6158 {
6159 String addr = data.getStringExtra("address_string");
6160 double lat = data.getDoubleExtra("lat", 0);
6161 double lon = data.getDoubleExtra("lon", 0);
6162 String hn = "";
6163
6164 // save last address entry string
6165 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6166 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6167
6168 Boolean partial_match = true;
6169 Navit.use_index_search = false;
6170
6171 Navit_last_address_partial_match = partial_match;
6172 Navit_last_address_search_string = addr;
6173 Navit_last_address_hn_string = hn;
6174
6175 Navit_last_address_full_file_search = false;
6176
6177 // clear results
6178 Navit.NavitAddressResultList_foundItems.clear();
6179 Navit.Navit_Address_Result_double_index.clear();
6180 Navit.NavitSearchresultBarIndex = -1;
6181 Navit.NavitSearchresultBar_title = "";
6182 Navit.NavitSearchresultBar_text = "";
6183 Navit.search_results_towns = 0;
6184 Navit.search_results_streets = 0;
6185 Navit.search_results_streets_hn = 0;
6186 Navit.search_results_poi = 0;
6187
6188 if (addr.equals(""))
6189 {
6190 // empty search string entered
6191 Toast.makeText(getApplicationContext(), Navit.get_text("No search string"), Toast.LENGTH_LONG).show(); //TRANS
6192 }
6193 else
6194 {
6195 System.out.println("Global_Location_update_not_allowed = 1");
6196 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6197
6198 // --> this still does the search // google_online_search_and_set_destination(addr);
6199 result_set_destination(lat, lon, addr);
6200
6201 System.out.println("Global_Location_update_not_allowed = 0");
6202 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
6203 }
6204
6205 }
6206 catch (Exception e)
6207 {
6208
6209 }
6210 }
6211 break;
6212 case NavitAddressSearch_id_online:
6213 case NavitAddressSearch_id_offline:
6214 Log.e("Navit", "NavitAddressSearch_id_:001");
6215 try
6216 {
6217 if (resultCode == ActionBarActivity.RESULT_OK)
6218 {
6219 try
6220 {
6221 String addr = data.getStringExtra("address_string");
6222 String hn = "";
6223 try
6224 {
6225 // only from offline mask!
6226 hn = data.getStringExtra("hn_string");
6227 }
6228 catch (Exception e)
6229 {
6230 hn = "";
6231 }
6232
6233 // save last address entry string
6234 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6235 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6236
6237 Boolean partial_match = false;
6238 try
6239 {
6240 // only from offline mask!
6241 partial_match = data.getStringExtra("partial_match").equals("1");
6242 }
6243 catch (Exception e)
6244 {
6245 }
6246
6247 Message msg2 = new Message();
6248 Bundle b2 = new Bundle();
6249 b2.putInt("Callback", 44);
6250 msg2.setData(b2);
6251 NavitGraphics.callback_handler.sendMessage(msg2);
6252
6253 if (requestCode == NavitAddressSearch_id_offline)
6254 {
6255 search_hide_duplicates = false;
6256 try
6257 {
6258 Boolean hide_dup = data.getStringExtra("hide_dup").equals("1");
6259 if (hide_dup)
6260 {
6261 search_hide_duplicates = true;
6262 Message msg = new Message();
6263 Bundle b = new Bundle();
6264 b.putInt("Callback", 45);
6265 msg.setData(b);
6266 NavitGraphics.callback_handler.sendMessage(msg);
6267 }
6268 }
6269 catch (Exception e)
6270 {
6271 }
6272 Navit.use_index_search = Navit.allow_use_index_search();
6273 }
6274 else
6275 {
6276 Navit.use_index_search = false;
6277 }
6278
6279 Navit_last_address_partial_match = partial_match;
6280 Navit_last_address_search_string = addr;
6281 Navit_last_address_hn_string = hn;
6282
6283 try
6284 {
6285 // only from offline mask!
6286 Navit_last_address_full_file_search = data.getStringExtra("full_file_search").equals("1");
6287 }
6288 catch (Exception e)
6289 {
6290 Navit_last_address_full_file_search = false;
6291 }
6292
6293 try
6294 {
6295 // only from offline mask!
6296 Navit_last_address_search_country_iso2_string = data.getStringExtra("address_country_iso2");
6297
6298 Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3);
6299 // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags);
6300 Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL*
6301 p.PREF_search_country = Navit_last_address_search_country_id;
6302 setPrefs_search_country();
6303 }
6304 catch (Exception e)
6305 {
6306
6307 }
6308
6309 // clear results
6310 Navit.NavitAddressResultList_foundItems.clear();
6311 Navit.Navit_Address_Result_double_index.clear();
6312 Navit.NavitSearchresultBarIndex = -1;
6313 Navit.NavitSearchresultBar_title = "";
6314 Navit.NavitSearchresultBar_text = "";
6315 Navit.search_results_towns = 0;
6316 Navit.search_results_streets = 0;
6317 Navit.search_results_streets_hn = 0;
6318 Navit.search_results_poi = 0;
6319
6320 if (addr.equals(""))
6321 {
6322 // empty search string entered
6323 Toast.makeText(getApplicationContext(), Navit.get_text("No search string entered"), Toast.LENGTH_LONG).show(); //TRANS
6324 }
6325 else
6326 {
6327 System.out.println("Global_Location_update_not_allowed = 1");
6328 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6329
6330 if (requestCode == NavitAddressSearch_id_online)
6331 {
6332 // online googlemaps search
6333 try
6334 {
6335 Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG);
6336 }
6337 catch (Exception e)
6338 {
6339 e.printStackTrace();
6340 }
6341
6342 System.out.println("online googlemaps search");
6343 Message msg = progress_handler.obtainMessage();
6344 Bundle b = new Bundle();
6345 msg.what = 11;
6346 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
6347 msg.setData(b);
6348 progress_handler.sendMessage(msg);
6349 }
6350 else if (requestCode == NavitAddressSearch_id_offline)
6351 {
6352 // offline binfile search
6353 try
6354 {
6355 Log.e("Navit", "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6356 }
6357 catch (Exception e)
6358 {
6359 e.printStackTrace();
6360 }
6361
6362 // show dialog, and start search for the results
6363 // make it indirect, to give our activity a chance to startup
6364 // (remember we come straight from another activity and ours is still paused!)
6365 Message msg = progress_handler.obtainMessage();
6366 Bundle b = new Bundle();
6367 msg.what = 11;
6368 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6369 msg.setData(b);
6370 progress_handler.sendMessage(msg);
6371 }
6372 }
6373 }
6374 catch (NumberFormatException e)
6375 {
6376 Log.d("Navit", "NumberFormatException selected_id");
6377 }
6378 }
6379 else
6380 {
6381 // user pressed back key
6382 Log.e("Navit", "NavitAddressSearch_id_:900");
6383 }
6384 }
6385 catch (Exception e)
6386 {
6387 Log.d("Navit", "error on onActivityResult");
6388 e.printStackTrace();
6389 }
6390 Log.e("Navit", "NavitAddressSearch_id_:999");
6391 break;
6392 case Navit.NavitAddressResultList_id:
6393 try
6394 {
6395 if (resultCode == ActionBarActivity.RESULT_OK)
6396 {
6397 try
6398 {
6399 if (data.getStringExtra("what").equals("view"))
6400 {
6401 // get the coords for the destination
6402 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6403
6404 // save last address entry string
6405 String addr = data.getStringExtra("address_string");
6406 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6407 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6408
6409 try
6410 {
6411 Navit.follow_button_off();
6412 }
6413 catch (Exception e2)
6414 {
6415 e2.printStackTrace();
6416 }
6417
6418 System.out.println("XSOM:009");
6419
6420 if (Navit.use_index_search)
6421 {
6422 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));
6423 }
6424 else
6425 {
6426 show_geo_on_screen_with_zoom_and_delay(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6427 }
6428 }
6429 else if (data.getStringExtra("what").equals("set"))
6430 {
6431 Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6432
6433 // save last address entry string
6434 String addr = data.getStringExtra("address_string");
6435 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6436 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6437
6438 // get the coords for the destination
6439 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6440
6441 String _addr = "";
6442 double _lat = 0;
6443 double _lon = 0;
6444
6445 // (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)
6446 // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)
6447
6448 // ok now set target
6449 try
6450 {
6451 if (Navit.use_index_search)
6452 {
6453 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6454 _lat = Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat);
6455 _lon = Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6456 //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));
6457 }
6458 else
6459 {
6460 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6461 _lat = Navit.NavitAddressResultList_foundItems.get(destination_id).lat;
6462 _lon = Navit.NavitAddressResultList_foundItems.get(destination_id).lon;
6463 //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6464 }
6465 // save points
6466 //write_map_points();
6467 }
6468 catch (Exception e)
6469 {
6470 e.printStackTrace();
6471 }
6472
6473 route_wrapper(_addr, 0, 0, false, _lat, _lon, true);
6474
6475 final Thread zoom_to_route_005 = new Thread()
6476 {
6477 int wait = 1;
6478 int count = 0;
6479 int max_count = 60;
6480
6481 @Override
6482 public void run()
6483 {
6484 while (wait == 1)
6485 {
6486 try
6487 {
6488 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6489 {
6490 zoom_to_route();
6491 wait = 0;
6492 }
6493 else
6494 {
6495 wait = 1;
6496 }
6497
6498 count++;
6499 if (count > max_count)
6500 {
6501 wait = 0;
6502 }
6503 else
6504 {
6505 Thread.sleep(400);
6506 }
6507 }
6508 catch (Exception e)
6509 {
6510 }
6511 }
6512 }
6513 };
6514 zoom_to_route_005.start();
6515 // zoom_to_route();
6516
6517 // ---------- DEBUG: write route to file ----------
6518 // ---------- DEBUG: write route to file ----------
6519 // ---------- DEBUG: write route to file ----------
6520 if (p.PREF_enable_debug_write_gpx)
6521 {
6522 write_route_to_gpx_file();
6523 }
6524 // ---------- DEBUG: write route to file ----------
6525 // ---------- DEBUG: write route to file ----------
6526
6527 try
6528 {
6529 Navit.follow_button_on();
6530 }
6531 catch (Exception e2)
6532 {
6533 e2.printStackTrace();
6534 }
6535
6536 // if (Navit.use_index_search)
6537 // {
6538 // 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));
6539 // }
6540 // else
6541 // {
6542 // show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6543 // }
6544 }
6545 else
6546 {
6547 // -- nothing --
6548 }
6549 }
6550 catch (NumberFormatException e)
6551 {
6552 Log.d("Navit", "NumberFormatException selected_id");
6553 }
6554 catch (Exception e)
6555 {
6556
6557 }
6558 }
6559 else
6560 {
6561 // user pressed back key
6562 }
6563 }
6564 catch (Exception e)
6565 {
6566 Log.d("Navit", "error on onActivityResult");
6567 e.printStackTrace();
6568 }
6569 break;
6570 case NavitAddressSearch_id_gmaps:
6571 try
6572 {
6573 if (resultCode == ActionBarActivity.RESULT_OK)
6574 {
6575
6576 }
6577 }
6578 catch (Exception e)
6579 {
6580 e.printStackTrace();
6581 }
6582 break;
6583 case NavitAddressSearch_id_sharedest:
6584 try
6585 {
6586 if (resultCode == ActionBarActivity.RESULT_OK)
6587 {
6588
6589 }
6590 Log.d("Navit", "sharedest: finished");
6591 }
6592 catch (Exception e)
6593 {
6594 e.printStackTrace();
6595 }
6596 break;
6597 case NavitGeoCoordEnter_id:
6598 try
6599 {
6600 if (resultCode == ActionBarActivity.RESULT_OK)
6601 {
6602 // lat lon enter activitiy result
6603
6604 try
6605 {
6606 if (data.getStringExtra("what").equals("view"))
6607 {
6608 // get the coords for the destination
6609 float lat = Float.parseFloat(data.getStringExtra("lat"));
6610 float lon = Float.parseFloat(data.getStringExtra("lon"));
6611
6612 // Log.d("Navit", "coord picker: " + lat);
6613 // Log.d("Navit", "coord picker: " + lon);
6614
6615 // set nice zoomlevel before we show destination
6616 // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
6617 // //
6618 // Message msg = new Message();
6619 // Bundle b = new Bundle();
6620 // b.putInt("Callback", 33);
6621 // b.putString("s", Integer.toString(zoom_want));
6622 // msg.setData(b);
6623 // try
6624 // {
6625 // N_NavitGraphics.callback_handler.sendMessage(msg);
6626 // Navit.GlobalScaleLevel = zoom_want;
6627 // }
6628 // catch (Exception e)
6629 // {
6630 // e.printStackTrace();
6631 // }
6632 // if (PREF_save_zoomlevel)
6633 // {
6634 // setPrefs_zoomlevel();
6635 // }
6636 // set nice zoomlevel before we show destination
6637
6638 try
6639 {
6640 Navit.follow_button_off();
6641 }
6642 catch (Exception e2)
6643 {
6644 e2.printStackTrace();
6645 }
6646
6647 show_geo_on_screen(lat, lon);
6648 }
6649 else
6650 {
6651 // get the coords for the destination
6652 float lat = Float.parseFloat(data.getStringExtra("lat"));
6653 float lon = Float.parseFloat(data.getStringExtra("lat"));
6654 String dest_name = "manual coordinates";
6655
6656 // ok now set target
6657 try
6658 {
6659 dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon);
6660 if ((dest_name.equals(" ")) || (dest_name == null))
6661 {
6662 dest_name = "manual coordinates";
6663 }
6664 // Navit.remember_destination(dest_name, lat, lon);
6665 // // save points
6666 // write_map_points();
6667 }
6668 catch (Exception e)
6669 {
6670 e.printStackTrace();
6671 }
6672
6673 // // DEBUG: clear route rectangle list
6674 // NavitGraphics.route_rects.clear();
6675 //
6676 // if (NavitGraphics.navit_route_status == 0)
6677 // {
6678 // Navit.destination_set();
6679 //
6680 // Message msg = new Message();
6681 // Bundle b = new Bundle();
6682 // b.putInt("Callback", 3);
6683 // b.putString("lat", String.valueOf(lat));
6684 // b.putString("lon", String.valueOf(lon));
6685 // b.putString("q", dest_name);
6686 // msg.setData(b);
6687 // NavitGraphics.callback_handler.sendMessage(msg);
6688 // }
6689 // else
6690 // {
6691 // Message msg = new Message();
6692 // Bundle b = new Bundle();
6693 // b.putInt("Callback", 48);
6694 // b.putString("lat", String.valueOf(lat));
6695 // b.putString("lon", String.valueOf(lon));
6696 // b.putString("q", dest_name);
6697 // msg.setData(b);
6698 // NavitGraphics.callback_handler.sendMessage(msg);
6699 // }
6700 //
6701
6702 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
6703
6704 final Thread zoom_to_route_006 = new Thread()
6705 {
6706 int wait = 1;
6707 int count = 0;
6708 int max_count = 60;
6709
6710 @Override
6711 public void run()
6712 {
6713 while (wait == 1)
6714 {
6715 try
6716 {
6717 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6718 {
6719 zoom_to_route();
6720 wait = 0;
6721 }
6722 else
6723 {
6724 wait = 1;
6725 }
6726
6727 count++;
6728 if (count > max_count)
6729 {
6730 wait = 0;
6731 }
6732 else
6733 {
6734 Thread.sleep(400);
6735 }
6736 }
6737 catch (Exception e)
6738 {
6739 }
6740 }
6741 }
6742 };
6743 zoom_to_route_006.start();
6744 // zoom_to_route();
6745
6746 // ---------- DEBUG: write route to file ----------
6747 // ---------- DEBUG: write route to file ----------
6748 // ---------- DEBUG: write route to file ----------
6749 if (p.PREF_enable_debug_write_gpx)
6750 {
6751 write_route_to_gpx_file();
6752 }
6753 // ---------- DEBUG: write route to file ----------
6754 // ---------- DEBUG: write route to file ----------
6755
6756 try
6757 {
6758 Navit.follow_button_on();
6759 }
6760 catch (Exception e2)
6761 {
6762 e2.printStackTrace();
6763 }
6764
6765 // show_geo_on_screen(lat, lon);
6766 }
6767 }
6768 catch (NumberFormatException e)
6769 {
6770 Log.d("Navit", "NumberFormatException selected_id");
6771 }
6772 catch (Exception e)
6773 {
6774
6775 }
6776 }
6777 }
6778 catch (Exception e)
6779 {
6780 e.printStackTrace();
6781 }
6782 break;
6783 case NavitRecentDest_id:
6784 try
6785 {
6786 if (resultCode == ActionBarActivity.RESULT_OK)
6787 {
6788 Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6789 // get the coords for the destination
6790 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6791
6792 if (data.getStringExtra("what").equals("view"))
6793 {
6794 try
6795 {
6796 Navit.follow_button_off();
6797 }
6798 catch (Exception e2)
6799 {
6800 e2.printStackTrace();
6801 }
6802
6803 float lat = Navit.map_points.get(destination_id).lat;
6804 float lon = Navit.map_points.get(destination_id).lon;
6805 show_geo_on_screen_with_zoom_and_delay(lat, lon, 150);
6806 }
6807 else
6808 {
6809 // ok now set target
6810 String dest_name = Navit.map_points.get(destination_id).point_name;
6811 float lat = Navit.map_points.get(destination_id).lat;
6812 float lon = Navit.map_points.get(destination_id).lon;
6813
6814 // System.out.println("XXXXXX:" + lat + " " + lon);
6815
6816 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
6817
6818 final Thread zoom_to_route_007 = new Thread()
6819 {
6820 int wait = 1;
6821 int count = 0;
6822 int max_count = 60;
6823
6824 @Override
6825 public void run()
6826 {
6827 while (wait == 1)
6828 {
6829 try
6830 {
6831 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6832 {
6833 zoom_to_route();
6834 wait = 0;
6835 }
6836 else
6837 {
6838 wait = 1;
6839 }
6840
6841 count++;
6842 if (count > max_count)
6843 {
6844 wait = 0;
6845 }
6846 else
6847 {
6848 Thread.sleep(400);
6849 }
6850 }
6851 catch (Exception e)
6852 {
6853 }
6854 }
6855 }
6856 };
6857 zoom_to_route_007.start();
6858
6859 // ---------- DEBUG: write route to file ----------
6860 // ---------- DEBUG: write route to file ----------
6861 // ---------- DEBUG: write route to file ----------
6862 if (p.PREF_enable_debug_write_gpx)
6863 {
6864 write_route_to_gpx_file();
6865 }
6866 // ---------- DEBUG: write route to file ----------
6867 // ---------- DEBUG: write route to file ----------
6868
6869 try
6870 {
6871 Navit.follow_button_on();
6872 }
6873 catch (Exception e2)
6874 {
6875 e2.printStackTrace();
6876 }
6877
6878 }
6879 }
6880 }
6881 catch (Exception e)
6882 {
6883 e.printStackTrace();
6884 }
6885 break;
6886
6887 case NavitSendFeedback_id:
6888 try
6889 {
6890 if (resultCode == ActionBarActivity.RESULT_OK)
6891 {
6892 String feedback_text = data.getStringExtra("feedback_text");
6893
6894 String subject_d_version = "";
6895 if (Navit_DonateVersion_Installed)
6896 {
6897 subject_d_version = subject_d_version + "D,";
6898 }
6899
6900 if (Navit_Largemap_DonateVersion_Installed)
6901 {
6902 subject_d_version = subject_d_version + "L,";
6903 }
6904
6905 try
6906 {
6907 int rl = get_reglevel();
6908
6909 if (rl > 0)
6910 {
6911 subject_d_version = "U" + rl + ",";
6912 }
6913 }
6914 catch (Exception e)
6915 {
6916 e.printStackTrace();
6917 }
6918
6919 String FD_addon = "";
6920 if (FDBL)
6921 {
6922 FD_addon = ",FD";
6923 }
6924
6925 sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + FD_addon + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text);
6926 }
6927 }
6928 catch (Exception e)
6929 {
6930 e.printStackTrace();
6931 Toast.makeText(getApplicationContext(), Navit.get_text("there was a problem with sending feedback"), Toast.LENGTH_SHORT).show(); //TRANS
6932 }
6933 break;
6934
6935 default:
6936 Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode);
6937 try
6938 {
6939 // ---------- what is this doing ????? ----------
6940 // ---------- what is this doing ????? ----------
6941 // ---------- what is this doing ????? ----------
6942 // ---------- what is this doing ????? ----------
6943 // ---------- what is this doing ????? ----------
6944 // ---------- what is this doing ????? ----------
6945 // ---------- what is this doing ????? ----------
6946 // ---------- what is this doing ????? ----------
6947 // ---------- what is this doing ????? ----------
6948 // ---------- what is this doing ????? ----------
6949 // ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
6950 // ---------- what is this doing ????? ----------
6951 // ---------- what is this doing ????? ----------
6952 // ---------- what is this doing ????? ----------
6953 // ---------- what is this doing ????? ----------
6954 // ---------- what is this doing ????? ----------
6955 // ---------- what is this doing ????? ----------
6956 // ---------- what is this doing ????? ----------
6957 // ---------- what is this doing ????? ----------
6958 }
6959 catch (Exception e)
6960 {
6961 e.printStackTrace();
6962 }
6963 break;
6964 }
6965 Log.e("Navit", "onActivityResult finished");
6966 }
6967
6968 public class SCCB_object
6969 {
6970 int w;
6971 int h;
6972 Bitmap mb;
6973 }
6974
6975 public class CMC_object
6976 {
6977 int i;
6978 String s;
6979 }
6980
6981 public class MCB_object
6982 {
6983 int x1;
6984 int y1;
6985 int x2;
6986
6987 int y2;
6988 }
6989
6990 public class TCB_object
6991 {
6992 int del;
6993 int id;
6994 NavitTimeout nt;
6995 }
6996
6997 public class GeCB_Object
6998 {
6999 int type;
7000 int a;
7001 float b;
7002 float c;
7003 }
7004
7005 public class CWorkerThread extends Thread
7006 {
7007 private Boolean running;
7008 Boolean startmain = false;
7009 private CMC_object l2;
7010 private Integer l3;
7011 private MCB_object l4;
7012 private TCB_object l5;
7013 private SCCB_object l6;
7014 private Location l7;
7015 private GeCB_Object l8;
7016
7017 Navit x;
7018 String lang;
7019 int version;
7020 String display_density_string;
7021 int timeout_loop_counter = 0;
7022 String n_datadir;
7023 String n_sharedir;
7024
7025 private final LinkedBlockingQueue<CMC_object> queue = new LinkedBlockingQueue<CMC_object>();
7026 private final LinkedBlockingQueue<Integer> queue2 = new LinkedBlockingQueue<Integer>();
7027 private final LinkedBlockingQueue<MCB_object> queue3 = new LinkedBlockingQueue<MCB_object>();
7028 private final LinkedBlockingQueue<TCB_object> queue4 = new LinkedBlockingQueue<TCB_object>();
7029 private final LinkedBlockingQueue<SCCB_object> queue5 = new LinkedBlockingQueue<SCCB_object>();
7030 private final LinkedBlockingQueue<Location> queue6 = new LinkedBlockingQueue<Location>();
7031 private final LinkedBlockingQueue<GeCB_Object> queue7 = new LinkedBlockingQueue<GeCB_Object>();
7032
7033 CWorkerThread()
7034 {
7035 this.running = true;
7036 }
7037
7038 public void SizeChangedCallback(int w, int h, Bitmap main_map_bitmap)
7039 {
7040 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7041
7042 SCCB_object sccbo = new SCCB_object();
7043 sccbo.w = w;
7044 sccbo.h = h;
7045 sccbo.mb = main_map_bitmap;
7046 queue5.offer(sccbo);
7047 this.interrupt();
7048
7049 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7050 }
7051
7052 public void TimeoutCallback2(NavitTimeout nt, int del, int id)
7053 {
7054 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7055
7056 TCB_object tcbo = new TCB_object();
7057 tcbo.del = del;
7058 tcbo.id = id;
7059 tcbo.nt = nt;
7060 queue4.offer(tcbo);
7061 this.interrupt();
7062 //timeout_loop_counter++;
7063
7064 //if (timeout_loop_counter > 100)
7065 //{
7066 // timeout_loop_counter = 0;
7067 // // run GC at every 100th loop
7068 // // System.gc();
7069 //}
7070 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7071 }
7072
7073 public void CallbackMessageChannel(int i, String s)
7074 {
7075 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0, "id=" + i);
7076 CMC_object cmco = new CMC_object();
7077 cmco.i = i;
7078 cmco.s = s;
7079 queue.offer(cmco);
7080 this.interrupt();
7081 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7082 }
7083
7084 public void MotionCallback(int x1, int y1, int x2, int y2)
7085 {
7086 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7087
7088 //System.out.println("MotionCallback:enter queue=" + queue3.size());
7089 MCB_object mcbo = new MCB_object();
7090 mcbo.x1 = x1;
7091 mcbo.y1 = y1;
7092 mcbo.x2 = x2;
7093 mcbo.y2 = y2;
7094 queue3.offer(mcbo);
7095 this.interrupt();
7096 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7097 }
7098
7099 public void NavitActivity2(int i)
7100 {
7101 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7102
7103 queue2.offer(Integer.valueOf(i));
7104 this.interrupt();
7105 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7106 }
7107
7108 public void CallbackGeoCalc2(int type, int a, float b, float c)
7109 {
7110 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7111
7112 GeCB_Object gcco = new GeCB_Object();
7113 gcco.type = type;
7114 gcco.a = a;
7115 gcco.b = b;
7116 gcco.c = c;
7117 queue7.offer(gcco);
7118 this.interrupt();
7119
7120 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7121 }
7122
7123 public void StartMain(Navit x, String lang, int version, String display_density_string, String n_datadir, String n_sharedir)
7124 {
7125 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7126
7127 //System.out.println("CWorkerThread:StartMain:JTHREAD ID=" + this.getId());
7128 //System.out.println("CWorkerThread:StartMain:THREAD ID=" + NavitGraphics.GetThreadId());
7129
7130 this.startmain = true;
7131 this.x = x;
7132 this.lang = lang;
7133 this.version = version;
7134 this.n_datadir = n_datadir;
7135 this.n_sharedir = n_sharedir;
7136 this.display_density_string = display_density_string;
7137 this.interrupt();
7138
7139 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7140 }
7141
7142 public void VehicleCallback3(Location location)
7143 {
7144 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7145
7146 boolean your_are_speeding_old = Navit.your_are_speeding;
7147
7148 if ((Navit.cur_max_speed != -1) && (Navit.isGPSFix))
7149 {
7150 if ((location.getSpeed() * 3.6f) > ((float) Navit.cur_max_speed * (((float) p.PREF_roadspeed_warning_margin + 100.0f) / 100.0f)))
7151 {
7152 Navit.your_are_speeding = true;
7153
7154 try
7155 {
7156
7157 if (!toneG_heared)
7158 {
7159 // make "beep" sound to indicate we are going to fast!!
7160 if (toneG != null)
7161 {
7162 if (p.PREF_roadspeed_warning)
7163 {
7164 toneG.stopTone();
7165 toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 500);
7166 }
7167 toneG_heared = true;
7168 }
7169
7170 }
7171 }
7172 catch (Exception e)
7173 {
7174 }
7175 }
7176 else
7177 {
7178 // reset "beep" flag
7179 Navit.toneG_heared = false;
7180 Navit.your_are_speeding = false;
7181 }
7182 }
7183 else
7184 {
7185 Navit.your_are_speeding = false;
7186 }
7187
7188 if (your_are_speeding_old != Navit.your_are_speeding)
7189 {
7190 //System.out.println("xx paint 6 xx");
7191 // NavitOSDJava.draw_real_wrapper(false, true);
7192 ZANaviLinearLayout.redraw_OSD(8);
7193 }
7194
7195 if (queue6.size() > 5)
7196 {
7197 while (queue6.size() > 5)
7198 {
7199 try
7200 {
7201 // if too many gps updates are waiting, then only process the last few entry!!
7202 queue6.poll();
7203 }
7204 catch (Exception e)
7205 {
7206 }
7207 }
7208 }
7209
7210 queue6.offer(location);
7211 this.interrupt();
7212
7213 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7214 }
7215
7216 public void calc_sun_stats()
7217 {
7218 //
7219 //
7220 // SUN ----------------
7221 //
7222 //
7223 sun_moon__must_calc_new = (SystemClock.elapsedRealtime() - sun_moon__mLastCalcSunMillis) > (60000 * 3); // calc new every 3 minutes
7224
7225 if ((sun_moon__must_calc_new) || (azmiuth_cache == -1))
7226 {
7227 float lat = 0;
7228 float lon = 0;
7229 try
7230 {
7231 // 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);
7232 String lat_lon = "";
7233 if (Navit.GFX_OVERSPILL)
7234 {
7235 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));
7236 }
7237 else
7238 {
7239 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);
7240 }
7241
7242 String tmp[] = lat_lon.split(":", 2);
7243 //System.out.println("tmp=" + lat_lon);
7244 lat = Float.parseFloat(tmp[0]);
7245 lon = Float.parseFloat(tmp[1]);
7246 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
7247 }
7248 catch (Exception e)
7249 {
7250 }
7251
7252 try
7253 {
7254 sun_moon__mLastCalcSunMillis = SystemClock.elapsedRealtime();
7255 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.
7256 //System.out.println(t.getID());
7257 sun_moon__calc = new SunriseSunsetCalculator(new Location2(String.valueOf(lat), String.valueOf(lon)), t.getID());
7258 sun_moon__cx = Calendar.getInstance();
7259 sun_moon__sc = SolarPosition.getSunPosition(new Date(), lat, lon);
7260
7261 azmiuth_cache = sun_moon__sc.azimuth;
7262 zenith_cache = sun_moon__sc.zenithAngle;
7263 sunrise_cache = sun_moon__calc.getOfficialSunriseForDate(sun_moon__cx);
7264 sunset_cache = sun_moon__calc.getOfficialSunsetForDate(sun_moon__cx);
7265 //System.out.println("calc moon");
7266 SolarEventCalculator.moonCoor_ret moon_stats = sun_moon__calc.computeMoon(sun_moon__cx);
7267 moon_azimuth_cache = moon_stats.az;
7268 moon_evelation_cache = moon_stats.alt;
7269 }
7270 catch (Exception e)
7271 {
7272 }
7273 }
7274 //
7275 elevation = 90 - zenith_cache;
7276 //
7277 // day -> +90.0 to - 0.83
7278 // evening dusk -> - 0.83 to -10.00
7279 if (elevation < -0.83)
7280 {
7281 is_night = true;
7282 if (elevation < -10.00)
7283 {
7284 is_twilight = false;
7285 }
7286 else
7287 {
7288 is_twilight = true;
7289 }
7290 //System.out.println("***NIGHT***");
7291 }
7292 else
7293 {
7294 is_night = false;
7295 //System.out.println("###DAY###");
7296 }
7297 //
7298 // SUN ----------------
7299 //
7300 //
7301 }
7302
7303 public void do_sun_calc()
7304 {
7305 //
7306 //
7307 // SUN ----------------
7308 //
7309 //
7310 try
7311 {
7312 this.calc_sun_stats();
7313 }
7314 catch (Exception e)
7315 {
7316 // on some systems BigInteger seems to crash, or maybe some values are out of range
7317 // until the bug is found, night modus is deactivated
7318 calc_sun_enabled = false;
7319 is_twilight = false;
7320 is_night = false;
7321 }
7322 //System.out.println("sunrise: " + sunrise_cache);
7323 //System.out.println("sunset: " + sunset_cache);
7324 //System.out.println("azimuth: " + roundTwoDecimals(azmiuth_cache));
7325 //System.out.println("elevation: " + elevation);
7326 //
7327 //
7328 // SUN ----------------
7329 //
7330 //
7331 }
7332
7333 public void run()
7334 {
7335 //System.out.println("CWorkerThread -- started --");
7336 while (this.running)
7337 {
7338 if ((queue4.size() == 0) && (queue6.size() == 0))
7339 {
7340 try
7341 {
7342 Thread.sleep(2000); // 2 secs.
7343 }
7344 catch (InterruptedException e)
7345 {
7346 }
7347 }
7348
7349 if (this.startmain)
7350 {
7351 //System.out.println("CWorkerThread:startup_calls:JTHREAD ID=" + this.getId());
7352 //System.out.println("CWorkerThread:startup_calls:THREAD ID=" + NavitGraphics.GetThreadId());
7353
7354 this.startmain = false;
7355 System.out.println("CWorkerThread -- NavitMain --");
7356 NavitMain(x, lang, version, display_density_string, n_datadir, n_sharedir, NavitGraphics.draw_bitmap_s);
7357 System.out.println("CWorkerThread -- NavitActivity(3) --");
7358 NavitActivity(3);
7359
7360 // -- set map detail level (after app startup) --
7361 // -- set map detail level (after app startup) --
7362 // -- set map detail level (after app startup) --
7363 try
7364 {
7365 getPrefs_more_map_detail();
7366 if (p.PREF_more_map_detail > 0)
7367 {
7368 Message msg2 = new Message();
7369 Bundle b2 = new Bundle();
7370 b2.putInt("Callback", 78);
7371 b2.putString("s", "" + p.PREF_more_map_detail);
7372 msg2.setData(b2);
7373 NavitGraphics.callback_handler.sendMessage(msg2);
7374 }
7375 }
7376 catch (Exception e)
7377 {
7378 // e.printStackTrace();
7379 }
7380 // -- set map detail level (after app startup) --
7381 // -- set map detail level (after app startup) --
7382 // -- set map detail level (after app startup) --
7383
7384 // -- set map DPI factor (after app startup) --
7385 // -- set map DPI factor (after app startup) --
7386 // -- set map DPI factor (after app startup) --
7387 try
7388 {
7389 if ((Navit.metrics.densityDpi >= 320) && (!p.PREF_shrink_on_high_dpi))
7390 {
7391 double factor;
7392 factor = (double) Navit.metrics.densityDpi / (double) NavitGraphics.Global_Scaled_DPI_normal;
7393
7394 Message msg2 = new Message();
7395 Bundle b2 = new Bundle();
7396 b2.putInt("Callback", 81);
7397 b2.putString("s", "" + factor);
7398 msg2.setData(b2);
7399 NavitGraphics.callback_handler.sendMessage(msg2);
7400 }
7401 }
7402 catch (Exception e)
7403 {
7404 // e.printStackTrace();
7405 }
7406 // -- set map DPI factor (after app startup) --
7407 // -- set map DPI factor (after app startup) --
7408 // -- set map DPI factor (after app startup) --
7409 Global_Init_Finished = 1;
7410 //x.runOnUiThread(new Runnable()
7411 //{
7412 // public void run()
7413 // {
7414 // NavitActivity(3);
7415 // }
7416 //});
7417
7418 //**getPrefs();
7419 //**activatePrefs();
7420
7421 System.out.println("CWorkerThread -- calling:ready --");
7422 }
7423
7424 while (queue6.size() > 0)
7425 {
7426 try
7427 {
7428 // blocking call
7429 // l2 = queue6.take();
7430 // non-blocking call
7431 l7 = queue6.poll();
7432 if (l2 != null)
7433 {
7434 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7435 }
7436 }
7437
7438 catch (Exception e)
7439 {
7440 }
7441
7442 }
7443
7444 while (queue.size() > 0)
7445 {
7446 try
7447 {
7448 // blocking call
7449 // l2 = queue.take();
7450 // non-blocking call
7451 l2 = queue.poll();
7452 if (l2 != null)
7453 {
7454 //System.out.println("CWorkerThread:CallbackMessageChannelReal_call:JTHREAD ID=" + this.getId());
7455 //System.out.println("CWorkerThread:CallbackMessageChannelReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7456 //System.out.println("CWorkerThread:CallbackMessageChannelReal:" + l2.i);
7457 NavitGraphics.CallbackMessageChannelReal(l2.i, l2.s);
7458 //System.out.println("CWorkerThread:CallbackMessageChannelReal:finished");
7459 }
7460 }
7461 catch (Exception e)
7462 {
7463 }
7464
7465 // if GPS updates are pending, process them
7466 if (queue6.size() > 0)
7467 {
7468 try
7469 {
7470 // blocking call
7471 // l2 = queue6.take();
7472 // non-blocking call
7473 l7 = queue6.poll();
7474 if (l2 != null)
7475 {
7476 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7477 }
7478 }
7479 catch (Exception e)
7480 {
7481 }
7482 }
7483
7484 }
7485
7486 while (queue5.size() > 0)
7487 {
7488 try
7489 {
7490 // blocking call
7491 // l6 = queue5.take();
7492 // non-blocking call
7493 l6 = queue5.poll();
7494 if (l6 != null)
7495 {
7496 //System.out.println("CWorkerThread:SizeChangedCallbackReal_call:JTHREAD ID=" + this.getId());
7497 //System.out.println("CWorkerThread:SizeChangedCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7498 NavitGraphics.SizeChangedCallbackReal(l6.w, l6.h, l6.mb);
7499 }
7500 }
7501 catch (Exception e)
7502 {
7503 }
7504
7505 }
7506
7507 int count_timeout_callbacks = 0;
7508 while (count_timeout_callbacks < 10 && queue4.size() > 0)
7509 {
7510 count_timeout_callbacks++;
7511 try
7512 {
7513 // blocking call
7514 // l5 = queue4.take();
7515 // non-blocking call
7516 l5 = queue4.poll();
7517 if (l5 != null)
7518 {
7519 //System.out.println("CWorkerThread:TimeoutCallback_call:JTHREAD ID=" + this.getId());
7520 //System.out.println("CWorkerThread:TimeoutCallback_call:THREAD ID=" + NavitGraphics.GetThreadId());
7521 if ((l5.nt.running) || (!l5.nt.event_multi))
7522 {
7523 NavitGraphics.TimeoutCallback(l5.del, l5.id);
7524 }
7525 else
7526 {
7527 // System.out.println("CWorkerThread:TimeoutCallback_call:running=false! cid=" + l5.id);
7528 }
7529 }
7530 }
7531 catch (Exception e)
7532 {
7533 }
7534
7535 // if GPS updates are pending, process them
7536 if (queue6.size() > 0)
7537 {
7538 try
7539 {
7540 // blocking call
7541 // l2 = queue6.take();
7542 // non-blocking call
7543 l7 = queue6.poll();
7544 if (l2 != null)
7545 {
7546 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7547 }
7548 }
7549 catch (Exception e)
7550 {
7551 }
7552 }
7553
7554 }
7555
7556 while (queue3.size() > 0)
7557 {
7558 try
7559 {
7560 // blocking call
7561 // l4 = queue3.take();
7562 // non-blocking call
7563 l4 = queue3.poll();
7564 if (l4 != null)
7565 {
7566 //System.out.println("CWorkerThread:MotionCallbackReal_call:JTHREAD ID=" + this.getId());
7567 //System.out.println("CWorkerThread:MotionCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7568 if (queue3.size() > 0)
7569 {
7570 // if more moves are queued up, disable map drawing!
7571 NavitGraphics.MotionCallbackReal(l4.x1, l4.y1, l4.x2, l4.y2, 0);
7572 }
7573 else
7574 {
7575 // ok, also draw the map
7576 NavitGraphics.MotionCallbackReal(l4.x1, l4.y1, l4.x2, l4.y2, 1);
7577 }
7578 }
7579 }
7580 catch (Exception e)
7581 {
7582 }
7583
7584 }
7585
7586 while (queue7.size() > 0)
7587 {
7588 try
7589 {
7590
7591 // if GPS updates are pending, process them
7592 if (queue6.size() > 0)
7593 {
7594 try
7595 {
7596 // blocking call
7597 // l2 = queue6.take();
7598 // non-blocking call
7599 l7 = queue6.poll();
7600 if (l2 != null)
7601 {
7602 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7603 }
7604 }
7605 catch (Exception e)
7606 {
7607 }
7608 }
7609
7610 l8 = queue7.poll();
7611 if (l8 != null)
7612 {
7613 if (l8.type == 1)
7614 {
7615 Navit.OSD_nextturn.nextturn_streetname_systematic = "";
7616 Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(8, l8.b, l8.c);
7617 if (p.PREF_item_dump)
7618 {
7619 // -------- DEBUG ------- DEBUG ---------
7620 // -------- DEBUG ------- DEBUG ---------
7621 // -------- DEBUG ------- DEBUG ---------
7622 Navit.debug_item_dump = NavitGraphics.CallbackGeoCalc(9, l8.b, l8.c);
7623 //System.out.println("xx paint 22 xx");
7624 NavitGraphics.NavitAOverlay_s.postInvalidate();
7625 // -------- DEBUG ------- DEBUG ---------
7626 // -------- DEBUG ------- DEBUG ---------
7627 // -------- DEBUG ------- DEBUG ---------
7628 }
7629 //System.out.println("OSD postinvalidate***");
7630 //System.out.println("xx paint 7 xx");
7631 // NavitOSDJava.draw_real_wrapper(true, false);
7632 ZANaviLinearLayout.redraw_OSD(1);
7633 //++ NavitGraphics.NavitAOSDJava_.postInvalidate();
7634 }
7635 else if (l8.type == 2)
7636 {
7637 NavitGraphics.CallbackGeoCalc(l8.a, l8.b, l8.c);
7638 }
7639 else if (l8.type == 13)
7640 {
7641 try
7642 {
7643 // get roadbook
7644 // String road_book_res = NavitGraphics.CallbackGeoCalc(13, l8.b, l8.c);
7645 String[] separated = NavitGraphics.GetRoadBookItems(12345);
7646 // System.out.println("ROADBOOK_RES=" + separated);
7647
7648 // parse roadbook data ------------
7649 road_book_items.clear();
7650 ZANaviListViewAdapter.ListViewItem l = null;
7651
7652 // String[] separated = road_book_res.split("\13");
7653 int jk = 0;
7654 int ResId = 0;
7655 for (jk = 0; jk < separated.length; jk++)
7656 {
7657 if (jk > 1)
7658 {
7659 // System.out.println("ROADBOOK_RES=" + jk + ":" + separated[jk]);
7660 String[] values = separated[jk].split(":");
7661 // 0 string:distance short form
7662 // 1 lat
7663 // 2 lon
7664 // 3 icon name
7665 // 4 text
7666
7667 // System.out.println("RBI:008:img=" + values[3]);
7668
7669 if (values[3].compareTo("nav_waypoint") == 0)
7670 {
7671 try
7672 {
7673 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_waypoint_bk_center", null, null);
7674 }
7675 catch (Exception e_res_id)
7676 {
7677 ResId = 0;
7678 e_res_id.printStackTrace();
7679 }
7680 }
7681 else if (values[3].compareTo("nav_destination") == 0)
7682 {
7683 try
7684 {
7685 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_destination_bk_center", null, null);
7686 }
7687 catch (Exception e_res_id)
7688 {
7689 ResId = 0;
7690 e_res_id.printStackTrace();
7691 }
7692 }
7693 else
7694 {
7695
7696 try
7697 {
7698 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + values[3] + "_bk", null, null);
7699 }
7700 catch (Exception e_res_id)
7701 {
7702 ResId = 0;
7703 e_res_id.printStackTrace();
7704 }
7705 }
7706
7707 // System.out.println("RBI:008+" + ResId);
7708 if (ResId != 0)
7709 {
7710 l = new ListViewItem(values[0], res_.getDrawable(ResId), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7711 }
7712 else
7713 {
7714 l = new ListViewItem(values[0], res_.getDrawable(R.drawable.mini_roundabout), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7715 }
7716 // System.out.println("RBI:008");
7717 road_book_items.add(l);
7718 // System.out.println("RBI:009");
7719 }
7720 }
7721 // System.out.println("RBI:010");
7722
7723 try
7724 {
7725 Message msg = Navit_progress_h.obtainMessage();
7726 Bundle b = new Bundle();
7727 msg.what = 33;
7728 msg.setData(b);
7729 Navit_progress_h.sendMessage(msg);
7730 }
7731 catch (Exception e)
7732 {
7733 e.printStackTrace();
7734 }
7735 // System.out.println("RBI:011");
7736 }
7737 catch (Exception eerb)
7738 {
7739 eerb.printStackTrace();
7740 }
7741 // parse roadbook data ------------
7742
7743 }
7744 }
7745 }
7746 catch (Exception e)
7747 {
7748 }
7749
7750 }
7751
7752 while (queue2.size() > 0)
7753 {
7754 try
7755 {
7756 // blocking call
7757 // l3 = queue2.take();
7758 // non-blocking call
7759 l3 = queue2.poll();
7760 if (l3 != null)
7761 {
7762 int i3 = l3.intValue();
7763 //System.out.println("CWorkerThread:NavitActivity_call:JTHREAD ID=" + this.getId());
7764 //System.out.println("CWorkerThread:NavitActivity_call:THREAD ID=" + NavitGraphics.GetThreadId());
7765 //System.out.println("CWorkerThread:NavitActivity:" + i3);
7766 NavitActivity(i3);
7767 }
7768 }
7769 catch (Exception e)
7770 {
7771 }
7772 }
7773
7774 // check sun position (and after interval, recalc values)
7775 do_sun_calc();
7776 }
7777 //System.out.println("CWorkerThread -- stopped --");
7778 }
7779
7780 public void stop_me()
7781 {
7782 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7783
7784 this.running = false;
7785 this.interrupt();
7786
7787 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7788 }
7789 }
7790
7791 public class SmoothVehicle extends Thread
7792 {
7793 private Boolean running;
7794
7795 SmoothVehicle()
7796 {
7797 this.running = true;
7798 }
7799
7800 public void run()
7801 {
7802 while (this.running)
7803 {
7804 try
7805 {
7806 Thread.sleep(5000); // 5 secs.
7807 }
7808 catch (InterruptedException e)
7809 {
7810 }
7811 }
7812 }
7813
7814 public void stop_me()
7815 {
7816 this.running = false;
7817 }
7818 }
7819
7820 public class WatchMem extends Thread
7821 {
7822 private Boolean running;
7823
7824 WatchMem()
7825 {
7826 this.running = true;
7827 }
7828
7829 public void run()
7830 {
7831 //System.out.println("WatchMem -- started --");
7832 while (this.running)
7833 {
7834 Navit.show_mem_used();
7835
7836 try
7837 {
7838 Thread.sleep(5000); // 5 secs.
7839 }
7840 catch (InterruptedException e)
7841 {
7842 }
7843 }
7844 //System.out.println("WatchMem -- stopped --");
7845 }
7846
7847 public void stop_me()
7848 {
7849 this.running = false;
7850 }
7851 }
7852
7853 public class SimGPS extends Thread
7854 {
7855 private Boolean running;
7856 private Handler h;
7857
7858 SimGPS(Handler h_)
7859 {
7860 System.out.println("SimGPS -- inited --");
7861 this.h = h_;
7862 this.running = true;
7863 }
7864
7865 public void run()
7866 {
7867 System.out.println("SimGPS -- started --");
7868 while (this.running)
7869 {
7870 float rnd_heading = (float) (Math.random() * 360d);
7871 float lat = 48.216023f;
7872 float lng = 16.391664f;
7873 //Location l = new Location("Network");
7874 //l.setLatitude(lat);
7875 //l.setLongitude(lng);
7876 //l.setBearing(rnd_heading);
7877 // NavitVehicle.set_mock_location__fast(l);
7878 // NavitVehicle.update_compass_heading(rnd_heading);
7879 if (this.h != null)
7880 {
7881 Message msg = this.h.obtainMessage();
7882 Bundle b = new Bundle();
7883 msg.what = 1;
7884 b.putFloat("b", rnd_heading);
7885 b.putFloat("lat", lat);
7886 b.putFloat("lng", lng);
7887 msg.setData(b);
7888 this.h.sendMessage(msg);
7889 }
7890 try
7891 {
7892 Thread.sleep(800);
7893 }
7894 catch (InterruptedException e)
7895 {
7896 }
7897 }
7898 System.out.println("SimGPS -- stopped --");
7899 }
7900
7901 public void stop_me()
7902 {
7903 this.running = false;
7904 }
7905 }
7906
7907 public class SearchResultsThreadSpinnerThread extends Thread
7908 {
7909 int dialog_num;
7910 int spinner_current_value;
7911 private Boolean running;
7912 Handler mHandler;
7913
7914 SearchResultsThreadSpinnerThread(Handler h, int dialog_num)
7915 {
7916 this.dialog_num = dialog_num;
7917 this.mHandler = h;
7918 this.spinner_current_value = 0;
7919
7920 this.running = true;
7921 Log.e("Navit", "SearchResultsThreadSpinnerThread created");
7922 }
7923
7924 public void run()
7925 {
7926 Log.e("Navit", "SearchResultsThreadSpinnerThread started");
7927 while (this.running)
7928 {
7929 if (Navit.NavitAddressSearchSpinnerActive == false)
7930 {
7931 this.running = false;
7932 }
7933 else
7934 {
7935 Message msg = mHandler.obtainMessage();
7936 Bundle b = new Bundle();
7937 msg.what = 10;
7938 b.putInt("dialog_num", this.dialog_num);
7939 b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
7940 b.putInt("cur", this.spinner_current_value % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
7941 if ((Navit.NavitSearchresultBar_title.equals("")) && (Navit.NavitSearchresultBar_text.equals("")))
7942 {
7943 b.putString("title", Navit.get_text("getting search results")); //TRANS
7944 b.putString("text", Navit.get_text("searching ...")); //TRANS
7945 }
7946 else
7947 {
7948 b.putString("title", Navit.NavitSearchresultBar_title);
7949 b.putString("text", Navit.NavitSearchresultBar_text);
7950 }
7951 msg.setData(b);
7952 mHandler.sendMessage(msg);
7953 try
7954 {
7955 Thread.sleep(700);
7956 }
7957 catch (InterruptedException e)
7958 {
7959 // e.printStackTrace();
7960 }
7961 this.spinner_current_value++;
7962 }
7963 }
7964 Log.e("Navit", "SearchResultsThreadSpinnerThread ended");
7965 }
7966 }
7967
7968 public class SearchResultsThread extends Thread
7969 {
7970 private Boolean running;
7971 Handler mHandler;
7972 int my_dialog_num;
7973
7974 SearchResultsThread(Handler h, int dialog_num)
7975 {
7976 this.running = true;
7977 this.mHandler = h;
7978 this.my_dialog_num = dialog_num;
7979 Log.e("Navit", "SearchResultsThread created");
7980 }
7981
7982 public void stop_me()
7983 {
7984 this.running = false;
7985 }
7986
7987 public void run()
7988 {
7989 Log.e("Navit", "SearchResultsThread started");
7990
7991 System.out.println("Global_Location_update_not_allowed = 1");
7992 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
7993
7994 // initialize the dialog with sane values
7995 Message msg = mHandler.obtainMessage();
7996 Bundle b = new Bundle();
7997 msg.what = 10;
7998 b.putInt("dialog_num", this.my_dialog_num);
7999 b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8000 b.putInt("cur", 0);
8001 b.putString("title", Navit.get_text("getting search results")); //TRANS
8002 b.putString("text", Navit.get_text("searching ...")); //TRANS
8003 msg.setData(b);
8004 mHandler.sendMessage(msg);
8005
8006 int partial_match_i = 0;
8007 if (Navit_last_address_partial_match)
8008 {
8009 partial_match_i = 1;
8010 }
8011
8012 if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
8013 {
8014 // start the search, this could take a long time!!
8015 Log.e("Navit", "SearchResultsThread run1");
8016 // need lowercase to find stuff !!
8017 Navit_last_address_search_string = filter_bad_chars(Navit_last_address_search_string).toLowerCase();
8018 if ((Navit_last_address_hn_string != null) && (Navit_last_address_hn_string.equals("")))
8019 {
8020 Navit_last_address_hn_string = filter_bad_chars(Navit_last_address_hn_string).toLowerCase();
8021 }
8022
8023 if (Navit_last_address_full_file_search)
8024 {
8025 // flags (18) -> order level to search at
8026 // ================
8027 // 0#0 0 -> search full world
8028 // lat#lon radius -> search only this area, around lat,lon
8029 // ================
8030 N_NavitGraphics.SearchResultList(3, partial_match_i, Navit_last_address_search_string, "", "", 18, Navit_last_address_search_country_iso2_string, "0#0", 0);
8031 }
8032 else
8033 {
8034 if (Navit.use_index_search)
8035 {
8036 // new method with index search
8037 // -----------------
8038 //Navit_last_address_search_string
8039 String street_ = "";
8040 String town_ = "";
8041 String hn_ = Navit_last_address_hn_string;
8042
8043 int last_space = Navit_last_address_search_string.lastIndexOf(" ");
8044 if (last_space != -1)
8045 {
8046 street_ = Navit_last_address_search_string.substring(0, last_space);
8047 town_ = Navit_last_address_search_string.substring(last_space + 1);
8048 // System.out.println("XX" + street_ + "YY" + town_ + "ZZ");
8049 }
8050 else
8051 {
8052 street_ = Navit_last_address_search_string;
8053 town_ = "";
8054 }
8055 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);
8056
8057 // sort result list
8058 Collections.sort(Navit.NavitAddressResultList_foundItems);
8059 }
8060 else
8061 {
8062 // old method search
8063 // -----------------
8064 // flags --> 3: search all countries
8065 // 2: search <iso2 string> country
8066 // 1: search default country (what you have set as language in prefs)
8067 N_NavitGraphics.SearchResultList(29, partial_match_i, Navit_last_address_search_string, "", "", Navit_last_address_search_country_flags, Navit_last_address_search_country_iso2_string, "0#0", 0);
8068
8069 // sort result list
8070 Collections.sort(Navit.NavitAddressResultList_foundItems);
8071 }
8072 }
8073 Log.e("Navit", "SearchResultsThread run2");
8074 }
8075 else if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG)
8076 {
8077 // online googlemaps search
8078 // google search
8079 Log.e("Navit", "SearchResultsThread run1 -> online googlemaps search");
8080 String addressInput = filter_bad_chars(Navit_last_address_search_string);
8081 try
8082 {
8083 List<Address> foundAdresses = Navit.Navit_Geocoder.getFromLocationName(addressInput, 3); //Search addresses
8084 System.out.println("found " + foundAdresses.size() + " results");
8085 // System.out.println("addr=" + foundAdresses.get(0).getLatitude() + " " + foundAdresses.get(0).getLongitude() + "" + foundAdresses.get(0).getAddressLine(0));
8086
8087 Navit.NavitAddressSearchSpinnerActive = false;
8088
8089 for (int results_step = 0; results_step < foundAdresses.size(); results_step++)
8090 {
8091 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
8092 tmp_addr.result_type = "STR";
8093 tmp_addr.item_id = "0";
8094 tmp_addr.lat = (float) foundAdresses.get(results_step).getLatitude();
8095 tmp_addr.lon = (float) foundAdresses.get(results_step).getLongitude();
8096 tmp_addr.addr = "";
8097
8098 String c_code = foundAdresses.get(results_step).getCountryCode();
8099 if (c_code != null)
8100 {
8101 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getCountryCode() + ",";
8102 }
8103
8104 String p_code = foundAdresses.get(results_step).getPostalCode();
8105 if (p_code != null)
8106 {
8107 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getPostalCode() + " ";
8108 }
8109
8110 if (foundAdresses.get(results_step).getMaxAddressLineIndex() > -1)
8111 {
8112 for (int addr_line = 0; addr_line < foundAdresses.get(results_step).getMaxAddressLineIndex(); addr_line++)
8113 {
8114 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
8115 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
8116 }
8117 }
8118
8119 Navit.NavitAddressResultList_foundItems.add(tmp_addr);
8120
8121 if (tmp_addr.result_type.equals("TWN"))
8122 {
8123 Navit.search_results_towns++;
8124 }
8125 else if (tmp_addr.result_type.equals("STR"))
8126 {
8127 Navit.search_results_streets++;
8128 }
8129 else if (tmp_addr.result_type.equals("SHN"))
8130 {
8131 Navit.search_results_streets_hn++;
8132 }
8133 else if (tmp_addr.result_type.equals("POI"))
8134 {
8135 Navit.search_results_poi++;
8136 }
8137
8138 // make the dialog move its bar ...
8139 Bundle b2 = new Bundle();
8140 b2.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
8141 b2.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8142 b2.putInt("cur", Navit.NavitAddressResultList_foundItems.size() % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
8143 b2.putString("title", Navit.get_text("loading search results")); //TRANS
8144 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);
8145
8146 Navit.msg_to_msg_handler(b2, 10);
8147 }
8148 }
8149 catch (Exception e)
8150 {
8151 e.printStackTrace();
8152 System.out.println("seems googlemaps API is not working, try offline search");
8153 }
8154 }
8155
8156 Navit.NavitAddressSearchSpinnerActive = false;
8157
8158 if (Navit.NavitAddressResultList_foundItems.size() > 0)
8159 {
8160 open_search_result_list();
8161 }
8162 else
8163 {
8164 // no results found, show toast
8165 msg = mHandler.obtainMessage();
8166 b = new Bundle();
8167 msg.what = 2;
8168 b.putString("text", Navit.get_text("No Results found!")); //TRANS
8169 msg.setData(b);
8170 mHandler.sendMessage(msg);
8171 }
8172
8173 // ok, remove dialog
8174 msg = mHandler.obtainMessage();
8175 b = new Bundle();
8176 msg.what = 99;
8177 b.putInt("dialog_num", this.my_dialog_num);
8178 msg.setData(b);
8179 mHandler.sendMessage(msg);
8180
8181 // reset the startup-search flag
8182 Navit.NavitStartupAlreadySearching = false;
8183
8184 System.out.println("Global_Location_update_not_allowed = 0");
8185 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
8186
8187 Log.e("Navit", "SearchResultsThread ended");
8188 }
8189 }
8190
8191 public static String filter_bad_chars(String in)
8192 {
8193 String out = in;
8194 out = out.replaceAll("\\n", " "); // newline -> space
8195 out = out.replaceAll("\\r", " "); // return -> space
8196 out = out.replaceAll("\\t", " "); // tab -> space
8197 out = out.trim();
8198 return out;
8199 }
8200
8201 public static void msg_to_msg_handler(Bundle b, int id)
8202 {
8203 Message msg = Navit_progress_h.obtainMessage();
8204 msg.what = id;
8205 msg.setData(b);
8206 Navit_progress_h.sendMessage(msg);
8207 }
8208
8209 public void open_search_result_list()
8210 {
8211 // open result list
8212 Intent address_result_list_activity = new Intent(this, NavitAddressResultListActivity.class);
8213 this.startActivityForResult(address_result_list_activity, Navit.NavitAddressResultList_id);
8214 }
8215
8216 public static Handler callback_handler_55 = new Handler()
8217 {
8218 public void handleMessage(Message msg)
8219 {
8220 // handle 111111
8221 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0, "" + msg.getData().getInt("Callback"));
8222
8223 if (msg.getData().getInt("Callback") == 1)
8224 {
8225 // zoom in
8226 NavitGraphics.CallbackMessageChannel(1, "");
8227 }
8228 else if (msg.getData().getInt("Callback") == 2)
8229 {
8230 // zoom out
8231 NavitGraphics.CallbackMessageChannel(2, "");
8232 }
8233 else if (msg.getData().getInt("Callback") == 55599)
8234 {
8235 // calc route after adding points
8236 NavitGraphics.CallbackMessageChannel(55599, "");
8237 }
8238 else if (msg.getData().getInt("Callback") == 55503)
8239 {
8240 try
8241 {
8242 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0);
8243 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8244 }
8245 catch (Exception e)
8246 {
8247 }
8248
8249 // get values
8250 String lat = msg.getData().getString("lat");
8251 String lon = msg.getData().getString("lon");
8252 String q = msg.getData().getString("q");
8253 // set routing target to lat,lon
8254 NavitGraphics.CallbackMessageChannel(55503, lat + "#" + lon + "#" + q);
8255 }
8256 else if (msg.getData().getInt("Callback") == 3)
8257 {
8258 try
8259 {
8260 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0);
8261 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8262 }
8263 catch (Exception e)
8264 {
8265 }
8266
8267 // get values
8268 String lat = msg.getData().getString("lat");
8269 String lon = msg.getData().getString("lon");
8270 String q = msg.getData().getString("q");
8271 // set routing target to lat,lon
8272 NavitGraphics.CallbackMessageChannel(3, lat + "#" + lon + "#" + q);
8273 }
8274 else if (msg.getData().getInt("Callback") == 55548)
8275 {
8276 try
8277 {
8278 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8279 }
8280 catch (Exception e)
8281 {
8282 }
8283
8284 // get values
8285 String lat = msg.getData().getString("lat");
8286 String lon = msg.getData().getString("lon");
8287 String q = msg.getData().getString("q");
8288 // append to routing, add waypoint at lat,lon
8289 NavitGraphics.CallbackMessageChannel(55548, lat + "#" + lon + "#" + q);
8290 }
8291 else if (msg.getData().getInt("Callback") == 48)
8292 {
8293 try
8294 {
8295 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8296 }
8297 catch (Exception e)
8298 {
8299 }
8300
8301 // get values
8302 String lat = msg.getData().getString("lat");
8303 String lon = msg.getData().getString("lon");
8304 String q = msg.getData().getString("q");
8305 // append to routing, add waypoint at lat,lon
8306 NavitGraphics.CallbackMessageChannel(48, lat + "#" + lon + "#" + q);
8307 }
8308 else if (msg.getData().getInt("Callback") == 4)
8309 {
8310 // set routing target to pixel x,y
8311 int x = msg.getData().getInt("x");
8312 int y = msg.getData().getInt("y");
8313
8314 NavitGraphics.CallbackMessageChannel(4, "" + x + "#" + y);
8315 try
8316 {
8317 Navit.follow_button_on();
8318 }
8319 catch (Exception e2)
8320 {
8321 e2.printStackTrace();
8322 }
8323 }
8324 else if (msg.getData().getInt("Callback") == 49)
8325 {
8326 // set routing target to pixel x,y
8327 int x = msg.getData().getInt("x");
8328 int y = msg.getData().getInt("y");
8329
8330 NavitGraphics.CallbackMessageChannel(49, "" + x + "#" + y);
8331 try
8332 {
8333 Navit.follow_button_on();
8334 }
8335 catch (Exception e2)
8336 {
8337 e2.printStackTrace();
8338 }
8339 }
8340 else if (msg.getData().getInt("Callback") == 5)
8341 {
8342 // toggle layer on/off
8343 String s = msg.getData().getString("s");
8344 NavitGraphics.CallbackMessageChannel(5, s);
8345 }
8346 else if (msg.getData().getInt("Callback") == 7)
8347 {
8348 NavitGraphics.CallbackMessageChannel(7, "");
8349 }
8350 else if ((msg.getData().getInt("Callback") > 7) && (msg.getData().getInt("Callback") < 21))
8351 {
8352 NavitGraphics.CallbackMessageChannel(msg.getData().getInt("Callback"), "");
8353 }
8354 else if (msg.getData().getInt("Callback") == 21)
8355 {
8356 int x = msg.getData().getInt("x");
8357 int y = msg.getData().getInt("y");
8358 // ??? // ButtonCallback(1, 1, x, y); // down
8359 }
8360 else if (msg.getData().getInt("Callback") == 22)
8361 {
8362 int x = msg.getData().getInt("x");
8363 int y = msg.getData().getInt("y");
8364 // ??? // ButtonCallback(0, 1, x, y); // up
8365 }
8366 else if (msg.getData().getInt("Callback") == 23)
8367 {
8368 int x = msg.getData().getInt("x");
8369 int y = msg.getData().getInt("y");
8370 int x2 = msg.getData().getInt("x2");
8371 int y2 = msg.getData().getInt("y2");
8372 NavitGraphics.MotionCallback(x, y, x2, y2);
8373 }
8374 else if (msg.getData().getInt("Callback") == 24)
8375 {
8376 try
8377 {
8378 NavitGraphics.NavitMsgTv_.setEnabled(true);
8379 NavitGraphics.NavitMsgTv_.setVisibility(View.VISIBLE);
8380 }
8381 catch (Exception e)
8382 {
8383
8384 }
8385 }
8386 else if (msg.getData().getInt("Callback") == 25)
8387 {
8388 try
8389 {
8390 NavitGraphics.NavitMsgTv_.setVisibility(View.INVISIBLE);
8391 NavitGraphics.NavitMsgTv_.setEnabled(false);
8392 NavitGraphics.NavitMsgTv_.setVisibility(View.GONE);
8393 }
8394 catch (Exception e)
8395 {
8396
8397 }
8398 }
8399 else if (msg.getData().getInt("Callback") == 30)
8400 {
8401 // 2D
8402 // String s = msg.getData().getString("s");
8403 NavitGraphics.CallbackMessageChannel(30, "");
8404 }
8405 else if (msg.getData().getInt("Callback") == 31)
8406 {
8407 // 3D
8408 // String s = msg.getData().getString("s");
8409 NavitGraphics.CallbackMessageChannel(31, "");
8410 }
8411 else if (msg.getData().getInt("Callback") == 32)
8412 {
8413 // switch to specific 3D pitch
8414 String s = msg.getData().getString("s");
8415 NavitGraphics.CallbackMessageChannel(32, s);
8416 }
8417 else if (msg.getData().getInt("Callback") == 33)
8418 {
8419 // zoom to specific zoomlevel
8420 String s = msg.getData().getString("s");
8421 NavitGraphics.CallbackMessageChannel(33, s);
8422 }
8423 else if (msg.getData().getInt("Callback") == 34)
8424 {
8425 // announcer voice OFF
8426 NavitGraphics.CallbackMessageChannel(34, "");
8427 }
8428 else if (msg.getData().getInt("Callback") == 35)
8429 {
8430 // announcer voice ON
8431 NavitGraphics.CallbackMessageChannel(35, "");
8432 }
8433 else if (msg.getData().getInt("Callback") == 36)
8434 {
8435 // switch "Lock on road" ON
8436 NavitGraphics.CallbackMessageChannel(36, "");
8437 }
8438 else if (msg.getData().getInt("Callback") == 37)
8439 {
8440 // switch "Lock on road" OFF
8441 NavitGraphics.CallbackMessageChannel(37, "");
8442 }
8443 else if (msg.getData().getInt("Callback") == 38)
8444 {
8445 // switch "Northing" ON
8446 NavitGraphics.CallbackMessageChannel(38, "");
8447 }
8448 else if (msg.getData().getInt("Callback") == 39)
8449 {
8450 // switch "Northing" OFF
8451 NavitGraphics.CallbackMessageChannel(39, "");
8452 }
8453 else if (msg.getData().getInt("Callback") == 40)
8454 {
8455 // switch "Map follows Vehicle" ON
8456 NavitGraphics.CallbackMessageChannel(40, "");
8457 }
8458 else if (msg.getData().getInt("Callback") == 41)
8459 {
8460 // switch "Map follows Vehicle" OFF
8461 NavitGraphics.CallbackMessageChannel(41, "");
8462 }
8463 else if (msg.getData().getInt("Callback") == 42)
8464 {
8465 // routing mode "highways"
8466 NavitGraphics.CallbackMessageChannel(42, "");
8467 }
8468 else if (msg.getData().getInt("Callback") == 43)
8469 {
8470 // routing mode "normal roads"
8471 NavitGraphics.CallbackMessageChannel(43, "");
8472 }
8473 else if (msg.getData().getInt("Callback") == 44)
8474 {
8475 // show duplicates in search results
8476 NavitGraphics.CallbackMessageChannel(44, "");
8477 }
8478 else if (msg.getData().getInt("Callback") == 45)
8479 {
8480 // filter duplicates in search results
8481 NavitGraphics.CallbackMessageChannel(45, "");
8482 }
8483 else if (msg.getData().getInt("Callback") == 46)
8484 {
8485 // stop searching and show results found until now
8486 NavitGraphics.CallbackMessageChannel(46, "");
8487 }
8488 else if (msg.getData().getInt("Callback") == 47)
8489 {
8490 // change maps data dir
8491 String s = msg.getData().getString("s");
8492 NavitGraphics.CallbackMessageChannel(47, s);
8493 }
8494 else if (msg.getData().getInt("Callback") == 50)
8495 {
8496 // we request to stop drawing the map
8497 NavitGraphics.CallbackMessageChannel(50, "");
8498 }
8499 else if (msg.getData().getInt("Callback") == 51)
8500 {
8501 // set position to pixel x,y
8502 int x = msg.getData().getInt("x");
8503 int y = msg.getData().getInt("y");
8504 NavitGraphics.CallbackMessageChannel(51, "" + x + "#" + y);
8505 }
8506 else if (msg.getData().getInt("Callback") == 52)
8507 {
8508 // switch to demo vehicle
8509 String s = msg.getData().getString("s");
8510 NavitGraphics.CallbackMessageChannel(52, s);
8511 }
8512 else if (msg.getData().getInt("Callback") == 53)
8513 {
8514 // dont speak streetnames
8515 NavitGraphics.CallbackMessageChannel(53, "");
8516 }
8517 else if (msg.getData().getInt("Callback") == 54)
8518 {
8519 // speak streetnames
8520 NavitGraphics.CallbackMessageChannel(54, "");
8521 }
8522 else if (msg.getData().getInt("Callback") == 55)
8523 {
8524 // set cache size for (map-)files
8525 String s = msg.getData().getString("s");
8526 NavitGraphics.CallbackMessageChannel(55, s);
8527 }
8528 // else if (msg.getData().getInt("Callback") == 56)
8529 // {
8530 // // draw polylines with/without circles at the end
8531 // String s = msg.getData().getString("s");
8532 // NavitGraphics.CallbackMessageChannel(56, s); // 0 -> draw circles, 1 -> DO NOT draw circles
8533 // }
8534 else if (msg.getData().getInt("Callback") == 57)
8535 {
8536 // keep drawing streets as if at "order" level xxx
8537 String s = msg.getData().getString("s");
8538 NavitGraphics.CallbackMessageChannel(57, s);
8539 }
8540 else if (msg.getData().getInt("Callback") == 58)
8541 {
8542 // street search radius factor (multiplier)
8543 String s = msg.getData().getString("s");
8544 NavitGraphics.CallbackMessageChannel(58, s);
8545 }
8546 else if (msg.getData().getInt("Callback") == 59)
8547 {
8548 // enable layer "name"
8549 String s = msg.getData().getString("s");
8550 NavitGraphics.CallbackMessageChannel(59, s);
8551 }
8552 else if (msg.getData().getInt("Callback") == 60)
8553 {
8554 // disable layer "name"
8555 String s = msg.getData().getString("s");
8556 NavitGraphics.CallbackMessageChannel(60, s);
8557 }
8558 else if (msg.getData().getInt("Callback") == 61)
8559 {
8560 // zoom to specific zoomlevel at given point as center
8561 // pixel-x#pixel-y#zoom-level
8562 String s = msg.getData().getString("s");
8563 NavitGraphics.CallbackMessageChannel(61, s);
8564 }
8565 else if (msg.getData().getInt("Callback") == 62)
8566 {
8567 // disable map drawing
8568 NavitGraphics.CallbackMessageChannel(62, "");
8569 }
8570 else if (msg.getData().getInt("Callback") == 63)
8571 {
8572 // enable map drawing
8573 NavitGraphics.CallbackMessageChannel(63, "");
8574 }
8575 else if (msg.getData().getInt("Callback") == 64)
8576 {
8577 // draw map
8578 NavitGraphics.CallbackMessageChannel(64, "");
8579 }
8580 else if (msg.getData().getInt("Callback") == 65)
8581 {
8582 // draw map async
8583 NavitGraphics.CallbackMessageChannel(65, "");
8584 }
8585 else if (msg.getData().getInt("Callback") == 66)
8586 {
8587 // enable "multipolygons"
8588 NavitGraphics.CallbackMessageChannel(66, "");
8589 }
8590 else if (msg.getData().getInt("Callback") == 67)
8591 {
8592 // disable "multipolygons"
8593 NavitGraphics.CallbackMessageChannel(67, "");
8594 }
8595 else if (msg.getData().getInt("Callback") == 68)
8596 {
8597 // shift "order" by this value (only for drawing objects)
8598 String s = msg.getData().getString("s");
8599 NavitGraphics.CallbackMessageChannel(68, s);
8600 }
8601 else if (msg.getData().getInt("Callback") == 69)
8602 {
8603 // stop drawing map
8604 NavitGraphics.CallbackMessageChannel(69, "");
8605 }
8606 else if (msg.getData().getInt("Callback") == 70)
8607 {
8608 // allow drawing map
8609 NavitGraphics.CallbackMessageChannel(70, "");
8610 }
8611 else if (msg.getData().getInt("Callback") == 71)
8612 {
8613 // activate/deactivate "route graph" display
8614 // 0 -> deactivate
8615 // 1 -> activate
8616 String s = msg.getData().getString("s");
8617 NavitGraphics.CallbackMessageChannel(71, s);
8618 }
8619 else if (msg.getData().getInt("Callback") == 72)
8620 {
8621 // update the route path and route graph (e.g. after setting new roadblocks)
8622 // does not update destinations!!!
8623 NavitGraphics.CallbackMessageChannel(72, "");
8624 }
8625 else if (msg.getData().getInt("Callback") == 73)
8626 {
8627 // update the route path and route graph (e.g. after setting new roadblocks)
8628 // this destroys the route graph and calcs everything totally new!
8629 NavitGraphics.CallbackMessageChannel(73, "");
8630 }
8631
8632 else if (msg.getData().getInt("Callback") == 74)
8633 {
8634 // allow demo vechile to move
8635 NavitGraphics.CallbackMessageChannel(74, "");
8636 }
8637 else if (msg.getData().getInt("Callback") == 75)
8638 {
8639 // stop demo vechile
8640 NavitGraphics.CallbackMessageChannel(75, "");
8641 }
8642 else if (msg.getData().getInt("Callback") == 76)
8643 {
8644 // show route rectangles
8645 NavitGraphics.CallbackMessageChannel(76, "");
8646 }
8647 else if (msg.getData().getInt("Callback") == 77)
8648 {
8649 // do not show route rectangles
8650 NavitGraphics.CallbackMessageChannel(77, "");
8651 }
8652 else if (msg.getData().getInt("Callback") == 78)
8653 {
8654 // shift layout "order" values
8655 String s = msg.getData().getString("s");
8656 NavitGraphics.CallbackMessageChannel(78, s);
8657 }
8658 else if (msg.getData().getInt("Callback") == 79)
8659 {
8660 // set traffic light delay/cost
8661 String s = msg.getData().getString("s");
8662 NavitGraphics.CallbackMessageChannel(79, s);
8663 }
8664 else if (msg.getData().getInt("Callback") == 80)
8665 {
8666 // set autozoom flag to 0 or 1
8667 String s = msg.getData().getString("s");
8668 NavitGraphics.CallbackMessageChannel(80, s);
8669 }
8670 else if (msg.getData().getInt("Callback") == 81)
8671 {
8672 // resize layout items by factor
8673 String s = msg.getData().getString("s");
8674 NavitGraphics.CallbackMessageChannel(81, s);
8675 }
8676 else if (msg.getData().getInt("Callback") == 82)
8677 {
8678 // report share dir
8679 String s = msg.getData().getString("s");
8680 NavitGraphics.CallbackMessageChannel(82, s);
8681 }
8682 else if (msg.getData().getInt("Callback") == 83)
8683 {
8684 // spill all the index files to log output
8685 NavitGraphics.CallbackMessageChannel(83, "");
8686 }
8687 else if (msg.getData().getInt("Callback") == 84)
8688 {
8689 // report data dir
8690 String s = msg.getData().getString("s");
8691 NavitGraphics.CallbackMessageChannel(84, s);
8692 }
8693 else if (msg.getData().getInt("Callback") == 85)
8694 {
8695 // C linedrawing flag
8696 String s = msg.getData().getString("s");
8697 NavitGraphics.CallbackMessageChannel(85, s);
8698 }
8699 else if (msg.getData().getInt("Callback") == 86)
8700 {
8701 // avoid sharp turns flag to 0 or 1
8702 String s = msg.getData().getString("s");
8703 NavitGraphics.CallbackMessageChannel(86, s);
8704 }
8705 else if (msg.getData().getInt("Callback") == 87)
8706 {
8707 // // avoid sharp turns minimum angle. if turn is harder than this angle then set penalty
8708 String s = msg.getData().getString("s");
8709 NavitGraphics.CallbackMessageChannel(87, s);
8710 }
8711 else if (msg.getData().getInt("Callback") == 88)
8712 {
8713 // avoid sharp turns penalty
8714 String s = msg.getData().getString("s");
8715 NavitGraphics.CallbackMessageChannel(88, s);
8716 }
8717 else if (msg.getData().getInt("Callback") == 89)
8718 {
8719 // search radius for housenumbers for streets
8720 String s = msg.getData().getString("s");
8721 NavitGraphics.CallbackMessageChannel(89, s);
8722 }
8723 else if (msg.getData().getInt("Callback") == 90)
8724 {
8725 // set vehicleprofile to value of string s ('car','bike')
8726 String s = msg.getData().getString("s");
8727 NavitGraphics.CallbackMessageChannel(90, s);
8728 }
8729 else if (msg.getData().getInt("Callback") == 91)
8730 {
8731 // change vehicle profile's roadprofile values
8732 String s = msg.getData().getString("s");
8733 NavitGraphics.CallbackMessageChannel(91, s);
8734 }
8735 else if (msg.getData().getInt("Callback") == 92)
8736 {
8737 // change vehicle profile's roadprofile values 2
8738 String s = msg.getData().getString("s");
8739 NavitGraphics.CallbackMessageChannel(92, s);
8740 }
8741 else if (msg.getData().getInt("Callback") == 93)
8742 {
8743 // change vehicle profile's roadprofile values 3
8744 String s = msg.getData().getString("s");
8745 NavitGraphics.CallbackMessageChannel(93, s);
8746 }
8747 else if (msg.getData().getInt("Callback") == 94)
8748 {
8749 // change priority for cycle lanes
8750 String s = msg.getData().getString("s");
8751 NavitGraphics.CallbackMessageChannel(94, s);
8752 }
8753 //else if (msg.getData().getInt("Callback") == 95)
8754 //{
8755 // // change priority for cycle tracks
8756 // String s = msg.getData().getString("s");
8757 // NavitGraphics.CallbackMessageChannel(95, s);
8758 //}
8759 else if (msg.getData().getInt("Callback") == 96)
8760 {
8761 // dump route to GPX file, "s" -> full pathname to output file
8762 String s = msg.getData().getString("s");
8763 NavitGraphics.CallbackMessageChannel(96, s);
8764 }
8765 else if (msg.getData().getInt("Callback") == 97)
8766 {
8767 // set positon to lat#lon#name
8768 String lat = msg.getData().getString("lat");
8769 String lon = msg.getData().getString("lon");
8770 String q = msg.getData().getString("q");
8771 NavitGraphics.CallbackMessageChannel(97, lat + "#" + lon + "#" + q);
8772 }
8773 else if (msg.getData().getInt("Callback") == 98)
8774 {
8775 // set connected_pref value
8776 String s = msg.getData().getString("s");
8777 NavitGraphics.CallbackMessageChannel(98, s);
8778 }
8779 else if (msg.getData().getInt("Callback") == 99)
8780 {
8781 // set angle_pref value
8782 String s = msg.getData().getString("s");
8783 NavitGraphics.CallbackMessageChannel(99, s);
8784 }
8785 else if (msg.getData().getInt("Callback") == 100)
8786 {
8787 // dump callbacks to log
8788 NavitGraphics.CallbackMessageChannel(100, "");
8789 }
8790 else if (msg.getData().getInt("Callback") == 101)
8791 {
8792 // set demo vehicle flag for tracking
8793 NavitGraphics.CallbackMessageChannel(101, "");
8794 }
8795 else if (msg.getData().getInt("Callback") == 102)
8796 {
8797 // set gpsfix flag
8798 String s = msg.getData().getString("s");
8799 NavitGraphics.CallbackMessageChannel(102, s);
8800 }
8801 else if (msg.getData().getInt("Callback") == 103)
8802 {
8803 // draw location of self (car) x% lower than screen center
8804 String s = msg.getData().getString("s");
8805 NavitGraphics.CallbackMessageChannel(103, s);
8806 }
8807 else if (msg.getData().getInt("Callback") == 104)
8808 {
8809 // send OVERSPILL_FACTOR to C-code
8810 String s;
8811 if (Navit.GFX_OVERSPILL)
8812 {
8813 s = "" + (OVERSPILL_FACTOR * 100);
8814 }
8815 else
8816 {
8817 s = "" + 100;
8818 }
8819
8820 NavitGraphics.CallbackMessageChannel(104, s);
8821 }
8822 else if (msg.getData().getInt("Callback") == 105)
8823 {
8824 // zoom to specific zoomlevel without redrawing the map!
8825 String s = msg.getData().getString("s");
8826 NavitGraphics.CallbackMessageChannel(105, s);
8827 }
8828 else if (msg.getData().getInt("Callback") == 106)
8829 {
8830 // factor for routing/road speed
8831 String s = msg.getData().getString("s");
8832 NavitGraphics.CallbackMessageChannel(106, s);
8833 }
8834 else if (msg.getData().getInt("Callback") == 107)
8835 {
8836 // level 0 announcement seconds
8837 String s = msg.getData().getString("s");
8838 NavitGraphics.CallbackMessageChannel(107, s);
8839 }
8840 else if (msg.getData().getInt("Callback") == 108)
8841 {
8842 // level 1 announcement seconds
8843 String s = msg.getData().getString("s");
8844 NavitGraphics.CallbackMessageChannel(108, s);
8845 }
8846 else if (msg.getData().getInt("Callback") == 109)
8847 {
8848 // level 2 announcement seconds
8849 String s = msg.getData().getString("s");
8850 NavitGraphics.CallbackMessageChannel(109, s);
8851 }
8852 else if (msg.getData().getInt("Callback") == 110)
8853 {
8854 // generic int option CallBack [<option name>:<option value "int">]
8855 String s = msg.getData().getString("s");
8856 NavitGraphics.CallbackMessageChannel(110, s);
8857 }
8858 else if (msg.getData().getInt("Callback") == 111)
8859 {
8860 // show real gps position on map
8861 String s = msg.getData().getString("s");
8862 NavitGraphics.CallbackMessageChannel(111, s);
8863 }
8864 else if (msg.getData().getInt("Callback") == 9901)
8865 {
8866 // if follow mode is on, then dont show freeview streetname
8867 //if (!Navit.PREF_follow_gps)
8868 //{
8869 // Navit.cwthr.CallbackGeoCalc2(1, 0, mCanvasWidth / 2, mCanvasHeight / 2);
8870 //}
8871 }
8872 else if (msg.getData().getInt("Callback") == 98001)
8873 {
8874 int id = msg.getData().getInt("id");
8875 int i = msg.getData().getInt("i");
8876 NavitGraphics.return_generic_int_real(id, i);
8877 }
8878 else if (msg.getData().getInt("Callback") == 9001)
8879 {
8880 NavitGraphics.busyspinner_.setVisibility(View.INVISIBLE);
8881 NavitGraphics.busyspinnertext_.setVisibility(View.INVISIBLE);
8882 }
8883 else if (msg.getData().getInt("Callback") == 9002)
8884 {
8885 NavitGraphics.busyspinner_.setVisibility(View.VISIBLE);
8886 NavitGraphics.busyspinnertext_.setVisibility(View.VISIBLE);
8887 }
8888
8889 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
8890 }
8891 };
8892
8893 public Handler progress_handler = new Handler()
8894 {
8895
8896 @SuppressLint("NewApi")
8897 public void handleMessage(Message msg)
8898 {
8899 switch (msg.what)
8900 {
8901 case 0:
8902 // dismiss dialog, remove dialog
8903 try
8904 {
8905 Log.e("Navit", "0: dismiss dialog num " + msg.getData().getInt("dialog_num"));
8906 }
8907 catch (Exception e)
8908 {
8909 e.printStackTrace();
8910 }
8911
8912 try
8913 {
8914 dismissDialog(msg.getData().getInt("dialog_num"));
8915 removeDialog(msg.getData().getInt("dialog_num"));
8916 }
8917 catch (Exception e)
8918 {
8919 }
8920
8921 // exit_code=0 -> OK, map was downloaded fine
8922 if (msg.getData().getInt("exit_code") == 0)
8923 {
8924 // try to use the new downloaded map (works fine now!)
8925 //Log.d("Navit", "instance count=" + Navit.getInstanceCount()); // where did this go to?
8926
8927 // **** onStop();
8928 // **** onCreate(getIntent().getExtras());
8929
8930 String this_map_name = "map";
8931 try
8932 {
8933 this_map_name = msg.getData().getString("map_name");
8934 }
8935 catch (Exception e)
8936 {
8937 }
8938
8939 // reload sdcard maps
8940 Message msg2 = new Message();
8941 Bundle b2 = new Bundle();
8942 b2.putInt("Callback", 18);
8943 msg2.setData(b2);
8944 NavitGraphics.callback_handler.sendMessage(msg2);
8945
8946 // ----- service stop -----
8947 // ----- service stop -----
8948 Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
8949 // ----- service stop -----
8950 // ----- service stop -----
8951
8952 try
8953 {
8954 // show notification that map is ready
8955 String Notification_header = "ZANavi";
8956 String Notification_text = this_map_name + " ready";
8957
8958 NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
8959 Notification notification = new Notification(R.drawable.icon, "ZANavi download finished", System.currentTimeMillis());
8960 notification.flags = Notification.FLAG_AUTO_CANCEL;
8961 Intent in = new Intent();
8962 in.setClass(getBaseContext_, Navit.class);
8963 in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
8964 PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
8965 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
8966
8967 try
8968 {
8969 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
8970 }
8971 catch (Exception e)
8972 {
8973 e.printStackTrace();
8974
8975 try
8976 {
8977 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
8978
8979 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
8980 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
8981 }
8982 catch (Exception e2)
8983 {
8984 e2.printStackTrace();
8985 }
8986 }
8987 }
8988 catch (Exception e)
8989 {
8990 e.printStackTrace();
8991 }
8992
8993 zoom_out_full();
8994
8995 /*
8996 * Intent intent = getIntent();
8997 * System.out.println("ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ**********************");
8998 * startActivity(intent);
8999 * System.out.println("FFFFFFFFFFFFFFFFFFF**********************");
9000 * Log.d("Navit", "instance count=" + Navit.getInstanceCount());
9001 * onStop();
9002 * System.out.println("HHHHHHHHHHHHHHHHHHH**********************");
9003 */
9004
9005 //Message msg2 = new Message();
9006 //Bundle b2 = new Bundle();
9007 //b2.putInt("Callback", 6);
9008 //msg2.setData(b2);
9009 //N_NavitGraphics.callback_handler.sendMessage(msg2);
9010 }
9011 else
9012 {
9013 // there was a problem downloading the map
9014 // ----- service stop -----
9015 // ----- service stop -----
9016 Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
9017 // ----- service stop -----
9018 // ----- service stop -----
9019
9020 String this_map_name = "map";
9021 try
9022 {
9023 this_map_name = msg.getData().getString("map_name");
9024 }
9025 catch (Exception e)
9026 {
9027 }
9028
9029 try
9030 {
9031
9032 // show notification that there was a download problem
9033 String Notification_header = "ZANavi";
9034 String Notification_text = "ERROR while downloading " + this_map_name;
9035
9036 NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
9037 Notification notification = new Notification(R.drawable.icon, "ZANavi download ERROR", System.currentTimeMillis());
9038 notification.flags = Notification.FLAG_AUTO_CANCEL;
9039 Intent in = new Intent();
9040 in.setClass(getBaseContext_, Navit.class);
9041 in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9042 PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9043 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9044
9045 try
9046 {
9047 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9048 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9049 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9050 // {
9051 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9052 // }
9053
9054 }
9055 catch (Exception e)
9056 {
9057 e.printStackTrace();
9058
9059 try
9060 {
9061 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9062
9063 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9064 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9065 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9066 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9067 // {
9068 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9069 // }
9070 }
9071 catch (Exception e2)
9072 {
9073 e2.printStackTrace();
9074 }
9075 }
9076 }
9077 catch (Exception e)
9078 {
9079 e.printStackTrace();
9080 }
9081 }
9082 break;
9083 case 1:
9084 // change progressbar values
9085 try
9086 {
9087 int what_dialog = msg.getData().getInt("dialog_num");
9088 if (what_dialog == MAPDOWNLOAD_PRI_DIALOG)
9089 {
9090 mapdownloader_dialog_pri.setMax(msg.getData().getInt("max"));
9091 mapdownloader_dialog_pri.setProgress(msg.getData().getInt("cur"));
9092 mapdownloader_dialog_pri.setTitle(msg.getData().getString("title"));
9093 mapdownloader_dialog_pri.setMessage(msg.getData().getString("text"));
9094 }
9095 else if (what_dialog == MAPDOWNLOAD_SEC_DIALOG)
9096 {
9097 mapdownloader_dialog_sec.setMax(msg.getData().getInt("max"));
9098 mapdownloader_dialog_sec.setProgress(msg.getData().getInt("cur"));
9099 mapdownloader_dialog_sec.setTitle(msg.getData().getString("title"));
9100 mapdownloader_dialog_sec.setMessage(msg.getData().getString("text"));
9101 }
9102 }
9103 catch (Exception e)
9104 {
9105 }
9106 break;
9107 case 2:
9108 Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
9109 break;
9110 case 3:
9111 Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_LONG).show();
9112 break;
9113 case 10:
9114 // change values - generic
9115 try
9116 {
9117 int what_dialog_generic = msg.getData().getInt("dialog_num");
9118 if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG)
9119 {
9120 search_results_wait.setMax(msg.getData().getInt("max"));
9121 search_results_wait.setProgress(msg.getData().getInt("cur"));
9122 search_results_wait.setTitle(msg.getData().getString("title"));
9123 search_results_wait.setMessage(msg.getData().getString("text"));
9124 }
9125 else if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
9126 {
9127 search_results_wait_offline.setMax(msg.getData().getInt("max"));
9128 search_results_wait_offline.setProgress(msg.getData().getInt("cur"));
9129 search_results_wait_offline.setTitle(msg.getData().getString("title"));
9130 search_results_wait_offline.setMessage(msg.getData().getString("text"));
9131 }
9132 }
9133 catch (Exception e)
9134 {
9135 }
9136 break;
9137 case 11:
9138 // show dialog - generic
9139 try
9140 {
9141 // just in case, remove the dialog if it should be shown already!
9142 dismissDialog(msg.getData().getInt("dialog_num"));
9143 removeDialog(msg.getData().getInt("dialog_num"));
9144 }
9145 catch (Exception e)
9146 {
9147 // System.out.println("Ex D1: " + e.toString());
9148 }
9149 showDialog(msg.getData().getInt("dialog_num"));
9150 break;
9151 case 12:
9152 // turn on compass
9153 turn_on_compass();
9154 break;
9155 case 13:
9156 // turn off compass
9157 turn_off_compass();
9158 break;
9159 case 14:
9160 // set used mem in textview
9161 show_mem_used_real();
9162 break;
9163 case 15:
9164 // set debug text line 3
9165 Navit.set_debug_messages3(msg.getData().getString("text"));
9166 break;
9167 case 16:
9168 // refresh NavitAndriodOverlay
9169 try
9170 {
9171 //Log.e("NavitGraphics", "xx 1");
9172 //System.out.println("invalidate 027");
9173 NavitGraphics.NavitAOverlay_s.invalidate();
9174 //Log.e("NavitGraphics", "xx 2");
9175 }
9176 catch (Exception e)
9177 {
9178 e.printStackTrace();
9179 }
9180 break;
9181 case 17:
9182 try
9183 {
9184
9185 generic_alert_box.setMessage(Navit.get_text("Possibly not enough space on your device!")).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener() // TRANS
9186 {
9187 public void onClick(DialogInterface dialog, int id)
9188 {
9189 // Handle Ok
9190 }
9191 }).create();
9192 generic_alert_box.setCancelable(false);
9193 generic_alert_box.setTitle(Navit.get_text("device space")); // TRANS
9194 generic_alert_box.show();
9195 }
9196 catch (Exception e)
9197 {
9198 e.printStackTrace();
9199 }
9200 break;
9201 // case 18:
9202 // try
9203 // {
9204 // openOptionsMenu_wrapper();
9205 // }
9206 // catch (Exception e)
9207 // {
9208 // }
9209 // break;
9210 case 19:
9211 open_voice_recog_screen();
9212 break;
9213 case 20:
9214 dim_screen();
9215 break;
9216 case 21:
9217 default_brightness_screen();
9218 break;
9219 case 22:
9220 try
9221 {
9222 // ----- service start -----
9223 // ----- service start -----
9224 startService(Navit.ZANaviMapDownloaderServiceIntent);
9225 // ----- service start -----
9226 // ----- service start -----
9227
9228 // try
9229 // {
9230 // Thread.sleep(200);
9231 // }
9232 // catch (InterruptedException e)
9233 // {
9234 // }
9235
9236 // if (!ZANaviMapDownloaderService.service_running)
9237 // {
9238 // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
9239 // try
9240 // {
9241 // Thread.sleep(2000);
9242 // }
9243 // catch (InterruptedException e)
9244 // {
9245 // }
9246 // }
9247 //
9248 // if (!ZANaviMapDownloaderService.service_running)
9249 // {
9250 // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
9251 // try
9252 // {
9253 // Thread.sleep(2000);
9254 // }
9255 // catch (InterruptedException e)
9256 // {
9257 // }
9258 // }
9259
9260 // -------- // ZANaviMapDownloaderService.start_map_download();
9261 }
9262 catch (Exception e)
9263 {
9264 e.printStackTrace();
9265 }
9266 break;
9267 case 23:
9268
9269 // show actionbar download icon
9270 try
9271 {
9272 // show download actionbar icon
9273 //cur_menu.findItem(R.id.item_download_menu_button).setTitle("");
9274 actionabar_download_icon_visible = true;
9275 cur_menu.findItem(R.id.item_download_menu_button).setVisible(true);
9276 //cur_menu.findItem(R.id.item_download_menu_button).setEnabled(true);
9277 // ****** // cur_menu.findItem(R.id.item_download_menu_button).setIcon(R.drawable.anim_download_icon);
9278 // cur_menu.findItem(R.id.item_download_menu_button).setIcon((Drawable) null);
9279 }
9280 catch (Exception e)
9281 {
9282 e.printStackTrace();
9283 }
9284
9285 try
9286 {
9287 show_status_bar();
9288 getSupportActionBar().setDisplayShowTitleEnabled(true);
9289 }
9290 catch (Exception e)
9291 {
9292 e.printStackTrace();
9293 }
9294
9295 // try
9296 // {
9297 // View menuItemView = findViewById(R.id.item_download_menu_button);
9298 // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_2);
9299 // // menuItemView.setOnClickListener(new View.OnClickListener()
9300 // // {
9301 // // public void onClick(View v)
9302 // // {
9303 // // try
9304 // // {
9305 // // //menuItemView.setBackgroundResource(R.drawable.anim_download_icon_1);
9306 // // //AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9307 // // //frameAnimation.start();
9308 // // // menuItemView.setAlpha(100);
9309 // // View menuItemView = findViewById(R.id.item_download_menu_button);
9310 // // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_1);
9311 // //
9312 // // System.out.println("download icon pressed(2)");
9313 // //
9314 // // Intent mapdownload_cancel_activity = new Intent(Navit.getBaseContext_, ZANaviDownloadMapCancelActivity.class);
9315 // // mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9316 // // startActivity(mapdownload_cancel_activity);
9317 // //
9318 // // new Handler().postDelayed(new Runnable()
9319 // // {
9320 // // @Override
9321 // // public void run()
9322 // // {
9323 // // if (Navit.cur_menu.findItem(R.id.item_download_menu_button).isVisible())
9324 // // {
9325 // // View menuItemView = findViewById(R.id.item_download_menu_button);
9326 // // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_2);
9327 // // AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9328 // // frameAnimation.start();
9329 // // }
9330 // // }
9331 // // }, 50);
9332 // // }
9333 // // catch (Exception e)
9334 // // {
9335 // // }
9336 // // }
9337 // // });
9338 // AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9339 // frameAnimation.start();
9340 // }
9341 // catch (Exception e)
9342 // {
9343 // e.printStackTrace();
9344 // }
9345
9346 break;
9347 case 24:
9348 // hide actionbar download icon
9349
9350 // try
9351 // {
9352 // View menuItemView = findViewById(R.id.item_download_menu_button);
9353 // menuItemView.setBackground((Drawable) null);
9354 //
9355 // new Handler().postDelayed(new Runnable()
9356 // {
9357 // @Override
9358 // public void run()
9359 // {
9360 // if (Navit.cur_menu.findItem(R.id.item_download_menu_button).isVisible())
9361 // {
9362 // View menuItemView = findViewById(R.id.item_download_menu_button);
9363 // menuItemView.setBackground((Drawable) null);
9364 // }
9365 // }
9366 // }, 50);
9367 // }
9368 // catch (Exception e)
9369 // {
9370 // e.printStackTrace();
9371 // }
9372
9373 try
9374 {
9375 // hide download actionbar icon
9376 actionabar_download_icon_visible = false;
9377 cur_menu.findItem(R.id.item_download_menu_button).setVisible(false);
9378 //cur_menu.findItem(R.id.item_download_menu_button).setEnabled(false);
9379 // cur_menu.findItem(R.id.item_download_menu_button).setIcon((Drawable) null);
9380 }
9381 catch (Exception e)
9382 {
9383 e.printStackTrace();
9384 }
9385
9386 try
9387 {
9388 getSupportActionBar().setDisplayShowTitleEnabled(false);
9389 }
9390 catch (Exception e)
9391 {
9392 e.printStackTrace();
9393 }
9394
9395 try
9396 {
9397 hide_status_bar();
9398 }
9399 catch (Exception e)
9400 {
9401 e.printStackTrace();
9402 }
9403
9404 break;
9405 case 25:
9406 // Log.e("Navit", "nav: 25");
9407 NavitGraphics.deactivate_nav_wakelock_real();
9408 break;
9409 case 26:
9410 // Log.e("Navit", "nav: 26");
9411 NavitGraphics.activate_nav_wakelock_real();
9412 break;
9413 case 27:
9414 show_status_bar();
9415 break;
9416 case 28:
9417 hide_status_bar();
9418 break;
9419 case 29:
9420 invalidateOptionsMenu();
9421 break;
9422 case 30:
9423 try
9424 {
9425 NavitGraphics.NavitMsgTv2_.append(msg.getData().getString("text"));
9426 }
9427 catch (Exception e)
9428 {
9429 e.printStackTrace();
9430 }
9431 break;
9432 case 31:
9433 try
9434 {
9435 // map download menu
9436 Intent map_download_list_activity = new Intent(getBaseContext_, NavitDownloadSelectMapActivity.class);
9437 startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
9438 }
9439 catch (Exception e)
9440 {
9441 e.printStackTrace();
9442 }
9443 break;
9444 case 32:
9445 try
9446 {
9447 if (p.PREF_follow_gps)
9448 {
9449 push_pin_view.setImageResource(R.drawable.pin1_down);
9450 }
9451 else
9452 {
9453 push_pin_view.setImageResource(R.drawable.pin1_up);
9454 }
9455 }
9456 catch (Exception e)
9457 {
9458 e.printStackTrace();
9459 }
9460 break;
9461 case 33:
9462 if (road_book != null)
9463 {
9464 if (road_book_items != null)
9465 {
9466 try
9467 {
9468 // send new roadbook items to fragment and reload it
9469 road_book.reload_items(road_book_items);
9470 }
9471 catch (Exception e)
9472 {
9473 }
9474 }
9475 }
9476 break;
9477 case 34:
9478 // show bubble
9479 NavitGraphics.whats_here_container_wrap.setVisibility(View.VISIBLE);
9480 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9481 break;
9482 case 35:
9483 // hide bubble
9484 NavitGraphics.whats_here_container_wrap.setVisibility(View.INVISIBLE);
9485 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9486 // and move out of screen
9487
9488 if (!Navit.PAINT_OLD_API)
9489 {
9490 NavitGraphics.whats_here_container_wrap.setX(-2000);
9491 NavitGraphics.whats_here_container_wrap.setY(-2000);
9492 // NavitGraphics.whats_here_container_wrap.requestLayout();
9493
9494 NavitGraphics.whats_here_pointer_image.setX(0);
9495 }
9496 else
9497 {
9498 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9499 NavitGraphics.params_whats_here_container_wrap.leftMargin = -2000;
9500 NavitGraphics.params_whats_here_container_wrap.topMargin = -2000;
9501 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9502 NavitGraphics.whats_here_container_wrap.requestLayout();
9503
9504 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9505 // NavitGraphics.params_whats_here_pointer_image.leftMargin = 0;
9506 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9507 NavitGraphics.whats_here_pointer_image.requestLayout();
9508
9509 }
9510 break;
9511 case 36:
9512 // move bubble to x,y
9513 int width_in_px = getResources().getDimensionPixelSize(R.dimen.whats_here_container_width);
9514 int new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x;
9515 int new_diff = 0;
9516 if ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) > NavitGraphics.mCanvasWidth)
9517 {
9518 new_diff = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9519 new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x - ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth);
9520 }
9521
9522 new_x = new_x - NavitGraphics.dp_to_px(17);
9523
9524 if (!Navit.PAINT_OLD_API)
9525 {
9526 NavitGraphics.whats_here_container_wrap.setX(new_x);
9527 NavitGraphics.whats_here_container_wrap.setY(NavitGraphics.NavitAOverlay_s.bubble_001.y + NavitGraphics.dp_to_px(17));
9528 // NavitGraphics.whats_here_container_wrap.requestLayout();
9529
9530 NavitGraphics.whats_here_pointer_image.setX(new_diff);
9531 }
9532 else
9533 {
9534 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9535 NavitGraphics.params_whats_here_container_wrap.leftMargin = new_x;
9536 NavitGraphics.params_whats_here_container_wrap.topMargin = NavitGraphics.NavitAOverlay_s.bubble_001.y - NavitGraphics.whats_here_container_wrap.getHeight() + NavitGraphics.dp_to_px(17);
9537 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9538 NavitGraphics.whats_here_container_wrap.requestLayout();
9539
9540 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9541 // NavitGraphics.params_whats_here_pointer_image.leftMargin = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9542 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9543 NavitGraphics.whats_here_pointer_image.requestLayout();
9544 }
9545 break;
9546 case 37:
9547 // set text for point on screen
9548 String dest_name = "Point on Screen";
9549
9550 try
9551 {
9552 if (Navit.GFX_OVERSPILL)
9553 {
9554 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);
9555 }
9556 else
9557 {
9558 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);
9559 }
9560
9561 if ((dest_name.equals(" ")) || (dest_name == null))
9562 {
9563 dest_name = "Point on Screen";
9564 }
9565 }
9566 catch (Exception e)
9567 {
9568 e.printStackTrace();
9569 }
9570
9571 NavitGraphics.whats_here_text.setText(dest_name);
9572 break;
9573 case 38:
9574 try
9575 {
9576 NavitAddressSearchActivity.adapter.clear();
9577 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9578 // NavitAddressSearchActivity.listview.postInvalidate();
9579 }
9580 catch (Exception e)
9581 {
9582 System.out.println("AAEE:001");
9583 }
9584 break;
9585 case 39:
9586 try
9587 {
9588 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9589 }
9590 catch (Exception e)
9591 {
9592 System.out.println("AAEE:008");
9593 }
9594 break;
9595 case 99:
9596 // dismiss dialog, remove dialog - generic
9597 try
9598 {
9599 Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
9600 }
9601 catch (Exception e)
9602 {
9603 e.printStackTrace();
9604 }
9605 try
9606 {
9607 dismissDialog(msg.getData().getInt("dialog_num"));
9608 }
9609 catch (Exception e)
9610 {
9611 e.printStackTrace();
9612 }
9613 try
9614 {
9615 removeDialog(msg.getData().getInt("dialog_num"));
9616 }
9617 catch (Exception e)
9618 {
9619 e.printStackTrace();
9620 }
9621 break;
9622 }
9623 }
9624 };
9625
9626 @TargetApi(Build.VERSION_CODES.FROYO)
9627 protected Dialog onCreateDialog(int id)
9628 {
9629 switch (id)
9630 {
9631 case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
9632 search_results_wait_offline = new ProgressDialog(this);
9633 search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9634 search_results_wait_offline.setTitle("--");
9635 search_results_wait_offline.setMessage("--");
9636 search_results_wait_offline.setCancelable(true); // allow to stop search
9637 search_results_wait_offline.setProgress(0);
9638 search_results_wait_offline.setMax(10);
9639
9640 search_results_wait_offline.setOnCancelListener(new OnCancelListener()
9641 {
9642 public void onCancel(DialogInterface dialog)
9643 {
9644 Message msg = new Message();
9645 Bundle b = new Bundle();
9646 b.putInt("Callback", 46);
9647 msg.setData(b);
9648 try
9649 {
9650 NavitGraphics.callback_handler.sendMessage(msg);
9651 }
9652 catch (Exception e)
9653 {
9654 }
9655 Log.e("Navit", "onCancel: search_results_wait offline");
9656 }
9657 });
9658
9659 /*
9660 * search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
9661 * {
9662 * public void onClick(DialogInterface dialog, int which)
9663 * {
9664 * // Use either finish() or return() to either close the activity or just the dialog
9665 * return;
9666 * }
9667 * });
9668 */
9669
9670 DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener()
9671 {
9672 public void onDismiss(DialogInterface dialog)
9673 {
9674 Log.e("Navit", "onDismiss: search_results_wait offline");
9675 dialog.dismiss();
9676 dialog.cancel();
9677 searchresultsThread_offline.stop_me();
9678 }
9679 };
9680 search_results_wait_offline.setOnDismissListener(mOnDismissListener4);
9681 searchresultsThread_offline = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
9682 searchresultsThread_offline.start();
9683
9684 NavitAddressSearchSpinnerActive = true;
9685 spinner_thread_offline = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
9686 spinner_thread_offline.start();
9687
9688 return search_results_wait_offline;
9689 case Navit.SEARCHRESULTS_WAIT_DIALOG:
9690 search_results_wait = new ProgressDialog(this);
9691 search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9692 search_results_wait.setTitle("--");
9693 search_results_wait.setMessage("--");
9694 search_results_wait.setCancelable(false);
9695 search_results_wait.setProgress(0);
9696 search_results_wait.setMax(10);
9697
9698 DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener()
9699 {
9700 public void onDismiss(DialogInterface dialog)
9701 {
9702 Log.e("Navit", "onDismiss: search_results_wait");
9703 dialog.dismiss();
9704 dialog.cancel();
9705 searchresultsThread.stop_me();
9706 }
9707 };
9708 search_results_wait.setOnDismissListener(mOnDismissListener3);
9709 searchresultsThread = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
9710 searchresultsThread.start();
9711
9712 NavitAddressSearchSpinnerActive = true;
9713 spinner_thread = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
9714 spinner_thread.start();
9715
9716 return search_results_wait;
9717 case Navit.MAPDOWNLOAD_PRI_DIALOG:
9718 mapdownloader_dialog_pri = new ProgressDialog(this);
9719 mapdownloader_dialog_pri.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9720 mapdownloader_dialog_pri.setTitle("--");
9721 mapdownloader_dialog_pri.setMessage("--");
9722 mapdownloader_dialog_pri.setCancelable(false);
9723 mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
9724 mapdownloader_dialog_pri.setProgress(0);
9725 mapdownloader_dialog_pri.setMax(200);
9726
9727 WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
9728 dialog_lparams.screenBrightness = 0.1f;
9729 mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);
9730
9731 DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener()
9732 {
9733 public void onDismiss(DialogInterface dialog)
9734 {
9735 android.view.WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
9736 mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
9737 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
9738 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
9739 Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
9740 dialog.dismiss();
9741 dialog.cancel();
9742 progressThread_pri.stop_thread();
9743 }
9744 };
9745
9746 try
9747 {
9748 mapdownloader_dialog_pri.setButton(AlertDialog.BUTTON_NEGATIVE, Navit.get_text("Cancel"), new DialogInterface.OnClickListener()
9749 {
9750 @Override
9751 public void onClick(DialogInterface dialog, int which)
9752 {
9753 mapdownloader_dialog_pri.dismiss();
9754 }
9755 });
9756 }
9757 catch (Exception e)
9758 {
9759 e.printStackTrace();
9760 }
9761
9762 mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
9763 mapdownloader_pri = new NavitMapDownloader(this);
9764 progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
9765 progressThread_pri.start();
9766 //
9767 // show license for OSM maps
9768 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
9769 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
9770 return mapdownloader_dialog_pri;
9771 case Navit.MAPDOWNLOAD_SEC_DIALOG:
9772 mapdownloader_dialog_sec = new ProgressDialog(this);
9773 mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9774 mapdownloader_dialog_sec.setTitle("--");
9775 mapdownloader_dialog_sec.setMessage("--");
9776
9777 mapdownloader_dialog_sec.setCancelable(true);
9778 mapdownloader_dialog_sec.setProgress(0);
9779 mapdownloader_dialog_sec.setMax(200);
9780 DialogInterface.OnDismissListener mOnDismissListener2 = new DialogInterface.OnDismissListener()
9781 {
9782 public void onDismiss(DialogInterface dialog)
9783 {
9784 Log.e("Navit", "onDismiss: mapdownloader_dialog sec");
9785 dialog.dismiss();
9786 dialog.cancel();
9787 progressThread_sec.stop_thread();
9788 }
9789 };
9790 mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
9791 mapdownloader_sec = new NavitMapDownloader(this);
9792 progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
9793 progressThread_sec.start();
9794 //
9795 // show license for OSM maps
9796 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
9797 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
9798 return mapdownloader_dialog_sec;
9799 }
9800 // should never get here!!
9801 return null;
9802 }
9803
9804 public void disableSuspend()
9805 {
9806 // wl.acquire();
9807 // wl.release();
9808 }
9809
9810 public void exit2()
9811 {
9812 System.out.println("in exit2");
9813 }
9814
9815 public void exit()
9816 {
9817 try
9818 {
9819 if (toneG != null)
9820 {
9821 toneG.stopTone();
9822 toneG.release();
9823
9824 }
9825 }
9826 catch (Exception e)
9827 {
9828 }
9829
9830 NavitVehicle.turn_off_all_providers();
9831 //try
9832 //{
9833 // NavitSpeech.stop_me();
9834 //}
9835 //catch (Exception s)
9836 //{
9837 // s.printStackTrace();
9838 //}
9839
9840 try
9841 {
9842 mTts.stop();
9843 }
9844 catch (Exception e)
9845 {
9846
9847 }
9848
9849 try
9850 {
9851 mTts.shutdown();
9852 }
9853 catch (Exception e)
9854 {
9855
9856 }
9857 mTts = null;
9858
9859 try
9860 {
9861 try
9862 {
9863 plugin_api.removeListener(zclientListener);
9864 }
9865 catch (Exception e)
9866 {
9867 e.printStackTrace();
9868 Log.i("NavitPlugin", "Failed to remove Listener", e);
9869 }
9870 unbindService(serviceConnection);
9871 Log.i("NavitPlugin", "Unbind from the service");
9872 }
9873 catch (Throwable t)
9874 {
9875 // catch any issues, typical for destroy routines
9876 // even if we failed to destroy something, we need to continue destroying
9877 Log.i("NavitPlugin", "Failed to unbind from the service", t);
9878 }
9879
9880 try
9881 {
9882 if (wl_navigating != null)
9883 {
9884 //if (wl_navigating.isHeld())
9885 //{
9886 wl_navigating.release();
9887 Log.e("Navit", "WakeLock Nav: release 1");
9888 //}
9889 }
9890 }
9891 catch (Exception e)
9892 {
9893 e.printStackTrace();
9894 }
9895
9896 Log.e("Navit", "1***************** exit called ****************");
9897 Log.e("Navit", "2***************** exit called ****************");
9898 Log.e("Navit", "3***************** exit called ****************");
9899 Log.e("Navit", "4***************** exit called ****************");
9900 Log.e("Navit", "5***************** exit called ****************");
9901 Log.e("Navit", "6***************** exit called ****************");
9902 Log.e("Navit", "7***************** exit called ****************");
9903 Log.e("Navit", "8***************** exit called ****************");
9904
9905 // try
9906 // {
9907 // // hide download actionbar icon
9908 // Navit.cur_menu.findItem(R.id.item_download_menu_button).setVisible(false);
9909 // Navit.cur_menu.findItem(R.id.item_download_menu_button).setEnabled(false);
9910 // }
9911 // catch (Exception e)
9912 // {
9913 // }
9914
9915 // ----- service stop -----
9916 // ----- service stop -----
9917 System.out.println("Navit:exit -> stop ZANaviMapDownloaderService ---------");
9918 ZANaviMapDownloaderService.stop_downloading();
9919 stopService(Navit.ZANaviMapDownloaderServiceIntent);
9920 // ----- service stop -----
9921 // ----- service stop -----
9922
9923 // +++++ // System.gc();
9924 NavitActivity(-4);
9925 Log.e("Navit", "XX1***************** exit called ****************");
9926 finish();
9927 Log.e("Navit", "XX2***************** exit called ****************");
9928 System.runFinalizersOnExit(true);
9929 Log.e("Navit", "XX3***************** exit called ****************");
9930 System.exit(0);
9931 Log.e("Navit", "XX4***************** exit called ****************");
9932 }
9933
9934 public boolean handleMessage(Message m)
9935 {
9936 //Log.e("Navit", "Handler received message");
9937 return true;
9938 }
9939
9940 public static void set_2d3d_mode_in_settings()
9941 {
9942 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
9943 SharedPreferences.Editor editor = prefs.edit();
9944 editor.putBoolean("show_3d_map", p.PREF_show_3d_map);
9945 editor.commit();
9946 }
9947
9948 public static void follow_button_on()
9949 {
9950 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
9951 SharedPreferences.Editor editor = prefs.edit();
9952 Navit.follow_current = Navit.follow_on;
9953 p.PREF_follow_gps = true;
9954 editor.putBoolean("follow_gps", p.PREF_follow_gps);
9955 editor.commit();
9956
9957 // hold all map drawing -----------
9958 Message msg = new Message();
9959 Bundle b = new Bundle();
9960 b.putInt("Callback", 69);
9961 msg.setData(b);
9962 try
9963 {
9964 NavitGraphics.callback_handler.sendMessage(msg);
9965 }
9966 catch (Exception e)
9967 {
9968 e.printStackTrace();
9969 }
9970 // hold all map drawing -----------
9971
9972 msg = Navit_progress_h.obtainMessage();
9973 b = new Bundle();
9974 msg.what = 32;
9975 try
9976 {
9977 Navit_progress_h.sendMessage(msg);
9978 }
9979 catch (Exception e)
9980 {
9981 }
9982
9983 getPrefs();
9984 activatePrefs(1);
9985
9986 // follow mode ON -----------
9987 msg = new Message();
9988 b = new Bundle();
9989 b.putInt("Callback", 74);
9990 msg.setData(b);
9991 try
9992 {
9993 NavitGraphics.callback_handler.sendMessage(msg);
9994 }
9995 catch (Exception e)
9996 {
9997 e.printStackTrace();
9998 }
9999 // follow mode ON -----------
10000
10001 // allow all map drawing -----------
10002 msg = new Message();
10003 b = new Bundle();
10004 b.putInt("Callback", 70);
10005 msg.setData(b);
10006 try
10007 {
10008 NavitGraphics.callback_handler.sendMessage(msg);
10009 }
10010 catch (Exception e)
10011 {
10012 }
10013 // allow all map drawing -----------
10014
10015 NavitVehicle.set_last_known_pos_fast_provider();
10016
10017 // JB fix
10018 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10019 //System.out.println("xx paint 12 xx");
10020 NavitGraphics.OSD_new.postInvalidate();
10021 NavitGraphics.NavitAOverlay_s.postInvalidate();
10022 }
10023
10024 public static void follow_button_off()
10025 {
10026 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10027 SharedPreferences.Editor editor = prefs.edit();
10028 Navit.follow_current = Navit.follow_off;
10029 p.PREF_follow_gps = false;
10030 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10031 editor.commit();
10032 getPrefs();
10033 activatePrefs(1);
10034
10035 // follow mode OFF -----------
10036 Message msg = new Message();
10037 Bundle b = new Bundle();
10038 b.putInt("Callback", 75);
10039 msg.setData(b);
10040 try
10041 {
10042 NavitGraphics.callback_handler.sendMessage(msg);
10043 }
10044 catch (Exception e)
10045 {
10046 }
10047 // follow mode OFF -----------
10048
10049 msg = Navit_progress_h.obtainMessage();
10050 b = new Bundle();
10051 msg.what = 32;
10052 try
10053 {
10054 Navit_progress_h.sendMessage(msg);
10055 }
10056 catch (Exception e)
10057 {
10058 }
10059
10060 // JB fix
10061 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10062 //System.out.println("xx paint 13 xx");
10063 NavitGraphics.OSD_new.postInvalidate();
10064 NavitGraphics.NavitAOverlay_s.postInvalidate();
10065
10066 }
10067
10068 public static void toggle_poi_pref()
10069 {
10070 // PREF_show_poi_on_map
10071 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10072 SharedPreferences.Editor editor = prefs.edit();
10073 if (p.PREF_show_poi_on_map)
10074 {
10075 p.PREF_show_poi_on_map = false;
10076 }
10077 else
10078 {
10079 p.PREF_show_poi_on_map = true;
10080 }
10081 editor.putBoolean("show_poi_on_map", p.PREF_show_poi_on_map);
10082 editor.commit();
10083 }
10084
10085 public static void toggle_follow_button()
10086 {
10087 // the "red needle" OSD calls this function only!!
10088 //Log.e("NavitVehicle", "toggle_follow_button");
10089 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10090 SharedPreferences.Editor editor = prefs.edit();
10091 if (p.PREF_follow_gps)
10092 {
10093 Navit.follow_current = Navit.follow_off;
10094 p.PREF_follow_gps = false;
10095
10096 // follow mode OFF -----------
10097 Message msg = new Message();
10098 Bundle b = new Bundle();
10099 b.putInt("Callback", 75);
10100 msg.setData(b);
10101 try
10102 {
10103 NavitGraphics.callback_handler.sendMessage(msg);
10104 }
10105
10106 catch (Exception e)
10107 {
10108 e.printStackTrace();
10109 }
10110 // follow mode OFF -----------
10111 }
10112 else
10113 {
10114 Navit.follow_current = Navit.follow_on;
10115 p.PREF_follow_gps = true;
10116
10117 // follow mode ON -----------
10118 Message msg = new Message();
10119 Bundle b = new Bundle();
10120 b.putInt("Callback", 74);
10121 msg.setData(b);
10122 try
10123 {
10124 NavitGraphics.callback_handler.sendMessage(msg);
10125 }
10126 catch (Exception e)
10127 {
10128 e.printStackTrace();
10129 }
10130 // follow mode ON -----------
10131 }
10132 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10133 editor.commit();
10134 //if (!PREF_follow_gps)
10135 //{
10136 // // no compass turning without follow mode!
10137 // PREF_use_compass_heading_base = false;
10138 //}
10139 //if (!PREF_use_compass_heading_base)
10140 //{
10141 // // child is always "false" when parent is "false" !!
10142 // PREF_use_compass_heading_always = false;
10143 //}
10144
10145 Message msg = Navit_progress_h.obtainMessage();
10146 Bundle b = new Bundle();
10147 msg.what = 32;
10148 try
10149 {
10150 Navit_progress_h.sendMessage(msg);
10151 }
10152 catch (Exception e)
10153 {
10154 }
10155
10156 // hold all map drawing -----------
10157 msg = new Message();
10158 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 getPrefs();
10172 activatePrefs(1);
10173
10174 // allow all map drawing -----------
10175 msg = new Message();
10176 b = new Bundle();
10177 b.putInt("Callback", 70);
10178 msg.setData(b);
10179 try
10180 {
10181 NavitGraphics.callback_handler.sendMessage(msg);
10182 }
10183 catch (Exception e)
10184 {
10185 }
10186 // allow all map drawing -----------
10187
10188 NavitVehicle.set_last_known_pos_fast_provider();
10189
10190 // JB fix
10191 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10192 //System.out.println("xx paint 14 xx");
10193 NavitGraphics.OSD_new.postInvalidate();
10194 NavitGraphics.NavitAOverlay_s.postInvalidate();
10195 }
10196
10197 public static void setPrefs_search_country()
10198 {
10199 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10200
10201 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10202 SharedPreferences.Editor editor = prefs.edit();
10203 editor.putInt("search_country_id", p.PREF_search_country);
10204 editor.commit();
10205
10206 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10207 }
10208
10209 public static void setPrefs_zoomlevel()
10210 {
10211 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10212
10213 //System.out.println("1 save zoom level: " + Navit.GlobalScaleLevel);
10214 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10215 SharedPreferences.Editor editor = prefs.edit();
10216 editor.putInt("zoomlevel_num", Navit.GlobalScaleLevel);
10217 editor.commit();
10218 //System.out.println("2 save zoom level: " + Navit.GlobalScaleLevel);
10219
10220 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10221 }
10222
10223 public static void setPrefs_selected_gpx_dir()
10224 {
10225 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10226
10227 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10228 SharedPreferences.Editor editor = prefs.edit();
10229 editor.putString("last_selected_dir_gpxfiles", p.PREF_last_selected_dir_gpxfiles);
10230 editor.commit();
10231
10232 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10233 }
10234
10235 private static void getPrefs_more_map_detail()
10236 {
10237 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10238
10239 // int ret = 0;
10240 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10241 try
10242 {
10243 p.PREF_more_map_detail = Integer.parseInt(prefs.getString("more_map_detail", "0"));
10244 }
10245 catch (Exception e)
10246 {
10247 p.PREF_more_map_detail = 0;
10248 }
10249
10250 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10251 }
10252
10253 private static void get_prefs_highdpi()
10254 {
10255 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10256
10257 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10258 try
10259 {
10260 p.PREF_shrink_on_high_dpi = prefs.getBoolean("shrink_on_high_dpi", true);
10261 }
10262 catch (Exception e)
10263 {
10264 p.PREF_shrink_on_high_dpi = true;
10265 }
10266
10267 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10268 }
10269
10270 public static boolean saveArray(String[] array, String arrayName, int size)
10271 {
10272 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10273 SharedPreferences.Editor editor = prefs.edit();
10274 editor.putInt(arrayName + "_size", size);
10275 for (int i = 0; i < array.length; i++)
10276 {
10277 if (array[i] == null)
10278 {
10279 editor.putString(arrayName + "_" + i, "");
10280 }
10281 else
10282 {
10283 editor.putString(arrayName + "_" + i, array[i]);
10284 }
10285 }
10286 return editor.commit();
10287 }
10288
10289 public static String[] loadArray(String arrayName, int size)
10290 {
10291 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10292 String[] array = new String[size];
10293 for (int i = 0; i < size; i++)
10294 {
10295 try
10296
10297 {
10298 array[i] = prefs.getString(arrayName + "_" + i, "");
10299 }
10300 catch (Exception e)
10301 {
10302 array[i] = "";
10303 }
10304 //System.out.println("array" + i + "=" + array[i]);
10305 }
10306
10307 return array;
10308 }
10309
10310 public static String[] pushToArray(String[] array_in, String value, int size)
10311 {
10312 for (int j = 0; j < size; j++)
10313 {
10314 if (array_in[j].equals(value))
10315 {
10316 // our value is already in the array, dont add it twice!
10317 return array_in;
10318 }
10319 }
10320
10321 String[] array = new String[size];
10322 for (int i = size - 1; i > 0; i--)
10323 {
10324 array[i] = array_in[i - 1];
10325 }
10326 array[0] = value;
10327 return array;
10328 }
10329
10330 private static void getPrefs()
10331 {
10332 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10333
10334 // save old pref values ---------------
10335 ZANaviPrefs.deep_copy(p, p_old);
10336 // save old pref values ---------------
10337
10338 // Get the xml/preferences.xml preferences
10339 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10340 p.PREF_use_fast_provider = prefs.getBoolean("use_fast_provider", true);
10341 p.PREF_allow_gui_internal = prefs.getBoolean("allow_gui_internal", false);
10342 p.PREF_follow_gps = prefs.getBoolean("follow_gps", true);
10343 p.PREF_use_compass_heading_base = prefs.getBoolean("use_compass_heading_base", false);
10344 p.PREF_use_compass_heading_always = prefs.getBoolean("use_compass_heading_always", false);
10345 p.PREF_use_compass_heading_fast = prefs.getBoolean("use_compass_heading_fast", false);
10346 p.PREF_use_anti_aliasing = prefs.getBoolean("use_anti_aliasing", true);
10347 p.PREF_use_map_filtering = prefs.getBoolean("use_map_filtering", true);
10348 p.PREF_gui_oneway_arrows = prefs.getBoolean("gui_oneway_arrows", true);
10349 p.PREF_c_linedrawing = prefs.getBoolean("c_linedrawing", false);
10350
10351 p.PREF_show_debug_messages = prefs.getBoolean("show_debug_messages", false);
10352
10353 p.PREF_show_3d_map = prefs.getBoolean("show_3d_map", false);
10354 send_data_to_plugin_bg(PLUGIN_MSG_CAT_3d_mode, String.valueOf(p.PREF_show_3d_map));
10355
10356 p.PREF_use_smooth_drawing = prefs.getBoolean("use_smooth_drawing", true);
10357 p.PREF_use_more_smooth_drawing = prefs.getBoolean("use_more_smooth_drawing", false);
10358 if (p.PREF_use_smooth_drawing == false)
10359 {
10360 p.PREF_use_more_smooth_drawing = false;
10361 }
10362 if (p.PREF_use_more_smooth_drawing == true)
10363 {
10364 p.PREF_use_smooth_drawing = true;
10365 }
10366
10367 boolean b1 = prefs.getBoolean("show_real_gps_pos", false);
10368 if (b1 == false)
10369 {
10370 p.PREF_show_real_gps_pos = 0;
10371 }
10372 else
10373 {
10374 p.PREF_show_real_gps_pos = 1;
10375 }
10376
10377 if (p.PREF_use_more_smooth_drawing)
10378 {
10379 NavitGraphics.Vehicle_delay_real_gps_position = 595;
10380 }
10381 else
10382 {
10383 NavitGraphics.Vehicle_delay_real_gps_position = 450;
10384 }
10385
10386 p.PREF_use_lock_on_roads = prefs.getBoolean("use_lock_on_roads", true);
10387 p.PREF_use_route_highways = prefs.getBoolean("use_route_highways", true);
10388 p.PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true);
10389 p.PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL*
10390 p.PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 174698); // default zoom level = 174698 // shows almost the whole world
10391 p.PREF_show_sat_status = prefs.getBoolean("show_sat_status", true);
10392 p.PREF_use_agps = prefs.getBoolean("use_agps", true);
10393 p.PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false);
10394
10395 try
10396 {
10397 // recreate the menu items
10398 Message msg = Navit_progress_h.obtainMessage();
10399 Bundle b = new Bundle();
10400 msg.what = 29;
10401 msg.setData(b);
10402 Navit_progress_h.sendMessage(msg);
10403 }
10404 catch (Exception e)
10405 {
10406 e.printStackTrace();
10407 }
10408
10409 p.PREF_enable_debug_write_gpx = prefs.getBoolean("enable_debug_write_gpx", false);
10410 p.PREF_enable_debug_enable_comm = prefs.getBoolean("enable_debug_enable_comm", false);
10411
10412 p.PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
10413 p.PREF_use_custom_font = prefs.getBoolean("use_custom_font", true);
10414 p.PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
10415 p.PREF_streetsearch_r = prefs.getString("streetsearch_r", "2");
10416 p.PREF_route_style = prefs.getString("route_style", "3");
10417 p.PREF_item_dump = prefs.getBoolean("item_dump", false);
10418 p.PREF_show_route_rects = prefs.getBoolean("show_route_rects", false);
10419 p.PREF_trafficlights_delay = prefs.getString("trafficlights_delay", "0");
10420 boolean tmp = prefs.getBoolean("avoid_sharp_turns", false);
10421 p.PREF_avoid_sharp_turns = "0";
10422 //if (tmp)
10423 //{
10424 // p.PREF_avoid_sharp_turns = "1";
10425 //}
10426 p.PREF_autozoom_flag = prefs.getBoolean("autozoom_flag", true);
10427
10428 p.PREF_show_multipolygons = prefs.getBoolean("show_multipolygons", true);
10429 p.PREF_use_index_search = true; // prefs.getBoolean("use_index_search", true);
10430
10431 // PREF_show_2d3d_toggle = prefs.getBoolean("show_2d3d_toggle", true);
10432 p.PREF_show_2d3d_toggle = true;
10433
10434 // PREF_show_vehicle_3d = prefs.getBoolean("show_vehicle_3d", true);
10435 p.PREF_show_vehicle_3d = true;
10436
10437 p.PREF_speak_filter_special_chars = prefs.getBoolean("speak_filter_special_chars", true);
10438 try
10439 {
10440 p.PREF_routing_engine = Integer.parseInt(prefs.getString("routing_engine", "0"));
10441 }
10442 catch (Exception e)
10443 {
10444 p.PREF_routing_engine = 0;
10445 }
10446
10447 // send to C code --------
10448 NavitGraphics.CallbackMessageChannel(55598, "" + p.PREF_routing_engine);
10449 // send to C code --------
10450
10451 p.PREF_routing_profile = prefs.getString("routing_profile", "car");
10452 p.PREF_road_priority_001 = (prefs.getInt("road_priority_001", (68 - 10)) + 10); // must ADD minimum value!!
10453 p.PREF_road_priority_002 = (prefs.getInt("road_priority_002", (329 - 10)) + 10); // must ADD minimum value!!
10454 p.PREF_road_priority_003 = (prefs.getInt("road_priority_003", (5000 - 10)) + 10); // must ADD minimum value!!
10455 p.PREF_road_priority_004 = (prefs.getInt("road_priority_004", (5 - 0)) + 0); // must ADD minimum value!!
10456
10457 // p.PREF_road_prio_weight_street_1_city = (prefs.getInt("road_prio_weight_street_1_city", (30 - 10)) + 10); // must ADD minimum value!!
10458
10459 p.PREF_traffic_speed_factor = (prefs.getInt("traffic_speed_factor", (83 - 20)) + 20); // must ADD minimum value!!
10460
10461 p.PREF_tracking_connected_pref = (prefs.getInt("tracking_connected_pref", (250 - 0)) + 0); // must ADD minimum value!!
10462 p.PREF_tracking_angle_pref = (prefs.getInt("tracking_angle_pref", (40 - 0)) + 0); // must ADD minimum value!!
10463
10464 p.PREF_streets_only = prefs.getBoolean("streets_only", false);
10465 p.PREF_show_status_bar = prefs.getBoolean("show_status_bar", true);
10466 p.PREF_show_poi_on_map = prefs.getBoolean("show_poi_on_map", false);
10467 p.PREF_last_selected_dir_gpxfiles = prefs.getString("last_selected_dir_gpxfiles", MAP_FILENAME_PATH + "/../");
10468
10469 p.PREF_roadspeed_warning = prefs.getBoolean("roadspeed_warning", false);
10470 p.PREF_lane_assist = prefs.getBoolean("lane_assist", false);
10471
10472 try
10473 {
10474 p.PREF_roadspeed_warning_margin = Integer.parseInt(prefs.getString("roadspeed_warning_margin", "20"));
10475 }
10476 catch (Exception e)
10477 {
10478 p.PREF_roadspeed_warning_margin = 20;
10479 }
10480
10481 p.PREF_StreetSearchStrings = loadArray("xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
10482
10483 try
10484 {
10485 p.PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
10486 }
10487 catch (Exception e)
10488 {
10489 p.PREF_drawatorder = 0;
10490 }
10491
10492 //try
10493 //{
10494 // PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1"));
10495 //}
10496 //catch (Exception e)
10497 //{
10498 p.PREF_cancel_map_drawing_timeout = 1;
10499 //}
10500
10501 try
10502 {
10503 p.PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "3"));
10504 }
10505 catch (Exception e)
10506 {
10507 p.PREF_map_font_size = 2;
10508 }
10509
10510 Navit_last_address_search_country_id = p.PREF_search_country;
10511 Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[p.PREF_search_country][0];
10512
10513 if (!p.PREF_follow_gps)
10514 {
10515 // no compass turning without follow mode!
10516 p.PREF_use_compass_heading_base = false;
10517 }
10518
10519 if (!p.PREF_use_compass_heading_base)
10520 {
10521 // child is always "false" when parent is "false" !!
10522 p.PREF_use_compass_heading_always = false;
10523 }
10524 p.PREF_show_vehicle_in_center = prefs.getBoolean("show_vehicle_in_center", false);
10525 p.PREF_use_imperial = prefs.getBoolean("use_imperial", false);
10526 Navit.cur_max_speed = -1; // to update speedwarning graphics
10527
10528 // System.out.println("get settings");
10529 // System.out.println("PREF_search_country=" + PREF_search_country);
10530 // System.out.println("PREF_follow_gps=" + PREF_follow_gps);
10531 // System.out.println("PREF_use_fast_provider=" + PREF_use_fast_provider);
10532 // System.out.println("PREF_allow_gui_internal=" + PREF_allow_gui_internal);
10533 // System.out.println("PREF_use_compass_heading_base=" + PREF_use_compass_heading_base);
10534 // System.out.println("PREF_use_compass_heading_always=" + PREF_use_compass_heading_always);
10535 // System.out.println("PREF_show_vehicle_in_center=" + PREF_show_vehicle_in_center);
10536 // System.out.println("PREF_use_imperial=" + PREF_use_imperial);
10537
10538 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10539 }
10540
10541 private static void activatePrefs()
10542 {
10543 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10544
10545 activatePrefs(1);
10546
10547 if (p.PREF_save_zoomlevel)
10548 {
10549 // only if really started, but NOT if returning from our own child activities!!
10550
10551 //System.out.println("3 restore zoom level: " + Navit.GlobalScaleLevel);
10552 //System.out.println("4 restore zoom level: " + PREF_zoomlevel_num);
10553
10554 Message msg = new Message();
10555 Bundle b = new Bundle();
10556 b.putInt("Callback", 33);
10557 b.putString("s", Integer.toString(p.PREF_zoomlevel_num));
10558 msg.setData(b);
10559 try
10560 {
10561 NavitGraphics.callback_handler.sendMessage(msg);
10562 Navit.GlobalScaleLevel = p.PREF_zoomlevel_num;
10563 //System.out.println("5 restore zoom level: " + PREF_zoomlevel_num);
10564 }
10565 catch (Exception e)
10566 {
10567 }
10568 }
10569 else
10570 {
10571 p.PREF_zoomlevel_num = Navit.GlobalScaleLevel;
10572 }
10573
10574 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10575 }
10576
10577 private static void set_poi_layers()
10578 {
10579 int on_ = 59;
10580 int off_ = 60;
10581
10582 // System.out.println("POI:1");
10583 if (p.PREF_show_poi_on_map)
10584 {
10585 // System.out.println("POI:2");
10586 on_ = 60;
10587 off_ = 59;
10588 }
10589
10590 // toggle the normal POI layers (to avoid double POIs)
10591 Message msg = new Message();
10592 Bundle b = new Bundle();
10593 b.putInt("Callback", on_);
10594 b.putString("s", "POI Symbols");
10595 msg.setData(b);
10596 NavitGraphics.callback_handler.sendMessage(msg);
10597
10598 msg = new Message();
10599 b = new Bundle();
10600 b.putInt("Callback", on_);
10601 b.putString("s", "POI Labels");
10602 msg.setData(b);
10603 NavitGraphics.callback_handler.sendMessage(msg);
10604
10605 // toggle full POI icons on/off
10606 msg = new Message();
10607 b = new Bundle();
10608 b.putInt("Callback", off_);
10609 b.putString("s", "Android-POI-Icons-full");
10610 msg.setData(b);
10611 NavitGraphics.callback_handler.sendMessage(msg);
10612
10613 msg = new Message();
10614 b = new Bundle();
10615 b.putInt("Callback", off_);
10616 b.putString("s", "Android-POI-Labels-full");
10617 msg.setData(b);
10618 NavitGraphics.callback_handler.sendMessage(msg);
10619
10620 // draw_map();
10621 }
10622
10623 private static void activatePrefs(int dummy)
10624 {
10625
10626 need_recalc_route = false; // do we need to recalc the route?
10627
10628 // call some functions to activate the new settings
10629 if (p.PREF_follow_gps)
10630 {
10631 Navit.follow_current = Navit.follow_on;
10632 }
10633 else
10634 {
10635 Navit.follow_current = Navit.follow_off;
10636 }
10637
10638 if (p.PREF_use_fast_provider)
10639 {
10640 NavitVehicle.turn_on_fast_provider();
10641 }
10642 else
10643 {
10644 NavitVehicle.turn_off_fast_provider();
10645 }
10646
10647 if (p.PREF_show_sat_status)
10648 {
10649 NavitVehicle.turn_on_sat_status();
10650 }
10651 else
10652 {
10653 // status always on !
10654 //
10655 // NavitVehicle.turn_off_sat_status();
10656 NavitVehicle.turn_on_sat_status();
10657 }
10658
10659 if (p.PREF_show_status_bar)
10660 {
10661 show_status_bar_wrapper();
10662 }
10663 else
10664 {
10665 hide_status_bar_wrapper();
10666 }
10667
10668 if (p.PREF_allow_gui_internal)
10669 {
10670 Message msg = new Message();
10671 Bundle b = new Bundle();
10672 b.putInt("Callback", 10);
10673 msg.setData(b);
10674 try
10675 {
10676 NavitGraphics.callback_handler.sendMessage(msg);
10677 }
10678 catch (Exception e)
10679 {
10680 }
10681 }
10682 else
10683 {
10684 Message msg = new Message();
10685 Bundle b = new Bundle();
10686 b.putInt("Callback", 9);
10687 msg.setData(b);
10688 try
10689 {
10690 NavitGraphics.callback_handler.sendMessage(msg);
10691 }
10692 catch (Exception e)
10693 {
10694 }
10695 }
10696
10697 if (p.PREF_use_compass_heading_base)
10698 {
10699 // turn on compass
10700 msg_to_msg_handler(new Bundle(), 12);
10701 Message msg = new Message();
10702 Bundle b = new Bundle();
10703 b.putInt("Callback", 11);
10704 msg.setData(b);
10705 try
10706 {
10707 NavitGraphics.callback_handler.sendMessage(msg);
10708 }
10709 catch (Exception e)
10710 {
10711 }
10712 }
10713 else
10714 {
10715 // turn off compass
10716 msg_to_msg_handler(new Bundle(), 13);
10717 Message msg = new Message();
10718 Bundle b = new Bundle();
10719 b.putInt("Callback", 12);
10720 msg.setData(b);
10721 try
10722 {
10723 NavitGraphics.callback_handler.sendMessage(msg);
10724 }
10725 catch (Exception e)
10726 {
10727 }
10728 }
10729
10730 if (p.PREF_show_real_gps_pos == 1)
10731 {
10732 // show real gps pos
10733 Message msg = new Message();
10734 Bundle b = new Bundle();
10735 b.putInt("Callback", 111);
10736 b.putString("s", "1");
10737 msg.setData(b);
10738 try
10739 {
10740 NavitGraphics.callback_handler.sendMessage(msg);
10741 }
10742 catch (Exception e)
10743 {
10744 }
10745 }
10746 else
10747 {
10748 Message msg = new Message();
10749 Bundle b = new Bundle();
10750 b.putInt("Callback", 111);
10751 b.putString("s", "0");
10752 msg.setData(b);
10753 try
10754 {
10755 NavitGraphics.callback_handler.sendMessage(msg);
10756 }
10757 catch (Exception e)
10758 {
10759 }
10760 }
10761
10762 // search radius for housenumbers near streets -----------------
10763 Message msg43 = new Message();
10764 Bundle b43 = new Bundle();
10765 b43.putInt("Callback", 89);
10766 b43.putString("s", "1500");
10767 msg43.setData(b43);
10768 try
10769 {
10770 NavitGraphics.callback_handler.sendMessage(msg43);
10771 }
10772 catch (Exception e)
10773 {
10774 }
10775 // search radius for housenumbers near streets -----------------
10776
10777 // set routing profile -----------------
10778 if (Navit_Largemap_DonateVersion_Installed == true)
10779 {
10780 Message msg43a = new Message();
10781 Bundle b43a = new Bundle();
10782 b43a.putInt("Callback", 90);
10783 b43a.putString("s", p.PREF_routing_profile); // set routing profile
10784 msg43a.setData(b43a);
10785 try
10786 {
10787 NavitGraphics.callback_handler.sendMessage(msg43a);
10788 }
10789 catch (Exception e)
10790 {
10791 }
10792
10793 // need_recalc_route = true;
10794 }
10795 // set routing profile -----------------
10796
10797 Message msg99a = new Message();
10798 Bundle b99a = new Bundle();
10799 b99a.putInt("Callback", 98);
10800 // System.out.println("tracking_connected_pref=" + PREF_tracking_connected_pref);
10801 b99a.putString("s", "" + p.PREF_tracking_connected_pref); // set routing profile
10802 msg99a.setData(b99a);
10803 try
10804 {
10805 NavitGraphics.callback_handler.sendMessage(msg99a);
10806 }
10807 catch (Exception e)
10808 {
10809 }
10810
10811 msg99a = new Message();
10812 b99a = new Bundle();
10813 b99a.putInt("Callback", 99);
10814 // System.out.println("tracking_angle_pref=" + PREF_tracking_angle_pref);
10815 b99a.putString("s", "" + p.PREF_tracking_angle_pref); // set routing profile
10816 msg99a.setData(b99a);
10817 try
10818 {
10819 NavitGraphics.callback_handler.sendMessage(msg99a);
10820 }
10821 catch (Exception e)
10822 {
10823 }
10824
10825 // change road profile -----------------
10826 if (Navit_Largemap_DonateVersion_Installed == true)
10827 {
10828 if (p.PREF_routing_profile.equals("bike-normal"))
10829 {
10830 Message msg43b = new Message();
10831 Bundle b43b = new Bundle();
10832 b43b.putInt("Callback", 91);
10833 System.out.println("road_priority_001=" + p.PREF_road_priority_001);
10834 b43b.putString("s", "" + p.PREF_road_priority_001); // set routing profile
10835 msg43b.setData(b43b);
10836 try
10837 {
10838 NavitGraphics.callback_handler.sendMessage(msg43b);
10839 }
10840 catch (Exception e)
10841 {
10842 }
10843
10844 msg43b = new Message();
10845 b43b = new Bundle();
10846 b43b.putInt("Callback", 92);
10847 System.out.println("road_priority_002=" + p.PREF_road_priority_002);
10848 b43b.putString("s", "" + p.PREF_road_priority_002); // set routing profile
10849 msg43b.setData(b43b);
10850 try
10851 {
10852 NavitGraphics.callback_handler.sendMessage(msg43b);
10853 }
10854 catch (Exception e)
10855 {
10856 }
10857
10858 msg43b = new Message();
10859 b43b = new Bundle();
10860 b43b.putInt("Callback", 93);
10861 System.out.println("road_priority_003=" + p.PREF_road_priority_003);
10862 b43b.putString("s", "" + p.PREF_road_priority_003); // set routing profile
10863 msg43b.setData(b43b);
10864 try
10865 {
10866 NavitGraphics.callback_handler.sendMessage(msg43b);
10867 }
10868 catch (Exception e)
10869 {
10870 }
10871
10872 msg43b = new Message();
10873 b43b = new Bundle();
10874 b43b.putInt("Callback", 94);
10875 System.out.println("road_priority_004=" + p.PREF_road_priority_004);
10876 b43b.putString("s", "" + p.PREF_road_priority_004); // set routing profile
10877 msg43b.setData(b43b);
10878 try
10879 {
10880 NavitGraphics.callback_handler.sendMessage(msg43b);
10881 }
10882 catch (Exception e)
10883 {
10884 }
10885
10886 // switch off layers --------------------
10887 msg43b = new Message();
10888 b43b = new Bundle();
10889 b43b.putInt("Callback", 60);
10890 b43b.putString("s", "POI traffic lights");
10891 msg43b.setData(b43b);
10892 try
10893 {
10894 NavitGraphics.callback_handler.sendMessage(msg43b);
10895 }
10896 catch (Exception e)
10897 {
10898 }
10899 // switch off layers --------------------
10900
10901 // switch ON layers --------------------
10902 msg43b = new Message();
10903 b43b = new Bundle();
10904 b43b.putInt("Callback", 59);
10905 b43b.putString("s", "POI bicycle");
10906 msg43b.setData(b43b);
10907 try
10908 {
10909 NavitGraphics.callback_handler.sendMessage(msg43b);
10910 }
10911 catch (Exception e)
10912 {
10913 }
10914 // switch ON layers --------------------
10915
10916 }
10917 else
10918 {
10919 // switch off layers --------------------
10920 Message msg43b = new Message();
10921 Bundle b43b = new Bundle();
10922 b43b.putInt("Callback", 60);
10923 b43b.putString("s", "POI bicycle");
10924 msg43b.setData(b43b);
10925 try
10926 {
10927 NavitGraphics.callback_handler.sendMessage(msg43b);
10928 }
10929 catch (Exception e)
10930 {
10931 }
10932 // switch off layers --------------------
10933
10934 // switch ON layers --------------------
10935 msg43b = new Message();
10936 b43b = new Bundle();
10937 b43b.putInt("Callback", 59);
10938 b43b.putString("s", "POI traffic lights");
10939 msg43b.setData(b43b);
10940 try
10941 {
10942 NavitGraphics.callback_handler.sendMessage(msg43b);
10943 }
10944 catch (Exception e)
10945 {
10946 }
10947 // switch ON layers --------------------
10948 }
10949 }
10950 // change road profile -----------------
10951
10952 // -- debug -- change some prio weights --
10953 // if ((!p.PREF_routing_profile.equals("bike-normal")) && (!p.PREF_routing_profile.equals("bike-no-oneway")) && (!p.PREF_routing_profile.equals("bike-avoid-roads")))
10954 // {
10955 // Message msg93 = new Message();
10956 // Bundle b93 = new Bundle();
10957 // b93.putInt("Callback", 110);
10958 // b93.putString("s", "street_1_city#route_prio_weight:" + p.PREF_road_prio_weight_street_1_city);
10959 // msg93.setData(b93);
10960 // try
10961 // {
10962 // NavitGraphics.callback_handler.sendMessage(msg93);
10963 // }
10964 // catch (Exception e)
10965 // {
10966 // }
10967 //
10968 // if (p_old.PREF_road_prio_weight_street_1_city != p.PREF_road_prio_weight_street_1_city)
10969 // {
10970 // need_recalc_route = true;
10971 // }
10972 // }
10973 // -- debug -- change some prio weights --
10974
10975 if (NavitGraphics.navit_route_status == 0)
10976 {
10977 if (p.PREF_c_linedrawing)
10978 {
10979 Message msg = new Message();
10980 Bundle b = new Bundle();
10981 b.putInt("Callback", 85);
10982 b.putString("s", "1");
10983 msg.setData(b);
10984 try
10985 {
10986 NavitGraphics.callback_handler.sendMessage(msg);
10987 }
10988 catch (Exception e)
10989 {
10990 }
10991 }
10992 else
10993 {
10994 Message msg = new Message();
10995 Bundle b = new Bundle();
10996 b.putInt("Callback", 85);
10997 b.putString("s", "0");
10998 msg.setData(b);
10999 try
11000 {
11001 NavitGraphics.callback_handler.sendMessage(msg);
11002 }
11003 catch (Exception e)
11004 {
11005 }
11006 }
11007 }
11008
11009 Message msg33 = new Message();
11010 Bundle b33 = new Bundle();
11011 b33.putInt("Callback", 103);
11012 if (p.PREF_show_vehicle_in_center)
11013 {
11014 b33.putString("s", "0");
11015 }
11016 else
11017 {
11018 b33.putString("s", "" + NavitGraphics.lower_than_center_percent);
11019 }
11020 msg33.setData(b33);
11021 try
11022 {
11023 NavitGraphics.callback_handler.sendMessage(msg33);
11024 }
11025 catch (Exception e88)
11026 {
11027 }
11028
11029 if (p.PREF_use_imperial)
11030 {
11031 Message msg = new Message();
11032 Bundle b = new Bundle();
11033 b.putInt("Callback", 16);
11034 msg.setData(b);
11035 try
11036 {
11037 NavitGraphics.callback_handler.sendMessage(msg);
11038 }
11039 catch (Exception e)
11040 {
11041 }
11042 }
11043 else
11044 {
11045 Message msg = new Message();
11046 Bundle b = new Bundle();
11047 b.putInt("Callback", 15);
11048 msg.setData(b);
11049 try
11050 {
11051 NavitGraphics.callback_handler.sendMessage(msg);
11052 }
11053 catch (Exception e)
11054 {
11055 }
11056 }
11057
11058 if (p.PREF_show_debug_messages)
11059 {
11060 Message msg = new Message();
11061 Bundle b = new Bundle();
11062 b.putInt("Callback", 24);
11063 msg.setData(b);
11064 try
11065 {
11066 NavitGraphics.callback_handler.sendMessage(msg);
11067 }
11068 catch (Exception e)
11069 {
11070 }
11071 }
11072 else
11073 {
11074 Message msg = new Message();
11075 Bundle b = new Bundle();
11076 b.putInt("Callback", 25);
11077 msg.setData(b);
11078 try
11079 {
11080 NavitGraphics.callback_handler.sendMessage(msg);
11081 }
11082 catch (Exception e)
11083 {
11084 }
11085 }
11086
11087 // if (PREF_show_3d_map)
11088 // {
11089 // Message msg = new Message();
11090 // Bundle b = new Bundle();
11091 // b.putInt("Callback", 31);
11092 // msg.setData(b);
11093 // try
11094 // {
11095 // N_NavitGraphics.callback_handler.sendMessage(msg);
11096 // }
11097 // catch (Exception e)
11098 // {
11099 // }
11100 // }
11101 // else
11102 // {
11103 // Message msg = new Message();
11104 // Bundle b = new Bundle();
11105 // b.putInt("Callback", 30);
11106 // msg.setData(b);
11107 // try
11108 // {
11109 // N_NavitGraphics.callback_handler.sendMessage(msg);
11110 // }
11111 // catch (Exception e)
11112 // {
11113 // }
11114 // }
11115
11116 if (p.PREF_use_lock_on_roads)
11117 {
11118 Message msg = new Message();
11119 Bundle b = new Bundle();
11120 b.putInt("Callback", 36);
11121 msg.setData(b);
11122 try
11123 {
11124 NavitGraphics.callback_handler.sendMessage(msg);
11125 }
11126 catch (Exception e)
11127 {
11128 }
11129 }
11130 else
11131 {
11132 Message msg = new Message();
11133 Bundle b = new Bundle();
11134 b.putInt("Callback", 37);
11135 msg.setData(b);
11136 try
11137 {
11138 NavitGraphics.callback_handler.sendMessage(msg);
11139 }
11140 catch (Exception e)
11141 {
11142 }
11143 }
11144
11145 // if (PREF_draw_polyline_circles)
11146 // {
11147 // Message msg = new Message();
11148 // Bundle b = new Bundle();
11149 // b.putString("s", "0");
11150 // b.putInt("Callback", 56);
11151 // msg.setData(b);
11152 // try
11153 // {
11154 // N_NavitGraphics.callback_handler.sendMessage(msg);
11155 // }
11156 // catch (Exception e)
11157 // {
11158 // }
11159 // }
11160 // else
11161 // {
11162 // Message msg = new Message();
11163 // Bundle b = new Bundle();
11164 // b.putString("s", "1");
11165 // b.putInt("Callback", 56);
11166 // msg.setData(b);
11167 // try
11168 // {
11169 // N_NavitGraphics.callback_handler.sendMessage(msg);
11170 // }
11171 // catch (Exception e)
11172 // {
11173 // }
11174 // }
11175
11176 if (p.PREF_use_route_highways)
11177 {
11178 Message msg = new Message();
11179 Bundle b = new Bundle();
11180 b.putInt("Callback", 42);
11181 msg.setData(b);
11182 try
11183 {
11184 NavitGraphics.callback_handler.sendMessage(msg);
11185 }
11186 catch (Exception e)
11187 {
11188 }
11189 }
11190 else
11191 {
11192 Message msg = new Message();
11193 Bundle b = new Bundle();
11194 b.putInt("Callback", 43);
11195 msg.setData(b);
11196 try
11197 {
11198 NavitGraphics.callback_handler.sendMessage(msg);
11199 }
11200 catch (Exception e)
11201 {
11202 }
11203 }
11204
11205 Message msg7 = new Message();
11206 Bundle b7 = new Bundle();
11207 b7.putInt("Callback", 57);
11208 b7.putString("s", "" + p.PREF_drawatorder);
11209 msg7.setData(b7);
11210 try
11211 {
11212 NavitGraphics.callback_handler.sendMessage(msg7);
11213 }
11214 catch (Exception e)
11215 {
11216 }
11217
11218 msg7 = new Message();
11219 b7 = new Bundle();
11220 b7.putInt("Callback", 58);
11221 b7.putString("s", p.PREF_streetsearch_r);
11222 msg7.setData(b7);
11223 try
11224 {
11225 NavitGraphics.callback_handler.sendMessage(msg7);
11226 }
11227 catch (Exception e)
11228 {
11229 }
11230
11231 if (p.PREF_speak_street_names)
11232 {
11233 Message msg = new Message();
11234 Bundle b = new Bundle();
11235 b.putInt("Callback", 54);
11236 msg.setData(b);
11237 try
11238 {
11239 NavitGraphics.callback_handler.sendMessage(msg);
11240 }
11241 catch (Exception e)
11242 {
11243 }
11244 }
11245 else
11246 {
11247 Message msg = new Message();
11248 Bundle b = new Bundle();
11249 b.putInt("Callback", 53);
11250 msg.setData(b);
11251 try
11252 {
11253 NavitGraphics.callback_handler.sendMessage(msg);
11254 }
11255 catch (Exception e)
11256 {
11257 }
11258
11259 }
11260
11261 try
11262 {
11263 NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[p.PREF_cancel_map_drawing_timeout];
11264 NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[p.PREF_cancel_map_drawing_timeout];
11265 NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[p.PREF_cancel_map_drawing_timeout];
11266 }
11267 catch (Exception e)
11268 {
11269
11270 }
11271
11272 // route variant
11273 Message msg67 = new Message();
11274 Bundle b67 = new Bundle();
11275 // turn off 1
11276 b67.putInt("Callback", 60);
11277 b67.putString("s", "route_001");
11278 msg67.setData(b67);
11279
11280 try
11281 {
11282 NavitGraphics.callback_handler.sendMessage(msg67);
11283 }
11284 catch (Exception e)
11285 {
11286 }
11287 // turn off 2
11288 msg67 = new Message();
11289 b67 = new Bundle();
11290 b67.putInt("Callback", 60);
11291 b67.putString("s", "route_002");
11292 msg67.setData(b67);
11293 try
11294 {
11295 NavitGraphics.callback_handler.sendMessage(msg67);
11296 }
11297 catch (Exception e)
11298 {
11299 }
11300 // turn off 3
11301 msg67 = new Message();
11302 b67 = new Bundle();
11303 b67.putInt("Callback", 60);
11304 b67.putString("s", "route_003");
11305 msg67.setData(b67);
11306 try
11307 {
11308 NavitGraphics.callback_handler.sendMessage(msg67);
11309 }
11310 catch (Exception e)
11311 {
11312 }
11313
11314 // turn on the wanted route style
11315 msg67 = new Message();
11316 b67 = new Bundle();
11317 b67.putInt("Callback", 59);
11318 b67.putString("s", "route_00" + p.PREF_route_style);
11319 msg67.setData(b67);
11320 try
11321 {
11322 NavitGraphics.callback_handler.sendMessage(msg67);
11323 }
11324 catch (Exception e)
11325 {
11326 }
11327 // route variant
11328
11329 // show route rectanlges -----
11330 if (p.PREF_show_route_rects)
11331 {
11332 msg67 = new Message();
11333 b67 = new Bundle();
11334 b67.putInt("Callback", 76);
11335 msg67.setData(b67);
11336 try
11337 {
11338 NavitGraphics.callback_handler.sendMessage(msg67);
11339 }
11340 catch (Exception e)
11341 {
11342 }
11343 }
11344 else
11345 {
11346 msg67 = new Message();
11347 b67 = new Bundle();
11348 b67.putInt("Callback", 77);
11349 msg67.setData(b67);
11350 try
11351 {
11352 NavitGraphics.callback_handler.sendMessage(msg67);
11353 }
11354 catch (Exception e)
11355 {
11356 }
11357 }
11358 // show route rectanlges -----
11359
11360 // show route multipolygons -----
11361 if (p.PREF_show_multipolygons)
11362 {
11363 msg67 = new Message();
11364 b67 = new Bundle();
11365 b67.putInt("Callback", 66);
11366 msg67.setData(b67);
11367 try
11368 {
11369 NavitGraphics.callback_handler.sendMessage(msg67);
11370 }
11371 catch (Exception e)
11372 {
11373 }
11374 }
11375 else
11376 {
11377 msg67 = new Message();
11378 b67 = new Bundle();
11379 b67.putInt("Callback", 67);
11380 msg67.setData(b67);
11381 try
11382 {
11383 NavitGraphics.callback_handler.sendMessage(msg67);
11384 }
11385 catch (Exception e)
11386 {
11387 }
11388 }
11389 // show route multipolygons -----
11390
11391 // traffic lights delay ----
11392 msg67 = new Message();
11393 b67 = new Bundle();
11394 b67.putInt("Callback", 79);
11395 //System.out.println("traffic lights delay:" + PREF_trafficlights_delay);
11396 // (PREF_trafficlights_delay / 10) seconds delay for each traffic light
11397 b67.putString("s", p.PREF_trafficlights_delay); // (delay in 1/10 of a second)
11398 msg67.setData(b67);
11399 try
11400 {
11401 NavitGraphics.callback_handler.sendMessage(msg67);
11402 }
11403 catch (Exception e)
11404 {
11405 }
11406 // traffic lights delay ----
11407
11408 // avoid sharp turns ----
11409 msg67 = new Message();
11410 b67 = new Bundle();
11411 b67.putInt("Callback", 86);
11412 b67.putString("s", p.PREF_avoid_sharp_turns);
11413 msg67.setData(b67);
11414 try
11415 {
11416 NavitGraphics.callback_handler.sendMessage(msg67);
11417 }
11418 catch (Exception e)
11419 {
11420 }
11421
11422 msg67 = new Message();
11423 b67 = new Bundle();
11424 b67.putInt("Callback", 87);
11425 b67.putString("s", "47"); // **DANGER** sharp turn max angle hardcoded here!! **DANGER**
11426 msg67.setData(b67);
11427 try
11428 {
11429 NavitGraphics.callback_handler.sendMessage(msg67);
11430 }
11431 catch (Exception e)
11432 {
11433 }
11434
11435 msg67 = new Message();
11436 b67 = new Bundle();
11437 b67.putInt("Callback", 88);
11438 b67.putString("s", "6000");
11439 msg67.setData(b67);
11440 try
11441 {
11442 NavitGraphics.callback_handler.sendMessage(msg67);
11443 }
11444 catch (Exception e)
11445 {
11446 }
11447 // avoid sharp turns ----
11448
11449 // autozoom flag ----
11450 msg67 = new Message();
11451 b67 = new Bundle();
11452 b67.putInt("Callback", 80);
11453 if (p.PREF_autozoom_flag)
11454 {
11455 b67.putString("s", "1"); // (0 or 1)
11456 }
11457 else
11458 {
11459 b67.putString("s", "0"); // (0 or 1)
11460 }
11461 msg67.setData(b67);
11462 try
11463 {
11464 NavitGraphics.callback_handler.sendMessage(msg67);
11465 }
11466 catch (Exception e)
11467 {
11468
11469 }
11470 // autozoom flag ----
11471
11472 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed))
11473 {
11474 // use pref
11475 }
11476 else
11477 {
11478 p.PREF_roadspeed_warning = false;
11479 }
11480
11481 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed))
11482 {
11483 // use pref
11484 }
11485 else
11486 {
11487 p.PREF_lane_assist = false;
11488 }
11489
11490 if (p.PREF_streets_only)
11491 {
11492 // ----------------------- streets only pref -------------------
11493 // 59 -> enable
11494 // 60 -> disable
11495 Message msg31 = new Message();
11496 Bundle b31 = new Bundle();
11497 b31.putInt("Callback", 60);
11498 b31.putString("s", "polygons001");
11499 msg31.setData(b31);
11500 NavitGraphics.callback_handler.sendMessage(msg31);
11501
11502 msg31 = new Message();
11503 b31 = new Bundle();
11504 b31.putInt("Callback", 60);
11505 b31.putString("s", "polygons");
11506 msg31.setData(b31);
11507 NavitGraphics.callback_handler.sendMessage(msg31);
11508
11509 msg31 = new Message();
11510 b31 = new Bundle();
11511 b31.putInt("Callback", 60);
11512 b31.putString("s", "POI Symbols");
11513 msg31.setData(b31);
11514 NavitGraphics.callback_handler.sendMessage(msg31);
11515
11516 msg31 = new Message();
11517 b31 = new Bundle();
11518 b31.putInt("Callback", 60);
11519 b31.putString("s", "POI Labels");
11520 msg31.setData(b31);
11521 NavitGraphics.callback_handler.sendMessage(msg31);
11522
11523 msg31 = new Message();
11524 b31 = new Bundle();
11525 b31.putInt("Callback", 60);
11526 b31.putString("s", "Android-POI-Icons-full");
11527 msg31.setData(b31);
11528 NavitGraphics.callback_handler.sendMessage(msg31);
11529
11530 msg31 = new Message();
11531 b31 = new Bundle();
11532 b31.putInt("Callback", 60);
11533 b31.putString("s", "Android-POI-Labels-full");
11534 msg31.setData(b31);
11535 NavitGraphics.callback_handler.sendMessage(msg31);
11536
11537 msg31 = new Message();
11538 b31 = new Bundle();
11539 b31.putInt("Callback", 60);
11540 b31.putString("s", "streets");
11541 msg31.setData(b31);
11542 NavitGraphics.callback_handler.sendMessage(msg31);
11543
11544 msg31 = new Message();
11545 b31 = new Bundle();
11546 b31.putInt("Callback", 60);
11547 b31.putString("s", "streets_1");
11548 msg31.setData(b31);
11549 NavitGraphics.callback_handler.sendMessage(msg31);
11550
11551 msg31 = new Message();
11552 b31 = new Bundle();
11553 b31.putInt("Callback", 60);
11554 b31.putString("s", "streets_2");
11555 msg31.setData(b31);
11556 NavitGraphics.callback_handler.sendMessage(msg31);
11557
11558 msg31 = new Message();
11559 b31 = new Bundle();
11560 b31.putInt("Callback", 59);
11561 b31.putString("s", "streets_STR_ONLY");
11562 msg31.setData(b31);
11563 NavitGraphics.callback_handler.sendMessage(msg31);
11564
11565 msg31 = new Message();
11566 b31 = new Bundle();
11567 b31.putInt("Callback", 59);
11568 b31.putString("s", "streets_1_STR_ONLY");
11569 msg31.setData(b31);
11570 NavitGraphics.callback_handler.sendMessage(msg31);
11571
11572 msg31 = new Message();
11573 b31 = new Bundle();
11574 b31.putInt("Callback", 59);
11575 b31.putString("s", "streets_2_STR_ONLY");
11576 msg31.setData(b31);
11577 NavitGraphics.callback_handler.sendMessage(msg31);
11578 // ----------------------- streets only pref -------------------
11579 }
11580 else
11581 {
11582 // ----------------------- streets only pref -------------------
11583 // 59 -> enable
11584 // 60 -> disable
11585 Message msg31 = new Message();
11586 Bundle b31 = new Bundle();
11587 b31.putInt("Callback", 59);
11588 b31.putString("s", "polygons001");
11589 msg31.setData(b31);
11590 NavitGraphics.callback_handler.sendMessage(msg31);
11591
11592 msg31 = new Message();
11593 b31 = new Bundle();
11594 b31.putInt("Callback", 59);
11595 b31.putString("s", "polygons");
11596 msg31.setData(b31);
11597 NavitGraphics.callback_handler.sendMessage(msg31);
11598
11599 msg31 = new Message();
11600 b31 = new Bundle();
11601 b31.putInt("Callback", 59);
11602 b31.putString("s", "POI Symbols");
11603 msg31.setData(b31);
11604 NavitGraphics.callback_handler.sendMessage(msg31);
11605
11606 msg31 = new Message();
11607 b31 = new Bundle();
11608 b31.putInt("Callback", 59);
11609 b31.putString("s", "POI Labels");
11610 msg31.setData(b31);
11611 NavitGraphics.callback_handler.sendMessage(msg31);
11612
11613 msg31 = new Message();
11614 b31 = new Bundle();
11615 b31.putInt("Callback", 60);
11616 b31.putString("s", "Android-POI-Icons-full");
11617 msg31.setData(b31);
11618 NavitGraphics.callback_handler.sendMessage(msg31);
11619
11620 msg31 = new Message();
11621 b31 = new Bundle();
11622 b31.putInt("Callback", 60);
11623 b31.putString("s", "Android-POI-Labels-full");
11624 msg31.setData(b31);
11625 NavitGraphics.callback_handler.sendMessage(msg31);
11626
11627 msg31 = new Message();
11628 b31 = new Bundle();
11629 b31.putInt("Callback", 59);
11630 b31.putString("s", "streets");
11631 msg31.setData(b31);
11632 NavitGraphics.callback_handler.sendMessage(msg31);
11633
11634 msg31 = new Message();
11635 b31 = new Bundle();
11636 b31.putInt("Callback", 59);
11637 b31.putString("s", "streets_1");
11638 msg31.setData(b31);
11639 NavitGraphics.callback_handler.sendMessage(msg31);
11640
11641 msg31 = new Message();
11642 b31 = new Bundle();
11643 b31.putInt("Callback", 59);
11644 b31.putString("s", "streets_2");
11645 msg31.setData(b31);
11646 NavitGraphics.callback_handler.sendMessage(msg31);
11647
11648 msg31 = new Message();
11649 b31 = new Bundle();
11650 b31.putInt("Callback", 60);
11651 b31.putString("s", "streets_STR_ONLY");
11652 msg31.setData(b31);
11653 NavitGraphics.callback_handler.sendMessage(msg31);
11654
11655 msg31 = new Message();
11656 b31 = new Bundle();
11657 b31.putInt("Callback", 60);
11658 b31.putString("s", "streets_1_STR_ONLY");
11659 msg31.setData(b31);
11660 NavitGraphics.callback_handler.sendMessage(msg31);
11661
11662 msg31 = new Message();
11663 b31 = new Bundle();
11664 b31.putInt("Callback", 60);
11665 b31.putString("s", "streets_2_STR_ONLY");
11666 msg31.setData(b31);
11667 NavitGraphics.callback_handler.sendMessage(msg31);
11668 // ----------------------- streets only pref -------------------
11669 }
11670
11671 // ---------- set traffic factor for road speeds ------------
11672 try
11673 {
11674 Message msg_ss1 = new Message();
11675 Bundle b_ss1 = new Bundle();
11676 b_ss1.putInt("Callback", 106);
11677 b_ss1.putString("s", Integer.toString(p.PREF_traffic_speed_factor));
11678 msg_ss1.setData(b_ss1);
11679 NavitGraphics.callback_handler.sendMessage(msg_ss1);
11680 }
11681 catch (Exception e)
11682 {
11683 }
11684 // ---------- set traffic factor for road speeds ------------
11685
11686 // ------- PREF_show_poi_on_map ---------------------------------
11687 set_poi_layers();
11688 // ------- PREF_show_poi_on_map ---------------------------------
11689
11690 // set vars for mapdir change (only really takes effect after restart!)
11691 getPrefs_mapdir();
11692
11693 if (need_recalc_route)
11694 {
11695 recalculate_route();
11696 need_recalc_route = false;
11697 }
11698
11699 }
11700
11701 @SuppressLint("NewApi")
11702 private static void getPrefs_mapdir()
11703 {
11704 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
11705
11706 // Get the xml/preferences.xml preferences
11707 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
11708 String default_sdcard_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/zanavi/maps/";
11709 String default_sdcard_dir_1 = default_sdcard_dir;
11710 System.out.println("DataStorageDir[s1]=" + default_sdcard_dir_1);
11711
11712 // check for Android KitKat 4.4 ---------------
11713 try
11714 {
11715 if (Integer.valueOf(android.os.Build.VERSION.SDK) > 18)
11716 {
11717 // use app private dir
11718 default_sdcard_dir = Navit.getBaseContext_.getExternalFilesDir(null).getAbsolutePath();
11719 }
11720 }
11721 catch (Exception e)
11722 {
11723 }
11724 // check for Android KitKat 4.4 ---------------
11725
11726 try
11727 {
11728 NavitDataStorageDirs = android.support.v4.content.ContextCompat.getExternalFilesDirs(Navit.getBaseContext_, null);
11729
11730 if (NavitDataStorageDirs.length > 0)
11731 {
11732 // use new method
11733 default_sdcard_dir = NavitDataStorageDirs[0].getAbsolutePath() + "/zanavi/maps/";
11734 System.out.println("DataStorageDir count=" + NavitDataStorageDirs.length);
11735
11736 for (int jj2 = 0; jj2 < NavitDataStorageDirs.length; jj2++)
11737 {
11738 if (NavitDataStorageDirs[jj2] != null)
11739 {
11740 System.out.println("DataStorageDir[" + jj2 + "]=" + NavitDataStorageDirs[jj2].getAbsolutePath() + "/zanavi/maps/");
11741 }
11742 }
11743 }
11744
11745 if (NavitDataStorageDirs.length == 1)
11746 {
11747 File tf = null;
11748 File[] NavitDataStorageDirs_ = new File[NavitDataStorageDirs.length + 1];
11749
11750 try
11751 {
11752 Map<String, File> externalLocations = ExternalStorage.getAllStorageLocations();
11753 // String sdCard__ = externalLocations.get(ExternalStorage.SD_CARD).getAbsolutePath();
11754 String externalSdCard__ = externalLocations.get(ExternalStorage.EXTERNAL_SD_CARD).getAbsolutePath();
11755 // System.out.println("DataStorageDir[sd]=" + sdCard__);
11756 System.out.println("DataStorageDir[external sd]=" + externalSdCard__);
11757
11758 for (int jj2 = 0; jj2 < NavitDataStorageDirs.length; jj2++)
11759 {
11760 if (NavitDataStorageDirs[jj2] == null)
11761 {
11762 NavitDataStorageDirs_[jj2] = null;
11763 }
11764 else
11765 {
11766 NavitDataStorageDirs_[jj2] = new File(NavitDataStorageDirs[jj2].getAbsolutePath() + "/zanavi/maps/");
11767 }
11768 }
11769
11770 tf = new File(externalLocations.get(ExternalStorage.EXTERNAL_SD_CARD).getAbsolutePath() + "/Android/data/com.zoffcc.applications.zanavi/files" + "/zanavi/maps/");
11771 }
11772 catch (Exception e)
11773 {
11774 tf = null;
11775 }
11776
11777 if (tf != null)
11778 {
11779 NavitDataStorageDirs_[NavitDataStorageDirs.length] = tf;
11780 NavitDataStorageDirs = null;
11781 NavitDataStorageDirs = NavitDataStorageDirs_;
11782 }
11783 }
11784
11785 }
11786 catch (Exception e)
11787 {
11788 System.out.println("DataStorageDir Ex002");
11789 e.printStackTrace();
11790 }
11791
11792 //Log.e("Navit", "old sdcard dir=" + NavitDataDirectory_Maps);
11793 //Log.e("Navit", "default sdcard dir=" + default_sdcard_dir);
11794 NavitDataDirectory_Maps = prefs.getString("map_directory", default_sdcard_dir + "/zanavi/maps/");
11795 String Navit_storage_directory_select = prefs.getString("storage_directory", "-1");
11796 int Navit_storage_directory_select_i = 0;
11797 try
11798 {
11799 Navit_storage_directory_select_i = Integer.parseInt(Navit_storage_directory_select);
11800 }
11801 catch (Exception e)
11802 {
11803
11804 }
11805 System.out.println("DataStorageDir[sel 1]=" + NavitDataDirectory_Maps);
11806 System.out.println("DataStorageDir[sel 2]=" + Navit_storage_directory_select);
11807
11808 if (Navit_storage_directory_select_i > 0)
11809 {
11810 NavitDataDirectory_Maps = NavitDataStorageDirs[Navit_storage_directory_select_i - 1].getAbsolutePath();
11811 }
11812 System.out.println("DataStorageDir[*in use*]=" + NavitDataDirectory_Maps);
11813
11814 // Navit_storage_directory_select:
11815 // -1 --> first run -> select best dir for user
11816 // 0 --> use custom directory
11817 // 1..n --> select default dir on SD Card number 1..n
11818
11819 // ** DEBUG ** set dir manually ** // NavitDataDirectory_Maps = default_sdcard_dir + "/zanavi/maps/";
11820 // ** DEBUG ** NavitDataDirectory_Maps = prefs.getString("navit_mapsdir", "/sdcard" + "/zanavi/maps/");
11821 //Log.e("Navit", "new sdcard dir=" + NavitDataDirectory_Maps);
11822
11823 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
11824 }
11825
11826 static String sanity_check_maps_dir(String check_dir)
11827 {
11828 String ret = check_dir;
11829 ret = ret.replaceAll("\\n", ""); // newline -> ""
11830 ret = ret.replaceAll("\\r", ""); // return -> ""
11831 ret = ret.replaceAll("\\t", ""); // tab -> ""
11832 ret = ret.replaceAll(" ", ""); // space -> ""
11833 ret = ret.replaceAll("\"", ""); // \" -> ""
11834 ret = ret.replaceAll("'", ""); // \' -> ""
11835 ret = ret.replaceAll("\\\\", ""); // "\" -> ""
11836 if (!ret.endsWith("/"))
11837 {
11838 ret = ret + "/";
11839 }
11840 // System.out.println("sanity check:" + ret);
11841 return ret;
11842 }
11843
11844 private static void activatePrefs_mapdir(Boolean at_startup)
11845 {
11846 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
11847
11848 // activate the new directory
11849 NavitDataDirectory_Maps = sanity_check_maps_dir(NavitDataDirectory_Maps);
11850 MAP_FILENAME_PATH = NavitDataDirectory_Maps;
11851 MAPMD5_FILENAME_PATH = NavitDataDirectory_Maps + "/../md5/";
11852 CFG_FILENAME_PATH = NavitDataDirectory_Maps + "/../";
11853 NAVIT_DATA_DEBUG_DIR = CFG_FILENAME_PATH + "../debug/";
11854
11855 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11856 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11857 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11858 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11859 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11860 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11861 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11862 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11863 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
11864
11865 Handler h_temp = null;
11866 h_temp = NavitGraphics.callback_handler_s;
11867 //System.out.println("handler 1=" + h_temp.toString());
11868
11869 Message msg1 = new Message();
11870 Bundle b1 = new Bundle();
11871 b1.putInt("Callback", 47);
11872 b1.putString("s", MAP_FILENAME_PATH);
11873 msg1.setData(b1);
11874 h_temp.sendMessage(msg1);
11875
11876 if (!at_startup)
11877 {
11878 Message msg2 = new Message();
11879 Bundle b2 = new Bundle();
11880 b2.putInt("Callback", 18);
11881 msg2.setData(b2);
11882 h_temp.sendMessage(msg2);
11883 }
11884
11885 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
11886 }
11887
11888 private void getPrefs_theme()
11889 {
11890 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
11891 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
11892 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
11893 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
11894 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
11895 if (theme_tmp == 1)
11896 {
11897 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_LIGHT;
11898 }
11899 else
11900 {
11901 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
11902 }
11903
11904 }
11905
11906 private void getPrefs_theme_main()
11907 {
11908 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
11909 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
11910 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
11911 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
11912 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
11913 if (theme_tmp == 1)
11914 {
11915 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_LIGHT_M;
11916 }
11917 else
11918 {
11919 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
11920 }
11921
11922 }
11923
11924 private static void getPrefs_loc()
11925 {
11926 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
11927
11928 // Get the xml/preferences.xml preferences
11929 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
11930 p.PREF_navit_lang = prefs.getString("navit_lang", "*DEFAULT*");
11931 System.out.println("**** ***** **** pref lang=" + p.PREF_navit_lang);
11932
11933 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
11934 }
11935
11936 private static void activatePrefs_loc()
11937 {
11938 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
11939
11940 // creating locale
11941 if (!p.PREF_navit_lang.equals("*DEFAULT*"))
11942 {
11943 Locale locale2 = null;
11944 if (p.PREF_navit_lang.contains("_"))
11945 {
11946 String _lang = p.PREF_navit_lang.split("_", 2)[0];
11947 String _country = p.PREF_navit_lang.split("_", 2)[1];
11948 System.out.println("l=" + _lang + " c=" + _country);
11949 locale2 = new Locale(_lang, _country);
11950 }
11951 else
11952 {
11953 locale2 = new Locale(p.PREF_navit_lang);
11954 }
11955 Locale.setDefault(locale2);
11956 Configuration config2 = new Configuration();
11957 config2.locale = locale2;
11958 // updating locale
11959 getBaseContext_.getResources().updateConfiguration(config2, null);
11960 }
11961
11962 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
11963 }
11964
11965 private static void getPrefs_mapcache()
11966 {
11967 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
11968 try
11969 {
11970 p.PREF_mapcache = Integer.parseInt(prefs.getString("mapcache", "" + (10 * 1024)));
11971 }
11972 catch (Exception e)
11973 {
11974 e.printStackTrace();
11975 p.PREF_mapcache = 10 * 1024;
11976 }
11977 System.out.println("**** ***** **** pref mapcache=" + p.PREF_mapcache);
11978 }
11979
11980 private static void activatePrefs_mapcache()
11981 {
11982 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
11983
11984 Handler h_temp2 = null;
11985 h_temp2 = NavitGraphics.callback_handler_s;
11986 System.out.println("activatePrefs_mapcache " + NavitGraphics.callback_handler_s);
11987 Message msg7 = new Message();
11988 Bundle b7 = new Bundle();
11989 b7.putInt("Callback", 55);
11990 b7.putString("s", String.valueOf(p.PREF_mapcache * 1024));
11991 msg7.setData(b7);
11992 h_temp2.sendMessage(msg7);
11993
11994 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
11995 }
11996
11997 public native void NavitMain(Navit x, String lang, int version, String display_density_string, String n_datadir, String n_sharedir, Bitmap main_map_bitmap);
11998
11999 public native void NavitActivity(int activity);
12000
12001 /*
12002 * this is used to load the 'navit' native library on
12003 * application startup. The library has already been unpacked at
12004 * installation time by the package manager.
12005 */
12006 static
12007 {
12008 System.loadLibrary("navit");
12009 }
12010
12011 /*
12012 * Show a search activity with the string "search" filled in
12013 */
12014 private void executeSearch(String search)
12015 {
12016 Navit.use_index_search = Navit.allow_use_index_search();
12017 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
12018 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
12019 search_intent.putExtra("address_string", search);
12020 search_intent.putExtra("type", "offline");
12021 search_intent.putExtra("search_country_id", Navit_last_address_search_country_id);
12022 String pm_temp = "0";
12023 if (Navit_last_address_partial_match)
12024 {
12025 pm_temp = "1";
12026 }
12027 search_intent.putExtra("partial_match", pm_temp);
12028 this.startActivityForResult(search_intent, NavitAddressSearch_id_offline);
12029 }
12030
12031 private void share_location(String lat, String lon, String name, String subject_text, String time_at_destination, boolean is_dest)
12032 {
12033 Intent intent = new Intent(Intent.ACTION_SEND);
12034 intent.setType("text/plain");
12035 String url;
12036 final String map_zoomlevel = "18";
12037 // url = "" + lat + "," + lon + "\n" + name;
12038 url = "http://maps.google.com/?q=" + lat + "," + lon + "&z=" + map_zoomlevel + "\n\n" + name;
12039
12040 if (is_dest)
12041 {
12042 if (time_at_destination.compareTo("") != 0)
12043 {
12044 url = url + " " + time_at_destination;
12045 }
12046 }
12047
12048 intent.putExtra(Intent.EXTRA_TEXT, url);
12049 intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject_text);
12050 //Uri uri = Uri.parse("geo:0,0?z=16&q=" + lat + "," + lon);
12051 //intent.putExtra(Intent.EXTRA_STREAM, uri);
12052
12053 // shut down TTS ---------------
12054 // if (!Navit.is_navigating)
12055 // {
12056 // try
12057 // {
12058 // mTts.stop();
12059 // }
12060 // catch (Exception e)
12061 // {
12062 //
12063 // }
12064 //
12065 // try
12066 // {
12067 // mTts.shutdown();
12068 // }
12069 // catch (Exception e)
12070 // {
12071 //
12072 // }
12073 // }
12074 // shut down TTS ---------------
12075
12076 startActivityForResult(Intent.createChooser(intent, Navit.get_text("Share")), NavitAddressSearch_id_sharedest); // TRANS
12077 }
12078
12079 /*
12080 * open google maps at a given coordinate
12081 */
12082 private void googlemaps_show(String lat, String lon, String name)
12083 {
12084 // geo:latitude,longitude
12085 String url = null;
12086 Intent gmaps_intent = new Intent(Intent.ACTION_VIEW);
12087
12088 //url = "geo:" + lat + "," + lon + "?z=" + "16";
12089 //url = "geo:0,0?q=" + lat + "," + lon + " (" + name + ")";
12090 url = "geo:0,0?z=16&q=" + lat + "," + lon + " (" + name + ")";
12091
12092 gmaps_intent.setData(Uri.parse(url));
12093 this.startActivityForResult(gmaps_intent, NavitAddressSearch_id_gmaps);
12094 }
12095
12096 public void zoom_out_full()
12097 {
12098 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12099
12100 System.out.println("");
12101 System.out.println("*** Zoom out FULL ***");
12102 System.out.println("");
12103 Message msg = new Message();
12104 Bundle b = new Bundle();
12105 b.putInt("Callback", 8);
12106 msg.setData(b);
12107 NavitGraphics.callback_handler.sendMessage(msg);
12108
12109 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12110 }
12111
12112 static public void show_geo_on_screen_with_zoom_and_delay(float lat, float lon)
12113 {
12114 show_geo_on_screen_with_zoom_and_delay(lat, lon, 0);
12115 }
12116
12117 @SuppressLint("NewApi")
12118 static public void show_geo_on_screen_with_zoom_and_delay(final float lat, final float lon, final int millis_start_delay)
12119 {
12120 System.out.println("XSOM:010");
12121
12122 // if (api_version_int < 11)
12123 // {
12124 //
12125 // new AsyncTask<Void, Void, String>()
12126 // {
12127 // @Override
12128 // protected String doInBackground(Void... params)
12129 // {
12130 // System.out.println("XSOM:011");
12131 //
12132 // try
12133 // {
12134 // System.out.println("XSOM:001");
12135 // Thread.sleep((long) millis_start_delay);
12136 // Navit.show_geo_on_screen_no_draw(lat, lon);
12137 // System.out.println("XSOM:002");
12138 // Thread.sleep(100);
12139 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12140 // System.out.println("XSOM:004");
12141 // Thread.sleep(120);
12142 // Navit.draw_map();
12143 // System.out.println("XSOM:005");
12144 // }
12145 // catch (Exception e)
12146 // {
12147 // }
12148 //
12149 // return "";
12150 // }
12151 //
12152 // @Override
12153 // protected void onPostExecute(String msg)
12154 // {
12155 //
12156 // }
12157 // }.execute(null, null, null);
12158 //
12159 // }
12160 // else
12161 // {
12162 // new AsyncTask<Void, Void, String>()
12163 // {
12164 // @Override
12165 // protected String doInBackground(Void... params)
12166 // {
12167 // System.out.println("XSOM:011");
12168 //
12169 // try
12170 // {
12171 // System.out.println("XSOM:001");
12172 // Thread.sleep((long) millis_start_delay);
12173 // Navit.show_geo_on_screen_no_draw(lat, lon);
12174 // System.out.println("XSOM:002");
12175 // Thread.sleep(100);
12176 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12177 // System.out.println("XSOM:004");
12178 // Thread.sleep(120);
12179 // Navit.draw_map();
12180 // System.out.println("XSOM:005");
12181 // }
12182 // catch (Exception e)
12183 // {
12184 // }
12185 //
12186 // return "";
12187 // }
12188 //
12189 // @Override
12190 // protected void onPostExecute(String msg)
12191 // {
12192 //
12193 // }
12194 // }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
12195 //
12196 // }
12197
12198 final Thread temp_work_thread = new Thread()
12199 {
12200 @Override
12201 public void run()
12202 {
12203 try
12204 {
12205 Thread.sleep((long) millis_start_delay);
12206 Navit.show_geo_on_screen_no_draw(lat, lon);
12207 Thread.sleep(500);
12208 Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12209 Thread.sleep(120);
12210 Navit.draw_map();
12211 }
12212 catch (Exception e2)
12213 {
12214 e2.printStackTrace();
12215 }
12216 }
12217 };
12218 temp_work_thread.start();
12219 }
12220
12221 static public void show_geo_on_screen(float lat, float lng)
12222 {
12223 // this function sets screen center to "lat, lon", and just returns a dummy string!
12224 Navit.cwthr.CallbackGeoCalc2(2, 3, lat, lng);
12225 }
12226
12227 static public void show_geo_on_screen_no_draw(float lat, float lng)
12228 {
12229 // this function sets screen center to "lat, lon", and just returns a dummy string!
12230 Navit.cwthr.CallbackGeoCalc2(2, 15, lat, lng);
12231 }
12232
12233 public static void zoom_to_route()
12234 {
12235 try
12236 {
12237 //System.out.println("");
12238 //System.out.println("*** Zoom to ROUTE ***");
12239 //System.out.println("");
12240 Message msg = new Message();
12241 Bundle b = new Bundle();
12242 b.putInt("Callback", 17);
12243 msg.setData(b);
12244 NavitGraphics.callback_handler.sendMessage(msg);
12245
12246 set_map_position_to_screen_center();
12247 }
12248 catch (Exception e)
12249 {
12250 }
12251 }
12252
12253 static void set_map_position_to_screen_center()
12254 {
12255 try
12256 {
12257 Message msg = new Message();
12258 Bundle b = new Bundle();
12259 b.putInt("Callback", 51);
12260
12261 if (Navit.GFX_OVERSPILL)
12262 {
12263 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
12264 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
12265 }
12266 else
12267 {
12268 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
12269 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
12270 }
12271 msg.setData(b);
12272 NavitGraphics.callback_handler.sendMessage(msg);
12273 }
12274 catch (Exception e)
12275 {
12276 }
12277 }
12278
12279 public void turn_on_compass()
12280 {
12281 try
12282 {
12283 if (!p.PREF_use_compass_heading_fast)
12284
12285 {
12286 // Slower
12287 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL);
12288 }
12289 else
12290 {
12291 // FAST
12292 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI);
12293 }
12294 }
12295 catch (Exception e)
12296 {
12297 e.printStackTrace();
12298 }
12299 }
12300
12301 public void turn_off_compass()
12302 {
12303 try
12304 {
12305 sensorManager.unregisterListener(this);
12306 }
12307 catch (Exception e)
12308 {
12309 e.printStackTrace();
12310 }
12311 }
12312
12313 public void onSensorChanged(SensorEvent event)
12314 {
12315
12316 if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD)
12317 {
12318 // System.out.println("Sensor.TYPE_MAGNETIC_FIELD");
12319 return;
12320 }
12321
12322 if (event.sensor.getType() == Sensor.TYPE_ORIENTATION)
12323 {
12324 // System.out.println("Sensor.TYPE_ORIENTATION");
12325
12326 // compass
12327 float myAzimuth = event.values[0];
12328 // double myPitch = event.values[1];
12329 // double myRoll = event.values[2];
12330
12331 //String out = String.format("Azimuth: %.2f", myAzimuth);
12332 //System.out.println("compass: " + out);
12333 NavitVehicle.update_compass_heading(myAzimuth);
12334 }
12335 }
12336
12337 public void onAccuracyChanged(Sensor sensor, int accuracy)
12338 {
12339 // compass
12340 }
12341
12342 public void hide_status_bar()
12343 {
12344 if (!p.PREF_show_status_bar)
12345 {
12346 // Hide the Status Bar
12347 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN);
12348 }
12349 }
12350
12351 public void show_status_bar()
12352 {
12353 // Show the Status Bar
12354 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN);
12355 }
12356
12357 public void hide_title_bar()
12358 {
12359 // -- unsued !!!! --
12360 // -- unsued !!!! --
12361 // -- unsued !!!! --
12362
12363 // Hide the Title Bar - this works ONLY before setcontent in onCreate!!
12364 requestWindowFeature(Window.FEATURE_NO_TITLE);
12365 }
12366
12367 public void show_title_bar()
12368 {
12369 // -- unsued !!!! --
12370 // -- unsued !!!! --
12371 // -- unsued !!!! --
12372
12373 // Hide the Title Bar - this works ONLY before setcontent in onCreate!!
12374 // ?? requestWindowFeature(Window.);
12375 }
12376
12377 public static Boolean downloadGPSXtra(Context context)
12378 {
12379 Boolean ret = false;
12380 Boolean ret2 = false;
12381 try
12382 {
12383 LocationManager locationmanager2 = (LocationManager) context.getSystemService("location");
12384 Bundle bundle = new Bundle();
12385 //ret2 = locationmanager2.sendExtraCommand("gps", "delete_aiding_data", null);
12386 //ret = ret2;
12387 // System.out.println("ret0=" + ret);
12388 ret2 = locationmanager2.sendExtraCommand("gps", "force_xtra_injection", bundle);
12389 ret = ret2;
12390 //System.out.println("ret1=" + ret2);
12391 ret2 = locationmanager2.sendExtraCommand("gps", "force_time_injection", bundle);
12392 ret = ret || ret2;
12393 //System.out.println("ret2=" + ret2);
12394 }
12395 catch (Exception e)
12396 {
12397 //System.out.println("*XX*");
12398 e.printStackTrace();
12399 }
12400 return ret;
12401 }
12402
12403 static void remove_oldest_normal_point()
12404 {
12405 int i;
12406 for (i = 0; i < map_points.size(); i++)
12407 {
12408 Navit_Point_on_Map element_temp = map_points.get(i);
12409 if (element_temp.addon == null)
12410 {
12411 // its a normal (non home, non special item), so can remove it, and return.
12412 break;
12413 }
12414 }
12415 }
12416
12417 static int find_home_point()
12418 {
12419 int home_id = -1;
12420 int i;
12421
12422 for (i = 0; i < map_points.size(); i++)
12423 {
12424 Navit_Point_on_Map element_temp = map_points.get(i);
12425 if (element_temp.addon != null)
12426 {
12427 if (element_temp.addon.equals("1"))
12428 {
12429 // found home
12430 return i;
12431 }
12432 }
12433 }
12434 return home_id;
12435 }
12436
12437 static void readd_home_point()
12438 {
12439 try
12440 {
12441 int home_id = find_home_point();
12442 if (home_id != -1)
12443 {
12444 Navit_Point_on_Map element_old = map_points.get(home_id);
12445 map_points.remove(home_id);
12446 map_points.add(element_old);
12447 }
12448 }
12449 catch (Exception e)
12450 {
12451 }
12452 }
12453
12454 static void add_map_point(Navit_Point_on_Map element)
12455 {
12456 if (element == null)
12457 {
12458 return;
12459 }
12460
12461 if (map_points == null)
12462 {
12463 map_points = new ArrayList<Navit_Point_on_Map>();
12464 }
12465
12466 int el_pos = get_destination_pos(element);
12467 // int home_id = find_home_point();
12468 boolean is_home = is_home_element(element);
12469
12470 // System.out.println("EEPOS:el_pos=" + el_pos + " is_home=" + is_home);
12471
12472 if (is_home)
12473 {
12474 // its the "home" destination
12475 return;
12476 }
12477
12478 if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
12479 {
12480 try
12481 {
12482 // map_points.remove(0);
12483 remove_oldest_normal_point();
12484 }
12485 catch (Exception e)
12486 {
12487 }
12488 }
12489
12490 if (el_pos == -1)
12491 {
12492 // if not duplicate, then add
12493 map_points.add(element);
12494 readd_home_point();
12495 write_map_points();
12496 }
12497 else
12498 {
12499 try
12500 {
12501 // if already in list, then first remove and add again
12502 // that moves it to the top of the list
12503 Navit_Point_on_Map element_old = map_points.get(el_pos);
12504 map_points.remove(el_pos);
12505 map_points.add(element_old);
12506 readd_home_point();
12507 write_map_points();
12508 }
12509 catch (Exception e)
12510 {
12511 e.printStackTrace();
12512 }
12513 }
12514 }
12515
12516 void read_map_points()
12517 {
12518 deserialize_map_points();
12519 }
12520
12521 static void write_map_points()
12522 {
12523 if (map_points != null)
12524 {
12525 serialize_map_points();
12526 }
12527 }
12528
12529 private static void serialize_map_points()
12530 {
12531 FileOutputStream fos;
12532 try
12533 {
12534 fos = new FileOutputStream(NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME);
12535 // openFileOutput(CFG_FILENAME_PATH + Navit_DEST_FILENAME, Context.MODE_PRIVATE);
12536 ObjectOutputStream oos = new ObjectOutputStream(fos);
12537 oos.writeObject(map_points);
12538 oos.close();
12539 }
12540 catch (FileNotFoundException e)
12541 {
12542 e.printStackTrace();
12543 }
12544 catch (IOException e)
12545 {
12546 e.printStackTrace();
12547 }
12548 catch (Exception e)
12549 {
12550 e.printStackTrace();
12551 }
12552 }
12553
12554 private void export_map_points_to_sdcard()
12555 {
12556 String orig_file = NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME;
12557 String dest_file_dir = CFG_FILENAME_PATH + "../export/";
12558
12559 try
12560 {
12561 File dir = new File(dest_file_dir);
12562 dir.mkdirs();
12563 }
12564 catch (Exception e)
12565 {
12566 e.printStackTrace();
12567 }
12568
12569 try
12570 {
12571 File source = new File(orig_file);
12572 File destination = new File(dest_file_dir + Navit_DEST_FILENAME);
12573
12574 if (source.exists())
12575 {
12576 FileInputStream fi = new FileInputStream(source);
12577 FileOutputStream fo = new FileOutputStream(destination);
12578 FileChannel src = fi.getChannel();
12579 FileChannel dst = fo.getChannel();
12580 dst.transferFrom(src, 0, src.size());
12581 src.close();
12582 dst.close();
12583 fi.close();
12584 fo.close();
12585 }
12586 }
12587 catch (Exception e)
12588 {
12589 e.printStackTrace();
12590 }
12591 }
12592
12593 private void import_map_points_from_sdcard()
12594 {
12595 String orig_file = NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME;
12596 String dest_file_dir = CFG_FILENAME_PATH + "../export/";
12597
12598 try
12599 {
12600 File source = new File(dest_file_dir + Navit_DEST_FILENAME);
12601 File destination = new File(orig_file);
12602
12603 if (source.exists())
12604 {
12605 FileInputStream fi = new FileInputStream(source);
12606 FileOutputStream fo = new FileOutputStream(destination);
12607 FileChannel src = fi.getChannel();
12608 FileChannel dst = fo.getChannel();
12609 dst.transferFrom(src, 0, src.size());
12610 src.close();
12611 dst.close();
12612 fi.close();
12613 fo.close();
12614 }
12615 }
12616 catch (Exception e)
12617 {
12618 e.printStackTrace();
12619 }
12620
12621 read_map_points();
12622 }
12623
12624 //@SuppressWarnings("unchecked")
12625 private void deserialize_map_points()
12626 {
12627 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12628
12629 FileInputStream fis = null;
12630 ObjectInputStream ois = null;
12631
12632 try
12633 {
12634 fis = new FileInputStream(NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME);
12635 // openFileInput(CFG_FILENAME_PATH + Navit_DEST_FILENAME);
12636 ois = new ObjectInputStream(fis);
12637 map_points = (ArrayList<Navit_Point_on_Map>) ois.readObject();
12638 }
12639 catch (FileNotFoundException e)
12640 {
12641 e.printStackTrace();
12642 map_points = new ArrayList<Navit_Point_on_Map>();
12643 }
12644 catch (IOException e)
12645 {
12646 e.printStackTrace();
12647 map_points = new ArrayList<Navit_Point_on_Map>();
12648 }
12649 catch (ClassNotFoundException e)
12650 {
12651 e.printStackTrace();
12652 map_points = new ArrayList<Navit_Point_on_Map>();
12653 }
12654 catch (Exception e)
12655 {
12656 e.printStackTrace();
12657 map_points = new ArrayList<Navit_Point_on_Map>();
12658 }
12659
12660 try
12661 {
12662 if (ois != null)
12663 {
12664 ois.close();
12665 }
12666 }
12667 catch (Exception e)
12668 {
12669 }
12670
12671 try
12672 {
12673 if (fis != null)
12674 {
12675 ois.close();
12676 }
12677 }
12678 catch (Exception e)
12679 {
12680 }
12681
12682 // for (int j = 0; j < map_points.size(); j++)
12683 // {
12684 // System.out.println("####******************" + j + ":" + map_points.get(j).point_name);
12685 // }
12686
12687 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12688
12689 }
12690
12691 static void remember_destination_xy(String name, int x, int y)
12692 {
12693 // i=1 -> pixel a,b (x,y) -> geo string "lat(float):lng(float)"
12694 // i=2 -> geo a,b (lat,lng) -> pixel string "x(int):y(int)"
12695 String lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
12696 try
12697 {
12698 String tmp[] = lat_lon.split(":", 2);
12699 //System.out.println("tmp=" + lat_lon);
12700 float lat = Float.parseFloat(tmp[0]);
12701 float lon = Float.parseFloat(tmp[1]);
12702 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
12703 remember_destination(name, lat, lon);
12704 }
12705 catch (Exception e)
12706 {
12707 e.printStackTrace();
12708
12709 }
12710 }
12711
12712 static void remember_destination(String name, String lat, String lon)
12713 {
12714 try
12715 {
12716 //System.out.println("22 **## " + name + " " + lat + " " + lon + " ##**");
12717 remember_destination(name, Float.parseFloat(lat), Float.parseFloat(lon));
12718 }
12719 catch (Exception e)
12720 {
12721 e.printStackTrace();
12722 }
12723 }
12724
12725 static void remember_destination(String name, float lat, float lon)
12726 {
12727 //System.out.println("11 **## " + name + " " + lat + " " + lon + " ##**");
12728 Navit_Point_on_Map t = new Navit_Point_on_Map();
12729 t.point_name = name;
12730 t.lat = lat;
12731 t.lon = lon;
12732 add_map_point(t);
12733 }
12734
12735 static void destination_set()
12736 {
12737 // status = "destination set"
12738 NavitGraphics.navit_route_status = 1;
12739 }
12740
12741 static Boolean check_dup_destination(Navit_Point_on_Map element)
12742 {
12743 Boolean ret = false;
12744 Navit_Point_on_Map t;
12745 for (int i = 0; i < map_points.size(); i++)
12746 {
12747 t = map_points.get(i);
12748 if (t.addon == null)
12749 {
12750 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
12751 {
12752 return true;
12753 }
12754 }
12755 else
12756 {
12757 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
12758 {
12759 return true;
12760 }
12761 }
12762 }
12763 return ret;
12764 }
12765
12766 static int get_destination_pos(Navit_Point_on_Map element)
12767 {
12768 int ret = -1;
12769 Navit_Point_on_Map t;
12770 for (int i = 0; i < map_points.size(); i++)
12771 {
12772 t = map_points.get(i);
12773 if (t.addon == null)
12774 {
12775 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
12776 {
12777 return i;
12778 }
12779 }
12780 else
12781 {
12782 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
12783 {
12784 return i;
12785 }
12786 }
12787 }
12788 return ret;
12789 }
12790
12791 static boolean is_home_element(Navit_Point_on_Map element)
12792 {
12793 int home_id = find_home_point();
12794 if (home_id != -1)
12795 {
12796 Navit_Point_on_Map home_element = map_points.get(home_id);
12797
12798 if ((home_element.point_name.equals(element.point_name)) && (home_element.lat == element.lat) && (home_element.lon == element.lon))
12799 {
12800 return true;
12801 }
12802
12803 }
12804
12805 return false;
12806 }
12807
12808 static NavitSpeech2 get_speech_object()
12809 {
12810 System.out.println("get_speech_object");
12811 return NSp;
12812 }
12813
12814 static NavitVehicle get_vehicle_object()
12815 {
12816 System.out.println("get_vehicle_object");
12817 return NV;
12818 }
12819
12820 static NavitGraphics get_graphics_object_by_name(String name)
12821 {
12822 System.out.println("get_graphics_object_by_name:*" + name + "*");
12823
12824 if (name.equals("type:map-main"))
12825 {
12826 System.out.println("map-main");
12827 return NG__map_main;
12828 }
12829 else
12830 {
12831 System.out.println("vehicle");
12832 return NG__vehicle;
12833 }
12834 }
12835
12836 public static Handler vehicle_handler = new Handler()
12837 {
12838 public void handleMessage(Message msg)
12839 {
12840 //System.out.println("vehicle_handler:handleMessage:JTHREAD ID=" + Thread.currentThread().getId());
12841 //System.out.println("vehicle_handler:handleMessage:THREAD ID=" + NavitGraphics.GetThreadId());
12842
12843 switch (msg.what)
12844 {
12845 case 1:
12846 Location l = new Location("Network");
12847 l.setLatitude(msg.getData().getFloat("lat"));
12848 l.setLongitude(msg.getData().getFloat("lng"));
12849 l.setBearing(msg.getData().getFloat("b"));
12850 l.setSpeed(0.8f);
12851 NavitVehicle.set_mock_location__fast(l);
12852 break;
12853 case 2:
12854 if (NavitVehicle.update_location_in_progress)
12855 {
12856 }
12857 else
12858 {
12859 NavitVehicle.update_location_in_progress = true;
12860 NavitVehicle.VehicleCallback2(NavitVehicle.last_location);
12861 NavitVehicle.update_location_in_progress = false;
12862 }
12863 break;
12864 }
12865 }
12866 };
12867
12868 public String roundTwoDecimals(double d)
12869 {
12870 return String.format(Locale.US, "%.2f", d);
12871 }
12872
12873 /* ZZ GEO TRANS ZZ */
12874 static double __EARTH_RADIUS__ = 6378137.000;
12875 static double __GEO_ACCURACY_FACTOR__ = 2.000;
12876 final static double M_PI_div_360 = 0.008726646259971647884618;
12877 final static double M_PI_div_180 = 0.01745329251994329576;
12878 final static double M_PI_mul_360 = 1130.97335529232556584560;
12879 final static double M_PI_mul_180 = 565.48667764616278292280;
12880
12881 /* ZZ GEO TRANS ZZ */
12882
12883 public static int transform_from_geo_lat(double lat)
12884 {
12885 /* ZZ GEO TRANS ZZ */
12886 int ret = (int) ((Math.log(Math.tan((Math.PI / 4f) + lat * M_PI_div_360)) * __EARTH_RADIUS__) * __GEO_ACCURACY_FACTOR__);
12887 return ret;
12888 }
12889
12890 public static int transform_from_geo_lon(double lon)
12891 {
12892 /* ZZ GEO TRANS ZZ */
12893 int ret = (int) ((lon * __EARTH_RADIUS__ * M_PI_div_180) * __GEO_ACCURACY_FACTOR__);
12894
12895 return ret;
12896 }
12897
12898 public static double transform_to_geo_lat(float y) // y
12899 {
12900 /* ZZ GEO TRANS ZZ */
12901 return (Math.atan(Math.exp((y / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__)) / M_PI_div_360 - 90);
12902 }
12903
12904 public static double transform_to_geo_lon(float x) // x
12905 {
12906 /* ZZ GEO TRANS ZZ */
12907 return ((x / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__ / M_PI_div_180);
12908 }
12909
12910 public static boolean allow_use_index_search()
12911 {
12912 if ((!Navit_DonateVersion_Installed) && (!Navit_Largemap_DonateVersion_Installed))
12913 {
12914 // no donate version installed
12915 Log.e("Navit", "no donate version installed");
12916
12917 Navit_index_on_but_no_idx_files = false;
12918 return false;
12919 }
12920
12921 boolean ret = false;
12922
12923 // MAP_FILENAME_PATH
12924 File folder = new File(MAP_FILENAME_PATH);
12925 File[] listOfFiles = folder.listFiles();
12926 File idx = null;
12927 File md5_file = null;
12928 FileOutputStream fos = null;
12929
12930 int files = 0;
12931 int file_without_index = 0;
12932
12933 for (File file : listOfFiles)
12934 {
12935 if (file.isFile())
12936 {
12937 // System.out.println("FFNN:" + file.getName());
12938
12939 if (file.getName().endsWith(".bin"))
12940 {
12941 if (!file.getName().equals("borders.bin"))
12942 {
12943 if (!file.getName().equals("coastline.bin"))
12944 {
12945 files++;
12946 idx = new File(folder, file.getName() + ".idx");
12947 if (idx.exists())
12948 {
12949 }
12950 else
12951 {
12952 file_without_index++;
12953
12954 String servername = "";
12955 try
12956 {
12957 servername = NavitMapDownloader.is_in_cat_file_disk_name(file.getName()).split(":", 2)[1];
12958 }
12959 catch (Exception ee)
12960 {
12961 }
12962
12963 if (!servername.equals(""))
12964 {
12965
12966 // index for this map is missing. hack MD5 file so we can download it again
12967 md5_file = new File(Navit.MAPMD5_FILENAME_PATH + "/" + servername + ".md5");
12968
12969 // System.out.println("FFNN:hack MD5:" + md5_file.getAbsolutePath() + " s=" + servername);
12970
12971 if ((md5_file.exists()) && (md5_file.canWrite()))
12972 {
12973 try
12974 {
12975 fos = new FileOutputStream(md5_file);
12976 fos.write(65);
12977 fos.write(65);
12978 fos.write(65);
12979 fos.close();
12980 }
12981 catch (Exception e1)
12982 {
12983 // System.out.println("FFNN:EEEEEEEEEEEEEE");
12984 }
12985 }
12986 }
12987 }
12988 }
12989 }
12990 }
12991
12992 if (file.getName().endsWith(".bin.idx"))
12993 {
12994 ret = true;
12995 }
12996 }
12997 }
12998
12999 if (files > 0)
13000 {
13001 if (file_without_index > 0)
13002 {
13003 Navit_index_on_but_no_idx_files = true;
13004 }
13005 else
13006 {
13007 Navit_index_on_but_no_idx_files = false;
13008 }
13009 }
13010
13011 return ret;
13012 }
13013
13014 private void sendEmail(String recipient, String subject, String message)
13015 {
13016 try
13017 {
13018 final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
13019 emailIntent.setType("plain/text");
13020 if (recipient != null) emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { recipient });
13021 if (subject != null) emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
13022 if (message != null) emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
13023
13024 startActivity(Intent.createChooser(emailIntent, Navit.get_text("Send feedback via email ...")));
13025
13026 }
13027 catch (ActivityNotFoundException e)
13028 {
13029 // cannot send email for some reason
13030 }
13031 }
13032
13033 @SuppressLint("NewApi")
13034 void detect_menu_button()
13035 {
13036 // default: we dont have a real menu button
13037 has_hw_menu_button = false;
13038
13039 try
13040 {
13041 if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 14)
13042 {
13043 if (ViewConfiguration.get(getApplicationContext()).hasPermanentMenuKey())
13044 {
13045 has_hw_menu_button = true;
13046 }
13047 else
13048 {
13049 has_hw_menu_button = false;
13050 }
13051 }
13052 else
13053 {
13054 has_hw_menu_button = true;
13055 }
13056 }
13057 catch (Exception e)
13058 {
13059 // on error we must be on android API < 14 and therfore we have a menu button (that is what we assume)
13060 has_hw_menu_button = true;
13061 }
13062
13063 // now always show menu button icon
13064 has_hw_menu_button = false;
13065 }
13066
13067 public void onBackPressed()
13068 {
13069 // do something on back.
13070 //System.out.println("no back key!");
13071 // super.onBackPressed();
13072 // !!disable the back key otherwise!!
13073
13074 if (Navit_doubleBackToExitPressedOnce)
13075 {
13076
13077 try
13078 {
13079 if (wl_navigating != null)
13080 {
13081 //if (wl_navigating.isHeld())
13082 //{
13083 wl_navigating.release();
13084 Log.e("Navit", "WakeLock Nav: release 1");
13085 //}
13086 }
13087 }
13088 catch (Exception e)
13089 {
13090 e.printStackTrace();
13091 }
13092
13093 // super.onBackPressed(); --> this would only put the app in background
13094 // --------
13095 // exit the app here
13096 this.onPause();
13097 this.onStop();
13098 this.exit();
13099 // --------
13100 return;
13101 }
13102
13103 try
13104 {
13105 Navit_doubleBackToExitPressedOnce = true;
13106 Toast.makeText(this, Navit.get_text("Please press BACK again to Exit"), Toast.LENGTH_SHORT).show();
13107
13108 new Handler().postDelayed(new Runnable()
13109 {
13110 @Override
13111 public void run()
13112 {
13113 Navit_doubleBackToExitPressedOnce = false;
13114 }
13115 }, NAVIT_BACKBUTTON_TO_EXIT_TIME);
13116 }
13117 catch (Exception e)
13118 {
13119 }
13120
13121 try
13122 {
13123 // if bottom bar is up, animate it down on "back" press
13124 animate_bottom_bar_down();
13125 }
13126 catch (Exception e)
13127 {
13128 }
13129
13130 }
13131
13132 // public void openOptionsMenu_wrapper()
13133 // {
13134 // //openOptionsMenu();
13135 //
13136 // prepare_emu_options_menu();
13137 // NavitGraphics.emu_menu_view.set_adapter(EmulatedMenuView.MenuItemsList2, EmulatedMenuView.MenuItemsIdMapping2);
13138 // NavitGraphics.emu_menu_view.bringToFront();
13139 // NavitGraphics.emu_menu_view.setVisibility(View.VISIBLE);
13140 // }
13141
13142 public static String logHeap(Class clazz)
13143 {
13144 Double allocated = Double.valueOf(Debug.getNativeHeapAllocatedSize()) / Double.valueOf((1048576));
13145 Double sum_size = Double.valueOf(Debug.getNativeHeapSize() / Double.valueOf(1048576.0));
13146 Double free = Double.valueOf(Debug.getNativeHeapFreeSize() / Double.valueOf(1048576.0));
13147 DecimalFormat df = new DecimalFormat();
13148 df.setMaximumFractionDigits(2);
13149 df.setMinimumFractionDigits(2);
13150
13151 // Log.d("Navit", "MemMem:DEBUG: =================================");
13152 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.", "") + "]");
13153 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)");
13154
13155 calcAvailableMemory();
13156
13157 String mem_type = "NATIVE";
13158 try
13159 {
13160 if (android.os.Build.VERSION.SDK_INT >= 11)
13161 {
13162 mem_type = "JAVA";
13163 }
13164 }
13165 catch (Exception e)
13166 {
13167 }
13168 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);
13169 }
13170
13171 private static long calcAvailableMemory()
13172 {
13173 try
13174 {
13175 long value = Runtime.getRuntime().maxMemory();
13176 String type = "";
13177 if (android.os.Build.VERSION.SDK_INT >= 11)
13178 {
13179 value = (value / 1024 / 1024) - (Runtime.getRuntime().totalMemory() / 1024 / 1024);
13180 type = "JAVA";
13181 }
13182 else
13183 {
13184 value = (value / 1024 / 1024) - (Debug.getNativeHeapAllocatedSize() / 1024 / 1024);
13185 type = "NATIVE";
13186 }
13187 Log.i("Navit", "avail.mem size=" + value + "MB, type=" + type);
13188 return value;
13189 }
13190 catch (Exception e)
13191 {
13192 return 0L;
13193 }
13194 }
13195
13196 public void google_online_search_and_set_destination(String address_string)
13197 {
13198 // online googlemaps search
13199 // String addressInput = filter_bad_chars(address_string);
13200 String addressInput = address_string;
13201 try
13202 {
13203 List<Address> foundAdresses = Navit.Navit_Geocoder.getFromLocationName(addressInput, 1); //Search addresses
13204 //System.out.println("found " + foundAdresses.size() + " results");
13205 //System.out.println("addr=" + foundAdresses.get(0).getLatitude() + " " + foundAdresses.get(0).getLongitude() + "" + foundAdresses.get(0).getAddressLine(0));
13206
13207 int results_step = 0;
13208 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
13209 tmp_addr.result_type = "STR";
13210 tmp_addr.item_id = "0";
13211 tmp_addr.lat = (float) foundAdresses.get(results_step).getLatitude();
13212 tmp_addr.lon = (float) foundAdresses.get(results_step).getLongitude();
13213 tmp_addr.addr = "";
13214
13215 String c_code = foundAdresses.get(results_step).getCountryCode();
13216 if (c_code != null)
13217 {
13218 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getCountryCode() + ",";
13219 }
13220
13221 String p_code = foundAdresses.get(results_step).getPostalCode();
13222 if (p_code != null)
13223 {
13224 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getPostalCode() + " ";
13225 }
13226
13227 if (foundAdresses.get(results_step).getMaxAddressLineIndex() > -1)
13228 {
13229 for (int addr_line = 0; addr_line < foundAdresses.get(results_step).getMaxAddressLineIndex(); addr_line++)
13230 {
13231 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
13232 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
13233 }
13234 }
13235
13236 // // DEBUG: clear route rectangle list
13237 // NavitGraphics.route_rects.clear();
13238 //
13239 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
13240 //
13241 // try
13242 // {
13243 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
13244 // // save points
13245 // write_map_points();
13246 // }
13247 // catch (Exception e)
13248 // {
13249 // e.printStackTrace();
13250 // }
13251 //
13252 // if (NavitGraphics.navit_route_status == 0)
13253 // {
13254 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13255 // Navit.destination_set();
13256 //
13257 // Message msg = new Message();
13258 // Bundle b = new Bundle();
13259 // b.putInt("Callback", 3);
13260 // b.putString("lat", String.valueOf(tmp_addr.lat));
13261 // b.putString("lon", String.valueOf(tmp_addr.lon));
13262 // b.putString("q", tmp_addr.addr);
13263 // msg.setData(b);
13264 // NavitGraphics.callback_handler.sendMessage(msg);
13265 // }
13266 // else
13267 // {
13268 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13269 // Message msg = new Message();
13270 // Bundle b = new Bundle();
13271 // b.putInt("Callback", 48);
13272 // b.putString("lat", String.valueOf(tmp_addr.lat));
13273 // b.putString("lon", String.valueOf(tmp_addr.lon));
13274 // b.putString("q", tmp_addr.addr);
13275 // msg.setData(b);
13276 // NavitGraphics.callback_handler.sendMessage(msg);
13277 // }
13278
13279 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
13280
13281 // ---------- DEBUG: write route to file ----------
13282 // ---------- DEBUG: write route to file ----------
13283 // ---------- DEBUG: write route to file ----------
13284 if (p.PREF_enable_debug_write_gpx)
13285 {
13286 write_route_to_gpx_file();
13287 }
13288 // ---------- DEBUG: write route to file ----------
13289 // ---------- DEBUG: write route to file ----------
13290
13291 try
13292 {
13293 Navit.follow_button_on();
13294 }
13295 catch (Exception e2)
13296 {
13297 e2.printStackTrace();
13298 }
13299
13300 show_geo_on_screen(tmp_addr.lat, tmp_addr.lon);
13301
13302 }
13303 catch (Exception e)
13304 {
13305 e.printStackTrace();
13306 Toast.makeText(getApplicationContext(), Navit.get_text("google search API is not working at this moment, try offline search"), Toast.LENGTH_SHORT).show();
13307 }
13308 }
13309
13310 public void result_set_destination(double lat, double lon, String addr)
13311 {
13312 try
13313 {
13314 int results_step = 0;
13315 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
13316 tmp_addr.result_type = "STR";
13317 tmp_addr.item_id = "0";
13318 tmp_addr.lat = (float) lat;
13319 tmp_addr.lon = (float) lon;
13320 tmp_addr.addr = addr;
13321
13322 // // DEBUG: clear route rectangle list
13323 // NavitGraphics.route_rects.clear();
13324 //
13325 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
13326 //
13327 // try
13328 // {
13329 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
13330 // // save points
13331 // write_map_points();
13332 // }
13333 // catch (Exception e)
13334 // {
13335 // e.printStackTrace();
13336 // }
13337 //
13338 // if (NavitGraphics.navit_route_status == 0)
13339 // {
13340 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13341 // Navit.destination_set();
13342 //
13343 // Message msg = new Message();
13344 // Bundle b = new Bundle();
13345 // b.putInt("Callback", 3);
13346 // b.putString("lat", String.valueOf(tmp_addr.lat));
13347 // b.putString("lon", String.valueOf(tmp_addr.lon));
13348 // b.putString("q", tmp_addr.addr);
13349 // msg.setData(b);
13350 // NavitGraphics.callback_handler.sendMessage(msg);
13351 // }
13352 // else
13353 // {
13354 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13355 // Message msg = new Message();
13356 // Bundle b = new Bundle();
13357 // b.putInt("Callback", 48);
13358 // b.putString("lat", String.valueOf(tmp_addr.lat));
13359 // b.putString("lon", String.valueOf(tmp_addr.lon));
13360 // b.putString("q", tmp_addr.addr);
13361 // msg.setData(b);
13362 // NavitGraphics.callback_handler.sendMessage(msg);
13363 // }
13364
13365 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
13366
13367 try
13368 {
13369 Navit.follow_button_on();
13370 }
13371 catch (Exception e2)
13372 {
13373 e2.printStackTrace();
13374 }
13375
13376 // ---------- DEBUG: write route to file ----------
13377 // ---------- DEBUG: write route to file ----------
13378 // ---------- DEBUG: write route to file ----------
13379 if (p.PREF_enable_debug_write_gpx)
13380 {
13381 write_route_to_gpx_file();
13382 }
13383 // ---------- DEBUG: write route to file ----------
13384 // ---------- DEBUG: write route to file ----------
13385
13386 show_geo_on_screen(tmp_addr.lat, tmp_addr.lon);
13387
13388 }
13389 catch (Exception e)
13390 {
13391 e.printStackTrace();
13392 Toast.makeText(getApplicationContext(), Navit.get_text("google search API is not working at this moment, try offline search"), Toast.LENGTH_SHORT).show();
13393 }
13394 }
13395
13396 void open_voice_recog_screen()
13397 {
13398 Intent ii = new Intent(this, ZANaviVoiceInput.class);
13399 this.startActivityForResult(ii, Navit.ZANaviVoiceInput_id);
13400 }
13401
13402 static void dim_screen_wrapper()
13403 {
13404 try
13405 {
13406 Message msg = Navit.Navit_progress_h.obtainMessage();
13407 Bundle b = new Bundle();
13408 msg.what = 20;
13409 msg.setData(b);
13410 Navit.Navit_progress_h.sendMessage(msg);
13411 }
13412 catch (Exception e)
13413 {
13414 e.printStackTrace();
13415 }
13416 }
13417
13418 static void show_status_bar_wrapper()
13419 {
13420 try
13421 {
13422 Message msg = Navit.Navit_progress_h.obtainMessage();
13423 Bundle b = new Bundle();
13424 msg.what = 27;
13425 msg.setData(b);
13426 Navit.Navit_progress_h.sendMessage(msg);
13427 }
13428 catch (Exception e)
13429 {
13430 e.printStackTrace();
13431 }
13432 }
13433
13434 static void hide_status_bar_wrapper()
13435 {
13436 try
13437 {
13438 Message msg = Navit.Navit_progress_h.obtainMessage();
13439 Bundle b = new Bundle();
13440 msg.what = 28;
13441 msg.setData(b);
13442 Navit.Navit_progress_h.sendMessage(msg);
13443 }
13444 catch (Exception e)
13445 {
13446 e.printStackTrace();
13447 }
13448 }
13449
13450 static void default_brightness_screen_wrapper()
13451 {
13452 try
13453 {
13454 Message msg = Navit.Navit_progress_h.obtainMessage();
13455 Bundle b = new Bundle();
13456 msg.what = 21;
13457 msg.setData(b);
13458 Navit.Navit_progress_h.sendMessage(msg);
13459 }
13460 catch (Exception e)
13461 {
13462 e.printStackTrace();
13463 }
13464 }
13465
13466 static void dim_screen()
13467 {
13468 try
13469 {
13470 WindowManager.LayoutParams params_wm = app_window.getAttributes();
13471 // params_wm.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
13472 params_wm.screenBrightness = 0.1f;
13473 app_window.setAttributes(params_wm);
13474 //app_window.addFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
13475 }
13476 catch (Exception e)
13477 {
13478 e.printStackTrace();
13479 }
13480 }
13481
13482 static void default_brightness_screen()
13483 {
13484 try
13485 {
13486 WindowManager.LayoutParams params_wm = app_window.getAttributes();
13487 // params_wm.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
13488 params_wm.screenBrightness = -1f;
13489 app_window.setAttributes(params_wm);
13490 //app_window.clearFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
13491 }
13492 catch (Exception e)
13493 {
13494 e.printStackTrace();
13495 }
13496 }
13497
13498 void donate_bitcoins()
13499 {
13500 try
13501 {
13502 Intent donate_activity = new Intent(this, ZANaviDonateActivity.class);
13503 // donate_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
13504 startActivity(donate_activity);
13505 }
13506 catch (Exception e)
13507 {
13508 }
13509 }
13510
13511 void donate()
13512 {
13513 try
13514 {
13515 Intent donate_activity = new Intent(this, ZANaviNormalDonateActivity.class);
13516 // donate_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
13517 startActivity(donate_activity);
13518 }
13519 catch (Exception e)
13520 {
13521 }
13522 }
13523
13524 static int debug_indent = -1;
13525 static String debug_indent_spaces = " ";
13526
13527 // type: 0 -> enter, 1 -> leave, 2 .. n -> return(#n)
13528 static void my_func_name(int type)
13529 {
13530 int debug_indent2;
13531
13532 // -- switch off !! --
13533 // -- switch off !! --
13534 debug_indent = 0;
13535 // -- switch off !! --
13536 // -- switch off !! --
13537
13538 try
13539 {
13540 StackTraceElement[] a = Thread.currentThread().getStackTrace();
13541 if (type == 0)
13542 {
13543 //debug_indent++;
13544 debug_indent2 = debug_indent;
13545 //if (debug_indent2 > debug_indent_spaces.length())
13546 //{
13547 // debug_indent2 = debug_indent_spaces.length() - 1;
13548 //}
13549 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":enter");
13550 }
13551 else if (type == 1)
13552 {
13553 debug_indent2 = debug_indent;
13554 //if (debug_indent2 > debug_indent_spaces.length())
13555 //{
13556 // debug_indent2 = debug_indent_spaces.length() - 1;
13557 //}
13558 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":leave");
13559 //debug_indent--;
13560 }
13561 else
13562 {
13563 debug_indent2 = debug_indent;
13564 //if (debug_indent2 > debug_indent_spaces.length())
13565 //{
13566 // debug_indent2 = debug_indent_spaces.length() - 1;
13567 //}
13568 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":return(" + type + ")");
13569 //debug_indent--;
13570 }
13571 }
13572 catch (Exception e)
13573 {
13574 e.printStackTrace();
13575 }
13576 }
13577
13578 // type: 0 -> enter, 1 -> leave, 2 .. n -> return(#n)
13579 static void my_func_name(int type, String msg)
13580 {
13581 int debug_indent2;
13582
13583 // -- switch off !! --
13584 // -- switch off !! --
13585 debug_indent = 0;
13586 // -- switch off !! --
13587 // -- switch off !! --
13588
13589 try
13590 {
13591 StackTraceElement[] a = Thread.currentThread().getStackTrace();
13592 if (type == 0)
13593 {
13594 //debug_indent++;
13595 debug_indent2 = debug_indent;
13596 //if (debug_indent2 > debug_indent_spaces.length())
13597 //{
13598 // debug_indent2 = debug_indent_spaces.length() - 1;
13599 //}
13600 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":enter" + ":" + msg);
13601 }
13602 else if (type == 1)
13603 {
13604 debug_indent2 = debug_indent;
13605 //if (debug_indent2 > debug_indent_spaces.length())
13606 //{
13607 // debug_indent2 = debug_indent_spaces.length() - 1;
13608 //}
13609 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":leave" + ":" + msg);
13610 //debug_indent--;
13611 }
13612 else
13613 {
13614 debug_indent2 = debug_indent;
13615 //if (debug_indent2 > debug_indent_spaces.length())
13616 //{
13617 // debug_indent2 = debug_indent_spaces.length() - 1;
13618 //}
13619 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":return(" + type + ")" + ":" + msg);
13620 //debug_indent--;
13621 }
13622 }
13623 catch (Exception e)
13624 {
13625 e.printStackTrace();
13626 }
13627 }
13628
13629 public static void write_route_to_gpx_file()
13630 {
13631 final Thread write_route_to_gpx_file_001 = new Thread()
13632 {
13633 int wait = 1;
13634 int count = 0;
13635 int max_count = 60;
13636
13637 @Override
13638 public void run()
13639 {
13640 while (wait == 1)
13641 {
13642 try
13643 {
13644 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
13645 {
13646 Message msg = new Message();
13647 Bundle b = new Bundle();
13648 b.putInt("Callback", 96);
13649 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
13650 String filename = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_route_" + date + ".gpx";
13651 b.putString("s", filename);
13652 System.out.println("Debug:" + "file=" + filename);
13653 msg.setData(b);
13654 NavitGraphics.callback_handler.sendMessage(msg);
13655
13656 Message msg7 = Navit_progress_h.obtainMessage();
13657 Bundle b7 = new Bundle();
13658 msg7.what = 2; // long Toast message
13659 b7.putString("text", Navit.get_text("saving route to GPX-file") + " " + filename); //TRANS
13660 msg7.setData(b7);
13661 Navit_progress_h.sendMessage(msg7);
13662
13663 wait = 0;
13664 }
13665 else
13666 {
13667 wait = 1;
13668 }
13669
13670 count++;
13671 if (count > max_count)
13672 {
13673 wait = 0;
13674
13675 Message msg7 = Navit_progress_h.obtainMessage();
13676 Bundle b7 = new Bundle();
13677 msg7.what = 2; // long Toast message
13678 b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS
13679 msg7.setData(b7);
13680 Navit_progress_h.sendMessage(msg7);
13681 }
13682 else
13683 {
13684 Thread.sleep(400);
13685 }
13686 }
13687 catch (Exception e)
13688 {
13689 }
13690 }
13691 }
13692 };
13693 write_route_to_gpx_file_001.start();
13694 }
13695
13696 void convert_gpx_file_real(String gpx_file)
13697 {
13698 File tt2 = new File(gpx_file);
13699 p.PREF_last_selected_dir_gpxfiles = tt2.getParent();
13700 Log.e("Navit", "last_selected_dir_gpxfiles " + p.PREF_last_selected_dir_gpxfiles);
13701 setPrefs_selected_gpx_dir();
13702
13703 String out_ = MAP_FILENAME_PATH + "/gpxtracks.txt";
13704 Log.e("Navit", "onActivityResult 002 " + gpx_file + " " + out_);
13705 MainFrame.do_conversion(gpx_file, out_);
13706
13707 // draw map no-async
13708 Message msg = new Message();
13709 Bundle b = new Bundle();
13710 b.putInt("Callback", 64);
13711 msg.setData(b);
13712 NavitGraphics.callback_handler.sendMessage(msg);
13713 }
13714
13715 String intent_flags_to_string(int flags)
13716 {
13717 String ret = "(" + String.format("%#x", flags) + ") ";
13718
13719 // Intent flags
13720 final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
13721 final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
13722 final int FLAG_FROM_BACKGROUND = 0x00000004;
13723 final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
13724 final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
13725 final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
13726 final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
13727 final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
13728 final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
13729 final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
13730 final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
13731 final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
13732 final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
13733 final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
13734 final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
13735 final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
13736 final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
13737 final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
13738 final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
13739 final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
13740 final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
13741 final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
13742 final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
13743 /*
13744 * final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
13745 * final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
13746 * final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
13747 * final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x08000000;
13748 * final int FLAG_RECEIVER_BOOT_UPGRADE = 0x04000000;
13749 */
13750
13751 int first = 1;
13752 String sep = "";
13753
13754 if ((flags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
13755 {
13756 if (first == 1)
13757 {
13758 first = 0;
13759 sep = "";
13760 }
13761 else
13762 {
13763 sep = ",";
13764 }
13765 ret = ret + sep + "FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS";
13766 }
13767 if ((flags & FLAG_ACTIVITY_BROUGHT_TO_FRONT) == FLAG_ACTIVITY_BROUGHT_TO_FRONT)
13768 {
13769 if (first == 1)
13770 {
13771 first = 0;
13772 sep = "";
13773 }
13774 else
13775 {
13776 sep = ",";
13777 }
13778 ret = ret + sep + "FLAG_ACTIVITY_BROUGHT_TO_FRONT";
13779 }
13780 if ((flags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) == FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
13781 {
13782 if (first == 1)
13783 {
13784 first = 0;
13785 sep = "";
13786 }
13787 else
13788 {
13789 sep = ",";
13790 }
13791 ret = ret + sep + "FLAG_ACTIVITY_RESET_TASK_IF_NEEDED";
13792 }
13793 if ((flags & FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)
13794 {
13795 if (first == 1)
13796 {
13797 first = 0;
13798 sep = "";
13799 }
13800 else
13801 {
13802 sep = ",";
13803 }
13804 ret = ret + sep + "FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY";
13805 }
13806 if ((flags & FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) == FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
13807 {
13808 if (first == 1)
13809 {
13810 first = 0;
13811 sep = "";
13812 }
13813 else
13814 {
13815 sep = ",";
13816 }
13817 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET";
13818 }
13819 if ((flags & FLAG_ACTIVITY_NO_USER_ACTION) == FLAG_ACTIVITY_NO_USER_ACTION)
13820 {
13821 if (first == 1)
13822 {
13823 first = 0;
13824 sep = "";
13825 }
13826 else
13827 {
13828 sep = ",";
13829 }
13830 ret = ret + sep + "FLAG_ACTIVITY_NO_USER_ACTION";
13831 }
13832 if ((flags & FLAG_ACTIVITY_REORDER_TO_FRONT) == FLAG_ACTIVITY_REORDER_TO_FRONT)
13833 {
13834 if (first == 1)
13835 {
13836 first = 0;
13837 sep = "";
13838 }
13839 else
13840 {
13841 sep = ",";
13842 }
13843 ret = ret + sep + "FLAG_ACTIVITY_REORDER_TO_FRONT";
13844 }
13845 if ((flags & FLAG_ACTIVITY_NO_ANIMATION) == FLAG_ACTIVITY_NO_ANIMATION)
13846 {
13847 if (first == 1)
13848 {
13849 first = 0;
13850 sep = "";
13851 }
13852 else
13853 {
13854 sep = ",";
13855 }
13856 ret = ret + sep + "FLAG_ACTIVITY_NO_ANIMATION";
13857 }
13858 if ((flags & FLAG_ACTIVITY_CLEAR_TASK) == FLAG_ACTIVITY_CLEAR_TASK)
13859 {
13860 if (first == 1)
13861 {
13862 first = 0;
13863 sep = "";
13864 }
13865 else
13866 {
13867 sep = ",";
13868 }
13869 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_TASK";
13870 }
13871 if ((flags & FLAG_ACTIVITY_TASK_ON_HOME) == FLAG_ACTIVITY_TASK_ON_HOME)
13872 {
13873 if (first == 1)
13874 {
13875 first = 0;
13876 sep = "";
13877 }
13878 else
13879 {
13880 sep = ",";
13881 }
13882 ret = ret + sep + "FLAG_ACTIVITY_TASK_ON_HOME";
13883 }
13884
13885 if ((flags & FLAG_GRANT_READ_URI_PERMISSION) == FLAG_GRANT_READ_URI_PERMISSION)
13886 {
13887 if (first == 1)
13888 {
13889 first = 0;
13890 sep = "";
13891 }
13892 else
13893 {
13894 sep = ",";
13895 }
13896 ret = ret + sep + "FLAG_GRANT_READ_URI_PERMISSION";
13897 }
13898
13899 if ((flags & FLAG_GRANT_WRITE_URI_PERMISSION) == FLAG_GRANT_WRITE_URI_PERMISSION)
13900 {
13901 if (first == 1)
13902 {
13903 first = 0;
13904 sep = "";
13905 }
13906 else
13907 {
13908 sep = ",";
13909 }
13910 ret = ret + sep + "FLAG_GRANT_WRITE_URI_PERMISSION";
13911 }
13912
13913 if ((flags & FLAG_FROM_BACKGROUND) == FLAG_FROM_BACKGROUND)
13914 {
13915 if (first == 1)
13916 {
13917 first = 0;
13918 sep = "";
13919 }
13920 else
13921 {
13922 sep = ",";
13923 }
13924 ret = ret + sep + "FLAG_FROM_BACKGROUND";
13925 }
13926 if ((flags & FLAG_DEBUG_LOG_RESOLUTION) == FLAG_DEBUG_LOG_RESOLUTION)
13927 {
13928 if (first == 1)
13929 {
13930 first = 0;
13931 sep = "";
13932 }
13933 else
13934 {
13935 sep = ",";
13936 }
13937 ret = ret + sep + "FLAG_DEBUG_LOG_RESOLUTION";
13938 }
13939 if ((flags & FLAG_EXCLUDE_STOPPED_PACKAGES) == FLAG_EXCLUDE_STOPPED_PACKAGES)
13940 {
13941 if (first == 1)
13942 {
13943 first = 0;
13944 sep = "";
13945 }
13946 else
13947 {
13948 sep = ",";
13949 }
13950 ret = ret + sep + "FLAG_EXCLUDE_STOPPED_PACKAGES";
13951 }
13952 if ((flags & FLAG_INCLUDE_STOPPED_PACKAGES) == FLAG_INCLUDE_STOPPED_PACKAGES)
13953 {
13954 if (first == 1)
13955 {
13956 first = 0;
13957 sep = "";
13958 }
13959 else
13960 {
13961 sep = ",";
13962 }
13963 ret = ret + sep + "FLAG_INCLUDE_STOPPED_PACKAGES";
13964 }
13965 if ((flags & FLAG_ACTIVITY_NO_HISTORY) == FLAG_ACTIVITY_NO_HISTORY)
13966 {
13967 if (first == 1)
13968 {
13969 first = 0;
13970 sep = "";
13971 }
13972 else
13973 {
13974 sep = ",";
13975 }
13976 ret = ret + sep + "FLAG_ACTIVITY_NO_HISTORY";
13977 }
13978 if ((flags & FLAG_ACTIVITY_SINGLE_TOP) == FLAG_ACTIVITY_SINGLE_TOP)
13979 {
13980 if (first == 1)
13981 {
13982 first = 0;
13983 sep = "";
13984 }
13985 else
13986 {
13987 sep = ",";
13988 }
13989 ret = ret + sep + "FLAG_ACTIVITY_SINGLE_TOP";
13990 }
13991 if ((flags & FLAG_ACTIVITY_NEW_TASK) == FLAG_ACTIVITY_NEW_TASK)
13992 {
13993 if (first == 1)
13994 {
13995 first = 0;
13996 sep = "";
13997 }
13998 else
13999 {
14000 sep = ",";
14001 }
14002 ret = ret + sep + "FLAG_ACTIVITY_NEW_TASK";
14003 }
14004 if ((flags & FLAG_ACTIVITY_MULTIPLE_TASK) == FLAG_ACTIVITY_MULTIPLE_TASK)
14005 {
14006 if (first == 1)
14007 {
14008 first = 0;
14009 sep = "";
14010 }
14011 else
14012 {
14013 sep = ",";
14014 }
14015 ret = ret + sep + "FLAG_ACTIVITY_MULTIPLE_TASK";
14016 }
14017 if ((flags & FLAG_ACTIVITY_CLEAR_TOP) == FLAG_ACTIVITY_CLEAR_TOP)
14018 {
14019 if (first == 1)
14020 {
14021 first = 0;
14022 sep = "";
14023 }
14024 else
14025 {
14026 sep = ",";
14027 }
14028 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_TOP";
14029 }
14030 if ((flags & FLAG_ACTIVITY_FORWARD_RESULT) == FLAG_ACTIVITY_FORWARD_RESULT)
14031 {
14032 if (first == 1)
14033 {
14034 first = 0;
14035 sep = "";
14036 }
14037 else
14038 {
14039 sep = ",";
14040 }
14041 ret = ret + sep + "FLAG_ACTIVITY_FORWARD_RESULT";
14042 }
14043 if ((flags & FLAG_ACTIVITY_PREVIOUS_IS_TOP) == FLAG_ACTIVITY_PREVIOUS_IS_TOP)
14044 {
14045 if (first == 1)
14046 {
14047 first = 0;
14048 sep = "";
14049 }
14050 else
14051 {
14052 sep = ",";
14053 }
14054 ret = ret + sep + "FLAG_ACTIVITY_PREVIOUS_IS_TOP";
14055 }
14056
14057 return ret;
14058 }
14059
14060 static boolean want_tunnel_extrapolation()
14061 {
14062 if ((!isGPSFix) && (pos_is_underground == 1) && (NavitGraphics.CallbackDestinationValid2() > 0))
14063 {
14064 // gps fix is lost
14065 // and
14066 // our position is underground
14067 // and
14068 // we have a destination set
14069 //
14070 // --> we want tunnel extrapolation
14071 return true;
14072 }
14073
14074 return false;
14075 }
14076
14077 public static void applySharedTheme(Activity act, int Theme_id)
14078 {
14079 act.setTheme(Theme_id);
14080 }
14081
14082 private com.zoffcc.applications.zanavi_msg.ZListener.Stub zclientListener = new com.zoffcc.applications.zanavi_msg.ZListener.Stub()
14083 {
14084 @Override
14085 public String handleUpdated(String data) throws RemoteException
14086 {
14087 // Log.i("NavitPlugin", "update from Plugin=" + data);
14088 return "Navit says:\"PONG\"";
14089 }
14090 };
14091
14092 static Object sync_plugin_send = new Object();
14093
14094 public static void send_data_to_plugin_bg(final int msg_cat, final String data)
14095 {
14096 // send data to plugin (plugin will send to server) in another task! --------------------------
14097 new AsyncTask<Void, Void, String>()
14098 {
14099 @Override
14100 protected String doInBackground(Void... params)
14101 {
14102 synchronized (sync_plugin_send)
14103 {
14104 try
14105 {
14106 if (plugin_api == null)
14107 {
14108 try
14109 {
14110 Thread.sleep(3000); // wait until the service is bound
14111 }
14112 catch (Exception e)
14113 {
14114 }
14115 }
14116
14117 String response = plugin_api.getResult(PLUGIN_MSG_ID, msg_cat, data);
14118
14119 }
14120 catch (RemoteException e)
14121 {
14122 // Log.e("NavitPlugin", "Failed(1) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14123 }
14124 catch (Exception e)
14125 {
14126 // Log.e("NavitPlugin", "Failed(2) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14127 }
14128 }
14129 return "";
14130 }
14131
14132 @Override
14133 protected void onPostExecute(String msg)
14134 {
14135
14136 }
14137 }.execute(null, null, null);
14138 // send data to plugin (plugin will send to server) in another task! --------------------------
14139 }
14140
14141 private ServiceConnection serviceConnection = new ServiceConnection()
14142 {
14143 @Override
14144 public void onServiceConnected(ComponentName name, IBinder service)
14145 {
14146 Log.i("NavitPlugin", "Service connection established");
14147
14148 // that's how we get the client side of the IPC connection
14149 plugin_api = ZanaviCloudApi.Stub.asInterface((IBinder) service);
14150 try
14151 {
14152 plugin_api.addListener(zclientListener);
14153 }
14154 catch (RemoteException e)
14155 {
14156 Log.e("NavitPlugin", "Failed(1) to add listener", e);
14157 }
14158 catch (Exception e)
14159 {
14160 Log.e("NavitPlugin", "Failed(2) to add listener", e);
14161 }
14162
14163 send_installed_maps_to_plugin();
14164 send_data_to_plugin_bg(PLUGIN_MSG_CAT_zanavi_version, Navit.NavitAppVersion);
14165 }
14166
14167 @Override
14168 public void onServiceDisconnected(ComponentName name)
14169 {
14170 plugin_api = null;
14171 Log.i("NavitPlugin", "Service connection closed");
14172 }
14173 };
14174
14175 /**
14176 * send installed maps and download date/time (time up to minute) in UTC to plugin
14177 */
14178 static void send_installed_maps_to_plugin()
14179 {
14180 try
14181 {
14182 /*
14183 * { "201502032311":"austria.bin","201502032312":"germany.bin" }
14184 */
14185
14186 String data = "";
14187
14188 // dirty hardcode JSON data struct
14189 final String maps_and_timestamp_data_start = "{ \"";
14190 final String maps_and_timestamp_data_sep1 = "\":\"";
14191 final String maps_and_timestamp_data_sep2 = "\",\"";
14192 final String maps_and_timestamp_data_end = "\" }";
14193
14194 NavitMapDownloader.init_cat_file_maps_timestamps();
14195
14196 data = data + maps_and_timestamp_data_start;
14197
14198 String map_name = "";
14199 Iterator<String> k = NavitMapDownloader.map_catalogue_date.listIterator();
14200 while (k.hasNext())
14201 {
14202 map_name = k.next();
14203 data = data + map_name.split(":", 2)[1];
14204 data = data + maps_and_timestamp_data_sep1;
14205 data = data + map_name.split(":", 2)[0];
14206 if (k.hasNext())
14207 {
14208 data = data + maps_and_timestamp_data_sep2;
14209 }
14210 }
14211 data = data + maps_and_timestamp_data_end;
14212
14213 // System.out.println("PLUGIN:MAPS:" + data);
14214
14215 send_data_to_plugin_bg(PLUGIN_MSG_CAT_installed_maps, data);
14216 }
14217 catch (Exception e)
14218 {
14219 }
14220 }
14221
14222 static boolean have_maps_installed()
14223 {
14224 int count_maps_installed = NavitMapDownloader.cat_file_maps_have_installed_any();
14225 if (count_maps_installed == 0)
14226 {
14227 return false;
14228 }
14229 else
14230 {
14231 return true;
14232 }
14233 }
14234
14235 /**
14236 * auto start map download/update
14237 *
14238 * @param map_name
14239 * mapfilename with ending ".bin"
14240 */
14241 void auto_start_update_map(String map_name)
14242 {
14243
14244 int count = NavitMapDownloader.z_OSM_MAPS.length;
14245 Navit.download_map_id = -1;
14246 for (int i = 0; i < count; i++)
14247 {
14248 if (!NavitMapDownloader.z_OSM_MAPS[i].is_continent)
14249 {
14250 // System.out.println("mmm1=" + NavitMapDownloader.z_OSM_MAPS[i].url);
14251 if (NavitMapDownloader.z_OSM_MAPS[i].url.equals(map_name))
14252 {
14253 Navit.download_map_id = i;
14254 System.out.println("mMM2=" + NavitMapDownloader.z_OSM_MAPS[i].map_name);
14255 }
14256 }
14257 }
14258
14259 // show the map download progressbar, and download the map
14260 if (Navit.download_map_id > -1)
14261 {
14262 // new method in service
14263 Message msg = progress_handler.obtainMessage();
14264 Bundle b = new Bundle();
14265 msg.what = 22;
14266 progress_handler.sendMessage(msg);
14267 }
14268 }
14269
14270 void show_case_001()
14271 {
14272 // try
14273 // {
14274 // new ShowcaseView.Builder(this).setTarget(new ViewTarget(R.id.no_maps_button, this)).setContentTitle("").setContentText("").singleShot(Navit.SHOWCASEVIEW_ID_001).build();
14275 // }
14276 // catch (Exception e1)
14277 // {
14278 // }
14279 // catch (NoSuchMethodError e2)
14280 // {
14281 // }
14282 // catch (NoClassDefFoundError e3)
14283 // {
14284 // }
14285 }
14286
14287 static void set_zoom_level(int want_zoom_level)
14288 {
14289 try
14290 {
14291 Bundle b = new Bundle();
14292 Message msg = new Message();
14293 b.putInt("Callback", 33);
14294 b.putString("s", Integer.toString(want_zoom_level));
14295 msg.setData(b);
14296 NavitGraphics.callback_handler.sendMessage(msg);
14297 }
14298 catch (Exception e)
14299 {
14300 e.printStackTrace();
14301 }
14302 }
14303
14304 static void set_zoom_level_no_draw(int want_zoom_level)
14305 {
14306 try
14307 {
14308 Bundle b = new Bundle();
14309 Message msg = new Message();
14310 b.putInt("Callback", 105);
14311 b.putString("s", Integer.toString(want_zoom_level));
14312 msg.setData(b);
14313 NavitGraphics.callback_handler.sendMessage(msg);
14314 }
14315 catch (Exception e)
14316 {
14317 e.printStackTrace();
14318 }
14319 }
14320
14321 static void draw_map()
14322 {
14323 try
14324 {
14325 // draw map no-async
14326 Message msg = new Message();
14327 Bundle b = new Bundle();
14328 b.putInt("Callback", 64);
14329 msg.setData(b);
14330 NavitGraphics.callback_handler.sendMessage(msg);
14331 }
14332 catch (Exception e)
14333 {
14334 e.printStackTrace();
14335 }
14336 }
14337
14338 final static int bottom_bar_snap_duration = 190;
14339
14340 void animate_bottom_bar_up()
14341 {
14342 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
14343 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -cur_y_margin_bottom_bar_touch);
14344 animation.setDuration(bottom_bar_snap_duration); // animation duration
14345 animation.setFillAfter(true);
14346 animation.setFillEnabled(true);
14347 animation.setRepeatCount(0); // animation repeat count
14348 animation.setAnimationListener(new AnimationListener()
14349 {
14350 @Override
14351 public void onAnimationStart(Animation animation)
14352 {
14353 }
14354
14355 @Override
14356 public void onAnimationRepeat(Animation animation)
14357 {
14358 }
14359
14360 @Override
14361 public void onAnimationEnd(Animation animation)
14362 {
14363 cur_y_margin_bottom_bar_touch = 0;
14364 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14365 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14366 a.setLayoutParams(relativeParams);
14367 a.requestLayout();
14368
14369 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14370 anim.setFillAfter(true);
14371 anim.setFillEnabled(true);
14372 anim.setDuration(1);
14373 a.startAnimation(anim);
14374 }
14375 });
14376 a.startAnimation(animation);
14377 }
14378
14379 static void animate_bottom_bar_down()
14380 {
14381 final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide);
14382
14383 // System.out.println("FRAG:animate_bottom_bar_down:014");
14384
14385 // set bottom end positon correctly??
14386 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14387
14388 final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch);
14389 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); // new TranslateAnimation(xFrom,xTo, yFrom,yTo)
14390 animation.setDuration(bottom_bar_snap_duration); // animation duration
14391 animation.setFillAfter(true);
14392 animation.setFillEnabled(true);
14393 animation.setRepeatCount(0); // animation repeat count
14394 animation.setAnimationListener(new AnimationListener()
14395 {
14396
14397 @Override
14398 public void onAnimationStart(Animation animation)
14399 {
14400 }
14401
14402 @Override
14403 public void onAnimationRepeat(Animation animation)
14404 {
14405 }
14406
14407 @Override
14408 public void onAnimationEnd(Animation animation)
14409 {
14410 // set bottom end positon correctly??
14411 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14412
14413 cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch;
14414 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14415 relativeParams.setMargins(0, (int) bottom_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14416 a.setLayoutParams(relativeParams);
14417 a.requestLayout();
14418
14419 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14420 anim.setFillAfter(true);
14421 anim.setFillEnabled(true);
14422 anim.setDuration(1);
14423 a.startAnimation(anim);
14424
14425 // remove roadbook fragment -----------
14426 try
14427 {
14428 if (road_book != null)
14429 {
14430 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
14431 // System.out.println("FRAG:dettach:002");
14432 fragmentTransaction.detach(road_book);
14433 fragmentTransaction.remove(road_book).commit();
14434 road_book = null;
14435 }
14436 }
14437 catch (Exception ef)
14438 {
14439 }
14440 // remove roadbook fragment -----------
14441
14442 }
14443 });
14444 a.startAnimation(animation);
14445 }
14446
14447 synchronized static int find_max_font_size_for_height(String sample_text, int height, int max_font_size, int padding_in_dp)
14448 {
14449 String s = sample_text;
14450 int bh = 0;
14451 Paint p = new Paint();
14452 Rect bounds = new Rect();
14453 p.setTextSize(max_font_size);
14454 // p.measureText(s);
14455 p.getTextBounds(s, 0, s.length(), bounds);
14456
14457 int ret_font_size = max_font_size;
14458
14459 int loop_counter_max = 400;
14460 int loop_counter = 0;
14461 int padding_in_px = 0;
14462 if (padding_in_dp > 0)
14463 {
14464 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14465 }
14466
14467 bh = bounds.height();
14468 //System.out.println("bh(1)=" + bh);
14469 while ((bh + padding_in_px) > height)
14470 {
14471 loop_counter++;
14472 if (loop_counter > loop_counter_max)
14473 {
14474 break;
14475 }
14476
14477 ret_font_size--;
14478 p.setTextSize(ret_font_size);
14479 // p.measureText(s);
14480 p.getTextBounds(s, 0, s.length(), bounds);
14481 bh = bounds.height();
14482 }
14483
14484 return ret_font_size;
14485 }
14486
14487 synchronized static int find_max_letters_for_width_and_fontsize(String max_length_text, int width, int max_font_size, int padding_in_dp)
14488 {
14489 int ret_max_letters = 10;
14490
14491 int padding_in_px = 0;
14492 if (padding_in_dp > 0)
14493 {
14494 //System.out.println("aaa2:l:1:x:" + padding_in_dp);
14495 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14496 //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);
14497 }
14498 //System.out.println("aaa2:l:1:x:1=" + padding_in_px);
14499
14500 int c = 0;
14501 Paint p = new Paint();
14502 p.setTextSize(max_font_size);
14503
14504 String s = max_length_text;
14505
14506 if ((s == null) || (s.equals("")))
14507 {
14508 s = "Mlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwo";
14509 }
14510
14511 int l = s.length();
14512 ret_max_letters = l;
14513 float mt = p.measureText(s);
14514 //System.out.println("aaa2:l:1:" + l + " " + s);
14515 //System.out.println("aaa2:l:22:." + mt + " padding_in_px=" + padding_in_px + " " + width);
14516
14517 while (mt + padding_in_px > width)
14518 {
14519 //System.out.println("aaa2:l:22:+" + mt + " " + padding_in_px + " " + width);
14520
14521 c++;
14522 if (c == l)
14523 {
14524 // no more letters
14525 //System.out.println("aaa2:l:1:no more letters:" + l + " " + s);
14526 break;
14527 }
14528 s = s.substring(0, s.length() - 1);
14529 mt = p.measureText(s);
14530 ret_max_letters--;
14531 }
14532
14533 //System.out.println("aaa2:l:1:res=" + ret_max_letters);
14534 return ret_max_letters;
14535 }
14536
14537 synchronized static int find_max_font_size_for_width(String sample_text, int width, int max_font_size, int padding_in_dp)
14538 {
14539 final String s = sample_text;
14540 int bh = 0;
14541 Paint p = new Paint();
14542 Rect bounds = new Rect();
14543 p.setTextSize(max_font_size);
14544 p.getTextBounds(s, 0, s.length(), bounds);
14545
14546 int ret_font_size = max_font_size;
14547
14548 int loop_counter_max = 400;
14549 int loop_counter = 0;
14550 int padding_in_px = 0;
14551 if (padding_in_dp > 0)
14552 {
14553 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14554 }
14555
14556 bh = bounds.width();
14557 while ((bh + padding_in_px) > width)
14558 {
14559 loop_counter++;
14560 if (loop_counter > loop_counter_max)
14561 {
14562 break;
14563 }
14564
14565 ret_font_size--;
14566 p.setTextSize(ret_font_size);
14567 p.getTextBounds(s, 0, s.length(), bounds);
14568 bh = bounds.width();
14569 // mt = p.measureText(s);
14570 }
14571
14572 return ret_font_size;
14573 }
14574
14575 static int last_orientation = Configuration.ORIENTATION_LANDSCAPE;
14576
14577 @Override
14578 public void onConfigurationChanged(Configuration newConfig)
14579 {
14580 super.onConfigurationChanged(newConfig);
14581
14582 if (last_orientation != newConfig.orientation)
14583 {
14584 // Checks the orientation of the screen
14585 if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
14586 {
14587 // setContentView(R.layout.main_layout);
14588
14589 // -- bottom bar --
14590 int h = NavitGraphics.mCanvasHeight;
14591 try
14592 {
14593 int h001;
14594 android.view.ViewGroup.LayoutParams lp001;
14595
14596 View v003 = (View) findViewById(R.id.osd_nextturn_new);
14597 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
14598 lp001 = v003.getLayoutParams();
14599 lp001.height = h001;
14600 v003.requestLayout();
14601
14602 v003 = (View) findViewById(R.id.bottom_bar);
14603 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
14604 lp001 = v003.getLayoutParams();
14605 lp001.height = h001;
14606 v003.requestLayout();
14607
14608 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
14609 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
14610 lp001 = v002.getLayoutParams();
14611 lp001.height = h001;
14612 v002.requestLayout();
14613
14614 v003 = (View) findViewById(R.id.osd_timetodest_new);
14615 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
14616 lp001 = v003.getLayoutParams();
14617 lp001.height = h001;
14618 v003.requestLayout();
14619
14620 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
14621 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
14622 lp001 = v002.getLayoutParams();
14623 lp001.height = h001;
14624 v002.requestLayout();
14625
14626 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
14627 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
14628 lp001 = v001.getLayoutParams();
14629 lp001.height = h001;
14630 v001.requestLayout();
14631
14632 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
14633 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
14634 v003 = (View) findViewById(R.id.view_speeding);
14635 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
14636 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
14637 v003.setLayoutParams(relativeParams_001);
14638 v003.requestLayout();
14639
14640 // Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
14641
14642 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
14643 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
14644
14645 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
14646 }
14647 catch (Exception e)
14648 {
14649 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
14650 }
14651 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
14652 // -- bottom bar --
14653 }
14654 else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
14655 {
14656 // setContentView(R.layout.main_layout);
14657
14658 // -- bottom bar --
14659 int h = NavitGraphics.mCanvasHeight;
14660 try
14661 {
14662 int h001;
14663 android.view.ViewGroup.LayoutParams lp001;
14664
14665 View v003 = (View) findViewById(R.id.osd_nextturn_new);
14666 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
14667 lp001 = v003.getLayoutParams();
14668 lp001.height = h001;
14669 v003.requestLayout();
14670
14671 v003 = (View) findViewById(R.id.bottom_bar);
14672 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
14673 lp001 = v003.getLayoutParams();
14674 lp001.height = h001;
14675 v003.requestLayout();
14676
14677 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
14678 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
14679 lp001 = v002.getLayoutParams();
14680 lp001.height = h001;
14681 v002.requestLayout();
14682
14683 v003 = (View) findViewById(R.id.osd_timetodest_new);
14684 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
14685 lp001 = v003.getLayoutParams();
14686 lp001.height = h001;
14687 v003.requestLayout();
14688
14689 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
14690 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
14691 lp001 = v002.getLayoutParams();
14692 lp001.height = h001;
14693 v002.requestLayout();
14694
14695 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
14696 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
14697 lp001 = v001.getLayoutParams();
14698 lp001.height = h001;
14699 v001.requestLayout();
14700
14701 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
14702 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
14703 v003 = (View) findViewById(R.id.view_speeding);
14704 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
14705 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
14706 v003.setLayoutParams(relativeParams_001);
14707 v003.requestLayout();
14708
14709 // Toast.makeText(this, "protrait", Toast.LENGTH_SHORT).show();
14710
14711 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
14712 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
14713
14714 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
14715 }
14716 catch (Exception e)
14717 {
14718 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
14719 }
14720 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
14721 // -- bottom bar --
14722 }
14723
14724 last_orientation = newConfig.orientation;
14725 }
14726 }
14727
14728 static void long_toast(String msg)
14729 {
14730 try
14731 {
14732 Message msg7 = Navit_progress_h.obtainMessage();
14733 Bundle b7 = new Bundle();
14734 msg7.what = 2; // long Toast message
14735 b7.putString("text", msg);
14736 msg7.setData(b7);
14737 Navit_progress_h.sendMessage(msg7);
14738 }
14739 catch (Exception e)
14740 {
14741 }
14742 }
14743
14744 static void short_toast(String msg)
14745 {
14746 try
14747 {
14748 Message msg7 = Navit_progress_h.obtainMessage();
14749 Bundle b7 = new Bundle();
14750 msg7.what = 3; // short Toast message
14751 b7.putString("text", msg);
14752 msg7.setData(b7);
14753 Navit_progress_h.sendMessage(msg7);
14754 }
14755 catch (Exception e)
14756 {
14757 }
14758 }
14759
14760 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)
14761 {
14762 if (p.PREF_routing_engine == 1)
14763 {
14764 route_online_OSRM(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
14765 }
14766 else if (p.PREF_routing_engine == 0)
14767 {
14768 route_offline_ZANavi(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
14769 }
14770 }
14771
14772 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)
14773 {
14774 if (remember_dest)
14775 {
14776 try
14777 {
14778 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
14779 // save points
14780 write_map_points();
14781 }
14782 catch (Exception e)
14783 {
14784 e.printStackTrace();
14785 }
14786 }
14787
14788 // DEBUG: clear route rectangle list
14789 NavitGraphics.route_rects.clear();
14790
14791 if (NavitGraphics.navit_route_status == 0)
14792 {
14793 short_toast(Navit.get_text("setting destination to") + "\n" + addr);
14794
14795 Navit.destination_set();
14796
14797 Message msg = new Message();
14798 Bundle b = new Bundle();
14799 b.putInt("Callback", 3);
14800 b.putString("lat", "" + lat_end);
14801 b.putString("lon", "" + lon_end);
14802 b.putString("q", addr);
14803 msg.setData(b);
14804 NavitGraphics.callback_handler.sendMessage(msg);
14805 }
14806 else
14807 {
14808 short_toast(Navit.get_text("new Waypoint") + "\n" + addr);
14809
14810 Message msg = new Message();
14811 Bundle b = new Bundle();
14812 b.putInt("Callback", 48);
14813 b.putString("lat", "" + lat_end);
14814 b.putString("lon", "" + lon_end);
14815 b.putString("q", addr);
14816 msg.setData(b);
14817 NavitGraphics.callback_handler.sendMessage(msg);
14818 }
14819
14820 }
14821
14822 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)
14823 {
14824 // http://router.project-osrm.org/viaroute?loc=46.3456438,17.450&loc=47.34122,17.5332&instructions=false&alt=false
14825
14826 if (!start_coords_valid)
14827 {
14828 location_coords cur_target = new location_coords();
14829 try
14830 {
14831 geo_coord tmp = get_current_vehicle_position();
14832 cur_target.lat = tmp.Latitude;
14833 cur_target.lon = tmp.Longitude;
14834 }
14835 catch (Exception e)
14836 {
14837 }
14838
14839 try
14840 {
14841 lat_start = (float) cur_target.lat;
14842 lon_start = (float) cur_target.lon;
14843 }
14844 catch (Exception e)
14845 {
14846 e.printStackTrace();
14847 Log.e("Navit", "problem with location!");
14848 }
14849 }
14850
14851 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);
14852
14853 // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
14854 // StrictMode.setThreadPolicy(policy);
14855
14856 try
14857 {
14858 // System.out.println("XML:S:001 url=" + request_url);
14859 final URL url = new URL(request_url);
14860 // System.out.println("XML:S:002");
14861 // SAXParserFactory factory = SAXParserFactory.newInstance();
14862 // System.out.println("XML:S:003");
14863 // SAXParser parser = factory.newSAXParser();
14864 // System.out.println("XML:S:004");
14865 // XMLReader xmlreader = parser.getXMLReader();
14866 // System.out.println("XML:S:005");
14867 // xmlreader.setContentHandler(new ZANaviXMLHandler());
14868 // System.out.println("XML:S:006");
14869
14870 final Thread add_to_route = new Thread()
14871 {
14872 @Override
14873 public void run()
14874 {
14875 try
14876 {
14877
14878 // --------------
14879 // --------------
14880 // --------------
14881 // ------- allow this HTTPS cert ---
14882 // --------------
14883 // --------------
14884 // --------------
14885 // X509HostnameVerifier hnv = new X509HostnameVerifier()
14886 // {
14887 //
14888 // @Override
14889 // public void verify(String hostname, SSLSocket arg1) throws IOException
14890 // {
14891 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14892 // }
14893 //
14894 // @Override
14895 // public void verify(String hostname, X509Certificate cert) throws SSLException
14896 // {
14897 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14898 // }
14899 //
14900 // @Override
14901 // public void verify(String hostname, String[] cns, String[] subjectAlts) throws SSLException
14902 // {
14903 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14904 // }
14905 //
14906 // @Override
14907 // public boolean verify(String hostname, SSLSession session)
14908 // {
14909 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14910 // return true;
14911 // }
14912 // };
14913 //
14914 // SSLContext context = SSLContext.getInstance("TLS");
14915 // context.init(null, new X509TrustManager[] { new X509TrustManager()
14916 // {
14917 // public java.security.cert.X509Certificate[] getAcceptedIssuers()
14918 // {
14919 // return new java.security.cert.X509Certificate[0];
14920 // }
14921 //
14922 // @Override
14923 // public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
14924 // {
14925 // }
14926 //
14927 // @Override
14928 // public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
14929 // {
14930 // }
14931 // } }, new SecureRandom());
14932 // javax.net.ssl.SSLSocketFactory sslf = context.getSocketFactory();
14933 //
14934 // HostnameVerifier hnv_default = HttpsURLConnection.getDefaultHostnameVerifier();
14935 // javax.net.ssl.SSLSocketFactory sslf_default = HttpsURLConnection.getDefaultSSLSocketFactory();
14936 // HttpsURLConnection.setDefaultHostnameVerifier(hnv);
14937 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf);
14938 //
14939 // DefaultHttpClient client = new DefaultHttpClient();
14940 //
14941 // SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
14942 // SchemeRegistry registry = new SchemeRegistry();
14943 // registry.register(new Scheme("https", socketFactory, 443));
14944 // ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(client.getParams(), registry);
14945 // DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
14946 //
14947 // socketFactory.setHostnameVerifier(hnv);
14948 //
14949 // HttpGet get_request = new HttpGet(request_url);
14950 // HttpResponse http_response = httpClient.execute(get_request);
14951 // HttpEntity responseEntity = http_response.getEntity();
14952 //
14953 // HttpsURLConnection.setDefaultHostnameVerifier(hnv_default);
14954 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf_default);
14955 // --------------
14956 // --------------
14957 // --------------
14958 // ------- allow this HTTPS cert ---
14959 // --------------
14960 // --------------
14961 // --------------
14962
14963 InputSource is = new InputSource();
14964 is.setEncoding("utf-8");
14965 // is.setByteStream(responseEntity.getContent());
14966 is.setByteStream(url.openStream());
14967 // System.out.println("XML:S:007");
14968
14969 String response = slurp(is.getByteStream(), 16384);
14970 // response = response.replaceAll("&", "&amp;");
14971
14972 // System.out.println("XML:S:007.a res=" + response);
14973
14974 final JSONObject obj = new JSONObject(response);
14975
14976 // System.out.println(person.getInt("id"));
14977
14978 final String route_geometry = obj.getString("route_geometry");
14979 final JSONArray route_instructions_array = obj.getJSONArray("route_instructions");
14980
14981 int loop_i = 0;
14982 JSONArray instruction;
14983 int[] instruction_pos = new int[route_instructions_array.length()];
14984 for (loop_i = 0; loop_i < route_instructions_array.length(); loop_i++)
14985 {
14986 instruction = (JSONArray) route_instructions_array.get(loop_i);
14987 instruction_pos[loop_i] = Integer.parseInt(instruction.get(3).toString());
14988 // System.out.println("XML:instr. pos=" + instruction_pos[loop_i]);
14989 }
14990
14991 // System.out.println("XML:S:009 o=" + route_geometry);
14992
14993 List<geo_coord> gc_list = decode_function(route_geometry, 6);
14994
14995 if (gc_list.size() < 2)
14996 {
14997 // no real route found!! (only 1 point)
14998 }
14999 else
15000 {
15001
15002 Message msg = new Message();
15003 Bundle b = new Bundle();
15004
15005 int loop = 0;
15006
15007 geo_coord cur = new geo_coord();
15008 geo_coord old = new geo_coord();
15009 geo_coord corr = new geo_coord();
15010
15011 cur.Latitude = gc_list.get(loop).Latitude;
15012 cur.Longitude = gc_list.get(loop).Longitude;
15013
15014 int first_found = 1;
15015
15016 if (gc_list.size() > 2)
15017 {
15018 int instr_count = 1;
15019
15020 for (loop = 1; loop < gc_list.size(); loop++)
15021 {
15022
15023 old.Latitude = cur.Latitude;
15024 old.Longitude = cur.Longitude;
15025 cur.Latitude = gc_list.get(loop).Latitude;
15026 cur.Longitude = gc_list.get(loop).Longitude;
15027
15028 if ((instruction_pos[instr_count] == loop) || (loop == (gc_list.size() - 1)))
15029 {
15030
15031 if (loop == (gc_list.size() - 1))
15032 {
15033 corr = cur;
15034 }
15035 else
15036 {
15037 corr = get_point_on_line(old, cur, 70);
15038 }
15039
15040 // -- add waypoint --
15041 // b.putInt("Callback", 55548);
15042 // b.putString("lat", "" + corr.Latitude);
15043 // b.putString("lon", "" + corr.Longitude);
15044 // b.putString("q", " ");
15045 // msg.setData(b);
15046 try
15047 {
15048 // NavitGraphics.callback_handler.sendMessage(msg);
15049 if (first_found == 1)
15050 {
15051 first_found = 0;
15052 NavitGraphics.CallbackMessageChannel(55503, corr.Latitude + "#" + corr.Longitude + "#" + "");
15053 // System.out.println("XML:rR:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15054 }
15055 else
15056 {
15057 NavitGraphics.CallbackMessageChannel(55548, corr.Latitude + "#" + corr.Longitude + "#" + "");
15058 // System.out.println("XML:rw:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15059 }
15060 // Thread.sleep(25);
15061 }
15062 catch (Exception e)
15063 {
15064 e.printStackTrace();
15065 }
15066 // -- add waypoint --
15067
15068 instr_count++;
15069
15070 }
15071
15072 }
15073 }
15074
15075 if (remember_dest)
15076 {
15077 try
15078 {
15079 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
15080 // save points
15081 write_map_points();
15082 }
15083 catch (Exception e)
15084 {
15085 e.printStackTrace();
15086 }
15087 }
15088
15089 b.putInt("Callback", 55599);
15090 msg.setData(b);
15091 try
15092 {
15093 // System.out.println("XML:calc:");
15094 Thread.sleep(10);
15095 NavitGraphics.callback_handler.sendMessage(msg);
15096 }
15097 catch (Exception e)
15098 {
15099 e.printStackTrace();
15100 }
15101
15102 }
15103
15104 }
15105 catch (Exception e2)
15106 {
15107 e2.printStackTrace();
15108 }
15109 }
15110 };
15111 add_to_route.start();
15112
15113 // convert to coords -------------
15114 // convert to coords -------------
15115
15116 }
15117 catch (Exception e)
15118 {
15119 // System.out.println("XML:S:EEE");
15120 e.printStackTrace();
15121 }
15122 }
15123
15124 static List<geo_coord> decode_function(String encoded, double precision)
15125 {
15126
15127 precision = Math.pow(10, -precision);
15128 int len = encoded.length();
15129 int index = 0;
15130 int lat = 0;
15131 int lng = 0;
15132 double lat_f;
15133 double lon_f;
15134
15135 final List<geo_coord> latLongList = new ArrayList<geo_coord>();
15136 latLongList.clear();
15137
15138 while (index < len)
15139 {
15140
15141 int b;
15142 int shift = 0;
15143 int result = 0;
15144
15145 do
15146 {
15147 b = encoded.charAt(index++) - 63;
15148 result |= (b & 0x1f) << shift;
15149 shift += 5;
15150
15151 }
15152 while (b >= 0x20);
15153
15154 int dlat = 0;
15155 if ((result & 1) != 0)
15156 {
15157 dlat = ~(result >> 1);
15158 }
15159 else
15160 {
15161 dlat = (result >> 1);
15162 }
15163
15164 lat += dlat;
15165 shift = 0;
15166 result = 0;
15167
15168 do
15169 {
15170 b = encoded.charAt(index++) - 63;
15171 result |= (b & 0x1f) << shift;
15172 shift += 5;
15173 }
15174 while (b >= 0x20);
15175
15176 int dlng = 0;
15177 if ((result & 1) != 0)
15178 {
15179 dlng = ~(result >> 1);
15180 }
15181 else
15182 {
15183 dlng = (result >> 1);
15184 }
15185
15186 lng += dlng;
15187 //array.push( {lat: lat * precision, lng: lng * precision} );
15188 // array.push( [lat * precision, lng * precision] );
15189
15190 // System.out.println("XML:lat=" + (lat * precision) + " lon=" + (lng * precision));
15191
15192 lat_f = lat * precision;
15193 lon_f = lng * precision;
15194
15195 geo_coord gc = new geo_coord();
15196 gc.Latitude = lat_f;
15197 gc.Longitude = lon_f;
15198 latLongList.add(gc);
15199 }
15200
15201 return latLongList;
15202 }
15203
15204 public static class geo_coord
15205 {
15206 public double Latitude;
15207 public double Longitude;
15208 }
15209
15210 static geo_coord get_current_vehicle_position()
15211 {
15212 geo_coord ret = new geo_coord();
15213 String current_target_string2 = NavitGraphics.CallbackGeoCalc(14, 1, 1);
15214 // System.out.println("GET CUR POS:" + current_target_string2);
15215 ret.Latitude = 0;
15216 ret.Longitude = 0;
15217 try
15218 {
15219 String tmp[] = current_target_string2.split(":", 2);
15220 ret.Latitude = Double.parseDouble(tmp[0]);
15221 ret.Longitude = Double.parseDouble(tmp[1]);
15222 }
15223 catch (Exception e)
15224 {
15225 // System.out.println("GET CUR POS:ERROR " + e.getMessage());
15226 }
15227 return ret;
15228 }
15229
15230 static int[] geo_to_px(float lat, float lon)
15231 {
15232 int[] ret = new int[3];
15233
15234 ret[0] = -100;
15235 ret[1] = -100;
15236 ret[2] = 0; // invalid
15237
15238 try
15239 {
15240 String x_y = NavitGraphics.CallbackGeoCalc(2, lat, lon);
15241
15242 if (Navit.GFX_OVERSPILL)
15243 {
15244 String tmp[] = x_y.split(":", 2);
15245 int x = Integer.parseInt(tmp[0]);
15246 int y = Integer.parseInt(tmp[1]);
15247
15248 ret[0] = (int) (((float) x + (float) NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor);
15249 ret[1] = (int) (((float) y + (float) NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15250
15251 ret[2] = 1; // VALID
15252 }
15253 else
15254 {
15255 String tmp[] = x_y.split(":", 2);
15256 int x = Integer.parseInt(tmp[0]);
15257 int y = Integer.parseInt(tmp[1]);
15258
15259 ret[0] = (int) ((float) x * NavitGraphics.Global_dpi_factor);
15260 ret[1] = (int) ((float) y * NavitGraphics.Global_dpi_factor);
15261
15262 ret[2] = 1; // VALID
15263 }
15264
15265 }
15266 catch (Exception e)
15267 {
15268 }
15269
15270 return ret;
15271 }
15272
15273 static geo_coord px_to_geo(int x, int y)
15274 {
15275 geo_coord out = new geo_coord();
15276 try
15277 {
15278
15279 String lat_lon = "";
15280 if (Navit.GFX_OVERSPILL)
15281 {
15282 lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15283 }
15284 else
15285 {
15286 lat_lon = NavitGraphics.CallbackGeoCalc(1, x * NavitGraphics.Global_dpi_factor, y * NavitGraphics.Global_dpi_factor);
15287 }
15288
15289 String tmp[] = lat_lon.split(":", 2);
15290 out.Latitude = Float.parseFloat(tmp[0]);
15291 out.Longitude = Float.parseFloat(tmp[1]);
15292 }
15293 catch (Exception e)
15294 {
15295 }
15296
15297 return out;
15298 }
15299
15300 static double get_percent_coord(double start, double end, int perecent_pos)
15301 {
15302 double out = start + (end - start) * ((float) perecent_pos / 100.0f);
15303 return out;
15304 }
15305
15306 static geo_coord get_point_on_line(geo_coord start, geo_coord end, int perecent_pos)
15307 {
15308 geo_coord out = new geo_coord();
15309
15310 out.Latitude = start.Latitude + (end.Latitude - start.Latitude) * ((float) perecent_pos / 100.0f);
15311 out.Longitude = start.Longitude + (end.Longitude - start.Longitude) * ((float) perecent_pos / 100.0f);
15312
15313 return out;
15314 }
15315
15316 public static String slurp(final InputStream is, final int bufferSize)
15317 {
15318 final char[] buffer = new char[bufferSize];
15319 final StringBuilder out = new StringBuilder();
15320 Reader in = null;
15321
15322 try
15323 {
15324
15325 in = new InputStreamReader(is, "UTF-8");
15326
15327 for (;;)
15328 {
15329 int rsz;
15330 rsz = in.read(buffer, 0, buffer.length);
15331
15332 if (rsz < 0)
15333 {
15334 break;
15335 }
15336 out.append(buffer, 0, rsz);
15337 }
15338
15339 }
15340 catch (IOException e)
15341 {
15342 }
15343 catch (Exception ex)
15344 {
15345 }
15346
15347 return out.toString();
15348 }
15349
15350 public static Handler UIHandler;
15351 static
15352 {
15353 UIHandler = new Handler(Looper.getMainLooper());
15354 }
15355
15356 public static void recalculate_route()
15357 {
15358 try
15359 {
15360 // update route, if a route is set
15361 Message msg = new Message();
15362 Bundle b = new Bundle();
15363 b.putInt("Callback", 73);
15364 msg.setData(b);
15365 NavitGraphics.callback_handler.sendMessage(msg);
15366 }
15367 catch (Exception e)
15368 {
15369 }
15370 }
15371
15372 public static void runOnUI(Runnable runnable)
15373 {
15374 UIHandler.post(runnable);
15375 }
15376
15377 String substring_without_ioobe(String in, int start, int end)
15378 {
15379 String ret = ";:;:****no match****;:;:";
15380
15381 try
15382 {
15383 ret = in.substring(start, end);
15384 }
15385 catch (Exception e)
15386 {
15387 // return dummy-no-match String
15388 }
15389
15390 return ret;
15391 }
15392
15393 static private int get_reglevel()
15394 {
15395 int ret = 0;
15396
15397 try
15398 {
15399 Uri uri = CR_CONTENT_URI;
15400 Cursor c = content_resolver.query(uri, null, null, null, null);
15401
15402 if (c == null)
15403 {
15404 System.out.println("CPVD:Cursor c == null.");
15405 System.out.println("CPVD:reg(0)=" + ret);
15406 return ret;
15407 }
15408
15409 while (c.moveToNext())
15410 {
15411 String column1 = c.getString(0);
15412 String column2 = c.getString(1);
15413 String column3 = c.getString(2);
15414
15415 System.out.println("CPVD:column1=" + column1 + " column2=" + column2 + " column3=" + column3);
15416
15417 if (Integer.parseInt(column1) == 1)
15418 {
15419 if (column2.equals("reg"))
15420 {
15421 ret = Integer.parseInt(column3);
15422 System.out.println("CPVD:reg(1)=" + ret);
15423 }
15424 }
15425 }
15426 c.close();
15427 }
15428 catch (Exception e)
15429 {
15430 e.printStackTrace();
15431 }
15432
15433 System.out.println("CPVD:reg(2)=" + ret);
15434 return ret;
15435 }
15436
15437 static void take_map_screenshot(String dir_name, String name_base)
15438 {
15439 try
15440 {
15441 View v1 = Navit.N_NavitGraphics.view;
15442 v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
15443 v1.setDrawingCacheEnabled(true);
15444 Bitmap bm = v1.getDrawingCache();
15445
15446 FileOutputStream out = null;
15447 try
15448 {
15449 out = new FileOutputStream(dir_name + "/" + name_base + ".png");
15450 bm.compress(Bitmap.CompressFormat.PNG, 100, out);
15451 }
15452 catch (Exception e)
15453 {
15454 e.printStackTrace();
15455 System.out.println("TSCR:004 " + e.getMessage());
15456 }
15457 finally
15458 {
15459 v1.setDrawingCacheEnabled(false);
15460
15461 try
15462 {
15463 if (out != null)
15464 {
15465 out.close();
15466 }
15467 }
15468 catch (IOException e)
15469 {
15470 e.printStackTrace();
15471 }
15472 }
15473 }
15474 catch (Exception e4)
15475 {
15476 }
15477 }
15478 }

   
Visit the ZANavi Wiki