/[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 51 - (show annotations) (download)
Mon Jul 25 19:29:08 2016 UTC (7 years, 8 months ago) by zoff99
File size: 479493 byte(s)
v2.0.52
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2015 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2008 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38
39 package com.zoffcc.applications.zanavi;
40
41 import java.io.File;
42 import java.io.FileInputStream;
43 import java.io.FileNotFoundException;
44 import java.io.FileOutputStream;
45 import java.io.IOException;
46 import java.io.InputStream;
47 import java.io.InputStreamReader;
48 import java.io.ObjectInputStream;
49 import java.io.ObjectOutputStream;
50 import java.io.OutputStream;
51 import java.io.OutputStreamWriter;
52 import java.io.PrintWriter;
53 import java.io.Reader;
54 import java.io.Serializable;
55 import java.io.StringWriter;
56 import java.net.URL;
57 import java.net.URLDecoder;
58 import java.nio.channels.FileChannel;
59 import java.text.DecimalFormat;
60 import java.text.SimpleDateFormat;
61 import java.util.ArrayList;
62 import java.util.Calendar;
63 import java.util.Collections;
64 import java.util.Date;
65 import java.util.HashSet;
66 import java.util.Iterator;
67 import java.util.List;
68 import java.util.Locale;
69 import java.util.Map;
70 import java.util.Random;
71 import java.util.Set;
72 import java.util.TimeZone;
73 import java.util.concurrent.LinkedBlockingQueue;
74
75 import org.json.JSONArray;
76 import org.json.JSONObject;
77 import org.xml.sax.InputSource;
78
79 import android.annotation.SuppressLint;
80 import android.annotation.TargetApi;
81 import android.app.Activity;
82 import android.app.AlertDialog;
83 import android.app.Dialog;
84 import android.app.Notification;
85 import android.app.NotificationManager;
86 import android.app.PendingIntent;
87 import android.app.ProgressDialog;
88 import android.app.backup.BackupManager;
89 import android.content.ActivityNotFoundException;
90 import android.content.ComponentName;
91 import android.content.ContentResolver;
92 import android.content.Context;
93 import android.content.DialogInterface;
94 import android.content.DialogInterface.OnCancelListener;
95 import android.content.Intent;
96 import android.content.ServiceConnection;
97 import android.content.SharedPreferences;
98 import android.content.pm.PackageInfo;
99 import android.content.pm.PackageManager.NameNotFoundException;
100 import android.content.res.AssetManager;
101 import android.content.res.Configuration;
102 import android.content.res.Resources;
103 import android.database.Cursor;
104 import android.graphics.Bitmap;
105 import android.graphics.BitmapFactory;
106 import android.graphics.Color;
107 import android.graphics.Paint;
108 import android.graphics.Rect;
109 import android.graphics.RectF;
110 import android.graphics.Typeface;
111 import android.hardware.Sensor;
112 import android.hardware.SensorEvent;
113 import android.hardware.SensorEventListener;
114 import android.hardware.SensorManager;
115 import android.location.Address;
116 import android.location.Geocoder;
117 import android.location.GpsStatus;
118 import android.location.Location;
119 import android.location.LocationManager;
120 import android.media.AudioManager;
121 import android.media.AudioManager.OnAudioFocusChangeListener;
122 import android.media.ToneGenerator;
123 import android.net.Uri;
124 import android.os.AsyncTask;
125 import android.os.Build;
126 import android.os.Bundle;
127 import android.os.Debug;
128 import android.os.Environment;
129 import android.os.Handler;
130 import android.os.IBinder;
131 import android.os.Looper;
132 import android.os.Message;
133 import android.os.PowerManager;
134 import android.os.RemoteException;
135 import android.os.SystemClock;
136 import android.preference.PreferenceManager;
137 import android.speech.tts.TextToSpeech;
138 import android.support.v4.app.FragmentManager;
139 import android.support.v4.app.FragmentTransaction;
140 import android.support.v7.app.ActionBar;
141 import android.support.v7.app.ActionBarActivity;
142 import android.support.v7.widget.Toolbar;
143 import android.text.Html;
144 import android.text.SpannableString;
145 import android.text.method.LinkMovementMethod;
146 import android.text.util.Linkify;
147 import android.util.DisplayMetrics;
148 import android.util.Log;
149 import android.util.TypedValue;
150 import android.view.Display;
151 import android.view.GestureDetector;
152 import android.view.GestureDetector.SimpleOnGestureListener;
153 import android.view.Gravity;
154 import android.view.KeyEvent;
155 import android.view.Menu;
156 import android.view.MenuItem;
157 import android.view.MotionEvent;
158 import android.view.View;
159 import android.view.ViewConfiguration;
160 import android.view.ViewTreeObserver;
161 import android.view.ViewTreeObserver.OnGlobalLayoutListener;
162 import android.view.Window;
163 import android.view.WindowManager;
164 import android.view.animation.Animation;
165 import android.view.animation.Animation.AnimationListener;
166 import android.view.animation.TranslateAnimation;
167 import android.view.inputmethod.InputMethodManager;
168 import android.widget.Button;
169 import android.widget.FrameLayout;
170 import android.widget.ImageView;
171 import android.widget.LinearLayout;
172 import android.widget.RelativeLayout;
173 import android.widget.TextView;
174 import android.widget.Toast;
175 import bpi.sdbm.illuminance.SolarPosition;
176
177 import com.lamerman.FileDialog;
178 import com.lamerman.SelectionMode;
179 import com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator;
180 import com.luckycatlabs.sunrisesunset.calculator.SolarEventCalculator;
181 import com.luckycatlabs.sunrisesunset.dto.Location2;
182 import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
183 import com.zoffcc.applications.zanavi.NavitOSDJava.drawOSDThread;
184 import com.zoffcc.applications.zanavi.NavitVehicle.location_coords;
185 import com.zoffcc.applications.zanavi.ZANaviListViewAdapter.ListViewItem;
186 import com.zoffcc.applications.zanavi_msg.ZanaviCloudApi;
187
188 import de.oberoner.gpx2navit_txt.MainFrame;
189
190 public class Navit extends ActionBarActivity implements Handler.Callback, SensorEventListener
191 {
192 public static final String VERSION_TEXT_LONG_INC_REV = "3981";
193 public static String NavitAppVersion = "0";
194 public static String NavitAppVersion_prev = "-1";
195 public static String NavitAppVersion_string = "0";
196 public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
197 public static boolean has_hw_menu_button = false;
198 static int NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR = 400;
199 static int actionbar_item_width = 100;
200 static int actionbar_items_will_fit = 2;
201 static boolean actionbar_all_items_will_fit = false;
202 static boolean actionabar_download_icon_visible = false;
203 static boolean is_navigating = false;
204 static boolean is_paused = true;
205
206 static int api_version_int = 6;
207
208 static boolean PAINT_OLD_API = true;
209
210 static long SHOWCASEVIEW_ID_001 = 93457181726L;
211
212 //static final int DEFAULT_THEME_DARK = android.R.style.Theme_WithActionBar;
213 //static final int DEFAULT_THEME_LIGHT = android.R.style.Theme_Material_Light;
214 static final int DEFAULT_THEME_OLD_LIGHT = R.style.CustomActionBarThemeLight;
215 static final int DEFAULT_THEME_OLD_DARK = R.style.CustomActionBarTheme;
216
217 static final int DEFAULT_THEME_OLD_LIGHT_M = R.style.CustomActionBarThemeLightM;
218 static final int DEFAULT_THEME_OLD_DARK_M = R.style.CustomActionBarThemeM;
219
220 // GLSurfaceView glSurfaceView;
221
222 static int OSD_blueish_bg_color = 0;
223
224 // ----------------- DEBUG ----------------
225 // ----------------- DEBUG ----------------
226 // ----------------- DEBUG ----------------
227 static final boolean METHOD_DEBUG = false; // for debugging only, set this to "false" on release builds!!
228 static final boolean DEBUG_DRAW_VEHICLE = true; // if "false" then dont draw green vehicle, set this to "true" on release builds!!
229 static final boolean NAVIT_ALWAYS_UNPACK_XMLFILE = false; // always unpacks the navit.xml file, set this to "false" on release builds!!
230 static final boolean NAVIT_DEBUG_TEXT_VIEW = false; // show overlay with debug messages, set this to "false" on release builds!!
231 static final boolean GFX_OVERSPILL = true; // make gfx canvas bigger for rotation and zoom smoothness, set this to "true" on release builds!!
232 static final boolean DEBUG_LUX_VALUE = false; // show lux values, set to "false" on release builds!!
233 // ----------------- DEBUG ----------------
234 // ----------------- DEBUG ----------------
235 // ----------------- DEBUG ----------------
236
237 // ----------------------------------------
238 // ----------------------------------------
239 static final boolean FDBL = false;
240 static final int CIDEBUG = 0;
241 static boolean CIRUN = false;
242 static int CI_TEST_CASE_NUM = -1;
243 static String CI_TEST_CASE_TEXT = "";
244 // ----------------------------------------
245 // ----------------------------------------
246
247 static final float OVERSPILL_FACTOR = 1.4f; // 20% percent on each side
248
249 // ------------------ BitCoin Addr --------
250 // ------------------ BitCoin Addr --------
251 // ------------------ BitCoin Addr --------
252 final static String BITCOIN_DONATE_ADDR = "1ZANav18WY8ytM7bhnAEBS3bdrTohsD9p";
253 // ------------------ BitCoin Addr --------
254 // ------------------ BitCoin Addr --------
255 // ------------------ BitCoin Addr --------
256
257 private static ZanaviCloudApi plugin_api = null;
258 static final int PLUGIN_MSG_ID = 1;
259 static final int PLUGIN_MSG_CAT_zanavi_version = 1;
260 static final int PLUGIN_MSG_CAT_installed_maps = 2;
261 static final int PLUGIN_MSG_CAT_3d_mode = 3;
262
263 static ZANaviPrefs p = new ZANaviPrefs();
264 static ZANaviPrefs p_old = new ZANaviPrefs();
265 static final int STREET_SEARCH_STRINGS_SAVE_COUNT = 10;
266 static boolean search_ready = false;
267 static boolean search_list_ready = false;
268
269 // static AnimationDrawable mFrameAnimation;
270 static Menu cur_menu = null;
271
272 static long NAVIT_START_INTENT_DRIVE_HOME = 1L;
273
274 static final int NAVIT_BACKBUTTON_TO_EXIT_TIME = 2000; // 2 secs.
275
276 static int NavitOverflowMenuItemID = -1;
277
278 static ContentResolver content_resolver = null;
279 public static final String CR_AUTHORITY = "com.zoffcc.applications.zanavi_udonate.provider";
280 public static final Uri CR_CONTENT_URI = Uri.parse("content://" + CR_AUTHORITY + "/" + "table1");
281
282 public static Intent ZANaviMapDownloaderServiceIntent = null;
283
284 static float last_y_bottom_bar_touch = 0;
285 static float cur_y_margin_bottom_bar_touch = 0;
286 static int map_view_height = 100;
287 static float bottom_y_margin_bottom_bar_touch = 0;
288 static int actionBarHeight = 0;
289 static int bottom_bar_px = 80;
290 static int bottom_bar_slider_shadow_px = 4;
291 static GestureDetector mGestureDetector = null;
292 static int swipeMaxOffPath = 20;
293 static ZANaviRoadbookFragment road_book = null;
294 static FragmentManager fragmentManager = null;
295 static ImageView push_pin_view = null;
296 static List<ListViewItem> road_book_items = null;
297
298 TextToSpeech mTts = null;
299
300 static ToneGenerator toneG = null;
301 static boolean toneG_heared = false;
302
303 public static int Global_Init_Finished = 0; // 0 -> no init
304 // 1 -> all C structures are ready for use
305 public static int Global_Location_update_not_allowed = 0; // 0 -> send location update to C functions
306 // 1 -> DO NOT send location update to C functions, it may crash in this phase
307
308 //static BackupManager backupManager = null;
309 static Object backupManager = null;
310
311 // AlertDialog dialog_info_popup = null;
312 Dialog dialog_info_popup = null;
313 int info_popup_seen_count = 0;
314 final int info_popup_seen_count_max = 2; // must look at the info pop 2 times
315 boolean info_popup_seen_count_end = false;
316
317 static Navit Global_Navit_Object = null;
318 static AssetManager asset_mgr = null;
319
320 static boolean Navit_doubleBackToExitPressedOnce = false;
321
322 // define graphics here (this is bad, please fix me!)
323 public static NavitGraphics N_NavitGraphics = null;
324
325 public static int usedMegs_old = -1;
326 public static String usedMegs_str_old = "";
327 public static int Routgraph_enabled = 0;
328
329 // -------- SUN / MOON ----------
330 long sun_moon__mLastCalcSunMillis = -1L;
331 public double azmiuth_cache = -1;
332 public double zenith_cache = -1;
333 public static String sunrise_cache = "";
334 public static boolean is_night = false;
335 public static boolean is_twilight = false;
336 public static String sunset_cache = "";
337 public static double elevation = 0;
338 public double moon_azimuth_cache = -1;
339 public double moon_evelation_cache = -1;
340 Boolean sun_moon__must_calc_new = true;
341 SunriseSunsetCalculator sun_moon__calc = null;
342 Calendar sun_moon__cx = null;
343 SolarPosition.SunCoordinates sun_moon__sc = null;
344 public static boolean calc_sun_enabled = true;
345 // -------- SUN / MOON ----------
346
347 public static CWorkerThread cwthr = null;
348 public static NavitGraphics NG__map_main = null;
349 public static NavitGraphics NG__vehicle = null;
350 public static NavitVehicle NV = null;
351 public static NavitSpeech2 NSp = null;
352 public static drawOSDThread draw_osd_thread = null;
353
354 public static boolean use_index_search = false;
355 public static boolean index_search_realtime = false;
356
357 static AlertDialog.Builder generic_alert_box = null;
358
359 private Boolean xmlconfig_unpack_file = true;
360 private Boolean write_new_version_file = true;
361 final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
362 final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
363 final static int Navit_Status_NORMAL_STARTUP = 0;
364 static Boolean Navit_DonateVersion_Installed = false;
365 static Boolean Navit_Plugin_001_Installed = false;
366 static Boolean Navit_index_on_but_no_idx_files = false;
367 static Boolean Navit_maps_too_old = false;
368 static Boolean Navit_Largemap_DonateVersion_Installed = false;
369 private int startup_status = Navit_Status_NORMAL_STARTUP;
370 final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
371 static Boolean unsupported = false;
372 static Boolean Navit_maps_loaded = false;
373 final static int Navit_MAX_RECENT_DESTINATIONS = 50;
374 static String debug_item_dump = "";
375 static String global_last_destination_name = "";
376
377 // for future use ...
378 // public static String NavitDataDirectory = "/sdcard/";
379 public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
380 static File[] NavitDataStorageDirs = null;
381
382 public static int GlobalScaleLevel = 0;
383
384 public class CopyFiles
385 {
386 public void copyFiles(File sourceLocation, File targetLocation) throws IOException
387 {
388 if (sourceLocation.isDirectory())
389 {
390 if (!targetLocation.exists())
391 {
392 targetLocation.mkdir();
393 }
394 File[] files = sourceLocation.listFiles();
395 for (File file : files)
396 {
397 InputStream in = new FileInputStream(file);
398 OutputStream out = new FileOutputStream(targetLocation + "/" + file.getName());
399
400 // Copy the bits from input stream to output stream
401 byte[] buf = new byte[1024];
402 int len;
403 while ((len = in.read(buf)) > 0)
404 {
405 out.write(buf, 0, len);
406 }
407 in.close();
408 out.close();
409 }
410
411 }
412 }
413 }
414
415 private static void copyFile(File sourceFile, File destFile) throws IOException
416 {
417 if (!sourceFile.exists())
418 {
419 return;
420 }
421 if (!destFile.exists())
422 {
423 destFile.createNewFile();
424 }
425 FileChannel source = null;
426 FileChannel destination = null;
427 source = new FileInputStream(sourceFile).getChannel();
428 destination = new FileOutputStream(destFile).getChannel();
429 if (destination != null && source != null)
430 {
431 destination.transferFrom(source, 0, source.size());
432 }
433 if (source != null)
434 {
435 source.close();
436 }
437 if (destination != null)
438 {
439 destination.close();
440 }
441
442 }
443
444 public static final class Navit_Address_Result_Struct implements Comparable<Navit_Address_Result_Struct>
445 {
446 String result_type; // TWN,STR,SHN
447 String item_id; // H<ddddd>L<ddddd> -> item.id_hi item.id_lo
448 float lat;
449 float lon;
450 String addr;
451
452 // function to sort address result list
453 public int compareTo(Navit_Address_Result_Struct comp)
454 {
455 return this.addr.toLowerCase().compareTo(comp.addr.toLowerCase());
456 }
457 }
458
459 public static final class Navit_Point_on_Map implements Serializable
460 {
461 /**
462 * struct for a point on the map
463 */
464 private static final long serialVersionUID = 6899215049749155051L;
465 String point_name = "";
466 String addon = null; // null -> normal, "1" -> home location
467 float lat = 0.0f;
468 float lon = 0.0f;
469 }
470
471 static ArrayList<Navit_Point_on_Map> map_points;
472
473 public static Set<String> Navit_Address_Result_double_index = new HashSet<String>();
474
475 public NavitAndroidOverlay NavitAOverlay2;
476 public static NavitAndroidOverlay NavitAOverlay2_s;
477
478 public static final class Navit_OSD_compass
479 {
480 Boolean angle_north_valid = false;
481 float angle_north = 0.0f;
482 Boolean angle_target_valid = false;
483 float angle_target = 0.0f;
484 Boolean direct_distance_to_target_valid = false;
485 String direct_distance_to_target = "";
486 }
487
488 public static final class Navit_OSD_route_001
489 {
490 Boolean driving_distance_to_target_valid = false;
491 String driving_distance_to_target = "";
492 Boolean arriving_time_valid = false;
493 String arriving_time = "";
494 Boolean arriving_secs_to_dest_valid = false;
495 String arriving_secs_to_dest = "";
496 }
497
498 public static final class Navit_OSD_route_nextturn
499 {
500 Boolean nextturn_image_filename_valid = false;
501 String nextturn_image_filename = "";
502 Boolean nextturn_image_valid = false;
503 Bitmap nextturn_image = null;
504 Boolean nextturn_distance_valid = false;
505 String nextturn_distance = "";
506 String nextturn_streetname = "";
507 String nextturn_streetname_systematic = "";
508 }
509
510 public static final class Navit_OSD_scale
511 {
512 Boolean scale_valid = false;
513 String scale_text = "";
514 int base = 0;
515 int var = 0;
516 }
517
518 public static Navit_OSD_compass OSD_compass = new Navit_OSD_compass();
519 public static Navit_OSD_route_001 OSD_route_001 = new Navit_OSD_route_001();
520 public static Navit_OSD_route_nextturn OSD_nextturn = new Navit_OSD_route_nextturn();
521 public static Navit_OSD_scale OSD_scale = new Navit_OSD_scale();
522
523 SimGPS Simulate = null;
524 WatchMem watchmem = null;
525
526 public static int sats = 0;
527 public static int satsInFix = 0;
528
529 // -------------- GPS fix and extrapolation vars -------------
530 // -------------- GPS fix and extrapolation vars -------------
531 // -------------- GPS fix and extrapolation vars -------------
532 static Location mLastLocation = null;
533 static long mLastLocationMillis = -1;
534 static boolean isGPSFix = false;
535 static int pos_is_underground = 0;
536 static boolean tunnel_extrapolation = false;
537 // -------------- GPS fix and extrapolation vars -------------
538 // -------------- GPS fix and extrapolation vars -------------
539 // -------------- GPS fix and extrapolation vars -------------
540
541 // public static Vibrator vibrator = null;
542
543 public Handler handler;
544 static PowerManager.WakeLock wl;
545 static PowerManager.WakeLock wl_cpu;
546 static PowerManager.WakeLock wl_navigating;
547 private NavitActivityResult ActivityResults[];
548 static AudioManager NavitAudioManager = null;
549 public static InputMethodManager mgr = null;
550 public static DisplayMetrics metrics = null;
551 public static Boolean show_soft_keyboard = false;
552 public static Boolean show_soft_keyboard_now_showing = false;
553 public static long last_pressed_menu_key = 0L;
554 public static long time_pressed_menu_key = 0L;
555 private static Intent startup_intent = null;
556 private static long startup_intent_timestamp = 0L;
557 public static String my_display_density = "mdpi";
558 private boolean searchBoxShown = false;
559 public static final int MAPDOWNLOAD_PRI_DIALOG = 1;
560 public static final int MAPDOWNLOAD_SEC_DIALOG = 2;
561 public static final int SEARCHRESULTS_WAIT_DIALOG = 3;
562 public static final int SEARCHRESULTS_WAIT_DIALOG_OFFLINE = 4;
563 public static final int ADDRESS_RESULTS_DIALOG_MAX = 10;
564 public ProgressDialog mapdownloader_dialog_pri = null;
565 public ProgressDialog mapdownloader_dialog_sec = null;
566 public ProgressDialog search_results_wait = null;
567 public ProgressDialog search_results_wait_offline = null;
568 public static Handler Navit_progress_h = null;
569 public static NavitMapDownloader mapdownloader_pri = null;
570 public static NavitMapDownloader mapdownloader_sec = null;
571 public static final int NavitDownloaderPriSelectMap_id = 967;
572 public static final int NavitDownloaderSecSelectMap_id = 968;
573 public static final int NavitDeleteSecSelectMap_id = 969;
574 public static final int NavitRecentDest_id = 970;
575 public static final int NavitGeoCoordEnter_id = 971;
576 public static final int NavitGPXConvChooser_id = 972;
577 public static final int NavitSendFeedback_id = 973;
578 public static final int NavitReplayFileConvChooser_id = 974;
579 public static int download_map_id = 0;
580 ProgressThread progressThread_pri = null;
581 ProgressThread progressThread_sec = null;
582 public static int search_results_towns = 0;
583 public static int search_results_streets = 0;
584 public static int search_results_streets_hn = 0;
585 public static int search_results_poi = 0;
586 public static Boolean search_hide_duplicates = false;
587 public static Boolean NavitStartupAlreadySearching = false;
588 SearchResultsThread searchresultsThread = null;
589 SearchResultsThread searchresultsThread_offline = null;
590 SearchResultsThreadSpinnerThread spinner_thread = null;
591 SearchResultsThreadSpinnerThread spinner_thread_offline = null;
592 public static Boolean NavitAddressSearchSpinnerActive = false;
593 public static final int MAP_NUM_PRIMARY = 11;
594 public static final int NavitAddressSearch_id_offline = 70;
595 public static final int NavitAddressSearch_id_online = 73;
596 public static final int NavitAddressResultList_id = 71;
597 public static final int NavitAddressSearchCountry_id = 74;
598 public static final int NavitMapPreview_id = 75;
599 public static final int NavitAddressSearch_id_gmaps = 76;
600 public static final int NavitAddressSearch_id_sharedest = 77;
601 public static final int ZANaviVoiceInput_id = 78;
602 public static final int NavitDonateFromSearch_id = 79;
603 public static int NavitSearchresultBarIndex = -1;
604 public static String NavitSearchresultBar_title = "";
605 public static String NavitSearchresultBar_text = "";
606 public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();
607
608 public static Boolean DemoVehicle = false;
609
610 static Typeface NavitStreetnameFont = null;
611
612 public SensorManager sensorManager = null;
613 public static float lightsensor_max_value = -1;
614 // static final float lux_darkness_value = 4;
615 Sensor lightSensor = null;
616 SensorEventListener lightSensorEventListener = null;
617 public static boolean night_mode = false;
618 public static float debug_cur_lux_value = -1;
619 //private static SensorManager sensorManager_ = null;
620
621 public static Context getBaseContext_ = null;
622 public static GpsStatus gps_st = null;
623
624 static Bitmap lane_none = null;
625 static Bitmap lane_left = null;
626 static Bitmap lane_right = null;
627 static Bitmap lane_merge_to_left = null;
628 static Bitmap lane_merge_to_right = null;
629 static String lane_destination = "";
630 static String lanes_text = "";
631 static String lanes_text1 = "";
632 static String lane_choices = "";
633 static String lane_choices1 = "";
634 static String lane_choices2 = "";
635 static int lanes_num = 0;
636 static int lanes_num_forward = 0;
637 static int lanes_num1 = 0;
638 static int lanes_num_forward1 = 0;
639 static int seg_len = 0;
640 static int cur_max_speed = -1;
641 static int cur_max_speed_corr = -1;
642 static boolean your_are_speeding = false;
643
644 // ------- new features -----------
645 // ------- new features -----------
646 // ------- new features -----------
647 // static boolean new_features = false; // for development ONLY !!
648 // ------- new features -----------
649 // ------- new features -----------
650 // ------- new features -----------
651
652 public static Bitmap long_green_arrow = null;
653 public static Bitmap menu_button = null;
654 public static RectF menu_button_rect = new RectF(-100, 1, 1, 1);
655 public static RectF menu_button_rect_touch = new RectF(-100, 1, 1, 1);
656 public static Bitmap follow_on = null;
657 public static Bitmap follow_off = null;
658 public static Bitmap follow_current = null;
659 public static Bitmap zoomin = null;
660 public static Bitmap zoomout = null;
661 // public static Bitmap bigmap_bitmap = null;
662 public static Bitmap oneway_arrow = null;
663 public static Bitmap oneway_bicycle_arrow = null;
664 public static Bitmap nav_arrow_stopped = null;
665 public static Bitmap nav_arrow_stopped_small = null;
666 public static Bitmap nav_arrow_moving = null;
667 public static Bitmap nav_arrow_moving_grey = null;
668 public static Bitmap nav_arrow_moving_small = null;
669 public static Bitmap nav_arrow_moving_shadow = null;
670 public static Bitmap nav_arrow_moving_shadow_small = null;
671
672 public static String Navit_last_address_search_string = "";
673 public static String Navit_last_address_hn_string = "";
674 public static Boolean Navit_last_address_full_file_search = false;
675 public static String Navit_last_address_search_country_iso2_string = "";
676 public static int Navit_last_address_search_country_flags = 3;
677 public static int Navit_last_address_search_country_id = 0;
678 public static Boolean Navit_last_address_partial_match = true;
679 public static Geocoder Navit_Geocoder = null;
680 public static String UserAgentString = null;
681 public static String UserAgentString_bind = null;
682 public static Boolean first_ever_startup = false;
683
684 public static Boolean Navit_Announcer = true;
685
686 public static final int MAP_NUM_SECONDARY = 12;
687 static String MAP_FILENAME_PATH = "/sdcard/zanavi/maps/";
688 static String MAPMD5_FILENAME_PATH = "/sdcard/zanavi/md5/";
689 static String CFG_FILENAME_PATH = "/sdcard/zanavi/";
690 static String NAVIT_DATA_DIR = "/data/data/com.zoffcc.applications.zanavi"; // later use: Context.getFilesDir().getPath();
691 static String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
692 static String NAVIT_DATA_DEBUG_DIR = CFG_FILENAME_PATH + "../debug/";
693 static String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
694 static String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
695 static final String Navit_DEST_FILENAME = "destinations.dat";
696 static final String Navit_CENTER_FILENAME = "center.txt";
697
698 static boolean need_recalc_route = false;
699
700 static Resources res_ = null;
701 static Window app_window = null;
702
703 public static String get_text(String in)
704 {
705 return NavitTextTranslations.get_text(in);
706 }
707
708 private boolean extractRes(String resname, String result)
709 {
710 int slash = -1;
711 boolean needs_update = false;
712 File resultfile;
713 Resources res = getResources();
714 Log.e("Navit", "Res Obj " + res);
715 Log.e("Navit", "Res Name " + resname);
716 Log.e("Navit", "result " + result);
717 int id = res.getIdentifier(resname, "raw", "com.zoffcc.applications.zanavi");
718 // int id = res.getIdentifier(resname, "raw", getPackageName());
719
720 Log.e("Navit", "Res ID " + id);
721
722 if (id == 0)
723 {
724 return false;
725 }
726
727 while ((slash = result.indexOf("/", slash + 1)) != -1)
728 {
729 if (slash != 0)
730 {
731 Log.e("Navit", "Checking " + result.substring(0, slash));
732 resultfile = new File(result.substring(0, slash));
733 if (!resultfile.exists())
734 {
735 Log.e("Navit", "Creating dir");
736 if (!resultfile.mkdir()) return false;
737 needs_update = true;
738 }
739 }
740 }
741
742 resultfile = new File(result);
743
744 if (!resultfile.exists())
745 {
746 needs_update = true;
747 }
748
749 if (!needs_update)
750 {
751 try
752 {
753 InputStream resourcestream = res.openRawResource(id);
754 FileInputStream resultfilestream = new FileInputStream(resultfile);
755 byte[] resourcebuf = new byte[1024];
756 byte[] resultbuf = new byte[1024];
757 int i = 0;
758
759 while ((i = resourcestream.read(resourcebuf)) != -1)
760 {
761 if (resultfilestream.read(resultbuf) != i)
762 {
763 Log.e("Navit", "Result is too short");
764 needs_update = true;
765 break;
766 }
767
768 for (int j = 0; j < i; j++)
769 {
770 if (resourcebuf[j] != resultbuf[j])
771 {
772 Log.e("Navit", "Result is different");
773 needs_update = true;
774 break;
775 }
776 }
777 if (needs_update) break;
778 }
779
780 if (!needs_update && resultfilestream.read(resultbuf) != -1)
781 {
782 Log.e("Navit", "Result is too long");
783 needs_update = true;
784 }
785
786 if (resultfilestream != null)
787 {
788 resultfilestream.close();
789 }
790 }
791 catch (Exception e)
792 {
793 Log.e("Navit", "Exception " + e.getMessage());
794 return false;
795 }
796 }
797
798 if (needs_update)
799 {
800 Log.e("Navit", "Extracting resource");
801 try
802 {
803 InputStream resourcestream = res.openRawResource(id);
804 FileOutputStream resultfilestream = new FileOutputStream(resultfile);
805 byte[] buf = new byte[1024];
806 int i = 0;
807
808 while ((i = resourcestream.read(buf)) != -1)
809 {
810 resultfilestream.write(buf, 0, i);
811 }
812
813 if (resultfilestream != null)
814 {
815 resultfilestream.close();
816 }
817 }
818 catch (Exception e)
819 {
820 Log.e("Navit", "Exception " + e.getMessage());
821 return false;
822 }
823 }
824 return true;
825 }
826
827 static OnAudioFocusChangeListener focusChangeListener = new OnAudioFocusChangeListener()
828 {
829 public void onAudioFocusChange(int focusChange)
830 {
831 // AudioManager am = Navit.NavitAudioManager;
832 switch (focusChange)
833 {
834
835 case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK):
836 // Lower the volume while ducking.
837 //mediaPlayer.setVolume(0.2f, 0.2f);
838 break;
839 case (AudioManager.AUDIOFOCUS_LOSS_TRANSIENT):
840 //pause();
841 break;
842
843 case (AudioManager.AUDIOFOCUS_LOSS):
844 //stop();
845 //ComponentName component = new ComponentName(AudioPlayerActivity.this, MediaControlReceiver.class);
846 //am.unregisterMediaButtonEventReceiver(component);
847 break;
848
849 case (AudioManager.AUDIOFOCUS_GAIN):
850 // Return the volume to normal and resume if paused.
851 //mediaPlayer.setVolume(1f, 1f);
852 //mediaPlayer.start();
853 break;
854 default:
855 break;
856 }
857 }
858 };
859
860 // private boolean checkPlayServices()
861
862 // {
863 // int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
864 //
865 // Log.i("PlayServices", "isGooglePlayServicesAvailable=" + status);
866 //
867 // if (status != ConnectionResult.SUCCESS)
868 // {
869 // if (GooglePlayServicesUtil.isUserRecoverableError(status))
870 // {
871 // Toast.makeText(this, "Recoverable error.", Toast.LENGTH_LONG).show();
872 // // showErrorDialog(status);
873 // }
874 // else
875 // {
876 // Toast.makeText(this, "This device is not supported.", Toast.LENGTH_LONG).show();
877 // }
878 // return false;
879 // }
880 // return true;
881 // }
882
883 // ----------------------------------------------------------------------------------------------------------
884 // thanks to: http://stackoverflow.com/questions/843675/how-do-i-find-out-if-the-gps-of-an-android-device-is-enabled
885 // ----------------------------------------------------------------------------------------------------------
886 private void buildAlertMessageNoGps()
887 {
888 try
889 {
890 AlertDialog.Builder builder = new AlertDialog.Builder(this);
891 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()
892 {
893 public void onClick(final DialogInterface dialog, final int id)
894 {
895 startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
896 }
897 }).setNegativeButton(Navit.get_text("No"), new DialogInterface.OnClickListener()
898 {
899 public void onClick(final DialogInterface dialog, final int id)
900 {
901 dialog.cancel();
902 }
903 });
904 AlertDialog alert = builder.create();
905 alert.show();
906 }
907 catch (Exception e)
908 {
909 e.printStackTrace();
910 }
911 }
912
913 /** Called when the activity is first created. */
914
915 // ----------- remove later -------------
916 // ----------- remove later -------------
917 @SuppressLint("NewApi")
918 // ----------- remove later -------------
919 // ----------- remove later -------------
920 @TargetApi(Build.VERSION_CODES.FROYO)
921 @Override
922 public void onCreate(Bundle savedInstanceState)
923 {
924 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
925
926 // ------- only after API level 9 -------
927 // ------- only after API level 9 -------
928 // try
929 // {
930 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDeath().penaltyLog().build());
931 // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
932 //
933 // StrictMode.ThreadPolicy old = StrictMode.getThreadPolicy();
934 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskWrites().build());
935 // old = StrictMode.getThreadPolicy();
936 // StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder(old).permitDiskReads().build());
937 //
938 // }
939 // catch (NoClassDefFoundError e)
940 // {
941 // }
942 // ------- only after API level 9 -------
943 // ------- only after API level 9 -------
944
945 // Log.e("Navit", "OnCreate");
946
947 // if (checkPlayServices())
948 // {
949 // }
950
951 getPrefs_theme();
952 getPrefs_theme_main();
953 Navit.applySharedTheme(this, p.PREF_current_theme_M);
954
955 super.onCreate(savedInstanceState);
956
957 Global_Navit_Object = this;
958 asset_mgr = getAssets();
959
960 OSD_blueish_bg_color = getResources().getColor(R.color.blueish_bg_color);
961
962 // getBaseContext_ = getBaseContext().getApplicationContext();
963 getBaseContext_ = getBaseContext();
964
965 last_orientation = getResources().getConfiguration().orientation;
966
967 content_resolver = getContentResolver();
968 // get_reglevel();
969
970 Display display_ = getWindowManager().getDefaultDisplay();
971 metrics = new DisplayMetrics();
972 display_.getMetrics(Navit.metrics);
973
974 road_book_items = new ArrayList<ListViewItem>();
975 fragmentManager = getSupportFragmentManager();
976
977 setContentView(R.layout.main_layout);
978 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
979 if (toolbar != null)
980 {
981 try
982 {
983 setSupportActionBar(toolbar);
984 // System.out.println("TTT01:" + toolbar);
985 }
986 catch (NoClassDefFoundError e)
987 {
988 }
989 }
990
991 try
992 {
993 getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
994 getSupportActionBar().setDisplayUseLogoEnabled(false);
995 getSupportActionBar().setIcon(R.drawable.icon);
996 getSupportActionBar().setDisplayShowHomeEnabled(true);
997 getSupportActionBar().setDisplayShowTitleEnabled(false);
998 }
999 catch (NoClassDefFoundError e)
1000 {
1001 }
1002 catch (Exception e)
1003 {
1004 e.printStackTrace();
1005 }
1006
1007 // ------------ bottom bar slider ----------------
1008 // ------------ bottom bar slider ----------------
1009 // ------------ bottom bar slider ----------------
1010
1011 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
1012 // System.out.println("VVV:bottom_bar_height:" + bottom_bar_px);
1013 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
1014 // System.out.println("VVV:bottom_bar_slider_shadow_px:" + bottom_bar_slider_shadow_px);
1015
1016 // final RelativeLayout a = (RelativeLayout) findViewById(R.id.bottom_bar_container);
1017 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
1018 final RelativeLayout.LayoutParams pp22 = (RelativeLayout.LayoutParams) a.getLayoutParams();
1019
1020 // Calculate ToolBar height
1021 try
1022 {
1023 TypedValue tv = new TypedValue();
1024 if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
1025 {
1026 actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
1027 System.out.println("VVV:abh:" + actionBarHeight);
1028 }
1029 else
1030 {
1031 actionBarHeight = NavitGraphics.dp_to_px(144);
1032 }
1033 }
1034 catch (Exception e)
1035 {
1036 actionBarHeight = NavitGraphics.dp_to_px(144);
1037 }
1038
1039 final android.support.v7.widget.Toolbar view_toolbar_top = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
1040 ViewTreeObserver vto = view_toolbar_top.getViewTreeObserver();
1041 vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener()
1042 {
1043 @Override
1044 public void onGlobalLayout()
1045 {
1046 view_toolbar_top.getViewTreeObserver().removeGlobalOnLayoutListener(this);
1047 // int width = view_toolbar_top.getMeasuredWidth();
1048 int height = view_toolbar_top.getMeasuredHeight();
1049 Navit.actionBarHeight = height;
1050 // System.out.println("hhh:88=" + Navit.actionBarHeight);
1051 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
1052
1053 pp22.setMargins(0, (int) Navit.cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1054 a.setLayoutParams(pp22);
1055 a.requestLayout();
1056 }
1057 });
1058
1059 // actionBarHeight = 168;
1060
1061 // final int SWIPE_MIN_DISTANCE = NavitGraphics.dp_to_px(25);
1062 // final float SWIPE_THRESHOLD_VELOCITY = 5.5f;
1063 // final float FLING_PIXELS_PER_SECOND = 100;
1064 // final float maxFlingVelocity = ViewConfiguration.get(this).getScaledMaximumFlingVelocity();
1065 final ViewConfiguration vc = ViewConfiguration.get(this);
1066 final int swipeMinDistance = vc.getScaledPagingTouchSlop();
1067 final int swipeThresholdVelocity = vc.getScaledMinimumFlingVelocity();
1068 swipeMaxOffPath = vc.getScaledTouchSlop();
1069 // (there is also vc.getScaledMaximumFlingVelocity() one could check against)
1070
1071 // setup some values --------
1072 NavitGraphics.long_press_on_screen_max_distance = swipeMaxOffPath;
1073 // setup some values --------
1074
1075 class MyGestureDetector extends SimpleOnGestureListener
1076 {
1077 @Override
1078 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
1079 {
1080 try
1081 {
1082 // float velocityPercentY = velocityY / maxFlingVelocity; // the percent is a value in the range of (0, 1]
1083 // float normalizedVelocityY = velocityPercentY * FLING_PIXELS_PER_SECOND; // where PIXELS_PER_SECOND is a device-independent measurement
1084
1085 // System.out.println("VVV:" + (e1.getY() - e2.getY()) + " " + NavitGraphics.dp_to_px((int) (e1.getY() - e2.getY())) + " " + maxFlingVelocity + " " + velocityY + " " + velocityPercentY + " " + normalizedVelocityY + " " + SWIPE_THRESHOLD_VELOCITY);
1086
1087 // System.out.println("VVV:2:" + swipeMinDistance + " " + swipeThresholdVelocity + " " + swipeMaxOffPath);
1088
1089 // bottom to top
1090 if (e1.getY() - e2.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1091 {
1092 //int featureWidth = getMeasuredWidth();
1093 //mActiveFeature = (mActiveFeature < (mItems.size() - 1)) ? mActiveFeature + 1 : mItems.size() - 1;
1094 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1095 //System.out.println("GS:002:up:" + velocityY + " " + e2.getY() + " " + e1.getY());
1096
1097 animate_bottom_bar_up();
1098
1099 return true;
1100 }
1101 // top to bottom
1102 else if (e2.getY() - e1.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1103 {
1104 //int featureWidth = getMeasuredWidth();
1105 //mActiveFeature = (mActiveFeature > 0) ? mActiveFeature - 1 : 0;
1106 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1107 //System.out.println("GS:003:down:" + velocityY + " " + e1.getY() + " " + e2.getY());
1108
1109 animate_bottom_bar_down();
1110
1111 return true;
1112 }
1113 }
1114 catch (Exception e)
1115 {
1116 //System.out.println("GS:009:EE:" + e.getMessage());
1117 }
1118 return false;
1119 }
1120 }
1121 mGestureDetector = new GestureDetector(new MyGestureDetector());
1122
1123 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
1124 push_pin_view.setOnClickListener(new ImageView.OnClickListener()
1125 {
1126 public void onClick(View v)
1127 {
1128 try
1129 {
1130 toggle_follow_button();
1131 }
1132 catch (Exception e)
1133 {
1134 }
1135 }
1136 });
1137
1138 cur_y_margin_bottom_bar_touch = 0; // try to put view at bottom
1139
1140 a.setOnTouchListener(new View.OnTouchListener()
1141 {
1142 @Override
1143 synchronized public boolean onTouch(View v, MotionEvent m)
1144 {
1145
1146 int action = m.getAction();
1147
1148 if (mGestureDetector.onTouchEvent(m))
1149 {
1150 //System.out.println("GS:001:fling!!");
1151 // System.out.println("FRAG:fling:011");
1152 return true;
1153 }
1154 else if (action == MotionEvent.ACTION_DOWN)
1155 {
1156 last_y_bottom_bar_touch = m.getY();
1157
1158 // put roadbook into layout -----------
1159 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
1160
1161 try
1162 {
1163 if (road_book == null)
1164 {
1165 road_book = new ZANaviRoadbookFragment();
1166 // System.out.println("FRAG:attach:001");
1167 fragmentTransaction.replace(R.id.roadbook_fragment_container, road_book, "");
1168 fragmentTransaction.commitAllowingStateLoss();
1169 // fragmentTransaction.show(road_book);
1170 }
1171 else
1172 {
1173 // System.out.println("FRAG:attached:003");
1174 }
1175 }
1176 catch (Exception ef)
1177 {
1178 }
1179 // put roadbook into layout -----------
1180
1181 return true;
1182 }
1183 else if ((action == MotionEvent.ACTION_UP) || (action == MotionEvent.ACTION_CANCEL))
1184 {
1185 // System.out.println("FRAG:up/cancel:012");
1186
1187 // release
1188 if (cur_y_margin_bottom_bar_touch > (bottom_y_margin_bottom_bar_touch / 2))
1189 {
1190 // snap back to bottom
1191 animate_bottom_bar_down();
1192 }
1193 else
1194 {
1195 // snap top top
1196 animate_bottom_bar_up();
1197 }
1198 }
1199 else
1200 // if (action == MotionEvent.ACTION_MOVE)
1201 {
1202 // System.out.println("FRAG:*else*:012");
1203
1204 if (Math.abs(last_y_bottom_bar_touch - m.getY()) > 2)
1205 {
1206 float last_margin = cur_y_margin_bottom_bar_touch;
1207 cur_y_margin_bottom_bar_touch = cur_y_margin_bottom_bar_touch - (last_y_bottom_bar_touch - m.getY());
1208
1209 if ((cur_y_margin_bottom_bar_touch >= 0) && (cur_y_margin_bottom_bar_touch <= bottom_y_margin_bottom_bar_touch))
1210 {
1211 // System.out.println("VVV:move:" + cur_y_margin_bottom_bar_touch + " " + bottom_y_margin_bottom_bar_touch);
1212
1213 last_y_bottom_bar_touch = m.getY() + (last_y_bottom_bar_touch - m.getY());
1214 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
1215 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1216 a.setLayoutParams(relativeParams);
1217 a.requestLayout();
1218 }
1219 else
1220 {
1221 // System.out.println("VVV:revert");
1222
1223 // revert position
1224 cur_y_margin_bottom_bar_touch = last_margin;
1225 }
1226 }
1227
1228 }
1229 return true;
1230 }
1231 });
1232 // ------------ bottom bar slider ----------------
1233 // ------------ bottom bar slider ----------------
1234 // ------------ bottom bar slider ----------------
1235
1236 // init cancel dialog!! ----------
1237 // init cancel dialog!! ----------
1238 Message msg2 = new Message();
1239 Bundle b2 = new Bundle();
1240 b2.putString("text", "");
1241 msg2.what = 0;
1242 msg2.setData(b2);
1243 ZANaviDownloadMapCancelActivity.canceldialog_handler.sendMessage(msg2);
1244 // init cancel dialog!! ----------
1245 // init cancel dialog!! ----------
1246
1247 app_window = getWindow();
1248
1249 // ---------------- set some directories -----------------
1250 // ---------------- set some directories -----------------
1251 NAVIT_DATA_DIR = this.getFilesDir().getPath();
1252 this.getFilesDir().mkdirs();
1253 // ---
1254 // System.out.println("data dir=" + NAVIT_DATA_DIR);
1255 NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share/";
1256 File tmp3 = new File(NAVIT_DATA_SHARE_DIR);
1257 tmp3.mkdirs();
1258 // ---
1259 FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
1260 VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
1261 // ---------------- set some directories -----------------
1262 // ---------------- set some directories -----------------
1263
1264 try
1265 {
1266 toneG = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
1267 }
1268 catch (Exception e)
1269 {
1270 }
1271
1272 try
1273 {
1274 Class.forName("android.app.backup.BackupManager");
1275 backupManager = new BackupManager(this);
1276 }
1277 catch (ClassNotFoundException e)
1278 {
1279 e.printStackTrace();
1280 }
1281 catch (Exception e)
1282 {
1283 e.printStackTrace();
1284 }
1285
1286 int width_ = display_.getWidth();
1287 int height_ = display_.getHeight();
1288 Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_);
1289 Log.e("Navit", "Navit -> dpi=" + Navit.metrics.densityDpi);
1290 Log.e("Navit", "Navit -> density=" + Navit.metrics.density);
1291 Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);
1292
1293 try
1294 {
1295 // send overspill factor to C-code
1296 Message msg33 = new Message();
1297 Bundle b33 = new Bundle();
1298 b33.putInt("Callback", 104);
1299 msg33.setData(b33);
1300 NavitGraphics.callback_handler.sendMessage(msg33);
1301 }
1302 catch (Exception eee)
1303 {
1304 }
1305
1306 // ----- service -----
1307 // ----- service -----
1308 ZANaviMapDownloaderServiceIntent = new Intent(Navit.getBaseContext_, ZANaviMapDownloaderService.class);
1309 // ----- service -----
1310 // ----- service -----
1311
1312 System.out.println("Navit:onCreate:JTHREAD ID=" + Thread.currentThread().getId());
1313 System.out.println("Navit:onCreate:THREAD ID=" + NavitGraphics.GetThreadId());
1314
1315 // bitmaps for lanes
1316 lane_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_left);
1317 lane_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_right);
1318 lane_merge_to_left = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_left);
1319 lane_merge_to_right = BitmapFactory.decodeResource(getResources(), R.drawable.lane_merge_to_right);
1320 lane_none = BitmapFactory.decodeResource(getResources(), R.drawable.lane_none);
1321 // bitmaps for lanes
1322
1323 // paint for bitmapdrawing on map
1324 NavitGraphics.paint_for_map_display.setAntiAlias(true);
1325 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
1326
1327 // sky
1328 NavitGraphics.paint_sky_day.setAntiAlias(true);
1329 NavitGraphics.paint_sky_day.setColor(Color.parseColor("#79BAEC"));
1330 NavitGraphics.paint_sky_night.setAntiAlias(true);
1331 NavitGraphics.paint_sky_night.setColor(Color.parseColor("#090909"));
1332 // stars
1333 NavitGraphics.paint_sky_night_stars.setColor(Color.parseColor("#DEDDEF"));
1334 // twilight
1335 NavitGraphics.paint_sky_twilight1.setColor(Color.parseColor("#090909"));
1336 NavitGraphics.paint_sky_twilight2.setColor(Color.parseColor("#113268"));
1337 NavitGraphics.paint_sky_twilight3.setColor(Color.parseColor("#79BAEC"));
1338
1339 Random m = new Random();
1340 int i6 = 0;
1341 for (i6 = 0; i6 < (NavitGraphics.max_stars + 1); i6++)
1342 {
1343 NavitGraphics.stars_x[i6] = m.nextFloat();
1344 NavitGraphics.stars_y[i6] = m.nextFloat();
1345 NavitGraphics.stars_size[i6] = m.nextInt(3) + 1;
1346 }
1347
1348 res_ = getResources();
1349 int ii = 0;
1350 NavitGraphics.dl_thread_cur = 0;
1351 for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
1352 {
1353 NavitGraphics.dl_thread[ii] = null;
1354 }
1355
1356 String font_file_name = "Roboto-Regular.ttf"; // "LiberationSans-Regular.ttf";
1357 NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), font_file_name);
1358 // System.out.println("NavitStreetnameFont" + NavitStreetnameFont);
1359
1360 Navit_maps_loaded = false;
1361
1362 // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
1363 Navit.startup_intent = this.getIntent();
1364 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
1365 Navit.startup_intent_timestamp = System.currentTimeMillis();
1366 Log.e("Navit", "**1**A " + startup_intent.getAction());
1367 Log.e("Navit", "**1**D " + startup_intent.getDataString());
1368 Log.e("Navit", "**1**I " + startup_intent.toString());
1369 try
1370 {
1371 Log.e("Navit", "**1**DH E " + startup_intent.getExtras().describeContents());
1372 }
1373 catch (Exception ee)
1374 {
1375 }
1376
1377 startup_status = Navit_Status_NORMAL_STARTUP;
1378
1379 // glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView_001);
1380 // glSurfaceView.setEGLContextClientVersion(2); // enable OpenGL 2.0
1381 // glSurfaceView.setRenderer(new GlRenderer());
1382 // glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // only render on demand
1383 //
1384 // // draw some sample lines ----
1385 // // draw some sample lines ----
1386 // // draw some sample lines ----
1387 // ZANaviGlLine vertLine = new ZANaviGlLine();
1388 // vertLine.SetVerts(1000f, 1000f, 0f, -1000f, -1000f, 0f);
1389 // vertLine.SetColor(.8f, .8f, 0f, 1.0f);
1390 //
1391 // float[] mMVPMatrix = new float[16];
1392 //
1393 // // Position the eye behind the origin.
1394 // final float eyeX = 0.0f;
1395 // final float eyeY = 0.0f;
1396 // final float eyeZ = 1.5f;
1397 //
1398 // // We are looking toward the distance
1399 // final float lookX = 0.0f;
1400 // final float lookY = 0.0f;
1401 // final float lookZ = -5.0f;
1402 //
1403 // // Set our up vector. This is where our head would be pointing were we holding the camera.
1404 // final float upX = 0.0f;
1405 // final float upY = 1.0f;
1406 // final float upZ = 0.0f;
1407 //
1408 // // Set the view matrix. This matrix can be said to represent the camera position.
1409 // // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
1410 // // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
1411 // Matrix.setLookAtM(mMVPMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
1412 //
1413 // vertLine.draw(mMVPMatrix);
1414 //
1415 // glSurfaceView.postInvalidate();
1416 // glSurfaceView.requestRender();
1417 // glSurfaceView.postInvalidate();
1418 // // draw some sample lines ----
1419 // // draw some sample lines ----
1420 // // draw some sample lines ----
1421
1422 // setup graphics objects
1423 // setup graphics objects
1424 // setup graphics objects
1425 NG__vehicle = new NavitGraphics(this, 1, 0, 0, 50, 50, 65535, 0, 0);
1426 NG__map_main = new NavitGraphics(this, 0, 0, 0, 100, 100, 0, 0, 0);
1427 Navit.N_NavitGraphics = NG__map_main;
1428 // setup graphics objects
1429 // setup graphics objects
1430 // setup graphics objects
1431
1432 NV = new NavitVehicle(this);
1433 NSp = new NavitSpeech2(this);
1434
1435 // init translated text
1436 NavitTextTranslations.init();
1437
1438 // set the new locale here -----------------------------------
1439 getPrefs_loc();
1440 activatePrefs_loc();
1441 // set the new locale here -----------------------------------
1442
1443 // get the local language -------------
1444 Locale locale = java.util.Locale.getDefault();
1445 String lang = locale.getLanguage();
1446 String langu = lang;
1447 String langc = lang;
1448 Log.e("Navit", "lang=" + lang);
1449 int pos = langu.indexOf('_');
1450 if (pos != -1)
1451 {
1452 langc = langu.substring(0, pos);
1453 langu = langc + langu.substring(pos).toUpperCase(locale);
1454 Log.e("Navit", "substring lang " + langu.substring(pos).toUpperCase(locale));
1455 // set lang. for translation
1456 NavitTextTranslations.main_language = langc;
1457 NavitTextTranslations.sub_language = langu.substring(pos).toUpperCase(locale);
1458 }
1459 else
1460 {
1461 String country = locale.getCountry();
1462 Log.e("Navit", "Country1 " + country);
1463 Log.e("Navit", "Country2 " + country.toUpperCase(locale));
1464 langu = langc + "_" + country.toUpperCase(locale);
1465 // set lang. for translation
1466 NavitTextTranslations.main_language = langc;
1467 NavitTextTranslations.sub_language = country.toUpperCase(locale);
1468 }
1469 Log.e("Navit", "Language " + lang);
1470 // get the local language -------------
1471
1472 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
1473 no_maps_text.setText("\n\n\n" + Navit.get_text("No Maps installed") + "\n" + Navit.get_text("Please download a map") + "\n\n");
1474 // no_maps_text.postInvalidate();
1475
1476 // set map cache size here -----------------------------------
1477 getPrefs_mapcache();
1478 activatePrefs_mapcache();
1479 // set map cache size here -----------------------------------
1480
1481 // get map data dir and set it -----------------------------
1482 getPrefs_mapdir();
1483 activatePrefs_mapdir(true);
1484 // get map data dir and set it -----------------------------
1485
1486 // get special prefs here ------------------------------------
1487 get_prefs_highdpi();
1488 // get special prefs here ------------------------------------
1489
1490 // make sure the new path for the navitmap.bin file(s) exist!!
1491 File navit_maps_dir = new File(MAP_FILENAME_PATH);
1492 navit_maps_dir.mkdirs();
1493 // create nomedia files
1494 File nomedia_file = new File(MAP_FILENAME_PATH + ".nomedia");
1495 try
1496 {
1497 nomedia_file.createNewFile();
1498 }
1499 catch (Exception e1)
1500 {
1501 e1.printStackTrace();
1502 }
1503 // create nomedia files
1504
1505 // check if we already have a borders.bin file (if not, then extract the included simplified one)
1506 File b_ = new File(MAP_FILENAME_PATH + "/borders.bin");
1507 try
1508 {
1509 if (!b_.exists())
1510 {
1511 try
1512 {
1513 File c_ = new File(MAPMD5_FILENAME_PATH + "/borders.bin.md5");
1514 c_.delete();
1515 }
1516 catch (Exception e2)
1517 {
1518
1519 }
1520 Log.e("Navit", "trying to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1521 if (!extractRes("borders_simple", MAP_FILENAME_PATH + "/borders.bin"))
1522 {
1523 Log.e("Navit", "Failed to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1524 }
1525 }
1526 }
1527 catch (Exception e)
1528 {
1529
1530 }
1531 // check if we already have a borders.bin file
1532
1533 // make sure the new path for config files exist
1534 File navit_cfg_dir = new File(CFG_FILENAME_PATH);
1535 navit_cfg_dir.mkdirs();
1536
1537 // make sure the new path for the navitmap.bin file(s) exist!!
1538 File navit_mapsmd5_dir = new File(MAPMD5_FILENAME_PATH);
1539 navit_mapsmd5_dir.mkdirs();
1540
1541 // make sure the share dir exists, otherwise the infobox will not show
1542 File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR);
1543 navit_data_share_dir.mkdirs();
1544
1545 File dd = new File(NAVIT_DATA_DEBUG_DIR);
1546 dd.mkdirs();
1547
1548 // try to create cat. file if it does not exist
1549 File navit_maps_catalogue = new File(CFG_FILENAME_PATH + NavitMapDownloader.CAT_FILE);
1550 if (!navit_maps_catalogue.exists())
1551 {
1552 FileOutputStream fos_temp;
1553 try
1554 {
1555 fos_temp = new FileOutputStream(navit_maps_catalogue);
1556 fos_temp.write((NavitMapDownloader.MAP_CAT_HEADER + "\n").getBytes()); // just write header to the file
1557 fos_temp.flush();
1558 fos_temp.close();
1559 }
1560 catch (Exception e)
1561 {
1562 e.printStackTrace();
1563 }
1564 }
1565
1566 // ---------- downloader threads ----------------
1567 PackageInfo pkgInfo;
1568 Navit_DonateVersion_Installed = false;
1569 try
1570 {
1571 // is the donate version installed?
1572 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_donate", 0);
1573 String sharedUserId = pkgInfo.sharedUserId;
1574 System.out.println("str nd=" + sharedUserId);
1575 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
1576 {
1577 System.out.println("##bonus 001##");
1578 Navit_DonateVersion_Installed = true;
1579 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1580 }
1581 }
1582 catch (NameNotFoundException e)
1583 {
1584 e.printStackTrace();
1585 }
1586 catch (Exception e)
1587 {
1588 e.printStackTrace();
1589 }
1590
1591 try
1592 {
1593 if (get_reglevel() == 1)
1594 {
1595 System.out.println("##U:bonus 001##");
1596 Navit_DonateVersion_Installed = true;
1597 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1598 }
1599 }
1600 catch (Exception e)
1601 {
1602 e.printStackTrace();
1603 }
1604
1605 try
1606 {
1607 // is the "large map" donate version installed?
1608 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0);
1609 String sharedUserId = pkgInfo.sharedUserId;
1610 System.out.println("str lm=" + sharedUserId);
1611
1612 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
1613 {
1614 System.out.println("##bonus 002##");
1615 Navit_DonateVersion_Installed = true;
1616 Navit_Largemap_DonateVersion_Installed = true;
1617 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1618 }
1619 }
1620 catch (NameNotFoundException e)
1621 {
1622 e.printStackTrace();
1623 }
1624 catch (Exception e)
1625 {
1626 e.printStackTrace();
1627 }
1628
1629 try
1630 {
1631 if (get_reglevel() == 1)
1632 {
1633 System.out.println("##U:bonus 002##");
1634 Navit_DonateVersion_Installed = true;
1635 Navit_Largemap_DonateVersion_Installed = true;
1636 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1637 }
1638 }
1639 catch (Exception e)
1640 {
1641 e.printStackTrace();
1642 }
1643
1644 // update map list
1645 NavitMapDownloader.init_maps_without_donate_largemaps();
1646 // ---------- downloader threads ----------------
1647
1648 // ---- detect menu button ----
1649 detect_menu_button();
1650
1651 if (Navit.metrics.densityDpi >= 320) //&& (PREF_shrink_on_high_dpi))
1652 {
1653 Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001);
1654 }
1655 else
1656 {
1657 Navit.menu_button = BitmapFactory.decodeResource(getResources(), R.drawable.menu_001_small);
1658 }
1659
1660 Navit.long_green_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.long_green_arrow);
1661
1662 Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow);
1663 Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off);
1664 Navit.follow_current = Navit.follow_on;
1665
1666 if ((Navit.metrics.densityDpi >= 320) && (p.PREF_shrink_on_high_dpi))
1667 {
1668 float factor;
1669 factor = (float) NavitGraphics.Global_Scaled_DPI_normal / (float) Navit.metrics.densityDpi;
1670 factor = factor * 1.7f;
1671 //
1672 BitmapFactory.Options o = new BitmapFactory.Options();
1673 o.inDither = true;
1674 //o.inScaled = true;
1675 //o.inTargetDensity = NavitGraphics.Global_Scaled_DPI_normal;
1676 Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped, o);
1677 Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving, o);
1678 Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey, o);
1679 Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow, o);
1680
1681 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);
1682 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);
1683 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);
1684 }
1685 else
1686 {
1687 Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped);
1688 Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving);
1689 Navit.nav_arrow_moving_grey = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_grey);
1690 Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow);
1691
1692 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);
1693 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);
1694 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);
1695 }
1696
1697 Navit.zoomin = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_in_32_32);
1698 Navit.zoomout = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_out_32_32);
1699
1700 //Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway);
1701 Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_large);
1702 Navit.oneway_bicycle_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_bicycle_large);
1703
1704 // *******************
1705 // *******************
1706 // *******************
1707 // *******************
1708 // check/init the catalogue file for downloaded maps
1709 NavitMapDownloader.init_cat_file();
1710 // *******************
1711 // *******************
1712 // *******************
1713 // *******************
1714
1715 xmlconfig_unpack_file = false;
1716 write_new_version_file = false;
1717 try
1718 {
1719 NavitAppVersion = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionCode;
1720 NavitAppVersion_string = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
1721 }
1722 catch (NameNotFoundException e)
1723 {
1724 e.printStackTrace();
1725 NavitAppVersion = "1";
1726 NavitAppVersion_string = "1";
1727 }
1728 catch (Exception e)
1729 {
1730 e.printStackTrace();
1731 NavitAppVersion = "2";
1732 NavitAppVersion_string = "2";
1733 }
1734
1735 try
1736 {
1737 File navit_version = new File(VERSION_FILE);
1738 if (!navit_version.exists())
1739 {
1740 System.out.println("version file does not exist");
1741 NavitAppVersion_prev = "-1";
1742 write_new_version_file = true;
1743 }
1744 else
1745 {
1746 // files exists, read in the prev. verison number
1747 System.out.println("version file is here");
1748 FileInputStream fos_temp;
1749 byte[] buffer = new byte[101];
1750 fos_temp = new FileInputStream(navit_version);
1751 int len = fos_temp.read(buffer, 0, 100);
1752 if (len != -1)
1753 {
1754 // use only len bytes to make the string (the rest is garbage!!)
1755 NavitAppVersion_prev = new String(buffer).substring(0, len);
1756 }
1757 else
1758 {
1759 NavitAppVersion_prev = "-1";
1760 write_new_version_file = true;
1761 }
1762 fos_temp.close();
1763 }
1764
1765 }
1766 catch (Exception e)
1767 {
1768 NavitAppVersion_prev = "-1";
1769 write_new_version_file = true;
1770 e.printStackTrace();
1771 }
1772
1773 System.out.println("vprev:" + NavitAppVersion_prev + " vcur:" + NavitAppVersion);
1774
1775 if (NavitAppVersion_prev.compareTo(NavitAppVersion) != 0)
1776 {
1777 // different version
1778 System.out.println("different version!!");
1779 write_new_version_file = true;
1780 xmlconfig_unpack_file = true;
1781
1782 //if ((NavitAppVersion_prev.compareTo("-1") != 0) && (NavitAppVersion.compareTo("-1") != 0))
1783 //{
1784 // user has upgraded to a new version of ZANavi
1785 startup_status = Navit_Status_UPGRADED_TO_NEW_VERSION;
1786 //}
1787 }
1788 else
1789 {
1790 // same version
1791 System.out.println("same version");
1792 xmlconfig_unpack_file = false;
1793 }
1794
1795 // write new version file
1796 if (write_new_version_file)
1797 {
1798 try
1799 {
1800 System.out.println("write version file");
1801 FileOutputStream fos_temp;
1802 File navit_version = new File(VERSION_FILE);
1803 navit_version.delete();
1804 fos_temp = new FileOutputStream(navit_version);
1805 fos_temp.write(NavitAppVersion.getBytes());
1806 fos_temp.flush();
1807 fos_temp.close();
1808 }
1809 catch (Exception e)
1810 {
1811 e.printStackTrace();
1812 }
1813 }
1814
1815 // Sample useragent strings:
1816 //
1817 // Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110616 Firefox/7.0a1 SeaMonkey/2.4a1
1818 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; GT-I9100 Build/GINGERBREAD)
1819 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5830 Build/FROYO)
1820 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Desire S Build/GRI40)
1821 // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-179)
1822 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Wildfire S A510e Build/GRI40)
1823 // Wget/1.10.2
1824 // Dalvik/1.4.0 (Linux; U; Android 2.3.3; sdk Build/GRI34)
1825 // Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-164)
1826 // Dalvik/1.2.0 (Linux; U; Android 2.2; GT-I9000 Build/FROYO)
1827 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5570L Build/FROYO)
1828 // Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-I9000 Build/FROYO)
1829 // Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)
1830 String ANDROID = android.os.Build.VERSION.SDK; //The current development codename, or the string "REL" if this is a release build.
1831 //String BOARD = android.os.Build.BOARD; //The name of the underlying board, like "goldfish".
1832 //String BOOTLOADER = android.os.Build.BOOTLOADER; // The system bootloader version number.
1833 String BRAND = android.os.Build.BRAND; //The brand (e.g., carrier) the software is customized for, if any.
1834 //String CPU_ABI = android.os.Build.CPU_ABI; //The name of the instruction set (CPU type + ABI convention) of native code.
1835 //String CPU_ABI2 = android.os.Build.CPU_ABI2; // The name of the second instruction set (CPU type + ABI convention) of native code.
1836 String DEVICE = android.os.Build.DEVICE; // The name of the industrial design.
1837 String DISPLAY = android.os.Build.DISPLAY; //A build ID string meant for displaying to the user
1838 //String FINGERPRINT = android.os.Build.FINGERPRINT; //A string that uniquely identifies this build.
1839 //String HARDWARE = android.os.Build.HARDWARE; //The name of the hardware (from the kernel command line or /proc).
1840 //String HOST = android.os.Build.HOST;
1841 //String ID = android.os.Build.ID; //Either a changelist number, or a label like "M4-rc20".
1842 String MANUFACTURER = android.os.Build.MANUFACTURER; //The manufacturer of the product/hardware.
1843 //String MODEL = android.os.Build.MODEL; //The end-user-visible name for the end product.
1844 //String PRODUCT = android.os.Build.PRODUCT; //The name of the overall product.
1845 //String RADIO = android.os.Build.RADIO; //The radio firmware version number.
1846 //String TAGS = android.os.Build.TAGS; //Comma-separated tags describing the build, like "unsigned,debug".
1847 //String TYPE = android.os.Build.TYPE; //The type of build, like "user" or "eng".
1848 //String USER = android.os.Build.USER;
1849
1850 String android_version = "Android " + ANDROID;
1851 String android_device = MANUFACTURER + " " + BRAND + " " + DEVICE;
1852
1853 api_version_int = Integer.valueOf(android.os.Build.VERSION.SDK);
1854 System.out.println("XXX:API=" + api_version_int);
1855 if (api_version_int > 10)
1856 {
1857 Navit.PAINT_OLD_API = false;
1858 }
1859 else
1860 {
1861 Navit.PAINT_OLD_API = true;
1862 }
1863
1864 if (MANUFACTURER.equalsIgnoreCase("amazon"))
1865 {
1866 // we are on amazon device
1867 ZANaviNormalDonateActivity.on_amazon_device = true;
1868 }
1869
1870 // debug
1871 // debug
1872 // android_device = "telechips telechips m801";
1873 // debug
1874 // debug
1875
1876 String android_rom_name = DISPLAY;
1877
1878 if (FDBL)
1879 {
1880 android_rom_name = android_rom_name + "; FD";
1881 }
1882
1883 if (Navit_DonateVersion_Installed == false)
1884 {
1885 UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1886 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1887 }
1888 else
1889 {
1890 if (Navit_Largemap_DonateVersion_Installed == false)
1891 {
1892 UserAgentString = "Mozilla/5.0 (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1893 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1894 }
1895 else
1896
1897 {
1898 UserAgentString = "Mozilla/5.0 (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1899 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1900 }
1901 }
1902 // System.out.println("UA=" + UserAgentString);
1903
1904 // --------- enable GPS ? --------------
1905 // --------- enable GPS ? --------------
1906 // try
1907 // {
1908 // final LocationManager llmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
1909 // if (!llmanager.isProviderEnabled(LocationManager.GPS_PROVIDER))
1910 // {
1911 // buildAlertMessageNoGps();
1912 // }
1913 // }
1914 // catch (Exception e)
1915 // {
1916 // e.printStackTrace();
1917 // }
1918 // --------- enable GPS ? --------------
1919 // --------- enable GPS ? --------------
1920
1921 unsupported = false;
1922 try
1923 {
1924 if (android_device.toLowerCase().contains("telechips"))
1925 {
1926 if (android_device.toLowerCase().contains("m801"))
1927 {
1928 // if the donate version is already installed, dont disable the app
1929 if (Navit_DonateVersion_Installed == false)
1930 {
1931 if (Navit_Largemap_DonateVersion_Installed == false)
1932 {
1933 // activate [Weltbild] Cat Nova again (19.12.2011)
1934 // ** // unsupported = true;
1935 }
1936 }
1937 }
1938 }
1939 }
1940 catch (Exception e)
1941 {
1942 e.printStackTrace();
1943 }
1944
1945 try
1946 {
1947 // this hangs the emulator, if emulator < 2.3 (only works in emulator >= 2.3)!!
1948 if (!NAVIT_IS_EMULATOR)
1949 {
1950 sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
1951 }
1952 }
1953 catch (Exception e3)
1954 {
1955 e3.printStackTrace();
1956 }
1957
1958 // try
1959 // {
1960 // vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
1961 // }
1962 // catch (Exception e)
1963 // {
1964 // e.printStackTrace();
1965 // }
1966 //sensorManager_ = sensorManager;
1967
1968 // light sensor -------------------
1969 try
1970 {
1971 lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
1972 lightsensor_max_value = lightSensor.getMaximumRange();
1973 lightSensorEventListener = new SensorEventListener()
1974 {
1975 @Override
1976 public void onAccuracyChanged(Sensor sensor, int accuracy)
1977 {
1978 }
1979
1980 @Override
1981 public void onSensorChanged(SensorEvent event)
1982 {
1983 try
1984 {
1985 if (p.PREF_auto_night_mode)
1986 {
1987 if (event.sensor.getType() == Sensor.TYPE_LIGHT)
1988 {
1989
1990 if (Navit.DEBUG_LUX_VALUE)
1991 {
1992 debug_cur_lux_value = event.values[0];
1993 NavitGraphics.NavitAOverlay_s.postInvalidate();
1994 }
1995
1996 // System.out.println("Current Reading(Lux): cur=" + event.values[0] + " max=" + lightsensor_max_value);
1997
1998 if (night_mode == false)
1999 {
2000 if (event.values[0] < p.PREF_night_mode_lux)
2001 {
2002 night_mode = true;
2003 set_night_mode(1);
2004 draw_map();
2005 }
2006 }
2007 else if (night_mode == true)
2008 {
2009 if (event.values[0] > (p.PREF_night_mode_lux + p.PREF_night_mode_buffer))
2010 {
2011 night_mode = false;
2012 set_night_mode(0);
2013 draw_map();
2014 }
2015 }
2016 }
2017 }
2018 else
2019 {
2020 try
2021 {
2022 sensorManager.unregisterListener(lightSensorEventListener);
2023 System.out.println("stop lightsensor");
2024 }
2025 catch (Exception e)
2026 {
2027 }
2028
2029 try
2030 {
2031 night_mode = false;
2032 set_night_mode(0);
2033 draw_map();
2034 }
2035 catch (Exception e)
2036 {
2037 }
2038 }
2039 }
2040 catch (Exception e)
2041 {
2042 // e.printStackTrace();
2043 }
2044 }
2045
2046 };
2047 }
2048 catch (Exception e)
2049 {
2050 }
2051 // light sensor -------------------
2052
2053 generic_alert_box = new AlertDialog.Builder(this);
2054 /*
2055 * show info box for first time users
2056 */
2057 AlertDialog.Builder infobox = new AlertDialog.Builder(this);
2058 //. english text: Welcome to ZANavi
2059 infobox.setTitle(Navit.get_text("__INFO_BOX_TITLE__")); //TRANS
2060 infobox.setCancelable(false);
2061 final TextView message = new TextView(this);
2062 message.setFadingEdgeLength(20);
2063 message.setVerticalFadingEdgeEnabled(true);
2064 message.setPadding(10, 5, 10, 5);
2065 message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
2066 message.setGravity(Gravity.LEFT);
2067 // message.setScrollBarStyle(TextView.SCROLLBARS_INSIDE_OVERLAY);
2068 // message.setVerticalScrollBarEnabled(true);
2069 RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
2070 rlp.leftMargin = 7;
2071 rlp.rightMargin = 7;
2072
2073 Navit.Navit_Geocoder = null;
2074 try
2075 {
2076 // for online search
2077 Navit.Navit_Geocoder = new Geocoder(this);
2078 }
2079 catch (Exception e)
2080 {
2081 e.printStackTrace();
2082 }
2083
2084 //TRANS
2085 infobox.setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
2086 {
2087 public void onClick(DialogInterface arg0, int arg1)
2088 {
2089 Log.e("Navit", "Ok, user saw the infobox");
2090 }
2091 });
2092
2093 //TRANS
2094 infobox.setNeutralButton(Navit.get_text("More info"), new DialogInterface.OnClickListener()
2095 {
2096 public void onClick(DialogInterface arg0, int arg1)
2097 {
2098 Log.e("Navit", "user wants more info, show the website");
2099 // URL to ZANavi Manual (in english language)
2100 String url = "http://zanavi.cc/index.php/Manual";
2101 if (FDBL)
2102 {
2103 url = "http://fd.zanavi.cc/manual";
2104 }
2105 Intent i = new Intent(Intent.ACTION_VIEW);
2106 i.setData(Uri.parse(url));
2107 startActivity(i);
2108 }
2109 });
2110
2111 info_popup_seen_count_end = false;
2112 File navit_first_startup = new File(FIRST_STARTUP_FILE);
2113 // if file does NOT exist, show the info box
2114 if (!navit_first_startup.exists())
2115 {
2116 // set first-ever-startup flag
2117 first_ever_startup = true;
2118 info_popup_seen_count_end = true; // don't show on first ever start of the app
2119 startup_status = Navit_Status_COMPLETE_NEW_INSTALL;
2120 FileOutputStream fos_temp;
2121 try
2122 {
2123 info_popup_seen_count++;
2124 fos_temp = new FileOutputStream(navit_first_startup);
2125 fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count
2126 fos_temp.flush();
2127 fos_temp.close();
2128
2129 message.setLayoutParams(rlp);
2130 //. TRANSLATORS: multiline info text for first startup of application (see en_US for english text)
2131 final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
2132 Linkify.addLinks(s, Linkify.WEB_URLS);
2133 message.setText(s);
2134 message.setMovementMethod(LinkMovementMethod.getInstance());
2135 infobox.setView(message);
2136
2137 infobox.show();
2138 }
2139 catch (Exception e)
2140 {
2141 e.printStackTrace();
2142 }
2143 }
2144 else
2145 {
2146 FileOutputStream fos_temp;
2147 FileInputStream fis_temp;
2148 try
2149 {
2150 fis_temp = new FileInputStream(navit_first_startup);
2151 info_popup_seen_count = fis_temp.read();
2152 fis_temp.close();
2153
2154 if (info_popup_seen_count < 0)
2155 {
2156 info_popup_seen_count = 0;
2157 }
2158
2159 // we wrote "A" -> (int)65 previously, so account for that
2160 if (info_popup_seen_count == 65)
2161 {
2162 info_popup_seen_count = 0;
2163 }
2164
2165 if (info_popup_seen_count > info_popup_seen_count_max)
2166 {
2167 info_popup_seen_count_end = true;
2168 }
2169 else
2170 {
2171 info_popup_seen_count++;
2172 fos_temp = new FileOutputStream(navit_first_startup);
2173 fos_temp.write((int) info_popup_seen_count); // use to store info popup seen count
2174 fos_temp.flush();
2175 fos_temp.close();
2176 }
2177 }
2178 catch (Exception e)
2179 {
2180 e.printStackTrace();
2181 }
2182 }
2183 /*
2184 * show info box for first time users
2185 */
2186
2187 // show info box for upgrade
2188 // if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
2189 // {
2190 // try
2191 // {
2192 // message.setLayoutParams(rlp);
2193 // // upgrade message
2194 // String upgrade_summary = "\n\n***********\n";
2195 // // upgrade message
2196 // final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
2197 // Linkify.addLinks(s, Linkify.WEB_URLS);
2198 // message.setText(s);
2199 // message.setMovementMethod(LinkMovementMethod.getInstance());
2200 // infobox.setView(message);
2201 //
2202 // infobox.show();
2203 // }
2204 // catch (Exception e)
2205 // {
2206 // e.printStackTrace();
2207 // }
2208 //
2209 // }
2210 // show info box for upgrade
2211
2212 //
2213 // ----------- info popup
2214 // ----------- info popup
2215 // ----------- info popup
2216 // ----------- info popup
2217 //
2218 if ((!info_popup_seen_count_end) || (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION))
2219 {
2220 try
2221 {
2222 //Builder a1 = new AlertDialog.Builder(this);
2223 //dialog_info_popup = a1.show();
2224 dialog_info_popup = new Dialog(this);
2225
2226 dialog_info_popup.setContentView(R.layout.info_popup);
2227 Button b_i1 = (Button) dialog_info_popup.findViewById(R.id.dialogButtonOK_i1);
2228
2229 TextView tv_i1 = (TextView) dialog_info_popup.findViewById(R.id.text_i1);
2230 final String ZANAVI_MSG_PLUGIN_MARKET_LINK = "https://play.google.com/store/apps/details?id=com.zoffcc.applications.zanavi_msg";
2231 final String ZANAVI_MSG_PLUGIN_FD_LINK = "https://static.zanavi.cc/app/zanavi_plugin_latest.apk";
2232
2233 // final String ZANAVI_UDONATE_LINK = "http://more.zanavi.cc/donate/";
2234 final String ZANAVI_HOWTO_DEBUG_LINK = "http://static.zanavi.cc/be-a-testdriver/be-a-testdriver.html";
2235 final String ZANAVI_HOWTO_UDONTATE_FREE_LINK = "http://static.zanavi.cc/activate-udonate/activate-udonate.html";
2236
2237 if (FDBL)
2238 {
2239 tv_i1.setText(Html.fromHtml("\n<br>Help us to improve ZANavi, be a Testdriver and send in your route debug information.<br>\n<a href=\"" + ZANAVI_HOWTO_DEBUG_LINK + "\">HowTo be a Testdriver</a><br>\n<br>\n" + "And get the uDonate Version for free.<br>\n<a href=\"" + ZANAVI_HOWTO_UDONTATE_FREE_LINK + "\">get free uDonate version</a>\n" + "\n<br>\n<br>" + "Install the ZANavi Plugin and always know when updated maps are available.<br>\n<a href=\"" + ZANAVI_MSG_PLUGIN_FD_LINK
2240 + "\">download here</a><br>\n"));
2241 }
2242 else
2243 {
2244 tv_i1.setText(Html.fromHtml("\n<br>Help us to improve ZANavi, be a Testdriver and send in your route debug information.<br>\n<a href=\"" + ZANAVI_HOWTO_DEBUG_LINK + "\">HowTo be a Testdriver</a><br>\n<br>\n" + "And get the uDonate Version for free.<br>\n<a href=\"" + ZANAVI_HOWTO_UDONTATE_FREE_LINK + "\">get free uDonate version</a>\n" + "\n<br>\n<br>" + "Install the ZANavi Plugin and always know when updated maps are available.<br>\n<a href=\""
2245 + ZANAVI_MSG_PLUGIN_MARKET_LINK + "\">download here</a><br>\n"));
2246
2247 // 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>"));
2248 // 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>"));
2249 }
2250
2251 try
2252 {
2253 tv_i1.setMovementMethod(LinkMovementMethod.getInstance());
2254 }
2255 catch (Exception ee3)
2256 {
2257 }
2258
2259 b_i1.setText("Ok (" + (1 + info_popup_seen_count_max - info_popup_seen_count) + ")");
2260 b_i1.setOnClickListener(new View.OnClickListener()
2261 {
2262 public void onClick(View v)
2263 {
2264 try
2265 {
2266 dialog_info_popup.cancel();
2267 }
2268 catch (Exception e)
2269 {
2270
2271 }
2272
2273 try
2274 {
2275 dialog_info_popup.dismiss();
2276 }
2277 catch (Exception e)
2278 {
2279
2280 }
2281
2282 try
2283 {
2284 // draw map no-async
2285 Message msg = new Message();
2286 Bundle b = new Bundle();
2287 b.putInt("Callback", 64);
2288 msg.setData(b);
2289 NavitGraphics.callback_handler.sendMessage(msg);
2290 }
2291 catch (Exception e)
2292 {
2293 e.printStackTrace();
2294 }
2295
2296 }
2297 });
2298 dialog_info_popup.setCancelable(true);
2299 dialog_info_popup.show();
2300 dialog_info_popup.getWindow().getDecorView().setBackgroundResource(R.drawable.rounded_bg);
2301 if (FDBL)
2302 {
2303 dialog_info_popup.setTitle(" Support us");
2304 }
2305 else
2306 {
2307 // dialog_info_popup.setTitle(" Try the new Plugin");
2308 dialog_info_popup.setTitle(" Support us");
2309 }
2310 }
2311 catch (Exception e)
2312 {
2313 e.printStackTrace();
2314 }
2315 }
2316 //
2317 // ----------- info popup
2318 // ----------- info popup
2319 // ----------- info popup
2320 //
2321
2322 // make handler statically available for use in "msg_to_msg_handler"
2323 Navit_progress_h = this.progress_handler;
2324
2325 // try
2326 // {
2327 // Navit.bigmap_bitmap = BitmapFactory.decodeResource(getResources(), R.raw.bigmap_colors_zanavi2);
2328 // }
2329 // catch (Exception e)
2330 // {
2331 // // when not enough memory is available, then disable large world overview map!
2332 // System.gc();
2333 // Navit.bigmap_bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
2334 // }
2335 // // ------no----- // Navit.bigmap_bitmap.setDensity(120); // set our dpi!!
2336
2337 try
2338 {
2339 setVolumeControlStream(AudioManager.STREAM_MUSIC);
2340 ActivityResults = new NavitActivityResult[16];
2341 }
2342 catch (Exception e)
2343 {
2344 e.printStackTrace();
2345 }
2346
2347 try
2348 {
2349 NavitAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
2350 }
2351 catch (Exception e)
2352 {
2353 e.printStackTrace();
2354 }
2355
2356 PowerManager pm = null;
2357 try
2358 {
2359 pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
2360 }
2361 catch (Exception e)
2362 {
2363 e.printStackTrace();
2364 }
2365
2366 try
2367 {
2368 // -- // pm.wakeUp(SystemClock.uptimeMillis()); // -- //
2369 // **screen always full on** // wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2370 // **screen can go off, cpu will stay on** // wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2371
2372 // this works so far, lets the screen dim, but it cpu and screen stays on
2373 wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
2374 }
2375 catch (Exception e)
2376 {
2377 e.printStackTrace();
2378 wl = null;
2379 }
2380
2381 try
2382 {
2383 wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ZANaviNeedCpu");
2384 }
2385 catch (Exception e)
2386 {
2387 e.printStackTrace();
2388 wl_cpu = null;
2389 }
2390
2391 try
2392 {
2393 wl_navigating = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "ZANaviNavigationOn");
2394 }
2395 catch (Exception e)
2396 {
2397 Log.e("Navit", "WakeLock NAV: create failed!!");
2398 e.printStackTrace();
2399 wl_navigating = null;
2400 }
2401
2402 // try
2403 // {
2404 // if (wl_navigating != null)
2405 // {
2406 // wl_navigating.acquire();
2407 // Log.e("Navit", "WakeLock NAV: acquire 00");
2408 // }
2409 // }
2410 // catch (Exception e)
2411 // {
2412 // Log.e("Navit", "WakeLock NAV: something wrong 00");
2413 // e.printStackTrace();
2414 // }
2415
2416 // try
2417 // {
2418 // if (wl != null)
2419 // {
2420 // try
2421 // {
2422 // wl.release();
2423 // }
2424 // catch (Exception e2)
2425 // {
2426 // }
2427 // wl.acquire();
2428 // Log.e("Navit", "WakeLock: acquire 1");
2429 // }
2430 // }
2431 // catch (Exception e)
2432 // {
2433 // e.printStackTrace();
2434 // }
2435
2436 // -- extract overview maps --
2437 // -- extract overview maps --
2438
2439 // File navit_worldmap2_file = new File(NAVIT_DATA_DIR + "/share/worldmap2.txt");
2440 File navit_worldmap2_file = new File(MAP_FILENAME_PATH + "/worldmap2.txt");
2441 if (!navit_worldmap2_file.exists())
2442 {
2443 if (!extractRes("worldmap2", MAP_FILENAME_PATH + "/worldmap2.txt"))
2444 {
2445 Log.e("Navit", "Failed to extract worldmap2.txt");
2446 }
2447 }
2448
2449 File navit_worldmap5_file = new File(MAP_FILENAME_PATH + "/worldmap5.txt");
2450 if (!navit_worldmap5_file.exists())
2451 {
2452 if (!extractRes("worldmap5", MAP_FILENAME_PATH + "/worldmap5.txt"))
2453 {
2454 Log.e("Navit", "Failed to extract worldmap5.txt");
2455 }
2456 }
2457 // -- extract overview maps --
2458 // -- extract overview maps --
2459
2460 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
2461 if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
2462 {
2463 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
2464 }
2465
2466 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
2467 if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase(), NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
2468 {
2469 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
2470 }
2471
2472 Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language);
2473 if (!extractRes(NavitTextTranslations.main_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo"))
2474 {
2475 Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language);
2476 }
2477
2478 // DEBUG - check if language file is on SDCARD -
2479 try
2480 {
2481 File debug_mo_src = new File("/sdcard/zanavi/debug/navit.mo");
2482 File debug_mo_dest = new File(NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo");
2483 //* File navit_debug_dir = new File("/sdcard/zanavi/debug/");
2484 //* navit_debug_dir.mkdirs();
2485 copyFile(debug_mo_src, debug_mo_dest);
2486 }
2487 catch (Exception e)
2488 {
2489 e.printStackTrace();
2490 }
2491 // DEBUG - check if language file is on SDCARD -
2492
2493 File navit_config_xml_file = new File(NAVIT_DATA_SHARE_DIR + "/navit.xml");
2494 if ((!navit_config_xml_file.exists()) || (NAVIT_ALWAYS_UNPACK_XMLFILE))
2495 {
2496 xmlconfig_unpack_file = true;
2497 Log.e("Navit", "navit.xml does not exist, unpacking in any case");
2498 }
2499
2500 my_display_density = "mdpi";
2501 // ldpi display (120 dpi)
2502
2503 NavitGraphics.Global_want_dpi = Navit.metrics.densityDpi;
2504 NavitGraphics.Global_want_dpi_other = Navit.metrics.densityDpi;
2505
2506 if (Navit.metrics.densityDpi <= 120)
2507 {
2508 my_display_density = "ldpi";
2509 if (xmlconfig_unpack_file)
2510 {
2511 if (!extractRes("navitldpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2512 {
2513 Log.e("Navit", "Failed to extract navit.xml for ldpi device(s)");
2514 }
2515 }
2516 }
2517 // mdpi display (160 dpi)
2518 else if ((Navit.metrics.densityDpi > 120) && (Navit.metrics.densityDpi <= 160))
2519 {
2520 my_display_density = "mdpi";
2521 if (xmlconfig_unpack_file)
2522 {
2523 if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2524 {
2525 Log.e("Navit", "Failed to extract navit.xml for mdpi device(s)");
2526 }
2527 }
2528 }
2529 // hdpi display (240 dpi)
2530 else if ((Navit.metrics.densityDpi > 160) && (Navit.metrics.densityDpi < 320))
2531 //else if (Navit.metrics.densityDpi == 240)
2532 {
2533 my_display_density = "hdpi";
2534 if (xmlconfig_unpack_file)
2535 {
2536 if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2537 {
2538 Log.e("Navit", "Failed to extract navit.xml for hdpi device(s)");
2539 }
2540 }
2541 }
2542 // xhdpi display (320 dpi)
2543 else if (Navit.metrics.densityDpi >= 320)
2544 {
2545 // set the map display DPI down. otherwise everything will be very small and unreadable
2546 // and performance will be very low
2547 if (p.PREF_shrink_on_high_dpi)
2548 {
2549 NavitGraphics.Global_want_dpi = NavitGraphics.Global_Scaled_DPI_normal;
2550 }
2551 NavitGraphics.Global_want_dpi_other = NavitGraphics.Global_Scaled_DPI_normal;
2552
2553 Log.e("Navit", "found xhdpi device, this is not fully supported yet");
2554 Log.e("Navit", "using hdpi values for compatibility");
2555 my_display_density = "hdpi";
2556 if (xmlconfig_unpack_file)
2557 {
2558 if (!extractRes("navithdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2559 {
2560 Log.e("Navit", "Failed to extract navit.xml for xhdpi device(s)");
2561 }
2562 }
2563 }
2564 else
2565 {
2566 /* default, meaning we just dont know what display this is */
2567 if (xmlconfig_unpack_file)
2568 {
2569 if (!extractRes("navitmdpi", NAVIT_DATA_SHARE_DIR + "/navit.xml"))
2570 {
2571 Log.e("Navit", "Failed to extract navit.xml (default version)");
2572 }
2573 }
2574 }
2575 // Debug.startMethodTracing("calc");
2576
2577 // if (unsupported)
2578 // {
2579 // class CustomListener implements View.OnClickListener
2580 // {
2581 // private final Dialog dialog;
2582 //
2583 // public CustomListener(Dialog dialog)
2584 // {
2585 // this.dialog = dialog;
2586 // }
2587 //
2588 // @Override
2589 // public void onClick(View v)
2590 // {
2591 //
2592 // // Do whatever you want here
2593 //
2594 // // If tou want to close the dialog, uncomment the line below
2595 // //dialog.dismiss();
2596 // }
2597 // }
2598 //
2599 // AlertDialog.Builder dialog = new AlertDialog.Builder(this);
2600 // dialog.setTitle(Navit.get_text("WeltBild Tablet")); //TRANS
2601 // dialog.setCancelable(false);
2602 // dialog.setMessage("Your device is not supported!");
2603 // dialog.show();
2604 // //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
2605 // //theButton.setOnClickListener(new CustomListener(dialog));
2606 // }
2607
2608 int have_dpi = Navit.metrics.densityDpi;
2609
2610 System.out.println("Global_want_dpi[001]=" + NavitGraphics.Global_want_dpi + ":" + Navit.metrics.densityDpi + ":" + NavitGraphics.Global_dpi_factor + ":" + NavitGraphics.Global_dpi_factor_better);
2611
2612 if (NavitGraphics.Global_want_dpi == have_dpi)
2613 {
2614 NavitGraphics.Global_dpi_factor = 1;
2615 NavitGraphics.preview_coord_factor = 1;
2616 }
2617 else
2618 // this was missing??????!!!!!!!!!??????!!!!!!
2619 {
2620 NavitGraphics.Global_dpi_factor = ((float) NavitGraphics.Global_want_dpi / (float) have_dpi);
2621 NavitGraphics.preview_coord_factor = ((float) have_dpi / (float) NavitGraphics.Global_want_dpi);
2622 }
2623
2624 System.out.println("Global_want_dpi[002]=" + NavitGraphics.Global_dpi_factor + ":" + NavitGraphics.preview_coord_factor);
2625
2626 // gggggggggggggggggggggggggg new !!!!!!!!!!!!!!!!!!!!
2627
2628 // --> dont use!! NavitMain(this, langu, android.os.Build.VERSION.SDK_INT);
2629 Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
2630
2631 // -- report share dir back to C-code --
2632 //Message msg2 = new Message();
2633 //Bundle b2 = new Bundle();
2634 //b2.putInt("Callback", 82);
2635 //b2.putString("s", NAVIT_DATA_DIR + "/share/");
2636 //msg2.setData(b2);
2637 //N_NavitGraphics.callback_handler.sendMessage(msg2);
2638 // -- report share dir back to C-code --
2639
2640 // -- report data dir back to C-code --
2641 //msg2 = new Message();
2642 //b2 = new Bundle();
2643 //b2.putInt("Callback", 84);
2644 //b2.putString("s", NAVIT_DATA_DIR + "/");
2645 //msg2.setData(b2);
2646 //N_NavitGraphics.callback_handler.sendMessage(msg2);
2647 // -- report share dir back to C-code --
2648
2649 draw_osd_thread = new drawOSDThread();
2650 draw_osd_thread.start();
2651
2652 cwthr = new CWorkerThread();
2653 cwthr.start();
2654
2655 // --new--
2656 cwthr.StartMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), "" + Navit.metrics.densityDpi, NAVIT_DATA_DIR, NAVIT_DATA_SHARE_DIR);
2657
2658 // --old--
2659 // NavitMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density);
2660 // --old--
2661 // NavitActivity(3);
2662
2663 // CAUTION: don't use android.os.Build.VERSION.SDK_INT if <uses-sdk android:minSdkVersion="3" />
2664 // You will get exception on all devices with Android 1.5 and lower
2665 // because Build.VERSION.SDK_INT is since SDK 4 (Donut 1.6)
2666
2667 // (see: http://developer.android.com/guide/appendix/api-levels.html)
2668 // Platform Version API Level
2669 // =============================================
2670 // Android 4.0.3 15
2671 // Android 4.0, 4.0.1, 4.0.2 14
2672 // Android 3.2 13
2673 // Android 3.1 12
2674 // Android 3.0 11
2675 // Android 2.3.3 10
2676 // Android 2.3.1 9
2677 // Android 2.2 8
2678 // Android 2.1 7
2679 // Android 2.0.1 6
2680 // Android 2.0 5
2681 // Android 1.6 4
2682 // Android 1.5 3
2683 // Android 1.1 2
2684 // Android 1.0 1
2685
2686 Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
2687
2688 //try
2689 //{
2690 // Thread.sleep(2000);
2691 //}
2692 //catch (InterruptedException e)
2693 //{
2694 //}
2695
2696 //getPrefs();
2697 //activatePrefs();
2698
2699 // unpack some localized Strings
2700 // a test now, later we will unpack all needed strings for java, here at this point!!
2701 //String x = NavitGraphics.getLocalizedString("Austria");
2702 //Log.e("Navit", "x=" + x);
2703 Navit.show_mem_used();
2704
2705 /*
2706 * GpsStatus.Listener listener = new GpsStatus.Listener()
2707 * {
2708 * public void onGpsStatusChanged(int event)
2709 * {
2710 * //System.out.println("xxxxx");
2711 * if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS)
2712 * {
2713 * }
2714 * }
2715 * };
2716 */
2717
2718 try
2719 {
2720 Intent sintent = new Intent();
2721 sintent.setPackage("com.zoffcc.applications.zanavi_msg");
2722 sintent.setAction("com.zoffcc.applications.zanavi_msg.ZanaviCloudService");
2723 // ComponentName cname = startService(sintent);
2724 // Log.i("NavitPlugin", "start Service res=" + cname);
2725 // System.out.println("NavitPlugin:bind to Service");
2726 boolean res_bind = bindService(sintent, serviceConnection, Context.BIND_AUTO_CREATE);
2727 // Log.i("NavitPlugin", "bind to Service res=" + res_bind);
2728 }
2729 catch (Exception e)
2730 {
2731 e.printStackTrace();
2732 }
2733 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
2734 }
2735
2736 public static void show_mem_used() // wrapper
2737 {
2738 try
2739 {
2740 Message msg = Navit_progress_h.obtainMessage();
2741 Bundle b = new Bundle();
2742 msg.what = 14;
2743 msg.setData(b);
2744 Navit_progress_h.sendMessage(msg);
2745 }
2746 catch (Exception e)
2747 {
2748 e.printStackTrace();
2749 }
2750 }
2751
2752 public static void show_mem_used_real()
2753 {
2754 try
2755 {
2756 if (p.PREF_show_debug_messages)
2757 {
2758 // --------- OLD method -----------
2759 // --------- OLD method -----------
2760 // int usedMegs;
2761 // //System.gc();
2762 // usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
2763 // //Debug.MemoryInfo meminfo = new Debug.MemoryInfo();
2764 // //Debug.getMemoryInfo(meminfo);
2765 //
2766 // if (usedMegs_old != usedMegs)
2767 // {
2768 // String usedMegsString = String.format("Memory Used: %d MB", usedMegs);
2769 // //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);
2770 // Navit.set_debug_messages2(usedMegsString);
2771 // }
2772 // usedMegs_old = usedMegs;
2773 // --------- OLD method -----------
2774 // --------- OLD method -----------
2775
2776 // --------- NEW method -----------
2777 // --------- NEW method -----------
2778 String usedMegs = logHeap(Global_Navit_Object.getClass());
2779 if (usedMegs_str_old.compareTo(usedMegs) != 0)
2780 {
2781 Navit.set_debug_messages2(usedMegs);
2782 }
2783 usedMegs_str_old = usedMegs;
2784 // --------- NEW method -----------
2785 // --------- NEW method -----------
2786 }
2787 }
2788 catch (Exception e)
2789 {
2790 e.printStackTrace();
2791 }
2792 }
2793
2794 public static void set_debug_messages(String texta, String textb, String textc)
2795 {
2796 try
2797 {
2798 NavitGraphics.debug_line_1 = texta;
2799 NavitGraphics.debug_line_2 = textb;
2800 NavitGraphics.debug_line_3 = textc;
2801 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2802 NavitGraphics.NavitMsgTv_.setLines(4);
2803 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2804 //System.out.println("invalidate 022");
2805 NavitGraphics.NavitMsgTv_.postInvalidate();
2806 }
2807 catch (Exception e)
2808 {
2809 e.printStackTrace();
2810 }
2811 }
2812
2813 public static void set_debug_messages1(String text)
2814 {
2815 try
2816 {
2817 NavitGraphics.debug_line_1 = text;
2818 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2819 NavitGraphics.NavitMsgTv_.setLines(4);
2820 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2821 //System.out.println("invalidate 023");
2822 NavitGraphics.NavitMsgTv_.postInvalidate();
2823 }
2824 catch (Exception e)
2825 {
2826 e.printStackTrace();
2827 }
2828 }
2829
2830 public static void set_debug_messages2(String text)
2831 {
2832 try
2833 {
2834 NavitGraphics.debug_line_2 = text;
2835 //NavitGraphics.NavitMsgTv_.setMaxLines(4);
2836 //NavitGraphics.NavitMsgTv_.setLines(4);
2837
2838 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2839 //System.out.println("invalidate 024");
2840 NavitGraphics.NavitMsgTv_.postInvalidate();
2841 }
2842 catch (Exception e)
2843 {
2844 e.printStackTrace();
2845 }
2846 }
2847
2848 public static void set_debug_messages3(String text)
2849 {
2850 try
2851 {
2852 NavitGraphics.debug_line_3 = text;
2853 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2854 NavitGraphics.NavitMsgTv_.setLines(4);
2855 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2856 //System.out.println("invalidate 025");
2857 NavitGraphics.NavitMsgTv_.postInvalidate();
2858 }
2859 catch (Exception e)
2860 {
2861 e.printStackTrace();
2862 }
2863 }
2864
2865 public static void set_debug_messages4(String text)
2866 {
2867 try
2868 {
2869 NavitGraphics.debug_line_4 = text;
2870 NavitGraphics.NavitMsgTv_.setMaxLines(4);
2871 NavitGraphics.NavitMsgTv_.setLines(4);
2872 NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
2873 //System.out.println("invalidate 026");
2874 NavitGraphics.NavitMsgTv_.postInvalidate();
2875 }
2876 catch (Exception e)
2877 {
2878 e.printStackTrace();
2879 }
2880 }
2881
2882 public static void set_debug_messages3_wrapper(String text)
2883 {
2884 try
2885 {
2886 Message msg = Navit_progress_h.obtainMessage();
2887 Bundle b = new Bundle();
2888 msg.what = 15;
2889 b.putString("text", text);
2890 msg.setData(b);
2891 Navit_progress_h.sendMessage(msg);
2892 }
2893 catch (Exception e)
2894 {
2895 e.printStackTrace();
2896 }
2897 }
2898
2899 public static void set_debug_messages_say_wrapper(String text)
2900 {
2901 try
2902 {
2903 Message msg = Navit_progress_h.obtainMessage();
2904 Bundle b = new Bundle();
2905 msg.what = 30;
2906 b.putString("text", text);
2907 msg.setData(b);
2908 Navit_progress_h.sendMessage(msg);
2909 }
2910 catch (Exception e)
2911 {
2912 e.printStackTrace();
2913 }
2914 }
2915
2916 protected void onNewIntent(Intent intent)
2917 {
2918 super.onNewIntent(intent);
2919
2920 try
2921 {
2922 System.out.println("XXIIXX(2):111");
2923 String mid_str = intent.getExtras().getString("com.zoffcc.applications.zanavi.mid");
2924
2925 System.out.println("XXIIXX(2):111a:mid_str=" + mid_str);
2926
2927 if (mid_str != null)
2928 {
2929 if (mid_str.equals("201:UPDATE-APP"))
2930 {
2931 // a new ZANavi version is available, show something to the user here -------------------
2932 // a new ZANavi version is available, show something to the user here -------------------
2933 // a new ZANavi version is available, show something to the user here -------------------
2934 // a new ZANavi version is available, show something to the user here -------------------
2935 // a new ZANavi version is available, show something to the user here -------------------
2936 // a new ZANavi version is available, show something to the user here -------------------
2937 }
2938 else if (mid_str.startsWith("202:UPDATE-MAP:"))
2939 {
2940 // System.out.println("need to update1:" + mid_str);
2941 // System.out.println("need to update2:" + mid_str.substring(15));
2942
2943 auto_start_update_map(mid_str.substring(15));
2944 }
2945 }
2946
2947 System.out.println("XXIIXX(2):111b:mid_str=" + mid_str);
2948 }
2949 catch (Exception e)
2950 {
2951 e.printStackTrace();
2952 System.out.println("XXIIXX(2):111:EEEE");
2953 }
2954
2955 // ---- Intent dump ----
2956 // ---- Intent dump ----
2957 // ---- Intent dump ----
2958 // ---- Intent dump ----
2959 try
2960 {
2961 System.out.println("XXIIXX(2):" + intent);
2962 Bundle bundle77 = intent.getExtras();
2963 System.out.println("XXIIXX(2):" + intent_flags_to_string(intent.getFlags()));
2964 if (bundle77 == null)
2965 {
2966 System.out.println("XXIIXX(2):" + "null");
2967 }
2968 else
2969 {
2970 for (String key : bundle77.keySet())
2971 {
2972 Object value = bundle77.get(key);
2973 System.out.println("XXIIXX(2):" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
2974 }
2975 }
2976 }
2977 catch (Exception ee22)
2978 {
2979 String exst = Log.getStackTraceString(ee22);
2980 System.out.println("XXIIXX(2):ERR:" + exst);
2981 }
2982 // ---- Intent dump ----
2983 // ---- Intent dump ----
2984 // ---- Intent dump ----
2985 // ---- Intent dump ----
2986
2987 Log.e("Navit", "3:**1**A " + intent.getAction());
2988 Log.e("Navit", "3:**1**D " + intent.getDataString());
2989 Log.e("Navit", "3:**1**S " + intent.toString());
2990 try
2991 {
2992 Log.e("Navit", "3:**1**S " + intent.getExtras().describeContents());
2993 }
2994 catch (Exception ee3)
2995 {
2996 }
2997
2998 // if (Navit.startup_intent == null)
2999 {
3000 try
3001 {
3002 // make a copy of the given intent object
3003 // Navit.startup_intent = intent.cloneFilter();
3004 Navit.startup_intent = intent;
3005
3006 Log.e("Navit", "3a:**1**001");
3007 Bundle extras2 = intent.getExtras();
3008 Log.e("Navit", "3a:**1**002");
3009 try
3010 {
3011 Navit.startup_intent.putExtras(extras2);
3012 Log.e("Navit", "3a:**1**003");
3013 }
3014 catch (Exception e4)
3015 {
3016 if (startup_intent.getDataString() != null)
3017 {
3018 // we have a "geo:" thingy intent, use it
3019 // or "gpx file"
3020 Log.e("Navit", "3c:**1**A " + startup_intent.getAction());
3021 Log.e("Navit", "3c:**1**D " + startup_intent.getDataString());
3022 Log.e("Navit", "3c:**1**S " + startup_intent.toString());
3023 }
3024 else
3025 {
3026 Log.e("Navit", "3X:**1**X ");
3027 Navit.startup_intent = null;
3028 }
3029
3030 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
3031 Navit.startup_intent_timestamp = System.currentTimeMillis();
3032
3033 return;
3034 }
3035
3036 // Intent { act=android.intent.action.VIEW
3037 // cat=[android.intent.category.DEFAULT]
3038 // dat=file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
3039 // cmp=com.zoffcc.applications.zanavi/.Navit }
3040
3041 // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
3042 Navit.startup_intent_timestamp = System.currentTimeMillis();
3043 Log.e("Navit", "3a:**1**A " + startup_intent.getAction());
3044 Log.e("Navit", "3a:**1**D " + startup_intent.getDataString());
3045 Log.e("Navit", "3a:**1**S " + startup_intent.toString());
3046 if (extras2 != null)
3047 {
3048 long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
3049 // System.out.println("DH:a007 l=" + l);
3050 if (l != 0L)
3051 {
3052 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
3053 {
3054 // Log.e("Navit", "2:**1** started via drive home");
3055 // we have been called from "drive home" widget
3056
3057 // drive home
3058
3059 // check if we have a home location
3060 int home_id = find_home_point();
3061
3062 if (home_id != -1)
3063 {
3064 Message msg7 = progress_handler.obtainMessage();
3065 Bundle b7 = new Bundle();
3066 msg7.what = 2; // long Toast message
3067 b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
3068 msg7.setData(b7);
3069 progress_handler.sendMessage(msg7);
3070
3071 // clear any previous destinations
3072 Message msg2 = new Message();
3073 Bundle b2 = new Bundle();
3074 b2.putInt("Callback", 7);
3075 msg2.setData(b2);
3076 NavitGraphics.callback_handler.sendMessage(msg2);
3077
3078 // set position to middle of screen -----------------------
3079 // set position to middle of screen -----------------------
3080 // set position to middle of screen -----------------------
3081 // Message msg67 = new Message();
3082 // Bundle b67 = new Bundle();
3083 // b67.putInt("Callback", 51);
3084 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
3085 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
3086 // msg67.setData(b67);
3087 // N_NavitGraphics.callback_handler.sendMessage(msg67);
3088 // set position to middle of screen -----------------------
3089 // set position to middle of screen -----------------------
3090 // set position to middle of screen -----------------------
3091
3092 try
3093 {
3094 Thread.sleep(60);
3095 }
3096 catch (Exception e)
3097 {
3098 }
3099
3100 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);
3101
3102 // Navit.destination_set();
3103 //
3104 // // set destination to home location
3105 // String lat = String.valueOf(map_points.get(home_id).lat);
3106 // String lon = String.valueOf(map_points.get(home_id).lon);
3107 // String q = map_points.get(home_id).point_name;
3108 //
3109 // // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
3110 //
3111 // Message msg55 = new Message();
3112 // Bundle b55 = new Bundle();
3113 // b55.putInt("Callback", 3);
3114 // b55.putString("lat", lat);
3115 // b55.putString("lon", lon);
3116 // b55.putString("q", q);
3117 // msg55.setData(b55);
3118 // NavitGraphics.callback_handler.sendMessage(msg55);
3119
3120 final Thread zoom_to_route_001 = new Thread()
3121 {
3122 int wait = 1;
3123 int count = 0;
3124 int max_count = 60;
3125
3126 @Override
3127 public void run()
3128 {
3129 while (wait == 1)
3130 {
3131 try
3132 {
3133 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3134 {
3135 zoom_to_route();
3136 wait = 0;
3137 }
3138 else
3139 {
3140 wait = 1;
3141 }
3142
3143 count++;
3144 if (count > max_count)
3145 {
3146 wait = 0;
3147 }
3148 else
3149 {
3150 Thread.sleep(400);
3151 }
3152 }
3153 catch (Exception e)
3154 {
3155 }
3156 }
3157 }
3158 };
3159 zoom_to_route_001.start();
3160
3161 // try
3162 // {
3163 // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3164 // }
3165 // catch (Exception e2)
3166 // {
3167 // e2.printStackTrace();
3168 // }
3169
3170 try
3171 {
3172 Navit.follow_button_on();
3173 }
3174 catch (Exception e2)
3175 {
3176 e2.printStackTrace();
3177 }
3178 }
3179 else
3180 {
3181 // no home location set
3182 Message msg = progress_handler.obtainMessage();
3183 Bundle b = new Bundle();
3184 msg.what = 2; // long Toast message
3185 b.putString("text", Navit.get_text("No Home Location set")); //TRANS
3186 msg.setData(b);
3187 progress_handler.sendMessage(msg);
3188 }
3189
3190 }
3191 }
3192 else
3193 {
3194 if (startup_intent.getDataString() != null)
3195 {
3196 // we have a "geo:" thingy intent, use it
3197 // or "gpx file"
3198 }
3199 else
3200 {
3201 Navit.startup_intent = null;
3202 }
3203 }
3204 }
3205 else
3206 {
3207 if (startup_intent.getDataString() != null)
3208 {
3209 // we have a "geo:" thingy intent, use it
3210 }
3211 else
3212 {
3213 Navit.startup_intent = null;
3214 }
3215 }
3216 }
3217 catch (Exception e99)
3218 {
3219 Navit.startup_intent = null;
3220 }
3221
3222 }
3223
3224 }
3225
3226 @Override
3227 public void onStart()
3228 {
3229 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3230
3231 Navit.show_mem_used();
3232
3233 super.onStart();
3234
3235 Log.e("Navit", "OnStart");
3236
3237 while (Global_Init_Finished == 0)
3238 {
3239 Log.e("Navit", "OnStart:Global_Init_Finished==0 !!!!!");
3240 try
3241 {
3242 Thread.sleep(60, 0); // sleep
3243 }
3244 catch (InterruptedException e)
3245 {
3246 }
3247 }
3248
3249 cwthr.NavitActivity2(2);
3250
3251 getPrefs();
3252 activatePrefs();
3253 sun_moon__mLastCalcSunMillis = -1L;
3254
3255 // paint for bitmapdrawing on map
3256 if (p.PREF_use_anti_aliasing)
3257 {
3258 NavitGraphics.paint_for_map_display.setAntiAlias(true);
3259 }
3260 else
3261 {
3262 NavitGraphics.paint_for_map_display.setAntiAlias(false);
3263 }
3264 if (p.PREF_use_map_filtering)
3265 {
3266 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
3267 }
3268 else
3269 {
3270 NavitGraphics.paint_for_map_display.setFilterBitmap(false);
3271 }
3272
3273 // activate gps AFTER 3g-location
3274 NavitVehicle.turn_on_precise_provider();
3275
3276 Navit.show_mem_used();
3277
3278 // restore points
3279 read_map_points();
3280
3281 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3282 }
3283
3284 @Override
3285 public void onRestart()
3286 {
3287 super.onRestart();
3288 Log.e("Navit", "OnRestart");
3289
3290 while (Global_Init_Finished == 0)
3291 {
3292 Log.e("Navit", "onRestart:Global_Init_Finished==0 !!!!!");
3293 try
3294 {
3295 Thread.sleep(60, 0); // sleep
3296 }
3297 catch (InterruptedException e)
3298 {
3299 }
3300 }
3301
3302 cwthr.NavitActivity2(0);
3303 NavitVehicle.turn_on_sat_status();
3304 }
3305
3306 @SuppressLint("NewApi")
3307 @Override
3308 public void onResume()
3309 {
3310 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
3311
3312 // System.gc();
3313 super.onResume();
3314
3315 try
3316 {
3317 sensorManager.registerListener(lightSensorEventListener, lightSensor, (int) (8 * 1000000)); // updates approx. every 8 seconds
3318 }
3319 catch (Exception e)
3320 {
3321 }
3322
3323 // get the intent fresh !! ----------
3324 startup_intent = this.getIntent();
3325 // get the intent fresh !! ----------
3326
3327 PackageInfo pkgInfo;
3328 Navit_Plugin_001_Installed = false;
3329 try
3330 {
3331 // is the donate version installed?
3332 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_msg", 0);
3333 String sharedUserId = pkgInfo.sharedUserId;
3334 System.out.println("str nd=" + sharedUserId);
3335 if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
3336 {
3337 System.out.println("##plugin 001##");
3338 Navit_Plugin_001_Installed = true;
3339 }
3340 }
3341 catch (Exception e)
3342 {
3343 e.printStackTrace();
3344 }
3345
3346 // ---- Intent dump ----
3347 // ---- Intent dump ----
3348 // ---- Intent dump ----
3349 // ---- Intent dump ----
3350
3351 try
3352 {
3353 System.out.println("XXIIXX:111");
3354 String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid");
3355 System.out.println("XXIIXX:111a:mid_str=" + mid_str);
3356
3357 if (mid_str != null)
3358 {
3359 if (mid_str.equals("201:UPDATE-APP"))
3360 {
3361 // a new ZANavi version is available, show something to the user here -------------------
3362 // a new ZANavi version is available, show something to the user here -------------------
3363 // a new ZANavi version is available, show something to the user here -------------------
3364 // a new ZANavi version is available, show something to the user here -------------------
3365 // a new ZANavi version is available, show something to the user here -------------------
3366 // a new ZANavi version is available, show something to the user here -------------------
3367 }
3368 else if (mid_str.startsWith("202:UPDATE-MAP:"))
3369 {
3370 System.out.println("need to update1:" + mid_str);
3371 System.out.println("need to update2:" + mid_str.substring(15));
3372
3373 auto_start_update_map(mid_str.substring(15));
3374 }
3375 }
3376
3377 System.out.println("XXIIXX:111b:mid_str=" + mid_str);
3378 }
3379 catch (Exception e)
3380 {
3381 e.printStackTrace();
3382 System.out.println("XXIIXX:111:EEEE");
3383 }
3384
3385 try
3386 {
3387 System.out.println("XXIIXX:" + this.getIntent());
3388 Bundle bundle77 = this.getIntent().getExtras();
3389 System.out.println("XXIIXX:" + intent_flags_to_string(this.getIntent().getFlags()));
3390 if (bundle77 == null)
3391 {
3392 System.out.println("XXIIXX:" + "null");
3393 }
3394 else
3395 {
3396 for (String key : bundle77.keySet())
3397 {
3398 Object value = bundle77.get(key);
3399 System.out.println("XXIIXX:" + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
3400 }
3401 }
3402 }
3403 catch (Exception ee22)
3404 {
3405 String exst = Log.getStackTraceString(ee22);
3406 System.out.println("XXIIXX:ERR:" + exst);
3407 }
3408 // ---- Intent dump ----
3409 // ---- Intent dump ----
3410 // ---- Intent dump ----
3411 // ---- Intent dump ----
3412
3413 is_paused = false;
3414
3415 Navit_doubleBackToExitPressedOnce = false;
3416
3417 app_window = getWindow();
3418
3419 Log.e("Navit", "OnResume");
3420
3421 while (Global_Init_Finished == 0)
3422 {
3423 Log.e("Navit", "OnResume:Global_Init_Finished==0 !!!!!");
3424 try
3425 {
3426 Thread.sleep(30, 0); // sleep
3427 }
3428 catch (InterruptedException e)
3429 {
3430 }
3431 }
3432
3433 //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
3434 cwthr.NavitActivity2(1);
3435
3436 try
3437 {
3438 NSp.resume_me();
3439 }
3440 catch (Exception e)
3441 {
3442 e.printStackTrace();
3443 }
3444
3445 NavitVehicle.turn_on_sat_status();
3446
3447 try
3448 {
3449 if (wl != null)
3450 {
3451 // try
3452 // {
3453 // wl.release();
3454 // }
3455 // catch (Exception e2)
3456 // {
3457 // }
3458 wl.acquire();
3459 Log.e("Navit", "WakeLock: acquire 2");
3460 }
3461 }
3462 catch (Exception e)
3463 {
3464 e.printStackTrace();
3465 }
3466
3467 //Intent caller = this.getIntent();
3468 //System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
3469 //System.out.println("C=" + caller.getComponent().flattenToString());
3470
3471 if (unsupported)
3472 {
3473 class CustomListener implements View.OnClickListener
3474 {
3475 private final Dialog dialog;
3476
3477 public CustomListener(Dialog dialog)
3478 {
3479 this.dialog = dialog;
3480 }
3481
3482 @Override
3483 public void onClick(View v)
3484 {
3485
3486 // Do whatever you want here
3487
3488 // If you want to close the dialog, uncomment the line below
3489 //dialog.dismiss();
3490 }
3491 }
3492
3493 AlertDialog.Builder dialog = new AlertDialog.Builder(this);
3494 dialog.setTitle("WeltBild Tablet");
3495 dialog.setCancelable(false);
3496 dialog.setMessage("Your device is not supported!");
3497 dialog.show();
3498 //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
3499 //theButton.setOnClickListener(new CustomListener(dialog));
3500 }
3501
3502 // reset "maps too old" flag
3503 Navit_maps_too_old = false;
3504
3505 if (Navit_maps_loaded == false)
3506 {
3507 Navit_maps_loaded = true;
3508 // activate all maps
3509 Log.e("Navit", "**** LOAD ALL MAPS **** start");
3510 Message msg3 = new Message();
3511 Bundle b3 = new Bundle();
3512 b3.putInt("Callback", 20);
3513 msg3.setData(b3);
3514 NavitGraphics.callback_handler.sendMessage(msg3);
3515 Log.e("Navit", "**** LOAD ALL MAPS **** end");
3516 }
3517
3518 try
3519 {
3520 if (!have_maps_installed())
3521 {
3522 // System.out.println("MMMM=no maps installed");
3523 // show semi transparent box "no maps installed" ------------------
3524 // show semi transparent box "no maps installed" ------------------
3525 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
3526 try
3527 {
3528 NavitGraphics.no_maps_container.setActivated(true);
3529 }
3530 catch (NoSuchMethodError e)
3531 {
3532 }
3533
3534 show_case_001();
3535
3536 // show semi transparent box "no maps installed" ------------------
3537 // show semi transparent box "no maps installed" ------------------
3538 }
3539 else
3540 {
3541 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
3542 try
3543 {
3544 NavitGraphics.no_maps_container.setActivated(false);
3545 }
3546 catch (NoSuchMethodError e)
3547 {
3548 }
3549 }
3550 }
3551 catch (Exception e)
3552 {
3553 e.printStackTrace();
3554 }
3555
3556 try
3557 {
3558 // draw map no-async
3559 Message msg = new Message();
3560 Bundle b = new Bundle();
3561 b.putInt("Callback", 64);
3562 msg.setData(b);
3563 NavitGraphics.callback_handler.sendMessage(msg);
3564 }
3565 catch (Exception e)
3566 {
3567 e.printStackTrace();
3568 }
3569
3570 String intent_data = null;
3571 try
3572 {
3573 //Log.e("Navit", "**9**A " + startup_intent.getAction());
3574 //Log.e("Navit", "**9**D " + startup_intent.getDataString());
3575
3576 int type = 1; // default = assume it's a map coords intent
3577
3578 try
3579 {
3580 String si = startup_intent.getDataString();
3581 String tmp2 = si.split(":", 2)[0];
3582 Log.e("Navit", "**9a**A " + startup_intent.getAction());
3583 Log.e("Navit", "**9a**D " + startup_intent.getDataString() + " " + tmp2);
3584 if (tmp2.equals("file"))
3585 {
3586 Log.e("Navit", "**9b**D " + startup_intent.getDataString() + " " + tmp2);
3587 if (si.toLowerCase().endsWith(".gpx"))
3588 {
3589 Log.e("Navit", "**9c**D " + startup_intent.getDataString() + " " + tmp2);
3590 type = 4;
3591 }
3592 }
3593 }
3594 catch (Exception e2)
3595 {
3596 }
3597
3598 if (type != 4)
3599 {
3600 Bundle extras = startup_intent.getExtras();
3601 // System.out.println("DH:001");
3602 if (extras != null)
3603 {
3604 // System.out.println("DH:002");
3605 long l = extras.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
3606 // System.out.println("DH:003 l=" + l);
3607 if (l != 0L)
3608 {
3609 // System.out.println("DH:004");
3610 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
3611 {
3612 // System.out.println("DH:005");
3613 type = 2; // call from drive-home-widget
3614 }
3615 // ok, now remove that key
3616 extras.remove("com.zoffcc.applications.zanavi");
3617 startup_intent.replaceExtras((Bundle) null);
3618 // System.out.println("DH:006");
3619 }
3620 }
3621 }
3622
3623 // ------------------------ BIG LOOP ------------------------
3624 // ------------------------ BIG LOOP ------------------------
3625 if (type == 2)
3626 {
3627 // drive home
3628
3629 // check if we have a home location
3630 int home_id = find_home_point();
3631
3632 if (home_id != -1)
3633 {
3634 Message msg7 = progress_handler.obtainMessage();
3635 Bundle b7 = new Bundle();
3636 msg7.what = 2; // long Toast message
3637 b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
3638 msg7.setData(b7);
3639 progress_handler.sendMessage(msg7);
3640
3641 // clear any previous destinations
3642 Message msg2 = new Message();
3643 Bundle b2 = new Bundle();
3644 b2.putInt("Callback", 7);
3645 msg2.setData(b2);
3646 NavitGraphics.callback_handler.sendMessage(msg2);
3647
3648 // set position to middle of screen -----------------------
3649 // set position to middle of screen -----------------------
3650 // set position to middle of screen -----------------------
3651 // Message msg67 = new Message();
3652 // Bundle b67 = new Bundle();
3653 // b67.putInt("Callback", 51);
3654 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
3655 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
3656 // msg67.setData(b67);
3657 // N_NavitGraphics.callback_handler.sendMessage(msg67);
3658 // set position to middle of screen -----------------------
3659 // set position to middle of screen -----------------------
3660 // set position to middle of screen -----------------------
3661
3662 try
3663 {
3664 Thread.sleep(60);
3665 }
3666 catch (Exception e)
3667 {
3668 }
3669
3670 Navit.destination_set();
3671
3672 // set destination to home location
3673 // String lat = String.valueOf(map_points.get(home_id).lat);
3674 // String lon = String.valueOf(map_points.get(home_id).lon);
3675 // String q = map_points.get(home_id).point_name;
3676 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);
3677
3678 final Thread zoom_to_route_001 = new Thread()
3679 {
3680 int wait = 1;
3681 int count = 0;
3682 int max_count = 60;
3683
3684 @Override
3685 public void run()
3686 {
3687 while (wait == 1)
3688 {
3689 try
3690 {
3691 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
3692 {
3693 zoom_to_route();
3694 wait = 0;
3695 }
3696 else
3697 {
3698 wait = 1;
3699 }
3700
3701 count++;
3702 if (count > max_count)
3703 {
3704 wait = 0;
3705 }
3706 else
3707 {
3708 Thread.sleep(400);
3709 }
3710 }
3711 catch (Exception e)
3712 {
3713 }
3714 }
3715 }
3716 };
3717 zoom_to_route_001.start();
3718
3719 // try
3720 // {
3721 // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3722 // }
3723 // catch (Exception e2)
3724 // {
3725 // e2.printStackTrace();
3726 // }
3727
3728 try
3729 {
3730 Navit.follow_button_on();
3731 }
3732 catch (Exception e2)
3733 {
3734 e2.printStackTrace();
3735 }
3736 }
3737 else
3738 {
3739 // no home location set
3740 Message msg = progress_handler.obtainMessage();
3741 Bundle b = new Bundle();
3742 msg.what = 2; // long Toast message
3743 b.putString("text", Navit.get_text("No Home Location set")); //TRANS
3744 msg.setData(b);
3745 progress_handler.sendMessage(msg);
3746 }
3747 }
3748 else if (type == 4)
3749 {
3750
3751 if (startup_intent != null)
3752 {
3753 // Log.e("Navit", "**7**A " + startup_intent.getAction() + System.currentTimeMillis() + " " + Navit.startup_intent_timestamp);
3754 if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
3755 {
3756 Log.e("Navit", "**7**A " + startup_intent.getAction());
3757 Log.e("Navit", "**7**D " + startup_intent.getDataString());
3758 intent_data = startup_intent.getDataString();
3759 try
3760 {
3761 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
3762 }
3763 catch (Exception e1)
3764 {
3765 e1.printStackTrace();
3766 }
3767
3768 // we consumed the intent, so reset timestamp value to avoid double consuming of event
3769 Navit.startup_intent_timestamp = 0L;
3770
3771 if (intent_data != null)
3772 {
3773 // file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
3774 String tmp1;
3775 tmp1 = intent_data.split(":", 2)[1].substring(2);
3776
3777 Log.e("Navit", "**7**f=" + tmp1);
3778
3779 // convert gpx file ---------------------
3780 convert_gpx_file_real(tmp1);
3781 }
3782 }
3783 }
3784 }
3785 else if (type == 1)
3786 {
3787 if (startup_intent != null)
3788 {
3789 if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
3790 {
3791 Log.e("Navit", "**2**A " + startup_intent.getAction());
3792 Log.e("Navit", "**2**D " + startup_intent.getDataString());
3793 intent_data = startup_intent.getDataString();
3794 // we consumed the intent, so reset timestamp value to avoid double consuming of event
3795 Navit.startup_intent_timestamp = 0L;
3796
3797 if (intent_data != null)
3798 {
3799 // set position to middle of screen -----------------------
3800 // set position to middle of screen -----------------------
3801 // set position to middle of screen -----------------------
3802 // Message msg67 = new Message();
3803 // Bundle b67 = new Bundle();
3804 // b67.putInt("Callback", 51);
3805 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
3806 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
3807 // msg67.setData(b67);
3808 // N_NavitGraphics.callback_handler.sendMessage(msg67);
3809 // set position to middle of screen -----------------------
3810 // set position to middle of screen -----------------------
3811 // set position to middle of screen -----------------------
3812 }
3813 }
3814 else
3815 {
3816 Log.e("Navit", "timestamp for navigate_to expired! not using data");
3817 }
3818 }
3819
3820 System.out.println("SUI:000a " + intent_data);
3821
3822 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/"))))
3823 {
3824
3825 System.out.println("SUI:000b");
3826
3827 // better use regex later, but for now to test this feature its ok :-)
3828 // better use regex later, but for now to test this feature its ok :-)
3829
3830 // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
3831 // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
3832 // b: google.navigation:q=48.25676,16.643
3833 // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
3834 // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
3835 // sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
3836 // -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
3837 // f: google.navigation:ll=48.25676,16.643&...
3838 // c: google.navigation:ll=48.25676,16.643
3839 // h: http://maps.google.com/?q=48.222210,16.387058&z=16
3840 // i: https://maps.google.com/?q=48.222210,16.387058&z=16
3841 // i:,h: https://maps.google.com/maps/place?ftid=0x476d07075e933fc5:0xccbeba7fe1e3dd36&q=48.222210,16.387058&ui=maps_mini
3842 //
3843 // ??!!new??!!: http://maps.google.com/?cid=10549738100504591748&hl=en&gl=gb
3844
3845 String lat;
3846 String lon;
3847 String q;
3848
3849 String temp1 = null;
3850 String temp2 = null;
3851 String temp3 = null;
3852 boolean parsable = false;
3853 boolean unparsable_info_box = true;
3854 try
3855 {
3856 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
3857 }
3858 catch (Exception e1)
3859 {
3860 e1.printStackTrace();
3861 }
3862
3863 // DEBUG
3864 // DEBUG
3865 // DEBUG
3866 // intent_data = "google.navigation:q=Wien Burggasse 27";
3867 // intent_data = "google.navigation:q=48.25676,16.643";
3868 // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
3869 // intent_data = "google.navigation:ll=48.25676,16.643";
3870 // DEBUG
3871 // DEBUG
3872 // DEBUG
3873
3874 try
3875 {
3876 Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
3877 Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
3878 Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
3879 Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
3880 Log.e("Navit", "found DEBUG 4.1: yy" + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
3881 Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
3882 }
3883 catch (Exception e)
3884 {
3885 e.printStackTrace();
3886 }
3887
3888 if (!Navit.NavitStartupAlreadySearching)
3889 {
3890 if (intent_data.length() > 19)
3891 {
3892 // if h: then show target
3893 if (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/"))
3894 {
3895 Uri uri = Uri.parse(intent_data);
3896 Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
3897 parsable = true;
3898 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3899 }
3900 // if i: then show target
3901 else if (substring_without_ioobe(intent_data, 0, 24).equals("https://maps.google.com/"))
3902 {
3903 Uri uri = Uri.parse(intent_data);
3904 Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
3905 parsable = true;
3906 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3907 }
3908 // if d: then start target search
3909 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]"))))
3910 {
3911 Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
3912 Navit.NavitStartupAlreadySearching = true;
3913 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
3914 // dont use this here, already starting search, so set to "false"
3915 parsable = false;
3916 unparsable_info_box = false;
3917 }
3918 // if b: then remodel the input string to look like a:
3919 else if (substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q="))
3920 {
3921 intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
3922 Log.e("Navit", "target found (b): " + intent_data);
3923 parsable = true;
3924 }
3925 // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
3926 else if (substring_without_ioobe(intent_data, 0, 25).equals("google.navigation:///?ll="))
3927 {
3928 intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
3929 Log.e("Navit", "target found (g): " + intent_data);
3930 parsable = true;
3931 }
3932 // if e: then remodel the input string to look like a:
3933 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")))
3934 {
3935 int idx = intent_data.indexOf("&");
3936 intent_data = substring_without_ioobe(intent_data, 0, idx) + "&q=Target";
3937 Log.e("Navit", "target found (e): " + intent_data);
3938 parsable = true;
3939 }
3940 // if f: then remodel the input string to look like a:
3941 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
3942 {
3943 int idx = intent_data.indexOf("&");
3944 intent_data = intent_data.substring(0, idx) + "&q=Target";
3945 Log.e("Navit", "target found (f): " + intent_data);
3946 parsable = true;
3947 }
3948 // already looks like a: just set flag
3949 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
3950 {
3951 // dummy, just set the flag
3952 Log.e("Navit", "target found (a): " + intent_data);
3953 Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
3954 parsable = true;
3955 }
3956 // if c: then remodel the input string to look like a:
3957 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
3958 {
3959
3960 intent_data = intent_data + "&q=Target";
3961 Log.e("Navit", "target found (c): " + intent_data);
3962 parsable = true;
3963 }
3964 }
3965 }
3966 else
3967 {
3968 Log.e("Navit", "already started search from startup intent");
3969 parsable = false;
3970 unparsable_info_box = false;
3971 }
3972
3973 if (parsable)
3974 {
3975 // now string should be in form --> a:
3976 // now split the parts off
3977 temp1 = intent_data.split("&q=", -1)[0];
3978 try
3979 {
3980 temp3 = temp1.split("ll=", -1)[1];
3981 temp2 = intent_data.split("&q=", -1)[1];
3982 }
3983 catch (Exception e)
3984 {
3985 // java.lang.ArrayIndexOutOfBoundsException most likely
3986 // so let's assume we dont have '&q=xxxx'
3987 temp3 = temp1;
3988 }
3989
3990 if (temp2 == null)
3991 {
3992 // use some default name
3993 temp2 = "Target";
3994 }
3995
3996 lat = temp3.split(",", -1)[0];
3997 lon = temp3.split(",", -1)[1];
3998 q = temp2;
3999 // is the "search name" url-encoded? i think so, lets url-decode it here
4000 q = URLDecoder.decode(q);
4001 // System.out.println();
4002
4003 Navit.remember_destination(q, lat, lon);
4004 Navit.destination_set();
4005
4006 Message msg = new Message();
4007 Bundle b = new Bundle();
4008 b.putInt("Callback", 3);
4009 b.putString("lat", lat);
4010 b.putString("lon", lon);
4011 b.putString("q", q);
4012 msg.setData(b);
4013 NavitGraphics.callback_handler.sendMessage(msg);
4014
4015 final Thread zoom_to_route_002 = new Thread()
4016 {
4017 int wait = 1;
4018 int count = 0;
4019 int max_count = 60;
4020
4021 @Override
4022 public void run()
4023 {
4024 while (wait == 1)
4025 {
4026 try
4027 {
4028 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
4029 {
4030 zoom_to_route();
4031 wait = 0;
4032 }
4033 else
4034 {
4035 wait = 1;
4036 }
4037
4038 count++;
4039 if (count > max_count)
4040 {
4041 wait = 0;
4042 }
4043 else
4044 {
4045 Thread.sleep(400);
4046 }
4047 }
4048 catch (Exception e)
4049 {
4050 }
4051 }
4052 }
4053 };
4054 zoom_to_route_002.start();
4055
4056 // try
4057 // {
4058 // Thread.sleep(400);
4059 // }
4060 // catch (InterruptedException e)
4061 // {
4062 // }
4063 //
4064 // // try
4065 // // {
4066 // // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
4067 // // }
4068 // // catch (Exception e2)
4069 // // {
4070 // // e2.printStackTrace();
4071 // // }
4072
4073 try
4074 {
4075 Navit.follow_button_on();
4076 }
4077 catch (Exception e2)
4078
4079 {
4080 e2.printStackTrace();
4081 }
4082 }
4083 else
4084 {
4085 if (unparsable_info_box && !searchBoxShown)
4086 {
4087 try
4088 {
4089 searchBoxShown = true;
4090 String searchString = intent_data.split("q=")[1];
4091 searchString = searchString.split("&")[0];
4092 searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
4093 Log.e("Navit", "Search String :" + searchString);
4094 executeSearch(searchString);
4095 }
4096 catch (Exception e)
4097 {
4098 // safety net
4099 try
4100 {
4101 Log.e("Navit", "problem with startup search 7 str=" + intent_data);
4102 }
4103 catch (Exception e2)
4104 {
4105 e2.printStackTrace();
4106 }
4107 }
4108 }
4109 }
4110 }
4111 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 10).equals("geo:0,0?q=")))
4112 {
4113 // g: geo:0,0?q=wien%20burggasse
4114
4115 System.out.println("SUI:001");
4116
4117 boolean parsable = false;
4118 boolean unparsable_info_box = true;
4119 try
4120 {
4121 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
4122 }
4123 catch (Exception e1)
4124 {
4125 e1.printStackTrace();
4126
4127 }
4128
4129 System.out.println("SUI:002");
4130
4131 if (!Navit.NavitStartupAlreadySearching)
4132 {
4133 if (intent_data.length() > 10)
4134 {
4135 // if g: then start target search
4136 Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
4137 Navit.NavitStartupAlreadySearching = true;
4138 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
4139 // dont use this here, already starting search, so set to "false"
4140 parsable = false;
4141 unparsable_info_box = false;
4142 }
4143 }
4144 else
4145 {
4146 Log.e("Navit", "already started search from startup intent");
4147 parsable = false;
4148 unparsable_info_box = false;
4149 }
4150
4151 if (unparsable_info_box && !searchBoxShown)
4152 {
4153 try
4154 {
4155 searchBoxShown = true;
4156 String searchString = intent_data.split("q=")[1];
4157 searchString = searchString.split("&")[0];
4158 searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
4159 Log.e("Navit", "Search String :" + searchString);
4160 executeSearch(searchString);
4161 }
4162 catch (Exception e)
4163 {
4164 // safety net
4165 try
4166 {
4167 Log.e("Navit", "problem with startup search 88 str=" + intent_data);
4168 }
4169 catch (Exception e2)
4170 {
4171 e2.printStackTrace();
4172 }
4173 }
4174 }
4175
4176 }
4177 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 4).equals("geo:")))
4178 {
4179 // g: geo:16.8,46.3?z=15
4180
4181 System.out.println("SUI:002a");
4182
4183 boolean parsable = false;
4184 boolean unparsable_info_box = true;
4185
4186 String tmp1;
4187 String tmp2;
4188 String tmp3;
4189 float lat1 = 0;
4190 float lon1 = 0;
4191 int zoom1 = 15;
4192
4193 try
4194 {
4195 intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
4196 }
4197 catch (Exception e1)
4198 {
4199 e1.printStackTrace();
4200 }
4201
4202 if (!Navit.NavitStartupAlreadySearching)
4203 {
4204 try
4205 {
4206 tmp1 = intent_data.split(":", 2)[1];
4207 tmp2 = tmp1.split("\\?", 2)[0];
4208 tmp3 = tmp1.split("\\?", 2)[1];
4209 lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
4210 lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
4211 zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
4212 parsable = true;
4213 }
4214 catch (Exception e4)
4215 {
4216 e4.printStackTrace();
4217 }
4218 }
4219
4220 if (parsable)
4221 {
4222 // geo: intent -> only show destination on map!
4223
4224 // set nice zoomlevel before we show destination
4225 // int zoom_want = zoom1;
4226 // //
4227 // Message msg = new Message();
4228 // Bundle b = new Bundle();
4229 // b.putInt("Callback", 33);
4230 // b.putString("s", Integer.toString(zoom_want));
4231 // msg.setData(b);
4232 // try
4233 // {
4234 // N_NavitGraphics.callback_handler.sendMessage(msg);
4235 // Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
4236 // if ((zoom_want > 8) && (zoom_want < 17))
4237 // {
4238 // Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
4239 // System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
4240 // }
4241 // }
4242 // catch (Exception e)
4243 // {
4244 // e.printStackTrace();
4245 // }
4246 // if (PREF_save_zoomlevel)
4247 // {
4248 // setPrefs_zoomlevel();
4249 // }
4250 // set nice zoomlevel before we show destination
4251
4252 try
4253 {
4254 Navit.follow_button_off();
4255 }
4256 catch (Exception e2)
4257 {
4258 e2.printStackTrace();
4259 }
4260
4261 show_geo_on_screen(lat1, lon1);
4262 // final Thread zoom_to_route_003 = new Thread()
4263 // {
4264 // @Override
4265 // public void run()
4266 // {
4267 // try
4268 // {
4269 // Thread.sleep(200);
4270 // show_geo_on_screen(lat1, lon1);
4271 // }
4272 // catch (Exception e)
4273 // {
4274 // }
4275 // }
4276 // };
4277 // zoom_to_route_003.start();
4278
4279 }
4280 }
4281 }
4282
4283 System.out.println("SUI:099 XX" + substring_without_ioobe(intent_data, 0, 10) + "XX");
4284
4285 // clear intent
4286 startup_intent = null;
4287 // ------------------------ BIG LOOP ------------------------
4288 // ------------------------ BIG LOOP ------------------------
4289 }
4290 catch (Exception e)
4291 {
4292 e.printStackTrace();
4293 System.out.println("SUI:199");
4294 }
4295
4296 // clear intent
4297 startup_intent = null;
4298
4299 // hold all map drawing -----------
4300 Message msg = new Message();
4301 Bundle b = new Bundle();
4302 b.putInt("Callback", 69);
4303 msg.setData(b);
4304 try
4305 {
4306 NavitGraphics.callback_handler.sendMessage(msg);
4307 }
4308 catch (Exception e)
4309 {
4310 }
4311 // hold all map drawing -----------
4312
4313 getPrefs();
4314 activatePrefs();
4315 sun_moon__mLastCalcSunMillis = -1L;
4316
4317 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
4318 if (p.PREF_follow_gps)
4319 {
4320 push_pin_view.setImageResource(R.drawable.pin1_down);
4321 }
4322 else
4323 {
4324 push_pin_view.setImageResource(R.drawable.pin1_up);
4325 }
4326
4327 // paint for bitmapdrawing on map
4328 if (p.PREF_use_anti_aliasing)
4329 {
4330 NavitGraphics.paint_for_map_display.setAntiAlias(true);
4331 }
4332 else
4333 {
4334 NavitGraphics.paint_for_map_display.setAntiAlias(false);
4335 }
4336 if (p.PREF_use_map_filtering)
4337 {
4338 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
4339 }
4340 else
4341 {
4342 NavitGraphics.paint_for_map_display.setFilterBitmap(false);
4343 }
4344
4345 // activate gps AFTER 3g-location
4346 NavitVehicle.turn_on_precise_provider();
4347
4348 // allow all map drawing -----------
4349 msg = new Message();
4350 b = new Bundle();
4351 b.putInt("Callback", 70);
4352 msg.setData(b);
4353 try
4354 {
4355 NavitGraphics.callback_handler.sendMessage(msg);
4356 }
4357 catch (Exception e)
4358 {
4359 }
4360 // allow all map drawing -----------
4361
4362 // --- disabled --- NavitVehicle.set_last_known_pos_fast_provider();
4363
4364 try
4365 {
4366 //Simulate = new SimGPS(NavitVehicle.vehicle_handler_);
4367 //Simulate.start();
4368 }
4369 catch (Exception e)
4370 {
4371 e.printStackTrace();
4372 }
4373
4374 try
4375 {
4376 watchmem = new WatchMem();
4377 watchmem.start();
4378 }
4379 catch (Exception e)
4380 {
4381 e.printStackTrace();
4382 }
4383
4384 // ----- check if we have some index files downloaded -----
4385 if (Navit.have_maps_installed())
4386 {
4387 if (Navit_maps_too_old)
4388 {
4389 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4390 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");
4391
4392 try
4393 {
4394 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4395 try
4396 {
4397 NavitGraphics.no_maps_container.setActivated(true);
4398 }
4399 catch (NoSuchMethodError e)
4400 {
4401 }
4402 NavitGraphics.no_maps_container.bringToFront();
4403 }
4404 catch (Exception e)
4405 {
4406 e.printStackTrace();
4407 }
4408 }
4409 else
4410 {
4411 allow_use_index_search();
4412 if (Navit_index_on_but_no_idx_files)
4413 {
4414 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4415 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");
4416
4417 try
4418 {
4419 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4420 try
4421 {
4422 NavitGraphics.no_maps_container.setActivated(true);
4423 }
4424 catch (NoSuchMethodError e)
4425 {
4426 }
4427 NavitGraphics.no_maps_container.bringToFront();
4428 }
4429 catch (Exception e)
4430 {
4431 e.printStackTrace();
4432 }
4433 }
4434 else
4435 {
4436 try
4437 {
4438 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
4439 try
4440 {
4441 NavitGraphics.no_maps_container.setActivated(false);
4442 }
4443 catch (NoSuchMethodError e)
4444 {
4445 }
4446 }
4447 catch (Exception e)
4448 {
4449 e.printStackTrace();
4450 }
4451 }
4452 }
4453 }
4454 // ----- check if we have some index files downloaded -----
4455
4456 // ---- DEBUG ----
4457 // ---- DEBUG ----
4458 // ---- DEBUG ----
4459 try
4460 {
4461 if (!NavitVehicle.is_pos_recording)
4462 {
4463 if (p.PREF_enable_debug_write_gpx)
4464 {
4465 NavitVehicle.pos_recording_start();
4466 NavitVehicle.pos_recording_add(0, 0, 0, 0, 0, 0);
4467 }
4468 }
4469 }
4470 catch (Exception e)
4471 {
4472 }
4473 // ---- DEBUG ----
4474 // ---- DEBUG ----
4475 // ---- DEBUG ----
4476
4477 // glSurfaceView.onResume();
4478
4479 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
4480
4481 if (Navit.CIDEBUG == 1)
4482 {
4483 new Thread()
4484 {
4485 public void run()
4486 {
4487 try
4488 {
4489 System.out.println("DR_run_all_yaml_tests --> want");
4490
4491 if (CIRUN == false)
4492 {
4493 System.out.println("DR_run_all_yaml_tests --> do");
4494 CIRUN = true;
4495 Thread.sleep(20000); // 20 secs.
4496 ZANaviDebugReceiver.DR_run_all_yaml_tests();
4497 }
4498 }
4499 catch (Exception e)
4500 {
4501 }
4502 }
4503 }.start();
4504 }
4505 }
4506
4507 @TargetApi(Build.VERSION_CODES.FROYO)
4508 @Override
4509 public void onPause()
4510 {
4511
4512 // if COMM stuff is running, stop it!
4513 ZANaviDebugReceiver.stop_me = true;
4514
4515 try
4516 {
4517 sensorManager.unregisterListener(lightSensorEventListener);
4518 }
4519 catch (Exception e)
4520 {
4521 }
4522
4523 // ---- DEBUG ----
4524 // ---- DEBUG ----
4525 // ---- DEBUG ----
4526 // -- dump all callbacks --
4527 try
4528 {
4529 if (p.PREF_enable_debug_functions)
4530 {
4531 Message msg99a = new Message();
4532 Bundle b99a = new Bundle();
4533 b99a.putInt("Callback", 100);
4534 msg99a.setData(b99a);
4535 N_NavitGraphics.callback_handler.sendMessage(msg99a);
4536 }
4537 }
4538 catch (Exception e)
4539 {
4540 }
4541 // -- dump all callbacks --
4542 // ---- DEBUG ----
4543 // ---- DEBUG ----
4544 // ---- DEBUG ----
4545
4546 // ---- DEBUG ----
4547 // ---- DEBUG ----
4548 // ---- DEBUG ----
4549 try
4550 {
4551 if (!Navit.is_navigating)
4552 {
4553 if (p.PREF_enable_debug_write_gpx)
4554 {
4555 NavitVehicle.pos_recording_end();
4556 }
4557 }
4558 }
4559 catch (Exception e)
4560 {
4561 }
4562 // ---- DEBUG ----
4563 // ---- DEBUG ----
4564 // ---- DEBUG ----
4565
4566 // System.out.println("@@ onPause @@");
4567 Log.e("Navit", "OnPause");
4568 try
4569 {
4570 setPrefs_zoomlevel();
4571 }
4572 catch (Exception e)
4573 {
4574 e.printStackTrace();
4575 }
4576
4577 try
4578 {
4579 watchmem.stop_me();
4580 }
4581 catch (Exception e)
4582 {
4583 e.printStackTrace();
4584 }
4585
4586 try
4587 {
4588 //watchmem.join();
4589 }
4590 catch (Exception e)
4591 {
4592 e.printStackTrace();
4593 }
4594
4595 try
4596 {
4597 //Simulate.stop_me();
4598 }
4599 catch (Exception e)
4600 {
4601 e.printStackTrace();
4602 }
4603
4604 try
4605 {
4606 //Simulate.join();
4607 }
4608 catch (Exception e)
4609 {
4610 e.printStackTrace();
4611 }
4612
4613 Navit.show_mem_used();
4614
4615 // if (!Navit.is_navigating)
4616 // {
4617 // try
4618 // {
4619 // mTts.stop();
4620 // }
4621 // catch (Exception e)
4622 // {
4623 //
4624 // }
4625 //
4626 // try
4627 // {
4628 // mTts.shutdown();
4629 // }
4630 // catch (Exception e)
4631 // {
4632 //
4633 // }
4634 //
4635 // mTts = null;
4636 // }
4637
4638 super.onPause();
4639
4640 // signal to backupmanager that data "is / could have" changed
4641 try
4642 {
4643 Class.forName("android.app.backup.BackupManager");
4644 BackupManager b = (BackupManager) backupManager;
4645 b.dataChanged();
4646 }
4647 catch (ClassNotFoundException e)
4648 {
4649 e.printStackTrace();
4650 }
4651 catch (Exception e)
4652 {
4653 e.printStackTrace();
4654 }
4655
4656 turn_off_compass();
4657
4658 // System.out.println("XXNAV: onpause:001");
4659 if (!Navit.is_navigating)
4660 {
4661 // System.out.println("XXNAV: onpause:002");
4662 NavitVehicle.turn_off_all_providers();
4663 NavitVehicle.turn_off_sat_status();
4664 // System.out.println("XXNAV: onpause:003");
4665 }
4666
4667 // Log.e("Navit", "OnPause");
4668 cwthr.NavitActivity2(-1);
4669
4670 Navit.show_mem_used();
4671
4672 try
4673 {
4674 if (wl != null)
4675 {
4676 wl.release();
4677 Log.e("Navit", "WakeLock: release 1");
4678 }
4679 }
4680 catch (Exception e)
4681 {
4682 e.printStackTrace();
4683 }
4684
4685 try
4686 {
4687 if (wl_cpu != null)
4688 {
4689 if (wl_cpu.isHeld())
4690 {
4691 wl_cpu.release();
4692 Log.e("Navit", "WakeLock CPU: release 1");
4693 }
4694 }
4695 }
4696 catch (Exception e)
4697 {
4698 e.printStackTrace();
4699 }
4700
4701 // glSurfaceView.onPause();
4702
4703 is_paused = true;
4704 }
4705
4706 @Override
4707 public void onStop()
4708 {
4709 super.onStop();
4710 Log.e("Navit", "OnStop");
4711
4712 if (!Navit.is_navigating)
4713 {
4714 NavitVehicle.turn_off_all_providers();
4715 NavitVehicle.turn_off_sat_status();
4716 }
4717
4718 cwthr.NavitActivity2(-2);
4719 Navit.show_mem_used();
4720
4721 // if (!Navit.is_navigating)
4722 // {
4723 // try
4724 // {
4725 // mTts.stop();
4726 // }
4727 // catch (Exception e)
4728 // {
4729 //
4730 // }
4731 //
4732 // try
4733 // {
4734 // mTts.shutdown();
4735 // }
4736 // catch (Exception e)
4737 // {
4738 //
4739 // }
4740 //
4741 // mTts = null;
4742 // }
4743
4744 // save points
4745 write_map_points();
4746 }
4747
4748 @Override
4749 public void onDestroy()
4750 {
4751 super.onDestroy();
4752 Log.e("Navit", "OnDestroy");
4753
4754 try
4755 {
4756 try
4757 {
4758 plugin_api.removeListener(zclientListener);
4759 }
4760 catch (Exception e)
4761 {
4762 e.printStackTrace();
4763 Log.i("NavitPlugin", "Failed to remove Listener", e);
4764 }
4765 unbindService(serviceConnection);
4766 Log.i("NavitPlugin", "Unbind from the service");
4767 }
4768 catch (Throwable t)
4769 {
4770 // catch any issues, typical for destroy routines
4771 // even if we failed to destroy something, we need to continue destroying
4772 Log.i("NavitPlugin", "Failed to unbind from the service", t);
4773 }
4774
4775 try
4776 {
4777 mTts.stop();
4778 }
4779 catch (Exception e)
4780 {
4781
4782 }
4783
4784 try
4785 {
4786 mTts.shutdown();
4787 }
4788 catch (Exception e)
4789 {
4790
4791 }
4792
4793 mTts = null;
4794
4795 // ----- service stop -----
4796 // ----- service stop -----
4797 System.out.println("Navit:onDestroy -> stop ZANaviMapDownloaderService ---------");
4798 stopService(Navit.ZANaviMapDownloaderServiceIntent);
4799 try
4800 {
4801 Thread.sleep(1000);
4802 }
4803 catch (InterruptedException e)
4804 {
4805 }
4806 // ----- service stop -----
4807 // ----- service stop -----
4808
4809 NavitActivity(-3);
4810 Navit.show_mem_used();
4811 }
4812
4813 public void setActivityResult(int requestCode, NavitActivityResult ActivityResult)
4814 {
4815 Log.e("Navit", "setActivityResult " + requestCode);
4816 ActivityResults[requestCode] = ActivityResult;
4817 }
4818
4819 @Override
4820 public boolean onKeyUp(int keyCode, KeyEvent event)
4821 {
4822 if (keyCode == KeyEvent.KEYCODE_MENU)
4823 {
4824 if (cur_menu != null)
4825 {
4826 // open the overflow menu
4827 cur_menu.performIdentifierAction(R.id.item_overflow, 0);
4828 return true;
4829 }
4830 }
4831 return super.onKeyUp(keyCode, event);
4832 }
4833
4834 // @Override
4835 // public boolean onKeyDown(int keyCode, KeyEvent event)
4836 // {
4837 // if (keyCode == KeyEvent.KEYCODE_MENU)
4838 // {
4839 // return true;
4840 // }
4841 // return super.onKeyUp(keyCode, event);
4842 // }
4843
4844 @Override
4845 public boolean onPrepareOptionsMenu(Menu menu)
4846 {
4847 super.onPrepareOptionsMenu(menu);
4848 //
4849 menu.clear();
4850
4851 // load the menu from XML
4852 getMenuInflater().inflate(R.menu.actionbaricons, menu);
4853
4854 // NavitOverflowMenuItemID = R.id.item_overflow_menu_button;
4855 menu.findItem(R.id.share_menu_destination).setTitle(Navit.get_text("Share Destination"));
4856 menu.findItem(R.id.share_menu_location).setTitle(Navit.get_text("Share my Location"));
4857 menu.findItem(R.id.search_menu_offline).setTitle(get_text("address search (offline)"));
4858 menu.findItem(R.id.search_menu_online).setTitle(get_text("address search (online)"));
4859 menu.findItem(R.id.item_recentdest_menu_button).setTitle(get_text("Recent destinations"));
4860 menu.findItem(R.id.item_settings_menu_button).setTitle(get_text("Settings"));
4861 menu.findItem(R.id.item_search_menu_button).setTitle(get_text("Search"));
4862 menu.findItem(R.id.item_download_menu_button).setTitle(get_text("downloading map"));
4863 //
4864 menu.findItem(R.id.overflow_share_location).setTitle(Navit.get_text("Share my Location"));
4865 menu.findItem(R.id.overflow_share_destination).setTitle(Navit.get_text("Share Destination"));
4866 menu.findItem(R.id.overflow_settings).setTitle(Navit.get_text("Settings"));
4867 menu.findItem(R.id.overflow_zoom_to_route).setTitle(Navit.get_text("Zoom to Route"));
4868
4869 if (ZANaviNormalDonateActivity.on_amazon_device)
4870 {
4871 menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate"));
4872 }
4873 else
4874 {
4875 menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate with Google Play"));
4876 }
4877 menu.findItem(R.id.overflow_donate_bitcoins_item).setTitle(Navit.get_text("Donate with Bitcoin"));
4878 //. TRANSLATORS: text to translate is: exit ZANavi
4879 menu.findItem(R.id.overflow_exit).setTitle(Navit.get_text("exit navit"));
4880 menu.findItem(R.id.overflow_toggle_poi).setTitle(Navit.get_text("toggle POI"));
4881 menu.findItem(R.id.overflow_announcer_on).setTitle(Navit.get_text("Announcer On"));
4882 menu.findItem(R.id.overflow_announcer_off).setTitle(Navit.get_text("Announcer Off"));
4883 menu.findItem(R.id.overflow_download_maps).setTitle(Navit.get_text("download maps"));
4884 menu.findItem(R.id.overflow_delete_maps).setTitle(Navit.get_text("delete maps"));
4885 menu.findItem(R.id.overflow_maps_age).setTitle(Navit.get_text("show Maps age"));
4886 menu.findItem(R.id.overflow_coord_dialog).setTitle(Navit.get_text("Coord Dialog"));
4887 menu.findItem(R.id.overflow_add_traffic_block).setTitle(Navit.get_text("add Traffic block"));
4888 menu.findItem(R.id.overflow_clear_traffic_block).setTitle(Navit.get_text("clear Traffic blocks"));
4889 menu.findItem(R.id.overflow_convert_gpx_file).setTitle(Navit.get_text("convert GPX file"));
4890 menu.findItem(R.id.overflow_replay_gps_file).setTitle(Navit.get_text("replay a ZANavi gps file"));
4891 menu.findItem(R.id.overflow_yaml_tests).setTitle(Navit.get_text("run YAML tests"));
4892 menu.findItem(R.id.overflow_clear_gpx_map).setTitle(Navit.get_text("clear GPX map"));
4893 // menu.findItem(R.id.overflow_dummy2)
4894 menu.findItem(R.id.overflow_demo_v_normal).setTitle(get_text("Demo Vehicle") + " [normal]");
4895 menu.findItem(R.id.overflow_demo_v_fast).setTitle(get_text("Demo Vehicle") + " [fast]");
4896 menu.findItem(R.id.overflow_speech_texts).setTitle(Navit.get_text("Speech Texts"));
4897 menu.findItem(R.id.overflow_nav_commands).setTitle(Navit.get_text("Nav. Commands"));
4898 menu.findItem(R.id.overflow_toggle_route_graph).setTitle(Navit.get_text("toggle Routegraph"));
4899 //menu.findItem(R.id.overflow_dummy1)
4900 menu.findItem(R.id.overflow_export_map_points_to_sdcard).setTitle(Navit.get_text("export Destinations"));
4901 menu.findItem(R.id.overflow_import_map_points_from_sdcard).setTitle(Navit.get_text("import Destinations"));
4902 menu.findItem(R.id.overflow_send_feedback).setTitle(Navit.get_text("send feedback"));
4903 menu.findItem(R.id.overflow_online_help).setTitle(Navit.get_text("online Help"));
4904 //. TRANSLATORS: it means: "show current target in google maps"
4905 //. TRANSLATORS: please keep this text short, to fit in the android menu!
4906 menu.findItem(R.id.overflow_target_in_gmaps).setTitle(Navit.get_text("Target in gmaps"));
4907 //
4908 //
4909 menu.findItem(R.id.item_share_menu_button).setTitle(get_text("Share"));
4910
4911 Display display_ = getWindowManager().getDefaultDisplay();
4912 Log.e("Navit", "Navit width in DP -> " + display_.getWidth() / Navit.metrics.density);
4913 Log.e("Navit", "Navit width in DP -> density=" + Navit.metrics.density);
4914
4915 try
4916 {
4917 View v4 = findViewById(R.id.item_settings_menu_button);
4918 // Log.e("Navit", "Navit width in DP -> v4=" + v4);
4919 if ((v4 != null) && (v4.getWidth() > 0))
4920 {
4921 Log.e("Navit", "Navit width in DP -> v4.w=" + v4.getWidth());
4922 MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
4923 // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
4924 // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
4925 Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
4926 actionbar_item_width = (int) ((v4.getWidth() + (menuItem.getIcon().getIntrinsicWidth() * 1.5f)) / 2);
4927 }
4928 else
4929 {
4930 MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
4931 // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
4932 // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
4933 Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
4934 actionbar_item_width = (int) ((menuItem.getIcon().getIntrinsicWidth()) * 1.7f);
4935 }
4936
4937 actionbar_items_will_fit = display_.getWidth() / actionbar_item_width;
4938 Log.e("Navit", "Navit width in DP -> number of items that will fit=" + actionbar_items_will_fit);
4939 if (actionbar_items_will_fit > 6) // now we need to fit max. 6 items on actionbar
4940 {
4941 actionbar_all_items_will_fit = true;
4942 }
4943 else
4944 {
4945 actionbar_all_items_will_fit = false;
4946 }
4947 }
4948 catch (Exception e)
4949 {
4950 if ((display_.getWidth() / Navit.metrics.density) < NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR)
4951 {
4952 actionbar_all_items_will_fit = false;
4953 }
4954 else
4955 {
4956 actionbar_all_items_will_fit = true;
4957 }
4958 }
4959
4960 if (actionbar_all_items_will_fit == false)
4961 {
4962 menu.findItem(R.id.item_share_menu_button).setVisible(false);
4963 menu.findItem(R.id.overflow_share_location).setVisible(true);
4964 if (NavitGraphics.CallbackDestinationValid2() == 0)
4965 {
4966 menu.findItem(R.id.overflow_share_destination).setVisible(false);
4967 }
4968 else
4969 {
4970 menu.findItem(R.id.overflow_share_destination).setVisible(true);
4971 }
4972
4973 if (actionbar_items_will_fit < 6)
4974 {
4975 // also push the settings icons to overflow menu
4976 menu.findItem(R.id.item_settings_menu_button).setVisible(false);
4977 menu.findItem(R.id.overflow_settings).setVisible(true);
4978 }
4979 else
4980 {
4981 menu.findItem(R.id.item_settings_menu_button).setVisible(true);
4982 menu.findItem(R.id.overflow_settings).setVisible(false);
4983 }
4984 }
4985 else
4986 {
4987 menu.findItem(R.id.item_settings_menu_button).setVisible(true);
4988 menu.findItem(R.id.overflow_settings).setVisible(false);
4989 menu.findItem(R.id.overflow_share_location).setVisible(false);
4990 menu.findItem(R.id.overflow_share_destination).setVisible(false);
4991 menu.findItem(R.id.item_share_menu_button).setVisible(true);
4992 }
4993
4994 cur_menu = menu;
4995
4996 if (actionabar_download_icon_visible)
4997 {
4998 menu.findItem(R.id.item_download_menu_button).setVisible(true);
4999 }
5000 else
5001 {
5002 menu.findItem(R.id.item_download_menu_button).setVisible(false);
5003 }
5004
5005 if (NavitGraphics.CallbackDestinationValid2() > 0)
5006 {
5007 menu.findItem(R.id.item_endnavigation_menu_button).setVisible(true);
5008 menu.findItem(R.id.item_endnavigation_menu_button).setTitle(get_text("Stop Navigation"));
5009 menu.findItem(R.id.overflow_zoom_to_route).setVisible(true);
5010 menu.findItem(R.id.overflow_target_in_gmaps).setVisible(true);
5011 menu.findItem(R.id.share_menu_destination).setVisible(true);
5012 }
5013 else
5014 {
5015 menu.findItem(R.id.item_endnavigation_menu_button).setVisible(false);
5016 menu.findItem(R.id.overflow_zoom_to_route).setVisible(false);
5017 menu.findItem(R.id.overflow_target_in_gmaps).setVisible(false);
5018 menu.findItem(R.id.share_menu_destination).setVisible(false);
5019 }
5020
5021 if (Navit_Announcer == true)
5022 {
5023 menu.findItem(R.id.overflow_announcer_off).setVisible(true);
5024 menu.findItem(R.id.overflow_announcer_on).setVisible(false);
5025 }
5026 else
5027 {
5028 menu.findItem(R.id.overflow_announcer_off).setVisible(false);
5029 menu.findItem(R.id.overflow_announcer_on).setVisible(true);
5030 }
5031
5032 if (p.PREF_enable_debug_functions)
5033 {
5034 menu.findItem(R.id.overflow_dummy2).setVisible(true);
5035 menu.findItem(R.id.overflow_demo_v_normal).setVisible(true);
5036 menu.findItem(R.id.overflow_demo_v_fast).setVisible(true);
5037 menu.findItem(R.id.overflow_speech_texts).setVisible(true);
5038 menu.findItem(R.id.overflow_nav_commands).setVisible(true);
5039 menu.findItem(R.id.overflow_toggle_route_graph).setVisible(true);
5040 menu.findItem(R.id.overflow_replay_gps_file).setVisible(true);
5041 menu.findItem(R.id.overflow_yaml_tests).setVisible(true);
5042 }
5043 else
5044 {
5045 menu.findItem(R.id.overflow_dummy2).setVisible(false);
5046 menu.findItem(R.id.overflow_demo_v_normal).setVisible(false);
5047 menu.findItem(R.id.overflow_demo_v_fast).setVisible(false);
5048 menu.findItem(R.id.overflow_speech_texts).setVisible(false);
5049 menu.findItem(R.id.overflow_nav_commands).setVisible(false);
5050 menu.findItem(R.id.overflow_toggle_route_graph).setVisible(false);
5051 menu.findItem(R.id.overflow_replay_gps_file).setVisible(false);
5052 menu.findItem(R.id.overflow_yaml_tests).setVisible(false);
5053 }
5054
5055 return true;
5056 }
5057
5058 public void start_targetsearch_from_intent(String target_address)
5059 {
5060 Navit_last_address_partial_match = true; // this will overwrite the default setting --> this is not good
5061 Navit_last_address_search_string = target_address;
5062 Navit_last_address_hn_string = "";
5063
5064 // ----------- CONFIG ---------
5065 // ----------- CONFIG ---------
5066 // ----------- CONFIG ---------
5067 Boolean use_online_searchmode_here = true;
5068 Boolean hide_duplicates_searchmode_here = false;
5069 // ----------- CONFIG ---------
5070 // ----------- CONFIG ---------
5071 // ----------- CONFIG ---------
5072
5073 int dialog_num_;
5074
5075 if (use_online_searchmode_here)
5076 {
5077 dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG;
5078 Navit.use_index_search = false;
5079 Log.e("Navit", "*google*:online search");
5080 }
5081 else
5082 {
5083 dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE;
5084 Navit.use_index_search = Navit.allow_use_index_search();
5085 }
5086
5087 // clear results
5088 Navit.NavitAddressResultList_foundItems.clear();
5089 Navit.Navit_Address_Result_double_index.clear();
5090 Navit.NavitSearchresultBarIndex = -1;
5091 Navit.NavitSearchresultBar_title = "";
5092 Navit.NavitSearchresultBar_text = "";
5093 search_hide_duplicates = false;
5094
5095 if (Navit_last_address_search_string.equals(""))
5096 {
5097 // empty search string entered
5098 Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
5099 }
5100 else
5101 {
5102 // show dialog
5103 try
5104 {
5105 Log.e("Navit", "*google*:call-11: (0)num " + dialog_num_);
5106 }
5107 catch (Exception e)
5108 {
5109 e.printStackTrace();
5110 }
5111
5112 if (hide_duplicates_searchmode_here)
5113 {
5114 search_hide_duplicates = true;
5115 // hide duplicates when searching
5116 // hide duplicates when searching
5117 Message msg22 = new Message();
5118 Bundle b22 = new Bundle();
5119 b22.putInt("Callback", 45);
5120 msg22.setData(b22);
5121 NavitGraphics.callback_handler.sendMessage(msg22);
5122 // hide duplicates when searching
5123 // hide duplicates when searching
5124 }
5125
5126 System.out.println("dialog -- 11:002");
5127 Message msg = progress_handler.obtainMessage();
5128 Bundle b = new Bundle();
5129 msg.what = 11;
5130 b.putInt("dialog_num", dialog_num_);
5131 msg.setData(b);
5132 progress_handler.sendMessage(msg);
5133 }
5134 }
5135
5136 @Override
5137 public boolean onCreateOptionsMenu(Menu menu)
5138 {
5139 super.onCreateOptionsMenu(menu);
5140
5141 return true;
5142 }
5143
5144 @Override
5145 public boolean onOptionsItemSelected(MenuItem item)
5146 {
5147 //System.out.println("menu button pressed ID=" + item.getItemId());
5148
5149 if ((item.getItemId() == R.id.share_menu_destination) || (item.getItemId() == R.id.overflow_share_destination) || (item.getItemId() == 23020))
5150 {
5151 // System.out.println("share destination pressed ID=" + item.getItemId());
5152 // ------------
5153 // ------------
5154 // share the current destination with your friends
5155 String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5156 if (current_target_string2.equals("x:x"))
5157 {
5158 Log.e("Navit", "no target set!");
5159 }
5160 else
5161 {
5162 try
5163 {
5164 String tmp[] = current_target_string2.split(":", 2);
5165
5166 if (Navit.OSD_route_001.arriving_time_valid)
5167 {
5168 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
5169 }
5170 else
5171 {
5172 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5173 }
5174
5175 }
5176 catch (Exception e)
5177 {
5178 e.printStackTrace();
5179 Log.e("Navit", "problem with target!");
5180 }
5181 }
5182 return true;
5183 }
5184 else if (item.getItemId() == R.id.item_download_menu_button)
5185 {
5186 // System.out.println("download icon pressed(1) ID=" + item.getItemId());
5187
5188 Intent mapdownload_cancel_activity = new Intent(this, ZANaviDownloadMapCancelActivity.class);
5189 mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
5190 startActivity(mapdownload_cancel_activity);
5191
5192 return true;
5193 }
5194 else if ((item.getItemId() == R.id.share_menu_location) || (item.getItemId() == R.id.overflow_share_location) || (item.getItemId() == 23000))
5195 {
5196 // System.out.println("share location pressed ID=" + item.getItemId());
5197 // ------------
5198 // ------------
5199 // share the current location with your friends
5200 location_coords cur_target = new location_coords();
5201 try
5202 {
5203 geo_coord tmp = get_current_vehicle_position();
5204 cur_target.lat = tmp.Latitude;
5205 cur_target.lon = tmp.Longitude;
5206
5207 if ((cur_target.lat == 0.0) && (cur_target.lon == 0.0))
5208 {
5209 cur_target = NavitVehicle.get_last_known_pos();
5210 }
5211 }
5212 catch (Exception e)
5213 {
5214 cur_target = null;
5215 try
5216 {
5217 cur_target = NavitVehicle.get_last_known_pos();
5218 }
5219 catch (Exception e2)
5220 {
5221 cur_target = null;
5222 }
5223 }
5224
5225 if (cur_target == null)
5226 {
5227 Log.e("Navit", "no location found!");
5228 }
5229 else
5230 {
5231 try
5232 {
5233 share_location(String.valueOf(cur_target.lat), String.valueOf(cur_target.lon), Navit.get_text("my Location"), Navit.get_text("my Location"), "", false);
5234 }
5235 catch (Exception e)
5236 {
5237 e.printStackTrace();
5238 Log.e("Navit", "problem with location!");
5239 }
5240 }
5241 return true;
5242 }
5243 else if ((item.getItemId() == R.id.item_settings_menu_button) || (item.getItemId() == R.id.overflow_settings) || (item.getItemId() == 490))
5244 {
5245 // open settings menu
5246 Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
5247 startActivity(settingsActivity);
5248
5249 return true;
5250 }
5251 else if (item.getItemId() == R.id.search_menu_offline)
5252 {
5253 // ok startup address search activity (offline binfile search)
5254 Navit.use_index_search = Navit.allow_use_index_search();
5255 Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
5256 search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5257 search_intent2.putExtra("address_string", Navit_last_address_search_string);
5258 search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
5259 search_intent2.putExtra("type", "offline");
5260 search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);
5261
5262 String pm_temp2 = "0";
5263 if (Navit_last_address_partial_match)
5264 {
5265 pm_temp2 = "1";
5266 }
5267
5268 search_intent2.putExtra("partial_match", pm_temp2);
5269
5270 Navit.use_index_search = Navit.allow_use_index_search();
5271 if (Navit.use_index_search)
5272 {
5273 this.startActivityForResult(search_intent2, NavitAddressResultList_id);
5274 }
5275 else
5276 {
5277 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
5278 }
5279
5280 return true;
5281 }
5282 else if (item.getItemId() == R.id.search_menu_online)
5283 {
5284 // ok startup address search activity (online google maps search)
5285 Navit.use_index_search = false;
5286 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
5287 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5288 search_intent.putExtra("address_string", Navit_last_address_search_string);
5289 //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
5290 search_intent.putExtra("type", "online");
5291 String pm_temp = "0";
5292 if (Navit_last_address_partial_match)
5293 {
5294 pm_temp = "1";
5295 }
5296 search_intent.putExtra("partial_match", pm_temp);
5297 this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
5298
5299 return true;
5300 }
5301 else if (item.getItemId() == R.id.item_endnavigation_menu_button)
5302 {
5303 // stop navigation (this menu should only appear when navigation is actually on!)
5304 NavitGraphics.deactivate_nav_wakelock();
5305 Message msg2 = new Message();
5306 Bundle b2 = new Bundle();
5307 b2.putInt("Callback", 7);
5308 msg2.setData(b2);
5309 NavitGraphics.callback_handler.sendMessage(msg2);
5310 Log.e("Navit", "stop navigation");
5311
5312 if (p.PREF_enable_debug_write_gpx)
5313 {
5314 NavitVehicle.speech_recording_end();
5315 }
5316
5317 // redraw all OSD elements
5318 Navit.OSD_route_001.arriving_time_valid = false;
5319 Navit.OSD_route_001.arriving_secs_to_dest_valid = false;
5320 Navit.OSD_route_001.driving_distance_to_target_valid = false;
5321 Navit.OSD_nextturn.nextturn_distance_valid = false;
5322 Navit.OSD_nextturn.nextturn_image_valid = false;
5323 Navit.OSD_compass.direct_distance_to_target_valid = false;
5324 NavitGraphics.OSD_new.postInvalidate();
5325
5326 return true;
5327 }
5328 else if (item.getItemId() == R.id.item_recentdest_menu_button)
5329 {
5330 // show recent destination list
5331 Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
5332 this.startActivityForResult(i2, Navit.NavitRecentDest_id);
5333
5334 return true;
5335 }
5336 else if (item.getItemId() == R.id.overflow_zoom_to_route)
5337 {
5338 return onOptionsItemSelected_wrapper(11);
5339 }
5340 else if (item.getItemId() == R.id.overflow_donate_item)
5341 {
5342 return onOptionsItemSelected_wrapper(26);
5343 }
5344 else if (item.getItemId() == R.id.overflow_donate_bitcoins_item)
5345 {
5346 return onOptionsItemSelected_wrapper(27);
5347 }
5348 else if (item.getItemId() == R.id.overflow_exit)
5349 {
5350 return onOptionsItemSelected_wrapper(99);
5351 }
5352 else if (item.getItemId() == R.id.overflow_toggle_poi)
5353 {
5354 return onOptionsItemSelected_wrapper(5);
5355 }
5356 else if (item.getItemId() == R.id.overflow_announcer_on)
5357 {
5358 return onOptionsItemSelected_wrapper(13);
5359 }
5360 else if (item.getItemId() == R.id.overflow_announcer_off)
5361 {
5362 return onOptionsItemSelected_wrapper(12);
5363 }
5364 else if (item.getItemId() == R.id.overflow_download_maps)
5365 {
5366 return onOptionsItemSelected_wrapper(3);
5367 }
5368 else if (item.getItemId() == R.id.overflow_delete_maps)
5369 {
5370 return onOptionsItemSelected_wrapper(8);
5371 }
5372 else if (item.getItemId() == R.id.overflow_maps_age)
5373 {
5374 return onOptionsItemSelected_wrapper(17);
5375 }
5376 else if (item.getItemId() == R.id.overflow_coord_dialog)
5377 {
5378 return onOptionsItemSelected_wrapper(19);
5379 }
5380 else if (item.getItemId() == R.id.overflow_add_traffic_block)
5381 {
5382 return onOptionsItemSelected_wrapper(21);
5383 }
5384 else if (item.getItemId() == R.id.overflow_clear_traffic_block)
5385 {
5386 return onOptionsItemSelected_wrapper(22);
5387 }
5388 else if (item.getItemId() == R.id.overflow_convert_gpx_file)
5389 {
5390 return onOptionsItemSelected_wrapper(20);
5391 }
5392 else if (item.getItemId() == R.id.overflow_clear_gpx_map)
5393 {
5394 return onOptionsItemSelected_wrapper(23);
5395 }
5396 else if (item.getItemId() == R.id.overflow_replay_gps_file)
5397 {
5398 return onOptionsItemSelected_wrapper(28);
5399 }
5400 else if (item.getItemId() == R.id.overflow_yaml_tests)
5401 {
5402 return onOptionsItemSelected_wrapper(609);
5403 }
5404 else if (item.getItemId() == R.id.overflow_demo_v_normal)
5405 {
5406 return onOptionsItemSelected_wrapper(601);
5407 }
5408 else if (item.getItemId() == R.id.overflow_demo_v_fast)
5409 {
5410 return onOptionsItemSelected_wrapper(604);
5411 }
5412 else if (item.getItemId() == R.id.overflow_speech_texts)
5413 {
5414 return onOptionsItemSelected_wrapper(602);
5415 }
5416 else if (item.getItemId() == R.id.overflow_nav_commands)
5417 {
5418 return onOptionsItemSelected_wrapper(603);
5419 }
5420 else if (item.getItemId() == R.id.overflow_toggle_route_graph)
5421 {
5422 return onOptionsItemSelected_wrapper(605);
5423 }
5424 else if (item.getItemId() == R.id.overflow_export_map_points_to_sdcard)
5425 {
5426 return onOptionsItemSelected_wrapper(607);
5427 }
5428 else if (item.getItemId() == R.id.overflow_import_map_points_from_sdcard)
5429 {
5430 return onOptionsItemSelected_wrapper(608);
5431 }
5432 else if (item.getItemId() == R.id.overflow_send_feedback)
5433 {
5434 return onOptionsItemSelected_wrapper(24);
5435 }
5436 else if (item.getItemId() == R.id.overflow_online_help)
5437 {
5438 return onOptionsItemSelected_wrapper(16);
5439 }
5440 else if (item.getItemId() == R.id.overflow_target_in_gmaps)
5441 {
5442 return onOptionsItemSelected_wrapper(15);
5443 }
5444 // else
5445 // {
5446 // return onOptionsItemSelected_wrapper(item.getItemId());
5447 // }
5448
5449 return false;
5450 }
5451
5452 @SuppressLint("NewApi")
5453 public boolean onOptionsItemSelected_wrapper(int id)
5454 {
5455 // Handle item selection
5456 switch (id)
5457 {
5458 case 1:
5459 // zoom in
5460 Message msg = new Message();
5461 Bundle b = new Bundle();
5462 b.putInt("Callback", 1);
5463 msg.setData(b);
5464 NavitGraphics.callback_handler.sendMessage(msg);
5465 // if we zoom, hide the bubble
5466 if (N_NavitGraphics.NavitAOverlay != null)
5467 {
5468 N_NavitGraphics.NavitAOverlay.hide_bubble();
5469 }
5470 Log.e("Navit", "onOptionsItemSelected -> zoom in");
5471 break;
5472 case 2:
5473 // zoom out
5474 msg = new Message();
5475 b = new Bundle();
5476 b.putInt("Callback", 2);
5477 msg.setData(b);
5478 NavitGraphics.callback_handler.sendMessage(msg);
5479 // if we zoom, hide the bubble
5480 if (N_NavitGraphics.NavitAOverlay != null)
5481 {
5482 N_NavitGraphics.NavitAOverlay.hide_bubble();
5483 }
5484 Log.e("Navit", "onOptionsItemSelected -> zoom out");
5485 break;
5486 case 3:
5487 // map download menu
5488 Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
5489 this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
5490 break;
5491 case 5:
5492 toggle_poi_pref();
5493 set_poi_layers();
5494 draw_map();
5495 break;
5496 case 6:
5497 // ok startup address search activity (online google maps search)
5498 Navit.use_index_search = false;
5499 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
5500 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5501 search_intent.putExtra("address_string", Navit_last_address_search_string);
5502 //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
5503 search_intent.putExtra("type", "online");
5504 String pm_temp = "0";
5505 if (Navit_last_address_partial_match)
5506 {
5507 pm_temp = "1";
5508 }
5509 search_intent.putExtra("partial_match", pm_temp);
5510 this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
5511 break;
5512 case 7:
5513 // ok startup address search activity (offline binfile search)
5514 Navit.use_index_search = Navit.allow_use_index_search();
5515 Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
5516 search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
5517 search_intent2.putExtra("address_string", Navit_last_address_search_string);
5518 search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
5519 search_intent2.putExtra("type", "offline");
5520 search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);
5521
5522 String pm_temp2 = "0";
5523 if (Navit_last_address_partial_match)
5524 {
5525 pm_temp2 = "1";
5526 }
5527
5528 search_intent2.putExtra("partial_match", pm_temp2);
5529 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
5530 break;
5531 case 8:
5532 // map delete menu
5533 Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class);
5534 this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id);
5535 break;
5536 case 9:
5537 // stop navigation (this menu should only appear when navigation is actually on!)
5538 Message msg2 = new Message();
5539 Bundle b2 = new Bundle();
5540 b2.putInt("Callback", 7);
5541 msg2.setData(b2);
5542 NavitGraphics.callback_handler.sendMessage(msg2);
5543 Log.e("Navit", "stop navigation");
5544 break;
5545 case 10:
5546 // open settings menu
5547 Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
5548 startActivity(settingsActivity);
5549 break;
5550 case 11:
5551 //zoom_to_route
5552 zoom_to_route();
5553 break;
5554 case 12:
5555 // announcer off
5556 Navit_Announcer = false;
5557 msg = new Message();
5558 b = new Bundle();
5559 b.putInt("Callback", 34);
5560 msg.setData(b);
5561 NavitGraphics.callback_handler.sendMessage(msg);
5562 try
5563 {
5564 invalidateOptionsMenu();
5565 }
5566 catch (Exception e)
5567 {
5568 }
5569 break;
5570 case 13:
5571 // announcer on
5572 Navit_Announcer = true;
5573 msg = new Message();
5574 b = new Bundle();
5575 b.putInt("Callback", 35);
5576 msg.setData(b);
5577 NavitGraphics.callback_handler.sendMessage(msg);
5578 try
5579 {
5580 invalidateOptionsMenu();
5581 }
5582 catch (Exception e)
5583 {
5584 }
5585 break;
5586 case 14:
5587 // show recent destination list
5588 Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
5589 this.startActivityForResult(i2, Navit.NavitRecentDest_id);
5590 break;
5591 case 15:
5592 // show current target on googlemaps
5593 String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5594 // Log.e("Navit", "got target 1: "+current_target_string);
5595 if (current_target_string.equals("x:x"))
5596 {
5597 Log.e("Navit", "no target set!");
5598 }
5599 else
5600 {
5601 try
5602 {
5603 String tmp[] = current_target_string.split(":", 2);
5604 googlemaps_show(tmp[0], tmp[1], "ZANavi Target");
5605 }
5606 catch (Exception e)
5607 {
5608 e.printStackTrace();
5609 Log.e("Navit", "problem with target!");
5610 }
5611 }
5612 break;
5613 case 16:
5614 // show online manual
5615 Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase());
5616 // URL to ZANavi Manual (in english language)
5617 String url = "http://zanavi.cc/index.php/Manual";
5618 if (FDBL)
5619 {
5620 url = "http://fd.zanavi.cc/manual";
5621 }
5622 if (NavitTextTranslations.main_language.toLowerCase().equals("de"))
5623 {
5624 // show german manual
5625 url = "http://zanavi.cc/index.php/Manual/de";
5626 if (FDBL)
5627 {
5628 url = "http://fd.zanavi.cc/manualde";
5629 }
5630 }
5631
5632 Intent i = new Intent(Intent.ACTION_VIEW);
5633 i.setData(Uri.parse(url));
5634 startActivity(i);
5635 break;
5636 case 17:
5637 // show age of maps (online)
5638 Intent i3 = new Intent(Intent.ACTION_VIEW);
5639 i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL));
5640 startActivity(i3);
5641 break;
5642 case 18:
5643 Intent intent_latlon = new Intent(Intent.ACTION_MAIN);
5644 //intent_latlon.setAction("android.intent.action.POINTPICK");
5645 intent_latlon.setPackage("com.cruthu.latlongcalc1");
5646 intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain");
5647 //intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick");
5648 try
5649 {
5650 startActivity(intent_latlon);
5651 }
5652 catch (Exception e88)
5653 {
5654 e88.printStackTrace();
5655 // show install page
5656 try
5657 {
5658 // String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1";
5659 String urlx = "market://details?id=com.cruthu.latlongcalc1";
5660 Intent ix = new Intent(Intent.ACTION_VIEW);
5661 ix.setData(Uri.parse(urlx));
5662 startActivity(ix);
5663 }
5664 catch (Exception ex)
5665 {
5666 ex.printStackTrace();
5667 }
5668 }
5669 break;
5670 case 19:
5671 // GeoCoordEnterDialog
5672 Intent it001 = new Intent(this, GeoCoordEnterDialog.class);
5673 this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id);
5674 break;
5675 case 20:
5676 // convert GPX file
5677 Intent intent77 = new Intent(getBaseContext(), FileDialog.class);
5678 File a = new File(p.PREF_last_selected_dir_gpxfiles);
5679 try
5680 {
5681 // convert the "/../" in the path to normal absolut dir
5682 intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath());
5683 //can user select directories or not
5684 intent77.putExtra(FileDialog.CAN_SELECT_DIR, false);
5685 // disable the "new" button
5686 intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
5687 //alternatively you can set file filter
5688 //intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" });
5689 startActivityForResult(intent77, Navit.NavitGPXConvChooser_id);
5690 }
5691 catch (IOException e1)
5692 {
5693 e1.printStackTrace();
5694 }
5695 break;
5696 case 21:
5697 // add traffic block (like blocked road, or construction site) at current location of crosshair
5698 try
5699 {
5700 String traffic = "";
5701 if (Navit.GFX_OVERSPILL)
5702 {
5703 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)));
5704 }
5705 else
5706 {
5707 traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2));
5708 }
5709
5710 // System.out.println("traffic=" + traffic);
5711 File traffic_file_dir = new File(MAP_FILENAME_PATH);
5712 traffic_file_dir.mkdirs();
5713 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
5714 FileOutputStream fOut = null;
5715 OutputStreamWriter osw = null;
5716 try
5717 {
5718 fOut = new FileOutputStream(traffic_file, true);
5719 osw = new OutputStreamWriter(fOut);
5720 osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header
5721 osw.write(traffic); // item coordinates
5722 osw.close();
5723 fOut.close();
5724 }
5725 catch (Exception ef)
5726 {
5727 ef.printStackTrace();
5728 }
5729
5730 // update route, if a route is set
5731 msg = new Message();
5732 b = new Bundle();
5733 b.putInt("Callback", 73);
5734 msg.setData(b);
5735 NavitGraphics.callback_handler.sendMessage(msg);
5736
5737 // draw map no-async
5738 msg = new Message();
5739 b = new Bundle();
5740 b.putInt("Callback", 64);
5741 msg.setData(b);
5742 NavitGraphics.callback_handler.sendMessage(msg);
5743 }
5744 catch (Exception e)
5745 {
5746 e.printStackTrace();
5747 }
5748 break;
5749 case 22:
5750 // clear all traffic blocks
5751 try
5752 {
5753 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
5754 traffic_file.delete();
5755
5756 // update route, if a route is set
5757 msg = new Message();
5758 b = new Bundle();
5759 b.putInt("Callback", 73);
5760 msg.setData(b);
5761 NavitGraphics.callback_handler.sendMessage(msg);
5762
5763 // draw map no-async
5764 msg = new Message();
5765 b = new Bundle();
5766 b.putInt("Callback", 64);
5767 msg.setData(b);
5768 NavitGraphics.callback_handler.sendMessage(msg);
5769 }
5770 catch (Exception e)
5771 {
5772 }
5773 break;
5774 case 23:
5775 // clear all GPX maps
5776 try
5777 {
5778 File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt");
5779 gpx_file.delete();
5780
5781 // draw map no-async
5782 msg = new Message();
5783 b = new Bundle();
5784 b.putInt("Callback", 64);
5785 msg.setData(b);
5786 NavitGraphics.callback_handler.sendMessage(msg);
5787 }
5788 catch (Exception e)
5789 {
5790 }
5791 break;
5792 case 24:
5793 // show feedback form
5794 Intent i4 = new Intent(this, NavitFeedbackFormActivity.class);
5795 this.startActivityForResult(i4, Navit.NavitSendFeedback_id);
5796 break;
5797 case 25:
5798 // share the current destination with your friends
5799 String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
5800 if (current_target_string2.equals("x:x"))
5801 {
5802 Log.e("Navit", "no target set!");
5803 }
5804 else
5805 {
5806 try
5807 {
5808 String tmp[] = current_target_string2.split(":", 2);
5809
5810 if (Navit.OSD_route_001.arriving_time_valid)
5811 {
5812 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
5813 }
5814 else
5815 {
5816 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5817 }
5818 }
5819 catch (Exception e)
5820 {
5821 e.printStackTrace();
5822 Log.e("Navit", "problem with target!");
5823 }
5824 }
5825 break;
5826 case 26:
5827 // donate
5828 Log.e("Navit", "start donate app");
5829 donate();
5830 break;
5831 case 27:
5832 // donate
5833 Log.e("Navit", "donate bitcoins");
5834 donate_bitcoins();
5835 break;
5836 case 28:
5837 // replay GPS file
5838 Intent intent771 = new Intent(getBaseContext(), FileDialog.class);
5839 File a1 = new File(Navit.NAVIT_DATA_DEBUG_DIR);
5840 try
5841 {
5842 // convert the "/../" in the path to normal absolut dir
5843 intent771.putExtra(FileDialog.START_PATH, a1.getCanonicalPath());
5844 //can user select directories or not
5845 intent771.putExtra(FileDialog.CAN_SELECT_DIR, false);
5846 // disable the "new" button
5847 intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
5848 //alternatively you can set file filter
5849 intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" });
5850 startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id);
5851 }
5852 catch (IOException e1)
5853 {
5854 e1.printStackTrace();
5855 }
5856 break;
5857
5858 case 88:
5859 // dummy entry, just to make "breaks" in the menu
5860 break;
5861 case 601:
5862 // DEBUG: activate demo vehicle and set position to position to screen center
5863
5864 Navit.DemoVehicle = true;
5865
5866 msg = new Message();
5867 b = new Bundle();
5868 b.putInt("Callback", 101);
5869 msg.setData(b);
5870 NavitGraphics.callback_handler.sendMessage(msg);
5871
5872 final Thread demo_v_001 = new Thread()
5873 {
5874 @Override
5875 public void run()
5876 {
5877 try
5878 {
5879 Thread.sleep(1000); // wait 1 seconds before we start
5880
5881 try
5882 {
5883 float lat = 0;
5884 float lon = 0;
5885
5886 String lat_lon = "";
5887 if (Navit.GFX_OVERSPILL)
5888 {
5889 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));
5890 }
5891 else
5892 {
5893 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);
5894 }
5895 String tmp[] = lat_lon.split(":", 2);
5896 //System.out.println("tmp=" + lat_lon);
5897 lat = Float.parseFloat(tmp[0]);
5898 lon = Float.parseFloat(tmp[1]);
5899 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
5900 Location l = null;
5901 l = new Location("ZANavi Demo 001");
5902 l.setLatitude(lat);
5903 l.setLongitude(lon);
5904 l.setBearing(0.0f);
5905 l.setSpeed(0);
5906 l.setAccuracy(4.0f); // accuracy 4 meters
5907 // NavitVehicle.update_compass_heading(0.0f);
5908 NavitVehicle.set_mock_location__fast(l);
5909 }
5910 catch (Exception e)
5911 {
5912 }
5913
5914 Message msg = new Message();
5915 Bundle b = new Bundle();
5916 b.putInt("Callback", 52);
5917 b.putString("s", "45"); // speed in km/h of Demo-Vehicle
5918 // b.putString("s", "20");
5919
5920 msg.setData(b);
5921 NavitGraphics.callback_handler.sendMessage(msg);
5922 }
5923 catch (Exception e)
5924 {
5925 }
5926 }
5927 };
5928 demo_v_001.start();
5929
5930 msg = new Message();
5931 b = new Bundle();
5932 b.putInt("Callback", 51);
5933
5934 if (Navit.GFX_OVERSPILL)
5935 {
5936 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5937 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5938 }
5939 else
5940 {
5941 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
5942 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
5943 }
5944 msg.setData(b);
5945 NavitGraphics.callback_handler.sendMessage(msg);
5946
5947 break;
5948 case 602:
5949 // DEBUG: toggle textview with spoken and translated string (to help with translation)
5950 try
5951 {
5952 if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE)
5953 {
5954 NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE);
5955 NavitGraphics.NavitMsgTv2_.setEnabled(false);
5956 NavitGraphics.NavitMsgTv2sc_.setVisibility(View.GONE);
5957 NavitGraphics.NavitMsgTv2sc_.setEnabled(false);
5958 }
5959 else
5960 {
5961 NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE);
5962 NavitGraphics.NavitMsgTv2sc_.setEnabled(true);
5963 NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
5964 NavitGraphics.NavitMsgTv2_.setEnabled(true);
5965 }
5966 }
5967 catch (Exception e)
5968 {
5969 e.printStackTrace();
5970 }
5971 break;
5972 case 603:
5973 // DEBUG: show all possible navigation commands (also translated)
5974 NavitGraphics.generate_all_speech_commands();
5975 break;
5976 case 604:
5977 // DEBUG: activate FAST driving demo vehicle and set position to screen center
5978
5979 Navit.DemoVehicle = true;
5980
5981 msg = new Message();
5982
5983 b = new Bundle();
5984 b.putInt("Callback", 52);
5985 b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle
5986 msg.setData(b);
5987 NavitGraphics.callback_handler.sendMessage(msg);
5988
5989 msg = new Message();
5990 b = new Bundle();
5991 b.putInt("Callback", 51);
5992 if (Navit.GFX_OVERSPILL)
5993 {
5994 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5995 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5996 }
5997 else
5998 {
5999 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
6000 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
6001 }
6002 msg.setData(b);
6003 NavitGraphics.callback_handler.sendMessage(msg);
6004
6005 try
6006 {
6007 float lat = 0;
6008 float lon = 0;
6009
6010 lat = 0;
6011 lon = 0;
6012 String lat_lon = "";
6013 if (Navit.GFX_OVERSPILL)
6014 {
6015 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));
6016 }
6017 else
6018 {
6019 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);
6020 }
6021
6022 String tmp[] = lat_lon.split(":", 2);
6023 //System.out.println("tmp=" + lat_lon);
6024 lat = Float.parseFloat(tmp[0]);
6025 lon = Float.parseFloat(tmp[1]);
6026 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
6027 Location l = null;
6028 l = new Location("ZANavi Demo 001");
6029 l.setLatitude(lat);
6030 l.setLongitude(lon);
6031 l.setBearing(0.0f);
6032 l.setSpeed(0);
6033 l.setAccuracy(4.0f); // accuracy 4 meters
6034 // NavitVehicle.update_compass_heading(0.0f);
6035 NavitVehicle.set_mock_location__fast(l);
6036 }
6037 catch (Exception e)
6038 {
6039 }
6040
6041 break;
6042 case 605:
6043 // DEBUG: toggle Routgraph on/off
6044 msg = new Message();
6045 b = new Bundle();
6046 b.putInt("Callback", 71);
6047 Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled;
6048 b.putString("s", "" + Navit.Routgraph_enabled);
6049 msg.setData(b);
6050 NavitGraphics.callback_handler.sendMessage(msg);
6051 break;
6052 case 606:
6053 // DEBUG: spill contents of index file(s)
6054 msg = new Message();
6055 b = new Bundle();
6056 b.putInt("Callback", 83);
6057 msg.setData(b);
6058 NavitGraphics.callback_handler.sendMessage(msg);
6059 break;
6060 case 607:
6061 export_map_points_to_sdcard();
6062 break;
6063 case 608:
6064 import_map_points_from_sdcard();
6065 break;
6066 case 609:
6067 // run yaml tests
6068 new Thread()
6069 {
6070 public void run()
6071 {
6072 try
6073 {
6074 ZANaviDebugReceiver.DR_run_all_yaml_tests();
6075 }
6076 catch (Exception e)
6077 {
6078 }
6079 }
6080 }.start();
6081 break;
6082 case 99:
6083 try
6084 {
6085 if (wl_navigating != null)
6086 {
6087 //if (wl_navigating.isHeld())
6088 //{
6089 wl_navigating.release();
6090 Log.e("Navit", "WakeLock Nav: release 1");
6091 //}
6092 }
6093 }
6094 catch (Exception e)
6095 {
6096 e.printStackTrace();
6097 }
6098 // exit
6099 this.onPause();
6100 this.onStop();
6101 this.exit();
6102 //msg = new Message();
6103 //b = new Bundle();
6104 //b.putInt("Callback", 5);
6105 //b.putString("cmd", "quit();");
6106 //msg.setData(b);
6107 //N_NavitGraphics.callback_handler.sendMessage(msg);
6108 break;
6109 }
6110 return true;
6111 }
6112
6113 protected void onActivityResult(int requestCode, int resultCode, Intent data)
6114 {
6115 Log.e("Navit", "onActivityResult");
6116 switch (requestCode)
6117 {
6118 case Navit.NavitGPXConvChooser_id:
6119 try
6120 {
6121 Log.e("Navit", "onActivityResult 001");
6122 if (resultCode == ActionBarActivity.RESULT_OK)
6123 {
6124 String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
6125 convert_gpx_file_real(in_);
6126 }
6127 }
6128 catch (Exception e77)
6129 {
6130 e77.printStackTrace();
6131 }
6132 break;
6133
6134 case NavitReplayFileConvChooser_id:
6135 try
6136 {
6137 if (resultCode == ActionBarActivity.RESULT_OK)
6138 {
6139 final String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
6140 final Thread replay_gpx_file_001 = new Thread()
6141 {
6142 @Override
6143 public void run()
6144 {
6145 try
6146 {
6147 Thread.sleep(2000); // wait 2 seconds before we start
6148 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
6149 ZANaviDebugReceiver.DR_replay_gps_file(in_, date);
6150 }
6151 catch (Exception e)
6152 {
6153 }
6154 }
6155 };
6156 replay_gpx_file_001.start();
6157 }
6158 }
6159 catch (Exception e77)
6160 {
6161 e77.printStackTrace();
6162 }
6163 break;
6164
6165 case Navit.NavitDeleteSecSelectMap_id:
6166 try
6167 {
6168 if (resultCode == ActionBarActivity.RESULT_OK)
6169 {
6170 System.out.println("Global_Location_update_not_allowed = 1");
6171 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6172
6173 // remove all sdcard maps
6174 Message msg = new Message();
6175 Bundle b = new Bundle();
6176 b.putInt("Callback", 19);
6177 msg.setData(b);
6178 NavitGraphics.callback_handler.sendMessage(msg);
6179
6180 try
6181 {
6182 Thread.sleep(100);
6183 }
6184 catch (InterruptedException e)
6185 {
6186 }
6187
6188 Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6189 String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
6190 Log.d("Navit", "delete map full line=" + map_full_line);
6191
6192 String del_map_name = MAP_FILENAME_PATH + map_full_line.split(":", 2)[0];
6193 System.out.println("del map file :" + del_map_name);
6194 // remove from cat file
6195 NavitMapDownloader.remove_from_cat_file(map_full_line);
6196 // remove from disk
6197 File del_map_name_file = new File(del_map_name);
6198 del_map_name_file.delete();
6199 for (int jkl = 1; jkl < 51; jkl++)
6200 {
6201 File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl));
6202 del_map_name_fileSplit.delete();
6203 }
6204 // also remove index file
6205 File del_map_name_file_idx = new File(del_map_name + ".idx");
6206 del_map_name_file_idx.delete();
6207 // remove also any MD5 files for this map that may be on disk
6208 try
6209 {
6210 String tmp = map_full_line.split(":", 2)[1];
6211 if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN))
6212 {
6213 tmp = tmp.replace("*", "");
6214 tmp = tmp.replace("/", "");
6215 tmp = tmp.replace("\\", "");
6216 tmp = tmp.replace(" ", "");
6217 tmp = tmp.replace(">", "");
6218 tmp = tmp.replace("<", "");
6219 System.out.println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
6220 File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
6221 md5_final_filename.delete();
6222 }
6223 }
6224 catch (Exception e)
6225 {
6226 e.printStackTrace();
6227 }
6228
6229 // remove map, and zoom out
6230 // ***** onStop();
6231 // ***** onCreate(getIntent().getExtras());
6232
6233 try
6234 {
6235 Thread.sleep(100);
6236 }
6237 catch (InterruptedException e)
6238 {
6239 }
6240
6241 // add all sdcard maps
6242 msg = new Message();
6243 b = new Bundle();
6244 b.putInt("Callback", 20);
6245 msg.setData(b);
6246 NavitGraphics.callback_handler.sendMessage(msg);
6247
6248 final Thread zoom_to_route_004 = new Thread()
6249 {
6250 int wait = 1;
6251 int count = 0;
6252 int max_count = 60;
6253
6254 @Override
6255 public void run()
6256 {
6257 while (wait == 1)
6258 {
6259 try
6260 {
6261 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6262 {
6263 zoom_to_route();
6264 wait = 0;
6265 }
6266 else
6267 {
6268 wait = 1;
6269 }
6270
6271 count++;
6272 if (count > max_count)
6273 {
6274 wait = 0;
6275 }
6276 else
6277 {
6278 Thread.sleep(400);
6279 }
6280 }
6281 catch (Exception e)
6282 {
6283 }
6284 }
6285 }
6286 };
6287 zoom_to_route_004.start();
6288
6289 System.out.println("Global_Location_update_not_allowed = 0");
6290 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
6291 }
6292 }
6293 catch (Exception e)
6294 {
6295 Log.d("Navit", "error on onActivityResult 3");
6296 e.printStackTrace();
6297 }
6298 break;
6299 case Navit.NavitDownloaderPriSelectMap_id:
6300 try
6301 {
6302 if (resultCode == ActionBarActivity.RESULT_OK)
6303 {
6304 try
6305 {
6306 // Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6307 // set map id to download
6308 Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
6309 // show the map download progressbar, and download the map
6310 if (Navit.download_map_id > -1)
6311 {
6312 // --------- start a map download (highest level) ---------
6313 // --------- start a map download (highest level) ---------
6314 // --------- start a map download (highest level) ---------
6315 // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app
6316
6317 // new method in service
6318 Message msg = progress_handler.obtainMessage();
6319 // Bundle b = new Bundle();
6320 msg.what = 22;
6321 progress_handler.sendMessage(msg);
6322
6323 // show license for OSM maps
6324 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
6325 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
6326 // --------- start a map download (highest level) ---------
6327 // --------- start a map download (highest level) ---------
6328 // --------- start a map download (highest level) ---------
6329 }
6330 }
6331 catch (NumberFormatException e)
6332 {
6333 Log.d("Navit", "NumberFormatException selected_id");
6334 }
6335 }
6336 else
6337 {
6338 // user pressed back key
6339 }
6340 }
6341 catch (Exception e)
6342 {
6343 Log.d("Navit", "error on onActivityResult");
6344 e.printStackTrace();
6345 }
6346 break;
6347 case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!!
6348 break;
6349 case ZANaviVoiceInput_id:
6350 if (resultCode == ActionBarActivity.RESULT_OK)
6351 {
6352 try
6353 {
6354 String addr = data.getStringExtra("address_string");
6355 double lat = data.getDoubleExtra("lat", 0);
6356 double lon = data.getDoubleExtra("lon", 0);
6357 String hn = "";
6358
6359 // save last address entry string
6360 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6361 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6362
6363 Boolean partial_match = true;
6364 Navit.use_index_search = false;
6365
6366 Navit_last_address_partial_match = partial_match;
6367 Navit_last_address_search_string = addr;
6368 Navit_last_address_hn_string = hn;
6369
6370 Navit_last_address_full_file_search = false;
6371
6372 // clear results
6373 Navit.NavitAddressResultList_foundItems.clear();
6374 Navit.Navit_Address_Result_double_index.clear();
6375 Navit.NavitSearchresultBarIndex = -1;
6376 Navit.NavitSearchresultBar_title = "";
6377 Navit.NavitSearchresultBar_text = "";
6378 Navit.search_results_towns = 0;
6379 Navit.search_results_streets = 0;
6380 Navit.search_results_streets_hn = 0;
6381 Navit.search_results_poi = 0;
6382
6383 if (addr.equals(""))
6384 {
6385 // empty search string entered
6386 Toast.makeText(getApplicationContext(), Navit.get_text("No search string"), Toast.LENGTH_LONG).show(); //TRANS
6387 }
6388 else
6389 {
6390 System.out.println("Global_Location_update_not_allowed = 1");
6391 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6392
6393 // --> this still does the search // google_online_search_and_set_destination(addr);
6394 result_set_destination(lat, lon, addr);
6395
6396 System.out.println("Global_Location_update_not_allowed = 0");
6397 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
6398 }
6399
6400 }
6401 catch (Exception e)
6402 {
6403
6404 }
6405 }
6406 break;
6407 case NavitAddressSearch_id_online:
6408 case NavitAddressSearch_id_offline:
6409 Log.e("Navit", "NavitAddressSearch_id_:001");
6410 try
6411 {
6412 if (resultCode == ActionBarActivity.RESULT_OK)
6413 {
6414 try
6415 {
6416 String addr = data.getStringExtra("address_string");
6417 String hn = "";
6418 try
6419 {
6420 // only from offline mask!
6421 hn = data.getStringExtra("hn_string");
6422 }
6423 catch (Exception e)
6424 {
6425 hn = "";
6426 }
6427
6428 // save last address entry string
6429 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6430 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6431
6432 Boolean partial_match = false;
6433 try
6434 {
6435 // only from offline mask!
6436 partial_match = data.getStringExtra("partial_match").equals("1");
6437 }
6438 catch (Exception e)
6439 {
6440 }
6441
6442 Message msg2 = new Message();
6443 Bundle b2 = new Bundle();
6444 b2.putInt("Callback", 44);
6445 msg2.setData(b2);
6446 NavitGraphics.callback_handler.sendMessage(msg2);
6447
6448 if (requestCode == NavitAddressSearch_id_offline)
6449 {
6450 search_hide_duplicates = false;
6451 try
6452 {
6453 Boolean hide_dup = data.getStringExtra("hide_dup").equals("1");
6454 if (hide_dup)
6455 {
6456 search_hide_duplicates = true;
6457 Message msg = new Message();
6458 Bundle b = new Bundle();
6459 b.putInt("Callback", 45);
6460 msg.setData(b);
6461 NavitGraphics.callback_handler.sendMessage(msg);
6462 }
6463 }
6464 catch (Exception e)
6465 {
6466 }
6467
6468 if (Navit.CIDEBUG == 0)
6469 {
6470 Navit.use_index_search = Navit.allow_use_index_search();
6471 }
6472 }
6473 else
6474 {
6475 Navit.use_index_search = false;
6476 }
6477
6478 Navit_last_address_partial_match = partial_match;
6479 Navit_last_address_search_string = addr;
6480 Navit_last_address_hn_string = hn;
6481
6482 try
6483 {
6484 // only from offline mask!
6485 Navit_last_address_full_file_search = data.getStringExtra("full_file_search").equals("1");
6486 }
6487 catch (Exception e)
6488 {
6489 Navit_last_address_full_file_search = false;
6490 }
6491
6492 try
6493 {
6494 // only from offline mask!
6495 Navit_last_address_search_country_iso2_string = data.getStringExtra("address_country_iso2");
6496
6497 Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3);
6498 // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags);
6499 Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL*
6500 p.PREF_search_country = Navit_last_address_search_country_id;
6501 setPrefs_search_country();
6502 }
6503 catch (Exception e)
6504 {
6505
6506 }
6507
6508 // clear results
6509 Navit.NavitAddressResultList_foundItems.clear();
6510 Navit.Navit_Address_Result_double_index.clear();
6511 Navit.NavitSearchresultBarIndex = -1;
6512 Navit.NavitSearchresultBar_title = "";
6513 Navit.NavitSearchresultBar_text = "";
6514 Navit.search_results_towns = 0;
6515 Navit.search_results_streets = 0;
6516 Navit.search_results_streets_hn = 0;
6517 Navit.search_results_poi = 0;
6518
6519 if (addr.equals(""))
6520 {
6521 // empty search string entered
6522 Toast.makeText(getApplicationContext(), Navit.get_text("No search string entered"), Toast.LENGTH_LONG).show(); //TRANS
6523 }
6524 else
6525 {
6526 System.out.println("Global_Location_update_not_allowed = 1");
6527 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
6528
6529 if (requestCode == NavitAddressSearch_id_online)
6530 {
6531 // online googlemaps search
6532 try
6533 {
6534 Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG);
6535 }
6536 catch (Exception e)
6537 {
6538 e.printStackTrace();
6539 }
6540
6541 System.out.println("dialog -- 11:003");
6542 System.out.println("online googlemaps search");
6543 Message msg = progress_handler.obtainMessage();
6544 Bundle b = new Bundle();
6545 msg.what = 11;
6546 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
6547 msg.setData(b);
6548 progress_handler.sendMessage(msg);
6549 }
6550 else if (requestCode == NavitAddressSearch_id_offline)
6551 {
6552 // offline binfile search
6553
6554 if (!Navit.use_index_search)
6555 {
6556 try
6557 {
6558 Log.e("Navit", "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6559 }
6560 catch (Exception e)
6561 {
6562 e.printStackTrace();
6563 }
6564
6565 // show dialog, and start search for the results
6566 // make it indirect, to give our activity a chance to startup
6567 // (remember we come straight from another activity and ours is still paused!)
6568 System.out.println("dialog -- 11:004");
6569 Message msg = progress_handler.obtainMessage();
6570 Bundle b = new Bundle();
6571 msg.what = 11;
6572 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
6573 msg.setData(b);
6574 progress_handler.sendMessage(msg);
6575 }
6576 }
6577 }
6578 }
6579 catch (NumberFormatException e)
6580 {
6581 Log.d("Navit", "NumberFormatException selected_id");
6582 }
6583 }
6584 else
6585 {
6586 // user pressed back key
6587 Log.e("Navit", "NavitAddressSearch_id_:900");
6588 }
6589 }
6590 catch (Exception e)
6591 {
6592 Log.d("Navit", "error on onActivityResult");
6593 e.printStackTrace();
6594 }
6595 Log.e("Navit", "NavitAddressSearch_id_:999");
6596 break;
6597 case Navit.NavitAddressResultList_id:
6598 try
6599 {
6600 if (resultCode == ActionBarActivity.RESULT_OK)
6601 {
6602 try
6603 {
6604 if (data.getStringExtra("what").equals("view"))
6605 {
6606 // get the coords for the destination
6607 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6608
6609 // save last address entry string
6610 String addr = data.getStringExtra("address_string");
6611 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6612 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6613
6614 try
6615 {
6616 Navit.follow_button_off();
6617 }
6618 catch (Exception e2)
6619 {
6620 e2.printStackTrace();
6621 }
6622
6623 System.out.println("XSOM:009");
6624
6625 if (Navit.use_index_search)
6626 {
6627 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));
6628 }
6629 else
6630 {
6631 show_geo_on_screen_with_zoom_and_delay(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6632 }
6633 }
6634 else if (data.getStringExtra("what").equals("set"))
6635 {
6636 Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6637
6638 // save last address entry string
6639 String addr = data.getStringExtra("address_string");
6640 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6641 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6642
6643 // get the coords for the destination
6644 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6645
6646 String _addr = "";
6647 double _lat = 0;
6648 double _lon = 0;
6649
6650 // (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)
6651 // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)
6652
6653 // ok now set target
6654 try
6655 {
6656 if (Navit.use_index_search)
6657 {
6658 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6659 _lat = Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat);
6660 _lon = Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6661 //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));
6662 }
6663 else
6664 {
6665 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6666 _lat = Navit.NavitAddressResultList_foundItems.get(destination_id).lat;
6667 _lon = Navit.NavitAddressResultList_foundItems.get(destination_id).lon;
6668 //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6669 }
6670 // save points
6671 //write_map_points();
6672 }
6673 catch (Exception e)
6674 {
6675 e.printStackTrace();
6676 }
6677
6678 route_wrapper(_addr, 0, 0, false, _lat, _lon, true);
6679
6680 final Thread zoom_to_route_005 = new Thread()
6681 {
6682 int wait = 1;
6683 int count = 0;
6684 int max_count = 60;
6685
6686 @Override
6687 public void run()
6688 {
6689 while (wait == 1)
6690 {
6691 try
6692 {
6693 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6694 {
6695 zoom_to_route();
6696 wait = 0;
6697 }
6698 else
6699 {
6700 wait = 1;
6701 }
6702
6703 count++;
6704 if (count > max_count)
6705 {
6706 wait = 0;
6707 }
6708 else
6709 {
6710 Thread.sleep(400);
6711 }
6712 }
6713 catch (Exception e)
6714 {
6715 }
6716 }
6717 }
6718 };
6719 zoom_to_route_005.start();
6720 // zoom_to_route();
6721
6722 // ---------- DEBUG: write route to file ----------
6723 // ---------- DEBUG: write route to file ----------
6724 // ---------- DEBUG: write route to file ----------
6725 if (p.PREF_enable_debug_write_gpx)
6726 {
6727 write_route_to_gpx_file();
6728 }
6729 // ---------- DEBUG: write route to file ----------
6730 // ---------- DEBUG: write route to file ----------
6731
6732 try
6733 {
6734 Navit.follow_button_on();
6735 }
6736 catch (Exception e2)
6737 {
6738 e2.printStackTrace();
6739 }
6740
6741 // if (Navit.use_index_search)
6742 // {
6743 // 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));
6744 // }
6745 // else
6746 // {
6747 // show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6748 // }
6749 }
6750 else
6751 {
6752 // -- nothing --
6753 }
6754 }
6755 catch (NumberFormatException e)
6756 {
6757 Log.d("Navit", "NumberFormatException selected_id");
6758 }
6759 catch (Exception e)
6760 {
6761
6762 }
6763 }
6764 else
6765 {
6766 // user pressed back key
6767 }
6768 }
6769 catch (Exception e)
6770 {
6771 Log.d("Navit", "error on onActivityResult");
6772 e.printStackTrace();
6773 }
6774 break;
6775 case NavitAddressSearch_id_gmaps:
6776 try
6777 {
6778 if (resultCode == ActionBarActivity.RESULT_OK)
6779 {
6780
6781 }
6782 }
6783 catch (Exception e)
6784 {
6785 e.printStackTrace();
6786 }
6787 break;
6788 case NavitAddressSearch_id_sharedest:
6789 try
6790 {
6791 if (resultCode == ActionBarActivity.RESULT_OK)
6792 {
6793
6794 }
6795 Log.d("Navit", "sharedest: finished");
6796 }
6797 catch (Exception e)
6798 {
6799 e.printStackTrace();
6800 }
6801 break;
6802 case NavitGeoCoordEnter_id:
6803 try
6804 {
6805 if (resultCode == ActionBarActivity.RESULT_OK)
6806 {
6807 // lat lon enter activitiy result
6808
6809 try
6810 {
6811 if (data.getStringExtra("what").equals("view"))
6812 {
6813 // get the coords for the destination
6814 float lat = Float.parseFloat(data.getStringExtra("lat"));
6815 float lon = Float.parseFloat(data.getStringExtra("lon"));
6816
6817 // Log.d("Navit", "coord picker: " + lat);
6818 // Log.d("Navit", "coord picker: " + lon);
6819
6820 // set nice zoomlevel before we show destination
6821 // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
6822 // //
6823 // Message msg = new Message();
6824 // Bundle b = new Bundle();
6825 // b.putInt("Callback", 33);
6826 // b.putString("s", Integer.toString(zoom_want));
6827 // msg.setData(b);
6828 // try
6829 // {
6830 // N_NavitGraphics.callback_handler.sendMessage(msg);
6831 // Navit.GlobalScaleLevel = zoom_want;
6832 // }
6833 // catch (Exception e)
6834 // {
6835 // e.printStackTrace();
6836 // }
6837 // if (PREF_save_zoomlevel)
6838 // {
6839 // setPrefs_zoomlevel();
6840 // }
6841 // set nice zoomlevel before we show destination
6842
6843 try
6844 {
6845 Navit.follow_button_off();
6846 }
6847 catch (Exception e2)
6848 {
6849 e2.printStackTrace();
6850 }
6851
6852 show_geo_on_screen(lat, lon);
6853 }
6854 else
6855 {
6856 // get the coords for the destination
6857 float lat = Float.parseFloat(data.getStringExtra("lat"));
6858 float lon = Float.parseFloat(data.getStringExtra("lat"));
6859 String dest_name = "manual coordinates";
6860
6861 // ok now set target
6862 try
6863 {
6864 dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon);
6865 if ((dest_name.equals(" ")) || (dest_name == null))
6866 {
6867 dest_name = "manual coordinates";
6868 }
6869 // Navit.remember_destination(dest_name, lat, lon);
6870 // // save points
6871 // write_map_points();
6872 }
6873 catch (Exception e)
6874 {
6875 e.printStackTrace();
6876 }
6877
6878 // // DEBUG: clear route rectangle list
6879 // NavitGraphics.route_rects.clear();
6880 //
6881 // if (NavitGraphics.navit_route_status == 0)
6882 // {
6883 // Navit.destination_set();
6884 //
6885 // Message msg = new Message();
6886 // Bundle b = new Bundle();
6887 // b.putInt("Callback", 3);
6888 // b.putString("lat", String.valueOf(lat));
6889 // b.putString("lon", String.valueOf(lon));
6890 // b.putString("q", dest_name);
6891 // msg.setData(b);
6892 // NavitGraphics.callback_handler.sendMessage(msg);
6893 // }
6894 // else
6895 // {
6896 // Message msg = new Message();
6897 // Bundle b = new Bundle();
6898 // b.putInt("Callback", 48);
6899 // b.putString("lat", String.valueOf(lat));
6900 // b.putString("lon", String.valueOf(lon));
6901 // b.putString("q", dest_name);
6902 // msg.setData(b);
6903 // NavitGraphics.callback_handler.sendMessage(msg);
6904 // }
6905 //
6906
6907 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
6908
6909 final Thread zoom_to_route_006 = new Thread()
6910 {
6911 int wait = 1;
6912 int count = 0;
6913 int max_count = 60;
6914
6915 @Override
6916 public void run()
6917 {
6918 while (wait == 1)
6919 {
6920 try
6921 {
6922 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6923 {
6924 zoom_to_route();
6925 wait = 0;
6926 }
6927 else
6928 {
6929 wait = 1;
6930 }
6931
6932 count++;
6933 if (count > max_count)
6934 {
6935 wait = 0;
6936 }
6937 else
6938 {
6939 Thread.sleep(400);
6940 }
6941 }
6942 catch (Exception e)
6943 {
6944 }
6945 }
6946 }
6947 };
6948 zoom_to_route_006.start();
6949 // zoom_to_route();
6950
6951 // ---------- DEBUG: write route to file ----------
6952 // ---------- DEBUG: write route to file ----------
6953 // ---------- DEBUG: write route to file ----------
6954 if (p.PREF_enable_debug_write_gpx)
6955 {
6956 write_route_to_gpx_file();
6957 }
6958 // ---------- DEBUG: write route to file ----------
6959 // ---------- DEBUG: write route to file ----------
6960
6961 try
6962 {
6963 Navit.follow_button_on();
6964 }
6965 catch (Exception e2)
6966 {
6967 e2.printStackTrace();
6968 }
6969
6970 // show_geo_on_screen(lat, lon);
6971 }
6972 }
6973 catch (NumberFormatException e)
6974 {
6975 Log.d("Navit", "NumberFormatException selected_id");
6976 }
6977 catch (Exception e)
6978 {
6979
6980 }
6981 }
6982 }
6983 catch (Exception e)
6984 {
6985 e.printStackTrace();
6986 }
6987 break;
6988 case NavitRecentDest_id:
6989 try
6990 {
6991 if (resultCode == ActionBarActivity.RESULT_OK)
6992 {
6993 Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6994 // get the coords for the destination
6995 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6996
6997 if (data.getStringExtra("what").equals("view"))
6998 {
6999 try
7000 {
7001 Navit.follow_button_off();
7002 }
7003 catch (Exception e2)
7004 {
7005 e2.printStackTrace();
7006 }
7007
7008 float lat = Navit.map_points.get(destination_id).lat;
7009 float lon = Navit.map_points.get(destination_id).lon;
7010 show_geo_on_screen_with_zoom_and_delay(lat, lon, 150);
7011 }
7012 else
7013 {
7014 // ok now set target
7015 String dest_name = Navit.map_points.get(destination_id).point_name;
7016 float lat = Navit.map_points.get(destination_id).lat;
7017 float lon = Navit.map_points.get(destination_id).lon;
7018
7019 // System.out.println("XXXXXX:" + lat + " " + lon);
7020
7021 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
7022
7023 final Thread zoom_to_route_007 = new Thread()
7024 {
7025 int wait = 1;
7026 int count = 0;
7027 int max_count = 60;
7028
7029 @Override
7030 public void run()
7031 {
7032 while (wait == 1)
7033 {
7034 try
7035 {
7036 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
7037 {
7038 zoom_to_route();
7039 wait = 0;
7040 }
7041 else
7042 {
7043 wait = 1;
7044 }
7045
7046 count++;
7047 if (count > max_count)
7048 {
7049 wait = 0;
7050 }
7051 else
7052 {
7053 Thread.sleep(400);
7054 }
7055 }
7056 catch (Exception e)
7057 {
7058 }
7059 }
7060 }
7061 };
7062 zoom_to_route_007.start();
7063
7064 // ---------- DEBUG: write route to file ----------
7065 // ---------- DEBUG: write route to file ----------
7066 // ---------- DEBUG: write route to file ----------
7067 if (p.PREF_enable_debug_write_gpx)
7068 {
7069 write_route_to_gpx_file();
7070 }
7071 // ---------- DEBUG: write route to file ----------
7072 // ---------- DEBUG: write route to file ----------
7073
7074 try
7075 {
7076 Navit.follow_button_on();
7077 }
7078 catch (Exception e2)
7079 {
7080 e2.printStackTrace();
7081 }
7082
7083 }
7084 }
7085 }
7086 catch (Exception e)
7087 {
7088 e.printStackTrace();
7089 }
7090 break;
7091
7092 case NavitSendFeedback_id:
7093 try
7094 {
7095 if (resultCode == ActionBarActivity.RESULT_OK)
7096 {
7097 String feedback_text = data.getStringExtra("feedback_text");
7098
7099 String subject_d_version = "";
7100 if (Navit_DonateVersion_Installed)
7101 {
7102 subject_d_version = subject_d_version + "D,";
7103 }
7104
7105 if (Navit_Largemap_DonateVersion_Installed)
7106 {
7107 subject_d_version = subject_d_version + "L,";
7108 }
7109
7110 try
7111 {
7112 int rl = get_reglevel();
7113
7114 if (rl > 0)
7115 {
7116 subject_d_version = "U" + rl + ",";
7117 }
7118 }
7119 catch (Exception e)
7120 {
7121 e.printStackTrace();
7122 }
7123
7124 String FD_addon = "";
7125 if (FDBL)
7126 {
7127 FD_addon = ",FD";
7128 }
7129
7130 sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + FD_addon + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text);
7131 }
7132 }
7133 catch (Exception e)
7134 {
7135 e.printStackTrace();
7136 Toast.makeText(getApplicationContext(), Navit.get_text("there was a problem with sending feedback"), Toast.LENGTH_SHORT).show(); //TRANS
7137 }
7138 break;
7139
7140 default:
7141 Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode);
7142 try
7143 {
7144 // ---------- what is this doing ????? ----------
7145 // ---------- what is this doing ????? ----------
7146 // ---------- what is this doing ????? ----------
7147 // ---------- what is this doing ????? ----------
7148 // ---------- what is this doing ????? ----------
7149 // ---------- what is this doing ????? ----------
7150 // ---------- what is this doing ????? ----------
7151 // ---------- what is this doing ????? ----------
7152 // ---------- what is this doing ????? ----------
7153 // ---------- what is this doing ????? ----------
7154 // ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
7155 // ---------- what is this doing ????? ----------
7156 // ---------- what is this doing ????? ----------
7157 // ---------- what is this doing ????? ----------
7158 // ---------- what is this doing ????? ----------
7159 // ---------- what is this doing ????? ----------
7160 // ---------- what is this doing ????? ----------
7161 // ---------- what is this doing ????? ----------
7162 // ---------- what is this doing ????? ----------
7163 }
7164 catch (Exception e)
7165 {
7166 e.printStackTrace();
7167 }
7168 break;
7169 }
7170 Log.e("Navit", "onActivityResult finished");
7171 }
7172
7173 public class SCCB_object
7174 {
7175 int w;
7176 int h;
7177 Bitmap mb;
7178 }
7179
7180 public class CMC_object
7181 {
7182 int i;
7183 String s;
7184 }
7185
7186 public class MCB_object
7187 {
7188 int x1;
7189 int y1;
7190 int x2;
7191
7192 int y2;
7193 }
7194
7195 public class TCB_object
7196 {
7197 int del;
7198 int id;
7199 NavitTimeout nt;
7200 }
7201
7202 public class GeCB_Object
7203 {
7204 int type;
7205 int a;
7206 float b;
7207 float c;
7208 }
7209
7210 public class LowQ_Object
7211 {
7212 String latlonzoom;
7213 int w;
7214 int h;
7215 int fontsize;
7216 int scale;
7217 int selection_range;
7218 }
7219
7220 public class CWorkerThread extends Thread
7221 {
7222 private Boolean running;
7223 Boolean startmain = false;
7224 private CMC_object l2;
7225 private Integer l3;
7226 private MCB_object l4;
7227 private TCB_object l5;
7228 private SCCB_object l6;
7229 private Location l7;
7230 private GeCB_Object l8;
7231 private LowQ_Object l9;
7232
7233 Navit x;
7234 String lang;
7235 int version;
7236 String display_density_string;
7237 int timeout_loop_counter = 0;
7238 String n_datadir;
7239 String n_sharedir;
7240
7241 private final LinkedBlockingQueue<CMC_object> queue = new LinkedBlockingQueue<CMC_object>();
7242 private final LinkedBlockingQueue<Integer> queue2 = new LinkedBlockingQueue<Integer>();
7243 private final LinkedBlockingQueue<MCB_object> queue3 = new LinkedBlockingQueue<MCB_object>();
7244 private final LinkedBlockingQueue<TCB_object> queue4 = new LinkedBlockingQueue<TCB_object>();
7245 private final LinkedBlockingQueue<SCCB_object> queue5 = new LinkedBlockingQueue<SCCB_object>();
7246 private final LinkedBlockingQueue<Location> queue6 = new LinkedBlockingQueue<Location>();
7247 private final LinkedBlockingQueue<GeCB_Object> queue7 = new LinkedBlockingQueue<GeCB_Object>();
7248 private final LinkedBlockingQueue<LowQ_Object> queue8 = new LinkedBlockingQueue<LowQ_Object>();
7249
7250 CWorkerThread()
7251 {
7252 this.running = true;
7253 }
7254
7255 public void DrawLowqualMap_wrapper(String latlonzoom, int w, int h, int fontsize, int scale, int selection_range)
7256 {
7257 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7258
7259 LowQ_Object o = new LowQ_Object();
7260 o.latlonzoom = latlonzoom;
7261 o.w = w;
7262 o.h = h;
7263 o.fontsize = fontsize;
7264 o.scale = scale;
7265 o.selection_range = selection_range;
7266 queue8.offer(o);
7267 this.interrupt();
7268
7269 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7270 }
7271
7272 public void SizeChangedCallback(int w, int h, Bitmap main_map_bitmap)
7273 {
7274 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7275
7276 SCCB_object sccbo = new SCCB_object();
7277 sccbo.w = w;
7278 sccbo.h = h;
7279 sccbo.mb = main_map_bitmap;
7280 queue5.offer(sccbo);
7281 this.interrupt();
7282
7283 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7284 }
7285
7286 public void TimeoutCallback2(NavitTimeout nt, int del, int id)
7287 {
7288 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7289
7290 TCB_object tcbo = new TCB_object();
7291 tcbo.del = del;
7292 tcbo.id = id;
7293 tcbo.nt = nt;
7294 queue4.offer(tcbo);
7295 this.interrupt();
7296 //timeout_loop_counter++;
7297
7298 //if (timeout_loop_counter > 100)
7299 //{
7300 // timeout_loop_counter = 0;
7301 // // run GC at every 100th loop
7302 // // System.gc();
7303 //}
7304 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7305 }
7306
7307 public void CallbackMessageChannel(int i, String s)
7308 {
7309 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0, "id=" + i);
7310 CMC_object cmco = new CMC_object();
7311 cmco.i = i;
7312 cmco.s = s;
7313 queue.offer(cmco);
7314 this.interrupt();
7315 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7316 }
7317
7318 public void MotionCallback(int x1, int y1, int x2, int y2)
7319 {
7320 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7321
7322 //System.out.println("MotionCallback:enter queue=" + queue3.size());
7323 MCB_object mcbo = new MCB_object();
7324 mcbo.x1 = x1;
7325 mcbo.y1 = y1;
7326 mcbo.x2 = x2;
7327 mcbo.y2 = y2;
7328 queue3.offer(mcbo);
7329 this.interrupt();
7330 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7331 }
7332
7333 public void NavitActivity2(int i)
7334 {
7335 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7336
7337 queue2.offer(Integer.valueOf(i));
7338 this.interrupt();
7339 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7340 }
7341
7342 public void CallbackGeoCalc2(int type, int a, float b, float c)
7343 {
7344 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7345
7346 GeCB_Object gcco = new GeCB_Object();
7347 gcco.type = type;
7348 gcco.a = a;
7349 gcco.b = b;
7350 gcco.c = c;
7351 queue7.offer(gcco);
7352 this.interrupt();
7353
7354 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7355 }
7356
7357 public void StartMain(Navit x, String lang, int version, String display_density_string, String n_datadir, String n_sharedir)
7358 {
7359 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7360
7361 //System.out.println("CWorkerThread:StartMain:JTHREAD ID=" + this.getId());
7362 //System.out.println("CWorkerThread:StartMain:THREAD ID=" + NavitGraphics.GetThreadId());
7363
7364 this.startmain = true;
7365 this.x = x;
7366 this.lang = lang;
7367 this.version = version;
7368 this.n_datadir = n_datadir;
7369 this.n_sharedir = n_sharedir;
7370 this.display_density_string = display_density_string;
7371 this.interrupt();
7372
7373 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7374 }
7375
7376 public void VehicleCallback3(Location location)
7377 {
7378 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
7379
7380 boolean your_are_speeding_old = Navit.your_are_speeding;
7381
7382 if ((Navit.cur_max_speed != -1) && (Navit.isGPSFix))
7383 {
7384 if ((location.getSpeed() * 3.6f) > ((float) Navit.cur_max_speed * (((float) p.PREF_roadspeed_warning_margin + 100.0f) / 100.0f)))
7385 {
7386 Navit.your_are_speeding = true;
7387
7388 try
7389 {
7390
7391 if (!toneG_heared)
7392 {
7393 // make "beep" sound to indicate we are going to fast!!
7394 if (toneG != null)
7395 {
7396 if (p.PREF_roadspeed_warning)
7397 {
7398 toneG.stopTone();
7399 toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 500);
7400 }
7401 toneG_heared = true;
7402 }
7403
7404 }
7405 }
7406 catch (Exception e)
7407 {
7408 }
7409 }
7410 else
7411 {
7412 // reset "beep" flag
7413 Navit.toneG_heared = false;
7414 Navit.your_are_speeding = false;
7415 }
7416 }
7417 else
7418 {
7419 Navit.your_are_speeding = false;
7420 }
7421
7422 if (your_are_speeding_old != Navit.your_are_speeding)
7423 {
7424 //System.out.println("xx paint 6 xx");
7425 // NavitOSDJava.draw_real_wrapper(false, true);
7426 ZANaviLinearLayout.redraw_OSD(8);
7427 }
7428
7429 if (queue6.size() > 5)
7430 {
7431 while (queue6.size() > 5)
7432 {
7433 try
7434 {
7435 // if too many gps updates are waiting, then only process the last few entry!!
7436 queue6.poll();
7437 }
7438 catch (Exception e)
7439 {
7440 }
7441 }
7442 }
7443
7444 queue6.offer(location);
7445 this.interrupt();
7446
7447 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
7448 }
7449
7450 public void calc_sun_stats()
7451 {
7452 //
7453 //
7454 // SUN ----------------
7455 //
7456 //
7457 sun_moon__must_calc_new = (SystemClock.elapsedRealtime() - sun_moon__mLastCalcSunMillis) > (60000 * 3); // calc new every 3 minutes
7458
7459 if ((sun_moon__must_calc_new) || (azmiuth_cache == -1))
7460 {
7461 float lat = 0;
7462 float lon = 0;
7463 try
7464 {
7465 // 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);
7466 String lat_lon = "";
7467 if (Navit.GFX_OVERSPILL)
7468 {
7469 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));
7470 }
7471 else
7472 {
7473 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);
7474 }
7475
7476 String tmp[] = lat_lon.split(":", 2);
7477 //System.out.println("tmp=" + lat_lon);
7478 lat = Float.parseFloat(tmp[0]);
7479 lon = Float.parseFloat(tmp[1]);
7480 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
7481 }
7482 catch (Exception e)
7483 {
7484 }
7485
7486 try
7487 {
7488 sun_moon__mLastCalcSunMillis = SystemClock.elapsedRealtime();
7489 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.
7490 //System.out.println(t.getID());
7491 sun_moon__calc = new SunriseSunsetCalculator(new Location2(String.valueOf(lat), String.valueOf(lon)), t.getID());
7492 sun_moon__cx = Calendar.getInstance();
7493 sun_moon__sc = SolarPosition.getSunPosition(new Date(), lat, lon);
7494
7495 azmiuth_cache = sun_moon__sc.azimuth;
7496 zenith_cache = sun_moon__sc.zenithAngle;
7497 sunrise_cache = sun_moon__calc.getOfficialSunriseForDate(sun_moon__cx);
7498 sunset_cache = sun_moon__calc.getOfficialSunsetForDate(sun_moon__cx);
7499 //System.out.println("calc moon");
7500 SolarEventCalculator.moonCoor_ret moon_stats = sun_moon__calc.computeMoon(sun_moon__cx);
7501 moon_azimuth_cache = moon_stats.az;
7502 moon_evelation_cache = moon_stats.alt;
7503 }
7504 catch (Exception e)
7505 {
7506 }
7507 }
7508 //
7509 elevation = 90 - zenith_cache;
7510 //
7511 // day -> +90.0 to - 0.83
7512 // evening dusk -> - 0.83 to -10.00
7513 if (elevation < -0.83)
7514 {
7515 is_night = true;
7516 if (elevation < -10.00)
7517 {
7518 is_twilight = false;
7519 }
7520 else
7521 {
7522 is_twilight = true;
7523 }
7524 //System.out.println("***NIGHT***");
7525 }
7526 else
7527 {
7528 is_night = false;
7529 //System.out.println("###DAY###");
7530 }
7531 //
7532 // SUN ----------------
7533 //
7534 //
7535 }
7536
7537 public void do_sun_calc()
7538 {
7539 //
7540 //
7541 // SUN ----------------
7542 //
7543 //
7544 try
7545 {
7546 this.calc_sun_stats();
7547 }
7548 catch (Exception e)
7549 {
7550 // on some systems BigInteger seems to crash, or maybe some values are out of range
7551 // until the bug is found, night modus is deactivated
7552 calc_sun_enabled = false;
7553 is_twilight = false;
7554 is_night = false;
7555 }
7556 //System.out.println("sunrise: " + sunrise_cache);
7557 //System.out.println("sunset: " + sunset_cache);
7558 //System.out.println("azimuth: " + roundTwoDecimals(azmiuth_cache));
7559 //System.out.println("elevation: " + elevation);
7560 //
7561 //
7562 // SUN ----------------
7563 //
7564 //
7565 }
7566
7567 public void run()
7568 {
7569 //System.out.println("CWorkerThread -- started --");
7570 while (this.running)
7571 {
7572 if ((queue4.size() == 0) && (queue6.size() == 0))
7573 {
7574 try
7575 {
7576 Thread.sleep(2000); // 2 secs.
7577 }
7578 catch (InterruptedException e)
7579 {
7580 }
7581 }
7582
7583 if (this.startmain)
7584 {
7585 //System.out.println("CWorkerThread:startup_calls:JTHREAD ID=" + this.getId());
7586 //System.out.println("CWorkerThread:startup_calls:THREAD ID=" + NavitGraphics.GetThreadId());
7587
7588 this.startmain = false;
7589 System.out.println("CWorkerThread -- NavitMain --");
7590 NavitMain(x, lang, version, display_density_string, n_datadir, n_sharedir, NavitGraphics.draw_bitmap_s);
7591 System.out.println("CWorkerThread -- NavitActivity(3) --");
7592 NavitActivity(3);
7593
7594 // -- set map detail level (after app startup) --
7595 // -- set map detail level (after app startup) --
7596 // -- set map detail level (after app startup) --
7597 try
7598 {
7599 getPrefs_more_map_detail();
7600 if (p.PREF_more_map_detail > 0)
7601 {
7602 Message msg2 = new Message();
7603 Bundle b2 = new Bundle();
7604 b2.putInt("Callback", 78);
7605 b2.putString("s", "" + p.PREF_more_map_detail);
7606 msg2.setData(b2);
7607 NavitGraphics.callback_handler.sendMessage(msg2);
7608 }
7609 }
7610 catch (Exception e)
7611 {
7612 // e.printStackTrace();
7613 }
7614 // -- set map detail level (after app startup) --
7615 // -- set map detail level (after app startup) --
7616 // -- set map detail level (after app startup) --
7617
7618 // -- set map DPI factor (after app startup) --
7619 // -- set map DPI factor (after app startup) --
7620 // -- set map DPI factor (after app startup) --
7621 try
7622 {
7623 if ((Navit.metrics.densityDpi >= 320) && (!p.PREF_shrink_on_high_dpi))
7624 {
7625 double factor;
7626 factor = (double) Navit.metrics.densityDpi / (double) NavitGraphics.Global_Scaled_DPI_normal;
7627
7628 Message msg2 = new Message();
7629 Bundle b2 = new Bundle();
7630 b2.putInt("Callback", 81);
7631 b2.putString("s", "" + factor);
7632 msg2.setData(b2);
7633 NavitGraphics.callback_handler.sendMessage(msg2);
7634 }
7635 }
7636 catch (Exception e)
7637 {
7638 // e.printStackTrace();
7639 }
7640 // -- set map DPI factor (after app startup) --
7641 // -- set map DPI factor (after app startup) --
7642 // -- set map DPI factor (after app startup) --
7643 Global_Init_Finished = 1;
7644 //x.runOnUiThread(new Runnable()
7645 //{
7646 // public void run()
7647 // {
7648 // NavitActivity(3);
7649 // }
7650 //});
7651
7652 //**getPrefs();
7653 //**activatePrefs();
7654
7655 System.out.println("CWorkerThread -- calling:ready --");
7656 }
7657
7658 try
7659 {
7660 while (queue8.size() > 0)
7661 {
7662 l9 = queue8.poll();
7663 if (l9 != null)
7664 {
7665 // System.out.println("DrawLowqualMap");
7666 NavitGraphics.DrawLowqualMap(l9.latlonzoom, l9.w, l9.h, l9.fontsize, l9.scale, l9.selection_range);
7667 }
7668 }
7669 }
7670 catch (Exception e)
7671 {
7672 }
7673
7674 while (queue6.size() > 0)
7675 {
7676 try
7677 {
7678 // blocking call
7679 // l2 = queue6.take();
7680 // non-blocking call
7681 l7 = queue6.poll();
7682 if (l7 != null)
7683 {
7684 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7685 }
7686 }
7687
7688 catch (Exception e)
7689 {
7690 }
7691
7692 }
7693
7694 while (queue.size() > 0)
7695 {
7696 try
7697 {
7698 // blocking call
7699 // l2 = queue.take();
7700 // non-blocking call
7701 l2 = queue.poll();
7702 if (l2 != null)
7703 {
7704 //System.out.println("CWorkerThread:CallbackMessageChannelReal_call:JTHREAD ID=" + this.getId());
7705 //System.out.println("CWorkerThread:CallbackMessageChannelReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7706 //System.out.println("CWorkerThread:CallbackMessageChannelReal:" + l2.i);
7707 NavitGraphics.CallbackMessageChannelReal(l2.i, l2.s);
7708 //System.out.println("CWorkerThread:CallbackMessageChannelReal:finished");
7709 }
7710 }
7711 catch (Exception e)
7712 {
7713 }
7714
7715 // if GPS updates are pending, process them
7716 if (queue6.size() > 0)
7717 {
7718 try
7719 {
7720 // blocking call
7721 // l2 = queue6.take();
7722 // non-blocking call
7723 l7 = queue6.poll();
7724 if (l7 != null)
7725 {
7726 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7727 }
7728 }
7729 catch (Exception e)
7730 {
7731 }
7732 }
7733
7734 }
7735
7736 while (queue5.size() > 0)
7737 {
7738 try
7739 {
7740 // blocking call
7741 // l6 = queue5.take();
7742 // non-blocking call
7743 l6 = queue5.poll();
7744 if (l6 != null)
7745 {
7746 //System.out.println("CWorkerThread:SizeChangedCallbackReal_call:JTHREAD ID=" + this.getId());
7747 //System.out.println("CWorkerThread:SizeChangedCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7748 NavitGraphics.SizeChangedCallbackReal(l6.w, l6.h, l6.mb);
7749 }
7750 }
7751 catch (Exception e)
7752 {
7753 }
7754
7755 }
7756
7757 int count_timeout_callbacks = 0;
7758 while (count_timeout_callbacks < 10 && queue4.size() > 0)
7759 {
7760 count_timeout_callbacks++;
7761 try
7762 {
7763 // blocking call
7764 // l5 = queue4.take();
7765 // non-blocking call
7766 l5 = queue4.poll();
7767 if (l5 != null)
7768 {
7769 //System.out.println("CWorkerThread:TimeoutCallback_call:JTHREAD ID=" + this.getId());
7770 //System.out.println("CWorkerThread:TimeoutCallback_call:THREAD ID=" + NavitGraphics.GetThreadId());
7771 if ((l5.nt.running) || (!l5.nt.event_multi))
7772 {
7773 NavitGraphics.TimeoutCallback(l5.del, l5.id);
7774 }
7775 else
7776 {
7777 // System.out.println("CWorkerThread:TimeoutCallback_call:running=false! cid=" + l5.id);
7778 }
7779 }
7780 }
7781 catch (Exception e)
7782 {
7783 }
7784
7785 // if GPS updates are pending, process them
7786 if (queue6.size() > 0)
7787 {
7788 try
7789 {
7790 // blocking call
7791 // l2 = queue6.take();
7792 // non-blocking call
7793 l7 = queue6.poll();
7794 if (l7 != null)
7795 {
7796 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7797 }
7798 }
7799 catch (Exception e)
7800 {
7801 }
7802 }
7803
7804 }
7805
7806 while (queue3.size() > 0)
7807 {
7808 try
7809 {
7810 // blocking call
7811 // l4 = queue3.take();
7812 // non-blocking call
7813 l4 = queue3.poll();
7814 if (l4 != null)
7815 {
7816 //System.out.println("CWorkerThread:MotionCallbackReal_call:JTHREAD ID=" + this.getId());
7817 //System.out.println("CWorkerThread:MotionCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
7818 if (queue3.size() > 0)
7819 {
7820 // if more moves are queued up, disable map drawing!
7821 NavitGraphics.MotionCallbackReal(l4.x1, l4.y1, l4.x2, l4.y2, 0);
7822 }
7823 else
7824 {
7825 // ok, also draw the map
7826 NavitGraphics.MotionCallbackReal(l4.x1, l4.y1, l4.x2, l4.y2, 1);
7827 }
7828 }
7829 }
7830 catch (Exception e)
7831 {
7832 }
7833
7834 }
7835
7836 while (queue7.size() > 0)
7837 {
7838 try
7839 {
7840
7841 // if GPS updates are pending, process them
7842 if (queue6.size() > 0)
7843 {
7844 try
7845 {
7846 // blocking call
7847 // l2 = queue6.take();
7848 // non-blocking call
7849 l7 = queue6.poll();
7850 if (l7 != null)
7851 {
7852 NavitVehicle.VehicleCallback(l7.getLatitude(), l7.getLongitude(), (l7.getSpeed() * 3.6f), l7.getBearing(), l7.getAltitude(), l7.getAccuracy(), (l7.getTime() / 1000L));
7853 }
7854 }
7855 catch (Exception e)
7856 {
7857 }
7858 }
7859
7860 l8 = queue7.poll();
7861 if (l8 != null)
7862 {
7863 if (l8.type == 1)
7864 {
7865 Navit.OSD_nextturn.nextturn_streetname_systematic = "";
7866 // System.out.println("street name(1)");
7867 Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(8, l8.b, l8.c);
7868 // System.out.println("street name(2):" + Navit.OSD_nextturn.nextturn_streetname);
7869
7870 if (p.PREF_item_dump)
7871 {
7872 // -------- DEBUG ------- DEBUG ---------
7873 // -------- DEBUG ------- DEBUG ---------
7874 // -------- DEBUG ------- DEBUG ---------
7875 Navit.debug_item_dump = NavitGraphics.CallbackGeoCalc(9, l8.b, l8.c);
7876 //System.out.println("xx paint 22 xx");
7877 NavitGraphics.NavitAOverlay_s.postInvalidate();
7878 // -------- DEBUG ------- DEBUG ---------
7879 // -------- DEBUG ------- DEBUG ---------
7880 // -------- DEBUG ------- DEBUG ---------
7881 }
7882 //System.out.println("OSD postinvalidate***");
7883 //System.out.println("xx paint 7 xx");
7884 // NavitOSDJava.draw_real_wrapper(true, false);
7885 ZANaviLinearLayout.redraw_OSD(1);
7886 //++ NavitGraphics.NavitAOSDJava_.postInvalidate();
7887 }
7888 else if (l8.type == 2)
7889 {
7890 NavitGraphics.CallbackGeoCalc(l8.a, l8.b, l8.c);
7891 }
7892 else if (l8.type == 13)
7893 {
7894 try
7895 {
7896 // get roadbook
7897 // String road_book_res = NavitGraphics.CallbackGeoCalc(13, l8.b, l8.c);
7898 String[] separated = NavitGraphics.GetRoadBookItems(12345);
7899 // System.out.println("ROADBOOK_RES=" + separated);
7900
7901 // parse roadbook data ------------
7902 road_book_items.clear();
7903 ZANaviListViewAdapter.ListViewItem l = null;
7904
7905 // String[] separated = road_book_res.split("\13");
7906 int jk = 0;
7907 int ResId = 0;
7908 for (jk = 0; jk < separated.length; jk++)
7909 {
7910 if (jk > 1)
7911 {
7912 // System.out.println("ROADBOOK_RES=" + jk + ":" + separated[jk]);
7913 String[] values = new String[5];
7914 String[] values2 = separated[jk].split(":");
7915 values[0] = values2[0];
7916 values[1] = values2[1];
7917 values[2] = values2[2];
7918 values[3] = values2[3];
7919 try
7920 {
7921 values[4] = values2[4];
7922 }
7923 catch (Exception ee)
7924 {
7925 values[4] = "";
7926 }
7927 // 0 string:distance short form
7928 // 1 lat
7929 // 2 lon
7930 // 3 icon name
7931 // 4 text
7932
7933 // System.out.println("RBI:008:img=" + values[3]);
7934
7935 if (values[3].compareTo("nav_waypoint") == 0)
7936 {
7937 try
7938 {
7939 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_waypoint_bk_center", null, null);
7940 }
7941 catch (Exception e_res_id)
7942 {
7943 ResId = 0;
7944 e_res_id.printStackTrace();
7945 }
7946 }
7947 else if (values[3].compareTo("nav_destination") == 0)
7948 {
7949 try
7950 {
7951 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_destination_bk_center", null, null);
7952 }
7953 catch (Exception e_res_id)
7954 {
7955 ResId = 0;
7956 e_res_id.printStackTrace();
7957 }
7958 }
7959 else
7960 {
7961
7962 try
7963 {
7964 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + values[3] + "_bk", null, null);
7965 }
7966 catch (Exception e_res_id)
7967 {
7968 ResId = 0;
7969 e_res_id.printStackTrace();
7970 }
7971 }
7972
7973 try
7974 {
7975 // System.out.println("RBI:008+" + ResId);
7976 if (ResId != 0)
7977 {
7978 l = new ListViewItem(values[0], res_.getDrawable(ResId), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7979 }
7980 else
7981 {
7982 l = new ListViewItem(values[0], res_.getDrawable(R.drawable.mini_roundabout), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7983 }
7984 // System.out.println("RBI:008");
7985 road_book_items.add(l);
7986 // System.out.println("RBI:009");
7987 }
7988 catch (Exception ee)
7989 {
7990 // System.out.println("item=" + separated[jk] + " EEXX:" + ee.getMessage());
7991 }
7992 }
7993 }
7994 // System.out.println("RBI:010");
7995
7996 try
7997 {
7998 Message msg = Navit_progress_h.obtainMessage();
7999 Bundle b = new Bundle();
8000 msg.what = 33;
8001 msg.setData(b);
8002 Navit_progress_h.sendMessage(msg);
8003 }
8004 catch (Exception e)
8005 {
8006 e.printStackTrace();
8007 }
8008 // System.out.println("RBI:011");
8009 }
8010 catch (Exception eerb)
8011 {
8012 eerb.printStackTrace();
8013 }
8014 // parse roadbook data ------------
8015
8016 }
8017 }
8018 }
8019 catch (Exception e)
8020 {
8021 }
8022
8023 }
8024
8025 while (queue2.size() > 0)
8026 {
8027 try
8028 {
8029 // blocking call
8030 // l3 = queue2.take();
8031 // non-blocking call
8032 l3 = queue2.poll();
8033 if (l3 != null)
8034 {
8035 int i3 = l3.intValue();
8036 //System.out.println("CWorkerThread:NavitActivity_call:JTHREAD ID=" + this.getId());
8037 //System.out.println("CWorkerThread:NavitActivity_call:THREAD ID=" + NavitGraphics.GetThreadId());
8038 //System.out.println("CWorkerThread:NavitActivity:" + i3);
8039 NavitActivity(i3);
8040 }
8041 }
8042 catch (Exception e)
8043 {
8044 }
8045 }
8046
8047 // check sun position (and after interval, recalc values)
8048 do_sun_calc();
8049 }
8050 //System.out.println("CWorkerThread -- stopped --");
8051 }
8052
8053 public void stop_me()
8054 {
8055 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
8056
8057 this.running = false;
8058 this.interrupt();
8059
8060 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
8061 }
8062 }
8063
8064 public class SmoothVehicle extends Thread
8065 {
8066 private Boolean running;
8067
8068 SmoothVehicle()
8069 {
8070 this.running = true;
8071 }
8072
8073 public void run()
8074 {
8075 while (this.running)
8076 {
8077 try
8078 {
8079 Thread.sleep(5000); // 5 secs.
8080 }
8081 catch (InterruptedException e)
8082 {
8083 }
8084 }
8085 }
8086
8087 public void stop_me()
8088 {
8089 this.running = false;
8090 }
8091 }
8092
8093 public class WatchMem extends Thread
8094 {
8095 private Boolean running;
8096
8097 WatchMem()
8098 {
8099 this.running = true;
8100 }
8101
8102 public void run()
8103 {
8104 //System.out.println("WatchMem -- started --");
8105 while (this.running)
8106 {
8107 Navit.show_mem_used();
8108
8109 try
8110 {
8111 Thread.sleep(5000); // 5 secs.
8112 }
8113 catch (InterruptedException e)
8114 {
8115 }
8116 }
8117 //System.out.println("WatchMem -- stopped --");
8118 }
8119
8120 public void stop_me()
8121 {
8122 this.running = false;
8123 }
8124 }
8125
8126 public class SimGPS extends Thread
8127 {
8128 private Boolean running;
8129 private Handler h;
8130
8131 SimGPS(Handler h_)
8132 {
8133 System.out.println("SimGPS -- inited --");
8134 this.h = h_;
8135 this.running = true;
8136 }
8137
8138 public void run()
8139 {
8140 System.out.println("SimGPS -- started --");
8141 while (this.running)
8142 {
8143 float rnd_heading = (float) (Math.random() * 360d);
8144 float lat = 48.216023f;
8145 float lng = 16.391664f;
8146 //Location l = new Location("Network");
8147 //l.setLatitude(lat);
8148 //l.setLongitude(lng);
8149 //l.setBearing(rnd_heading);
8150 // NavitVehicle.set_mock_location__fast(l);
8151 // NavitVehicle.update_compass_heading(rnd_heading);
8152 if (this.h != null)
8153 {
8154 Message msg = this.h.obtainMessage();
8155 Bundle b = new Bundle();
8156 msg.what = 1;
8157 b.putFloat("b", rnd_heading);
8158 b.putFloat("lat", lat);
8159 b.putFloat("lng", lng);
8160 msg.setData(b);
8161 this.h.sendMessage(msg);
8162 }
8163 try
8164 {
8165 Thread.sleep(800);
8166 }
8167 catch (InterruptedException e)
8168 {
8169 }
8170 }
8171 System.out.println("SimGPS -- stopped --");
8172 }
8173
8174 public void stop_me()
8175 {
8176 this.running = false;
8177 }
8178 }
8179
8180 public class SearchResultsThreadSpinnerThread extends Thread
8181 {
8182 int dialog_num;
8183 int spinner_current_value;
8184 private Boolean running;
8185 Handler mHandler;
8186
8187 SearchResultsThreadSpinnerThread(Handler h, int dialog_num)
8188 {
8189 this.dialog_num = dialog_num;
8190 this.mHandler = h;
8191 this.spinner_current_value = 0;
8192
8193 this.running = true;
8194 Log.e("Navit", "SearchResultsThreadSpinnerThread created");
8195 }
8196
8197 public void run()
8198 {
8199 Log.e("Navit", "SearchResultsThreadSpinnerThread started");
8200 while (this.running)
8201 {
8202 if (Navit.NavitAddressSearchSpinnerActive == false)
8203 {
8204 this.running = false;
8205 }
8206 else
8207 {
8208 Message msg = mHandler.obtainMessage();
8209 Bundle b = new Bundle();
8210 msg.what = 10;
8211 b.putInt("dialog_num", this.dialog_num);
8212 b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8213 b.putInt("cur", this.spinner_current_value % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
8214 if ((Navit.NavitSearchresultBar_title.equals("")) && (Navit.NavitSearchresultBar_text.equals("")))
8215 {
8216 b.putString("title", Navit.get_text("getting search results")); //TRANS
8217 b.putString("text", Navit.get_text("searching ...")); //TRANS
8218 }
8219 else
8220 {
8221 b.putString("title", Navit.NavitSearchresultBar_title);
8222 b.putString("text", Navit.NavitSearchresultBar_text);
8223 }
8224 msg.setData(b);
8225 mHandler.sendMessage(msg);
8226 try
8227 {
8228 Thread.sleep(700);
8229 }
8230 catch (InterruptedException e)
8231 {
8232 // e.printStackTrace();
8233 }
8234 this.spinner_current_value++;
8235 }
8236 }
8237 Log.e("Navit", "SearchResultsThreadSpinnerThread ended");
8238 }
8239 }
8240
8241 public class SearchResultsThread extends Thread
8242 {
8243 private Boolean running;
8244 Handler mHandler;
8245 int my_dialog_num;
8246
8247 SearchResultsThread(Handler h, int dialog_num)
8248 {
8249 this.running = true;
8250 this.mHandler = h;
8251 this.my_dialog_num = dialog_num;
8252 Log.e("Navit", "SearchResultsThread created");
8253 }
8254
8255 public void stop_me()
8256 {
8257 this.running = false;
8258 }
8259
8260 public void run()
8261 {
8262 Log.e("Navit", "SearchResultsThread started");
8263
8264 System.out.println("Global_Location_update_not_allowed = 1");
8265 Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now!
8266
8267 // initialize the dialog with sane values
8268 Message msg = mHandler.obtainMessage();
8269 Bundle b = new Bundle();
8270 msg.what = 10;
8271 b.putInt("dialog_num", this.my_dialog_num);
8272 b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8273 b.putInt("cur", 0);
8274 b.putString("title", Navit.get_text("getting search results")); //TRANS
8275 b.putString("text", Navit.get_text("searching ...")); //TRANS
8276 msg.setData(b);
8277 mHandler.sendMessage(msg);
8278
8279 int partial_match_i = 0;
8280 if (Navit_last_address_partial_match)
8281 {
8282 partial_match_i = 1;
8283 }
8284
8285 if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
8286 {
8287 Navit.search_ready = false;
8288
8289 // start the search, this could take a long time!!
8290 Log.e("Navit", "SearchResultsThread run1");
8291 // need lowercase to find stuff !!
8292 Navit_last_address_search_string = filter_bad_chars(Navit_last_address_search_string).toLowerCase();
8293 if ((Navit_last_address_hn_string != null) && (!Navit_last_address_hn_string.equals("")))
8294 {
8295 Navit_last_address_hn_string = filter_bad_chars(Navit_last_address_hn_string).toLowerCase();
8296 }
8297
8298 if (Navit_last_address_full_file_search)
8299 {
8300 // flags (18) -> order level to search at
8301 // ================
8302 // 0#0 0 -> search full world
8303 // lat#lon radius -> search only this area, around lat,lon
8304 // ================
8305 N_NavitGraphics.SearchResultList(3, partial_match_i, Navit_last_address_search_string, "", "", 18, Navit_last_address_search_country_iso2_string, "0#0", 0);
8306 }
8307 else
8308 {
8309 if (Navit.use_index_search)
8310 {
8311 // new method with index search
8312 // -----------------
8313 //Navit_last_address_search_string
8314 String street_ = "";
8315 String town_ = "";
8316 String hn_ = Navit_last_address_hn_string;
8317
8318 int last_space = Navit_last_address_search_string.lastIndexOf(" ");
8319 if (last_space != -1)
8320 {
8321 street_ = Navit_last_address_search_string.substring(0, last_space);
8322 town_ = Navit_last_address_search_string.substring(last_space + 1);
8323 // System.out.println("XX" + street_ + "YY" + town_ + "ZZ");
8324 }
8325 else
8326 {
8327 street_ = Navit_last_address_search_string;
8328 town_ = "";
8329 }
8330
8331 System.out.println("search params1=" + street_ + ":" + town_ + ":" + hn_);
8332 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);
8333
8334 // sort result list
8335 Collections.sort(Navit.NavitAddressResultList_foundItems);
8336 }
8337 else
8338 {
8339 // old method search
8340 // -----------------
8341 // flags --> 3: search all countries
8342 // 2: search <iso2 string> country
8343 // 1: search default country (what you have set as language in prefs)
8344 System.out.println("searching ... 001");
8345
8346 System.out.println("search params2a=" + Navit_last_address_hn_string);
8347
8348 String old_s = Navit_last_address_search_string;
8349 String new_s = Navit_last_address_search_string;
8350 if ((Navit_last_address_hn_string != null) && (!Navit_last_address_hn_string.equals("")))
8351 {
8352 new_s = Navit_last_address_search_string + " " + Navit_last_address_hn_string;
8353 }
8354
8355 System.out.println("search params2=" + new_s + ":" + Navit_last_address_search_country_flags + ":" + Navit_last_address_search_country_iso2_string);
8356
8357 N_NavitGraphics.SearchResultList(29, partial_match_i, new_s, "", "", Navit_last_address_search_country_flags, Navit_last_address_search_country_iso2_string, "0#0", 0);
8358 System.out.println("searching ... 002");
8359
8360 // sort result list
8361 Collections.sort(Navit.NavitAddressResultList_foundItems);
8362
8363 System.out.println("searching ... 099");
8364 Navit.search_ready = true;
8365 }
8366 }
8367 Log.e("Navit", "SearchResultsThread run2");
8368 }
8369 else if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG)
8370 {
8371 // online googlemaps search
8372 // google search
8373 Log.e("Navit", "SearchResultsThread run1 -> online googlemaps search");
8374 String addressInput = filter_bad_chars(Navit_last_address_search_string);
8375 try
8376 {
8377 List<Address> foundAdresses = Navit.Navit_Geocoder.getFromLocationName(addressInput, 3); //Search addresses
8378 System.out.println("found " + foundAdresses.size() + " results");
8379 // System.out.println("addr=" + foundAdresses.get(0).getLatitude() + " " + foundAdresses.get(0).getLongitude() + "" + foundAdresses.get(0).getAddressLine(0));
8380
8381 Navit.NavitAddressSearchSpinnerActive = false;
8382
8383 for (int results_step = 0; results_step < foundAdresses.size(); results_step++)
8384 {
8385 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
8386 tmp_addr.result_type = "STR";
8387 tmp_addr.item_id = "0";
8388 tmp_addr.lat = (float) foundAdresses.get(results_step).getLatitude();
8389 tmp_addr.lon = (float) foundAdresses.get(results_step).getLongitude();
8390 tmp_addr.addr = "";
8391
8392 String c_code = foundAdresses.get(results_step).getCountryCode();
8393 if (c_code != null)
8394 {
8395 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getCountryCode() + ",";
8396 }
8397
8398 String p_code = foundAdresses.get(results_step).getPostalCode();
8399 if (p_code != null)
8400 {
8401 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getPostalCode() + " ";
8402 }
8403
8404 if (foundAdresses.get(results_step).getMaxAddressLineIndex() > -1)
8405 {
8406 for (int addr_line = 0; addr_line < foundAdresses.get(results_step).getMaxAddressLineIndex(); addr_line++)
8407 {
8408 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
8409 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
8410 }
8411 }
8412
8413 Navit.NavitAddressResultList_foundItems.add(tmp_addr);
8414
8415 if (tmp_addr.result_type.equals("TWN"))
8416 {
8417 Navit.search_results_towns++;
8418 }
8419 else if (tmp_addr.result_type.equals("STR"))
8420 {
8421 Navit.search_results_streets++;
8422 }
8423 else if (tmp_addr.result_type.equals("SHN"))
8424 {
8425 Navit.search_results_streets_hn++;
8426 }
8427 else if (tmp_addr.result_type.equals("POI"))
8428 {
8429 Navit.search_results_poi++;
8430 }
8431
8432 // make the dialog move its bar ...
8433 Bundle b2 = new Bundle();
8434 b2.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
8435 b2.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
8436 b2.putInt("cur", Navit.NavitAddressResultList_foundItems.size() % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
8437 b2.putString("title", Navit.get_text("loading search results")); //TRANS
8438 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);
8439
8440 Navit.msg_to_msg_handler(b2, 10);
8441 }
8442 }
8443 catch (Exception e)
8444 {
8445 e.printStackTrace();
8446 System.out.println("seems googlemaps API is not working, try offline search");
8447 }
8448 }
8449
8450 Navit.NavitAddressSearchSpinnerActive = false;
8451
8452 if (Navit.NavitAddressResultList_foundItems.size() > 0)
8453 {
8454 open_search_result_list();
8455 }
8456 else
8457 {
8458 // no results found, show toast
8459 msg = mHandler.obtainMessage();
8460 b = new Bundle();
8461 msg.what = 2;
8462 b.putString("text", Navit.get_text("No Results found!")); //TRANS
8463 msg.setData(b);
8464 mHandler.sendMessage(msg);
8465 }
8466
8467 // ok, remove dialog
8468 Log.e("Navit", "SearchResultsThread:remove dialog (99)");
8469 msg = mHandler.obtainMessage();
8470 b = new Bundle();
8471 msg.what = 99;
8472 b.putInt("dialog_num", this.my_dialog_num);
8473 msg.setData(b);
8474 mHandler.sendMessage(msg);
8475
8476 // reset the startup-search flag
8477 Navit.NavitStartupAlreadySearching = false;
8478
8479 System.out.println("Global_Location_update_not_allowed = 0");
8480 Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now!
8481
8482 Log.e("Navit", "SearchResultsThread ended");
8483 }
8484 }
8485
8486 public static String filter_bad_chars(String in)
8487 {
8488 String out = in;
8489 out = out.replaceAll("\\n", " "); // newline -> space
8490 out = out.replaceAll("\\r", " "); // return -> space
8491 out = out.replaceAll("\\t", " "); // tab -> space
8492 out = out.trim();
8493 return out;
8494 }
8495
8496 public static void msg_to_msg_handler(Bundle b, int id)
8497 {
8498 Message msg = Navit_progress_h.obtainMessage();
8499 msg.what = id;
8500 msg.setData(b);
8501 Navit_progress_h.sendMessage(msg);
8502 }
8503
8504 public void open_search_result_list()
8505 {
8506 // open result list
8507 Intent address_result_list_activity = new Intent(this, NavitAddressResultListActivity.class);
8508 this.startActivityForResult(address_result_list_activity, Navit.NavitAddressResultList_id);
8509 }
8510
8511 public static Handler callback_handler_55 = new Handler()
8512 {
8513 public void handleMessage(Message msg)
8514 {
8515 // handle 111111
8516 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0, "" + msg.getData().getInt("Callback"));
8517
8518 if (msg.getData().getInt("Callback") == 1)
8519 {
8520 // zoom in
8521 NavitGraphics.CallbackMessageChannel(1, "");
8522 }
8523 else if (msg.getData().getInt("Callback") == 2)
8524 {
8525 // zoom out
8526 NavitGraphics.CallbackMessageChannel(2, "");
8527 }
8528 else if (msg.getData().getInt("Callback") == 55599)
8529 {
8530 // calc route after adding points
8531 NavitGraphics.CallbackMessageChannel(55599, "");
8532 }
8533 else if (msg.getData().getInt("Callback") == 55503)
8534 {
8535 try
8536 {
8537 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0); // CLR
8538 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8539 }
8540 catch (Exception e)
8541 {
8542 }
8543
8544 // get values
8545 String lat = msg.getData().getString("lat");
8546 String lon = msg.getData().getString("lon");
8547 String q = msg.getData().getString("q");
8548 // set routing target to lat,lon
8549 NavitGraphics.CallbackMessageChannel(55503, lat + "#" + lon + "#" + q);
8550 }
8551 else if (msg.getData().getInt("Callback") == 3)
8552 {
8553 try
8554 {
8555 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0); // CLR
8556 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8557 }
8558 catch (Exception e)
8559 {
8560 }
8561
8562 // get values
8563 String lat = msg.getData().getString("lat");
8564 String lon = msg.getData().getString("lon");
8565 String q = msg.getData().getString("q");
8566 // set routing target to lat,lon
8567 NavitGraphics.CallbackMessageChannel(3, lat + "#" + lon + "#" + q);
8568 }
8569 else if (msg.getData().getInt("Callback") == 55548)
8570 {
8571 try
8572 {
8573 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8574 }
8575 catch (Exception e)
8576 {
8577 }
8578
8579 // get values
8580 String lat = msg.getData().getString("lat");
8581 String lon = msg.getData().getString("lon");
8582 String q = msg.getData().getString("q");
8583 // append to routing, add waypoint at lat,lon
8584 NavitGraphics.CallbackMessageChannel(55548, lat + "#" + lon + "#" + q);
8585 }
8586 else if (msg.getData().getInt("Callback") == 48)
8587 {
8588 try
8589 {
8590 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8591 }
8592 catch (Exception e)
8593 {
8594 }
8595
8596 // get values
8597 String lat = msg.getData().getString("lat");
8598 String lon = msg.getData().getString("lon");
8599 String q = msg.getData().getString("q");
8600 // append to routing, add waypoint at lat,lon
8601 NavitGraphics.CallbackMessageChannel(48, lat + "#" + lon + "#" + q);
8602 }
8603 else if (msg.getData().getInt("Callback") == 4)
8604 {
8605 // set routing target to pixel x,y
8606 int x = msg.getData().getInt("x");
8607 int y = msg.getData().getInt("y");
8608
8609 NavitGraphics.CallbackMessageChannel(4, "" + x + "#" + y);
8610 try
8611 {
8612 Navit.follow_button_on();
8613 }
8614 catch (Exception e2)
8615 {
8616 e2.printStackTrace();
8617 }
8618 }
8619 else if (msg.getData().getInt("Callback") == 49)
8620 {
8621 // set routing target to pixel x,y
8622 int x = msg.getData().getInt("x");
8623 int y = msg.getData().getInt("y");
8624
8625 NavitGraphics.CallbackMessageChannel(49, "" + x + "#" + y);
8626 try
8627 {
8628 Navit.follow_button_on();
8629 }
8630 catch (Exception e2)
8631 {
8632 e2.printStackTrace();
8633 }
8634 }
8635 else if (msg.getData().getInt("Callback") == 5)
8636 {
8637 // toggle layer on/off
8638 String s = msg.getData().getString("s");
8639 NavitGraphics.CallbackMessageChannel(5, s);
8640 }
8641 else if (msg.getData().getInt("Callback") == 7)
8642 {
8643 NavitGraphics.CallbackMessageChannel(7, "");
8644 }
8645 else if ((msg.getData().getInt("Callback") > 7) && (msg.getData().getInt("Callback") < 21))
8646 {
8647 NavitGraphics.CallbackMessageChannel(msg.getData().getInt("Callback"), "");
8648 }
8649 else if (msg.getData().getInt("Callback") == 21)
8650 {
8651 int x = msg.getData().getInt("x");
8652 int y = msg.getData().getInt("y");
8653 // ??? // ButtonCallback(1, 1, x, y); // down
8654 }
8655 else if (msg.getData().getInt("Callback") == 22)
8656 {
8657 int x = msg.getData().getInt("x");
8658 int y = msg.getData().getInt("y");
8659 // ??? // ButtonCallback(0, 1, x, y); // up
8660 }
8661 else if (msg.getData().getInt("Callback") == 23)
8662 {
8663 int x = msg.getData().getInt("x");
8664 int y = msg.getData().getInt("y");
8665 int x2 = msg.getData().getInt("x2");
8666 int y2 = msg.getData().getInt("y2");
8667 NavitGraphics.MotionCallback(x, y, x2, y2);
8668 }
8669 else if (msg.getData().getInt("Callback") == 24)
8670 {
8671 try
8672 {
8673 NavitGraphics.NavitMsgTv_.setEnabled(true);
8674 NavitGraphics.NavitMsgTv_.setVisibility(View.VISIBLE);
8675 }
8676 catch (Exception e)
8677 {
8678
8679 }
8680 }
8681 else if (msg.getData().getInt("Callback") == 25)
8682 {
8683 try
8684 {
8685 NavitGraphics.NavitMsgTv_.setVisibility(View.INVISIBLE);
8686 NavitGraphics.NavitMsgTv_.setEnabled(false);
8687 NavitGraphics.NavitMsgTv_.setVisibility(View.GONE);
8688 }
8689 catch (Exception e)
8690 {
8691
8692 }
8693 }
8694 else if (msg.getData().getInt("Callback") == 30)
8695 {
8696 // 2D
8697 // String s = msg.getData().getString("s");
8698 NavitGraphics.CallbackMessageChannel(30, "");
8699 }
8700 else if (msg.getData().getInt("Callback") == 31)
8701 {
8702 // 3D
8703 // String s = msg.getData().getString("s");
8704 NavitGraphics.CallbackMessageChannel(31, "");
8705 }
8706 else if (msg.getData().getInt("Callback") == 32)
8707 {
8708 // switch to specific 3D pitch
8709 String s = msg.getData().getString("s");
8710 NavitGraphics.CallbackMessageChannel(32, s);
8711 }
8712 else if (msg.getData().getInt("Callback") == 33)
8713 {
8714 // zoom to specific zoomlevel
8715 String s = msg.getData().getString("s");
8716 NavitGraphics.CallbackMessageChannel(33, s);
8717 }
8718 else if (msg.getData().getInt("Callback") == 34)
8719 {
8720 // announcer voice OFF
8721 NavitGraphics.CallbackMessageChannel(34, "");
8722 }
8723 else if (msg.getData().getInt("Callback") == 35)
8724 {
8725 // announcer voice ON
8726 NavitGraphics.CallbackMessageChannel(35, "");
8727 }
8728 else if (msg.getData().getInt("Callback") == 36)
8729 {
8730 // switch "Lock on road" ON
8731 NavitGraphics.CallbackMessageChannel(36, "");
8732 }
8733 else if (msg.getData().getInt("Callback") == 37)
8734 {
8735 // switch "Lock on road" OFF
8736 NavitGraphics.CallbackMessageChannel(37, "");
8737 }
8738 else if (msg.getData().getInt("Callback") == 38)
8739 {
8740 // switch "Northing" ON
8741 NavitGraphics.CallbackMessageChannel(38, "");
8742 }
8743 else if (msg.getData().getInt("Callback") == 39)
8744 {
8745 // switch "Northing" OFF
8746 NavitGraphics.CallbackMessageChannel(39, "");
8747 }
8748 else if (msg.getData().getInt("Callback") == 40)
8749 {
8750 // switch "Map follows Vehicle" ON
8751 NavitGraphics.CallbackMessageChannel(40, "");
8752 }
8753 else if (msg.getData().getInt("Callback") == 41)
8754 {
8755 // switch "Map follows Vehicle" OFF
8756 NavitGraphics.CallbackMessageChannel(41, "");
8757 }
8758 else if (msg.getData().getInt("Callback") == 42)
8759 {
8760 // routing mode "highways"
8761 NavitGraphics.CallbackMessageChannel(42, "");
8762 }
8763 else if (msg.getData().getInt("Callback") == 43)
8764 {
8765 // routing mode "normal roads"
8766 NavitGraphics.CallbackMessageChannel(43, "");
8767 }
8768 else if (msg.getData().getInt("Callback") == 44)
8769 {
8770 // show duplicates in search results
8771 NavitGraphics.CallbackMessageChannel(44, "");
8772 }
8773 else if (msg.getData().getInt("Callback") == 45)
8774 {
8775 // filter duplicates in search results
8776 NavitGraphics.CallbackMessageChannel(45, "");
8777 }
8778 else if (msg.getData().getInt("Callback") == 46)
8779 {
8780 // stop searching and show results found until now
8781 NavitGraphics.CallbackMessageChannel(46, "");
8782 }
8783 else if (msg.getData().getInt("Callback") == 47)
8784 {
8785 // change maps data dir
8786 String s = msg.getData().getString("s");
8787 NavitGraphics.CallbackMessageChannel(47, s);
8788 }
8789 else if (msg.getData().getInt("Callback") == 50)
8790 {
8791 // we request to stop drawing the map
8792 NavitGraphics.CallbackMessageChannel(50, "");
8793 }
8794 else if (msg.getData().getInt("Callback") == 51)
8795 {
8796 // set position to pixel x,y
8797 int x = msg.getData().getInt("x");
8798 int y = msg.getData().getInt("y");
8799 NavitGraphics.CallbackMessageChannel(51, "" + x + "#" + y);
8800 }
8801 else if (msg.getData().getInt("Callback") == 52)
8802 {
8803 // switch to demo vehicle
8804 String s = msg.getData().getString("s");
8805 NavitGraphics.CallbackMessageChannel(52, s);
8806 }
8807 else if (msg.getData().getInt("Callback") == 53)
8808 {
8809 // dont speak streetnames
8810 NavitGraphics.CallbackMessageChannel(53, "");
8811 }
8812 else if (msg.getData().getInt("Callback") == 54)
8813 {
8814 // speak streetnames
8815 NavitGraphics.CallbackMessageChannel(54, "");
8816 }
8817 else if (msg.getData().getInt("Callback") == 55)
8818 {
8819 // set cache size for (map-)files
8820 String s = msg.getData().getString("s");
8821 NavitGraphics.CallbackMessageChannel(55, s);
8822 }
8823 // else if (msg.getData().getInt("Callback") == 56)
8824 // {
8825 // // draw polylines with/without circles at the end
8826 // String s = msg.getData().getString("s");
8827 // NavitGraphics.CallbackMessageChannel(56, s); // 0 -> draw circles, 1 -> DO NOT draw circles
8828 // }
8829 else if (msg.getData().getInt("Callback") == 57)
8830 {
8831 // keep drawing streets as if at "order" level xxx
8832 String s = msg.getData().getString("s");
8833 NavitGraphics.CallbackMessageChannel(57, s);
8834 }
8835 else if (msg.getData().getInt("Callback") == 58)
8836 {
8837 // street search radius factor (multiplier)
8838 String s = msg.getData().getString("s");
8839 NavitGraphics.CallbackMessageChannel(58, s);
8840 }
8841 else if (msg.getData().getInt("Callback") == 59)
8842 {
8843 // enable layer "name"
8844 String s = msg.getData().getString("s");
8845 NavitGraphics.CallbackMessageChannel(59, s);
8846 }
8847 else if (msg.getData().getInt("Callback") == 60)
8848 {
8849 // disable layer "name"
8850 String s = msg.getData().getString("s");
8851 NavitGraphics.CallbackMessageChannel(60, s);
8852 }
8853 else if (msg.getData().getInt("Callback") == 61)
8854 {
8855 // zoom to specific zoomlevel at given point as center
8856 // pixel-x#pixel-y#zoom-level
8857 String s = msg.getData().getString("s");
8858 NavitGraphics.CallbackMessageChannel(61, s);
8859 }
8860 else if (msg.getData().getInt("Callback") == 62)
8861 {
8862 // disable map drawing
8863 NavitGraphics.CallbackMessageChannel(62, "");
8864 }
8865 else if (msg.getData().getInt("Callback") == 63)
8866 {
8867 // enable map drawing
8868 NavitGraphics.CallbackMessageChannel(63, "");
8869 }
8870 else if (msg.getData().getInt("Callback") == 64)
8871 {
8872 // draw map
8873 NavitGraphics.CallbackMessageChannel(64, "");
8874 }
8875 else if (msg.getData().getInt("Callback") == 65)
8876 {
8877 // draw map async
8878 NavitGraphics.CallbackMessageChannel(65, "");
8879 }
8880 else if (msg.getData().getInt("Callback") == 66)
8881 {
8882 // enable "multipolygons"
8883 NavitGraphics.CallbackMessageChannel(66, "");
8884 }
8885 else if (msg.getData().getInt("Callback") == 67)
8886 {
8887 // disable "multipolygons"
8888 NavitGraphics.CallbackMessageChannel(67, "");
8889 }
8890 else if (msg.getData().getInt("Callback") == 68)
8891 {
8892 // shift "order" by this value (only for drawing objects)
8893 String s = msg.getData().getString("s");
8894 NavitGraphics.CallbackMessageChannel(68, s);
8895 }
8896 else if (msg.getData().getInt("Callback") == 69)
8897 {
8898 // stop drawing map
8899 NavitGraphics.CallbackMessageChannel(69, "");
8900 }
8901 else if (msg.getData().getInt("Callback") == 70)
8902 {
8903 // allow drawing map
8904 NavitGraphics.CallbackMessageChannel(70, "");
8905 }
8906 else if (msg.getData().getInt("Callback") == 71)
8907 {
8908 // activate/deactivate "route graph" display
8909 // 0 -> deactivate
8910 // 1 -> activate
8911 String s = msg.getData().getString("s");
8912 NavitGraphics.CallbackMessageChannel(71, s);
8913 }
8914 else if (msg.getData().getInt("Callback") == 72)
8915 {
8916 // update the route path and route graph (e.g. after setting new roadblocks)
8917 // does not update destinations!!!
8918 NavitGraphics.CallbackMessageChannel(72, "");
8919 }
8920 else if (msg.getData().getInt("Callback") == 73)
8921 {
8922 // update the route path and route graph (e.g. after setting new roadblocks)
8923 // this destroys the route graph and calcs everything totally new!
8924 NavitGraphics.CallbackMessageChannel(73, "");
8925 }
8926
8927 else if (msg.getData().getInt("Callback") == 74)
8928 {
8929 // allow demo vechile to move
8930 NavitGraphics.CallbackMessageChannel(74, "");
8931 }
8932 else if (msg.getData().getInt("Callback") == 75)
8933 {
8934 // stop demo vechile
8935 NavitGraphics.CallbackMessageChannel(75, "");
8936 }
8937 else if (msg.getData().getInt("Callback") == 76)
8938 {
8939 // show route rectangles
8940 NavitGraphics.CallbackMessageChannel(76, "");
8941 }
8942 else if (msg.getData().getInt("Callback") == 77)
8943 {
8944 // do not show route rectangles
8945 NavitGraphics.CallbackMessageChannel(77, "");
8946 }
8947 else if (msg.getData().getInt("Callback") == 78)
8948 {
8949 // shift layout "order" values
8950 String s = msg.getData().getString("s");
8951 NavitGraphics.CallbackMessageChannel(78, s);
8952 }
8953 else if (msg.getData().getInt("Callback") == 79)
8954 {
8955 // set traffic light delay/cost
8956 String s = msg.getData().getString("s");
8957 NavitGraphics.CallbackMessageChannel(79, s);
8958 }
8959 else if (msg.getData().getInt("Callback") == 80)
8960 {
8961 // set autozoom flag to 0 or 1
8962 String s = msg.getData().getString("s");
8963 NavitGraphics.CallbackMessageChannel(80, s);
8964 }
8965 else if (msg.getData().getInt("Callback") == 81)
8966 {
8967 // resize layout items by factor
8968 String s = msg.getData().getString("s");
8969 NavitGraphics.CallbackMessageChannel(81, s);
8970 }
8971 else if (msg.getData().getInt("Callback") == 82)
8972 {
8973 // report share dir
8974 String s = msg.getData().getString("s");
8975 NavitGraphics.CallbackMessageChannel(82, s);
8976 }
8977 else if (msg.getData().getInt("Callback") == 83)
8978 {
8979 // spill all the index files to log output
8980 NavitGraphics.CallbackMessageChannel(83, "");
8981 }
8982 else if (msg.getData().getInt("Callback") == 84)
8983 {
8984 // report data dir
8985 String s = msg.getData().getString("s");
8986 NavitGraphics.CallbackMessageChannel(84, s);
8987 }
8988 else if (msg.getData().getInt("Callback") == 85)
8989 {
8990 // C linedrawing flag
8991 String s = msg.getData().getString("s");
8992 NavitGraphics.CallbackMessageChannel(85, s);
8993 }
8994 else if (msg.getData().getInt("Callback") == 86)
8995 {
8996 // avoid sharp turns flag to 0 or 1
8997 String s = msg.getData().getString("s");
8998 NavitGraphics.CallbackMessageChannel(86, s);
8999 }
9000 else if (msg.getData().getInt("Callback") == 87)
9001 {
9002 // // avoid sharp turns minimum angle. if turn is harder than this angle then set penalty
9003 String s = msg.getData().getString("s");
9004 NavitGraphics.CallbackMessageChannel(87, s);
9005 }
9006 else if (msg.getData().getInt("Callback") == 88)
9007 {
9008 // avoid sharp turns penalty
9009 String s = msg.getData().getString("s");
9010 NavitGraphics.CallbackMessageChannel(88, s);
9011 }
9012 else if (msg.getData().getInt("Callback") == 89)
9013 {
9014 // search radius for housenumbers for streets
9015 String s = msg.getData().getString("s");
9016 NavitGraphics.CallbackMessageChannel(89, s);
9017 }
9018 else if (msg.getData().getInt("Callback") == 90)
9019 {
9020 // set vehicleprofile to value of string s ('car','bike')
9021 String s = msg.getData().getString("s");
9022 NavitGraphics.CallbackMessageChannel(90, s);
9023 }
9024 else if (msg.getData().getInt("Callback") == 91)
9025 {
9026 // change vehicle profile's roadprofile values
9027 String s = msg.getData().getString("s");
9028 NavitGraphics.CallbackMessageChannel(91, s);
9029 }
9030 else if (msg.getData().getInt("Callback") == 92)
9031 {
9032 // change vehicle profile's roadprofile values 2
9033 String s = msg.getData().getString("s");
9034 NavitGraphics.CallbackMessageChannel(92, s);
9035 }
9036 else if (msg.getData().getInt("Callback") == 93)
9037 {
9038 // change vehicle profile's roadprofile values 3
9039 String s = msg.getData().getString("s");
9040 NavitGraphics.CallbackMessageChannel(93, s);
9041 }
9042 else if (msg.getData().getInt("Callback") == 94)
9043 {
9044 // change priority for cycle lanes
9045 String s = msg.getData().getString("s");
9046 NavitGraphics.CallbackMessageChannel(94, s);
9047 }
9048 //else if (msg.getData().getInt("Callback") == 95)
9049 //{
9050 // // change priority for cycle tracks
9051 // String s = msg.getData().getString("s");
9052 // NavitGraphics.CallbackMessageChannel(95, s);
9053 //}
9054 else if (msg.getData().getInt("Callback") == 96)
9055 {
9056 // dump route to GPX file, "s" -> full pathname to output file
9057 String s = msg.getData().getString("s");
9058 NavitGraphics.CallbackMessageChannel(96, s);
9059 }
9060 else if (msg.getData().getInt("Callback") == 97)
9061 {
9062 // set positon to lat#lon#name
9063 String lat = msg.getData().getString("lat");
9064 String lon = msg.getData().getString("lon");
9065 String q = msg.getData().getString("q");
9066 NavitGraphics.CallbackMessageChannel(97, lat + "#" + lon + "#" + q);
9067 }
9068 else if (msg.getData().getInt("Callback") == 98)
9069 {
9070 // set connected_pref value
9071 String s = msg.getData().getString("s");
9072 NavitGraphics.CallbackMessageChannel(98, s);
9073 }
9074 else if (msg.getData().getInt("Callback") == 99)
9075 {
9076 // set angle_pref value
9077 String s = msg.getData().getString("s");
9078 NavitGraphics.CallbackMessageChannel(99, s);
9079 }
9080 else if (msg.getData().getInt("Callback") == 100)
9081 {
9082 // dump callbacks to log
9083 NavitGraphics.CallbackMessageChannel(100, "");
9084 }
9085 else if (msg.getData().getInt("Callback") == 101)
9086 {
9087 // set demo vehicle flag for tracking
9088 NavitGraphics.CallbackMessageChannel(101, "");
9089 }
9090 else if (msg.getData().getInt("Callback") == 102)
9091 {
9092 // set gpsfix flag
9093 String s = msg.getData().getString("s");
9094 NavitGraphics.CallbackMessageChannel(102, s);
9095 }
9096 else if (msg.getData().getInt("Callback") == 103)
9097 {
9098 // draw location of self (car) x% lower than screen center
9099 String s = msg.getData().getString("s");
9100 NavitGraphics.CallbackMessageChannel(103, s);
9101 }
9102 else if (msg.getData().getInt("Callback") == 104)
9103 {
9104 // send OVERSPILL_FACTOR to C-code
9105 String s;
9106 if (Navit.GFX_OVERSPILL)
9107 {
9108 s = "" + (OVERSPILL_FACTOR * 100);
9109 }
9110 else
9111 {
9112 s = "" + 100;
9113 }
9114
9115 NavitGraphics.CallbackMessageChannel(104, s);
9116 }
9117 else if (msg.getData().getInt("Callback") == 105)
9118 {
9119 // zoom to specific zoomlevel without redrawing the map!
9120 String s = msg.getData().getString("s");
9121 NavitGraphics.CallbackMessageChannel(105, s);
9122 }
9123 else if (msg.getData().getInt("Callback") == 106)
9124 {
9125 // factor for routing/road speed
9126 String s = msg.getData().getString("s");
9127 NavitGraphics.CallbackMessageChannel(106, s);
9128 }
9129 else if (msg.getData().getInt("Callback") == 107)
9130 {
9131 // level 0 announcement seconds
9132 String s = msg.getData().getString("s");
9133 NavitGraphics.CallbackMessageChannel(107, s);
9134 }
9135 else if (msg.getData().getInt("Callback") == 108)
9136 {
9137 // level 1 announcement seconds
9138 String s = msg.getData().getString("s");
9139 NavitGraphics.CallbackMessageChannel(108, s);
9140 }
9141 else if (msg.getData().getInt("Callback") == 109)
9142 {
9143 // level 2 announcement seconds
9144 String s = msg.getData().getString("s");
9145 NavitGraphics.CallbackMessageChannel(109, s);
9146 }
9147 else if (msg.getData().getInt("Callback") == 110)
9148 {
9149 // generic int option CallBack [<option name>:<option value "int">]
9150 String s = msg.getData().getString("s");
9151 NavitGraphics.CallbackMessageChannel(110, s);
9152 }
9153 else if (msg.getData().getInt("Callback") == 111)
9154 {
9155 // show real gps position on map
9156 String s = msg.getData().getString("s");
9157 NavitGraphics.CallbackMessageChannel(111, s);
9158 }
9159 else if (msg.getData().getInt("Callback") == 112)
9160 {
9161 // show maps debug view
9162 String s = msg.getData().getString("s");
9163 NavitGraphics.CallbackMessageChannel(112, s);
9164 }
9165 else if (msg.getData().getInt("Callback") == 113)
9166 {
9167 // cancel preview map drawing
9168 NavitGraphics.CallbackMessageChannel(113, "x");
9169 }
9170 else if (msg.getData().getInt("Callback") == 114)
9171 {
9172 // set night mode 0|1
9173 String s = msg.getData().getString("s");
9174 NavitGraphics.CallbackMessageChannel(114, s);
9175 }
9176 else if (msg.getData().getInt("Callback") == 115)
9177 {
9178 // set debug test number
9179 String s = msg.getData().getString("s");
9180 NavitGraphics.CallbackMessageChannel(115, s);
9181 }
9182 else if (msg.getData().getInt("Callback") == 9901)
9183 {
9184 // if follow mode is on, then dont show freeview streetname
9185 //if (!Navit.PREF_follow_gps)
9186 //{
9187 // Navit.cwthr.CallbackGeoCalc2(1, 0, mCanvasWidth / 2, mCanvasHeight / 2);
9188 //}
9189 }
9190 else if (msg.getData().getInt("Callback") == 98001)
9191 {
9192 int id = msg.getData().getInt("id");
9193 int i = msg.getData().getInt("i");
9194 NavitGraphics.return_generic_int_real(id, i);
9195 }
9196 else if (msg.getData().getInt("Callback") == 9001)
9197 {
9198 NavitGraphics.busyspinner_.setVisibility(View.INVISIBLE);
9199 NavitGraphics.busyspinnertext_.setVisibility(View.INVISIBLE);
9200 }
9201 else if (msg.getData().getInt("Callback") == 9002)
9202 {
9203 NavitGraphics.busyspinner_.setVisibility(View.VISIBLE);
9204 NavitGraphics.busyspinnertext_.setVisibility(View.VISIBLE);
9205 }
9206
9207 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
9208 }
9209 };
9210
9211 public Handler progress_handler = new Handler()
9212 {
9213 @SuppressLint("NewApi")
9214 public void handleMessage(Message msg)
9215 {
9216
9217 // System.out.println("progress_handler:msg:" + msg.what + "::" + msg.getData().toString());
9218
9219 switch (msg.what)
9220 {
9221 case 0:
9222 // dismiss dialog, remove dialog
9223 try
9224 {
9225 Log.e("Navit", "0: dismiss dialog num " + msg.getData().getInt("dialog_num"));
9226 }
9227 catch (Exception e)
9228 {
9229 e.printStackTrace();
9230 }
9231
9232 try
9233 {
9234 dismissDialog(msg.getData().getInt("dialog_num"));
9235 removeDialog(msg.getData().getInt("dialog_num"));
9236 }
9237 catch (Exception e)
9238 {
9239 }
9240
9241
9242 // exit_code=0 -> OK, map was downloaded fine
9243 if (msg.getData().getInt("exit_code") == 0)
9244 {
9245 // try to use the new downloaded map (works fine now!)
9246 //Log.d("Navit", "instance count=" + Navit.getInstanceCount()); // where did this go to?
9247
9248 // **** onStop();
9249 // **** onCreate(getIntent().getExtras());
9250
9251 String this_map_name = "map";
9252 try
9253 {
9254 this_map_name = msg.getData().getString("map_name");
9255 }
9256 catch (Exception e)
9257 {
9258 }
9259
9260 // reload sdcard maps
9261 Message msg2 = new Message();
9262 Bundle b2 = new Bundle();
9263 b2.putInt("Callback", 18);
9264 msg2.setData(b2);
9265 NavitGraphics.callback_handler.sendMessage(msg2);
9266
9267 // ----- service stop -----
9268 // ----- service stop -----
9269 Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
9270 // ----- service stop -----
9271 // ----- service stop -----
9272
9273 try
9274 {
9275 // show notification that map is ready
9276 String Notification_header = "ZANavi";
9277 String Notification_text = this_map_name + " ready";
9278
9279 NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
9280 Notification notification = new Notification(R.drawable.icon, "ZANavi download finished", System.currentTimeMillis());
9281 notification.flags = Notification.FLAG_AUTO_CANCEL;
9282 Intent in = new Intent();
9283 in.setClass(getBaseContext_, Navit.class);
9284 in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9285 PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9286 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9287
9288 try
9289 {
9290 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9291 }
9292 catch (Exception e)
9293 {
9294 e.printStackTrace();
9295
9296 try
9297 {
9298 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9299
9300 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9301 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9302 }
9303 catch (Exception e2)
9304 {
9305 e2.printStackTrace();
9306 }
9307 }
9308 }
9309 catch (Exception e)
9310 {
9311 e.printStackTrace();
9312 }
9313
9314 zoom_out_full();
9315
9316 /*
9317 * Intent intent = getIntent();
9318 * System.out.println("ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ**********************");
9319 * startActivity(intent);
9320 * System.out.println("FFFFFFFFFFFFFFFFFFF**********************");
9321 * Log.d("Navit", "instance count=" + Navit.getInstanceCount());
9322 * onStop();
9323 * System.out.println("HHHHHHHHHHHHHHHHHHH**********************");
9324 */
9325
9326 //Message msg2 = new Message();
9327 //Bundle b2 = new Bundle();
9328 //b2.putInt("Callback", 6);
9329 //msg2.setData(b2);
9330 //N_NavitGraphics.callback_handler.sendMessage(msg2);
9331 }
9332 else
9333 {
9334 // there was a problem downloading the map
9335 // ----- service stop -----
9336 // ----- service stop -----
9337 Navit.getBaseContext_.stopService(Navit.ZANaviMapDownloaderServiceIntent);
9338 // ----- service stop -----
9339 // ----- service stop -----
9340
9341 String this_map_name = "map";
9342 try
9343 {
9344 this_map_name = msg.getData().getString("map_name");
9345 }
9346 catch (Exception e)
9347 {
9348 }
9349
9350 try
9351 {
9352
9353 // show notification that there was a download problem
9354 String Notification_header = "ZANavi";
9355 String Notification_text = "ERROR while downloading " + this_map_name;
9356
9357 NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
9358 Notification notification = new Notification(R.drawable.icon, "ZANavi download ERROR", System.currentTimeMillis());
9359 notification.flags = Notification.FLAG_AUTO_CANCEL;
9360 Intent in = new Intent();
9361 in.setClass(getBaseContext_, Navit.class);
9362 in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9363 PendingIntent p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9364 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9365
9366 try
9367 {
9368 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9369 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9370 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9371 // {
9372 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9373 // }
9374
9375 }
9376 catch (Exception e)
9377 {
9378 e.printStackTrace();
9379
9380 try
9381 {
9382 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
9383
9384 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
9385 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9386 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9387 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9388 // {
9389 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9390 // }
9391 }
9392 catch (Exception e2)
9393 {
9394 e2.printStackTrace();
9395 }
9396 }
9397 }
9398 catch (Exception e)
9399 {
9400 e.printStackTrace();
9401 }
9402 }
9403 break;
9404 case 1:
9405 // change progressbar values
9406 try
9407 {
9408 int what_dialog = msg.getData().getInt("dialog_num");
9409 if (what_dialog == MAPDOWNLOAD_PRI_DIALOG)
9410 {
9411 mapdownloader_dialog_pri.setMax(msg.getData().getInt("max"));
9412 mapdownloader_dialog_pri.setProgress(msg.getData().getInt("cur"));
9413 mapdownloader_dialog_pri.setTitle(msg.getData().getString("title"));
9414 mapdownloader_dialog_pri.setMessage(msg.getData().getString("text"));
9415 }
9416 else if (what_dialog == MAPDOWNLOAD_SEC_DIALOG)
9417 {
9418 mapdownloader_dialog_sec.setMax(msg.getData().getInt("max"));
9419 mapdownloader_dialog_sec.setProgress(msg.getData().getInt("cur"));
9420 mapdownloader_dialog_sec.setTitle(msg.getData().getString("title"));
9421 mapdownloader_dialog_sec.setMessage(msg.getData().getString("text"));
9422 }
9423 }
9424 catch (Exception e)
9425 {
9426 }
9427 break;
9428 case 2:
9429 Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
9430 break;
9431 case 3:
9432 Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_LONG).show();
9433 break;
9434 case 10:
9435 // change values - generic
9436 try
9437 {
9438 int what_dialog_generic = msg.getData().getInt("dialog_num");
9439 if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG)
9440 {
9441 search_results_wait.setMax(msg.getData().getInt("max"));
9442 search_results_wait.setProgress(msg.getData().getInt("cur"));
9443 search_results_wait.setTitle(msg.getData().getString("title"));
9444 search_results_wait.setMessage(msg.getData().getString("text"));
9445 }
9446 else if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
9447 {
9448 search_results_wait_offline.setMax(msg.getData().getInt("max"));
9449 search_results_wait_offline.setProgress(msg.getData().getInt("cur"));
9450 search_results_wait_offline.setTitle(msg.getData().getString("title"));
9451 search_results_wait_offline.setMessage(msg.getData().getString("text"));
9452 }
9453 }
9454 catch (Exception e)
9455 {
9456 }
9457 break;
9458 case 11:
9459 // show dialog - generic
9460 try
9461 {
9462 // just in case, remove the dialog if it should be shown already!
9463 dismissDialog(msg.getData().getInt("dialog_num"));
9464 removeDialog(msg.getData().getInt("dialog_num"));
9465 }
9466 catch (Exception e)
9467 {
9468 // System.out.println("Ex D1: " + e.toString());
9469 }
9470 System.out.println("showDialog 001 dialog_num=" + msg.getData().getInt("dialog_num"));
9471 showDialog(msg.getData().getInt("dialog_num"));
9472 break;
9473 case 12:
9474 // turn on compass
9475 turn_on_compass();
9476 break;
9477 case 13:
9478 // turn off compass
9479 turn_off_compass();
9480 break;
9481 case 14:
9482 // set used mem in textview
9483 show_mem_used_real();
9484 break;
9485 case 15:
9486 // set debug text line 3
9487 Navit.set_debug_messages3(msg.getData().getString("text"));
9488 break;
9489 case 16:
9490 // refresh NavitAndriodOverlay
9491 try
9492 {
9493 //Log.e("NavitGraphics", "xx 1");
9494 //System.out.println("invalidate 027");
9495 NavitGraphics.NavitAOverlay_s.invalidate();
9496 //Log.e("NavitGraphics", "xx 2");
9497 }
9498 catch (Exception e)
9499 {
9500 e.printStackTrace();
9501 }
9502 break;
9503 case 17:
9504 try
9505 {
9506
9507 generic_alert_box.setMessage(Navit.get_text("Possibly not enough space on your device!")).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener() // TRANS
9508 {
9509 public void onClick(DialogInterface dialog, int id)
9510 {
9511 // Handle Ok
9512 }
9513 }).create();
9514 generic_alert_box.setCancelable(false);
9515 generic_alert_box.setTitle(Navit.get_text("device space")); // TRANS
9516 generic_alert_box.show();
9517 }
9518 catch (Exception e)
9519 {
9520 e.printStackTrace();
9521 }
9522 break;
9523 // case 18:
9524 // try
9525 // {
9526 // openOptionsMenu_wrapper();
9527 // }
9528 // catch (Exception e)
9529 // {
9530 // }
9531 // break;
9532 case 19:
9533 open_voice_recog_screen();
9534 break;
9535 case 20:
9536 dim_screen();
9537 break;
9538 case 21:
9539 default_brightness_screen();
9540 break;
9541 case 22:
9542 try
9543 {
9544 // ----- service start -----
9545 // ----- service start -----
9546 startService(Navit.ZANaviMapDownloaderServiceIntent);
9547 // ----- service start -----
9548 // ----- service start -----
9549
9550 // try
9551 // {
9552 // Thread.sleep(200);
9553 // }
9554 // catch (InterruptedException e)
9555 // {
9556 // }
9557
9558 // if (!ZANaviMapDownloaderService.service_running)
9559 // {
9560 // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
9561 // try
9562 // {
9563 // Thread.sleep(2000);
9564 // }
9565 // catch (InterruptedException e)
9566 // {
9567 // }
9568 // }
9569 //
9570 // if (!ZANaviMapDownloaderService.service_running)
9571 // {
9572 // System.out.println("ZANaviMapDownloaderService -> not running yet ...");
9573 // try
9574 // {
9575 // Thread.sleep(2000);
9576 // }
9577 // catch (InterruptedException e)
9578 // {
9579 // }
9580 // }
9581
9582 // -------- // ZANaviMapDownloaderService.start_map_download();
9583 }
9584 catch (Exception e)
9585 {
9586 e.printStackTrace();
9587 }
9588 break;
9589 case 23:
9590
9591 // show actionbar download icon
9592 try
9593 {
9594 // show download actionbar icon
9595 //cur_menu.findItem(R.id.item_download_menu_button).setTitle("");
9596 actionabar_download_icon_visible = true;
9597 cur_menu.findItem(R.id.item_download_menu_button).setVisible(true);
9598 //cur_menu.findItem(R.id.item_download_menu_button).setEnabled(true);
9599 // ****** // cur_menu.findItem(R.id.item_download_menu_button).setIcon(R.drawable.anim_download_icon);
9600 // cur_menu.findItem(R.id.item_download_menu_button).setIcon((Drawable) null);
9601 }
9602 catch (Exception e)
9603 {
9604 e.printStackTrace();
9605 }
9606
9607 try
9608 {
9609 show_status_bar();
9610 getSupportActionBar().setDisplayShowTitleEnabled(true);
9611 }
9612 catch (Exception e)
9613 {
9614 e.printStackTrace();
9615 }
9616
9617 // try
9618 // {
9619 // View menuItemView = findViewById(R.id.item_download_menu_button);
9620 // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_2);
9621 // // menuItemView.setOnClickListener(new View.OnClickListener()
9622 // // {
9623 // // public void onClick(View v)
9624 // // {
9625 // // try
9626 // // {
9627 // // //menuItemView.setBackgroundResource(R.drawable.anim_download_icon_1);
9628 // // //AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9629 // // //frameAnimation.start();
9630 // // // menuItemView.setAlpha(100);
9631 // // View menuItemView = findViewById(R.id.item_download_menu_button);
9632 // // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_1);
9633 // //
9634 // // System.out.println("download icon pressed(2)");
9635 // //
9636 // // Intent mapdownload_cancel_activity = new Intent(Navit.getBaseContext_, ZANaviDownloadMapCancelActivity.class);
9637 // // mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
9638 // // startActivity(mapdownload_cancel_activity);
9639 // //
9640 // // new Handler().postDelayed(new Runnable()
9641 // // {
9642 // // @Override
9643 // // public void run()
9644 // // {
9645 // // if (Navit.cur_menu.findItem(R.id.item_download_menu_button).isVisible())
9646 // // {
9647 // // View menuItemView = findViewById(R.id.item_download_menu_button);
9648 // // menuItemView.setBackgroundResource(R.drawable.anim_download_icon_2);
9649 // // AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9650 // // frameAnimation.start();
9651 // // }
9652 // // }
9653 // // }, 50);
9654 // // }
9655 // // catch (Exception e)
9656 // // {
9657 // // }
9658 // // }
9659 // // });
9660 // AnimationDrawable frameAnimation = (AnimationDrawable) menuItemView.getBackground();
9661 // frameAnimation.start();
9662 // }
9663 // catch (Exception e)
9664 // {
9665 // e.printStackTrace();
9666 // }
9667
9668 break;
9669 case 24:
9670 // hide actionbar download icon
9671
9672 // try
9673 // {
9674 // View menuItemView = findViewById(R.id.item_download_menu_button);
9675 // menuItemView.setBackground((Drawable) null);
9676 //
9677 // new Handler().postDelayed(new Runnable()
9678 // {
9679 // @Override
9680 // public void run()
9681 // {
9682 // if (Navit.cur_menu.findItem(R.id.item_download_menu_button).isVisible())
9683 // {
9684 // View menuItemView = findViewById(R.id.item_download_menu_button);
9685 // menuItemView.setBackground((Drawable) null);
9686 // }
9687 // }
9688 // }, 50);
9689 // }
9690 // catch (Exception e)
9691 // {
9692 // e.printStackTrace();
9693 // }
9694
9695 try
9696 {
9697 // hide download actionbar icon
9698 actionabar_download_icon_visible = false;
9699 cur_menu.findItem(R.id.item_download_menu_button).setVisible(false);
9700 //cur_menu.findItem(R.id.item_download_menu_button).setEnabled(false);
9701 // cur_menu.findItem(R.id.item_download_menu_button).setIcon((Drawable) null);
9702 }
9703 catch (Exception e)
9704 {
9705 e.printStackTrace();
9706 }
9707
9708 try
9709 {
9710 getSupportActionBar().setDisplayShowTitleEnabled(false);
9711 }
9712 catch (Exception e)
9713 {
9714 e.printStackTrace();
9715 }
9716
9717 try
9718 {
9719 hide_status_bar();
9720 }
9721 catch (Exception e)
9722 {
9723 e.printStackTrace();
9724 }
9725
9726 break;
9727 case 25:
9728 // Log.e("Navit", "nav: 25");
9729 NavitGraphics.deactivate_nav_wakelock_real();
9730 break;
9731 case 26:
9732 // Log.e("Navit", "nav: 26");
9733 NavitGraphics.activate_nav_wakelock_real();
9734 break;
9735 case 27:
9736 show_status_bar();
9737 break;
9738 case 28:
9739 hide_status_bar();
9740 break;
9741 case 29:
9742 invalidateOptionsMenu();
9743 break;
9744 case 30:
9745 try
9746 {
9747 NavitGraphics.NavitMsgTv2_.append(msg.getData().getString("text"));
9748 }
9749 catch (Exception e)
9750 {
9751 e.printStackTrace();
9752 }
9753 break;
9754 case 31:
9755 try
9756 {
9757 // map download menu
9758 Intent map_download_list_activity = new Intent(getBaseContext_, NavitDownloadSelectMapActivity.class);
9759 startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
9760 }
9761 catch (Exception e)
9762 {
9763 e.printStackTrace();
9764 }
9765 break;
9766 case 32:
9767 try
9768 {
9769 if (p.PREF_follow_gps)
9770 {
9771 push_pin_view.setImageResource(R.drawable.pin1_down);
9772 }
9773 else
9774 {
9775 push_pin_view.setImageResource(R.drawable.pin1_up);
9776 }
9777 }
9778 catch (Exception e)
9779 {
9780 e.printStackTrace();
9781 }
9782 break;
9783 case 33:
9784 if (road_book != null)
9785 {
9786 if (road_book_items != null)
9787 {
9788 try
9789 {
9790 // send new roadbook items to fragment and reload it
9791 road_book.reload_items(road_book_items);
9792 }
9793 catch (Exception e)
9794 {
9795 }
9796 }
9797 }
9798 break;
9799 case 34:
9800 // show bubble
9801 NavitGraphics.whats_here_container_wrap.setVisibility(View.VISIBLE);
9802 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9803 break;
9804 case 35:
9805 // hide bubble
9806 NavitGraphics.whats_here_container_wrap.setVisibility(View.INVISIBLE);
9807 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9808 // and move out of screen
9809
9810 if (!Navit.PAINT_OLD_API)
9811 {
9812 NavitGraphics.whats_here_container_wrap.setX(-2000);
9813 NavitGraphics.whats_here_container_wrap.setY(-2000);
9814 // NavitGraphics.whats_here_container_wrap.requestLayout();
9815
9816 NavitGraphics.whats_here_pointer_image.setX(0);
9817 }
9818 else
9819 {
9820 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9821 NavitGraphics.params_whats_here_container_wrap.leftMargin = -2000;
9822 NavitGraphics.params_whats_here_container_wrap.topMargin = -2000;
9823 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9824 NavitGraphics.whats_here_container_wrap.requestLayout();
9825
9826 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9827 // NavitGraphics.params_whats_here_pointer_image.leftMargin = 0;
9828 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9829 NavitGraphics.whats_here_pointer_image.requestLayout();
9830
9831 }
9832 break;
9833 case 36:
9834 // move bubble to x,y
9835 int width_in_px = getResources().getDimensionPixelSize(R.dimen.whats_here_container_width);
9836 int new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x;
9837 int new_diff = 0;
9838 if ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) > NavitGraphics.mCanvasWidth)
9839 {
9840 new_diff = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9841 new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x - ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth);
9842 }
9843
9844 new_x = new_x - NavitGraphics.dp_to_px(17);
9845
9846 if (!Navit.PAINT_OLD_API)
9847 {
9848 NavitGraphics.whats_here_container_wrap.setX(new_x);
9849 NavitGraphics.whats_here_container_wrap.setY(NavitGraphics.NavitAOverlay_s.bubble_001.y + NavitGraphics.dp_to_px(17));
9850 // NavitGraphics.whats_here_container_wrap.requestLayout();
9851
9852 NavitGraphics.whats_here_pointer_image.setX(new_diff);
9853 }
9854 else
9855 {
9856 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9857 NavitGraphics.params_whats_here_container_wrap.leftMargin = new_x;
9858 NavitGraphics.params_whats_here_container_wrap.topMargin = NavitGraphics.NavitAOverlay_s.bubble_001.y - NavitGraphics.whats_here_container_wrap.getHeight() + NavitGraphics.dp_to_px(17);
9859 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9860 NavitGraphics.whats_here_container_wrap.requestLayout();
9861
9862 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9863 // has some bugs // NavitGraphics.params_whats_here_pointer_image.leftMargin = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9864 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9865 NavitGraphics.whats_here_pointer_image.requestLayout();
9866 NavitGraphics.whats_here_pointer_image.setVisibility(View.INVISIBLE);
9867 }
9868 break;
9869 case 37:
9870 // set text for point on screen
9871 String dest_name = "Point on Screen";
9872
9873 try
9874 {
9875 if (Navit.GFX_OVERSPILL)
9876 {
9877 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);
9878 }
9879 else
9880 {
9881 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);
9882 }
9883
9884 if ((dest_name.equals(" ")) || (dest_name == null))
9885 {
9886 dest_name = "Point on Screen";
9887 }
9888 }
9889 catch (Exception e)
9890 {
9891 e.printStackTrace();
9892 }
9893
9894 NavitGraphics.whats_here_text.setText(dest_name);
9895 break;
9896 case 38:
9897 try
9898 {
9899 NavitAddressSearchActivity.adapter.clear();
9900 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9901 // NavitAddressSearchActivity.listview.postInvalidate();
9902 }
9903 catch (Exception e)
9904 {
9905 System.out.println("AAEE:001");
9906 }
9907 break;
9908 case 39:
9909 try
9910 {
9911 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9912 }
9913 catch (Exception e)
9914 {
9915 System.out.println("AAEE:008");
9916 }
9917 break;
9918 case 99:
9919 // dismiss dialog, remove dialog - generic
9920 try
9921 {
9922 Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
9923 }
9924 catch (Exception e)
9925 {
9926 e.printStackTrace();
9927 }
9928 try
9929 {
9930 dismissDialog(msg.getData().getInt("dialog_num"));
9931 }
9932 catch (Exception e)
9933 {
9934 e.printStackTrace();
9935 }
9936 try
9937 {
9938 removeDialog(msg.getData().getInt("dialog_num"));
9939 }
9940 catch (Exception e)
9941 {
9942 e.printStackTrace();
9943 }
9944 break;
9945 }
9946 }
9947 };
9948
9949 @TargetApi(Build.VERSION_CODES.FROYO)
9950 protected Dialog onCreateDialog(int id)
9951 {
9952
9953 System.out.println("onCreateDialog id=" + id);
9954
9955 switch (id)
9956 {
9957 // ==============---------- real search offline (old style) here ----------==============
9958 // ==============---------- real search offline (old style) here ----------==============
9959 // ==============---------- real search offline (old style) here ----------==============
9960 case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
9961 search_results_wait_offline = new ProgressDialog(this);
9962 search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
9963 search_results_wait_offline.setTitle("--");
9964 search_results_wait_offline.setMessage("--");
9965 search_results_wait_offline.setCancelable(true); // allow to stop search
9966 search_results_wait_offline.setProgress(0);
9967 search_results_wait_offline.setMax(10);
9968
9969 search_results_wait_offline.setOnCancelListener(new OnCancelListener()
9970 {
9971 public void onCancel(DialogInterface dialog)
9972 {
9973 Message msg = new Message();
9974 Bundle b = new Bundle();
9975 b.putInt("Callback", 46);
9976 msg.setData(b);
9977 try
9978 {
9979 NavitGraphics.callback_handler.sendMessage(msg);
9980 }
9981 catch (Exception e)
9982 {
9983 }
9984 Log.e("Navit", "onCancel: search_results_wait offline");
9985 }
9986 });
9987
9988 /*
9989 * search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
9990 * {
9991 * public void onClick(DialogInterface dialog, int which)
9992 * {
9993 * // Use either finish() or return() to either close the activity or just the dialog
9994 * return;
9995 * }
9996 * });
9997 */
9998
9999 DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener()
10000 {
10001 public void onDismiss(DialogInterface dialog)
10002 {
10003 Log.e("Navit", "onDismiss: search_results_wait offline");
10004 dialog.dismiss();
10005 dialog.cancel();
10006 searchresultsThread_offline.stop_me();
10007 }
10008 };
10009 search_results_wait_offline.setOnDismissListener(mOnDismissListener4);
10010 System.out.println("new SearchResultsThread 001");
10011 searchresultsThread_offline = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
10012 searchresultsThread_offline.start();
10013
10014 NavitAddressSearchSpinnerActive = true;
10015 spinner_thread_offline = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
10016 spinner_thread_offline.start();
10017
10018 return search_results_wait_offline;
10019 case Navit.SEARCHRESULTS_WAIT_DIALOG:
10020 search_results_wait = new ProgressDialog(this);
10021 search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
10022 search_results_wait.setTitle("--");
10023 search_results_wait.setMessage("--");
10024 search_results_wait.setCancelable(false);
10025 search_results_wait.setProgress(0);
10026 search_results_wait.setMax(10);
10027
10028 DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener()
10029 {
10030 public void onDismiss(DialogInterface dialog)
10031 {
10032 Log.e("Navit", "onDismiss: search_results_wait");
10033 dialog.dismiss();
10034 dialog.cancel();
10035 searchresultsThread.stop_me();
10036 }
10037 };
10038 search_results_wait.setOnDismissListener(mOnDismissListener3);
10039 System.out.println("new SearchResultsThread 002");
10040 searchresultsThread = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
10041 searchresultsThread.start();
10042
10043 NavitAddressSearchSpinnerActive = true;
10044 spinner_thread = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
10045 spinner_thread.start();
10046
10047 return search_results_wait;
10048 case Navit.MAPDOWNLOAD_PRI_DIALOG:
10049 mapdownloader_dialog_pri = new ProgressDialog(this);
10050 mapdownloader_dialog_pri.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
10051 mapdownloader_dialog_pri.setTitle("--");
10052 mapdownloader_dialog_pri.setMessage("--");
10053 mapdownloader_dialog_pri.setCancelable(false);
10054 mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
10055 mapdownloader_dialog_pri.setProgress(0);
10056 mapdownloader_dialog_pri.setMax(200);
10057
10058 WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
10059 dialog_lparams.screenBrightness = 0.1f;
10060 mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);
10061
10062 DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener()
10063 {
10064 public void onDismiss(DialogInterface dialog)
10065 {
10066 android.view.WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
10067 mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
10068 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
10069 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
10070 Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
10071 dialog.dismiss();
10072 dialog.cancel();
10073 progressThread_pri.stop_thread();
10074 }
10075 };
10076
10077 try
10078 {
10079 mapdownloader_dialog_pri.setButton(AlertDialog.BUTTON_NEGATIVE, Navit.get_text("Cancel"), new DialogInterface.OnClickListener()
10080 {
10081 @Override
10082 public void onClick(DialogInterface dialog, int which)
10083 {
10084 mapdownloader_dialog_pri.dismiss();
10085 }
10086 });
10087 }
10088 catch (Exception e)
10089 {
10090 e.printStackTrace();
10091 }
10092
10093 mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
10094 mapdownloader_pri = new NavitMapDownloader(this);
10095 progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
10096 progressThread_pri.start();
10097 //
10098 // show license for OSM maps
10099 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
10100 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
10101 return mapdownloader_dialog_pri;
10102 case Navit.MAPDOWNLOAD_SEC_DIALOG:
10103 mapdownloader_dialog_sec = new ProgressDialog(this);
10104 mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
10105 mapdownloader_dialog_sec.setTitle("--");
10106 mapdownloader_dialog_sec.setMessage("--");
10107
10108 mapdownloader_dialog_sec.setCancelable(true);
10109 mapdownloader_dialog_sec.setProgress(0);
10110 mapdownloader_dialog_sec.setMax(200);
10111 DialogInterface.OnDismissListener mOnDismissListener2 = new DialogInterface.OnDismissListener()
10112 {
10113 public void onDismiss(DialogInterface dialog)
10114 {
10115 Log.e("Navit", "onDismiss: mapdownloader_dialog sec");
10116 dialog.dismiss();
10117 dialog.cancel();
10118 progressThread_sec.stop_thread();
10119 }
10120 };
10121 mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
10122 mapdownloader_sec = new NavitMapDownloader(this);
10123 progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
10124 progressThread_sec.start();
10125 //
10126 // show license for OSM maps
10127 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
10128 Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_SHORT).show(); //TRANS
10129 return mapdownloader_dialog_sec;
10130 }
10131 // should never get here!!
10132 return null;
10133 }
10134
10135 public void disableSuspend()
10136 {
10137 // wl.acquire();
10138 // wl.release();
10139 }
10140
10141 public void exit2()
10142 {
10143 System.out.println("in exit2");
10144 }
10145
10146 public void exit()
10147 {
10148 try
10149 {
10150 if (toneG != null)
10151 {
10152 toneG.stopTone();
10153 toneG.release();
10154
10155 }
10156 }
10157 catch (Exception e)
10158 {
10159 }
10160
10161 NavitVehicle.turn_off_all_providers();
10162 //try
10163 //{
10164 // NavitSpeech.stop_me();
10165 //}
10166 //catch (Exception s)
10167 //{
10168 // s.printStackTrace();
10169 //}
10170
10171 try
10172 {
10173 if (p.PREF_enable_debug_write_gpx)
10174 {
10175 NavitVehicle.pos_recording_end();
10176 }
10177 }
10178 catch (Exception e)
10179 {
10180 }
10181
10182 try
10183 {
10184 mTts.stop();
10185 }
10186 catch (Exception e)
10187 {
10188
10189 }
10190
10191 try
10192 {
10193 mTts.shutdown();
10194 }
10195 catch (Exception e)
10196 {
10197
10198 }
10199 mTts = null;
10200
10201 try
10202 {
10203 try
10204 {
10205 plugin_api.removeListener(zclientListener);
10206 }
10207 catch (Exception e)
10208 {
10209 e.printStackTrace();
10210 Log.i("NavitPlugin", "Failed to remove Listener", e);
10211 }
10212 unbindService(serviceConnection);
10213 Log.i("NavitPlugin", "Unbind from the service");
10214 }
10215 catch (Throwable t)
10216 {
10217 // catch any issues, typical for destroy routines
10218 // even if we failed to destroy something, we need to continue destroying
10219 Log.i("NavitPlugin", "Failed to unbind from the service", t);
10220 }
10221
10222 try
10223 {
10224 if (wl_navigating != null)
10225 {
10226 //if (wl_navigating.isHeld())
10227 //{
10228 wl_navigating.release();
10229 Log.e("Navit", "WakeLock Nav: release 1");
10230 //}
10231 }
10232 }
10233 catch (Exception e)
10234 {
10235 e.printStackTrace();
10236 }
10237
10238 Log.e("Navit", "1***************** exit called ****************");
10239 Log.e("Navit", "2***************** exit called ****************");
10240 Log.e("Navit", "3***************** exit called ****************");
10241 Log.e("Navit", "4***************** exit called ****************");
10242 Log.e("Navit", "5***************** exit called ****************");
10243 Log.e("Navit", "6***************** exit called ****************");
10244 Log.e("Navit", "7***************** exit called ****************");
10245 Log.e("Navit", "8***************** exit called ****************");
10246
10247 // try
10248 // {
10249 // // hide download actionbar icon
10250 // Navit.cur_menu.findItem(R.id.item_download_menu_button).setVisible(false);
10251 // Navit.cur_menu.findItem(R.id.item_download_menu_button).setEnabled(false);
10252 // }
10253 // catch (Exception e)
10254 // {
10255 // }
10256
10257 // ----- service stop -----
10258 // ----- service stop -----
10259 System.out.println("Navit:exit -> stop ZANaviMapDownloaderService ---------");
10260 ZANaviMapDownloaderService.stop_downloading();
10261 stopService(Navit.ZANaviMapDownloaderServiceIntent);
10262 // ----- service stop -----
10263 // ----- service stop -----
10264
10265 // +++++ // System.gc();
10266 NavitActivity(-4);
10267 Log.e("Navit", "XX1***************** exit called ****************");
10268 finish();
10269 Log.e("Navit", "XX2***************** exit called ****************");
10270 System.runFinalizersOnExit(true);
10271 Log.e("Navit", "XX3***************** exit called ****************");
10272 System.exit(0);
10273 Log.e("Navit", "XX4***************** exit called ****************");
10274 }
10275
10276 public boolean handleMessage(Message m)
10277 {
10278 //Log.e("Navit", "Handler received message");
10279 return true;
10280 }
10281
10282 public static void set_2d3d_mode_in_settings()
10283 {
10284 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10285 SharedPreferences.Editor editor = prefs.edit();
10286 editor.putBoolean("show_3d_map", p.PREF_show_3d_map);
10287 editor.commit();
10288 }
10289
10290 public static void follow_button_on()
10291 {
10292 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10293 SharedPreferences.Editor editor = prefs.edit();
10294 Navit.follow_current = Navit.follow_on;
10295 p.PREF_follow_gps = true;
10296 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10297 editor.commit();
10298
10299 // hold all map drawing -----------
10300 Message msg = new Message();
10301 Bundle b = new Bundle();
10302 b.putInt("Callback", 69);
10303 msg.setData(b);
10304 try
10305 {
10306 NavitGraphics.callback_handler.sendMessage(msg);
10307 }
10308 catch (Exception e)
10309 {
10310 e.printStackTrace();
10311 }
10312 // hold all map drawing -----------
10313
10314 msg = Navit_progress_h.obtainMessage();
10315 b = new Bundle();
10316 msg.what = 32;
10317 try
10318 {
10319 Navit_progress_h.sendMessage(msg);
10320 }
10321 catch (Exception e)
10322 {
10323 }
10324
10325 getPrefs();
10326 activatePrefs(1);
10327
10328 // follow mode ON -----------
10329 msg = new Message();
10330 b = new Bundle();
10331 b.putInt("Callback", 74);
10332 msg.setData(b);
10333 try
10334 {
10335 NavitGraphics.callback_handler.sendMessage(msg);
10336 }
10337 catch (Exception e)
10338 {
10339 e.printStackTrace();
10340 }
10341 // follow mode ON -----------
10342
10343 // allow all map drawing -----------
10344 msg = new Message();
10345 b = new Bundle();
10346 b.putInt("Callback", 70);
10347 msg.setData(b);
10348 try
10349 {
10350 NavitGraphics.callback_handler.sendMessage(msg);
10351 }
10352 catch (Exception e)
10353 {
10354 }
10355 // allow all map drawing -----------
10356
10357 NavitVehicle.set_last_known_pos_fast_provider();
10358
10359 // JB fix
10360 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10361 //System.out.println("xx paint 12 xx");
10362 NavitGraphics.OSD_new.postInvalidate();
10363 NavitGraphics.NavitAOverlay_s.postInvalidate();
10364 }
10365
10366 public static void follow_button_off()
10367 {
10368 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10369 SharedPreferences.Editor editor = prefs.edit();
10370 Navit.follow_current = Navit.follow_off;
10371 p.PREF_follow_gps = false;
10372 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10373 editor.commit();
10374 getPrefs();
10375 activatePrefs(1);
10376
10377 // follow mode OFF -----------
10378 Message msg = new Message();
10379 Bundle b = new Bundle();
10380 b.putInt("Callback", 75);
10381 msg.setData(b);
10382 try
10383 {
10384 NavitGraphics.callback_handler.sendMessage(msg);
10385 }
10386 catch (Exception e)
10387 {
10388 }
10389 // follow mode OFF -----------
10390
10391 msg = Navit_progress_h.obtainMessage();
10392 b = new Bundle();
10393 msg.what = 32;
10394 try
10395 {
10396 Navit_progress_h.sendMessage(msg);
10397 }
10398 catch (Exception e)
10399 {
10400 }
10401
10402 // JB fix
10403 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10404 //System.out.println("xx paint 13 xx");
10405 NavitGraphics.OSD_new.postInvalidate();
10406 NavitGraphics.NavitAOverlay_s.postInvalidate();
10407
10408 }
10409
10410 public static void toggle_poi_pref()
10411 {
10412 // PREF_show_poi_on_map
10413 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10414 SharedPreferences.Editor editor = prefs.edit();
10415 if (p.PREF_show_poi_on_map)
10416 {
10417 p.PREF_show_poi_on_map = false;
10418 }
10419 else
10420 {
10421 p.PREF_show_poi_on_map = true;
10422 }
10423 editor.putBoolean("show_poi_on_map", p.PREF_show_poi_on_map);
10424 editor.commit();
10425 }
10426
10427 public static void toggle_follow_button()
10428 {
10429 // the "red needle" OSD calls this function only!!
10430 //Log.e("NavitVehicle", "toggle_follow_button");
10431 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10432 SharedPreferences.Editor editor = prefs.edit();
10433 if (p.PREF_follow_gps)
10434 {
10435 Navit.follow_current = Navit.follow_off;
10436 p.PREF_follow_gps = false;
10437
10438 // follow mode OFF -----------
10439 Message msg = new Message();
10440 Bundle b = new Bundle();
10441 b.putInt("Callback", 75);
10442 msg.setData(b);
10443 try
10444 {
10445 NavitGraphics.callback_handler.sendMessage(msg);
10446 }
10447
10448 catch (Exception e)
10449 {
10450 e.printStackTrace();
10451 }
10452 // follow mode OFF -----------
10453 }
10454 else
10455 {
10456 Navit.follow_current = Navit.follow_on;
10457 p.PREF_follow_gps = true;
10458
10459 // follow mode ON -----------
10460 Message msg = new Message();
10461 Bundle b = new Bundle();
10462 b.putInt("Callback", 74);
10463 msg.setData(b);
10464 try
10465 {
10466 NavitGraphics.callback_handler.sendMessage(msg);
10467 }
10468 catch (Exception e)
10469 {
10470 e.printStackTrace();
10471 }
10472 // follow mode ON -----------
10473 }
10474 editor.putBoolean("follow_gps", p.PREF_follow_gps);
10475 editor.commit();
10476 //if (!PREF_follow_gps)
10477 //{
10478 // // no compass turning without follow mode!
10479 // PREF_use_compass_heading_base = false;
10480 //}
10481 //if (!PREF_use_compass_heading_base)
10482 //{
10483 // // child is always "false" when parent is "false" !!
10484 // PREF_use_compass_heading_always = false;
10485 //}
10486
10487 Message msg = Navit_progress_h.obtainMessage();
10488 Bundle b = new Bundle();
10489 msg.what = 32;
10490 try
10491 {
10492 Navit_progress_h.sendMessage(msg);
10493 }
10494 catch (Exception e)
10495 {
10496 }
10497
10498 // hold all map drawing -----------
10499 msg = new Message();
10500 b = new Bundle();
10501 b.putInt("Callback", 69);
10502 msg.setData(b);
10503 try
10504 {
10505 NavitGraphics.callback_handler.sendMessage(msg);
10506 }
10507 catch (Exception e)
10508 {
10509 e.printStackTrace();
10510 }
10511 // hold all map drawing -----------
10512
10513 getPrefs();
10514 activatePrefs(1);
10515
10516 // allow all map drawing -----------
10517 msg = new Message();
10518 b = new Bundle();
10519 b.putInt("Callback", 70);
10520 msg.setData(b);
10521 try
10522 {
10523 NavitGraphics.callback_handler.sendMessage(msg);
10524 }
10525 catch (Exception e)
10526 {
10527 }
10528 // allow all map drawing -----------
10529
10530 NavitVehicle.set_last_known_pos_fast_provider();
10531
10532 // JB fix
10533 //NavitGraphics.NavitAOSDJava_.postInvalidate();
10534 //System.out.println("xx paint 14 xx");
10535 NavitGraphics.OSD_new.postInvalidate();
10536 NavitGraphics.NavitAOverlay_s.postInvalidate();
10537 }
10538
10539 public static void setPrefs_search_country()
10540 {
10541 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10542
10543 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10544 SharedPreferences.Editor editor = prefs.edit();
10545 editor.putInt("search_country_id", p.PREF_search_country);
10546 editor.commit();
10547
10548 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10549 }
10550
10551 public static void setPrefs_zoomlevel()
10552 {
10553 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10554
10555 System.out.println("1 save zoom level: " + Navit.GlobalScaleLevel);
10556 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10557 SharedPreferences.Editor editor = prefs.edit();
10558 editor.putInt("zoomlevel_num", Navit.GlobalScaleLevel);
10559 editor.commit();
10560 //System.out.println("2 save zoom level: " + Navit.GlobalScaleLevel);
10561
10562 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10563 }
10564
10565 public static void setPrefs_selected_gpx_dir()
10566 {
10567 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10568
10569 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10570 SharedPreferences.Editor editor = prefs.edit();
10571 editor.putString("last_selected_dir_gpxfiles", p.PREF_last_selected_dir_gpxfiles);
10572 editor.commit();
10573
10574 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10575 }
10576
10577 private static void getPrefs_more_map_detail()
10578 {
10579 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10580
10581 // int ret = 0;
10582 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10583 try
10584 {
10585 p.PREF_more_map_detail = Integer.parseInt(prefs.getString("more_map_detail", "0"));
10586 }
10587 catch (Exception e)
10588 {
10589 p.PREF_more_map_detail = 0;
10590 }
10591
10592 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10593 }
10594
10595 private static void get_prefs_highdpi()
10596 {
10597 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10598
10599 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10600 try
10601 {
10602 p.PREF_shrink_on_high_dpi = prefs.getBoolean("shrink_on_high_dpi", true);
10603 }
10604 catch (Exception e)
10605 {
10606 p.PREF_shrink_on_high_dpi = true;
10607 }
10608
10609 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10610 }
10611
10612 public static boolean saveArray(String[] array, String arrayName, int size)
10613 {
10614 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10615 SharedPreferences.Editor editor = prefs.edit();
10616 editor.putInt(arrayName + "_size", size);
10617 for (int i = 0; i < array.length; i++)
10618 {
10619 if (array[i] == null)
10620 {
10621 editor.putString(arrayName + "_" + i, "");
10622 }
10623 else
10624 {
10625 editor.putString(arrayName + "_" + i, array[i]);
10626 }
10627 }
10628 return editor.commit();
10629 }
10630
10631 public static String[] loadArray(String arrayName, int size)
10632 {
10633 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10634 String[] array = new String[size];
10635 for (int i = 0; i < size; i++)
10636 {
10637 try
10638
10639 {
10640 array[i] = prefs.getString(arrayName + "_" + i, "");
10641 }
10642 catch (Exception e)
10643 {
10644 array[i] = "";
10645 }
10646 //System.out.println("array" + i + "=" + array[i]);
10647 }
10648
10649 return array;
10650 }
10651
10652 public static String[] pushToArray(String[] array_in, String value, int size)
10653 {
10654 for (int j = 0; j < size; j++)
10655 {
10656 if (array_in[j].equals(value))
10657 {
10658 // our value is already in the array, dont add it twice!
10659 return array_in;
10660 }
10661 }
10662
10663 String[] array = new String[size];
10664 for (int i = size - 1; i > 0; i--)
10665 {
10666 array[i] = array_in[i - 1];
10667 }
10668 array[0] = value;
10669 return array;
10670 }
10671
10672 private static void getPrefs()
10673 {
10674 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10675
10676 // save old pref values ---------------
10677 ZANaviPrefs.deep_copy(p, p_old);
10678 // save old pref values ---------------
10679
10680 // Get the xml/preferences.xml preferences
10681 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10682 p.PREF_use_fast_provider = prefs.getBoolean("use_fast_provider", true);
10683 p.PREF_allow_gui_internal = prefs.getBoolean("allow_gui_internal", false);
10684 p.PREF_follow_gps = prefs.getBoolean("follow_gps", true);
10685 p.PREF_use_compass_heading_base = prefs.getBoolean("use_compass_heading_base", false);
10686 p.PREF_use_compass_heading_always = prefs.getBoolean("use_compass_heading_always", false);
10687 p.PREF_use_compass_heading_fast = prefs.getBoolean("use_compass_heading_fast", false);
10688 p.PREF_use_anti_aliasing = prefs.getBoolean("use_anti_aliasing", true);
10689 p.PREF_use_map_filtering = prefs.getBoolean("use_map_filtering", true);
10690 p.PREF_gui_oneway_arrows = prefs.getBoolean("gui_oneway_arrows", true);
10691 p.PREF_c_linedrawing = prefs.getBoolean("c_linedrawing", false);
10692
10693 p.PREF_show_debug_messages = prefs.getBoolean("show_debug_messages", false);
10694
10695 p.PREF_show_3d_map = prefs.getBoolean("show_3d_map", false);
10696 send_data_to_plugin_bg(PLUGIN_MSG_CAT_3d_mode, String.valueOf(p.PREF_show_3d_map));
10697
10698 p.PREF_use_smooth_drawing = prefs.getBoolean("use_smooth_drawing", true);
10699 p.PREF_use_more_smooth_drawing = prefs.getBoolean("use_more_smooth_drawing", false);
10700 if (p.PREF_use_smooth_drawing == false)
10701 {
10702 p.PREF_use_more_smooth_drawing = false;
10703 }
10704 if (p.PREF_use_more_smooth_drawing == true)
10705 {
10706 p.PREF_use_smooth_drawing = true;
10707 }
10708
10709 boolean b1 = prefs.getBoolean("show_real_gps_pos", false);
10710 if (b1 == false)
10711 {
10712 p.PREF_show_real_gps_pos = 0;
10713 }
10714 else
10715 {
10716 p.PREF_show_real_gps_pos = 1;
10717 }
10718
10719 if (p.PREF_use_more_smooth_drawing)
10720 {
10721 NavitGraphics.Vehicle_delay_real_gps_position = 595;
10722 }
10723 else
10724 {
10725 NavitGraphics.Vehicle_delay_real_gps_position = 450;
10726 }
10727
10728 p.PREF_use_lock_on_roads = prefs.getBoolean("use_lock_on_roads", true);
10729 p.PREF_use_route_highways = prefs.getBoolean("use_route_highways", true);
10730 p.PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true);
10731 p.PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL*
10732 p.PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 174698); // default zoom level = 174698 // shows almost the whole world
10733 p.PREF_show_sat_status = prefs.getBoolean("show_sat_status", true);
10734 p.PREF_use_agps = prefs.getBoolean("use_agps", true);
10735 p.PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false);
10736 p.PREF_show_turn_restrictions = prefs.getBoolean("show_turn_restrictions", false);
10737 p.PREF_auto_night_mode = prefs.getBoolean("auto_night_mode", true);
10738 // System.out.println("night mode=" + p.PREF_auto_night_mode);
10739
10740 try
10741 {
10742 // recreate the menu items
10743 Message msg = Navit_progress_h.obtainMessage();
10744 Bundle b = new Bundle();
10745 msg.what = 29;
10746 msg.setData(b);
10747 Navit_progress_h.sendMessage(msg);
10748 }
10749 catch (Exception e)
10750 {
10751 e.printStackTrace();
10752 }
10753
10754 p.PREF_enable_debug_write_gpx = prefs.getBoolean("enable_debug_write_gpx", false);
10755 p.PREF_enable_debug_enable_comm = prefs.getBoolean("enable_debug_enable_comm", false);
10756
10757 p.PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
10758 p.PREF_use_custom_font = prefs.getBoolean("use_custom_font", true);
10759 p.PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
10760 p.PREF_streetsearch_r = prefs.getString("streetsearch_r", "2");
10761 p.PREF_route_style = prefs.getString("route_style", "3");
10762 p.PREF_item_dump = prefs.getBoolean("item_dump", false);
10763 p.PREF_show_route_rects = prefs.getBoolean("show_route_rects", false);
10764 p.PREF_trafficlights_delay = prefs.getString("trafficlights_delay", "0");
10765 boolean tmp = prefs.getBoolean("avoid_sharp_turns", false);
10766 p.PREF_avoid_sharp_turns = "0";
10767 //if (tmp)
10768 //{
10769 // p.PREF_avoid_sharp_turns = "1";
10770 //}
10771 p.PREF_autozoom_flag = prefs.getBoolean("autozoom_flag", true);
10772
10773 p.PREF_show_multipolygons = prefs.getBoolean("show_multipolygons", true);
10774 p.PREF_use_index_search = true; // prefs.getBoolean("use_index_search", true);
10775
10776 // PREF_show_2d3d_toggle = prefs.getBoolean("show_2d3d_toggle", true);
10777 p.PREF_show_2d3d_toggle = true;
10778
10779 // PREF_show_vehicle_3d = prefs.getBoolean("show_vehicle_3d", true);
10780 p.PREF_show_vehicle_3d = true;
10781
10782 p.PREF_speak_filter_special_chars = prefs.getBoolean("speak_filter_special_chars", true);
10783 try
10784 {
10785 p.PREF_routing_engine = Integer.parseInt(prefs.getString("routing_engine", "0"));
10786 }
10787 catch (Exception e)
10788 {
10789 p.PREF_routing_engine = 0;
10790 }
10791
10792 // send to C code --------
10793 NavitGraphics.CallbackMessageChannel(55598, "" + p.PREF_routing_engine);
10794 // send to C code --------
10795
10796 p.PREF_routing_profile = prefs.getString("routing_profile", "car");
10797 p.PREF_road_priority_001 = (prefs.getInt("road_priority_001", (68 - 10)) + 10); // must ADD minimum value!!
10798 p.PREF_road_priority_002 = (prefs.getInt("road_priority_002", (329 - 10)) + 10); // must ADD minimum value!!
10799 p.PREF_road_priority_003 = (prefs.getInt("road_priority_003", (5000 - 10)) + 10); // must ADD minimum value!!
10800 p.PREF_road_priority_004 = (prefs.getInt("road_priority_004", (5 - 0)) + 0); // must ADD minimum value!!
10801 p.PREF_night_mode_lux = (prefs.getInt("night_mode_lux", (10 - 1)) + 1); // must ADD minimum value!!
10802 p.PREF_night_mode_buffer = (prefs.getInt("night_mode_buffer", (20 - 1)) + 1); // must ADD minimum value!!
10803
10804 // p.PREF_road_prio_weight_street_1_city = (prefs.getInt("road_prio_weight_street_1_city", (30 - 10)) + 10); // must ADD minimum value!!
10805
10806 p.PREF_traffic_speed_factor = (prefs.getInt("traffic_speed_factor", (83 - 20)) + 20); // must ADD minimum value!!
10807
10808 p.PREF_tracking_connected_pref = (prefs.getInt("tracking_connected_pref", (250 - 0)) + 0); // must ADD minimum value!!
10809 p.PREF_tracking_angle_pref = (prefs.getInt("tracking_angle_pref", (40 - 0)) + 0); // must ADD minimum value!!
10810
10811 p.PREF_streets_only = prefs.getBoolean("streets_only", false);
10812 p.PREF_show_status_bar = prefs.getBoolean("show_status_bar", true);
10813 p.PREF_show_poi_on_map = prefs.getBoolean("show_poi_on_map", false);
10814 p.PREF_last_selected_dir_gpxfiles = prefs.getString("last_selected_dir_gpxfiles", MAP_FILENAME_PATH + "/../");
10815
10816 p.PREF_roadspeed_warning = prefs.getBoolean("roadspeed_warning", false);
10817 p.PREF_lane_assist = prefs.getBoolean("lane_assist", false);
10818
10819 try
10820 {
10821 p.PREF_roadspeed_warning_margin = Integer.parseInt(prefs.getString("roadspeed_warning_margin", "20"));
10822 }
10823 catch (Exception e)
10824 {
10825 p.PREF_roadspeed_warning_margin = 20;
10826 }
10827
10828 p.PREF_StreetSearchStrings = loadArray("xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
10829
10830 try
10831 {
10832 p.PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
10833 }
10834 catch (Exception e)
10835 {
10836 p.PREF_drawatorder = 0;
10837 }
10838
10839 //try
10840 //{
10841 // PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1"));
10842 //}
10843 //catch (Exception e)
10844 //{
10845 p.PREF_cancel_map_drawing_timeout = 1;
10846 //}
10847
10848 try
10849 {
10850 p.PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "3"));
10851 }
10852 catch (Exception e)
10853 {
10854 p.PREF_map_font_size = 2;
10855 }
10856
10857 Navit_last_address_search_country_id = p.PREF_search_country;
10858 Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[p.PREF_search_country][0];
10859
10860 if (!p.PREF_follow_gps)
10861 {
10862 // no compass turning without follow mode!
10863 p.PREF_use_compass_heading_base = false;
10864 }
10865
10866 if (!p.PREF_use_compass_heading_base)
10867 {
10868 // child is always "false" when parent is "false" !!
10869 p.PREF_use_compass_heading_always = false;
10870 }
10871
10872 p.PREF_show_maps_debug_view = prefs.getBoolean("show_maps_debug_view", false);
10873
10874 p.PREF_show_vehicle_in_center = prefs.getBoolean("show_vehicle_in_center", false);
10875 p.PREF_use_imperial = prefs.getBoolean("use_imperial", false);
10876 Navit.cur_max_speed = -1; // to update speedwarning graphics
10877
10878 // System.out.println("get settings");
10879 // System.out.println("PREF_search_country=" + PREF_search_country);
10880 // System.out.println("PREF_follow_gps=" + PREF_follow_gps);
10881 // System.out.println("PREF_use_fast_provider=" + PREF_use_fast_provider);
10882 // System.out.println("PREF_allow_gui_internal=" + PREF_allow_gui_internal);
10883 // System.out.println("PREF_use_compass_heading_base=" + PREF_use_compass_heading_base);
10884 // System.out.println("PREF_use_compass_heading_always=" + PREF_use_compass_heading_always);
10885 // System.out.println("PREF_show_vehicle_in_center=" + PREF_show_vehicle_in_center);
10886 // System.out.println("PREF_use_imperial=" + PREF_use_imperial);
10887
10888 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10889 }
10890
10891 private static void activatePrefs()
10892 {
10893 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10894
10895 activatePrefs(1);
10896
10897 if (p.PREF_save_zoomlevel)
10898 {
10899 // only if really started, but NOT if returning from our own child activities!!
10900
10901 //System.out.println("3 restore zoom level: " + Navit.GlobalScaleLevel);
10902 //System.out.println("4 restore zoom level: " + PREF_zoomlevel_num);
10903
10904 Message msg = new Message();
10905 Bundle b = new Bundle();
10906 b.putInt("Callback", 33);
10907 b.putString("s", Integer.toString(p.PREF_zoomlevel_num));
10908 msg.setData(b);
10909 try
10910 {
10911 NavitGraphics.callback_handler.sendMessage(msg);
10912 Navit.GlobalScaleLevel = p.PREF_zoomlevel_num;
10913 //System.out.println("5 restore zoom level: " + PREF_zoomlevel_num);
10914 }
10915 catch (Exception e)
10916 {
10917 }
10918 }
10919 else
10920 {
10921 p.PREF_zoomlevel_num = Navit.GlobalScaleLevel;
10922 }
10923
10924 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10925 }
10926
10927 private static void set_TurnRestrictions_layers()
10928 {
10929 int on_ = 59; // on
10930
10931 if (!p.PREF_show_turn_restrictions)
10932 {
10933 on_ = 60; // off
10934 }
10935
10936 Message msg = new Message();
10937 Bundle b = new Bundle();
10938 b.putInt("Callback", on_);
10939 b.putString("s", "TurnRestrictions");
10940 msg.setData(b);
10941 NavitGraphics.callback_handler.sendMessage(msg);
10942 }
10943
10944 private static void set_poi_layers()
10945 {
10946 int on_ = 59;
10947 int off_ = 60;
10948
10949 // System.out.println("POI:1");
10950 if (p.PREF_show_poi_on_map)
10951 {
10952 // System.out.println("POI:2");
10953 on_ = 60;
10954 off_ = 59;
10955 }
10956
10957 // toggle the normal POI layers (to avoid double POIs)
10958 Message msg = new Message();
10959 Bundle b = new Bundle();
10960 b.putInt("Callback", on_);
10961 b.putString("s", "POI Symbols");
10962 msg.setData(b);
10963 NavitGraphics.callback_handler.sendMessage(msg);
10964
10965 msg = new Message();
10966 b = new Bundle();
10967 b.putInt("Callback", on_);
10968 b.putString("s", "POI Labels");
10969 msg.setData(b);
10970 NavitGraphics.callback_handler.sendMessage(msg);
10971
10972 // toggle full POI icons on/off
10973 msg = new Message();
10974 b = new Bundle();
10975 b.putInt("Callback", off_);
10976 b.putString("s", "Android-POI-Icons-full");
10977 msg.setData(b);
10978 NavitGraphics.callback_handler.sendMessage(msg);
10979
10980 msg = new Message();
10981 b = new Bundle();
10982 b.putInt("Callback", off_);
10983 b.putString("s", "Android-POI-Labels-full");
10984 msg.setData(b);
10985 NavitGraphics.callback_handler.sendMessage(msg);
10986
10987 // draw_map();
10988 }
10989
10990 private static void activatePrefs(int dummy)
10991 {
10992
10993 need_recalc_route = false; // do we need to recalc the route?
10994
10995 // call some functions to activate the new settings
10996 if (p.PREF_follow_gps)
10997 {
10998 Navit.follow_current = Navit.follow_on;
10999 }
11000 else
11001 {
11002 Navit.follow_current = Navit.follow_off;
11003 }
11004
11005 if (p.PREF_use_fast_provider)
11006 {
11007 NavitVehicle.turn_on_fast_provider();
11008 }
11009 else
11010 {
11011 NavitVehicle.turn_off_fast_provider();
11012 }
11013
11014 if (p.PREF_show_sat_status)
11015 {
11016 NavitVehicle.turn_on_sat_status();
11017 }
11018 else
11019 {
11020 // status always on !
11021 //
11022 // NavitVehicle.turn_off_sat_status();
11023 NavitVehicle.turn_on_sat_status();
11024 }
11025
11026 if (p.PREF_show_status_bar)
11027 {
11028 show_status_bar_wrapper();
11029 }
11030 else
11031 {
11032 hide_status_bar_wrapper();
11033 }
11034
11035 if (p.PREF_allow_gui_internal)
11036 {
11037 Message msg = new Message();
11038 Bundle b = new Bundle();
11039 b.putInt("Callback", 10);
11040 msg.setData(b);
11041 try
11042 {
11043 NavitGraphics.callback_handler.sendMessage(msg);
11044 }
11045 catch (Exception e)
11046 {
11047 }
11048 }
11049 else
11050 {
11051 Message msg = new Message();
11052 Bundle b = new Bundle();
11053 b.putInt("Callback", 9);
11054 msg.setData(b);
11055 try
11056 {
11057 NavitGraphics.callback_handler.sendMessage(msg);
11058 }
11059 catch (Exception e)
11060 {
11061 }
11062 }
11063
11064 if (p.PREF_use_compass_heading_base)
11065 {
11066 // turn on compass
11067 msg_to_msg_handler(new Bundle(), 12);
11068 Message msg = new Message();
11069 Bundle b = new Bundle();
11070 b.putInt("Callback", 11);
11071 msg.setData(b);
11072 try
11073 {
11074 NavitGraphics.callback_handler.sendMessage(msg);
11075 }
11076 catch (Exception e)
11077 {
11078 }
11079 }
11080 else
11081 {
11082 // turn off compass
11083 msg_to_msg_handler(new Bundle(), 13);
11084 Message msg = new Message();
11085 Bundle b = new Bundle();
11086 b.putInt("Callback", 12);
11087 msg.setData(b);
11088 try
11089 {
11090 NavitGraphics.callback_handler.sendMessage(msg);
11091 }
11092 catch (Exception e)
11093 {
11094 }
11095 }
11096
11097 if (p.PREF_show_maps_debug_view == true)
11098 {
11099 // show real gps pos
11100 Message msg = new Message();
11101 Bundle b = new Bundle();
11102 b.putInt("Callback", 112);
11103 b.putString("s", "1");
11104 msg.setData(b);
11105 try
11106 {
11107 NavitGraphics.callback_handler.sendMessage(msg);
11108 }
11109 catch (Exception e)
11110 {
11111 }
11112 }
11113 else
11114 {
11115 Message msg = new Message();
11116 Bundle b = new Bundle();
11117 b.putInt("Callback", 112);
11118 b.putString("s", "0");
11119 msg.setData(b);
11120 try
11121 {
11122 NavitGraphics.callback_handler.sendMessage(msg);
11123 }
11124 catch (Exception e)
11125 {
11126 }
11127 }
11128
11129 if (p.PREF_show_real_gps_pos == 1)
11130 {
11131 // show real gps pos
11132 Message msg = new Message();
11133 Bundle b = new Bundle();
11134 b.putInt("Callback", 111);
11135 b.putString("s", "1");
11136 msg.setData(b);
11137 try
11138 {
11139 NavitGraphics.callback_handler.sendMessage(msg);
11140 }
11141 catch (Exception e)
11142 {
11143 }
11144 }
11145 else
11146 {
11147 Message msg = new Message();
11148 Bundle b = new Bundle();
11149 b.putInt("Callback", 111);
11150 b.putString("s", "0");
11151 msg.setData(b);
11152 try
11153 {
11154 NavitGraphics.callback_handler.sendMessage(msg);
11155 }
11156 catch (Exception e)
11157 {
11158 }
11159 }
11160
11161 // search radius for housenumbers near streets -----------------
11162 Message msg43 = new Message();
11163 Bundle b43 = new Bundle();
11164 b43.putInt("Callback", 89);
11165 b43.putString("s", "1500");
11166 msg43.setData(b43);
11167 try
11168 {
11169 NavitGraphics.callback_handler.sendMessage(msg43);
11170 }
11171 catch (Exception e)
11172 {
11173 }
11174 // search radius for housenumbers near streets -----------------
11175
11176 // set routing profile -----------------
11177 if (Navit_Largemap_DonateVersion_Installed == true)
11178 {
11179 Message msg43a = new Message();
11180 Bundle b43a = new Bundle();
11181 b43a.putInt("Callback", 90);
11182 b43a.putString("s", p.PREF_routing_profile); // set routing profile
11183 msg43a.setData(b43a);
11184 try
11185 {
11186 NavitGraphics.callback_handler.sendMessage(msg43a);
11187 }
11188 catch (Exception e)
11189 {
11190 }
11191
11192 // need_recalc_route = true;
11193 }
11194 // set routing profile -----------------
11195
11196 Message msg99a = new Message();
11197 Bundle b99a = new Bundle();
11198 b99a.putInt("Callback", 98);
11199 // System.out.println("tracking_connected_pref=" + PREF_tracking_connected_pref);
11200 b99a.putString("s", "" + p.PREF_tracking_connected_pref); // set routing profile
11201 msg99a.setData(b99a);
11202 try
11203 {
11204 NavitGraphics.callback_handler.sendMessage(msg99a);
11205 }
11206 catch (Exception e)
11207 {
11208 }
11209
11210 msg99a = new Message();
11211 b99a = new Bundle();
11212 b99a.putInt("Callback", 99);
11213 // System.out.println("tracking_angle_pref=" + PREF_tracking_angle_pref);
11214 b99a.putString("s", "" + p.PREF_tracking_angle_pref); // set routing profile
11215 msg99a.setData(b99a);
11216 try
11217 {
11218 NavitGraphics.callback_handler.sendMessage(msg99a);
11219 }
11220 catch (Exception e)
11221 {
11222 }
11223
11224 // change road profile -----------------
11225 if (Navit_Largemap_DonateVersion_Installed == true)
11226 {
11227 if (p.PREF_routing_profile.equals("bike-normal"))
11228 {
11229 Message msg43b = new Message();
11230 Bundle b43b = new Bundle();
11231 b43b.putInt("Callback", 91);
11232 System.out.println("road_priority_001=" + p.PREF_road_priority_001);
11233 b43b.putString("s", "" + p.PREF_road_priority_001); // set routing profile
11234 msg43b.setData(b43b);
11235 try
11236 {
11237 NavitGraphics.callback_handler.sendMessage(msg43b);
11238 }
11239 catch (Exception e)
11240 {
11241 }
11242
11243 msg43b = new Message();
11244 b43b = new Bundle();
11245 b43b.putInt("Callback", 92);
11246 System.out.println("road_priority_002=" + p.PREF_road_priority_002);
11247 b43b.putString("s", "" + p.PREF_road_priority_002); // set routing profile
11248 msg43b.setData(b43b);
11249 try
11250 {
11251 NavitGraphics.callback_handler.sendMessage(msg43b);
11252 }
11253 catch (Exception e)
11254 {
11255 }
11256
11257 msg43b = new Message();
11258 b43b = new Bundle();
11259 b43b.putInt("Callback", 93);
11260 System.out.println("road_priority_003=" + p.PREF_road_priority_003);
11261 b43b.putString("s", "" + p.PREF_road_priority_003); // set routing profile
11262 msg43b.setData(b43b);
11263 try
11264 {
11265 NavitGraphics.callback_handler.sendMessage(msg43b);
11266 }
11267 catch (Exception e)
11268 {
11269 }
11270
11271 msg43b = new Message();
11272 b43b = new Bundle();
11273 b43b.putInt("Callback", 94);
11274 System.out.println("road_priority_004=" + p.PREF_road_priority_004);
11275 b43b.putString("s", "" + p.PREF_road_priority_004); // set routing profile
11276 msg43b.setData(b43b);
11277 try
11278 {
11279 NavitGraphics.callback_handler.sendMessage(msg43b);
11280 }
11281 catch (Exception e)
11282 {
11283 }
11284
11285 // switch off layers --------------------
11286 msg43b = new Message();
11287 b43b = new Bundle();
11288 b43b.putInt("Callback", 60);
11289 b43b.putString("s", "POI traffic lights");
11290 msg43b.setData(b43b);
11291 try
11292 {
11293 NavitGraphics.callback_handler.sendMessage(msg43b);
11294 }
11295 catch (Exception e)
11296 {
11297 }
11298 // switch off layers --------------------
11299
11300 // switch ON layers --------------------
11301 msg43b = new Message();
11302 b43b = new Bundle();
11303 b43b.putInt("Callback", 59);
11304 b43b.putString("s", "POI bicycle");
11305 msg43b.setData(b43b);
11306 try
11307 {
11308 NavitGraphics.callback_handler.sendMessage(msg43b);
11309 }
11310 catch (Exception e)
11311 {
11312 }
11313 // switch ON layers --------------------
11314
11315 }
11316 else
11317 {
11318 // switch off layers --------------------
11319 Message msg43b = new Message();
11320 Bundle b43b = new Bundle();
11321 b43b.putInt("Callback", 60);
11322 b43b.putString("s", "POI bicycle");
11323 msg43b.setData(b43b);
11324 try
11325 {
11326 NavitGraphics.callback_handler.sendMessage(msg43b);
11327 }
11328 catch (Exception e)
11329 {
11330 }
11331 // switch off layers --------------------
11332
11333 // switch ON layers --------------------
11334 msg43b = new Message();
11335 b43b = new Bundle();
11336 b43b.putInt("Callback", 59);
11337 b43b.putString("s", "POI traffic lights");
11338 msg43b.setData(b43b);
11339 try
11340 {
11341 NavitGraphics.callback_handler.sendMessage(msg43b);
11342 }
11343 catch (Exception e)
11344 {
11345 }
11346 // switch ON layers --------------------
11347 }
11348 }
11349 // change road profile -----------------
11350
11351 // -- debug -- change some prio weights --
11352 // if ((!p.PREF_routing_profile.equals("bike-normal")) && (!p.PREF_routing_profile.equals("bike-no-oneway")) && (!p.PREF_routing_profile.equals("bike-avoid-roads")))
11353 // {
11354 // Message msg93 = new Message();
11355 // Bundle b93 = new Bundle();
11356 // b93.putInt("Callback", 110);
11357 // b93.putString("s", "street_1_city#route_prio_weight:" + p.PREF_road_prio_weight_street_1_city);
11358 // msg93.setData(b93);
11359 // try
11360 // {
11361 // NavitGraphics.callback_handler.sendMessage(msg93);
11362 // }
11363 // catch (Exception e)
11364 // {
11365 // }
11366 //
11367 // if (p_old.PREF_road_prio_weight_street_1_city != p.PREF_road_prio_weight_street_1_city)
11368 // {
11369 // need_recalc_route = true;
11370 // }
11371 // }
11372 // -- debug -- change some prio weights --
11373
11374 if (NavitGraphics.navit_route_status == 0)
11375 {
11376 if (p.PREF_c_linedrawing)
11377 {
11378 Message msg = new Message();
11379 Bundle b = new Bundle();
11380 b.putInt("Callback", 85);
11381 b.putString("s", "1");
11382 msg.setData(b);
11383 try
11384 {
11385 NavitGraphics.callback_handler.sendMessage(msg);
11386 }
11387 catch (Exception e)
11388 {
11389 }
11390 }
11391 else
11392 {
11393 Message msg = new Message();
11394 Bundle b = new Bundle();
11395 b.putInt("Callback", 85);
11396 b.putString("s", "0");
11397 msg.setData(b);
11398 try
11399 {
11400 NavitGraphics.callback_handler.sendMessage(msg);
11401 }
11402 catch (Exception e)
11403 {
11404 }
11405 }
11406 }
11407
11408 Message msg33 = new Message();
11409 Bundle b33 = new Bundle();
11410 b33.putInt("Callback", 103);
11411 if (p.PREF_show_vehicle_in_center)
11412 {
11413 b33.putString("s", "0");
11414 }
11415 else
11416 {
11417 b33.putString("s", "" + NavitGraphics.lower_than_center_percent);
11418 }
11419 msg33.setData(b33);
11420 try
11421 {
11422 NavitGraphics.callback_handler.sendMessage(msg33);
11423 }
11424 catch (Exception e88)
11425 {
11426 }
11427
11428 if (p.PREF_use_imperial)
11429 {
11430 Message msg = new Message();
11431 Bundle b = new Bundle();
11432 b.putInt("Callback", 16);
11433 msg.setData(b);
11434 try
11435 {
11436 NavitGraphics.callback_handler.sendMessage(msg);
11437 }
11438 catch (Exception e)
11439 {
11440 }
11441 }
11442 else
11443 {
11444 Message msg = new Message();
11445 Bundle b = new Bundle();
11446 b.putInt("Callback", 15);
11447 msg.setData(b);
11448 try
11449 {
11450 NavitGraphics.callback_handler.sendMessage(msg);
11451 }
11452 catch (Exception e)
11453 {
11454 }
11455 }
11456
11457 if (p.PREF_show_debug_messages)
11458 {
11459 Message msg = new Message();
11460 Bundle b = new Bundle();
11461 b.putInt("Callback", 24);
11462 msg.setData(b);
11463 try
11464 {
11465 NavitGraphics.callback_handler.sendMessage(msg);
11466 }
11467 catch (Exception e)
11468 {
11469 }
11470 }
11471 else
11472 {
11473 Message msg = new Message();
11474 Bundle b = new Bundle();
11475 b.putInt("Callback", 25);
11476 msg.setData(b);
11477 try
11478 {
11479 NavitGraphics.callback_handler.sendMessage(msg);
11480 }
11481 catch (Exception e)
11482 {
11483 }
11484 }
11485
11486 // if (PREF_show_3d_map)
11487 // {
11488 // Message msg = new Message();
11489 // Bundle b = new Bundle();
11490 // b.putInt("Callback", 31);
11491 // msg.setData(b);
11492 // try
11493 // {
11494 // N_NavitGraphics.callback_handler.sendMessage(msg);
11495 // }
11496 // catch (Exception e)
11497 // {
11498 // }
11499 // }
11500 // else
11501 // {
11502 // Message msg = new Message();
11503 // Bundle b = new Bundle();
11504 // b.putInt("Callback", 30);
11505 // msg.setData(b);
11506 // try
11507 // {
11508 // N_NavitGraphics.callback_handler.sendMessage(msg);
11509 // }
11510 // catch (Exception e)
11511 // {
11512 // }
11513 // }
11514
11515 if (p.PREF_use_lock_on_roads)
11516 {
11517 Message msg = new Message();
11518 Bundle b = new Bundle();
11519 b.putInt("Callback", 36);
11520 msg.setData(b);
11521 try
11522 {
11523 NavitGraphics.callback_handler.sendMessage(msg);
11524 }
11525 catch (Exception e)
11526 {
11527 }
11528 }
11529 else
11530 {
11531 Message msg = new Message();
11532 Bundle b = new Bundle();
11533 b.putInt("Callback", 37);
11534 msg.setData(b);
11535 try
11536 {
11537 NavitGraphics.callback_handler.sendMessage(msg);
11538 }
11539 catch (Exception e)
11540 {
11541 }
11542 }
11543
11544 // if (PREF_draw_polyline_circles)
11545 // {
11546 // Message msg = new Message();
11547 // Bundle b = new Bundle();
11548 // b.putString("s", "0");
11549 // b.putInt("Callback", 56);
11550 // msg.setData(b);
11551 // try
11552 // {
11553 // N_NavitGraphics.callback_handler.sendMessage(msg);
11554 // }
11555 // catch (Exception e)
11556 // {
11557 // }
11558 // }
11559 // else
11560 // {
11561 // Message msg = new Message();
11562 // Bundle b = new Bundle();
11563 // b.putString("s", "1");
11564 // b.putInt("Callback", 56);
11565 // msg.setData(b);
11566 // try
11567 // {
11568 // N_NavitGraphics.callback_handler.sendMessage(msg);
11569 // }
11570 // catch (Exception e)
11571 // {
11572 // }
11573 // }
11574
11575 if (p.PREF_use_route_highways)
11576 {
11577 Message msg = new Message();
11578 Bundle b = new Bundle();
11579 b.putInt("Callback", 42);
11580 msg.setData(b);
11581 try
11582 {
11583 NavitGraphics.callback_handler.sendMessage(msg);
11584 }
11585 catch (Exception e)
11586 {
11587 }
11588 }
11589 else
11590 {
11591 Message msg = new Message();
11592 Bundle b = new Bundle();
11593 b.putInt("Callback", 43);
11594 msg.setData(b);
11595 try
11596 {
11597 NavitGraphics.callback_handler.sendMessage(msg);
11598 }
11599 catch (Exception e)
11600 {
11601 }
11602 }
11603
11604 Message msg7 = new Message();
11605 Bundle b7 = new Bundle();
11606 b7.putInt("Callback", 57);
11607 b7.putString("s", "" + p.PREF_drawatorder);
11608 msg7.setData(b7);
11609 try
11610 {
11611 NavitGraphics.callback_handler.sendMessage(msg7);
11612 }
11613 catch (Exception e)
11614 {
11615 }
11616
11617 msg7 = new Message();
11618 b7 = new Bundle();
11619 b7.putInt("Callback", 58);
11620 b7.putString("s", p.PREF_streetsearch_r);
11621 msg7.setData(b7);
11622 try
11623 {
11624 NavitGraphics.callback_handler.sendMessage(msg7);
11625 }
11626 catch (Exception e)
11627 {
11628 }
11629
11630 if (p.PREF_speak_street_names)
11631 {
11632 Message msg = new Message();
11633 Bundle b = new Bundle();
11634 b.putInt("Callback", 54);
11635 msg.setData(b);
11636 try
11637 {
11638 NavitGraphics.callback_handler.sendMessage(msg);
11639 }
11640 catch (Exception e)
11641 {
11642 }
11643 }
11644 else
11645 {
11646 Message msg = new Message();
11647 Bundle b = new Bundle();
11648 b.putInt("Callback", 53);
11649 msg.setData(b);
11650 try
11651 {
11652 NavitGraphics.callback_handler.sendMessage(msg);
11653 }
11654 catch (Exception e)
11655 {
11656 }
11657
11658 }
11659
11660 try
11661 {
11662 NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[p.PREF_cancel_map_drawing_timeout];
11663 NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[p.PREF_cancel_map_drawing_timeout];
11664 NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[p.PREF_cancel_map_drawing_timeout];
11665 }
11666 catch (Exception e)
11667 {
11668
11669 }
11670
11671 // route variant
11672 Message msg67 = new Message();
11673 Bundle b67 = new Bundle();
11674 // turn off 1
11675 b67.putInt("Callback", 60);
11676 b67.putString("s", "route_001");
11677 msg67.setData(b67);
11678
11679 try
11680 {
11681 NavitGraphics.callback_handler.sendMessage(msg67);
11682 }
11683 catch (Exception e)
11684 {
11685 }
11686 // turn off 2
11687 msg67 = new Message();
11688 b67 = new Bundle();
11689 b67.putInt("Callback", 60);
11690 b67.putString("s", "route_002");
11691 msg67.setData(b67);
11692 try
11693 {
11694 NavitGraphics.callback_handler.sendMessage(msg67);
11695 }
11696 catch (Exception e)
11697 {
11698 }
11699 // turn off 3
11700 msg67 = new Message();
11701 b67 = new Bundle();
11702 b67.putInt("Callback", 60);
11703 b67.putString("s", "route_003");
11704 msg67.setData(b67);
11705 try
11706 {
11707 NavitGraphics.callback_handler.sendMessage(msg67);
11708 }
11709 catch (Exception e)
11710 {
11711 }
11712
11713 // turn on the wanted route style
11714 msg67 = new Message();
11715 b67 = new Bundle();
11716 b67.putInt("Callback", 59);
11717 b67.putString("s", "route_00" + p.PREF_route_style);
11718 msg67.setData(b67);
11719 try
11720 {
11721 NavitGraphics.callback_handler.sendMessage(msg67);
11722 }
11723 catch (Exception e)
11724 {
11725 }
11726 // route variant
11727
11728 // show route rectanlges -----
11729 if (p.PREF_show_route_rects)
11730 {
11731 msg67 = new Message();
11732 b67 = new Bundle();
11733 b67.putInt("Callback", 76);
11734 msg67.setData(b67);
11735 try
11736 {
11737 NavitGraphics.callback_handler.sendMessage(msg67);
11738 }
11739 catch (Exception e)
11740 {
11741 }
11742 }
11743 else
11744 {
11745 msg67 = new Message();
11746 b67 = new Bundle();
11747 b67.putInt("Callback", 77);
11748 msg67.setData(b67);
11749 try
11750 {
11751 NavitGraphics.callback_handler.sendMessage(msg67);
11752 }
11753 catch (Exception e)
11754 {
11755 }
11756 }
11757 // show route rectanlges -----
11758
11759 // show route multipolygons -----
11760 if (p.PREF_show_multipolygons)
11761 {
11762 msg67 = new Message();
11763 b67 = new Bundle();
11764 b67.putInt("Callback", 66);
11765 msg67.setData(b67);
11766 try
11767 {
11768 NavitGraphics.callback_handler.sendMessage(msg67);
11769 }
11770 catch (Exception e)
11771 {
11772 }
11773 }
11774 else
11775 {
11776 msg67 = new Message();
11777 b67 = new Bundle();
11778 b67.putInt("Callback", 67);
11779 msg67.setData(b67);
11780 try
11781 {
11782 NavitGraphics.callback_handler.sendMessage(msg67);
11783 }
11784 catch (Exception e)
11785 {
11786 }
11787 }
11788 // show route multipolygons -----
11789
11790 // traffic lights delay ----
11791 msg67 = new Message();
11792 b67 = new Bundle();
11793 b67.putInt("Callback", 79);
11794 //System.out.println("traffic lights delay:" + PREF_trafficlights_delay);
11795 // (PREF_trafficlights_delay / 10) seconds delay for each traffic light
11796 b67.putString("s", p.PREF_trafficlights_delay); // (delay in 1/10 of a second)
11797 msg67.setData(b67);
11798 try
11799 {
11800 NavitGraphics.callback_handler.sendMessage(msg67);
11801 }
11802 catch (Exception e)
11803 {
11804 }
11805 // traffic lights delay ----
11806
11807 // avoid sharp turns ----
11808 msg67 = new Message();
11809 b67 = new Bundle();
11810 b67.putInt("Callback", 86);
11811 b67.putString("s", p.PREF_avoid_sharp_turns);
11812 msg67.setData(b67);
11813 try
11814 {
11815 NavitGraphics.callback_handler.sendMessage(msg67);
11816 }
11817 catch (Exception e)
11818 {
11819 }
11820
11821 msg67 = new Message();
11822 b67 = new Bundle();
11823 b67.putInt("Callback", 87);
11824 b67.putString("s", "47"); // **DANGER** sharp turn max angle hardcoded here!! **DANGER**
11825 msg67.setData(b67);
11826 try
11827 {
11828 NavitGraphics.callback_handler.sendMessage(msg67);
11829 }
11830 catch (Exception e)
11831 {
11832 }
11833
11834 msg67 = new Message();
11835 b67 = new Bundle();
11836 b67.putInt("Callback", 88);
11837 b67.putString("s", "6000");
11838 msg67.setData(b67);
11839 try
11840 {
11841 NavitGraphics.callback_handler.sendMessage(msg67);
11842 }
11843 catch (Exception e)
11844 {
11845 }
11846 // avoid sharp turns ----
11847
11848 // autozoom flag ----
11849 msg67 = new Message();
11850 b67 = new Bundle();
11851 b67.putInt("Callback", 80);
11852 if (p.PREF_autozoom_flag)
11853 {
11854 b67.putString("s", "1"); // (0 or 1)
11855 }
11856 else
11857 {
11858 b67.putString("s", "0"); // (0 or 1)
11859 }
11860 msg67.setData(b67);
11861 try
11862 {
11863 NavitGraphics.callback_handler.sendMessage(msg67);
11864 }
11865 catch (Exception e)
11866 {
11867
11868 }
11869 // autozoom flag ----
11870
11871 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed))
11872 {
11873 // use pref
11874 }
11875 else
11876 {
11877 p.PREF_roadspeed_warning = false;
11878 }
11879
11880 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed))
11881 {
11882 // use pref
11883 }
11884 else
11885 {
11886 p.PREF_lane_assist = false;
11887 }
11888
11889 if (p.PREF_streets_only)
11890 {
11891 // ----------------------- streets only pref -------------------
11892 // 59 -> enable
11893 // 60 -> disable
11894 Message msg31 = new Message();
11895 Bundle b31 = new Bundle();
11896 b31.putInt("Callback", 60);
11897 b31.putString("s", "polygons001");
11898 msg31.setData(b31);
11899 NavitGraphics.callback_handler.sendMessage(msg31);
11900
11901 msg31 = new Message();
11902 b31 = new Bundle();
11903 b31.putInt("Callback", 60);
11904 b31.putString("s", "polygons");
11905 msg31.setData(b31);
11906 NavitGraphics.callback_handler.sendMessage(msg31);
11907
11908 msg31 = new Message();
11909 b31 = new Bundle();
11910 b31.putInt("Callback", 60);
11911 b31.putString("s", "POI Symbols");
11912 msg31.setData(b31);
11913 NavitGraphics.callback_handler.sendMessage(msg31);
11914
11915 msg31 = new Message();
11916 b31 = new Bundle();
11917 b31.putInt("Callback", 60);
11918 b31.putString("s", "POI Labels");
11919 msg31.setData(b31);
11920 NavitGraphics.callback_handler.sendMessage(msg31);
11921
11922 msg31 = new Message();
11923 b31 = new Bundle();
11924 b31.putInt("Callback", 60);
11925 b31.putString("s", "Android-POI-Icons-full");
11926 msg31.setData(b31);
11927 NavitGraphics.callback_handler.sendMessage(msg31);
11928
11929 msg31 = new Message();
11930 b31 = new Bundle();
11931 b31.putInt("Callback", 60);
11932 b31.putString("s", "Android-POI-Labels-full");
11933 msg31.setData(b31);
11934 NavitGraphics.callback_handler.sendMessage(msg31);
11935
11936 msg31 = new Message();
11937 b31 = new Bundle();
11938 b31.putInt("Callback", 60);
11939 b31.putString("s", "streets");
11940 msg31.setData(b31);
11941 NavitGraphics.callback_handler.sendMessage(msg31);
11942
11943 msg31 = new Message();
11944 b31 = new Bundle();
11945 b31.putInt("Callback", 60);
11946 b31.putString("s", "streets_1");
11947 msg31.setData(b31);
11948 NavitGraphics.callback_handler.sendMessage(msg31);
11949
11950 msg31 = new Message();
11951 b31 = new Bundle();
11952 b31.putInt("Callback", 60);
11953 b31.putString("s", "streets_2");
11954 msg31.setData(b31);
11955 NavitGraphics.callback_handler.sendMessage(msg31);
11956
11957 msg31 = new Message();
11958 b31 = new Bundle();
11959 b31.putInt("Callback", 59);
11960 b31.putString("s", "streets_STR_ONLY");
11961 msg31.setData(b31);
11962 NavitGraphics.callback_handler.sendMessage(msg31);
11963
11964 msg31 = new Message();
11965 b31 = new Bundle();
11966 b31.putInt("Callback", 59);
11967 b31.putString("s", "streets_1_STR_ONLY");
11968 msg31.setData(b31);
11969 NavitGraphics.callback_handler.sendMessage(msg31);
11970
11971 msg31 = new Message();
11972 b31 = new Bundle();
11973 b31.putInt("Callback", 59);
11974 b31.putString("s", "streets_2_STR_ONLY");
11975 msg31.setData(b31);
11976 NavitGraphics.callback_handler.sendMessage(msg31);
11977 // ----------------------- streets only pref -------------------
11978 }
11979 else
11980 {
11981 // ----------------------- streets only pref -------------------
11982 // 59 -> enable
11983 // 60 -> disable
11984 Message msg31 = new Message();
11985 Bundle b31 = new Bundle();
11986 b31.putInt("Callback", 59);
11987 b31.putString("s", "polygons001");
11988 msg31.setData(b31);
11989 NavitGraphics.callback_handler.sendMessage(msg31);
11990
11991 msg31 = new Message();
11992 b31 = new Bundle();
11993 b31.putInt("Callback", 59);
11994 b31.putString("s", "polygons");
11995 msg31.setData(b31);
11996 NavitGraphics.callback_handler.sendMessage(msg31);
11997
11998 msg31 = new Message();
11999 b31 = new Bundle();
12000 b31.putInt("Callback", 59);
12001 b31.putString("s", "POI Symbols");
12002 msg31.setData(b31);
12003 NavitGraphics.callback_handler.sendMessage(msg31);
12004
12005 msg31 = new Message();
12006 b31 = new Bundle();
12007 b31.putInt("Callback", 59);
12008 b31.putString("s", "POI Labels");
12009 msg31.setData(b31);
12010 NavitGraphics.callback_handler.sendMessage(msg31);
12011
12012 msg31 = new Message();
12013 b31 = new Bundle();
12014 b31.putInt("Callback", 60);
12015 b31.putString("s", "Android-POI-Icons-full");
12016 msg31.setData(b31);
12017 NavitGraphics.callback_handler.sendMessage(msg31);
12018
12019 msg31 = new Message();
12020 b31 = new Bundle();
12021 b31.putInt("Callback", 60);
12022 b31.putString("s", "Android-POI-Labels-full");
12023 msg31.setData(b31);
12024 NavitGraphics.callback_handler.sendMessage(msg31);
12025
12026 msg31 = new Message();
12027 b31 = new Bundle();
12028 b31.putInt("Callback", 59);
12029 b31.putString("s", "streets");
12030 msg31.setData(b31);
12031 NavitGraphics.callback_handler.sendMessage(msg31);
12032
12033 msg31 = new Message();
12034 b31 = new Bundle();
12035 b31.putInt("Callback", 59);
12036 b31.putString("s", "streets_1");
12037 msg31.setData(b31);
12038 NavitGraphics.callback_handler.sendMessage(msg31);
12039
12040 msg31 = new Message();
12041 b31 = new Bundle();
12042 b31.putInt("Callback", 59);
12043 b31.putString("s", "streets_2");
12044 msg31.setData(b31);
12045 NavitGraphics.callback_handler.sendMessage(msg31);
12046
12047 msg31 = new Message();
12048 b31 = new Bundle();
12049 b31.putInt("Callback", 60);
12050 b31.putString("s", "streets_STR_ONLY");
12051 msg31.setData(b31);
12052 NavitGraphics.callback_handler.sendMessage(msg31);
12053
12054 msg31 = new Message();
12055 b31 = new Bundle();
12056 b31.putInt("Callback", 60);
12057 b31.putString("s", "streets_1_STR_ONLY");
12058 msg31.setData(b31);
12059 NavitGraphics.callback_handler.sendMessage(msg31);
12060
12061 msg31 = new Message();
12062 b31 = new Bundle();
12063 b31.putInt("Callback", 60);
12064 b31.putString("s", "streets_2_STR_ONLY");
12065 msg31.setData(b31);
12066 NavitGraphics.callback_handler.sendMessage(msg31);
12067 // ----------------------- streets only pref -------------------
12068 }
12069
12070 // ---------- set traffic factor for road speeds ------------
12071 try
12072 {
12073 Message msg_ss1 = new Message();
12074 Bundle b_ss1 = new Bundle();
12075 b_ss1.putInt("Callback", 106);
12076 b_ss1.putString("s", Integer.toString(p.PREF_traffic_speed_factor));
12077 msg_ss1.setData(b_ss1);
12078 NavitGraphics.callback_handler.sendMessage(msg_ss1);
12079 }
12080 catch (Exception e)
12081 {
12082 }
12083 // ---------- set traffic factor for road speeds ------------
12084
12085 // ------- PREF_show_poi_on_map ---------------------------------
12086 set_poi_layers();
12087 // ------- PREF_show_poi_on_map ---------------------------------
12088
12089 set_TurnRestrictions_layers();
12090
12091 // set vars for mapdir change (only really takes effect after restart!)
12092 getPrefs_mapdir();
12093
12094 if (need_recalc_route)
12095 {
12096 recalculate_route();
12097 need_recalc_route = false;
12098 }
12099
12100 }
12101
12102 @SuppressLint("NewApi")
12103 private static void getPrefs_mapdir()
12104 {
12105 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12106
12107 // Get the xml/preferences.xml preferences
12108 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
12109 String default_sdcard_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/zanavi/maps/";
12110 String default_sdcard_dir_1 = default_sdcard_dir;
12111 System.out.println("DataStorageDir[s1]=" + default_sdcard_dir_1);
12112
12113 // check for Android KitKat 4.4 ---------------
12114 try
12115 {
12116 if (Integer.valueOf(android.os.Build.VERSION.SDK) > 18)
12117 {
12118 // use app private dir
12119 default_sdcard_dir = Navit.getBaseContext_.getExternalFilesDir(null).getAbsolutePath();
12120 }
12121 }
12122 catch (Exception e)
12123 {
12124 }
12125 // check for Android KitKat 4.4 ---------------
12126
12127 try
12128 {
12129 NavitDataStorageDirs = android.support.v4.content.ContextCompat.getExternalFilesDirs(Navit.getBaseContext_, null);
12130
12131 if (NavitDataStorageDirs.length > 0)
12132 {
12133 // use new method
12134 default_sdcard_dir = NavitDataStorageDirs[0].getAbsolutePath() + "/zanavi/maps/";
12135 System.out.println("DataStorageDir count=" + NavitDataStorageDirs.length);
12136
12137 for (int jj2 = 0; jj2 < NavitDataStorageDirs.length; jj2++)
12138 {
12139 if (NavitDataStorageDirs[jj2] != null)
12140 {
12141 System.out.println("DataStorageDir[" + jj2 + "]=" + NavitDataStorageDirs[jj2].getAbsolutePath() + "/zanavi/maps/");
12142 }
12143 }
12144 }
12145
12146 if (NavitDataStorageDirs.length == 1)
12147 {
12148 File tf = null;
12149 File[] NavitDataStorageDirs_ = new File[NavitDataStorageDirs.length + 1];
12150
12151 try
12152 {
12153 Map<String, File> externalLocations = ExternalStorage.getAllStorageLocations();
12154 // String sdCard__ = externalLocations.get(ExternalStorage.SD_CARD).getAbsolutePath();
12155 String externalSdCard__ = externalLocations.get(ExternalStorage.EXTERNAL_SD_CARD).getAbsolutePath();
12156 // System.out.println("DataStorageDir[sd]=" + sdCard__);
12157 System.out.println("DataStorageDir[external sd]=" + externalSdCard__);
12158
12159 for (int jj2 = 0; jj2 < NavitDataStorageDirs.length; jj2++)
12160 {
12161 if (NavitDataStorageDirs[jj2] == null)
12162 {
12163 NavitDataStorageDirs_[jj2] = null;
12164 }
12165 else
12166 {
12167 NavitDataStorageDirs_[jj2] = new File(NavitDataStorageDirs[jj2].getAbsolutePath() + "/zanavi/maps/");
12168 }
12169 }
12170
12171 tf = new File(externalLocations.get(ExternalStorage.EXTERNAL_SD_CARD).getAbsolutePath() + "/Android/data/com.zoffcc.applications.zanavi/files" + "/zanavi/maps/");
12172 }
12173 catch (Exception e)
12174 {
12175 tf = null;
12176 }
12177
12178 if (tf != null)
12179 {
12180 NavitDataStorageDirs_[NavitDataStorageDirs.length] = tf;
12181 NavitDataStorageDirs = null;
12182 NavitDataStorageDirs = NavitDataStorageDirs_;
12183 }
12184 }
12185
12186 }
12187 catch (Exception e)
12188 {
12189 System.out.println("DataStorageDir Ex002");
12190 e.printStackTrace();
12191 }
12192
12193 //Log.e("Navit", "old sdcard dir=" + NavitDataDirectory_Maps);
12194 //Log.e("Navit", "default sdcard dir=" + default_sdcard_dir);
12195 NavitDataDirectory_Maps = prefs.getString("map_directory", default_sdcard_dir + "/zanavi/maps/");
12196 String Navit_storage_directory_select = prefs.getString("storage_directory", "-1");
12197 int Navit_storage_directory_select_i = 0;
12198 try
12199 {
12200 Navit_storage_directory_select_i = Integer.parseInt(Navit_storage_directory_select);
12201 }
12202 catch (Exception e)
12203 {
12204
12205 }
12206 System.out.println("DataStorageDir[sel 1]=" + NavitDataDirectory_Maps);
12207 System.out.println("DataStorageDir[sel 2]=" + Navit_storage_directory_select);
12208
12209 if (Navit_storage_directory_select_i > 0)
12210 {
12211 NavitDataDirectory_Maps = NavitDataStorageDirs[Navit_storage_directory_select_i - 1].getAbsolutePath();
12212 }
12213 System.out.println("DataStorageDir[*in use*]=" + NavitDataDirectory_Maps);
12214
12215 // Navit_storage_directory_select:
12216 // -1 --> first run -> select best dir for user
12217 // 0 --> use custom directory
12218 // 1..n --> select default dir on SD Card number 1..n
12219
12220 // ** DEBUG ** set dir manually ** // NavitDataDirectory_Maps = default_sdcard_dir + "/zanavi/maps/";
12221 // ** DEBUG ** NavitDataDirectory_Maps = prefs.getString("navit_mapsdir", "/sdcard" + "/zanavi/maps/");
12222 //Log.e("Navit", "new sdcard dir=" + NavitDataDirectory_Maps);
12223
12224 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12225 }
12226
12227 static String sanity_check_maps_dir(String check_dir)
12228 {
12229 String ret = check_dir;
12230 ret = ret.replaceAll("\\n", ""); // newline -> ""
12231 ret = ret.replaceAll("\\r", ""); // return -> ""
12232 ret = ret.replaceAll("\\t", ""); // tab -> ""
12233 ret = ret.replaceAll(" ", ""); // space -> ""
12234 ret = ret.replaceAll("\"", ""); // \" -> ""
12235 ret = ret.replaceAll("'", ""); // \' -> ""
12236 ret = ret.replaceAll("\\\\", ""); // "\" -> ""
12237 if (!ret.endsWith("/"))
12238 {
12239 ret = ret + "/";
12240 }
12241 // System.out.println("sanity check:" + ret);
12242 return ret;
12243 }
12244
12245 private static void activatePrefs_mapdir(Boolean at_startup)
12246 {
12247 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12248
12249 // activate the new directory
12250 NavitDataDirectory_Maps = sanity_check_maps_dir(NavitDataDirectory_Maps);
12251 MAP_FILENAME_PATH = NavitDataDirectory_Maps;
12252 MAPMD5_FILENAME_PATH = NavitDataDirectory_Maps + "/../md5/";
12253 CFG_FILENAME_PATH = NavitDataDirectory_Maps + "/../";
12254 NAVIT_DATA_DEBUG_DIR = CFG_FILENAME_PATH + "../debug/";
12255
12256 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12257 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12258 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12259 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12260 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12261 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12262 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12263 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12264 //System.out.println("xxxxxxxx************XXXXXXXXXXX");
12265
12266 Handler h_temp = null;
12267 h_temp = NavitGraphics.callback_handler_s;
12268 //System.out.println("handler 1=" + h_temp.toString());
12269
12270 Message msg1 = new Message();
12271 Bundle b1 = new Bundle();
12272 b1.putInt("Callback", 47);
12273 b1.putString("s", MAP_FILENAME_PATH);
12274 msg1.setData(b1);
12275 h_temp.sendMessage(msg1);
12276
12277 if (!at_startup)
12278 {
12279 Message msg2 = new Message();
12280 Bundle b2 = new Bundle();
12281 b2.putInt("Callback", 18);
12282 msg2.setData(b2);
12283 h_temp.sendMessage(msg2);
12284 }
12285
12286 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12287 }
12288
12289 private void getPrefs_theme()
12290 {
12291 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
12292 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
12293 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
12294 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
12295 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
12296 if (theme_tmp == 1)
12297 {
12298 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_LIGHT;
12299 }
12300 else
12301 {
12302 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
12303 }
12304
12305 }
12306
12307 private void getPrefs_theme_main()
12308 {
12309 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
12310 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
12311 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
12312 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
12313 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
12314 if (theme_tmp == 1)
12315 {
12316 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_LIGHT_M;
12317 }
12318 else
12319 {
12320 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
12321 }
12322
12323 }
12324
12325 private static void getPrefs_loc()
12326 {
12327 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12328
12329 // Get the xml/preferences.xml preferences
12330 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
12331 p.PREF_navit_lang = prefs.getString("navit_lang", "*DEFAULT*");
12332 System.out.println("**** ***** **** pref lang=" + p.PREF_navit_lang);
12333
12334 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12335 }
12336
12337 private static void activatePrefs_loc()
12338 {
12339 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12340
12341 // creating locale
12342 if (!p.PREF_navit_lang.equals("*DEFAULT*"))
12343 {
12344 Locale locale2 = null;
12345 if (p.PREF_navit_lang.contains("_"))
12346 {
12347 String _lang = p.PREF_navit_lang.split("_", 2)[0];
12348 String _country = p.PREF_navit_lang.split("_", 2)[1];
12349 System.out.println("l=" + _lang + " c=" + _country);
12350 locale2 = new Locale(_lang, _country);
12351 }
12352 else
12353 {
12354 locale2 = new Locale(p.PREF_navit_lang);
12355 }
12356 Locale.setDefault(locale2);
12357 Configuration config2 = new Configuration();
12358 config2.locale = locale2;
12359 // updating locale
12360 getBaseContext_.getResources().updateConfiguration(config2, null);
12361 }
12362
12363 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12364 }
12365
12366 private static void getPrefs_mapcache()
12367 {
12368 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
12369 try
12370 {
12371 p.PREF_mapcache = Integer.parseInt(prefs.getString("mapcache", "" + (10 * 1024)));
12372 }
12373 catch (Exception e)
12374 {
12375 e.printStackTrace();
12376 p.PREF_mapcache = 10 * 1024;
12377 }
12378 System.out.println("**** ***** **** pref mapcache=" + p.PREF_mapcache);
12379 }
12380
12381 private static void activatePrefs_mapcache()
12382 {
12383 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12384
12385 Handler h_temp2 = null;
12386 h_temp2 = NavitGraphics.callback_handler_s;
12387 System.out.println("activatePrefs_mapcache " + NavitGraphics.callback_handler_s);
12388 Message msg7 = new Message();
12389 Bundle b7 = new Bundle();
12390 b7.putInt("Callback", 55);
12391 b7.putString("s", String.valueOf(p.PREF_mapcache * 1024));
12392 msg7.setData(b7);
12393 h_temp2.sendMessage(msg7);
12394
12395 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12396 }
12397
12398 public native void NavitMain(Navit x, String lang, int version, String display_density_string, String n_datadir, String n_sharedir, Bitmap main_map_bitmap);
12399
12400 public native void NavitActivity(int activity);
12401
12402 /*
12403 * this is used to load the 'navit' native library on
12404 * application startup. The library has already been unpacked at
12405 * installation time by the package manager.
12406 */
12407 static
12408 {
12409 System.loadLibrary("navit");
12410 }
12411
12412 /*
12413 * Show a search activity with the string "search" filled in
12414 */
12415 private void executeSearch(String search)
12416 {
12417 Navit.use_index_search = Navit.allow_use_index_search();
12418 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
12419 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
12420 search_intent.putExtra("address_string", search);
12421 search_intent.putExtra("type", "offline");
12422 search_intent.putExtra("search_country_id", Navit_last_address_search_country_id);
12423 String pm_temp = "0";
12424 if (Navit_last_address_partial_match)
12425 {
12426 pm_temp = "1";
12427 }
12428 search_intent.putExtra("partial_match", pm_temp);
12429 this.startActivityForResult(search_intent, NavitAddressSearch_id_offline);
12430 }
12431
12432 private void share_location(String lat, String lon, String name, String subject_text, String time_at_destination, boolean is_dest)
12433 {
12434 Intent intent = new Intent(Intent.ACTION_SEND);
12435 intent.setType("text/plain");
12436 String url;
12437 final String map_zoomlevel = "18";
12438 // url = "" + lat + "," + lon + "\n" + name;
12439 url = "http://maps.google.com/?q=" + lat + "," + lon + "&z=" + map_zoomlevel + "\n\n" + name;
12440
12441 if (is_dest)
12442 {
12443 if (time_at_destination.compareTo("") != 0)
12444 {
12445 url = url + " " + time_at_destination;
12446 }
12447 }
12448
12449 intent.putExtra(Intent.EXTRA_TEXT, url);
12450 intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject_text);
12451 //Uri uri = Uri.parse("geo:0,0?z=16&q=" + lat + "," + lon);
12452 //intent.putExtra(Intent.EXTRA_STREAM, uri);
12453
12454 // shut down TTS ---------------
12455 // if (!Navit.is_navigating)
12456 // {
12457 // try
12458 // {
12459 // mTts.stop();
12460 // }
12461 // catch (Exception e)
12462 // {
12463 //
12464 // }
12465 //
12466 // try
12467 // {
12468 // mTts.shutdown();
12469 // }
12470 // catch (Exception e)
12471 // {
12472 //
12473 // }
12474 // }
12475 // shut down TTS ---------------
12476
12477 startActivityForResult(Intent.createChooser(intent, Navit.get_text("Share")), NavitAddressSearch_id_sharedest); // TRANS
12478 }
12479
12480 /*
12481 * open google maps at a given coordinate
12482 */
12483 private void googlemaps_show(String lat, String lon, String name)
12484 {
12485 // geo:latitude,longitude
12486 String url = null;
12487 Intent gmaps_intent = new Intent(Intent.ACTION_VIEW);
12488
12489 //url = "geo:" + lat + "," + lon + "?z=" + "16";
12490 //url = "geo:0,0?q=" + lat + "," + lon + " (" + name + ")";
12491 url = "geo:0,0?z=16&q=" + lat + "," + lon + " (" + name + ")";
12492
12493 gmaps_intent.setData(Uri.parse(url));
12494 this.startActivityForResult(gmaps_intent, NavitAddressSearch_id_gmaps);
12495 }
12496
12497 public void zoom_out_full()
12498 {
12499 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
12500
12501 System.out.println("");
12502 System.out.println("*** Zoom out FULL ***");
12503 System.out.println("");
12504 Message msg = new Message();
12505 Bundle b = new Bundle();
12506 b.putInt("Callback", 8);
12507 msg.setData(b);
12508 NavitGraphics.callback_handler.sendMessage(msg);
12509
12510 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
12511 }
12512
12513 static public void show_geo_on_screen_with_zoom_and_delay(float lat, float lon)
12514 {
12515 show_geo_on_screen_with_zoom_and_delay(lat, lon, 0);
12516 }
12517
12518 @SuppressLint("NewApi")
12519 static public void show_geo_on_screen_with_zoom_and_delay(final float lat, final float lon, final int millis_start_delay)
12520 {
12521 System.out.println("XSOM:010");
12522
12523 // if (api_version_int < 11)
12524 // {
12525 //
12526 // new AsyncTask<Void, Void, String>()
12527 // {
12528 // @Override
12529 // protected String doInBackground(Void... params)
12530 // {
12531 // System.out.println("XSOM:011");
12532 //
12533 // try
12534 // {
12535 // System.out.println("XSOM:001");
12536 // Thread.sleep((long) millis_start_delay);
12537 // Navit.show_geo_on_screen_no_draw(lat, lon);
12538 // System.out.println("XSOM:002");
12539 // Thread.sleep(100);
12540 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12541 // System.out.println("XSOM:004");
12542 // Thread.sleep(120);
12543 // Navit.draw_map();
12544 // System.out.println("XSOM:005");
12545 // }
12546 // catch (Exception e)
12547 // {
12548 // }
12549 //
12550 // return "";
12551 // }
12552 //
12553 // @Override
12554 // protected void onPostExecute(String msg)
12555 // {
12556 //
12557 // }
12558 // }.execute(null, null, null);
12559 //
12560 // }
12561 // else
12562 // {
12563 // new AsyncTask<Void, Void, String>()
12564 // {
12565 // @Override
12566 // protected String doInBackground(Void... params)
12567 // {
12568 // System.out.println("XSOM:011");
12569 //
12570 // try
12571 // {
12572 // System.out.println("XSOM:001");
12573 // Thread.sleep((long) millis_start_delay);
12574 // Navit.show_geo_on_screen_no_draw(lat, lon);
12575 // System.out.println("XSOM:002");
12576 // Thread.sleep(100);
12577 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12578 // System.out.println("XSOM:004");
12579 // Thread.sleep(120);
12580 // Navit.draw_map();
12581 // System.out.println("XSOM:005");
12582 // }
12583 // catch (Exception e)
12584 // {
12585 // }
12586 //
12587 // return "";
12588 // }
12589 //
12590 // @Override
12591 // protected void onPostExecute(String msg)
12592 // {
12593 //
12594 // }
12595 // }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
12596 //
12597 // }
12598
12599 final Thread temp_work_thread = new Thread()
12600 {
12601 @Override
12602 public void run()
12603 {
12604 try
12605 {
12606 Thread.sleep((long) millis_start_delay);
12607 Navit.show_geo_on_screen_no_draw(lat, lon);
12608 Thread.sleep(500);
12609 Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12610 Thread.sleep(120);
12611 Navit.draw_map();
12612 }
12613 catch (Exception e2)
12614 {
12615 e2.printStackTrace();
12616 }
12617 }
12618 };
12619 temp_work_thread.start();
12620 }
12621
12622 static public void show_geo_on_screen(float lat, float lng)
12623 {
12624 // this function sets screen center to "lat, lon", and just returns a dummy string!
12625 Navit.cwthr.CallbackGeoCalc2(2, 3, lat, lng);
12626 }
12627
12628 static public void show_geo_on_screen_no_draw(float lat, float lng)
12629 {
12630 // this function sets screen center to "lat, lon", and just returns a dummy string!
12631 Navit.cwthr.CallbackGeoCalc2(2, 15, lat, lng);
12632 }
12633
12634 public static void zoom_to_route()
12635 {
12636 try
12637 {
12638 //System.out.println("");
12639 //System.out.println("*** Zoom to ROUTE ***");
12640 //System.out.println("");
12641 Message msg = new Message();
12642 Bundle b = new Bundle();
12643 b.putInt("Callback", 17);
12644 msg.setData(b);
12645 NavitGraphics.callback_handler.sendMessage(msg);
12646
12647 set_map_position_to_screen_center();
12648 }
12649 catch (Exception e)
12650 {
12651 }
12652 }
12653
12654 static void set_map_position_to_screen_center()
12655 {
12656 try
12657 {
12658 Message msg = new Message();
12659 Bundle b = new Bundle();
12660 b.putInt("Callback", 51);
12661
12662 if (Navit.GFX_OVERSPILL)
12663 {
12664 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
12665 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
12666 }
12667 else
12668 {
12669 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
12670 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
12671 }
12672 msg.setData(b);
12673 NavitGraphics.callback_handler.sendMessage(msg);
12674 }
12675 catch (Exception e)
12676 {
12677 }
12678 }
12679
12680 public void turn_on_compass()
12681 {
12682 try
12683 {
12684 if (!p.PREF_use_compass_heading_fast)
12685
12686 {
12687 // Slower
12688 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL);
12689 }
12690 else
12691 {
12692 // FAST
12693 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI);
12694 }
12695 }
12696 catch (Exception e)
12697 {
12698 e.printStackTrace();
12699 }
12700 }
12701
12702 public void turn_off_compass()
12703 {
12704 try
12705 {
12706 sensorManager.unregisterListener(this);
12707 }
12708 catch (Exception e)
12709 {
12710 e.printStackTrace();
12711 }
12712 }
12713
12714 public void onSensorChanged(SensorEvent event)
12715 {
12716
12717 if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD)
12718 {
12719 // System.out.println("Sensor.TYPE_MAGNETIC_FIELD");
12720 return;
12721 }
12722
12723 if (event.sensor.getType() == Sensor.TYPE_ORIENTATION)
12724 {
12725 // System.out.println("Sensor.TYPE_ORIENTATION");
12726
12727 // compass
12728 float myAzimuth = event.values[0];
12729 // double myPitch = event.values[1];
12730 // double myRoll = event.values[2];
12731
12732 //String out = String.format("Azimuth: %.2f", myAzimuth);
12733 //System.out.println("compass: " + out);
12734 NavitVehicle.update_compass_heading(myAzimuth);
12735 }
12736 }
12737
12738 public void onAccuracyChanged(Sensor sensor, int accuracy)
12739 {
12740 // compass
12741 }
12742
12743 public void hide_status_bar()
12744 {
12745 if (!p.PREF_show_status_bar)
12746 {
12747 // Hide the Status Bar
12748 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN);
12749 }
12750 }
12751
12752 public void show_status_bar()
12753 {
12754 // Show the Status Bar
12755 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN);
12756 }
12757
12758 public void hide_title_bar()
12759 {
12760 // -- unsued !!!! --
12761 // -- unsued !!!! --
12762 // -- unsued !!!! --
12763
12764 // Hide the Title Bar - this works ONLY before setcontent in onCreate!!
12765 requestWindowFeature(Window.FEATURE_NO_TITLE);
12766 }
12767
12768 public void show_title_bar()
12769 {
12770 // -- unsued !!!! --
12771 // -- unsued !!!! --
12772 // -- unsued !!!! --
12773
12774 // Hide the Title Bar - this works ONLY before setcontent in onCreate!!
12775 // ?? requestWindowFeature(Window.);
12776 }
12777
12778 public static Boolean downloadGPSXtra(Context context)
12779 {
12780 Boolean ret = false;
12781 Boolean ret2 = false;
12782 try
12783 {
12784 LocationManager locationmanager2 = (LocationManager) context.getSystemService("location");
12785 Bundle bundle = new Bundle();
12786 //ret2 = locationmanager2.sendExtraCommand("gps", "delete_aiding_data", null);
12787 //ret = ret2;
12788 // System.out.println("ret0=" + ret);
12789 ret2 = locationmanager2.sendExtraCommand("gps", "force_xtra_injection", bundle);
12790 ret = ret2;
12791 //System.out.println("ret1=" + ret2);
12792 ret2 = locationmanager2.sendExtraCommand("gps", "force_time_injection", bundle);
12793 ret = ret || ret2;
12794 //System.out.println("ret2=" + ret2);
12795 }
12796 catch (Exception e)
12797 {
12798 //System.out.println("*XX*");
12799 e.printStackTrace();
12800 }
12801 return ret;
12802 }
12803
12804 static void remove_oldest_normal_point()
12805 {
12806 int i;
12807 for (i = 0; i < map_points.size(); i++)
12808 {
12809 Navit_Point_on_Map element_temp = map_points.get(i);
12810 if (element_temp.addon == null)
12811 {
12812 // its a normal (non home, non special item), so can remove it, and return.
12813 break;
12814 }
12815 }
12816 }
12817
12818 static int find_home_point()
12819 {
12820 int home_id = -1;
12821 int i;
12822
12823 for (i = 0; i < map_points.size(); i++)
12824 {
12825 Navit_Point_on_Map element_temp = map_points.get(i);
12826 if (element_temp.addon != null)
12827 {
12828 if (element_temp.addon.equals("1"))
12829 {
12830 // found home
12831 return i;
12832 }
12833 }
12834 }
12835 return home_id;
12836 }
12837
12838 static void readd_home_point()
12839 {
12840 try
12841 {
12842 int home_id = find_home_point();
12843 if (home_id != -1)
12844 {
12845 Navit_Point_on_Map element_old = map_points.get(home_id);
12846 map_points.remove(home_id);
12847 map_points.add(element_old);
12848 }
12849 }
12850 catch (Exception e)
12851 {
12852 }
12853 }
12854
12855 static void add_map_point(Navit_Point_on_Map element)
12856 {
12857 if (element == null)
12858 {
12859 return;
12860 }
12861
12862 if (map_points == null)
12863 {
12864 map_points = new ArrayList<Navit_Point_on_Map>();
12865 }
12866
12867 int el_pos = get_destination_pos(element);
12868 // int home_id = find_home_point();
12869 boolean is_home = is_home_element(element);
12870
12871 // System.out.println("EEPOS:el_pos=" + el_pos + " is_home=" + is_home);
12872
12873 if (is_home)
12874 {
12875 // its the "home" destination
12876 return;
12877 }
12878
12879 if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
12880 {
12881 try
12882 {
12883 // map_points.remove(0);
12884 remove_oldest_normal_point();
12885 }
12886 catch (Exception e)
12887 {
12888 }
12889 }
12890
12891 if (el_pos == -1)
12892 {
12893 // if not duplicate, then add
12894 map_points.add(element);
12895 readd_home_point();
12896 write_map_points();
12897 }
12898 else
12899 {
12900 try
12901 {
12902 // if already in list, then first remove and add again
12903 // that moves it to the top of the list
12904 Navit_Point_on_Map element_old = map_points.get(el_pos);
12905 map_points.remove(el_pos);
12906 map_points.add(element_old);
12907 readd_home_point();
12908 write_map_points();
12909 }
12910 catch (Exception e)
12911 {
12912 e.printStackTrace();
12913 }
12914 }
12915 }
12916
12917 void read_map_points()
12918 {
12919 deserialize_map_points();
12920 }
12921
12922 static void write_map_points()
12923 {
12924 if (map_points != null)
12925 {
12926 serialize_map_points();
12927 }
12928 }
12929
12930 private static void serialize_map_points()
12931 {
12932 FileOutputStream fos;
12933 try
12934 {
12935 fos = new FileOutputStream(NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME);
12936 // openFileOutput(CFG_FILENAME_PATH + Navit_DEST_FILENAME, Context.MODE_PRIVATE);
12937 ObjectOutputStream oos = new ObjectOutputStream(fos);
12938 oos.writeObject(map_points);
12939 oos.close();
12940 }
12941 catch (FileNotFoundException e)
12942 {
12943 e.printStackTrace();
12944 }
12945 catch (IOException e)
12946 {
12947 e.printStackTrace();
12948 }
12949 catch (Exception e)
12950 {
12951 e.printStackTrace();
12952 }
12953 }
12954
12955 private void export_map_points_to_sdcard()
12956 {
12957 String orig_file = NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME;
12958 String dest_file_dir = CFG_FILENAME_PATH + "../export/";
12959
12960 try
12961 {
12962 File dir = new File(dest_file_dir);
12963 dir.mkdirs();
12964 }
12965 catch (Exception e)
12966 {
12967 e.printStackTrace();
12968 }
12969
12970 try
12971 {
12972 File source = new File(orig_file);
12973 File destination = new File(dest_file_dir + Navit_DEST_FILENAME);
12974
12975 if (source.exists())
12976 {
12977 FileInputStream fi = new FileInputStream(source);
12978 FileOutputStream fo = new FileOutputStream(destination);
12979 FileChannel src = fi.getChannel();
12980 FileChannel dst = fo.getChannel();
12981 dst.transferFrom(src, 0, src.size());
12982 src.close();
12983 dst.close();
12984 fi.close();
12985 fo.close();
12986 }
12987 }
12988 catch (Exception e)
12989 {
12990 e.printStackTrace();
12991 }
12992 }
12993
12994 private void import_map_points_from_sdcard()
12995 {
12996 String orig_file = NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME;
12997 String dest_file_dir = CFG_FILENAME_PATH + "../export/";
12998
12999 try
13000 {
13001 File source = new File(dest_file_dir + Navit_DEST_FILENAME);
13002 File destination = new File(orig_file);
13003
13004 if (source.exists())
13005 {
13006 FileInputStream fi = new FileInputStream(source);
13007 FileOutputStream fo = new FileOutputStream(destination);
13008 FileChannel src = fi.getChannel();
13009 FileChannel dst = fo.getChannel();
13010 dst.transferFrom(src, 0, src.size());
13011 src.close();
13012 dst.close();
13013 fi.close();
13014 fo.close();
13015 }
13016 }
13017 catch (Exception e)
13018 {
13019 e.printStackTrace();
13020 }
13021
13022 read_map_points();
13023 }
13024
13025 //@SuppressWarnings("unchecked")
13026 private void deserialize_map_points()
13027 {
13028 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
13029
13030 FileInputStream fis = null;
13031 ObjectInputStream ois = null;
13032
13033 try
13034 {
13035 fis = new FileInputStream(NAVIT_DATA_SHARE_DIR + Navit_DEST_FILENAME);
13036 // openFileInput(CFG_FILENAME_PATH + Navit_DEST_FILENAME);
13037 ois = new ObjectInputStream(fis);
13038 map_points = (ArrayList<Navit_Point_on_Map>) ois.readObject();
13039 }
13040 catch (FileNotFoundException e)
13041 {
13042 e.printStackTrace();
13043 map_points = new ArrayList<Navit_Point_on_Map>();
13044 }
13045 catch (IOException e)
13046 {
13047 e.printStackTrace();
13048 map_points = new ArrayList<Navit_Point_on_Map>();
13049 }
13050 catch (ClassNotFoundException e)
13051 {
13052 e.printStackTrace();
13053 map_points = new ArrayList<Navit_Point_on_Map>();
13054 }
13055 catch (Exception e)
13056 {
13057 e.printStackTrace();
13058 map_points = new ArrayList<Navit_Point_on_Map>();
13059 }
13060
13061 try
13062 {
13063 if (ois != null)
13064 {
13065 ois.close();
13066 }
13067 }
13068 catch (Exception e)
13069 {
13070 }
13071
13072 try
13073 {
13074 if (fis != null)
13075 {
13076 ois.close();
13077 }
13078 }
13079 catch (Exception e)
13080 {
13081 }
13082
13083 // for (int j = 0; j < map_points.size(); j++)
13084 // {
13085 // System.out.println("####******************" + j + ":" + map_points.get(j).point_name);
13086 // }
13087
13088 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
13089
13090 }
13091
13092 static void remember_destination_xy(String name, int x, int y)
13093 {
13094 // i=1 -> pixel a,b (x,y) -> geo string "lat(float):lng(float)"
13095 // i=2 -> geo a,b (lat,lng) -> pixel string "x(int):y(int)"
13096 String lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
13097 try
13098 {
13099 String tmp[] = lat_lon.split(":", 2);
13100 //System.out.println("tmp=" + lat_lon);
13101 float lat = Float.parseFloat(tmp[0]);
13102 float lon = Float.parseFloat(tmp[1]);
13103 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
13104 remember_destination(name, lat, lon);
13105 }
13106 catch (Exception e)
13107 {
13108 e.printStackTrace();
13109
13110 }
13111 }
13112
13113 static void remember_destination(String name, String lat, String lon)
13114 {
13115 try
13116 {
13117 //System.out.println("22 **## " + name + " " + lat + " " + lon + " ##**");
13118 remember_destination(name, Float.parseFloat(lat), Float.parseFloat(lon));
13119 }
13120 catch (Exception e)
13121 {
13122 e.printStackTrace();
13123 }
13124 }
13125
13126 static void remember_destination(String name, float lat, float lon)
13127 {
13128 //System.out.println("11 **## " + name + " " + lat + " " + lon + " ##**");
13129 Navit_Point_on_Map t = new Navit_Point_on_Map();
13130 t.point_name = name;
13131 t.lat = lat;
13132 t.lon = lon;
13133 add_map_point(t);
13134 }
13135
13136 static void destination_set()
13137 {
13138 // status = "destination set"
13139 NavitGraphics.navit_route_status = 1;
13140 }
13141
13142 static Boolean check_dup_destination(Navit_Point_on_Map element)
13143 {
13144 Boolean ret = false;
13145 Navit_Point_on_Map t;
13146 for (int i = 0; i < map_points.size(); i++)
13147 {
13148 t = map_points.get(i);
13149 if (t.addon == null)
13150 {
13151 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
13152 {
13153 return true;
13154 }
13155 }
13156 else
13157 {
13158 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
13159 {
13160 return true;
13161 }
13162 }
13163 }
13164 return ret;
13165 }
13166
13167 static int get_destination_pos(Navit_Point_on_Map element)
13168 {
13169 int ret = -1;
13170 Navit_Point_on_Map t;
13171 for (int i = 0; i < map_points.size(); i++)
13172 {
13173 t = map_points.get(i);
13174 if (t.addon == null)
13175 {
13176 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (element.addon == null))
13177 {
13178 return i;
13179 }
13180 }
13181 else
13182 {
13183 if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon) && (t.addon.equals(element.addon)))
13184 {
13185 return i;
13186 }
13187 }
13188 }
13189 return ret;
13190 }
13191
13192 static boolean is_home_element(Navit_Point_on_Map element)
13193 {
13194 int home_id = find_home_point();
13195 if (home_id != -1)
13196 {
13197 Navit_Point_on_Map home_element = map_points.get(home_id);
13198
13199 if ((home_element.point_name.equals(element.point_name)) && (home_element.lat == element.lat) && (home_element.lon == element.lon))
13200 {
13201 return true;
13202 }
13203
13204 }
13205
13206 return false;
13207 }
13208
13209 static NavitSpeech2 get_speech_object()
13210 {
13211 System.out.println("get_speech_object");
13212 return NSp;
13213 }
13214
13215 static NavitVehicle get_vehicle_object()
13216 {
13217 System.out.println("get_vehicle_object");
13218 return NV;
13219 }
13220
13221 static NavitGraphics get_graphics_object_by_name(String name)
13222 {
13223 System.out.println("get_graphics_object_by_name:*" + name + "*");
13224
13225 if (name.equals("type:map-main"))
13226 {
13227 System.out.println("map-main");
13228 return NG__map_main;
13229 }
13230 else
13231 {
13232 System.out.println("vehicle");
13233 return NG__vehicle;
13234 }
13235 }
13236
13237 public static Handler vehicle_handler = new Handler()
13238 {
13239 public void handleMessage(Message msg)
13240 {
13241 //System.out.println("vehicle_handler:handleMessage:JTHREAD ID=" + Thread.currentThread().getId());
13242 //System.out.println("vehicle_handler:handleMessage:THREAD ID=" + NavitGraphics.GetThreadId());
13243
13244 switch (msg.what)
13245 {
13246 case 1:
13247 Location l = new Location("Network");
13248 l.setLatitude(msg.getData().getFloat("lat"));
13249 l.setLongitude(msg.getData().getFloat("lng"));
13250 l.setBearing(msg.getData().getFloat("b"));
13251 l.setSpeed(0.8f);
13252 NavitVehicle.set_mock_location__fast(l);
13253 break;
13254 case 2:
13255 if (NavitVehicle.update_location_in_progress)
13256 {
13257 }
13258 else
13259 {
13260 NavitVehicle.update_location_in_progress = true;
13261 NavitVehicle.VehicleCallback2(NavitVehicle.last_location);
13262 NavitVehicle.update_location_in_progress = false;
13263 }
13264 break;
13265 }
13266 }
13267 };
13268
13269 public String roundTwoDecimals(double d)
13270 {
13271 return String.format(Locale.US, "%.2f", d);
13272 }
13273
13274 /* ZZ GEO TRANS ZZ */
13275 static double __EARTH_RADIUS__ = 6378137.000;
13276 static double __GEO_ACCURACY_FACTOR__ = 2.000;
13277 final static double M_PI_div_360 = 0.008726646259971647884618;
13278 final static double M_PI_div_180 = 0.01745329251994329576;
13279 final static double M_PI_mul_360 = 1130.97335529232556584560;
13280 final static double M_PI_mul_180 = 565.48667764616278292280;
13281
13282 /* ZZ GEO TRANS ZZ */
13283
13284 public static int transform_from_geo_lat(double lat)
13285 {
13286 /* ZZ GEO TRANS ZZ */
13287 int ret = (int) ((Math.log(Math.tan((Math.PI / 4f) + lat * M_PI_div_360)) * __EARTH_RADIUS__) * __GEO_ACCURACY_FACTOR__);
13288 return ret;
13289 }
13290
13291 public static int transform_from_geo_lon(double lon)
13292 {
13293 /* ZZ GEO TRANS ZZ */
13294 int ret = (int) ((lon * __EARTH_RADIUS__ * M_PI_div_180) * __GEO_ACCURACY_FACTOR__);
13295
13296 return ret;
13297 }
13298
13299 public static double transform_to_geo_lat(float y) // y
13300 {
13301 /* ZZ GEO TRANS ZZ */
13302 return (Math.atan(Math.exp((y / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__)) / M_PI_div_360 - 90);
13303 }
13304
13305 public static double transform_to_geo_lon(float x) // x
13306 {
13307 /* ZZ GEO TRANS ZZ */
13308 return ((x / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__ / M_PI_div_180);
13309 }
13310
13311 public static boolean allow_use_index_search()
13312 {
13313 if ((!Navit_DonateVersion_Installed) && (!Navit_Largemap_DonateVersion_Installed))
13314 {
13315 // no donate version installed
13316 Log.e("Navit", "no donate version installed");
13317
13318 Navit_index_on_but_no_idx_files = false;
13319 return false;
13320 }
13321 else
13322 {
13323 Log.e("Navit", "donate version IS installed");
13324 }
13325
13326 boolean ret = false;
13327
13328 // MAP_FILENAME_PATH
13329 File folder = new File(MAP_FILENAME_PATH);
13330 File[] listOfFiles = folder.listFiles();
13331 File idx = null;
13332 File md5_file = null;
13333 FileOutputStream fos = null;
13334
13335 int files = 0;
13336 int file_without_index = 0;
13337
13338 for (File file : listOfFiles)
13339 {
13340 if (file.isFile())
13341 {
13342 // System.out.println("FFNN:" + file.getName());
13343
13344 if (file.getName().endsWith(".bin"))
13345 {
13346 if (!file.getName().equals("borders.bin"))
13347 {
13348 if (!file.getName().equals("coastline.bin"))
13349 {
13350 files++;
13351 idx = new File(folder, file.getName() + ".idx");
13352 if (idx.exists())
13353 {
13354 }
13355 else
13356 {
13357 file_without_index++;
13358
13359 String servername = "";
13360 try
13361 {
13362 servername = NavitMapDownloader.is_in_cat_file_disk_name(file.getName()).split(":", 2)[1];
13363 }
13364 catch (Exception ee)
13365 {
13366 }
13367
13368 if (!servername.equals(""))
13369 {
13370
13371 // index for this map is missing. hack MD5 file so we can download it again
13372 md5_file = new File(Navit.MAPMD5_FILENAME_PATH + "/" + servername + ".md5");
13373
13374 System.out.println("FFNN:hack MD5:" + md5_file.getAbsolutePath() + " s=" + servername);
13375
13376 if ((md5_file.exists()) && (md5_file.canWrite()))
13377 {
13378 try
13379 {
13380 fos = new FileOutputStream(md5_file);
13381 fos.write(65);
13382 fos.write(65);
13383 fos.write(65);
13384 fos.close();
13385 }
13386 catch (Exception e1)
13387 {
13388 // System.out.println("FFNN:EEEEEEEEEEEEEE");
13389 }
13390 }
13391 }
13392 }
13393 }
13394 }
13395 }
13396
13397 if (file.getName().endsWith(".bin.idx"))
13398 {
13399 ret = true;
13400 }
13401 }
13402 }
13403
13404 if (files > 0)
13405 {
13406 if (file_without_index > 0)
13407 {
13408 Navit_index_on_but_no_idx_files = true;
13409 }
13410 else
13411 {
13412 Navit_index_on_but_no_idx_files = false;
13413 }
13414 }
13415
13416 return ret;
13417 }
13418
13419 private void sendEmail(String recipient, String subject, String message)
13420 {
13421 try
13422 {
13423 final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
13424 emailIntent.setType("plain/text");
13425 if (recipient != null) emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { recipient });
13426 if (subject != null) emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
13427 if (message != null) emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
13428
13429 startActivity(Intent.createChooser(emailIntent, Navit.get_text("Send feedback via email ...")));
13430
13431 }
13432 catch (ActivityNotFoundException e)
13433 {
13434 // cannot send email for some reason
13435 }
13436 }
13437
13438 @SuppressLint("NewApi")
13439 void detect_menu_button()
13440 {
13441 // default: we dont have a real menu button
13442 has_hw_menu_button = false;
13443
13444 try
13445 {
13446 if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 14)
13447 {
13448 if (ViewConfiguration.get(getApplicationContext()).hasPermanentMenuKey())
13449 {
13450 has_hw_menu_button = true;
13451 }
13452 else
13453 {
13454 has_hw_menu_button = false;
13455 }
13456 }
13457 else
13458 {
13459 has_hw_menu_button = true;
13460 }
13461 }
13462 catch (Exception e)
13463 {
13464 // on error we must be on android API < 14 and therfore we have a menu button (that is what we assume)
13465 has_hw_menu_button = true;
13466 }
13467
13468 // now always show menu button icon
13469 has_hw_menu_button = false;
13470 }
13471
13472 public void onBackPressed()
13473 {
13474 // do something on back.
13475 //System.out.println("no back key!");
13476 // super.onBackPressed();
13477 // !!disable the back key otherwise!!
13478
13479 if (Navit_doubleBackToExitPressedOnce)
13480 {
13481
13482 try
13483 {
13484 if (wl_navigating != null)
13485 {
13486 //if (wl_navigating.isHeld())
13487 //{
13488 wl_navigating.release();
13489 Log.e("Navit", "WakeLock Nav: release 1");
13490 //}
13491 }
13492 }
13493 catch (Exception e)
13494 {
13495 e.printStackTrace();
13496 }
13497
13498 // super.onBackPressed(); --> this would only put the app in background
13499 // --------
13500 // exit the app here
13501 this.onPause();
13502 this.onStop();
13503 this.exit();
13504 // --------
13505 return;
13506 }
13507
13508 try
13509 {
13510 Navit_doubleBackToExitPressedOnce = true;
13511 Toast.makeText(this, Navit.get_text("Please press BACK again to Exit"), Toast.LENGTH_SHORT).show();
13512
13513 new Handler().postDelayed(new Runnable()
13514 {
13515 @Override
13516 public void run()
13517 {
13518 Navit_doubleBackToExitPressedOnce = false;
13519 }
13520 }, NAVIT_BACKBUTTON_TO_EXIT_TIME);
13521 }
13522 catch (Exception e)
13523 {
13524 }
13525
13526 try
13527 {
13528 // if bottom bar is up, animate it down on "back" press
13529 animate_bottom_bar_down();
13530 }
13531 catch (Exception e)
13532 {
13533 }
13534
13535 }
13536
13537 // public void openOptionsMenu_wrapper()
13538 // {
13539 // //openOptionsMenu();
13540 //
13541 // prepare_emu_options_menu();
13542 // NavitGraphics.emu_menu_view.set_adapter(EmulatedMenuView.MenuItemsList2, EmulatedMenuView.MenuItemsIdMapping2);
13543 // NavitGraphics.emu_menu_view.bringToFront();
13544 // NavitGraphics.emu_menu_view.setVisibility(View.VISIBLE);
13545 // }
13546
13547 public static String logHeap(Class clazz)
13548 {
13549 Double allocated = Double.valueOf(Debug.getNativeHeapAllocatedSize()) / Double.valueOf((1048576));
13550 Double sum_size = Double.valueOf(Debug.getNativeHeapSize() / Double.valueOf(1048576.0));
13551 Double free = Double.valueOf(Debug.getNativeHeapFreeSize() / Double.valueOf(1048576.0));
13552 DecimalFormat df = new DecimalFormat();
13553 df.setMaximumFractionDigits(2);
13554 df.setMinimumFractionDigits(2);
13555
13556 // Log.d("Navit", "MemMem:DEBUG: =================================");
13557 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.", "") + "]");
13558 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)");
13559
13560 calcAvailableMemory();
13561
13562 String mem_type = "NATIVE";
13563 try
13564 {
13565 if (android.os.Build.VERSION.SDK_INT >= 11)
13566 {
13567 mem_type = "JAVA";
13568 }
13569 }
13570 catch (Exception e)
13571 {
13572 }
13573 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);
13574 }
13575
13576 public static String logHeap_for_batch(Class clazz)
13577 {
13578 try
13579 {
13580 Double allocated = Double.valueOf(Debug.getNativeHeapAllocatedSize()) / Double.valueOf((1048576));
13581 Double sum_size = Double.valueOf(Debug.getNativeHeapSize() / Double.valueOf(1048576.0));
13582 Double free = Double.valueOf(Debug.getNativeHeapFreeSize() / Double.valueOf(1048576.0));
13583 DecimalFormat df = new DecimalFormat();
13584 df.setMaximumFractionDigits(2);
13585 df.setMinimumFractionDigits(2);
13586
13587 // Log.d("Navit", "MemMem:DEBUG: =================================");
13588 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.", "") + "]");
13589 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)");
13590
13591 // calcAvailableMemory();
13592
13593 String mem_type = "NATIVE";
13594 try
13595 {
13596 if (android.os.Build.VERSION.SDK_INT >= 11)
13597 {
13598 mem_type = "JAVA";
13599 }
13600 }
13601 catch (Exception e)
13602 {
13603 }
13604 // 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);
13605 return ("==MEM==:" + "J:" + (Double.valueOf(Runtime.getRuntime().totalMemory() / 1048576)) + ":" + (Double.valueOf(Runtime.getRuntime().maxMemory() / 1048576)) + ",N:" + allocated + ":" + sum_size);
13606 }
13607 catch (Exception e2)
13608 {
13609 return ("==MEM==:ERROR");
13610 }
13611 }
13612
13613 private static long calcAvailableMemory()
13614 {
13615 try
13616 {
13617 long value = Runtime.getRuntime().maxMemory();
13618 String type = "";
13619 if (android.os.Build.VERSION.SDK_INT >= 11)
13620 {
13621 value = (value / 1024 / 1024) - (Runtime.getRuntime().totalMemory() / 1024 / 1024);
13622 type = "JAVA";
13623 }
13624 else
13625 {
13626 value = (value / 1024 / 1024) - (Debug.getNativeHeapAllocatedSize() / 1024 / 1024);
13627 type = "NATIVE";
13628 }
13629 Log.i("Navit", "avail.mem size=" + value + "MB, type=" + type);
13630 return value;
13631 }
13632 catch (Exception e)
13633 {
13634 return 0L;
13635 }
13636 }
13637
13638 public void google_online_search_and_set_destination(String address_string)
13639 {
13640 // online googlemaps search
13641 // String addressInput = filter_bad_chars(address_string);
13642 String addressInput = address_string;
13643 try
13644 {
13645 List<Address> foundAdresses = Navit.Navit_Geocoder.getFromLocationName(addressInput, 1); //Search addresses
13646 //System.out.println("found " + foundAdresses.size() + " results");
13647 //System.out.println("addr=" + foundAdresses.get(0).getLatitude() + " " + foundAdresses.get(0).getLongitude() + "" + foundAdresses.get(0).getAddressLine(0));
13648
13649 int results_step = 0;
13650 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
13651 tmp_addr.result_type = "STR";
13652 tmp_addr.item_id = "0";
13653 tmp_addr.lat = (float) foundAdresses.get(results_step).getLatitude();
13654 tmp_addr.lon = (float) foundAdresses.get(results_step).getLongitude();
13655 tmp_addr.addr = "";
13656
13657 String c_code = foundAdresses.get(results_step).getCountryCode();
13658 if (c_code != null)
13659 {
13660 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getCountryCode() + ",";
13661 }
13662
13663 String p_code = foundAdresses.get(results_step).getPostalCode();
13664 if (p_code != null)
13665 {
13666 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getPostalCode() + " ";
13667 }
13668
13669 if (foundAdresses.get(results_step).getMaxAddressLineIndex() > -1)
13670 {
13671 for (int addr_line = 0; addr_line < foundAdresses.get(results_step).getMaxAddressLineIndex(); addr_line++)
13672 {
13673 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
13674 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
13675 }
13676 }
13677
13678 // // DEBUG: clear route rectangle list
13679 // NavitGraphics.route_rects.clear();
13680 //
13681 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
13682 //
13683 // try
13684 // {
13685 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
13686 // // save points
13687 // write_map_points();
13688 // }
13689 // catch (Exception e)
13690 // {
13691 // e.printStackTrace();
13692 // }
13693 //
13694 // if (NavitGraphics.navit_route_status == 0)
13695 // {
13696 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13697 // Navit.destination_set();
13698 //
13699 // Message msg = new Message();
13700 // Bundle b = new Bundle();
13701 // b.putInt("Callback", 3);
13702 // b.putString("lat", String.valueOf(tmp_addr.lat));
13703 // b.putString("lon", String.valueOf(tmp_addr.lon));
13704 // b.putString("q", tmp_addr.addr);
13705 // msg.setData(b);
13706 // NavitGraphics.callback_handler.sendMessage(msg);
13707 // }
13708 // else
13709 // {
13710 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13711 // Message msg = new Message();
13712 // Bundle b = new Bundle();
13713 // b.putInt("Callback", 48);
13714 // b.putString("lat", String.valueOf(tmp_addr.lat));
13715 // b.putString("lon", String.valueOf(tmp_addr.lon));
13716 // b.putString("q", tmp_addr.addr);
13717 // msg.setData(b);
13718 // NavitGraphics.callback_handler.sendMessage(msg);
13719 // }
13720
13721 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
13722
13723 // ---------- DEBUG: write route to file ----------
13724 // ---------- DEBUG: write route to file ----------
13725 // ---------- DEBUG: write route to file ----------
13726 if (p.PREF_enable_debug_write_gpx)
13727 {
13728 write_route_to_gpx_file();
13729 }
13730 // ---------- DEBUG: write route to file ----------
13731 // ---------- DEBUG: write route to file ----------
13732
13733 try
13734 {
13735 Navit.follow_button_on();
13736 }
13737 catch (Exception e2)
13738 {
13739 e2.printStackTrace();
13740 }
13741
13742 show_geo_on_screen(tmp_addr.lat, tmp_addr.lon);
13743
13744 }
13745 catch (Exception e)
13746 {
13747 e.printStackTrace();
13748 Toast.makeText(getApplicationContext(), Navit.get_text("google search API is not working at this moment, try offline search"), Toast.LENGTH_SHORT).show();
13749 }
13750 }
13751
13752 public void result_set_destination(double lat, double lon, String addr)
13753 {
13754 try
13755 {
13756 int results_step = 0;
13757 Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
13758 tmp_addr.result_type = "STR";
13759 tmp_addr.item_id = "0";
13760 tmp_addr.lat = (float) lat;
13761 tmp_addr.lon = (float) lon;
13762 tmp_addr.addr = addr;
13763
13764 // // DEBUG: clear route rectangle list
13765 // NavitGraphics.route_rects.clear();
13766 //
13767 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
13768 //
13769 // try
13770 // {
13771 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
13772 // // save points
13773 // write_map_points();
13774 // }
13775 // catch (Exception e)
13776 // {
13777 // e.printStackTrace();
13778 // }
13779 //
13780 // if (NavitGraphics.navit_route_status == 0)
13781 // {
13782 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13783 // Navit.destination_set();
13784 //
13785 // Message msg = new Message();
13786 // Bundle b = new Bundle();
13787 // b.putInt("Callback", 3);
13788 // b.putString("lat", String.valueOf(tmp_addr.lat));
13789 // b.putString("lon", String.valueOf(tmp_addr.lon));
13790 // b.putString("q", tmp_addr.addr);
13791 // msg.setData(b);
13792 // NavitGraphics.callback_handler.sendMessage(msg);
13793 // }
13794 // else
13795 // {
13796 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
13797 // Message msg = new Message();
13798 // Bundle b = new Bundle();
13799 // b.putInt("Callback", 48);
13800 // b.putString("lat", String.valueOf(tmp_addr.lat));
13801 // b.putString("lon", String.valueOf(tmp_addr.lon));
13802 // b.putString("q", tmp_addr.addr);
13803 // msg.setData(b);
13804 // NavitGraphics.callback_handler.sendMessage(msg);
13805 // }
13806
13807 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
13808
13809 try
13810 {
13811 Navit.follow_button_on();
13812 }
13813 catch (Exception e2)
13814 {
13815 e2.printStackTrace();
13816 }
13817
13818 // ---------- DEBUG: write route to file ----------
13819 // ---------- DEBUG: write route to file ----------
13820 // ---------- DEBUG: write route to file ----------
13821 if (p.PREF_enable_debug_write_gpx)
13822 {
13823 write_route_to_gpx_file();
13824 }
13825 // ---------- DEBUG: write route to file ----------
13826 // ---------- DEBUG: write route to file ----------
13827
13828 show_geo_on_screen(tmp_addr.lat, tmp_addr.lon);
13829
13830 }
13831 catch (Exception e)
13832 {
13833 e.printStackTrace();
13834 Toast.makeText(getApplicationContext(), Navit.get_text("google search API is not working at this moment, try offline search"), Toast.LENGTH_SHORT).show();
13835 }
13836 }
13837
13838 void open_voice_recog_screen()
13839 {
13840 Intent ii = new Intent(this, ZANaviVoiceInput.class);
13841 this.startActivityForResult(ii, Navit.ZANaviVoiceInput_id);
13842 }
13843
13844 static void dim_screen_wrapper()
13845 {
13846 try
13847 {
13848 Message msg = Navit.Navit_progress_h.obtainMessage();
13849 Bundle b = new Bundle();
13850 msg.what = 20;
13851 msg.setData(b);
13852 Navit.Navit_progress_h.sendMessage(msg);
13853 }
13854 catch (Exception e)
13855 {
13856 e.printStackTrace();
13857 }
13858 }
13859
13860 static void show_status_bar_wrapper()
13861 {
13862 try
13863 {
13864 Message msg = Navit.Navit_progress_h.obtainMessage();
13865 Bundle b = new Bundle();
13866 msg.what = 27;
13867 msg.setData(b);
13868 Navit.Navit_progress_h.sendMessage(msg);
13869 }
13870 catch (Exception e)
13871 {
13872 e.printStackTrace();
13873 }
13874 }
13875
13876 static void hide_status_bar_wrapper()
13877 {
13878 try
13879 {
13880 Message msg = Navit.Navit_progress_h.obtainMessage();
13881 Bundle b = new Bundle();
13882 msg.what = 28;
13883 msg.setData(b);
13884 Navit.Navit_progress_h.sendMessage(msg);
13885 }
13886 catch (Exception e)
13887 {
13888 e.printStackTrace();
13889 }
13890 }
13891
13892 static void default_brightness_screen_wrapper()
13893 {
13894 try
13895 {
13896 Message msg = Navit.Navit_progress_h.obtainMessage();
13897 Bundle b = new Bundle();
13898 msg.what = 21;
13899 msg.setData(b);
13900 Navit.Navit_progress_h.sendMessage(msg);
13901 }
13902 catch (Exception e)
13903 {
13904 e.printStackTrace();
13905 }
13906 }
13907
13908 static void dim_screen()
13909 {
13910 try
13911 {
13912 WindowManager.LayoutParams params_wm = app_window.getAttributes();
13913 // params_wm.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
13914 params_wm.screenBrightness = 0.1f;
13915 app_window.setAttributes(params_wm);
13916 //app_window.addFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
13917 }
13918 catch (Exception e)
13919 {
13920 e.printStackTrace();
13921 }
13922 }
13923
13924 static void default_brightness_screen()
13925 {
13926 try
13927 {
13928 WindowManager.LayoutParams params_wm = app_window.getAttributes();
13929 // params_wm.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
13930 params_wm.screenBrightness = -1f;
13931 app_window.setAttributes(params_wm);
13932 //app_window.clearFlags(WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
13933 }
13934 catch (Exception e)
13935 {
13936 e.printStackTrace();
13937 }
13938 }
13939
13940 void donate_bitcoins()
13941 {
13942 try
13943 {
13944 Intent donate_activity = new Intent(this, ZANaviDonateActivity.class);
13945 // donate_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
13946 startActivity(donate_activity);
13947 }
13948 catch (Exception e)
13949 {
13950 }
13951 }
13952
13953 void donate()
13954 {
13955 try
13956 {
13957 Intent donate_activity = new Intent(this, ZANaviNormalDonateActivity.class);
13958 // donate_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
13959 startActivity(donate_activity);
13960 }
13961 catch (Exception e)
13962 {
13963 }
13964 }
13965
13966 static int debug_indent = -1;
13967 static String debug_indent_spaces = " ";
13968
13969 // type: 0 -> enter, 1 -> leave, 2 .. n -> return(#n)
13970 static void my_func_name(int type)
13971 {
13972 int debug_indent2;
13973
13974 // -- switch off !! --
13975 // -- switch off !! --
13976 debug_indent = 0;
13977 // -- switch off !! --
13978 // -- switch off !! --
13979
13980 try
13981 {
13982 StackTraceElement[] a = Thread.currentThread().getStackTrace();
13983 if (type == 0)
13984 {
13985 //debug_indent++;
13986 debug_indent2 = debug_indent;
13987 //if (debug_indent2 > debug_indent_spaces.length())
13988 //{
13989 // debug_indent2 = debug_indent_spaces.length() - 1;
13990 //}
13991 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":enter");
13992 }
13993 else if (type == 1)
13994 {
13995 debug_indent2 = debug_indent;
13996 //if (debug_indent2 > debug_indent_spaces.length())
13997 //{
13998 // debug_indent2 = debug_indent_spaces.length() - 1;
13999 //}
14000 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":leave");
14001 //debug_indent--;
14002 }
14003 else
14004 {
14005 debug_indent2 = debug_indent;
14006 //if (debug_indent2 > debug_indent_spaces.length())
14007 //{
14008 // debug_indent2 = debug_indent_spaces.length() - 1;
14009 //}
14010 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":return(" + type + ")");
14011 //debug_indent--;
14012 }
14013 }
14014 catch (Exception e)
14015 {
14016 e.printStackTrace();
14017 }
14018 }
14019
14020 // type: 0 -> enter, 1 -> leave, 2 .. n -> return(#n)
14021 static void my_func_name(int type, String msg)
14022 {
14023 int debug_indent2;
14024
14025 // -- switch off !! --
14026 // -- switch off !! --
14027 debug_indent = 0;
14028 // -- switch off !! --
14029 // -- switch off !! --
14030
14031 try
14032 {
14033 StackTraceElement[] a = Thread.currentThread().getStackTrace();
14034 if (type == 0)
14035 {
14036 //debug_indent++;
14037 debug_indent2 = debug_indent;
14038 //if (debug_indent2 > debug_indent_spaces.length())
14039 //{
14040 // debug_indent2 = debug_indent_spaces.length() - 1;
14041 //}
14042 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":enter" + ":" + msg);
14043 }
14044 else if (type == 1)
14045 {
14046 debug_indent2 = debug_indent;
14047 //if (debug_indent2 > debug_indent_spaces.length())
14048 //{
14049 // debug_indent2 = debug_indent_spaces.length() - 1;
14050 //}
14051 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":leave" + ":" + msg);
14052 //debug_indent--;
14053 }
14054 else
14055 {
14056 debug_indent2 = debug_indent;
14057 //if (debug_indent2 > debug_indent_spaces.length())
14058 //{
14059 // debug_indent2 = debug_indent_spaces.length() - 1;
14060 //}
14061 System.out.println("FUNJ:" + debug_indent_spaces.substring(0, Math.abs(2 * debug_indent2)) + "zanav:" + a[3].getClassName() + "." + a[3].getMethodName() + ":return(" + type + ")" + ":" + msg);
14062 //debug_indent--;
14063 }
14064 }
14065 catch (Exception e)
14066 {
14067 e.printStackTrace();
14068 }
14069 }
14070
14071 public static void write_route_to_gpx_file()
14072 {
14073 final Thread write_route_to_gpx_file_001 = new Thread()
14074 {
14075 int wait = 1;
14076 int count = 0;
14077 int max_count = 300; // wait 2 minutes for route to be calculated
14078
14079 @Override
14080 public void run()
14081 {
14082 while (wait == 1)
14083 {
14084 try
14085 {
14086 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
14087 {
14088 Message msg = new Message();
14089 Bundle b = new Bundle();
14090 b.putInt("Callback", 96);
14091 String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
14092 String filename = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_route_" + date + ".gpx";
14093 b.putString("s", filename);
14094 System.out.println("Debug:" + "file=" + filename);
14095 msg.setData(b);
14096 NavitGraphics.callback_handler.sendMessage(msg);
14097
14098 Message msg7 = Navit_progress_h.obtainMessage();
14099 Bundle b7 = new Bundle();
14100 msg7.what = 2; // long Toast message
14101 b7.putString("text", Navit.get_text("saving route to GPX-file") + " " + filename); //TRANS
14102 msg7.setData(b7);
14103 Navit_progress_h.sendMessage(msg7);
14104
14105 wait = 0;
14106 }
14107 else
14108 {
14109 wait = 1;
14110 }
14111
14112 count++;
14113 if (count > max_count)
14114 {
14115 wait = 0;
14116
14117 Message msg7 = Navit_progress_h.obtainMessage();
14118 Bundle b7 = new Bundle();
14119 msg7.what = 2; // long Toast message
14120 b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS
14121 msg7.setData(b7);
14122 Navit_progress_h.sendMessage(msg7);
14123 }
14124 else
14125 {
14126 Thread.sleep(400);
14127 }
14128 }
14129 catch (Exception e)
14130 {
14131 }
14132 }
14133 }
14134 };
14135 write_route_to_gpx_file_001.start();
14136 }
14137
14138 void convert_gpx_file_real(String gpx_file)
14139 {
14140 File tt2 = new File(gpx_file);
14141 p.PREF_last_selected_dir_gpxfiles = tt2.getParent();
14142 Log.e("Navit", "last_selected_dir_gpxfiles " + p.PREF_last_selected_dir_gpxfiles);
14143 setPrefs_selected_gpx_dir();
14144
14145 String out_ = MAP_FILENAME_PATH + "/gpxtracks.txt";
14146 Log.e("Navit", "onActivityResult 002 " + gpx_file + " " + out_);
14147 MainFrame.do_conversion(gpx_file, out_);
14148
14149 // draw map no-async
14150 Message msg = new Message();
14151 Bundle b = new Bundle();
14152 b.putInt("Callback", 64);
14153 msg.setData(b);
14154 NavitGraphics.callback_handler.sendMessage(msg);
14155 }
14156
14157 String intent_flags_to_string(int flags)
14158 {
14159 String ret = "(" + String.format("%#x", flags) + ") ";
14160
14161 // Intent flags
14162 final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
14163 final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
14164 final int FLAG_FROM_BACKGROUND = 0x00000004;
14165 final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
14166 final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
14167 final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
14168 final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
14169 final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
14170 final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
14171 final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
14172 final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
14173 final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
14174 final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
14175 final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
14176 final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
14177 final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
14178 final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
14179 final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
14180 final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
14181 final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
14182 final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
14183 final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
14184 final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
14185 /*
14186 * final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
14187 * final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
14188 * final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
14189 * final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x08000000;
14190 * final int FLAG_RECEIVER_BOOT_UPGRADE = 0x04000000;
14191 */
14192
14193 int first = 1;
14194 String sep = "";
14195
14196 if ((flags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
14197 {
14198 if (first == 1)
14199 {
14200 first = 0;
14201 sep = "";
14202 }
14203 else
14204 {
14205 sep = ",";
14206 }
14207 ret = ret + sep + "FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS";
14208 }
14209 if ((flags & FLAG_ACTIVITY_BROUGHT_TO_FRONT) == FLAG_ACTIVITY_BROUGHT_TO_FRONT)
14210 {
14211 if (first == 1)
14212 {
14213 first = 0;
14214 sep = "";
14215 }
14216 else
14217 {
14218 sep = ",";
14219 }
14220 ret = ret + sep + "FLAG_ACTIVITY_BROUGHT_TO_FRONT";
14221 }
14222 if ((flags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) == FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
14223 {
14224 if (first == 1)
14225 {
14226 first = 0;
14227 sep = "";
14228 }
14229 else
14230 {
14231 sep = ",";
14232 }
14233 ret = ret + sep + "FLAG_ACTIVITY_RESET_TASK_IF_NEEDED";
14234 }
14235 if ((flags & FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)
14236 {
14237 if (first == 1)
14238 {
14239 first = 0;
14240 sep = "";
14241 }
14242 else
14243 {
14244 sep = ",";
14245 }
14246 ret = ret + sep + "FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY";
14247 }
14248 if ((flags & FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) == FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
14249 {
14250 if (first == 1)
14251 {
14252 first = 0;
14253 sep = "";
14254 }
14255 else
14256 {
14257 sep = ",";
14258 }
14259 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET";
14260 }
14261 if ((flags & FLAG_ACTIVITY_NO_USER_ACTION) == FLAG_ACTIVITY_NO_USER_ACTION)
14262 {
14263 if (first == 1)
14264 {
14265 first = 0;
14266 sep = "";
14267 }
14268 else
14269 {
14270 sep = ",";
14271 }
14272 ret = ret + sep + "FLAG_ACTIVITY_NO_USER_ACTION";
14273 }
14274 if ((flags & FLAG_ACTIVITY_REORDER_TO_FRONT) == FLAG_ACTIVITY_REORDER_TO_FRONT)
14275 {
14276 if (first == 1)
14277 {
14278 first = 0;
14279 sep = "";
14280 }
14281 else
14282 {
14283 sep = ",";
14284 }
14285 ret = ret + sep + "FLAG_ACTIVITY_REORDER_TO_FRONT";
14286 }
14287 if ((flags & FLAG_ACTIVITY_NO_ANIMATION) == FLAG_ACTIVITY_NO_ANIMATION)
14288 {
14289 if (first == 1)
14290 {
14291 first = 0;
14292 sep = "";
14293 }
14294 else
14295 {
14296 sep = ",";
14297 }
14298 ret = ret + sep + "FLAG_ACTIVITY_NO_ANIMATION";
14299 }
14300 if ((flags & FLAG_ACTIVITY_CLEAR_TASK) == FLAG_ACTIVITY_CLEAR_TASK)
14301 {
14302 if (first == 1)
14303 {
14304 first = 0;
14305 sep = "";
14306 }
14307 else
14308 {
14309 sep = ",";
14310 }
14311 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_TASK";
14312 }
14313 if ((flags & FLAG_ACTIVITY_TASK_ON_HOME) == FLAG_ACTIVITY_TASK_ON_HOME)
14314 {
14315 if (first == 1)
14316 {
14317 first = 0;
14318 sep = "";
14319 }
14320 else
14321 {
14322 sep = ",";
14323 }
14324 ret = ret + sep + "FLAG_ACTIVITY_TASK_ON_HOME";
14325 }
14326
14327 if ((flags & FLAG_GRANT_READ_URI_PERMISSION) == FLAG_GRANT_READ_URI_PERMISSION)
14328 {
14329 if (first == 1)
14330 {
14331 first = 0;
14332 sep = "";
14333 }
14334 else
14335 {
14336 sep = ",";
14337 }
14338 ret = ret + sep + "FLAG_GRANT_READ_URI_PERMISSION";
14339 }
14340
14341 if ((flags & FLAG_GRANT_WRITE_URI_PERMISSION) == FLAG_GRANT_WRITE_URI_PERMISSION)
14342 {
14343 if (first == 1)
14344 {
14345 first = 0;
14346 sep = "";
14347 }
14348 else
14349 {
14350 sep = ",";
14351 }
14352 ret = ret + sep + "FLAG_GRANT_WRITE_URI_PERMISSION";
14353 }
14354
14355 if ((flags & FLAG_FROM_BACKGROUND) == FLAG_FROM_BACKGROUND)
14356 {
14357 if (first == 1)
14358 {
14359 first = 0;
14360 sep = "";
14361 }
14362 else
14363 {
14364 sep = ",";
14365 }
14366 ret = ret + sep + "FLAG_FROM_BACKGROUND";
14367 }
14368 if ((flags & FLAG_DEBUG_LOG_RESOLUTION) == FLAG_DEBUG_LOG_RESOLUTION)
14369 {
14370 if (first == 1)
14371 {
14372 first = 0;
14373 sep = "";
14374 }
14375 else
14376 {
14377 sep = ",";
14378 }
14379 ret = ret + sep + "FLAG_DEBUG_LOG_RESOLUTION";
14380 }
14381 if ((flags & FLAG_EXCLUDE_STOPPED_PACKAGES) == FLAG_EXCLUDE_STOPPED_PACKAGES)
14382 {
14383 if (first == 1)
14384 {
14385 first = 0;
14386 sep = "";
14387 }
14388 else
14389 {
14390 sep = ",";
14391 }
14392 ret = ret + sep + "FLAG_EXCLUDE_STOPPED_PACKAGES";
14393 }
14394 if ((flags & FLAG_INCLUDE_STOPPED_PACKAGES) == FLAG_INCLUDE_STOPPED_PACKAGES)
14395 {
14396 if (first == 1)
14397 {
14398 first = 0;
14399 sep = "";
14400 }
14401 else
14402 {
14403 sep = ",";
14404 }
14405 ret = ret + sep + "FLAG_INCLUDE_STOPPED_PACKAGES";
14406 }
14407 if ((flags & FLAG_ACTIVITY_NO_HISTORY) == FLAG_ACTIVITY_NO_HISTORY)
14408 {
14409 if (first == 1)
14410 {
14411 first = 0;
14412 sep = "";
14413 }
14414 else
14415 {
14416 sep = ",";
14417 }
14418 ret = ret + sep + "FLAG_ACTIVITY_NO_HISTORY";
14419 }
14420 if ((flags & FLAG_ACTIVITY_SINGLE_TOP) == FLAG_ACTIVITY_SINGLE_TOP)
14421 {
14422 if (first == 1)
14423 {
14424 first = 0;
14425 sep = "";
14426 }
14427 else
14428 {
14429 sep = ",";
14430 }
14431 ret = ret + sep + "FLAG_ACTIVITY_SINGLE_TOP";
14432 }
14433 if ((flags & FLAG_ACTIVITY_NEW_TASK) == FLAG_ACTIVITY_NEW_TASK)
14434 {
14435 if (first == 1)
14436 {
14437 first = 0;
14438 sep = "";
14439 }
14440 else
14441 {
14442 sep = ",";
14443 }
14444 ret = ret + sep + "FLAG_ACTIVITY_NEW_TASK";
14445 }
14446 if ((flags & FLAG_ACTIVITY_MULTIPLE_TASK) == FLAG_ACTIVITY_MULTIPLE_TASK)
14447 {
14448 if (first == 1)
14449 {
14450 first = 0;
14451 sep = "";
14452 }
14453 else
14454 {
14455 sep = ",";
14456 }
14457 ret = ret + sep + "FLAG_ACTIVITY_MULTIPLE_TASK";
14458 }
14459 if ((flags & FLAG_ACTIVITY_CLEAR_TOP) == FLAG_ACTIVITY_CLEAR_TOP)
14460 {
14461 if (first == 1)
14462 {
14463 first = 0;
14464 sep = "";
14465 }
14466 else
14467 {
14468 sep = ",";
14469 }
14470 ret = ret + sep + "FLAG_ACTIVITY_CLEAR_TOP";
14471 }
14472 if ((flags & FLAG_ACTIVITY_FORWARD_RESULT) == FLAG_ACTIVITY_FORWARD_RESULT)
14473 {
14474 if (first == 1)
14475 {
14476 first = 0;
14477 sep = "";
14478 }
14479 else
14480 {
14481 sep = ",";
14482 }
14483 ret = ret + sep + "FLAG_ACTIVITY_FORWARD_RESULT";
14484 }
14485 if ((flags & FLAG_ACTIVITY_PREVIOUS_IS_TOP) == FLAG_ACTIVITY_PREVIOUS_IS_TOP)
14486 {
14487 if (first == 1)
14488 {
14489 first = 0;
14490 sep = "";
14491 }
14492 else
14493 {
14494 sep = ",";
14495 }
14496 ret = ret + sep + "FLAG_ACTIVITY_PREVIOUS_IS_TOP";
14497 }
14498
14499 return ret;
14500 }
14501
14502 static boolean want_tunnel_extrapolation()
14503 {
14504 if ((!isGPSFix) && (pos_is_underground == 1) && (NavitGraphics.CallbackDestinationValid2() > 0))
14505 {
14506 // gps fix is lost
14507 // and
14508 // our position is underground
14509 // and
14510 // we have a destination set
14511 //
14512 // --> we want tunnel extrapolation
14513 return true;
14514 }
14515
14516 return false;
14517 }
14518
14519 public static void applySharedTheme(Activity act, int Theme_id)
14520 {
14521 act.setTheme(Theme_id);
14522 }
14523
14524 private com.zoffcc.applications.zanavi_msg.ZListener.Stub zclientListener = new com.zoffcc.applications.zanavi_msg.ZListener.Stub()
14525 {
14526 @Override
14527 public String handleUpdated(String data) throws RemoteException
14528 {
14529 // Log.i("NavitPlugin", "update from Plugin=" + data);
14530 return "Navit says:\"PONG\"";
14531 }
14532 };
14533
14534 static Object sync_plugin_send = new Object();
14535
14536 public static void send_data_to_plugin_bg(final int msg_cat, final String data)
14537 {
14538 // send data to plugin (plugin will send to server) in another task! --------------------------
14539 new AsyncTask<Void, Void, String>()
14540 {
14541 @Override
14542 protected String doInBackground(Void... params)
14543 {
14544 synchronized (sync_plugin_send)
14545 {
14546 try
14547 {
14548 if (plugin_api == null)
14549 {
14550 try
14551 {
14552 Thread.sleep(3000); // wait until the service is bound
14553 }
14554 catch (Exception e)
14555 {
14556 }
14557 }
14558
14559 String response = plugin_api.getResult(PLUGIN_MSG_ID, msg_cat, data);
14560
14561 }
14562 catch (RemoteException e)
14563 {
14564 // Log.e("NavitPlugin", "Failed(1) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14565 }
14566 catch (Exception e)
14567 {
14568 // Log.e("NavitPlugin", "Failed(2) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14569 }
14570 }
14571 return "";
14572 }
14573
14574 @Override
14575 protected void onPostExecute(String msg)
14576 {
14577
14578 }
14579 }.execute(null, null, null);
14580 // send data to plugin (plugin will send to server) in another task! --------------------------
14581 }
14582
14583 private ServiceConnection serviceConnection = new ServiceConnection()
14584 {
14585 @Override
14586 public void onServiceConnected(ComponentName name, IBinder service)
14587 {
14588 Log.i("NavitPlugin", "Service connection established");
14589
14590 // that's how we get the client side of the IPC connection
14591 plugin_api = ZanaviCloudApi.Stub.asInterface((IBinder) service);
14592 try
14593 {
14594 plugin_api.addListener(zclientListener);
14595 }
14596 catch (RemoteException e)
14597 {
14598 Log.e("NavitPlugin", "Failed(1) to add listener", e);
14599 }
14600 catch (Exception e)
14601 {
14602 Log.e("NavitPlugin", "Failed(2) to add listener", e);
14603 }
14604
14605 send_installed_maps_to_plugin();
14606 send_data_to_plugin_bg(PLUGIN_MSG_CAT_zanavi_version, Navit.NavitAppVersion);
14607 }
14608
14609 @Override
14610 public void onServiceDisconnected(ComponentName name)
14611 {
14612 plugin_api = null;
14613 Log.i("NavitPlugin", "Service connection closed");
14614 }
14615 };
14616
14617 /**
14618 * send installed maps and download date/time (time up to minute) in UTC to plugin
14619 */
14620 static void send_installed_maps_to_plugin()
14621 {
14622 try
14623 {
14624 /*
14625 * { "201502032311":"austria.bin","201502032312":"germany.bin" }
14626 */
14627
14628 String data = "";
14629
14630 // dirty hardcode JSON data struct
14631 final String maps_and_timestamp_data_start = "{ \"";
14632 final String maps_and_timestamp_data_sep1 = "\":\"";
14633 final String maps_and_timestamp_data_sep2 = "\",\"";
14634 final String maps_and_timestamp_data_end = "\" }";
14635
14636 NavitMapDownloader.init_cat_file_maps_timestamps();
14637
14638 data = data + maps_and_timestamp_data_start;
14639
14640 String map_name = "";
14641 Iterator<String> k = NavitMapDownloader.map_catalogue_date.listIterator();
14642 while (k.hasNext())
14643 {
14644 map_name = k.next();
14645 data = data + map_name.split(":", 2)[1];
14646 data = data + maps_and_timestamp_data_sep1;
14647 data = data + map_name.split(":", 2)[0];
14648 if (k.hasNext())
14649 {
14650 data = data + maps_and_timestamp_data_sep2;
14651 }
14652 }
14653 data = data + maps_and_timestamp_data_end;
14654
14655 // System.out.println("PLUGIN:MAPS:" + data);
14656
14657 send_data_to_plugin_bg(PLUGIN_MSG_CAT_installed_maps, data);
14658 }
14659 catch (Exception e)
14660 {
14661 }
14662 }
14663
14664 static boolean have_maps_installed()
14665 {
14666 int count_maps_installed = NavitMapDownloader.cat_file_maps_have_installed_any();
14667 if (count_maps_installed == 0)
14668 {
14669 return false;
14670 }
14671 else
14672 {
14673 return true;
14674 }
14675 }
14676
14677 /**
14678 * auto start map download/update
14679 *
14680 * @param map_name
14681 * mapfilename with ending ".bin"
14682 */
14683 void auto_start_update_map(String map_name)
14684 {
14685
14686 int count = NavitMapDownloader.z_OSM_MAPS.length;
14687 Navit.download_map_id = -1;
14688 for (int i = 0; i < count; i++)
14689 {
14690 if (!NavitMapDownloader.z_OSM_MAPS[i].is_continent)
14691 {
14692 // System.out.println("mmm1=" + NavitMapDownloader.z_OSM_MAPS[i].url);
14693 if (NavitMapDownloader.z_OSM_MAPS[i].url.equals(map_name))
14694 {
14695 Navit.download_map_id = i;
14696 System.out.println("mMM2=" + NavitMapDownloader.z_OSM_MAPS[i].map_name);
14697 }
14698 }
14699 }
14700
14701 // show the map download progressbar, and download the map
14702 if (Navit.download_map_id > -1)
14703 {
14704 // new method in service
14705 Message msg = progress_handler.obtainMessage();
14706 Bundle b = new Bundle();
14707 msg.what = 22;
14708 progress_handler.sendMessage(msg);
14709 }
14710 }
14711
14712 void show_case_001()
14713 {
14714 // try
14715 // {
14716 // new ShowcaseView.Builder(this).setTarget(new ViewTarget(R.id.no_maps_button, this)).setContentTitle("").setContentText("").singleShot(Navit.SHOWCASEVIEW_ID_001).build();
14717 // }
14718 // catch (Exception e1)
14719 // {
14720 // }
14721 // catch (NoSuchMethodError e2)
14722 // {
14723 // }
14724 // catch (NoClassDefFoundError e3)
14725 // {
14726 // }
14727 }
14728
14729 static void set_zoom_level(int want_zoom_level)
14730 {
14731 try
14732 {
14733 Bundle b = new Bundle();
14734 Message msg = new Message();
14735 b.putInt("Callback", 33);
14736 b.putString("s", Integer.toString(want_zoom_level));
14737 msg.setData(b);
14738 NavitGraphics.callback_handler.sendMessage(msg);
14739 }
14740 catch (Exception e)
14741 {
14742 e.printStackTrace();
14743 }
14744 }
14745
14746 static void set_zoom_level_no_draw(int want_zoom_level)
14747 {
14748 try
14749 {
14750 Bundle b = new Bundle();
14751 Message msg = new Message();
14752 b.putInt("Callback", 105);
14753 b.putString("s", Integer.toString(want_zoom_level));
14754 msg.setData(b);
14755 NavitGraphics.callback_handler.sendMessage(msg);
14756 }
14757 catch (Exception e)
14758 {
14759 e.printStackTrace();
14760 }
14761 }
14762
14763 static void draw_map()
14764 {
14765 try
14766 {
14767 // draw map no-async
14768 Message msg = new Message();
14769 Bundle b = new Bundle();
14770 b.putInt("Callback", 64);
14771 msg.setData(b);
14772 NavitGraphics.callback_handler.sendMessage(msg);
14773 }
14774 catch (Exception e)
14775 {
14776 e.printStackTrace();
14777 }
14778 }
14779
14780 final static int bottom_bar_snap_duration = 190;
14781
14782 void animate_bottom_bar_up()
14783 {
14784 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
14785 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -cur_y_margin_bottom_bar_touch);
14786 animation.setDuration(bottom_bar_snap_duration); // animation duration
14787 animation.setFillAfter(true);
14788 animation.setFillEnabled(true);
14789 animation.setRepeatCount(0); // animation repeat count
14790 animation.setAnimationListener(new AnimationListener()
14791 {
14792 @Override
14793 public void onAnimationStart(Animation animation)
14794 {
14795 }
14796
14797 @Override
14798 public void onAnimationRepeat(Animation animation)
14799 {
14800 }
14801
14802 @Override
14803 public void onAnimationEnd(Animation animation)
14804 {
14805 cur_y_margin_bottom_bar_touch = 0;
14806 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14807 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14808 a.setLayoutParams(relativeParams);
14809 a.requestLayout();
14810
14811 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14812 anim.setFillAfter(true);
14813 anim.setFillEnabled(true);
14814 anim.setDuration(1);
14815 a.startAnimation(anim);
14816 }
14817 });
14818 a.startAnimation(animation);
14819 }
14820
14821 static void animate_bottom_bar_down()
14822 {
14823 final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide);
14824
14825 // System.out.println("FRAG:animate_bottom_bar_down:014");
14826
14827 // set bottom end positon correctly??
14828 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14829
14830 final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch);
14831 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); // new TranslateAnimation(xFrom,xTo, yFrom,yTo)
14832 animation.setDuration(bottom_bar_snap_duration); // animation duration
14833 animation.setFillAfter(true);
14834 animation.setFillEnabled(true);
14835 animation.setRepeatCount(0); // animation repeat count
14836 animation.setAnimationListener(new AnimationListener()
14837 {
14838
14839 @Override
14840 public void onAnimationStart(Animation animation)
14841 {
14842 }
14843
14844 @Override
14845 public void onAnimationRepeat(Animation animation)
14846 {
14847 }
14848
14849 @Override
14850 public void onAnimationEnd(Animation animation)
14851 {
14852 // set bottom end positon correctly??
14853 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14854
14855 cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch;
14856 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14857 relativeParams.setMargins(0, (int) bottom_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14858 a.setLayoutParams(relativeParams);
14859 a.requestLayout();
14860
14861 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14862 anim.setFillAfter(true);
14863 anim.setFillEnabled(true);
14864 anim.setDuration(1);
14865 a.startAnimation(anim);
14866
14867 // remove roadbook fragment -----------
14868 try
14869 {
14870 if (road_book != null)
14871 {
14872 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
14873 // System.out.println("FRAG:dettach:002");
14874 fragmentTransaction.detach(road_book);
14875 fragmentTransaction.remove(road_book).commit();
14876 road_book = null;
14877 }
14878 }
14879 catch (Exception ef)
14880 {
14881 }
14882 // remove roadbook fragment -----------
14883
14884 }
14885 });
14886 a.startAnimation(animation);
14887 }
14888
14889 synchronized static int find_max_font_size_for_height(String sample_text, int height, int max_font_size, int padding_in_dp)
14890 {
14891 String s = sample_text;
14892 int bh = 0;
14893 Paint p = new Paint();
14894 Rect bounds = new Rect();
14895 p.setTextSize(max_font_size);
14896 // p.measureText(s);
14897 p.getTextBounds(s, 0, s.length(), bounds);
14898
14899 int ret_font_size = max_font_size;
14900
14901 int loop_counter_max = 400;
14902 int loop_counter = 0;
14903 int padding_in_px = 0;
14904 if (padding_in_dp > 0)
14905 {
14906 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14907 }
14908
14909 bh = bounds.height();
14910 //System.out.println("bh(1)=" + bh);
14911 while ((bh + padding_in_px) > height)
14912 {
14913 loop_counter++;
14914 if (loop_counter > loop_counter_max)
14915 {
14916 break;
14917 }
14918
14919 ret_font_size--;
14920 p.setTextSize(ret_font_size);
14921 // p.measureText(s);
14922 p.getTextBounds(s, 0, s.length(), bounds);
14923 bh = bounds.height();
14924 }
14925
14926 return ret_font_size;
14927 }
14928
14929 synchronized static int find_max_letters_for_width_and_fontsize(String max_length_text, int width, int max_font_size, int padding_in_dp)
14930 {
14931 int ret_max_letters = 10;
14932
14933 int padding_in_px = 0;
14934 if (padding_in_dp > 0)
14935 {
14936 //System.out.println("aaa2:l:1:x:" + padding_in_dp);
14937 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14938 //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);
14939 }
14940 //System.out.println("aaa2:l:1:x:1=" + padding_in_px);
14941
14942 int c = 0;
14943 Paint p = new Paint();
14944 p.setTextSize(max_font_size);
14945
14946 String s = max_length_text;
14947
14948 if ((s == null) || (s.equals("")))
14949 {
14950 s = "Mlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwo";
14951 }
14952
14953 int l = s.length();
14954 ret_max_letters = l;
14955 float mt = p.measureText(s);
14956 //System.out.println("aaa2:l:1:" + l + " " + s);
14957 //System.out.println("aaa2:l:22:." + mt + " padding_in_px=" + padding_in_px + " " + width);
14958
14959 while (mt + padding_in_px > width)
14960 {
14961 //System.out.println("aaa2:l:22:+" + mt + " " + padding_in_px + " " + width);
14962
14963 c++;
14964 if (c == l)
14965 {
14966 // no more letters
14967 //System.out.println("aaa2:l:1:no more letters:" + l + " " + s);
14968 break;
14969 }
14970 s = s.substring(0, s.length() - 1);
14971 mt = p.measureText(s);
14972 ret_max_letters--;
14973 }
14974
14975 //System.out.println("aaa2:l:1:res=" + ret_max_letters);
14976 return ret_max_letters;
14977 }
14978
14979 synchronized static int find_max_font_size_for_width(String sample_text, int width, int max_font_size, int padding_in_dp)
14980 {
14981 final String s = sample_text;
14982 int bh = 0;
14983 Paint p = new Paint();
14984 Rect bounds = new Rect();
14985 p.setTextSize(max_font_size);
14986 p.getTextBounds(s, 0, s.length(), bounds);
14987
14988 int ret_font_size = max_font_size;
14989
14990 int loop_counter_max = 400;
14991 int loop_counter = 0;
14992 int padding_in_px = 0;
14993 if (padding_in_dp > 0)
14994 {
14995 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14996 }
14997
14998 bh = bounds.width();
14999 while ((bh + padding_in_px) > width)
15000 {
15001 loop_counter++;
15002 if (loop_counter > loop_counter_max)
15003 {
15004 break;
15005 }
15006
15007 ret_font_size--;
15008 p.setTextSize(ret_font_size);
15009 p.getTextBounds(s, 0, s.length(), bounds);
15010 bh = bounds.width();
15011 // mt = p.measureText(s);
15012 }
15013
15014 return ret_font_size;
15015 }
15016
15017 static int last_orientation = Configuration.ORIENTATION_LANDSCAPE;
15018
15019 @Override
15020 public void onConfigurationChanged(Configuration newConfig)
15021 {
15022 super.onConfigurationChanged(newConfig);
15023
15024 if (last_orientation != newConfig.orientation)
15025 {
15026 // Checks the orientation of the screen
15027 if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
15028 {
15029 // setContentView(R.layout.main_layout);
15030
15031 // -- bottom bar --
15032 int h = NavitGraphics.mCanvasHeight;
15033 try
15034 {
15035 int h001;
15036 android.view.ViewGroup.LayoutParams lp001;
15037
15038 View v003 = (View) findViewById(R.id.osd_nextturn_new);
15039 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
15040 lp001 = v003.getLayoutParams();
15041 lp001.height = h001;
15042 v003.requestLayout();
15043
15044 v003 = (View) findViewById(R.id.bottom_bar);
15045 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
15046 lp001 = v003.getLayoutParams();
15047 lp001.height = h001;
15048 v003.requestLayout();
15049
15050 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
15051 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
15052 lp001 = v002.getLayoutParams();
15053 lp001.height = h001;
15054 v002.requestLayout();
15055
15056 v003 = (View) findViewById(R.id.osd_timetodest_new);
15057 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
15058 lp001 = v003.getLayoutParams();
15059 lp001.height = h001;
15060 v003.requestLayout();
15061
15062 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
15063 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
15064 lp001 = v002.getLayoutParams();
15065 lp001.height = h001;
15066 v002.requestLayout();
15067
15068 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
15069 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
15070 lp001 = v001.getLayoutParams();
15071 lp001.height = h001;
15072 v001.requestLayout();
15073
15074 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
15075 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
15076 v003 = (View) findViewById(R.id.view_speeding);
15077 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
15078 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
15079 v003.setLayoutParams(relativeParams_001);
15080 v003.requestLayout();
15081
15082 // Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
15083
15084 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
15085 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
15086
15087 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
15088 }
15089 catch (Exception e)
15090 {
15091 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
15092 }
15093 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
15094 // -- bottom bar --
15095 }
15096 else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
15097 {
15098 // setContentView(R.layout.main_layout);
15099
15100 // -- bottom bar --
15101 int h = NavitGraphics.mCanvasHeight;
15102 try
15103 {
15104 int h001;
15105 android.view.ViewGroup.LayoutParams lp001;
15106
15107 View v003 = (View) findViewById(R.id.osd_nextturn_new);
15108 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
15109 lp001 = v003.getLayoutParams();
15110 lp001.height = h001;
15111 v003.requestLayout();
15112
15113 v003 = (View) findViewById(R.id.bottom_bar);
15114 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
15115 lp001 = v003.getLayoutParams();
15116 lp001.height = h001;
15117 v003.requestLayout();
15118
15119 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
15120 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
15121 lp001 = v002.getLayoutParams();
15122 lp001.height = h001;
15123 v002.requestLayout();
15124
15125 v003 = (View) findViewById(R.id.osd_timetodest_new);
15126 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
15127 lp001 = v003.getLayoutParams();
15128 lp001.height = h001;
15129 v003.requestLayout();
15130
15131 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
15132 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
15133 lp001 = v002.getLayoutParams();
15134 lp001.height = h001;
15135 v002.requestLayout();
15136
15137 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
15138 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
15139 lp001 = v001.getLayoutParams();
15140 lp001.height = h001;
15141 v001.requestLayout();
15142
15143 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
15144 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
15145 v003 = (View) findViewById(R.id.view_speeding);
15146 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
15147 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
15148 v003.setLayoutParams(relativeParams_001);
15149 v003.requestLayout();
15150
15151 // Toast.makeText(this, "protrait", Toast.LENGTH_SHORT).show();
15152
15153 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
15154 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
15155
15156 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
15157 }
15158 catch (Exception e)
15159 {
15160 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
15161 }
15162 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
15163 // -- bottom bar --
15164 }
15165
15166 last_orientation = newConfig.orientation;
15167 }
15168 }
15169
15170 static void long_toast(String msg)
15171 {
15172 try
15173 {
15174 Message msg7 = Navit_progress_h.obtainMessage();
15175 Bundle b7 = new Bundle();
15176 msg7.what = 2; // long Toast message
15177 b7.putString("text", msg);
15178 msg7.setData(b7);
15179 Navit_progress_h.sendMessage(msg7);
15180 }
15181 catch (Exception e)
15182 {
15183 }
15184 }
15185
15186 static void short_toast(String msg)
15187 {
15188 try
15189 {
15190 Message msg7 = Navit_progress_h.obtainMessage();
15191 Bundle b7 = new Bundle();
15192 msg7.what = 3; // short Toast message
15193 b7.putString("text", msg);
15194 msg7.setData(b7);
15195 Navit_progress_h.sendMessage(msg7);
15196 }
15197 catch (Exception e)
15198 {
15199 }
15200 }
15201
15202 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)
15203 {
15204 global_last_destination_name = NavitSpeech2.filter_out_special_chars_for_dest_string(addr);
15205 // System.out.println("HOME002:" + addr + " = " + global_last_destination_name);
15206
15207 if (p.PREF_routing_engine == 1)
15208 {
15209 route_online_OSRM(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
15210 }
15211 else if (p.PREF_routing_engine == 0)
15212 {
15213 route_offline_ZANavi(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
15214 }
15215 }
15216
15217 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)
15218 {
15219 if (remember_dest)
15220 {
15221 try
15222 {
15223 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
15224 // save points
15225 write_map_points();
15226 }
15227 catch (Exception e)
15228 {
15229 e.printStackTrace();
15230 }
15231 }
15232
15233 // DEBUG: clear route rectangle list
15234 NavitGraphics.route_rects.clear();
15235
15236 if (NavitGraphics.navit_route_status == 0)
15237 {
15238 short_toast(Navit.get_text("setting destination to") + "\n" + addr);
15239
15240 Navit.destination_set();
15241
15242 Message msg = new Message();
15243 Bundle b = new Bundle();
15244 b.putInt("Callback", 3);
15245 b.putString("lat", "" + lat_end);
15246 b.putString("lon", "" + lon_end);
15247 b.putString("q", addr);
15248 msg.setData(b);
15249 NavitGraphics.callback_handler.sendMessage(msg);
15250 }
15251 else
15252 {
15253 short_toast(Navit.get_text("new Waypoint") + "\n" + addr);
15254
15255 Message msg = new Message();
15256 Bundle b = new Bundle();
15257 b.putInt("Callback", 48);
15258 b.putString("lat", "" + lat_end);
15259 b.putString("lon", "" + lon_end);
15260 b.putString("q", addr);
15261 msg.setData(b);
15262 NavitGraphics.callback_handler.sendMessage(msg);
15263 }
15264
15265 }
15266
15267 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)
15268 {
15269 // http://router.project-osrm.org/viaroute?loc=46.3456438,17.450&loc=47.34122,17.5332&instructions=false&alt=false
15270
15271 if (!start_coords_valid)
15272 {
15273 location_coords cur_target = new location_coords();
15274 try
15275 {
15276 geo_coord tmp = get_current_vehicle_position();
15277 cur_target.lat = tmp.Latitude;
15278 cur_target.lon = tmp.Longitude;
15279 }
15280 catch (Exception e)
15281 {
15282 }
15283
15284 try
15285 {
15286 lat_start = (float) cur_target.lat;
15287 lon_start = (float) cur_target.lon;
15288 }
15289 catch (Exception e)
15290 {
15291 e.printStackTrace();
15292 Log.e("Navit", "problem with location!");
15293 }
15294 }
15295
15296 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);
15297
15298 // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
15299 // StrictMode.setThreadPolicy(policy);
15300
15301 try
15302 {
15303 // System.out.println("XML:S:001 url=" + request_url);
15304 final URL url = new URL(request_url);
15305 // System.out.println("XML:S:002");
15306 // SAXParserFactory factory = SAXParserFactory.newInstance();
15307 // System.out.println("XML:S:003");
15308 // SAXParser parser = factory.newSAXParser();
15309 // System.out.println("XML:S:004");
15310 // XMLReader xmlreader = parser.getXMLReader();
15311 // System.out.println("XML:S:005");
15312 // xmlreader.setContentHandler(new ZANaviXMLHandler());
15313 // System.out.println("XML:S:006");
15314
15315 final Thread add_to_route = new Thread()
15316 {
15317 @Override
15318 public void run()
15319 {
15320 try
15321 {
15322
15323 // --------------
15324 // --------------
15325 // --------------
15326 // ------- allow this HTTPS cert ---
15327 // --------------
15328 // --------------
15329 // --------------
15330 // X509HostnameVerifier hnv = new X509HostnameVerifier()
15331 // {
15332 //
15333 // @Override
15334 // public void verify(String hostname, SSLSocket arg1) throws IOException
15335 // {
15336 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15337 // }
15338 //
15339 // @Override
15340 // public void verify(String hostname, X509Certificate cert) throws SSLException
15341 // {
15342 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15343 // }
15344 //
15345 // @Override
15346 // public void verify(String hostname, String[] cns, String[] subjectAlts) throws SSLException
15347 // {
15348 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15349 // }
15350 //
15351 // @Override
15352 // public boolean verify(String hostname, SSLSession session)
15353 // {
15354 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
15355 // return true;
15356 // }
15357 // };
15358 //
15359 // SSLContext context = SSLContext.getInstance("TLS");
15360 // context.init(null, new X509TrustManager[] { new X509TrustManager()
15361 // {
15362 // public java.security.cert.X509Certificate[] getAcceptedIssuers()
15363 // {
15364 // return new java.security.cert.X509Certificate[0];
15365 // }
15366 //
15367 // @Override
15368 // public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
15369 // {
15370 // }
15371 //
15372 // @Override
15373 // public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
15374 // {
15375 // }
15376 // } }, new SecureRandom());
15377 // javax.net.ssl.SSLSocketFactory sslf = context.getSocketFactory();
15378 //
15379 // HostnameVerifier hnv_default = HttpsURLConnection.getDefaultHostnameVerifier();
15380 // javax.net.ssl.SSLSocketFactory sslf_default = HttpsURLConnection.getDefaultSSLSocketFactory();
15381 // HttpsURLConnection.setDefaultHostnameVerifier(hnv);
15382 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf);
15383 //
15384 // DefaultHttpClient client = new DefaultHttpClient();
15385 //
15386 // SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
15387 // SchemeRegistry registry = new SchemeRegistry();
15388 // registry.register(new Scheme("https", socketFactory, 443));
15389 // ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(client.getParams(), registry);
15390 // DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
15391 //
15392 // socketFactory.setHostnameVerifier(hnv);
15393 //
15394 // HttpGet get_request = new HttpGet(request_url);
15395 // HttpResponse http_response = httpClient.execute(get_request);
15396 // HttpEntity responseEntity = http_response.getEntity();
15397 //
15398 // HttpsURLConnection.setDefaultHostnameVerifier(hnv_default);
15399 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf_default);
15400 // --------------
15401 // --------------
15402 // --------------
15403 // ------- allow this HTTPS cert ---
15404 // --------------
15405 // --------------
15406 // --------------
15407
15408 InputSource is = new InputSource();
15409 is.setEncoding("utf-8");
15410 // is.setByteStream(responseEntity.getContent());
15411 is.setByteStream(url.openStream());
15412 // System.out.println("XML:S:007");
15413
15414 String response = slurp(is.getByteStream(), 16384);
15415 // response = response.replaceAll("&", "&amp;");
15416
15417 // System.out.println("XML:S:007.a res=" + response);
15418
15419 final JSONObject obj = new JSONObject(response);
15420
15421 // System.out.println(person.getInt("id"));
15422
15423 final String route_geometry = obj.getString("route_geometry");
15424 final JSONArray route_instructions_array = obj.getJSONArray("route_instructions");
15425
15426 int loop_i = 0;
15427 JSONArray instruction;
15428 int[] instruction_pos = new int[route_instructions_array.length()];
15429 for (loop_i = 0; loop_i < route_instructions_array.length(); loop_i++)
15430 {
15431 instruction = (JSONArray) route_instructions_array.get(loop_i);
15432 instruction_pos[loop_i] = Integer.parseInt(instruction.get(3).toString());
15433 // System.out.println("XML:instr. pos=" + instruction_pos[loop_i]);
15434 }
15435
15436 // System.out.println("XML:S:009 o=" + route_geometry);
15437
15438 List<geo_coord> gc_list = decode_function(route_geometry, 6);
15439
15440 if (gc_list.size() < 2)
15441 {
15442 // no real route found!! (only 1 point)
15443 }
15444 else
15445 {
15446
15447 Message msg = new Message();
15448 Bundle b = new Bundle();
15449
15450 int loop = 0;
15451
15452 geo_coord cur = new geo_coord();
15453 geo_coord old = new geo_coord();
15454 geo_coord corr = new geo_coord();
15455
15456 cur.Latitude = gc_list.get(loop).Latitude;
15457 cur.Longitude = gc_list.get(loop).Longitude;
15458
15459 int first_found = 1;
15460
15461 if (gc_list.size() > 2)
15462 {
15463 int instr_count = 1;
15464
15465 for (loop = 1; loop < gc_list.size(); loop++)
15466 {
15467
15468 old.Latitude = cur.Latitude;
15469 old.Longitude = cur.Longitude;
15470 cur.Latitude = gc_list.get(loop).Latitude;
15471 cur.Longitude = gc_list.get(loop).Longitude;
15472
15473 if ((instruction_pos[instr_count] == loop) || (loop == (gc_list.size() - 1)))
15474 {
15475
15476 if (loop == (gc_list.size() - 1))
15477 {
15478 corr = cur;
15479 }
15480 else
15481 {
15482 corr = get_point_on_line(old, cur, 70);
15483 }
15484
15485 // -- add waypoint --
15486 // b.putInt("Callback", 55548);
15487 // b.putString("lat", "" + corr.Latitude);
15488 // b.putString("lon", "" + corr.Longitude);
15489 // b.putString("q", " ");
15490 // msg.setData(b);
15491 try
15492 {
15493 // NavitGraphics.callback_handler.sendMessage(msg);
15494 if (first_found == 1)
15495 {
15496 first_found = 0;
15497 NavitGraphics.CallbackMessageChannel(55503, corr.Latitude + "#" + corr.Longitude + "#" + "");
15498 // System.out.println("XML:rR:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15499 }
15500 else
15501 {
15502 NavitGraphics.CallbackMessageChannel(55548, corr.Latitude + "#" + corr.Longitude + "#" + "");
15503 // System.out.println("XML:rw:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15504 }
15505 // Thread.sleep(25);
15506 }
15507 catch (Exception e)
15508 {
15509 e.printStackTrace();
15510 }
15511 // -- add waypoint --
15512
15513 instr_count++;
15514
15515 }
15516
15517 }
15518 }
15519
15520 if (remember_dest)
15521 {
15522 try
15523 {
15524 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
15525 // save points
15526 write_map_points();
15527 }
15528 catch (Exception e)
15529 {
15530 e.printStackTrace();
15531 }
15532 }
15533
15534 b.putInt("Callback", 55599);
15535 msg.setData(b);
15536 try
15537 {
15538 // System.out.println("XML:calc:");
15539 Thread.sleep(10);
15540 NavitGraphics.callback_handler.sendMessage(msg);
15541 }
15542 catch (Exception e)
15543 {
15544 e.printStackTrace();
15545 }
15546
15547 }
15548
15549 }
15550 catch (Exception e2)
15551 {
15552 e2.printStackTrace();
15553 }
15554 }
15555 };
15556 add_to_route.start();
15557
15558 // convert to coords -------------
15559 // convert to coords -------------
15560
15561 }
15562 catch (Exception e)
15563 {
15564 // System.out.println("XML:S:EEE");
15565 e.printStackTrace();
15566 }
15567 }
15568
15569 static List<geo_coord> decode_function(String encoded, double precision)
15570 {
15571
15572 precision = Math.pow(10, -precision);
15573 int len = encoded.length();
15574 int index = 0;
15575 int lat = 0;
15576 int lng = 0;
15577 double lat_f;
15578 double lon_f;
15579
15580 final List<geo_coord> latLongList = new ArrayList<geo_coord>();
15581 latLongList.clear();
15582
15583 while (index < len)
15584 {
15585
15586 int b;
15587 int shift = 0;
15588 int result = 0;
15589
15590 do
15591 {
15592 b = encoded.charAt(index++) - 63;
15593 result |= (b & 0x1f) << shift;
15594 shift += 5;
15595
15596 }
15597 while (b >= 0x20);
15598
15599 int dlat = 0;
15600 if ((result & 1) != 0)
15601 {
15602 dlat = ~(result >> 1);
15603 }
15604 else
15605 {
15606 dlat = (result >> 1);
15607 }
15608
15609 lat += dlat;
15610 shift = 0;
15611 result = 0;
15612
15613 do
15614 {
15615 b = encoded.charAt(index++) - 63;
15616 result |= (b & 0x1f) << shift;
15617 shift += 5;
15618 }
15619 while (b >= 0x20);
15620
15621 int dlng = 0;
15622 if ((result & 1) != 0)
15623 {
15624 dlng = ~(result >> 1);
15625 }
15626 else
15627 {
15628 dlng = (result >> 1);
15629 }
15630
15631 lng += dlng;
15632 //array.push( {lat: lat * precision, lng: lng * precision} );
15633 // array.push( [lat * precision, lng * precision] );
15634
15635 // System.out.println("XML:lat=" + (lat * precision) + " lon=" + (lng * precision));
15636
15637 lat_f = lat * precision;
15638 lon_f = lng * precision;
15639
15640 geo_coord gc = new geo_coord();
15641 gc.Latitude = lat_f;
15642 gc.Longitude = lon_f;
15643 latLongList.add(gc);
15644 }
15645
15646 return latLongList;
15647 }
15648
15649 public static class geo_coord
15650 {
15651 public double Latitude;
15652 public double Longitude;
15653 }
15654
15655 static geo_coord get_current_vehicle_position()
15656 {
15657 geo_coord ret = new geo_coord();
15658 String current_target_string2 = NavitGraphics.CallbackGeoCalc(14, 1, 1);
15659 // System.out.println("GET CUR POS:" + current_target_string2);
15660 ret.Latitude = 0;
15661 ret.Longitude = 0;
15662 try
15663 {
15664 String tmp[] = current_target_string2.split(":", 2);
15665 ret.Latitude = Double.parseDouble(tmp[0]);
15666 ret.Longitude = Double.parseDouble(tmp[1]);
15667 }
15668 catch (Exception e)
15669 {
15670 // System.out.println("GET CUR POS:ERROR " + e.getMessage());
15671 }
15672 return ret;
15673 }
15674
15675 static int[] geo_to_px(float lat, float lon)
15676 {
15677 int[] ret = new int[3];
15678
15679 ret[0] = -100;
15680 ret[1] = -100;
15681 ret[2] = 0; // invalid
15682
15683 try
15684 {
15685 String x_y = NavitGraphics.CallbackGeoCalc(2, lat, lon);
15686
15687 if (Navit.GFX_OVERSPILL)
15688 {
15689 String tmp[] = x_y.split(":", 2);
15690 int x = Integer.parseInt(tmp[0]);
15691 int y = Integer.parseInt(tmp[1]);
15692
15693 ret[0] = (int) (((float) x + (float) NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor);
15694 ret[1] = (int) (((float) y + (float) NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15695
15696 ret[2] = 1; // VALID
15697 }
15698 else
15699 {
15700 String tmp[] = x_y.split(":", 2);
15701 int x = Integer.parseInt(tmp[0]);
15702 int y = Integer.parseInt(tmp[1]);
15703
15704 ret[0] = (int) ((float) x * NavitGraphics.Global_dpi_factor);
15705 ret[1] = (int) ((float) y * NavitGraphics.Global_dpi_factor);
15706
15707 ret[2] = 1; // VALID
15708 }
15709
15710 }
15711 catch (Exception e)
15712 {
15713 }
15714
15715 return ret;
15716 }
15717
15718 static geo_coord px_to_geo(int x, int y)
15719 {
15720 geo_coord out = new geo_coord();
15721 try
15722 {
15723
15724 String lat_lon = "";
15725 if (Navit.GFX_OVERSPILL)
15726 {
15727 lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15728 }
15729 else
15730 {
15731 lat_lon = NavitGraphics.CallbackGeoCalc(1, x * NavitGraphics.Global_dpi_factor, y * NavitGraphics.Global_dpi_factor);
15732 }
15733
15734 String tmp[] = lat_lon.split(":", 2);
15735 out.Latitude = Float.parseFloat(tmp[0]);
15736 out.Longitude = Float.parseFloat(tmp[1]);
15737 }
15738 catch (Exception e)
15739 {
15740 }
15741
15742 return out;
15743 }
15744
15745 static double get_percent_coord(double start, double end, int perecent_pos)
15746 {
15747 double out = start + (end - start) * ((float) perecent_pos / 100.0f);
15748 return out;
15749 }
15750
15751 static geo_coord get_point_on_line(geo_coord start, geo_coord end, int perecent_pos)
15752 {
15753 geo_coord out = new geo_coord();
15754
15755 out.Latitude = start.Latitude + (end.Latitude - start.Latitude) * ((float) perecent_pos / 100.0f);
15756 out.Longitude = start.Longitude + (end.Longitude - start.Longitude) * ((float) perecent_pos / 100.0f);
15757
15758 return out;
15759 }
15760
15761 public static String slurp(final InputStream is, final int bufferSize)
15762 {
15763 final char[] buffer = new char[bufferSize];
15764 final StringBuilder out = new StringBuilder();
15765 Reader in = null;
15766
15767 try
15768 {
15769
15770 in = new InputStreamReader(is, "UTF-8");
15771
15772 for (;;)
15773 {
15774 int rsz;
15775 rsz = in.read(buffer, 0, buffer.length);
15776
15777 if (rsz < 0)
15778 {
15779 break;
15780 }
15781 out.append(buffer, 0, rsz);
15782 }
15783
15784 }
15785 catch (IOException e)
15786 {
15787 }
15788 catch (Exception ex)
15789 {
15790 }
15791
15792 return out.toString();
15793 }
15794
15795 public static Handler UIHandler;
15796 static
15797 {
15798 UIHandler = new Handler(Looper.getMainLooper());
15799 }
15800
15801 public static void recalculate_route()
15802 {
15803 try
15804 {
15805 // update route, if a route is set
15806 Message msg = new Message();
15807 Bundle b = new Bundle();
15808 b.putInt("Callback", 73);
15809 msg.setData(b);
15810 NavitGraphics.callback_handler.sendMessage(msg);
15811 }
15812 catch (Exception e)
15813 {
15814 }
15815 }
15816
15817 public static void runOnUI(Runnable runnable)
15818 {
15819 UIHandler.post(runnable);
15820 }
15821
15822 String substring_without_ioobe(String in, int start, int end)
15823 {
15824 String ret = ";:;:****no match****;:;:";
15825
15826 try
15827 {
15828 ret = in.substring(start, end);
15829 }
15830 catch (Exception e)
15831 {
15832 // return dummy-no-match String
15833 }
15834
15835 return ret;
15836 }
15837
15838 static private Cursor c = null;
15839 static private Uri uri = CR_CONTENT_URI;
15840
15841 static private int get_reglevel()
15842 {
15843 int ret = 0;
15844
15845 try
15846 {
15847 c = null;
15848 Thread thread = new Thread()
15849 {
15850 public void run()
15851 {
15852 try
15853 {
15854 c = content_resolver.query(uri, null, null, null, null);
15855 }
15856 catch (Exception c1)
15857 {
15858 System.out.println("CPVD:reg(e002)=" + c1.getMessage());
15859 }
15860 }
15861 };
15862 thread.start();
15863 try
15864 {
15865 thread.join();
15866 }
15867 catch (InterruptedException e)
15868 {
15869 }
15870
15871 if (c == null)
15872 {
15873 System.out.println("CPVD:Cursor c == null.");
15874 System.out.println("CPVD:reg(0)=" + ret);
15875 return ret;
15876 }
15877
15878 while (c.moveToNext())
15879 {
15880 String column1 = c.getString(0);
15881 String column2 = c.getString(1);
15882 String column3 = c.getString(2);
15883
15884 System.out.println("CPVD:column1=" + column1 + " column2=" + column2 + " column3=" + column3);
15885
15886 if (Integer.parseInt(column1) == 1)
15887 {
15888 if (column2.equals("reg"))
15889 {
15890 ret = Integer.parseInt(column3);
15891 System.out.println("CPVD:reg(1)=" + ret);
15892 }
15893 }
15894 }
15895 c.close();
15896 }
15897 catch (Exception e)
15898 {
15899 e.printStackTrace();
15900 System.out.println("CPVD:reg(e001)=" + e.getMessage());
15901 }
15902
15903 System.out.println("CPVD:reg(2)=" + ret);
15904 return ret;
15905 }
15906
15907 static void take_map_screenshot(String dir_name, String name_base)
15908 {
15909 try
15910 {
15911 View v1 = Navit.N_NavitGraphics.view;
15912 v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
15913 v1.setDrawingCacheEnabled(true);
15914 Bitmap bm = v1.getDrawingCache();
15915
15916 FileOutputStream out = null;
15917 try
15918 {
15919 out = new FileOutputStream(dir_name + "/" + name_base + ".png");
15920 bm.compress(Bitmap.CompressFormat.PNG, 100, out);
15921 }
15922 catch (Exception e)
15923 {
15924 e.printStackTrace();
15925 System.out.println("TSCR:004 " + e.getMessage());
15926 }
15927 finally
15928 {
15929 v1.setDrawingCacheEnabled(false);
15930
15931 try
15932 {
15933 if (out != null)
15934 {
15935 out.close();
15936 }
15937 }
15938 catch (IOException e)
15939 {
15940 e.printStackTrace();
15941 }
15942 }
15943 }
15944 catch (Exception e4)
15945 {
15946 }
15947 }
15948
15949 static void take_phone_screenshot(Activity a, String dir_name, String name_base)
15950 {
15951 try
15952 {
15953 View v1 = a.getWindow().getDecorView().getRootView();
15954 v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
15955 v1.setDrawingCacheEnabled(true);
15956 Bitmap bm = v1.getDrawingCache();
15957
15958 FileOutputStream out = null;
15959 try
15960 {
15961 out = new FileOutputStream(dir_name + "/" + name_base + ".png");
15962 bm.compress(Bitmap.CompressFormat.PNG, 100, out);
15963 }
15964 catch (Exception e)
15965 {
15966 e.printStackTrace();
15967 System.out.println("TSCR:004 " + e.getMessage());
15968 }
15969 finally
15970 {
15971 v1.setDrawingCacheEnabled(false);
15972
15973 try
15974 {
15975 if (out != null)
15976 {
15977 out.close();
15978 }
15979 }
15980 catch (IOException e)
15981 {
15982 e.printStackTrace();
15983 }
15984 }
15985 }
15986 catch (Exception e4)
15987 {
15988 }
15989 }
15990
15991 static String stacktrace_to_string(Exception e)
15992 {
15993 try
15994 {
15995 StringWriter errors = new StringWriter();
15996 e.printStackTrace(new PrintWriter(errors));
15997 return errors.toString();
15998 }
15999 catch (Exception e2)
16000 {
16001 try
16002 {
16003 return e.getMessage();
16004 }
16005 catch (Exception e3)
16006 {
16007 return "xxx";
16008 }
16009 }
16010 }
16011
16012 static void static_show_route_graph(int v)
16013 {
16014 // DEBUG: toggle Routgraph on/off
16015 try
16016 {
16017 if (v == 1)
16018 {
16019 Navit.Routgraph_enabled = 1;
16020
16021 Message msg = new Message();
16022 Bundle b = new Bundle();
16023 b.putInt("Callback", 71);
16024 b.putString("s", "" + Navit.Routgraph_enabled);
16025 msg.setData(b);
16026 NavitGraphics.callback_handler.sendMessage(msg);
16027 }
16028 else if (v == 0)
16029 {
16030 Navit.Routgraph_enabled = 0;
16031
16032 Message msg = new Message();
16033 Bundle b = new Bundle();
16034 b.putInt("Callback", 71);
16035 b.putString("s", "" + Navit.Routgraph_enabled);
16036 msg.setData(b);
16037 NavitGraphics.callback_handler.sendMessage(msg);
16038 }
16039 else
16040 {
16041 Navit.Routgraph_enabled = 0;
16042
16043 Message msg = new Message();
16044 Bundle b = new Bundle();
16045 b.putInt("Callback", 71);
16046 b.putString("s", "" + Navit.Routgraph_enabled);
16047 msg.setData(b);
16048 NavitGraphics.callback_handler.sendMessage(msg);
16049
16050 Thread.sleep(350);
16051
16052 System.out.println("static_show_route_graph:v=" + v);
16053
16054 msg = new Message();
16055 b = new Bundle();
16056 b.putInt("Callback", 71);
16057 b.putString("s", "" + v);
16058 msg.setData(b);
16059 NavitGraphics.callback_handler.sendMessage(msg);
16060 }
16061 }
16062 catch (Exception e)
16063 {
16064 }
16065
16066 }
16067
16068 /*
16069 * start a search with given values
16070 */
16071 static void executeSearch_with_values(String street, String town, String hn, boolean offline, boolean index, boolean partialmatch, boolean hide_dupl)
16072 {
16073 Intent search_intent = new Intent(Global_Navit_Object, NavitAddressSearchActivity.class);
16074 search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
16075 String addr1 = "";
16076 String addr2 = "";
16077
16078 if ((town != null) && (street != null))
16079 {
16080 if (index)
16081 {
16082 search_intent.putExtra("address_string", street + " " + town);
16083 addr1 = street + " " + town;
16084 addr2 = street + " " + town;
16085 }
16086 else
16087 {
16088 search_intent.putExtra("address_string", town + " " + street);
16089 addr1 = town + " " + street;
16090 addr2 = town + " " + street;
16091 }
16092 }
16093 else if (town != null)
16094 {
16095 search_intent.putExtra("address_string", town);
16096 addr1 = town;
16097 addr2 = town;
16098 }
16099 else if (street != null)
16100 {
16101 search_intent.putExtra("address_string", street);
16102 addr1 = street;
16103 addr2 = street;
16104 }
16105
16106 if (hn != null)
16107 {
16108 search_intent.putExtra("hn_string", hn);
16109 }
16110
16111 if (offline)
16112 {
16113 search_intent.putExtra("type", "offline");
16114 }
16115 else
16116 {
16117 search_intent.putExtra("type", "online");
16118 }
16119
16120 String pm_temp = "0";
16121 if (partialmatch)
16122 {
16123 pm_temp = "1";
16124 }
16125 search_intent.putExtra("partial_match", pm_temp);
16126
16127 if (index)
16128 {
16129 Navit_last_address_partial_match = partialmatch;
16130 Navit_last_address_search_string = addr2;
16131 Navit_last_address_hn_string = hn;
16132 Navit_last_address_full_file_search = false;
16133 search_hide_duplicates = hide_dupl;
16134 Global_Navit_Object.startActivityForResult(search_intent, NavitAddressSearch_id_offline);
16135 }
16136 else
16137 {
16138 Navit_last_address_partial_match = partialmatch;
16139 Navit_last_address_search_string = addr1;
16140 Navit_last_address_hn_string = hn;
16141 Navit_last_address_full_file_search = false;
16142 search_hide_duplicates = hide_dupl;
16143
16144 // only from offline mask!
16145 // { "*A", "*AA", "*ALL*" }
16146 Navit_last_address_search_country_iso2_string = "*A";
16147 Navit_last_address_search_country_flags = 3;
16148 Navit_last_address_search_country_id = 1; // default=*ALL*
16149 p.PREF_search_country = Navit_last_address_search_country_id;
16150 setPrefs_search_country();
16151
16152 // show duplicates in search ------------
16153 Message msg2 = new Message();
16154 Bundle b2 = new Bundle();
16155 b2.putInt("Callback", 44);
16156 msg2.setData(b2);
16157 NavitGraphics.callback_handler.sendMessage(msg2);
16158 // show duplicates in search ------------
16159
16160 if (hide_dupl)
16161 {
16162 search_hide_duplicates = true;
16163 // hide duplicates when searching
16164 // hide duplicates when searching
16165 Message msg22 = new Message();
16166 Bundle b22 = new Bundle();
16167 b22.putInt("Callback", 45);
16168 msg22.setData(b22);
16169 NavitGraphics.callback_handler.sendMessage(msg22);
16170 // hide duplicates when searching
16171 // hide duplicates when searching
16172 }
16173
16174 System.out.println("dialog -- 11:001");
16175 Message msg = Navit_progress_h.obtainMessage();
16176 Bundle b = new Bundle();
16177 msg.what = 11;
16178 b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
16179 msg.setData(b);
16180 Navit_progress_h.sendMessage(msg);
16181 }
16182 }
16183
16184 public static void set_night_mode(int i)
16185 {
16186 try
16187 {
16188 // i==0 --> day mode
16189 // i==1 --> night mode
16190 NavitGraphics.CallbackMessageChannelReal(114, "" + i);
16191 }
16192 catch (Exception e)
16193 {
16194 }
16195 }
16196 }

   
Visit the ZANavi Wiki