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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 40 Revision 41
1/** 1/**
2 * ZANavi, Zoff Android Navigation system. 2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2014 Zoff <zoff@zoff.cc> 3 * Copyright (C) 2011-2015 Zoff <zoff@zoff.cc>
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation. 7 * version 2 as published by the Free Software Foundation.
8 * 8 *
42import java.io.FileInputStream; 42import java.io.FileInputStream;
43import java.io.FileNotFoundException; 43import java.io.FileNotFoundException;
44import java.io.FileOutputStream; 44import java.io.FileOutputStream;
45import java.io.IOException; 45import java.io.IOException;
46import java.io.InputStream; 46import java.io.InputStream;
47import java.io.InputStreamReader;
47import java.io.ObjectInputStream; 48import java.io.ObjectInputStream;
48import java.io.ObjectOutputStream; 49import java.io.ObjectOutputStream;
49import java.io.OutputStream; 50import java.io.OutputStream;
50import java.io.OutputStreamWriter; 51import java.io.OutputStreamWriter;
52import java.io.Reader;
51import java.io.Serializable; 53import java.io.Serializable;
54import java.net.URL;
52import java.net.URLDecoder; 55import java.net.URLDecoder;
53import java.nio.channels.FileChannel; 56import java.nio.channels.FileChannel;
54import java.text.DecimalFormat; 57import java.text.DecimalFormat;
55import java.text.SimpleDateFormat; 58import java.text.SimpleDateFormat;
56import java.util.ArrayList; 59import java.util.ArrayList;
57import java.util.Calendar; 60import java.util.Calendar;
58import java.util.Collections; 61import java.util.Collections;
59import java.util.Date; 62import java.util.Date;
60import java.util.HashSet; 63import java.util.HashSet;
64import java.util.Iterator;
61import java.util.List; 65import java.util.List;
62import java.util.Locale; 66import java.util.Locale;
63import java.util.Map; 67import java.util.Map;
64import java.util.Random; 68import java.util.Random;
65import java.util.Set; 69import java.util.Set;
66import java.util.TimeZone; 70import java.util.TimeZone;
67import java.util.concurrent.LinkedBlockingQueue; 71import java.util.concurrent.LinkedBlockingQueue;
72
73import org.json.JSONArray;
74import org.json.JSONObject;
75import org.xml.sax.InputSource;
68 76
69import android.annotation.SuppressLint; 77import android.annotation.SuppressLint;
70import android.annotation.TargetApi; 78import android.annotation.TargetApi;
71import android.app.Activity; 79import android.app.Activity;
72import android.app.AlertDialog; 80import android.app.AlertDialog;
76import android.app.PendingIntent; 84import android.app.PendingIntent;
77import android.app.ProgressDialog; 85import android.app.ProgressDialog;
78import android.app.backup.BackupManager; 86import android.app.backup.BackupManager;
79import android.content.ActivityNotFoundException; 87import android.content.ActivityNotFoundException;
80import android.content.ComponentName; 88import android.content.ComponentName;
89import android.content.ContentResolver;
81import android.content.Context; 90import android.content.Context;
82import android.content.DialogInterface; 91import android.content.DialogInterface;
83import android.content.DialogInterface.OnCancelListener; 92import android.content.DialogInterface.OnCancelListener;
84import android.content.Intent; 93import android.content.Intent;
85import android.content.ServiceConnection; 94import android.content.ServiceConnection;
87import android.content.pm.PackageInfo; 96import android.content.pm.PackageInfo;
88import android.content.pm.PackageManager.NameNotFoundException; 97import android.content.pm.PackageManager.NameNotFoundException;
89import android.content.res.AssetManager; 98import android.content.res.AssetManager;
90import android.content.res.Configuration; 99import android.content.res.Configuration;
91import android.content.res.Resources; 100import android.content.res.Resources;
101import android.database.Cursor;
92import android.graphics.Bitmap; 102import android.graphics.Bitmap;
93import android.graphics.BitmapFactory; 103import android.graphics.BitmapFactory;
94import android.graphics.Color; 104import android.graphics.Color;
105import android.graphics.Paint;
106import android.graphics.Rect;
95import android.graphics.RectF; 107import android.graphics.RectF;
96import android.graphics.Typeface; 108import android.graphics.Typeface;
97import android.hardware.Sensor; 109import android.hardware.Sensor;
98import android.hardware.SensorEvent; 110import android.hardware.SensorEvent;
99import android.hardware.SensorEventListener; 111import android.hardware.SensorEventListener;
112import android.os.Bundle; 124import android.os.Bundle;
113import android.os.Debug; 125import android.os.Debug;
114import android.os.Environment; 126import android.os.Environment;
115import android.os.Handler; 127import android.os.Handler;
116import android.os.IBinder; 128import android.os.IBinder;
129import android.os.Looper;
117import android.os.Message; 130import android.os.Message;
118import android.os.PowerManager; 131import android.os.PowerManager;
119import android.os.RemoteException; 132import android.os.RemoteException;
120import android.os.SystemClock; 133import android.os.SystemClock;
121import android.preference.PreferenceManager; 134import android.preference.PreferenceManager;
122import android.speech.tts.TextToSpeech; 135import android.speech.tts.TextToSpeech;
136import android.support.v4.app.FragmentManager;
137import android.support.v4.app.FragmentTransaction;
123import android.support.v7.app.ActionBar; 138import android.support.v7.app.ActionBar;
124import android.support.v7.app.ActionBarActivity; 139import android.support.v7.app.ActionBarActivity;
125import android.support.v7.widget.Toolbar; 140import android.support.v7.widget.Toolbar;
141import android.text.Html;
126import android.text.SpannableString; 142import android.text.SpannableString;
127import android.text.method.LinkMovementMethod; 143import android.text.method.LinkMovementMethod;
128import android.text.util.Linkify; 144import android.text.util.Linkify;
129import android.util.DisplayMetrics; 145import android.util.DisplayMetrics;
130import android.util.Log; 146import android.util.Log;
131import android.util.TypedValue; 147import android.util.TypedValue;
132import android.view.Display; 148import android.view.Display;
149import android.view.GestureDetector;
150import android.view.GestureDetector.SimpleOnGestureListener;
133import android.view.Gravity; 151import android.view.Gravity;
134import android.view.KeyEvent; 152import android.view.KeyEvent;
135import android.view.Menu; 153import android.view.Menu;
136import android.view.MenuItem; 154import android.view.MenuItem;
155import android.view.MotionEvent;
137import android.view.View; 156import android.view.View;
138import android.view.ViewConfiguration; 157import android.view.ViewConfiguration;
139import android.view.ViewGroup.LayoutParams; 158import android.view.ViewTreeObserver;
159import android.view.ViewTreeObserver.OnGlobalLayoutListener;
140import android.view.Window; 160import android.view.Window;
141import android.view.WindowManager; 161import android.view.WindowManager;
162import android.view.animation.Animation;
163import android.view.animation.Animation.AnimationListener;
164import android.view.animation.TranslateAnimation;
142import android.view.inputmethod.InputMethodManager; 165import android.view.inputmethod.InputMethodManager;
143import android.widget.Button; 166import android.widget.Button;
167import android.widget.FrameLayout;
168import android.widget.ImageView;
169import android.widget.LinearLayout;
144import android.widget.RelativeLayout; 170import android.widget.RelativeLayout;
145import android.widget.TextView; 171import android.widget.TextView;
146import android.widget.Toast; 172import android.widget.Toast;
147import bpi.sdbm.illuminance.SolarPosition; 173import bpi.sdbm.illuminance.SolarPosition;
148 174
152import com.luckycatlabs.sunrisesunset.calculator.SolarEventCalculator; 178import com.luckycatlabs.sunrisesunset.calculator.SolarEventCalculator;
153import com.luckycatlabs.sunrisesunset.dto.Location2; 179import com.luckycatlabs.sunrisesunset.dto.Location2;
154import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread; 180import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
155import com.zoffcc.applications.zanavi.NavitOSDJava.drawOSDThread; 181import com.zoffcc.applications.zanavi.NavitOSDJava.drawOSDThread;
156import com.zoffcc.applications.zanavi.NavitVehicle.location_coords; 182import com.zoffcc.applications.zanavi.NavitVehicle.location_coords;
183import com.zoffcc.applications.zanavi.ZANaviListViewAdapter.ListViewItem;
157import com.zoffcc.applications.zanavi_msg.ZanaviCloudApi; 184import com.zoffcc.applications.zanavi_msg.ZanaviCloudApi;
158 185
159import de.oberoner.gpx2navit_txt.MainFrame; 186import de.oberoner.gpx2navit_txt.MainFrame;
160 187
161public class Navit extends ActionBarActivity implements Handler.Callback, SensorEventListener 188public class Navit extends ActionBarActivity implements Handler.Callback, SensorEventListener
162{ 189{
163 public static final String VERSION_TEXT_LONG_INC_REV = "2891"; 190 public static final String VERSION_TEXT_LONG_INC_REV = "3577";
164 public static String NavitAppVersion = "0"; 191 public static String NavitAppVersion = "0";
165 public static String NavitAppVersion_prev = "-1"; 192 public static String NavitAppVersion_prev = "-1";
166 public static String NavitAppVersion_string = "0"; 193 public static String NavitAppVersion_string = "0";
167 public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!! 194 public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
168 public static boolean has_hw_menu_button = false; 195 public static boolean has_hw_menu_button = false;
172 static boolean actionbar_all_items_will_fit = false; 199 static boolean actionbar_all_items_will_fit = false;
173 static boolean actionabar_download_icon_visible = false; 200 static boolean actionabar_download_icon_visible = false;
174 static boolean is_navigating = false; 201 static boolean is_navigating = false;
175 static boolean is_paused = true; 202 static boolean is_paused = true;
176 203
204 static int api_version_int = 6;
205
177 static boolean PAINT_OLD_API = true; 206 static boolean PAINT_OLD_API = true;
207
208 static long SHOWCASEVIEW_ID_001 = 93457181726L;
178 209
179 //static final int DEFAULT_THEME_DARK = android.R.style.Theme_WithActionBar; 210 //static final int DEFAULT_THEME_DARK = android.R.style.Theme_WithActionBar;
180 //static final int DEFAULT_THEME_LIGHT = android.R.style.Theme_Material_Light; 211 //static final int DEFAULT_THEME_LIGHT = android.R.style.Theme_Material_Light;
181 static final int DEFAULT_THEME_OLD_LIGHT = R.style.CustomActionBarThemeLight; 212 static final int DEFAULT_THEME_OLD_LIGHT = R.style.CustomActionBarThemeLight;
182 static final int DEFAULT_THEME_OLD_DARK = R.style.CustomActionBarTheme; 213 static final int DEFAULT_THEME_OLD_DARK = R.style.CustomActionBarTheme;
183 214
184 static final int DEFAULT_THEME_OLD_LIGHT_M = R.style.CustomActionBarThemeLightM; 215 static final int DEFAULT_THEME_OLD_LIGHT_M = R.style.CustomActionBarThemeLightM;
185 static final int DEFAULT_THEME_OLD_DARK_M = R.style.CustomActionBarThemeM; 216 static final int DEFAULT_THEME_OLD_DARK_M = R.style.CustomActionBarThemeM;
217
218 // GLSurfaceView glSurfaceView;
219
220 static int OSD_blueish_bg_color = 0;
186 221
187 // ----------------- DEBUG ---------------- 222 // ----------------- DEBUG ----------------
188 // ----------------- DEBUG ---------------- 223 // ----------------- DEBUG ----------------
189 // ----------------- DEBUG ---------------- 224 // ----------------- DEBUG ----------------
190 static final boolean METHOD_DEBUG = false; // for debugging only, set this to "false" on release builds!! 225 static final boolean METHOD_DEBUG = false; // for debugging only, set this to "false" on release builds!!
191 static final boolean DEBUG_DRAW_VEHICLE = true; // if "false" then dont draw green vehicle, set this to "true" on release builds!! 226 static final boolean DEBUG_DRAW_VEHICLE = true; // if "false" then dont draw green vehicle, set this to "true" on release builds!!
192 static final boolean NAVIT_ALWAYS_UNPACK_XMLFILE = false; // always unpacks the navit.xml file, set this to "false" on release builds!! 227 static final boolean NAVIT_ALWAYS_UNPACK_XMLFILE = false; // always unpacks the navit.xml file, set this to "false" on release builds!!
193 static final boolean NAVIT_DEBUG_TEXT_VIEW = false; // show overlay with debug messages, set this to "false" on release builds!! 228 static final boolean NAVIT_DEBUG_TEXT_VIEW = false; // show overlay with debug messages, set this to "false" on release builds!!
229 static final boolean GFX_OVERSPILL = true; // make gfx canvas bigger for rotation and zoom smoothness
194 // ----------------- DEBUG ---------------- 230 // ----------------- DEBUG ----------------
195 // ----------------- DEBUG ---------------- 231 // ----------------- DEBUG ----------------
196 // ----------------- DEBUG ---------------- 232 // ----------------- DEBUG ----------------
233
234 // ----------------------------------------
235 // ----------------------------------------
236 static final boolean FDBL = false;
237 // ----------------------------------------
238 // ----------------------------------------
239
240 static final float OVERSPILL_FACTOR = 1.4f; // 20% percent on each side
197 241
198 // ------------------ BitCoin Addr -------- 242 // ------------------ BitCoin Addr --------
199 // ------------------ BitCoin Addr -------- 243 // ------------------ BitCoin Addr --------
200 // ------------------ BitCoin Addr -------- 244 // ------------------ BitCoin Addr --------
201 final static String BITCOIN_DONATE_ADDR = "1ZANav18WY8ytM7bhnAEBS3bdrTohsD9p"; 245 final static String BITCOIN_DONATE_ADDR = "1ZANav18WY8ytM7bhnAEBS3bdrTohsD9p";
202 // ------------------ BitCoin Addr -------- 246 // ------------------ BitCoin Addr --------
203 // ------------------ BitCoin Addr -------- 247 // ------------------ BitCoin Addr --------
204 // ------------------ BitCoin Addr -------- 248 // ------------------ BitCoin Addr --------
205 249
206 private ZanaviCloudApi plugin_api; 250 private static ZanaviCloudApi plugin_api = null;
207 static final int PLUGIN_MSG_ID = 1; 251 static final int PLUGIN_MSG_ID = 1;
208 static final int PLUGIN_MSG_CAT_zanavi_version = 1; 252 static final int PLUGIN_MSG_CAT_zanavi_version = 1;
253 static final int PLUGIN_MSG_CAT_installed_maps = 2;
254 static final int PLUGIN_MSG_CAT_3d_mode = 3;
255
256 static ZANaviPrefs p = new ZANaviPrefs();
257 static ZANaviPrefs p_old = new ZANaviPrefs();
258 static final int STREET_SEARCH_STRINGS_SAVE_COUNT = 10;
209 259
210 // static AnimationDrawable mFrameAnimation; 260 // static AnimationDrawable mFrameAnimation;
211 static Menu cur_menu = null; 261 static Menu cur_menu = null;
212 262
213 static long NAVIT_START_INTENT_DRIVE_HOME = 1L; 263 static long NAVIT_START_INTENT_DRIVE_HOME = 1L;
214 264
215 static final int NAVIT_BACKBUTTON_TO_EXIT_TIME = 2000; // 2 secs. 265 static final int NAVIT_BACKBUTTON_TO_EXIT_TIME = 2000; // 2 secs.
216 266
217 static int NavitOverflowMenuItemID = -1; 267 static int NavitOverflowMenuItemID = -1;
218 268
269 static ContentResolver content_resolver = null;
270 public static final String CR_AUTHORITY = "com.zoffcc.applications.zanavi_udonate.provider";
271 public static final Uri CR_CONTENT_URI = Uri.parse("content://" + CR_AUTHORITY + "/" + "table1");
272
219 public static Intent ZANaviMapDownloaderServiceIntent = null; 273 public static Intent ZANaviMapDownloaderServiceIntent = null;
274
275 static float last_y_bottom_bar_touch = 0;
276 static float cur_y_margin_bottom_bar_touch = 0;
277 static int map_view_height = 100;
278 static float bottom_y_margin_bottom_bar_touch = 0;
279 static int actionBarHeight = 0;
280 static int bottom_bar_px = 80;
281 static int bottom_bar_slider_shadow_px = 4;
282 static GestureDetector mGestureDetector = null;
283 static int swipeMaxOffPath = 20;
284 static ZANaviRoadbookFragment road_book = null;
285 static FragmentManager fragmentManager = null;
286 static ImageView push_pin_view = null;
287 static List<ListViewItem> road_book_items = null;
220 288
221 TextToSpeech mTts = null; 289 TextToSpeech mTts = null;
222 290
223 static ToneGenerator toneG = null; 291 static ToneGenerator toneG = null;
224 static boolean toneG_heared = false; 292 static boolean toneG_heared = false;
232 static Object backupManager = null; 300 static Object backupManager = null;
233 301
234 // AlertDialog dialog_info_popup = null; 302 // AlertDialog dialog_info_popup = null;
235 Dialog dialog_info_popup = null; 303 Dialog dialog_info_popup = null;
236 int info_popup_seen_count = 0; 304 int info_popup_seen_count = 0;
237 final int info_popup_seen_count_max = 3; // must look at the info pop 3 times 305 final int info_popup_seen_count_max = 2; // must look at the info pop 2 times
238 boolean info_popup_seen_count_end = false; 306 boolean info_popup_seen_count_end = false;
239 307
240 static Navit Global_Navit_Object = null; 308 static Navit Global_Navit_Object = null;
241 static AssetManager asset_mgr = null; 309 static AssetManager asset_mgr = null;
242 310
273 public static NavitVehicle NV = null; 341 public static NavitVehicle NV = null;
274 public static NavitSpeech2 NSp = null; 342 public static NavitSpeech2 NSp = null;
275 public static drawOSDThread draw_osd_thread = null; 343 public static drawOSDThread draw_osd_thread = null;
276 344
277 public static boolean use_index_search = false; 345 public static boolean use_index_search = false;
346 public static boolean index_search_realtime = false;
278 347
279 static AlertDialog.Builder generic_alert_box = null; 348 static AlertDialog.Builder generic_alert_box = null;
280 349
281 private Boolean xmlconfig_unpack_file = true; 350 private Boolean xmlconfig_unpack_file = true;
282 private Boolean write_new_version_file = true; 351 private Boolean write_new_version_file = true;
283 final static int Navit_Status_COMPLETE_NEW_INSTALL = 1; 352 final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
284 final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2; 353 final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
285 final static int Navit_Status_NORMAL_STARTUP = 0; 354 final static int Navit_Status_NORMAL_STARTUP = 0;
286 static Boolean Navit_DonateVersion_Installed = false; 355 static Boolean Navit_DonateVersion_Installed = false;
287 static Boolean Navit_Plugin_001_Installed = false; 356 static Boolean Navit_Plugin_001_Installed = false;
357 static Boolean Navit_index_on_but_no_idx_files = false;
358 static Boolean Navit_maps_too_old = false;
288 static Boolean Navit_Largemap_DonateVersion_Installed = false; 359 static Boolean Navit_Largemap_DonateVersion_Installed = false;
289 private int startup_status = Navit_Status_NORMAL_STARTUP; 360 private int startup_status = Navit_Status_NORMAL_STARTUP;
290 final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8; 361 final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
291 static Boolean unsupported = false; 362 static Boolean unsupported = false;
292 static Boolean Navit_maps_loaded = false; 363 static Boolean Navit_maps_loaded = false;
408 { 479 {
409 Boolean driving_distance_to_target_valid = false; 480 Boolean driving_distance_to_target_valid = false;
410 String driving_distance_to_target = ""; 481 String driving_distance_to_target = "";
411 Boolean arriving_time_valid = false; 482 Boolean arriving_time_valid = false;
412 String arriving_time = ""; 483 String arriving_time = "";
484 Boolean arriving_secs_to_dest_valid = false;
485 String arriving_secs_to_dest = "";
413 } 486 }
414 487
415 public static final class Navit_OSD_route_nextturn 488 public static final class Navit_OSD_route_nextturn
416 { 489 {
417 Boolean nextturn_image_filename_valid = false; 490 Boolean nextturn_image_filename_valid = false;
514 public static final int NavitAddressSearchCountry_id = 74; 587 public static final int NavitAddressSearchCountry_id = 74;
515 public static final int NavitMapPreview_id = 75; 588 public static final int NavitMapPreview_id = 75;
516 public static final int NavitAddressSearch_id_gmaps = 76; 589 public static final int NavitAddressSearch_id_gmaps = 76;
517 public static final int NavitAddressSearch_id_sharedest = 77; 590 public static final int NavitAddressSearch_id_sharedest = 77;
518 public static final int ZANaviVoiceInput_id = 78; 591 public static final int ZANaviVoiceInput_id = 78;
592 public static final int NavitDonateFromSearch_id = 79;
519 public static int NavitSearchresultBarIndex = -1; 593 public static int NavitSearchresultBarIndex = -1;
520 public static String NavitSearchresultBar_title = ""; 594 public static String NavitSearchresultBar_title = "";
521 public static String NavitSearchresultBar_text = ""; 595 public static String NavitSearchresultBar_text = "";
522 public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>(); 596 public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();
523 597
603 static String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt"; 677 static String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
604 static String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt"; 678 static String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
605 static final String Navit_DEST_FILENAME = "destinations.dat"; 679 static final String Navit_DEST_FILENAME = "destinations.dat";
606 static final String Navit_CENTER_FILENAME = "center.txt"; 680 static final String Navit_CENTER_FILENAME = "center.txt";
607 681
608 static boolean PREF_use_fast_provider; 682 static boolean need_recalc_route = false;
609 static boolean PREF_follow_gps;
610 static boolean PREF_use_compass_heading_base;
611 static boolean PREF_use_compass_heading_always;
612 static boolean PREF_allow_gui_internal;
613 static boolean PREF_show_vehicle_in_center;
614 static boolean PREF_use_imperial;
615 static boolean PREF_use_compass_heading_fast;
616 static boolean PREF_use_anti_aliasing;
617 static boolean PREF_use_map_filtering;
618 static boolean PREF_gui_oneway_arrows;
619 static boolean PREF_c_linedrawing;
620 static boolean PREF_show_debug_messages;
621 static boolean PREF_show_3d_map = false;
622 static boolean PREF_use_lock_on_roads;
623 static boolean PREF_use_route_highways;
624 static boolean PREF_save_zoomlevel;
625 static boolean PREF_show_sat_status;
626 static boolean PREF_use_agps;
627 static boolean PREF_enable_debug_functions;
628 static boolean PREF_enable_debug_write_gpx = false;
629 static boolean PREF_enable_debug_enable_comm = false;
630 static boolean PREF_speak_street_names;
631 static boolean PREF_shrink_on_high_dpi;
632 static int PREF_search_country = 1; // default=*ALL*
633 static int PREF_zoomlevel_num = 174698;
634 static boolean PREF_use_custom_font = true;
635 static int PREF_map_font_size = 2; // 1 -> small, 2 -> normal, 3 -> large, 4-> extra large, 4-> mega large
636 static int PREF_cancel_map_drawing_timeout = 1; // 0 -> short, 1-> normal, 2-> long, 3-> almost unlimited
637 static boolean PREF_draw_polyline_circles = true; // true -> yes (default) false -> no
638 static int PREF_mapcache = 10 * 1024; // in kbytes
639 static String PREF_navit_lang;
640 static int PREF_drawatorder = 1;
641 static String PREF_streetsearch_r = "1"; // street search radius factor (multiplier)
642 static String PREF_route_style = "3"; // 1 -> under green 2 -> on top blue 3 -> on top of all and blue
643 static String PREF_trafficlights_delay = "0"; // 0 -> dont calc traffic lights delay
644 static String PREF_avoid_sharp_turns = "0"; // 0 -> normal routing, 1 -> avoid sharp turns
645 static boolean PREF_autozoom_flag = true; // false -> no autozoom true -> use autozoom
646 static boolean PREF_item_dump = false;
647 static boolean PREF_use_smooth_drawing = true;
648 static boolean PREF_use_more_smooth_drawing = false;
649 static boolean PREF_show_route_rects = false;
650 static int PREF_more_map_detail = 0; // 0 -> *normal* , higher values show more detail (and use a lot more CPU!!)
651 static boolean PREF_show_multipolygons = true;
652 static boolean PREF_use_index_search = true;
653 static boolean PREF_show_2d3d_toggle = true;
654 static final int STREET_SEARCH_STRINGS_SAVE_COUNT = 10;
655 static String[] PREF_StreetSearchStrings = new String[STREET_SEARCH_STRINGS_SAVE_COUNT];
656 static boolean PREF_speak_filter_special_chars = true;
657 static boolean PREF_show_vehicle_3d = true;
658 static boolean PREF_streets_only = false;
659 static String PREF_routing_profile = "car"; // 'car' -> car , 'bike' -> bicycle
660 static int PREF_road_priority_001 = 68;
661 static int PREF_road_priority_002 = 329;
662 static int PREF_road_priority_003 = 5000;
663 static int PREF_road_priority_004 = 5;
664 static int PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK; // what theme/style to use
665 static int PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M; // what theme/style to use
666 static boolean PREF_show_status_bar = true;
667 static String PREF_last_selected_dir_gpxfiles = "";
668 static int PREF_tracking_connected_pref = 280;
669 static int PREF_tracking_angle_pref = 40;
670 static boolean PREF_roadspeed_warning = false; // warning of going faster than speed allowed on this road
671 static boolean PREF_lane_assist = false; // shows lanes to drive on next
672 683
673 static Resources res_ = null; 684 static Resources res_ = null;
674 static Window app_window = null; 685 static Window app_window = null;
675 686
676 public static String get_text(String in) 687 public static String get_text(String in)
921 // { 932 // {
922 // } 933 // }
923 934
924 getPrefs_theme(); 935 getPrefs_theme();
925 getPrefs_theme_main(); 936 getPrefs_theme_main();
926 Navit.applySharedTheme(this, Navit.PREF_current_theme_M); 937 Navit.applySharedTheme(this, p.PREF_current_theme_M);
927 938
928 super.onCreate(savedInstanceState); 939 super.onCreate(savedInstanceState);
940
941 Global_Navit_Object = this;
942 asset_mgr = getAssets();
943
944 OSD_blueish_bg_color = getResources().getColor(R.color.blueish_bg_color);
945
946 // getBaseContext_ = getBaseContext().getApplicationContext();
947 getBaseContext_ = getBaseContext();
948
949 last_orientation = getResources().getConfiguration().orientation;
950
951 content_resolver = getContentResolver();
952 // get_reglevel();
929 953
930 Display display_ = getWindowManager().getDefaultDisplay(); 954 Display display_ = getWindowManager().getDefaultDisplay();
931 metrics = new DisplayMetrics(); 955 metrics = new DisplayMetrics();
932 display_.getMetrics(Navit.metrics); 956 display_.getMetrics(Navit.metrics);
933 957
958 road_book_items = new ArrayList<ListViewItem>();
959 fragmentManager = getSupportFragmentManager();
960
934 setContentView(R.layout.main_layout); 961 setContentView(R.layout.main_layout);
935 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 962 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
936 if (toolbar != null) 963 if (toolbar != null)
937 { 964 {
965 try
966 {
938 setSupportActionBar(toolbar); 967 setSupportActionBar(toolbar);
939 // System.out.println("TTT01:" + toolbar); 968 // System.out.println("TTT01:" + toolbar);
969 }
970 catch (NoClassDefFoundError e)
971 {
972 }
940 } 973 }
941 974
942 try 975 try
943 { 976 {
944 getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); 977 getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
945 getSupportActionBar().setDisplayUseLogoEnabled(false); 978 getSupportActionBar().setDisplayUseLogoEnabled(false);
946 getSupportActionBar().setIcon(R.drawable.icon); 979 getSupportActionBar().setIcon(R.drawable.icon);
947 getSupportActionBar().setDisplayShowHomeEnabled(true); 980 getSupportActionBar().setDisplayShowHomeEnabled(true);
948 getSupportActionBar().setDisplayShowTitleEnabled(false); 981 getSupportActionBar().setDisplayShowTitleEnabled(false);
949 } 982 }
983 catch (NoClassDefFoundError e)
984 {
985 }
950 catch (Exception e) 986 catch (Exception e)
951 { 987 {
952 e.printStackTrace(); 988 e.printStackTrace();
953 } 989 }
990
991 // ------------ bottom bar slider ----------------
992 // ------------ bottom bar slider ----------------
993 // ------------ bottom bar slider ----------------
994
995 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
996 // System.out.println("VVV:bottom_bar_height:" + bottom_bar_px);
997 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
998 // System.out.println("VVV:bottom_bar_slider_shadow_px:" + bottom_bar_slider_shadow_px);
999
1000 // final RelativeLayout a = (RelativeLayout) findViewById(R.id.bottom_bar_container);
1001 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
1002 final RelativeLayout.LayoutParams pp22 = (RelativeLayout.LayoutParams) a.getLayoutParams();
1003
1004 // Calculate ToolBar height
1005 try
1006 {
1007 TypedValue tv = new TypedValue();
1008 if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
1009 {
1010 actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
1011 System.out.println("VVV:abh:" + actionBarHeight);
1012 }
1013 else
1014 {
1015 actionBarHeight = NavitGraphics.dp_to_px(144);
1016 }
1017 }
1018 catch (Exception e)
1019 {
1020 actionBarHeight = NavitGraphics.dp_to_px(144);
1021 }
1022
1023 final android.support.v7.widget.Toolbar view_toolbar_top = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
1024 ViewTreeObserver vto = view_toolbar_top.getViewTreeObserver();
1025 vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener()
1026 {
1027 @Override
1028 public void onGlobalLayout()
1029 {
1030 view_toolbar_top.getViewTreeObserver().removeGlobalOnLayoutListener(this);
1031 // int width = view_toolbar_top.getMeasuredWidth();
1032 int height = view_toolbar_top.getMeasuredHeight();
1033 Navit.actionBarHeight = height;
1034 // System.out.println("hhh:88=" + Navit.actionBarHeight);
1035 Navit.cur_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
1036
1037 pp22.setMargins(0, (int) Navit.cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1038 a.setLayoutParams(pp22);
1039 a.requestLayout();
1040 }
1041 });
1042
1043 // actionBarHeight = 168;
1044
1045 // final int SWIPE_MIN_DISTANCE = NavitGraphics.dp_to_px(25);
1046 // final float SWIPE_THRESHOLD_VELOCITY = 5.5f;
1047 // final float FLING_PIXELS_PER_SECOND = 100;
1048 // final float maxFlingVelocity = ViewConfiguration.get(this).getScaledMaximumFlingVelocity();
1049 final ViewConfiguration vc = ViewConfiguration.get(this);
1050 final int swipeMinDistance = vc.getScaledPagingTouchSlop();
1051 final int swipeThresholdVelocity = vc.getScaledMinimumFlingVelocity();
1052 swipeMaxOffPath = vc.getScaledTouchSlop();
1053 // (there is also vc.getScaledMaximumFlingVelocity() one could check against)
1054
1055 // setup some values --------
1056 NavitGraphics.long_press_on_screen_max_distance = swipeMaxOffPath;
1057 // setup some values --------
1058
1059 class MyGestureDetector extends SimpleOnGestureListener
1060 {
1061 @Override
1062 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
1063 {
1064 try
1065 {
1066 // float velocityPercentY = velocityY / maxFlingVelocity; // the percent is a value in the range of (0, 1]
1067 // float normalizedVelocityY = velocityPercentY * FLING_PIXELS_PER_SECOND; // where PIXELS_PER_SECOND is a device-independent measurement
1068
1069 // System.out.println("VVV:" + (e1.getY() - e2.getY()) + " " + NavitGraphics.dp_to_px((int) (e1.getY() - e2.getY())) + " " + maxFlingVelocity + " " + velocityY + " " + velocityPercentY + " " + normalizedVelocityY + " " + SWIPE_THRESHOLD_VELOCITY);
1070
1071 // System.out.println("VVV:2:" + swipeMinDistance + " " + swipeThresholdVelocity + " " + swipeMaxOffPath);
1072
1073 // bottom to top
1074 if (e1.getY() - e2.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1075 {
1076 //int featureWidth = getMeasuredWidth();
1077 //mActiveFeature = (mActiveFeature < (mItems.size() - 1)) ? mActiveFeature + 1 : mItems.size() - 1;
1078 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1079 //System.out.println("GS:002:up:" + velocityY + " " + e2.getY() + " " + e1.getY());
1080
1081 animate_bottom_bar_up();
1082
1083 return true;
1084 }
1085 // top to bottom
1086 else if (e2.getY() - e1.getY() > swipeMinDistance && Math.abs(velocityY) > swipeThresholdVelocity)
1087 {
1088 //int featureWidth = getMeasuredWidth();
1089 //mActiveFeature = (mActiveFeature > 0) ? mActiveFeature - 1 : 0;
1090 //smoothScrollTo(mActiveFeature * featureWidth, 0);
1091 //System.out.println("GS:003:down:" + velocityY + " " + e1.getY() + " " + e2.getY());
1092
1093 animate_bottom_bar_down();
1094
1095 return true;
1096 }
1097 }
1098 catch (Exception e)
1099 {
1100 //System.out.println("GS:009:EE:" + e.getMessage());
1101 }
1102 return false;
1103 }
1104 }
1105 mGestureDetector = new GestureDetector(new MyGestureDetector());
1106
1107 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
1108 push_pin_view.setOnClickListener(new ImageView.OnClickListener()
1109 {
1110 public void onClick(View v)
1111 {
1112 try
1113 {
1114 toggle_follow_button();
1115 }
1116 catch (Exception e)
1117 {
1118 }
1119 }
1120 });
1121
1122 cur_y_margin_bottom_bar_touch = 0; // try to put view at bottom
1123
1124 a.setOnTouchListener(new View.OnTouchListener()
1125 {
1126 @Override
1127 synchronized public boolean onTouch(View v, MotionEvent m)
1128 {
1129
1130 int action = m.getAction();
1131
1132 if (mGestureDetector.onTouchEvent(m))
1133 {
1134 //System.out.println("GS:001:fling!!");
1135 // System.out.println("FRAG:fling:011");
1136 return true;
1137 }
1138 else if (action == MotionEvent.ACTION_DOWN)
1139 {
1140 last_y_bottom_bar_touch = m.getY();
1141
1142 // put roadbook into layout -----------
1143 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
1144
1145 try
1146 {
1147 if (road_book == null)
1148 {
1149 road_book = new ZANaviRoadbookFragment();
1150 // System.out.println("FRAG:attach:001");
1151 fragmentTransaction.replace(R.id.roadbook_fragment_container, road_book, "");
1152 fragmentTransaction.commitAllowingStateLoss();
1153 // fragmentTransaction.show(road_book);
1154 }
1155 else
1156 {
1157 // System.out.println("FRAG:attached:003");
1158 }
1159 }
1160 catch (Exception ef)
1161 {
1162 }
1163 // put roadbook into layout -----------
1164
1165 return true;
1166 }
1167 else if ((action == MotionEvent.ACTION_UP) || (action == MotionEvent.ACTION_CANCEL))
1168 {
1169 // System.out.println("FRAG:up/cancel:012");
1170
1171 // release
1172 if (cur_y_margin_bottom_bar_touch > (bottom_y_margin_bottom_bar_touch / 2))
1173 {
1174 // snap back to bottom
1175 animate_bottom_bar_down();
1176 }
1177 else
1178 {
1179 // snap top top
1180 animate_bottom_bar_up();
1181 }
1182 }
1183 else
1184 // if (action == MotionEvent.ACTION_MOVE)
1185 {
1186 // System.out.println("FRAG:*else*:012");
1187
1188 if (Math.abs(last_y_bottom_bar_touch - m.getY()) > 2)
1189 {
1190 float last_margin = cur_y_margin_bottom_bar_touch;
1191 cur_y_margin_bottom_bar_touch = cur_y_margin_bottom_bar_touch - (last_y_bottom_bar_touch - m.getY());
1192
1193 if ((cur_y_margin_bottom_bar_touch >= 0) && (cur_y_margin_bottom_bar_touch <= bottom_y_margin_bottom_bar_touch))
1194 {
1195 // System.out.println("VVV:move:" + cur_y_margin_bottom_bar_touch + " " + bottom_y_margin_bottom_bar_touch);
1196
1197 last_y_bottom_bar_touch = m.getY() + (last_y_bottom_bar_touch - m.getY());
1198 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
1199 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
1200 a.setLayoutParams(relativeParams);
1201 a.requestLayout();
1202 }
1203 else
1204 {
1205 // System.out.println("VVV:revert");
1206
1207 // revert position
1208 cur_y_margin_bottom_bar_touch = last_margin;
1209 }
1210 }
1211
1212 }
1213 return true;
1214 }
1215 });
1216 // ------------ bottom bar slider ----------------
1217 // ------------ bottom bar slider ----------------
1218 // ------------ bottom bar slider ----------------
954 1219
955 // init cancel dialog!! ---------- 1220 // init cancel dialog!! ----------
956 // init cancel dialog!! ---------- 1221 // init cancel dialog!! ----------
957 Message msg2 = new Message(); 1222 Message msg2 = new Message();
958 Bundle b2 = new Bundle(); 1223 Bundle b2 = new Bundle();
968 // ---------------- set some directories ----------------- 1233 // ---------------- set some directories -----------------
969 // ---------------- set some directories ----------------- 1234 // ---------------- set some directories -----------------
970 NAVIT_DATA_DIR = this.getFilesDir().getPath(); 1235 NAVIT_DATA_DIR = this.getFilesDir().getPath();
971 this.getFilesDir().mkdirs(); 1236 this.getFilesDir().mkdirs();
972 // --- 1237 // ---
973 System.out.println("data dir=" + NAVIT_DATA_DIR); 1238 // System.out.println("data dir=" + NAVIT_DATA_DIR);
974 NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share/"; 1239 NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share/";
975 File tmp3 = new File(NAVIT_DATA_SHARE_DIR); 1240 File tmp3 = new File(NAVIT_DATA_SHARE_DIR);
976 tmp3.mkdirs(); 1241 tmp3.mkdirs();
977 // --- 1242 // ---
978 FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt"; 1243 FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
1000 catch (Exception e) 1265 catch (Exception e)
1001 { 1266 {
1002 e.printStackTrace(); 1267 e.printStackTrace();
1003 } 1268 }
1004 1269
1005 Global_Navit_Object = this;
1006 asset_mgr = getAssets();
1007
1008 // getBaseContext_ = getBaseContext().getApplicationContext();
1009 getBaseContext_ = getBaseContext();
1010
1011 int width_ = display_.getWidth(); 1270 int width_ = display_.getWidth();
1012 int height_ = display_.getHeight(); 1271 int height_ = display_.getHeight();
1013 Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_); 1272 Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_);
1014 Log.e("Navit", "Navit -> dpi=" + Navit.metrics.densityDpi); 1273 Log.e("Navit", "Navit -> dpi=" + Navit.metrics.densityDpi);
1015 Log.e("Navit", "Navit -> density=" + Navit.metrics.density); 1274 Log.e("Navit", "Navit -> density=" + Navit.metrics.density);
1016 Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity); 1275 Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);
1276
1277 try
1278 {
1279 // send overspill factor to C-code
1280 Message msg33 = new Message();
1281 Bundle b33 = new Bundle();
1282 b33.putInt("Callback", 104);
1283 msg33.setData(b33);
1284 }
1285 catch (Exception eee)
1286 {
1287 }
1017 1288
1018 // ----- service ----- 1289 // ----- service -----
1019 // ----- service ----- 1290 // ----- service -----
1020 ZANaviMapDownloaderServiceIntent = new Intent(Navit.getBaseContext_, ZANaviMapDownloaderService.class); 1291 ZANaviMapDownloaderServiceIntent = new Intent(Navit.getBaseContext_, ZANaviMapDownloaderService.class);
1021 // ----- service ----- 1292 // ----- service -----
1086 { 1357 {
1087 } 1358 }
1088 1359
1089 startup_status = Navit_Status_NORMAL_STARTUP; 1360 startup_status = Navit_Status_NORMAL_STARTUP;
1090 1361
1362 // glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView_001);
1363 // glSurfaceView.setEGLContextClientVersion(2); // enable OpenGL 2.0
1364 // glSurfaceView.setRenderer(new GlRenderer());
1365 // glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // only render on demand
1366 //
1367 // // draw some sample lines ----
1368 // // draw some sample lines ----
1369 // // draw some sample lines ----
1370 // ZANaviGlLine vertLine = new ZANaviGlLine();
1371 // vertLine.SetVerts(1000f, 1000f, 0f, -1000f, -1000f, 0f);
1372 // vertLine.SetColor(.8f, .8f, 0f, 1.0f);
1373 //
1374 // float[] mMVPMatrix = new float[16];
1375 //
1376 // // Position the eye behind the origin.
1377 // final float eyeX = 0.0f;
1378 // final float eyeY = 0.0f;
1379 // final float eyeZ = 1.5f;
1380 //
1381 // // We are looking toward the distance
1382 // final float lookX = 0.0f;
1383 // final float lookY = 0.0f;
1384 // final float lookZ = -5.0f;
1385 //
1386 // // Set our up vector. This is where our head would be pointing were we holding the camera.
1387 // final float upX = 0.0f;
1388 // final float upY = 1.0f;
1389 // final float upZ = 0.0f;
1390 //
1391 // // Set the view matrix. This matrix can be said to represent the camera position.
1392 // // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
1393 // // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
1394 // Matrix.setLookAtM(mMVPMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
1395 //
1396 // vertLine.draw(mMVPMatrix);
1397 //
1398 // glSurfaceView.postInvalidate();
1399 // glSurfaceView.requestRender();
1400 // glSurfaceView.postInvalidate();
1401 // // draw some sample lines ----
1402 // // draw some sample lines ----
1403 // // draw some sample lines ----
1404
1091 // setup graphics objects 1405 // setup graphics objects
1092 // setup graphics objects 1406 // setup graphics objects
1093 // setup graphics objects 1407 // setup graphics objects
1094 NG__vehicle = new NavitGraphics(this, 1, 0, 0, 50, 50, 65535, 0, 0); 1408 NG__vehicle = new NavitGraphics(this, 1, 0, 0, 50, 50, 65535, 0, 0);
1095 NG__map_main = new NavitGraphics(this, 0, 0, 0, 100, 100, 0, 0, 0); 1409 NG__map_main = new NavitGraphics(this, 0, 0, 0, 100, 100, 0, 0, 0);
1107 // set the new locale here ----------------------------------- 1421 // set the new locale here -----------------------------------
1108 getPrefs_loc(); 1422 getPrefs_loc();
1109 activatePrefs_loc(); 1423 activatePrefs_loc();
1110 // set the new locale here ----------------------------------- 1424 // set the new locale here -----------------------------------
1111 1425
1112 System.out.println("CheckPOINT:a01");
1113
1114 // set map cache size here -----------------------------------
1115 getPrefs_mapcache();
1116 System.out.println("CheckPOINT:a02");
1117 activatePrefs_mapcache();
1118 // set map cache size here -----------------------------------
1119 System.out.println("CheckPOINT:a03");
1120
1121 // get map data dir and set it -----------------------------
1122 getPrefs_mapdir();
1123 System.out.println("CheckPOINT:a04");
1124 activatePrefs_mapdir(true);
1125 // get map data dir and set it -----------------------------
1126 System.out.println("CheckPOINT:a05");
1127
1128 // get special prefs here ------------------------------------
1129 get_prefs_highdpi();
1130 // get special prefs here ------------------------------------
1131
1132 System.out.println("CheckPOINT:a06");
1133
1134 // make sure the new path for the navitmap.bin file(s) exist!!
1135 File navit_maps_dir = new File(MAP_FILENAME_PATH);
1136 navit_maps_dir.mkdirs();
1137 // create nomedia files
1138 File nomedia_file = new File(MAP_FILENAME_PATH + ".nomedia");
1139 try
1140 {
1141 nomedia_file.createNewFile();
1142 }
1143 catch (Exception e1)
1144 {
1145 e1.printStackTrace();
1146 }
1147 // create nomedia files
1148
1149 // check if we already have a borders.bin file (if not, then extract the included simplified one)
1150 File b_ = new File(MAP_FILENAME_PATH + "/borders.bin");
1151 try
1152 {
1153 if (!b_.exists())
1154 {
1155 try
1156 {
1157 File c_ = new File(MAPMD5_FILENAME_PATH + "/borders.bin.md5");
1158 c_.delete();
1159 }
1160 catch (Exception e2)
1161 {
1162
1163 }
1164 Log.e("Navit", "trying to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1165 if (!extractRes("borders_simple", MAP_FILENAME_PATH + "/borders.bin"))
1166 {
1167 Log.e("Navit", "Failed to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1168 }
1169 }
1170 }
1171 catch (Exception e)
1172 {
1173
1174 }
1175 // check if we already have a borders.bin file
1176
1177 // get the local language ------------- 1426 // get the local language -------------
1178 Locale locale = java.util.Locale.getDefault(); 1427 Locale locale = java.util.Locale.getDefault();
1179 String lang = locale.getLanguage(); 1428 String lang = locale.getLanguage();
1180 String langu = lang; 1429 String langu = lang;
1181 String langc = lang; 1430 String langc = lang;
1201 NavitTextTranslations.sub_language = country.toUpperCase(locale); 1450 NavitTextTranslations.sub_language = country.toUpperCase(locale);
1202 } 1451 }
1203 Log.e("Navit", "Language " + lang); 1452 Log.e("Navit", "Language " + lang);
1204 // get the local language ------------- 1453 // get the local language -------------
1205 1454
1455 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
1456 no_maps_text.setText("\n\n\n" + Navit.get_text("No Maps installed") + "\n" + Navit.get_text("Please download a map") + "\n\n");
1457 // no_maps_text.postInvalidate();
1458
1459 // set map cache size here -----------------------------------
1460 getPrefs_mapcache();
1461 activatePrefs_mapcache();
1462 // set map cache size here -----------------------------------
1463
1464 // get map data dir and set it -----------------------------
1465 getPrefs_mapdir();
1466 activatePrefs_mapdir(true);
1467 // get map data dir and set it -----------------------------
1468
1469 // get special prefs here ------------------------------------
1470 get_prefs_highdpi();
1471 // get special prefs here ------------------------------------
1472
1473 // make sure the new path for the navitmap.bin file(s) exist!!
1474 File navit_maps_dir = new File(MAP_FILENAME_PATH);
1475 navit_maps_dir.mkdirs();
1476 // create nomedia files
1477 File nomedia_file = new File(MAP_FILENAME_PATH + ".nomedia");
1478 try
1479 {
1480 nomedia_file.createNewFile();
1481 }
1482 catch (Exception e1)
1483 {
1484 e1.printStackTrace();
1485 }
1486 // create nomedia files
1487
1488 // check if we already have a borders.bin file (if not, then extract the included simplified one)
1489 File b_ = new File(MAP_FILENAME_PATH + "/borders.bin");
1490 try
1491 {
1492 if (!b_.exists())
1493 {
1494 try
1495 {
1496 File c_ = new File(MAPMD5_FILENAME_PATH + "/borders.bin.md5");
1497 c_.delete();
1498 }
1499 catch (Exception e2)
1500 {
1501
1502 }
1503 Log.e("Navit", "trying to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1504 if (!extractRes("borders_simple", MAP_FILENAME_PATH + "/borders.bin"))
1505 {
1506 Log.e("Navit", "Failed to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
1507 }
1508 }
1509 }
1510 catch (Exception e)
1511 {
1512
1513 }
1514 // check if we already have a borders.bin file
1515
1206 // make sure the new path for config files exist 1516 // make sure the new path for config files exist
1207 File navit_cfg_dir = new File(CFG_FILENAME_PATH); 1517 File navit_cfg_dir = new File(CFG_FILENAME_PATH);
1208 navit_cfg_dir.mkdirs(); 1518 navit_cfg_dir.mkdirs();
1209 1519
1210 // make sure the new path for the navitmap.bin file(s) exist!! 1520 // make sure the new path for the navitmap.bin file(s) exist!!
1262 e.printStackTrace(); 1572 e.printStackTrace();
1263 } 1573 }
1264 1574
1265 try 1575 try
1266 { 1576 {
1577 if (get_reglevel() == 1)
1578 {
1579 System.out.println("##U:bonus 001##");
1580 Navit_DonateVersion_Installed = true;
1581 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1582 }
1583 }
1584 catch (Exception e)
1585 {
1586 e.printStackTrace();
1587 }
1588
1589 try
1590 {
1267 // is the "large map" donate version installed? 1591 // is the "large map" donate version installed?
1268 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0); 1592 pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0);
1269 String sharedUserId = pkgInfo.sharedUserId; 1593 String sharedUserId = pkgInfo.sharedUserId;
1270 System.out.println("str lm=" + sharedUserId); 1594 System.out.println("str lm=" + sharedUserId);
1271 1595
1283 } 1607 }
1284 catch (Exception e) 1608 catch (Exception e)
1285 { 1609 {
1286 e.printStackTrace(); 1610 e.printStackTrace();
1287 } 1611 }
1612
1613 try
1614 {
1615 if (get_reglevel() == 1)
1616 {
1617 System.out.println("##U:bonus 002##");
1618 Navit_DonateVersion_Installed = true;
1619 Navit_Largemap_DonateVersion_Installed = true;
1620 NavitMapDownloader.MULTI_NUM_THREADS = NavitMapDownloader.MULTI_NUM_THREADS_MAX;
1621 }
1622 }
1623 catch (Exception e)
1624 {
1625 e.printStackTrace();
1626 }
1627
1288 // update map list 1628 // update map list
1289 NavitMapDownloader.init_maps_without_donate_largemaps(); 1629 NavitMapDownloader.init_maps_without_donate_largemaps();
1290 // ---------- downloader threads ---------------- 1630 // ---------- downloader threads ----------------
1291 1631
1292 // ---- detect menu button ---- 1632 // ---- detect menu button ----
1305 1645
1306 Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow); 1646 Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow);
1307 Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off); 1647 Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off);
1308 Navit.follow_current = Navit.follow_on; 1648 Navit.follow_current = Navit.follow_on;
1309 1649
1310 if ((Navit.metrics.densityDpi >= 320) && (PREF_shrink_on_high_dpi)) 1650 if ((Navit.metrics.densityDpi >= 320) && (p.PREF_shrink_on_high_dpi))
1311 { 1651 {
1312 float factor; 1652 float factor;
1313 factor = (float) NavitGraphics.Global_Scaled_DPI_normal / (float) Navit.metrics.densityDpi; 1653 factor = (float) NavitGraphics.Global_Scaled_DPI_normal / (float) Navit.metrics.densityDpi;
1314 factor = factor * 1.7f; 1654 factor = factor * 1.7f;
1315 // 1655 //
1492 //String USER = android.os.Build.USER; 1832 //String USER = android.os.Build.USER;
1493 1833
1494 String android_version = "Android " + ANDROID; 1834 String android_version = "Android " + ANDROID;
1495 String android_device = MANUFACTURER + " " + BRAND + " " + DEVICE; 1835 String android_device = MANUFACTURER + " " + BRAND + " " + DEVICE;
1496 1836
1497 int api_version_int = Integer.valueOf(android.os.Build.VERSION.SDK); 1837 api_version_int = Integer.valueOf(android.os.Build.VERSION.SDK);
1498 System.out.println("XXX:API=" + api_version_int); 1838 System.out.println("XXX:API=" + api_version_int);
1499 if (api_version_int > 10) 1839 if (api_version_int > 10)
1500 { 1840 {
1501 Navit.PAINT_OLD_API = false; 1841 Navit.PAINT_OLD_API = false;
1502 } 1842 }
1516 // android_device = "telechips telechips m801"; 1856 // android_device = "telechips telechips m801";
1517 // debug 1857 // debug
1518 // debug 1858 // debug
1519 1859
1520 String android_rom_name = DISPLAY; 1860 String android_rom_name = DISPLAY;
1861
1862 if (FDBL)
1863 {
1864 android_rom_name = android_rom_name + "; FD";
1865 }
1866
1521 if (Navit_DonateVersion_Installed == false) 1867 if (Navit_DonateVersion_Installed == false)
1522 { 1868 {
1523 UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; 1869 UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1524 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")"; 1870 UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
1525 } 1871 }
1649 public void onClick(DialogInterface arg0, int arg1) 1995 public void onClick(DialogInterface arg0, int arg1)
1650 { 1996 {
1651 Log.e("Navit", "user wants more info, show the website"); 1997 Log.e("Navit", "user wants more info, show the website");
1652 // URL to ZANavi Manual (in english language) 1998 // URL to ZANavi Manual (in english language)
1653 String url = "http://zanavi.cc/index.php/Manual"; 1999 String url = "http://zanavi.cc/index.php/Manual";
2000 if (FDBL)
2001 {
2002 url = "http://fd.zanavi.cc/manual";
2003 }
1654 Intent i = new Intent(Intent.ACTION_VIEW); 2004 Intent i = new Intent(Intent.ACTION_VIEW);
1655 i.setData(Uri.parse(url)); 2005 i.setData(Uri.parse(url));
1656 startActivity(i); 2006 startActivity(i);
1657 } 2007 }
1658 }); 2008 });
1732 /* 2082 /*
1733 * show info box for first time users 2083 * show info box for first time users
1734 */ 2084 */
1735 2085
1736 // show info box for upgrade 2086 // show info box for upgrade
1737 if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION) 2087 // if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
1738 { 2088 // {
1739 try 2089 // try
1740 { 2090 // {
1741 message.setLayoutParams(rlp); 2091 // message.setLayoutParams(rlp);
1742 // upgrade message 2092 // // upgrade message
1743 String upgrade_summary = "\n\n***********\n"; 2093 // String upgrade_summary = "\n\n***********\n";
1744 // upgrade message 2094 // // upgrade message
1745 final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary); 2095 // final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
1746 Linkify.addLinks(s, Linkify.WEB_URLS); 2096 // Linkify.addLinks(s, Linkify.WEB_URLS);
1747 message.setText(s); 2097 // message.setText(s);
1748 message.setMovementMethod(LinkMovementMethod.getInstance()); 2098 // message.setMovementMethod(LinkMovementMethod.getInstance());
1749 infobox.setView(message); 2099 // infobox.setView(message);
1750 2100 //
1751 infobox.show(); 2101 // infobox.show();
1752 } 2102 // }
1753 catch (Exception e) 2103 // catch (Exception e)
1754 { 2104 // {
1755 e.printStackTrace(); 2105 // e.printStackTrace();
2106 // }
2107 //
1756 } 2108 // }
1757
1758 }
1759 // show info box for upgrade 2109 // show info box for upgrade
1760 2110
1761 // 2111 //
1762 // ----------- info popup 2112 // ----------- info popup
1763 // ----------- info popup 2113 // ----------- info popup
1764 // ----------- info popup 2114 // ----------- info popup
1765 // ----------- info popup 2115 // ----------- info popup
1766 // 2116 //
1767 if (!info_popup_seen_count_end) 2117 if ((!info_popup_seen_count_end) || (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION))
1768 { 2118 {
1769 try 2119 try
1770 { 2120 {
1771 //Builder a1 = new AlertDialog.Builder(this); 2121 //Builder a1 = new AlertDialog.Builder(this);
1772 //dialog_info_popup = a1.show(); 2122 //dialog_info_popup = a1.show();
1773 dialog_info_popup = new Dialog(this); 2123 dialog_info_popup = new Dialog(this);
1774 2124
1775 dialog_info_popup.setContentView(R.layout.info_popup); 2125 dialog_info_popup.setContentView(R.layout.info_popup);
1776 Button b_i1 = (Button) dialog_info_popup.findViewById(R.id.dialogButtonOK_i1); 2126 Button b_i1 = (Button) dialog_info_popup.findViewById(R.id.dialogButtonOK_i1);
2127
2128 TextView tv_i1 = (TextView) dialog_info_popup.findViewById(R.id.text_i1);
2129 final String ZANAVI_MSG_PLUGIN_MARKET_LINK = "https://play.google.com/store/apps/details?id=com.zoffcc.applications.zanavi_msg";
2130 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>"));
2131
2132 try
2133 {
2134 tv_i1.setMovementMethod(LinkMovementMethod.getInstance());
2135 }
2136 catch (Exception ee3)
2137 {
2138 }
2139
1777 b_i1.setText("Ok (" + (1 + info_popup_seen_count_max - info_popup_seen_count) + ")"); 2140 b_i1.setText("Ok (" + (1 + info_popup_seen_count_max - info_popup_seen_count) + ")");
1778 b_i1.setOnClickListener(new View.OnClickListener() 2141 b_i1.setOnClickListener(new View.OnClickListener()
1779 { 2142 {
1780 public void onClick(View v) 2143 public void onClick(View v)
1781 { 2144 {
1794 } 2157 }
1795 catch (Exception e) 2158 catch (Exception e)
1796 { 2159 {
1797 2160
1798 } 2161 }
2162
2163 try
2164 {
2165 // draw map no-async
2166 Message msg = new Message();
2167 Bundle b = new Bundle();
2168 b.putInt("Callback", 64);
2169 msg.setData(b);
2170 NavitGraphics.callback_handler.sendMessage(msg);
2171 }
2172 catch (Exception e)
2173 {
2174 e.printStackTrace();
2175 }
2176
1799 } 2177 }
1800 }); 2178 });
1801 dialog_info_popup.setCancelable(true); 2179 dialog_info_popup.setCancelable(true);
1802 dialog_info_popup.show(); 2180 dialog_info_popup.show();
1803 dialog_info_popup.getWindow().getDecorView().setBackgroundResource(R.drawable.rounded_bg); 2181 dialog_info_popup.getWindow().getDecorView().setBackgroundResource(R.drawable.rounded_bg);
1804 dialog_info_popup.setTitle(" We need your help"); 2182 dialog_info_popup.setTitle(" Try the new Plugin");
1805 } 2183 }
1806 catch (Exception e) 2184 catch (Exception e)
1807 { 2185 {
1808 e.printStackTrace(); 2186 e.printStackTrace();
1809 } 2187 }
2037 // xhdpi display (320 dpi) 2415 // xhdpi display (320 dpi)
2038 else if (Navit.metrics.densityDpi >= 320) 2416 else if (Navit.metrics.densityDpi >= 320)
2039 { 2417 {
2040 // set the map display DPI down. otherwise everything will be very small and unreadable 2418 // set the map display DPI down. otherwise everything will be very small and unreadable
2041 // and performance will be very low 2419 // and performance will be very low
2042 if (PREF_shrink_on_high_dpi) 2420 if (p.PREF_shrink_on_high_dpi)
2043 { 2421 {
2044 NavitGraphics.Global_want_dpi = NavitGraphics.Global_Scaled_DPI_normal; 2422 NavitGraphics.Global_want_dpi = NavitGraphics.Global_Scaled_DPI_normal;
2045 } 2423 }
2046 NavitGraphics.Global_want_dpi_other = NavitGraphics.Global_Scaled_DPI_normal; 2424 NavitGraphics.Global_want_dpi_other = NavitGraphics.Global_Scaled_DPI_normal;
2047 2425
2204 try 2582 try
2205 { 2583 {
2206 Intent sintent = new Intent(); 2584 Intent sintent = new Intent();
2207 sintent.setPackage("com.zoffcc.applications.zanavi_msg"); 2585 sintent.setPackage("com.zoffcc.applications.zanavi_msg");
2208 sintent.setAction("com.zoffcc.applications.zanavi_msg.ZanaviCloudService"); 2586 sintent.setAction("com.zoffcc.applications.zanavi_msg.ZanaviCloudService");
2209 ComponentName cname = startService(sintent); 2587 // ComponentName cname = startService(sintent);
2210 Log.i("NavitPlugin", "start Service res=" + cname); 2588 // Log.i("NavitPlugin", "start Service res=" + cname);
2211 System.out.println("NavitPlugin:bind to Service"); 2589 // System.out.println("NavitPlugin:bind to Service");
2212 boolean res_bind = bindService(sintent, serviceConnection, Context.BIND_AUTO_CREATE); 2590 boolean res_bind = bindService(sintent, serviceConnection, Context.BIND_AUTO_CREATE);
2213 Log.i("NavitPlugin", "bind to Service res=" + res_bind); 2591 // Log.i("NavitPlugin", "bind to Service res=" + res_bind);
2214 } 2592 }
2215 catch (Exception e) 2593 catch (Exception e)
2216 { 2594 {
2217 e.printStackTrace(); 2595 e.printStackTrace();
2218 } 2596 }
2219
2220 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 2597 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
2221 } 2598 }
2222 2599
2223 public static void show_mem_used() // wrapper 2600 public static void show_mem_used() // wrapper
2224 { 2601 {
2238 2615
2239 public static void show_mem_used_real() 2616 public static void show_mem_used_real()
2240 { 2617 {
2241 try 2618 try
2242 { 2619 {
2243 if (PREF_show_debug_messages) 2620 if (p.PREF_show_debug_messages)
2244 { 2621 {
2245 // --------- OLD method ----------- 2622 // --------- OLD method -----------
2246 // --------- OLD method ----------- 2623 // --------- OLD method -----------
2247 // int usedMegs; 2624 // int usedMegs;
2248 // //System.gc(); 2625 // //System.gc();
2405 super.onNewIntent(intent); 2782 super.onNewIntent(intent);
2406 2783
2407 try 2784 try
2408 { 2785 {
2409 System.out.println("XXIIXX(2):111"); 2786 System.out.println("XXIIXX(2):111");
2410 String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid"); 2787 String mid_str = intent.getExtras().getString("com.zoffcc.applications.zanavi.mid");
2788
2789 System.out.println("XXIIXX(2):111a:mid_str=" + mid_str);
2411 2790
2412 if (mid_str != null) 2791 if (mid_str != null)
2413 { 2792 {
2414 if (mid_str.equals("201:UPDATE-APP")) 2793 if (mid_str.equals("201:UPDATE-APP"))
2415 { 2794 {
2418 // a new ZANavi version is available, show something to the user here ------------------- 2797 // a new ZANavi version is available, show something to the user here -------------------
2419 // a new ZANavi version is available, show something to the user here ------------------- 2798 // a new ZANavi version is available, show something to the user here -------------------
2420 // a new ZANavi version is available, show something to the user here ------------------- 2799 // a new ZANavi version is available, show something to the user here -------------------
2421 // a new ZANavi version is available, show something to the user here ------------------- 2800 // a new ZANavi version is available, show something to the user here -------------------
2422 } 2801 }
2802 else if (mid_str.startsWith("202:UPDATE-MAP:"))
2803 {
2804 // System.out.println("need to update1:" + mid_str);
2805 // System.out.println("need to update2:" + mid_str.substring(15));
2806
2807 auto_start_update_map(mid_str.substring(15));
2423 } 2808 }
2809 }
2424 2810
2425 System.out.println("XXIIXX(2):111:mid_str=" + mid_str); 2811 System.out.println("XXIIXX(2):111b:mid_str=" + mid_str);
2426 } 2812 }
2427 catch (Exception e) 2813 catch (Exception e)
2428 { 2814 {
2429 2815 e.printStackTrace();
2816 System.out.println("XXIIXX(2):111:EEEE");
2430 } 2817 }
2431 2818
2432 // ---- Intent dump ---- 2819 // ---- Intent dump ----
2433 // ---- Intent dump ---- 2820 // ---- Intent dump ----
2434 // ---- Intent dump ---- 2821 // ---- Intent dump ----
2470 } 2857 }
2471 catch (Exception ee3) 2858 catch (Exception ee3)
2472 { 2859 {
2473 } 2860 }
2474 2861
2475 if (Navit.startup_intent == null) 2862 // if (Navit.startup_intent == null)
2476 { 2863 {
2477 try 2864 try
2478 { 2865 {
2479 // make a copy of the given intent object 2866 // make a copy of the given intent object
2480 Navit.startup_intent = intent.cloneFilter(); 2867 // Navit.startup_intent = intent.cloneFilter();
2868 Navit.startup_intent = intent;
2869
2481 Log.e("Navit", "3a:**1**001"); 2870 Log.e("Navit", "3a:**1**001");
2482 Bundle extras2 = intent.getExtras(); 2871 Bundle extras2 = intent.getExtras();
2483 Log.e("Navit", "3a:**1**002"); 2872 Log.e("Navit", "3a:**1**002");
2484 try 2873 try
2485 { 2874 {
2519 Log.e("Navit", "3a:**1**D " + startup_intent.getDataString()); 2908 Log.e("Navit", "3a:**1**D " + startup_intent.getDataString());
2520 Log.e("Navit", "3a:**1**S " + startup_intent.toString()); 2909 Log.e("Navit", "3a:**1**S " + startup_intent.toString());
2521 if (extras2 != null) 2910 if (extras2 != null)
2522 { 2911 {
2523 long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type"); 2912 long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
2524 System.out.println("DH:a007 l=" + l); 2913 // System.out.println("DH:a007 l=" + l);
2525 if (l != 0L) 2914 if (l != 0L)
2526 { 2915 {
2527 2916 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
2917 {
2528 // Log.e("Navit", "2:**1** started via drive home"); 2918 // Log.e("Navit", "2:**1** started via drive home");
2529 // we have been called from "drive home" widget 2919 // we have been called from "drive home" widget
2920
2921 // drive home
2922
2923 // check if we have a home location
2924 int home_id = find_home_point();
2925
2926 if (home_id != -1)
2927 {
2928 Message msg7 = progress_handler.obtainMessage();
2929 Bundle b7 = new Bundle();
2930 msg7.what = 2; // long Toast message
2931 b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
2932 msg7.setData(b7);
2933 progress_handler.sendMessage(msg7);
2934
2935 // clear any previous destinations
2936 Message msg2 = new Message();
2937 Bundle b2 = new Bundle();
2938 b2.putInt("Callback", 7);
2939 msg2.setData(b2);
2940 NavitGraphics.callback_handler.sendMessage(msg2);
2941
2942 // set position to middle of screen -----------------------
2943 // set position to middle of screen -----------------------
2944 // set position to middle of screen -----------------------
2945 // Message msg67 = new Message();
2946 // Bundle b67 = new Bundle();
2947 // b67.putInt("Callback", 51);
2948 // b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
2949 // b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
2950 // msg67.setData(b67);
2951 // N_NavitGraphics.callback_handler.sendMessage(msg67);
2952 // set position to middle of screen -----------------------
2953 // set position to middle of screen -----------------------
2954 // set position to middle of screen -----------------------
2955
2956 try
2957 {
2958 Thread.sleep(60);
2959 }
2960 catch (Exception e)
2961 {
2962 }
2963
2964 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);
2965
2966 // Navit.destination_set();
2967 //
2968 // // set destination to home location
2969 // String lat = String.valueOf(map_points.get(home_id).lat);
2970 // String lon = String.valueOf(map_points.get(home_id).lon);
2971 // String q = map_points.get(home_id).point_name;
2972 //
2973 // // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
2974 //
2975 // Message msg55 = new Message();
2976 // Bundle b55 = new Bundle();
2977 // b55.putInt("Callback", 3);
2978 // b55.putString("lat", lat);
2979 // b55.putString("lon", lon);
2980 // b55.putString("q", q);
2981 // msg55.setData(b55);
2982 // NavitGraphics.callback_handler.sendMessage(msg55);
2983
2984 final Thread zoom_to_route_001 = new Thread()
2985 {
2986 int wait = 1;
2987 int count = 0;
2988 int max_count = 60;
2989
2990 @Override
2991 public void run()
2992 {
2993 while (wait == 1)
2994 {
2995 try
2996 {
2997 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
2998 {
2999 zoom_to_route();
3000 wait = 0;
3001 }
3002 else
3003 {
3004 wait = 1;
3005 }
3006
3007 count++;
3008 if (count > max_count)
3009 {
3010 wait = 0;
3011 }
3012 else
3013 {
3014 Thread.sleep(400);
3015 }
3016 }
3017 catch (Exception e)
3018 {
3019 }
3020 }
3021 }
3022 };
3023 zoom_to_route_001.start();
3024
3025 // try
3026 // {
3027 // show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
3028 // }
3029 // catch (Exception e2)
3030 // {
3031 // e2.printStackTrace();
3032 // }
3033
3034 try
3035 {
3036 Navit.follow_button_on();
3037 }
3038 catch (Exception e2)
3039 {
3040 e2.printStackTrace();
3041 }
3042 }
3043 else
3044 {
3045 // no home location set
3046 Message msg = progress_handler.obtainMessage();
3047 Bundle b = new Bundle();
3048 msg.what = 2; // long Toast message
3049 b.putString("text", Navit.get_text("No Home Location set")); //TRANS
3050 msg.setData(b);
3051 progress_handler.sendMessage(msg);
3052 }
3053
3054 }
2530 } 3055 }
2531 else 3056 else
2532 { 3057 {
2533 if (startup_intent.getDataString() != null) 3058 if (startup_intent.getDataString() != null)
2534 { 3059 {
2590 getPrefs(); 3115 getPrefs();
2591 activatePrefs(); 3116 activatePrefs();
2592 sun_moon__mLastCalcSunMillis = -1L; 3117 sun_moon__mLastCalcSunMillis = -1L;
2593 3118
2594 // paint for bitmapdrawing on map 3119 // paint for bitmapdrawing on map
2595 if (PREF_use_anti_aliasing) 3120 if (p.PREF_use_anti_aliasing)
2596 { 3121 {
2597 NavitGraphics.paint_for_map_display.setAntiAlias(true); 3122 NavitGraphics.paint_for_map_display.setAntiAlias(true);
2598 } 3123 }
2599 else 3124 else
2600 { 3125 {
2601 NavitGraphics.paint_for_map_display.setAntiAlias(false); 3126 NavitGraphics.paint_for_map_display.setAntiAlias(false);
2602 } 3127 }
2603 if (PREF_use_map_filtering) 3128 if (p.PREF_use_map_filtering)
2604 { 3129 {
2605 NavitGraphics.paint_for_map_display.setFilterBitmap(true); 3130 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
2606 } 3131 }
2607 else 3132 else
2608 { 3133 {
2640 3165
2641 cwthr.NavitActivity2(0); 3166 cwthr.NavitActivity2(0);
2642 NavitVehicle.turn_on_sat_status(); 3167 NavitVehicle.turn_on_sat_status();
2643 } 3168 }
2644 3169
3170 @SuppressLint("NewApi")
2645 @Override 3171 @Override
2646 public void onResume() 3172 public void onResume()
2647 { 3173 {
2648 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 3174 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
2649 3175
2650 // System.gc(); 3176 // System.gc();
2651 super.onResume(); 3177 super.onResume();
3178
3179 // get the intent fresh !! ----------
3180 startup_intent = this.getIntent();
3181 // get the intent fresh !! ----------
2652 3182
2653 PackageInfo pkgInfo; 3183 PackageInfo pkgInfo;
2654 Navit_Plugin_001_Installed = false; 3184 Navit_Plugin_001_Installed = false;
2655 try 3185 try
2656 { 3186 {
2676 3206
2677 try 3207 try
2678 { 3208 {
2679 System.out.println("XXIIXX:111"); 3209 System.out.println("XXIIXX:111");
2680 String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid"); 3210 String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid");
3211 System.out.println("XXIIXX:111a:mid_str=" + mid_str);
2681 3212
2682 if (mid_str != null) 3213 if (mid_str != null)
2683 { 3214 {
2684 if (mid_str.equals("201:UPDATE-APP")) 3215 if (mid_str.equals("201:UPDATE-APP"))
2685 { 3216 {
2688 // a new ZANavi version is available, show something to the user here ------------------- 3219 // a new ZANavi version is available, show something to the user here -------------------
2689 // a new ZANavi version is available, show something to the user here ------------------- 3220 // a new ZANavi version is available, show something to the user here -------------------
2690 // a new ZANavi version is available, show something to the user here ------------------- 3221 // a new ZANavi version is available, show something to the user here -------------------
2691 // a new ZANavi version is available, show something to the user here ------------------- 3222 // a new ZANavi version is available, show something to the user here -------------------
2692 } 3223 }
3224 else if (mid_str.startsWith("202:UPDATE-MAP:"))
3225 {
3226 System.out.println("need to update1:" + mid_str);
3227 System.out.println("need to update2:" + mid_str.substring(15));
3228
3229 auto_start_update_map(mid_str.substring(15));
2693 } 3230 }
3231 }
2694 3232
2695 System.out.println("XXIIXX:111:mid_str=" + mid_str); 3233 System.out.println("XXIIXX:111b:mid_str=" + mid_str);
2696 } 3234 }
2697 catch (Exception e) 3235 catch (Exception e)
2698 { 3236 {
2699 e.printStackTrace(); 3237 e.printStackTrace();
3238 System.out.println("XXIIXX:111:EEEE");
2700 } 3239 }
2701 3240
2702 try 3241 try
2703 { 3242 {
2704 System.out.println("XXIIXX:" + this.getIntent()); 3243 System.out.println("XXIIXX:" + this.getIntent());
2814 dialog.show(); 3353 dialog.show();
2815 //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); 3354 //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
2816 //theButton.setOnClickListener(new CustomListener(dialog)); 3355 //theButton.setOnClickListener(new CustomListener(dialog));
2817 } 3356 }
2818 3357
3358 // reset "maps too old" flag
3359 Navit_maps_too_old = false;
3360
2819 if (Navit_maps_loaded == false) 3361 if (Navit_maps_loaded == false)
2820 { 3362 {
2821 Navit_maps_loaded = true; 3363 Navit_maps_loaded = true;
2822 // activate all maps 3364 // activate all maps
2823 Log.e("Navit", "**** LOAD ALL MAPS **** start"); 3365 Log.e("Navit", "**** LOAD ALL MAPS **** start");
2827 msg3.setData(b3); 3369 msg3.setData(b3);
2828 NavitGraphics.callback_handler.sendMessage(msg3); 3370 NavitGraphics.callback_handler.sendMessage(msg3);
2829 Log.e("Navit", "**** LOAD ALL MAPS **** end"); 3371 Log.e("Navit", "**** LOAD ALL MAPS **** end");
2830 } 3372 }
2831 3373
3374 try
3375 {
3376 if (!have_maps_installed())
3377 {
3378 // System.out.println("MMMM=no maps installed");
3379 // show semi transparent box "no maps installed" ------------------
3380 // show semi transparent box "no maps installed" ------------------
3381 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
3382 try
3383 {
3384 NavitGraphics.no_maps_container.setActivated(true);
3385 }
3386 catch (NoSuchMethodError e)
3387 {
3388 }
3389
3390 show_case_001();
3391
3392 // show semi transparent box "no maps installed" ------------------
3393 // show semi transparent box "no maps installed" ------------------
3394 }
3395 else
3396 {
3397 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
3398 try
3399 {
3400 NavitGraphics.no_maps_container.setActivated(false);
3401 }
3402 catch (NoSuchMethodError e)
3403 {
3404 }
3405 }
3406 }
3407 catch (Exception e)
3408 {
3409 e.printStackTrace();
3410 }
3411
3412 try
3413 {
3414 // draw map no-async
3415 Message msg = new Message();
3416 Bundle b = new Bundle();
3417 b.putInt("Callback", 64);
3418 msg.setData(b);
3419 NavitGraphics.callback_handler.sendMessage(msg);
3420 }
3421 catch (Exception e)
3422 {
3423 e.printStackTrace();
3424 }
3425
2832 String intent_data = null; 3426 String intent_data = null;
2833 try 3427 try
2834 { 3428 {
2835 //Log.e("Navit", "**9**A " + startup_intent.getAction()); 3429 //Log.e("Navit", "**9**A " + startup_intent.getAction());
2836 //Log.e("Navit", "**9**D " + startup_intent.getDataString()); 3430 //Log.e("Navit", "**9**D " + startup_intent.getDataString());
2858 } 3452 }
2859 3453
2860 if (type != 4) 3454 if (type != 4)
2861 { 3455 {
2862 Bundle extras = startup_intent.getExtras(); 3456 Bundle extras = startup_intent.getExtras();
2863 System.out.println("DH:001"); 3457 // System.out.println("DH:001");
2864 if (extras != null) 3458 if (extras != null)
2865 { 3459 {
2866 System.out.println("DH:002"); 3460 // System.out.println("DH:002");
2867 long l = extras.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type"); 3461 long l = extras.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
2868 System.out.println("DH:003 l=" + l); 3462 // System.out.println("DH:003 l=" + l);
2869 if (l != 0L) 3463 if (l != 0L)
2870 { 3464 {
2871 System.out.println("DH:004"); 3465 // System.out.println("DH:004");
2872 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME) 3466 if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME)
2873 { 3467 {
2874 System.out.println("DH:005"); 3468 // System.out.println("DH:005");
2875 type = 2; // call from drive-home-widget 3469 type = 2; // call from drive-home-widget
2876 } 3470 }
2877 // ok, now remove that key 3471 // ok, now remove that key
2878 extras.remove("com.zoffcc.applications.zanavi"); 3472 extras.remove("com.zoffcc.applications.zanavi");
2879 startup_intent.replaceExtras((Bundle) null); 3473 startup_intent.replaceExtras((Bundle) null);
2880 System.out.println("DH:006"); 3474 // System.out.println("DH:006");
2881 } 3475 }
2882 } 3476 }
2883 } 3477 }
2884 3478
2885 // ------------------------ BIG LOOP ------------------------ 3479 // ------------------------ BIG LOOP ------------------------
3087 { 3681 {
3088 Log.e("Navit", "timestamp for navigate_to expired! not using data"); 3682 Log.e("Navit", "timestamp for navigate_to expired! not using data");
3089 } 3683 }
3090 } 3684 }
3091 3685
3686 System.out.println("SUI:000a " + intent_data);
3687
3092 if ((intent_data != null) && ((intent_data.substring(0, 18).equals("google.navigation:")) || (intent_data.substring(0, 23).equals("http://maps.google.com/")) || (intent_data.substring(0, 24).equals("https://maps.google.com/")))) 3688 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/"))))
3093 { 3689 {
3690
3691 System.out.println("SUI:000b");
3692
3094 // better use regex later, but for now to test this feature its ok :-) 3693 // better use regex later, but for now to test this feature its ok :-)
3095 // better use regex later, but for now to test this feature its ok :-) 3694 // better use regex later, but for now to test this feature its ok :-)
3096 3695
3097 // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt= 3696 // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
3098 // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts) 3697 // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
3155 if (!Navit.NavitStartupAlreadySearching) 3754 if (!Navit.NavitStartupAlreadySearching)
3156 { 3755 {
3157 if (intent_data.length() > 19) 3756 if (intent_data.length() > 19)
3158 { 3757 {
3159 // if h: then show target 3758 // if h: then show target
3160 if (intent_data.substring(0, 23).equals("http://maps.google.com/")) 3759 if (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/"))
3161 { 3760 {
3162 Uri uri = Uri.parse(intent_data); 3761 Uri uri = Uri.parse(intent_data);
3163 Log.e("Navit", "target found (h): " + uri.getQueryParameter("q")); 3762 Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
3164 parsable = true; 3763 parsable = true;
3165 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target"; 3764 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3166 } 3765 }
3167 // if i: then show target 3766 // if i: then show target
3168 else if (intent_data.substring(0, 24).equals("https://maps.google.com/")) 3767 else if (substring_without_ioobe(intent_data, 0, 24).equals("https://maps.google.com/"))
3169 { 3768 {
3170 Uri uri = Uri.parse(intent_data); 3769 Uri uri = Uri.parse(intent_data);
3171 Log.e("Navit", "target found (i): " + uri.getQueryParameter("q")); 3770 Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
3172 parsable = true; 3771 parsable = true;
3173 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target"; 3772 intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
3174 } 3773 }
3175 // if d: then start target search 3774 // if d: then start target search
3176 else if ((intent_data.substring(0, 20).equals("google.navigation:q=")) && ((!intent_data.substring(20, 21).equals('+')) && (!intent_data.substring(20, 21).equals('-')) && (!intent_data.substring(20, 22).matches("[0-9][0-9]")))) 3775 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]"))))
3177 { 3776 {
3178 Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]); 3777 Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
3179 Navit.NavitStartupAlreadySearching = true; 3778 Navit.NavitStartupAlreadySearching = true;
3180 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]); 3779 start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
3181 // dont use this here, already starting search, so set to "false" 3780 // dont use this here, already starting search, so set to "false"
3182 parsable = false; 3781 parsable = false;
3183 unparsable_info_box = false; 3782 unparsable_info_box = false;
3184 } 3783 }
3185 // if b: then remodel the input string to look like a: 3784 // if b: then remodel the input string to look like a:
3186 else if (intent_data.substring(0, 20).equals("google.navigation:q=")) 3785 else if (substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q="))
3187 { 3786 {
3188 intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target"; 3787 intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
3189 Log.e("Navit", "target found (b): " + intent_data); 3788 Log.e("Navit", "target found (b): " + intent_data);
3190 parsable = true; 3789 parsable = true;
3191 } 3790 }
3192 // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a: 3791 // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
3193 else if (intent_data.substring(0, 25).equals("google.navigation:///?ll=")) 3792 else if (substring_without_ioobe(intent_data, 0, 25).equals("google.navigation:///?ll="))
3194 { 3793 {
3195 intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target"; 3794 intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
3196 Log.e("Navit", "target found (g): " + intent_data); 3795 Log.e("Navit", "target found (g): " + intent_data);
3197 parsable = true; 3796 parsable = true;
3198 } 3797 }
3199 // if e: then remodel the input string to look like a: 3798 // if e: then remodel the input string to look like a:
3200 else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1) && (intent_data.split("&")[1].substring(0, 1).toLowerCase().equals("f"))) 3799 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")))
3201 { 3800 {
3202 int idx = intent_data.indexOf("&"); 3801 int idx = intent_data.indexOf("&");
3203 intent_data = intent_data.substring(0, idx) + "&q=Target"; 3802 intent_data = substring_without_ioobe(intent_data, 0, idx) + "&q=Target";
3204 Log.e("Navit", "target found (e): " + intent_data); 3803 Log.e("Navit", "target found (e): " + intent_data);
3205 parsable = true; 3804 parsable = true;
3206 } 3805 }
3207 // if f: then remodel the input string to look like a: 3806 // if f: then remodel the input string to look like a:
3208 else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1)) 3807 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
3209 { 3808 {
3210 int idx = intent_data.indexOf("&"); 3809 int idx = intent_data.indexOf("&");
3211 intent_data = intent_data.substring(0, idx) + "&q=Target"; 3810 intent_data = intent_data.substring(0, idx) + "&q=Target";
3212 Log.e("Navit", "target found (f): " + intent_data); 3811 Log.e("Navit", "target found (f): " + intent_data);
3213 parsable = true; 3812 parsable = true;
3214 } 3813 }
3215 // already looks like a: just set flag 3814 // already looks like a: just set flag
3216 else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1)) 3815 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
3217 { 3816 {
3218 // dummy, just set the flag 3817 // dummy, just set the flag
3219 Log.e("Navit", "target found (a): " + intent_data); 3818 Log.e("Navit", "target found (a): " + intent_data);
3220 Log.e("Navit", "target found (a): " + intent_data.split("&q=").length); 3819 Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
3221 parsable = true; 3820 parsable = true;
3222 } 3821 }
3223 // if c: then remodel the input string to look like a: 3822 // if c: then remodel the input string to look like a:
3224 else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2)) 3823 else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
3225 { 3824 {
3226 3825
3227 intent_data = intent_data + "&q=Target"; 3826 intent_data = intent_data + "&q=Target";
3228 Log.e("Navit", "target found (c): " + intent_data); 3827 Log.e("Navit", "target found (c): " + intent_data);
3229 parsable = true; 3828 parsable = true;
3373 } 3972 }
3374 } 3973 }
3375 } 3974 }
3376 } 3975 }
3377 } 3976 }
3378 else if ((intent_data != null) && (intent_data.substring(0, 10).equals("geo:0,0?q="))) 3977 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 10).equals("geo:0,0?q=")))
3379 { 3978 {
3380 // g: geo:0,0?q=wien%20burggasse 3979 // g: geo:0,0?q=wien%20burggasse
3980
3981 System.out.println("SUI:001");
3381 3982
3382 boolean parsable = false; 3983 boolean parsable = false;
3383 boolean unparsable_info_box = true; 3984 boolean unparsable_info_box = true;
3384 try 3985 try
3385 { 3986 {
3388 catch (Exception e1) 3989 catch (Exception e1)
3389 { 3990 {
3390 e1.printStackTrace(); 3991 e1.printStackTrace();
3391 3992
3392 } 3993 }
3994
3995 System.out.println("SUI:002");
3393 3996
3394 if (!Navit.NavitStartupAlreadySearching) 3997 if (!Navit.NavitStartupAlreadySearching)
3395 { 3998 {
3396 if (intent_data.length() > 10) 3999 if (intent_data.length() > 10)
3397 { 4000 {
3435 } 4038 }
3436 } 4039 }
3437 } 4040 }
3438 4041
3439 } 4042 }
3440 else if ((intent_data != null) && (intent_data.substring(0, 4).equals("geo:"))) 4043 else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 4).equals("geo:")))
3441 { 4044 {
3442 // g: geo:16.8,46.3?z=15 4045 // g: geo:16.8,46.3?z=15
4046
4047 System.out.println("SUI:002a");
3443 4048
3444 boolean parsable = false; 4049 boolean parsable = false;
3445 boolean unparsable_info_box = true; 4050 boolean unparsable_info_box = true;
3446 4051
3447 String tmp1; 4052 String tmp1;
3539 4144
3540 } 4145 }
3541 } 4146 }
3542 } 4147 }
3543 4148
4149 System.out.println("SUI:099 XX" + substring_without_ioobe(intent_data, 0, 10) + "XX");
4150
3544 // clear intent 4151 // clear intent
3545 startup_intent = null; 4152 startup_intent = null;
3546 // ------------------------ BIG LOOP ------------------------ 4153 // ------------------------ BIG LOOP ------------------------
3547 // ------------------------ BIG LOOP ------------------------ 4154 // ------------------------ BIG LOOP ------------------------
3548 } 4155 }
3549 catch (Exception e) 4156 catch (Exception e)
3550 { 4157 {
3551 // e.printStackTrace(); 4158 e.printStackTrace();
4159 System.out.println("SUI:199");
3552 } 4160 }
3553 4161
3554 // clear intent 4162 // clear intent
3555 startup_intent = null; 4163 startup_intent = null;
3556 4164
3570 4178
3571 getPrefs(); 4179 getPrefs();
3572 activatePrefs(); 4180 activatePrefs();
3573 sun_moon__mLastCalcSunMillis = -1L; 4181 sun_moon__mLastCalcSunMillis = -1L;
3574 4182
4183 push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
4184 if (p.PREF_follow_gps)
4185 {
4186 push_pin_view.setImageResource(R.drawable.pin1_down);
4187 }
4188 else
4189 {
4190 push_pin_view.setImageResource(R.drawable.pin1_up);
4191 }
4192
3575 // paint for bitmapdrawing on map 4193 // paint for bitmapdrawing on map
3576 if (PREF_use_anti_aliasing) 4194 if (p.PREF_use_anti_aliasing)
3577 { 4195 {
3578 NavitGraphics.paint_for_map_display.setAntiAlias(true); 4196 NavitGraphics.paint_for_map_display.setAntiAlias(true);
3579 } 4197 }
3580 else 4198 else
3581 { 4199 {
3582 NavitGraphics.paint_for_map_display.setAntiAlias(false); 4200 NavitGraphics.paint_for_map_display.setAntiAlias(false);
3583 } 4201 }
3584 if (PREF_use_map_filtering) 4202 if (p.PREF_use_map_filtering)
3585 { 4203 {
3586 NavitGraphics.paint_for_map_display.setFilterBitmap(true); 4204 NavitGraphics.paint_for_map_display.setFilterBitmap(true);
3587 } 4205 }
3588 else 4206 else
3589 { 4207 {
3627 catch (Exception e) 4245 catch (Exception e)
3628 { 4246 {
3629 e.printStackTrace(); 4247 e.printStackTrace();
3630 } 4248 }
3631 4249
4250 // ----- check if we have some index files downloaded -----
4251 if (Navit.have_maps_installed())
4252 {
4253 if (Navit_maps_too_old)
4254 {
4255 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4256 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");
4257
4258 try
4259 {
4260 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4261 try
4262 {
4263 NavitGraphics.no_maps_container.setActivated(true);
4264 }
4265 catch (NoSuchMethodError e)
4266 {
4267 }
4268 NavitGraphics.no_maps_container.bringToFront();
4269 }
4270 catch (Exception e)
4271 {
4272 e.printStackTrace();
4273 }
4274 }
4275 else
4276 {
4277 allow_use_index_search();
4278 if (Navit_index_on_but_no_idx_files)
4279 {
4280 TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
4281 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");
4282
4283 try
4284 {
4285 NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
4286 try
4287 {
4288 NavitGraphics.no_maps_container.setActivated(true);
4289 }
4290 catch (NoSuchMethodError e)
4291 {
4292 }
4293 NavitGraphics.no_maps_container.bringToFront();
4294 }
4295 catch (Exception e)
4296 {
4297 e.printStackTrace();
4298 }
4299 }
4300 else
4301 {
4302 try
4303 {
4304 NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
4305 try
4306 {
4307 NavitGraphics.no_maps_container.setActivated(false);
4308 }
4309 catch (NoSuchMethodError e)
4310 {
4311 }
4312 }
4313 catch (Exception e)
4314 {
4315 e.printStackTrace();
4316 }
4317 }
4318 }
4319 }
4320 // ----- check if we have some index files downloaded -----
4321
3632 // ---- DEBUG ---- 4322 // ---- DEBUG ----
3633 // ---- DEBUG ---- 4323 // ---- DEBUG ----
3634 // ---- DEBUG ---- 4324 // ---- DEBUG ----
3635 try 4325 try
3636 { 4326 {
4327 if (!NavitVehicle.is_pos_recording)
4328 {
3637 if (PREF_enable_debug_write_gpx) 4329 if (p.PREF_enable_debug_write_gpx)
3638 { 4330 {
3639 NavitVehicle.pos_recording_start(); 4331 NavitVehicle.pos_recording_start();
3640 NavitVehicle.pos_recording_add(0, 0, 0, 0, 0, 0); 4332 NavitVehicle.pos_recording_add(0, 0, 0, 0, 0, 0);
4333 }
3641 } 4334 }
3642 } 4335 }
3643 catch (Exception e) 4336 catch (Exception e)
3644 { 4337 {
3645 } 4338 }
3646 // ---- DEBUG ---- 4339 // ---- DEBUG ----
3647 // ---- DEBUG ---- 4340 // ---- DEBUG ----
3648 // ---- DEBUG ---- 4341 // ---- DEBUG ----
4342
4343 // glSurfaceView.onResume();
3649 4344
3650 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 4345 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
3651 } 4346 }
3652 4347
3653 @TargetApi(Build.VERSION_CODES.FROYO) 4348 @TargetApi(Build.VERSION_CODES.FROYO)
3662 // ---- DEBUG ---- 4357 // ---- DEBUG ----
3663 // ---- DEBUG ---- 4358 // ---- DEBUG ----
3664 // -- dump all callbacks -- 4359 // -- dump all callbacks --
3665 try 4360 try
3666 { 4361 {
3667 if (PREF_enable_debug_functions) 4362 if (p.PREF_enable_debug_functions)
3668 { 4363 {
3669 Message msg99a = new Message(); 4364 Message msg99a = new Message();
3670 Bundle b99a = new Bundle(); 4365 Bundle b99a = new Bundle();
3671 b99a.putInt("Callback", 100); 4366 b99a.putInt("Callback", 100);
3672 msg99a.setData(b99a); 4367 msg99a.setData(b99a);
3684 // ---- DEBUG ---- 4379 // ---- DEBUG ----
3685 // ---- DEBUG ---- 4380 // ---- DEBUG ----
3686 // ---- DEBUG ---- 4381 // ---- DEBUG ----
3687 try 4382 try
3688 { 4383 {
4384 if (!Navit.is_navigating)
4385 {
3689 if (PREF_enable_debug_write_gpx) 4386 if (p.PREF_enable_debug_write_gpx)
3690 { 4387 {
3691 NavitVehicle.pos_recording_end(); 4388 NavitVehicle.pos_recording_end();
4389 }
3692 } 4390 }
3693 } 4391 }
3694 catch (Exception e) 4392 catch (Exception e)
3695 { 4393 {
3696 } 4394 }
3788 e.printStackTrace(); 4486 e.printStackTrace();
3789 } 4487 }
3790 4488
3791 turn_off_compass(); 4489 turn_off_compass();
3792 4490
3793 System.out.println("XXNAV: onpause:001"); 4491 // System.out.println("XXNAV: onpause:001");
3794 if (!Navit.is_navigating) 4492 if (!Navit.is_navigating)
3795 { 4493 {
3796 System.out.println("XXNAV: onpause:002"); 4494 // System.out.println("XXNAV: onpause:002");
3797 NavitVehicle.turn_off_all_providers(); 4495 NavitVehicle.turn_off_all_providers();
3798 NavitVehicle.turn_off_sat_status(); 4496 NavitVehicle.turn_off_sat_status();
3799 System.out.println("XXNAV: onpause:003"); 4497 // System.out.println("XXNAV: onpause:003");
3800 } 4498 }
3801 4499
3802 // Log.e("Navit", "OnPause"); 4500 // Log.e("Navit", "OnPause");
3803 cwthr.NavitActivity2(-1); 4501 cwthr.NavitActivity2(-1);
3804 4502
3830 } 4528 }
3831 catch (Exception e) 4529 catch (Exception e)
3832 { 4530 {
3833 e.printStackTrace(); 4531 e.printStackTrace();
3834 } 4532 }
4533
4534 // glSurfaceView.onPause();
3835 4535
3836 is_paused = true; 4536 is_paused = true;
3837 } 4537 }
3838 4538
3839 @Override 4539 @Override
4159 { 4859 {
4160 menu.findItem(R.id.overflow_announcer_off).setVisible(false); 4860 menu.findItem(R.id.overflow_announcer_off).setVisible(false);
4161 menu.findItem(R.id.overflow_announcer_on).setVisible(true); 4861 menu.findItem(R.id.overflow_announcer_on).setVisible(true);
4162 } 4862 }
4163 4863
4164 if (PREF_enable_debug_functions) 4864 if (p.PREF_enable_debug_functions)
4165 { 4865 {
4166 menu.findItem(R.id.overflow_dummy2).setVisible(true); 4866 menu.findItem(R.id.overflow_dummy2).setVisible(true);
4167 menu.findItem(R.id.overflow_demo_v_normal).setVisible(true); 4867 menu.findItem(R.id.overflow_demo_v_normal).setVisible(true);
4168 menu.findItem(R.id.overflow_demo_v_fast).setVisible(true); 4868 menu.findItem(R.id.overflow_demo_v_fast).setVisible(true);
4169 menu.findItem(R.id.overflow_speech_texts).setVisible(true); 4869 menu.findItem(R.id.overflow_speech_texts).setVisible(true);
4289 else 4989 else
4290 { 4990 {
4291 try 4991 try
4292 { 4992 {
4293 String tmp[] = current_target_string2.split(":", 2); 4993 String tmp[] = current_target_string2.split(":", 2);
4994
4995 if (Navit.OSD_route_001.arriving_time_valid)
4996 {
4997 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
4998 }
4999 else
5000 {
4294 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point")); 5001 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5002 }
5003
4295 } 5004 }
4296 catch (Exception e) 5005 catch (Exception e)
4297 { 5006 {
4298 e.printStackTrace(); 5007 e.printStackTrace();
4299 Log.e("Navit", "problem with target!"); 5008 Log.e("Navit", "problem with target!");
4318 // ------------ 5027 // ------------
4319 // share the current location with your friends 5028 // share the current location with your friends
4320 location_coords cur_target = null; 5029 location_coords cur_target = null;
4321 try 5030 try
4322 { 5031 {
5032 geo_coord tmp = get_current_vehicle_position();
5033 cur_target.lat = tmp.Latitude;
5034 cur_target.lon = tmp.Longitude;
4323 cur_target = NavitVehicle.get_last_known_pos(); 5035 // cur_target = NavitVehicle.get_last_known_pos();
4324 } 5036 }
4325 catch (Exception e) 5037 catch (Exception e)
4326 { 5038 {
4327 } 5039 }
4328 5040
4332 } 5044 }
4333 else 5045 else
4334 { 5046 {
4335 try 5047 try
4336 { 5048 {
4337 share_location(String.valueOf(cur_target.lat), String.valueOf(cur_target.lon), Navit.get_text("my Location"), Navit.get_text("my Location")); 5049 share_location(String.valueOf(cur_target.lat), String.valueOf(cur_target.lon), Navit.get_text("my Location"), Navit.get_text("my Location"), "", false);
4338 } 5050 }
4339 catch (Exception e) 5051 catch (Exception e)
4340 { 5052 {
4341 e.printStackTrace(); 5053 e.printStackTrace();
4342 Log.e("Navit", "problem with location!"); 5054 Log.e("Navit", "problem with location!");
4368 { 5080 {
4369 pm_temp2 = "1"; 5081 pm_temp2 = "1";
4370 } 5082 }
4371 5083
4372 search_intent2.putExtra("partial_match", pm_temp2); 5084 search_intent2.putExtra("partial_match", pm_temp2);
5085
5086 Navit.use_index_search = Navit.allow_use_index_search();
5087 if (Navit.use_index_search)
5088 {
5089 this.startActivityForResult(search_intent2, NavitAddressResultList_id);
5090 }
5091 else
5092 {
4373 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline); 5093 this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
5094 }
4374 5095
4375 return true; 5096 return true;
4376 } 5097 }
4377 else if (item.getItemId() == R.id.search_menu_online) 5098 else if (item.getItemId() == R.id.search_menu_online)
4378 { 5099 {
4402 b2.putInt("Callback", 7); 5123 b2.putInt("Callback", 7);
4403 msg2.setData(b2); 5124 msg2.setData(b2);
4404 NavitGraphics.callback_handler.sendMessage(msg2); 5125 NavitGraphics.callback_handler.sendMessage(msg2);
4405 Log.e("Navit", "stop navigation"); 5126 Log.e("Navit", "stop navigation");
4406 5127
4407 if (Navit.PREF_enable_debug_write_gpx) 5128 if (p.PREF_enable_debug_write_gpx)
4408 { 5129 {
4409 NavitVehicle.speech_recording_end(); 5130 NavitVehicle.speech_recording_end();
4410 } 5131 }
5132
5133 // redraw all OSD elements
5134 Navit.OSD_route_001.arriving_time_valid = false;
5135 Navit.OSD_route_001.arriving_secs_to_dest_valid = false;
5136 Navit.OSD_route_001.driving_distance_to_target_valid = false;
5137 Navit.OSD_nextturn.nextturn_distance_valid = false;
5138 Navit.OSD_nextturn.nextturn_image_valid = false;
5139 Navit.OSD_compass.direct_distance_to_target_valid = false;
5140 NavitGraphics.OSD_new.postInvalidate();
4411 5141
4412 return true; 5142 return true;
4413 } 5143 }
4414 else if (item.getItemId() == R.id.item_recentdest_menu_button) 5144 else if (item.getItemId() == R.id.item_recentdest_menu_button)
4415 { 5145 {
4569 // map download menu 5299 // map download menu
4570 Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class); 5300 Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
4571 this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id); 5301 this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
4572 break; 5302 break;
4573 case 5: 5303 case 5:
4574 // toggle the normal POI layers (to avoid double POIs) 5304 toggle_poi_pref();
4575 msg = new Message(); 5305 set_poi_layers();
4576 b = new Bundle(); 5306 draw_map();
4577 b.putInt("Callback", 5);
4578 b.putString("s", "POI Symbols");
4579 msg.setData(b);
4580 NavitGraphics.callback_handler.sendMessage(msg);
4581
4582 msg = new Message();
4583 b = new Bundle();
4584 b.putInt("Callback", 5);
4585 b.putString("s", "POI Labels");
4586 msg.setData(b);
4587 NavitGraphics.callback_handler.sendMessage(msg);
4588
4589 // toggle full POI icons on/off
4590 msg = new Message();
4591 b = new Bundle();
4592 b.putInt("Callback", 5);
4593 b.putString("s", "Android-POI-Icons-full");
4594 msg.setData(b);
4595 NavitGraphics.callback_handler.sendMessage(msg);
4596
4597 msg = new Message();
4598 b = new Bundle();
4599 b.putInt("Callback", 5);
4600 b.putString("s", "Android-POI-Labels-full");
4601 msg.setData(b);
4602 NavitGraphics.callback_handler.sendMessage(msg);
4603
4604 /*
4605 * POI Symbols
4606 * POI Labels
4607 * Android-POI-Icons-full
4608 * Android-POI-Labels-full
4609 */
4610
4611 break; 5307 break;
4612 case 6: 5308 case 6:
4613 // ok startup address search activity (online google maps search) 5309 // ok startup address search activity (online google maps search)
4614 Navit.use_index_search = false; 5310 Navit.use_index_search = false;
4615 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class); 5311 Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
4729 case 16: 5425 case 16:
4730 // show online manual 5426 // show online manual
4731 Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase()); 5427 Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase());
4732 // URL to ZANavi Manual (in english language) 5428 // URL to ZANavi Manual (in english language)
4733 String url = "http://zanavi.cc/index.php/Manual"; 5429 String url = "http://zanavi.cc/index.php/Manual";
5430 if (FDBL)
5431 {
5432 url = "http://fd.zanavi.cc/manual";
5433 }
4734 if (NavitTextTranslations.main_language.toLowerCase().equals("de")) 5434 if (NavitTextTranslations.main_language.toLowerCase().equals("de"))
4735 { 5435 {
4736 // show german manual 5436 // show german manual
4737 url = "http://zanavi.cc/index.php/Manual/de"; 5437 url = "http://zanavi.cc/index.php/Manual/de";
5438 if (FDBL)
5439 {
5440 url = "http://fd.zanavi.cc/manualde";
5441 }
4738 } 5442 }
4739 5443
4740 Intent i = new Intent(Intent.ACTION_VIEW); 5444 Intent i = new Intent(Intent.ACTION_VIEW);
4741 i.setData(Uri.parse(url)); 5445 i.setData(Uri.parse(url));
4742 startActivity(i); 5446 startActivity(i);
4781 this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id); 5485 this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id);
4782 break; 5486 break;
4783 case 20: 5487 case 20:
4784 // convert GPX file 5488 // convert GPX file
4785 Intent intent77 = new Intent(getBaseContext(), FileDialog.class); 5489 Intent intent77 = new Intent(getBaseContext(), FileDialog.class);
4786 File a = new File(PREF_last_selected_dir_gpxfiles); 5490 File a = new File(p.PREF_last_selected_dir_gpxfiles);
4787 try 5491 try
4788 { 5492 {
4789 // convert the "/../" in the path to normal absolut dir 5493 // convert the "/../" in the path to normal absolut dir
4790 intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath()); 5494 intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath());
4791 //can user select directories or not 5495 //can user select directories or not
4803 break; 5507 break;
4804 case 21: 5508 case 21:
4805 // add traffic block (like blocked road, or construction site) at current location of crosshair 5509 // add traffic block (like blocked road, or construction site) at current location of crosshair
4806 try 5510 try
4807 { 5511 {
5512 String traffic = "";
5513 if (Navit.GFX_OVERSPILL)
5514 {
5515 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)));
5516 }
5517 else
5518 {
4808 String traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2)); 5519 traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2));
5520 }
5521
4809 // System.out.println("traffic=" + traffic); 5522 // System.out.println("traffic=" + traffic);
4810 File traffic_file_dir = new File(MAP_FILENAME_PATH); 5523 File traffic_file_dir = new File(MAP_FILENAME_PATH);
4811 traffic_file_dir.mkdirs(); 5524 traffic_file_dir.mkdirs();
4812 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt"); 5525 File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
4813 FileOutputStream fOut = null; 5526 FileOutputStream fOut = null;
4903 else 5616 else
4904 { 5617 {
4905 try 5618 try
4906 { 5619 {
4907 String tmp[] = current_target_string2.split(":", 2); 5620 String tmp[] = current_target_string2.split(":", 2);
5621
5622 if (Navit.OSD_route_001.arriving_time_valid)
5623 {
5624 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
5625 }
5626 else
5627 {
4908 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point")); 5628 share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"), Navit.get_text("Meeting Point"), "", true);
5629 }
4909 } 5630 }
4910 catch (Exception e) 5631 catch (Exception e)
4911 { 5632 {
4912 e.printStackTrace(); 5633 e.printStackTrace();
4913 Log.e("Navit", "problem with target!"); 5634 Log.e("Navit", "problem with target!");
4935 //can user select directories or not 5656 //can user select directories or not
4936 intent771.putExtra(FileDialog.CAN_SELECT_DIR, false); 5657 intent771.putExtra(FileDialog.CAN_SELECT_DIR, false);
4937 // disable the "new" button 5658 // disable the "new" button
4938 intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN); 5659 intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
4939 //alternatively you can set file filter 5660 //alternatively you can set file filter
4940 intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt" }); 5661 intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" });
4941 startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id); 5662 startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id);
4942 } 5663 }
4943 catch (IOException e1) 5664 catch (IOException e1)
4944 { 5665 {
4945 e1.printStackTrace(); 5666 e1.printStackTrace();
4971 5692
4972 try 5693 try
4973 { 5694 {
4974 float lat = 0; 5695 float lat = 0;
4975 float lon = 0; 5696 float lon = 0;
5697
5698 String lat_lon = "";
5699 if (Navit.GFX_OVERSPILL)
5700 {
5701 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));
5702 }
5703 else
5704 {
4976 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); 5705 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);
5706 }
4977 String tmp[] = lat_lon.split(":", 2); 5707 String tmp[] = lat_lon.split(":", 2);
4978 //System.out.println("tmp=" + lat_lon); 5708 //System.out.println("tmp=" + lat_lon);
4979 lat = Float.parseFloat(tmp[0]); 5709 lat = Float.parseFloat(tmp[0]);
4980 lon = Float.parseFloat(tmp[1]); 5710 lon = Float.parseFloat(tmp[1]);
4981 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon); 5711 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
4995 5725
4996 Message msg = new Message(); 5726 Message msg = new Message();
4997 Bundle b = new Bundle(); 5727 Bundle b = new Bundle();
4998 b.putInt("Callback", 52); 5728 b.putInt("Callback", 52);
4999 b.putString("s", "45"); // speed in km/h of Demo-Vehicle 5729 b.putString("s", "45"); // speed in km/h of Demo-Vehicle
5730 // b.putString("s", "20");
5731
5000 msg.setData(b); 5732 msg.setData(b);
5001 NavitGraphics.callback_handler.sendMessage(msg); 5733 NavitGraphics.callback_handler.sendMessage(msg);
5002 } 5734 }
5003 catch (Exception e) 5735 catch (Exception e)
5004 { 5736 {
5008 demo_v_001.start(); 5740 demo_v_001.start();
5009 5741
5010 msg = new Message(); 5742 msg = new Message();
5011 b = new Bundle(); 5743 b = new Bundle();
5012 b.putInt("Callback", 51); 5744 b.putInt("Callback", 51);
5745
5746 if (Navit.GFX_OVERSPILL)
5747 {
5748 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5749 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5750 }
5751 else
5752 {
5013 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); 5753 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
5014 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); 5754 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
5755 }
5015 msg.setData(b); 5756 msg.setData(b);
5016 NavitGraphics.callback_handler.sendMessage(msg); 5757 NavitGraphics.callback_handler.sendMessage(msg);
5017 5758
5018 break; 5759 break;
5019 case 602: 5760 case 602:
5048 // DEBUG: activate FAST driving demo vehicle and set position to screen center 5789 // DEBUG: activate FAST driving demo vehicle and set position to screen center
5049 5790
5050 Navit.DemoVehicle = true; 5791 Navit.DemoVehicle = true;
5051 5792
5052 msg = new Message(); 5793 msg = new Message();
5794
5053 b = new Bundle(); 5795 b = new Bundle();
5054 b.putInt("Callback", 52); 5796 b.putInt("Callback", 52);
5055 b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle 5797 b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle
5056 msg.setData(b); 5798 msg.setData(b);
5057 NavitGraphics.callback_handler.sendMessage(msg); 5799 NavitGraphics.callback_handler.sendMessage(msg);
5058 5800
5059 msg = new Message(); 5801 msg = new Message();
5060 b = new Bundle(); 5802 b = new Bundle();
5061 b.putInt("Callback", 51); 5803 b.putInt("Callback", 51);
5804 if (Navit.GFX_OVERSPILL)
5805 {
5806 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
5807 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
5808 }
5809 else
5810 {
5062 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); 5811 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
5063 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); 5812 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
5813 }
5064 msg.setData(b); 5814 msg.setData(b);
5065 NavitGraphics.callback_handler.sendMessage(msg); 5815 NavitGraphics.callback_handler.sendMessage(msg);
5066 5816
5067 try 5817 try
5068 { 5818 {
5069 float lat = 0; 5819 float lat = 0;
5070 float lon = 0; 5820 float lon = 0;
5071 5821
5072 lat = 0; 5822 lat = 0;
5073 lon = 0; 5823 lon = 0;
5824 String lat_lon = "";
5825 if (Navit.GFX_OVERSPILL)
5826 {
5827 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));
5828 }
5829 else
5830 {
5074 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); 5831 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);
5832 }
5833
5075 String tmp[] = lat_lon.split(":", 2); 5834 String tmp[] = lat_lon.split(":", 2);
5076 //System.out.println("tmp=" + lat_lon); 5835 //System.out.println("tmp=" + lat_lon);
5077 lat = Float.parseFloat(tmp[0]); 5836 lat = Float.parseFloat(tmp[0]);
5078 lon = Float.parseFloat(tmp[1]); 5837 lon = Float.parseFloat(tmp[1]);
5079 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon); 5838 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
5337 { 6096 {
5338 if (resultCode == ActionBarActivity.RESULT_OK) 6097 if (resultCode == ActionBarActivity.RESULT_OK)
5339 { 6098 {
5340 try 6099 try
5341 { 6100 {
5342 Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id"))); 6101 // Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id")));
5343 // set map id to download 6102 // set map id to download
5344 Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))]; 6103 Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
5345 // show the map download progressbar, and download the map 6104 // show the map download progressbar, and download the map
5346 if (Navit.download_map_id > -1) 6105 if (Navit.download_map_id > -1)
5347 { 6106 {
5350 // --------- start a map download (highest level) --------- 6109 // --------- start a map download (highest level) ---------
5351 // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app 6110 // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app
5352 6111
5353 // new method in service 6112 // new method in service
5354 Message msg = progress_handler.obtainMessage(); 6113 Message msg = progress_handler.obtainMessage();
5355 Bundle b = new Bundle(); 6114 // Bundle b = new Bundle();
5356 msg.what = 22; 6115 msg.what = 22;
5357 progress_handler.sendMessage(msg); 6116 progress_handler.sendMessage(msg);
5358 6117
5359 // show license for OSM maps 6118 // show license for OSM maps
5360 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english 6119 //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
5379 Log.d("Navit", "error on onActivityResult"); 6138 Log.d("Navit", "error on onActivityResult");
5380 e.printStackTrace(); 6139 e.printStackTrace();
5381 } 6140 }
5382 break; 6141 break;
5383 case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!! 6142 case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!!
5384 // try
5385 // {
5386 // if (resultCode == Activity.RESULT_OK)
5387 // {
5388 // try
5389 // {
5390 // Log.d("Navit", "SEC id=" + Integer.parseInt(data.getStringExtra("selected_id")));
5391 // // set map id to download
5392 // Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
5393 // // show the map download progressbar, and download the map
5394 // if (Navit.download_map_id > -1)
5395 // {
5396 // showDialog(Navit.MAPDOWNLOAD_SEC_DIALOG);
5397 // }
5398 // }
5399 // catch (NumberFormatException e)
5400 // {
5401 // Log.d("Navit", "NumberFormatException selected_id");
5402 // }
5403 // }
5404 // else
5405 // {
5406 // // user pressed back key
5407 // }
5408 // }
5409 // catch (Exception e)
5410 // {
5411 // Log.d("Navit", "error on onActivityResult");
5412 // e.printStackTrace();
5413 // }
5414 break; 6143 break;
5415 case ZANaviVoiceInput_id: 6144 case ZANaviVoiceInput_id:
5416 if (resultCode == ActionBarActivity.RESULT_OK) 6145 if (resultCode == ActionBarActivity.RESULT_OK)
5417 { 6146 {
5418 try 6147 try
5421 double lat = data.getDoubleExtra("lat", 0); 6150 double lat = data.getDoubleExtra("lat", 0);
5422 double lon = data.getDoubleExtra("lon", 0); 6151 double lon = data.getDoubleExtra("lon", 0);
5423 String hn = ""; 6152 String hn = "";
5424 6153
5425 // save last address entry string 6154 // save last address entry string
5426 PREF_StreetSearchStrings = pushToArray(PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); 6155 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
5427 saveArray(PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); 6156 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
5428 6157
5429 Boolean partial_match = true; 6158 Boolean partial_match = true;
5430 Navit.use_index_search = false; 6159 Navit.use_index_search = false;
5431 6160
5432 Navit_last_address_partial_match = partial_match; 6161 Navit_last_address_partial_match = partial_match;
5490 { 6219 {
5491 hn = ""; 6220 hn = "";
5492 } 6221 }
5493 6222
5494 // save last address entry string 6223 // save last address entry string
5495 PREF_StreetSearchStrings = pushToArray(PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); 6224 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
5496 saveArray(PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); 6225 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
5497 6226
5498 Boolean partial_match = false; 6227 Boolean partial_match = false;
5499 try 6228 try
5500 { 6229 {
5501 // only from offline mask! 6230 // only from offline mask!
5557 Navit_last_address_search_country_iso2_string = data.getStringExtra("address_country_iso2"); 6286 Navit_last_address_search_country_iso2_string = data.getStringExtra("address_country_iso2");
5558 6287
5559 Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3); 6288 Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3);
5560 // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags); 6289 // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags);
5561 Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL* 6290 Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL*
5562 PREF_search_country = Navit_last_address_search_country_id; 6291 p.PREF_search_country = Navit_last_address_search_country_id;
5563 setPrefs_search_country(); 6292 setPrefs_search_country();
5564 } 6293 }
5565 catch (Exception e) 6294 catch (Exception e)
5566 { 6295 {
5567 6296
5659 { 6388 {
5660 if (data.getStringExtra("what").equals("view")) 6389 if (data.getStringExtra("what").equals("view"))
5661 { 6390 {
5662 // get the coords for the destination 6391 // get the coords for the destination
5663 int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); 6392 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6393
6394 // save last address entry string
6395 String addr = data.getStringExtra("address_string");
6396 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6397 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6398
6399 try
6400 {
6401 Navit.follow_button_off();
6402 }
6403 catch (Exception e2)
6404 {
6405 e2.printStackTrace();
6406 }
6407
6408 System.out.println("XSOM:009");
6409
6410 if (Navit.use_index_search)
6411 {
6412 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));
6413 }
6414 else
6415 {
6416 show_geo_on_screen_with_zoom_and_delay(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6417 }
6418 }
6419 else if (data.getStringExtra("what").equals("set"))
6420 {
6421 Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6422
6423 // save last address entry string
6424 String addr = data.getStringExtra("address_string");
6425 p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT);
6426 saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
6427
6428 // get the coords for the destination
6429 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6430
6431 String _addr = "";
6432 double _lat = 0;
6433 double _lon = 0;
6434
6435 // (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)
6436 // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)
6437
6438 // ok now set target
6439 try
6440 {
6441 if (Navit.use_index_search)
6442 {
6443 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6444 _lat = Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat);
6445 _lon = Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6446 //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));
6447 }
6448 else
6449 {
6450 _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr;
6451 _lat = Navit.NavitAddressResultList_foundItems.get(destination_id).lat;
6452 _lon = Navit.NavitAddressResultList_foundItems.get(destination_id).lon;
6453 //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6454 }
6455 // save points
6456 //write_map_points();
6457 }
6458 catch (Exception e)
6459 {
6460 e.printStackTrace();
6461 }
6462
6463 route_wrapper(_addr, 0, 0, false, _lat, _lon, true);
6464
6465 final Thread zoom_to_route_005 = new Thread()
6466 {
6467 int wait = 1;
6468 int count = 0;
6469 int max_count = 60;
6470
6471 @Override
6472 public void run()
6473 {
6474 while (wait == 1)
6475 {
6476 try
6477 {
6478 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6479 {
6480 zoom_to_route();
6481 wait = 0;
6482 }
6483 else
6484 {
6485 wait = 1;
6486 }
6487
6488 count++;
6489 if (count > max_count)
6490 {
6491 wait = 0;
6492 }
6493 else
6494 {
6495 Thread.sleep(400);
6496 }
6497 }
6498 catch (Exception e)
6499 {
6500 }
6501 }
6502 }
6503 };
6504 zoom_to_route_005.start();
6505 // zoom_to_route();
6506
6507 // ---------- DEBUG: write route to file ----------
6508 // ---------- DEBUG: write route to file ----------
6509 // ---------- DEBUG: write route to file ----------
6510 if (p.PREF_enable_debug_write_gpx)
6511 {
6512 write_route_to_gpx_file();
6513 }
6514 // ---------- DEBUG: write route to file ----------
6515 // ---------- DEBUG: write route to file ----------
6516
6517 try
6518 {
6519 Navit.follow_button_on();
6520 }
6521 catch (Exception e2)
6522 {
6523 e2.printStackTrace();
6524 }
6525
6526 // if (Navit.use_index_search)
6527 // {
6528 // 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));
6529 // }
6530 // else
6531 // {
6532 // show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
6533 // }
6534 }
6535 else
6536 {
6537 // -- nothing --
6538 }
6539 }
6540 catch (NumberFormatException e)
6541 {
6542 Log.d("Navit", "NumberFormatException selected_id");
6543 }
6544 catch (Exception e)
6545 {
6546
6547 }
6548 }
6549 else
6550 {
6551 // user pressed back key
6552 }
6553 }
6554 catch (Exception e)
6555 {
6556 Log.d("Navit", "error on onActivityResult");
6557 e.printStackTrace();
6558 }
6559 break;
6560 case NavitAddressSearch_id_gmaps:
6561 try
6562 {
6563 if (resultCode == ActionBarActivity.RESULT_OK)
6564 {
6565
6566 }
6567 }
6568 catch (Exception e)
6569 {
6570 e.printStackTrace();
6571 }
6572 break;
6573 case NavitAddressSearch_id_sharedest:
6574 try
6575 {
6576 if (resultCode == ActionBarActivity.RESULT_OK)
6577 {
6578
6579 }
6580 Log.d("Navit", "sharedest: finished");
6581 }
6582 catch (Exception e)
6583 {
6584 e.printStackTrace();
6585 }
6586 break;
6587 case NavitGeoCoordEnter_id:
6588 try
6589 {
6590 if (resultCode == ActionBarActivity.RESULT_OK)
6591 {
6592 // lat lon enter activitiy result
6593
6594 try
6595 {
6596 if (data.getStringExtra("what").equals("view"))
6597 {
6598 // get the coords for the destination
6599 float lat = Float.parseFloat(data.getStringExtra("lat"));
6600 float lon = Float.parseFloat(data.getStringExtra("lon"));
6601
6602 // Log.d("Navit", "coord picker: " + lat);
6603 // Log.d("Navit", "coord picker: " + lon);
5664 6604
5665 // set nice zoomlevel before we show destination 6605 // set nice zoomlevel before we show destination
5666 // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL; 6606 // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
5667 // // 6607 // //
5668 // Message msg = new Message(); 6608 // Message msg = new Message();
5692 catch (Exception e2) 6632 catch (Exception e2)
5693 { 6633 {
5694 e2.printStackTrace(); 6634 e2.printStackTrace();
5695 } 6635 }
5696 6636
5697 if (Navit.use_index_search)
5698 {
5699 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));
5700 }
5701 else
5702 {
5703 show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
5704 }
5705 }
5706 else
5707 {
5708 Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
5709 // get the coords for the destination
5710 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
5711
5712 // (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)
5713 // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)
5714
5715 // ok now set target
5716 try
5717 {
5718 if (Navit.use_index_search)
5719 {
5720 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));
5721 }
5722 else
5723 {
5724 Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
5725 }
5726 // save points
5727 write_map_points();
5728 }
5729 catch (Exception e)
5730 {
5731 e.printStackTrace();
5732 }
5733
5734 // DEBUG: clear route rectangle list
5735 NavitGraphics.route_rects.clear();
5736
5737 if (NavitGraphics.navit_route_status == 0)
5738 {
5739 Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Toast.LENGTH_SHORT).show(); //TRANS
5740 Navit.destination_set();
5741
5742 Message msg = new Message();
5743 Bundle b = new Bundle();
5744 b.putInt("Callback", 3);
5745 if (Navit.use_index_search)
5746 {
5747 b.putString("lat", String.valueOf((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)));
5748 b.putString("lon", String.valueOf((float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)));
5749 }
5750 else
5751 {
5752 b.putString("lat", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lat));
5753 b.putString("lon", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
5754 }
5755 b.putString("q", Navit.NavitAddressResultList_foundItems.get(destination_id).addr);
5756 msg.setData(b);
5757 NavitGraphics.callback_handler.sendMessage(msg);
5758 }
5759 else
5760 {
5761 Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Toast.LENGTH_SHORT).show(); //TRANS
5762 Message msg = new Message();
5763 Bundle b = new Bundle();
5764 b.putInt("Callback", 48);
5765 if (Navit.use_index_search)
5766 {
5767 b.putString("lat", String.valueOf((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)));
5768 b.putString("lon", String.valueOf((float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)));
5769 }
5770 else
5771 {
5772 b.putString("lat", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lat));
5773 b.putString("lon", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
5774 }
5775 b.putString("q", Navit.NavitAddressResultList_foundItems.get(destination_id).addr);
5776 msg.setData(b);
5777 NavitGraphics.callback_handler.sendMessage(msg);
5778 }
5779
5780 final Thread zoom_to_route_005 = new Thread()
5781 {
5782 int wait = 1;
5783 int count = 0;
5784 int max_count = 60;
5785
5786 @Override
5787 public void run()
5788 {
5789 while (wait == 1)
5790 {
5791 try
5792 {
5793 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
5794 {
5795 zoom_to_route();
5796 wait = 0;
5797 }
5798 else
5799 {
5800 wait = 1;
5801 }
5802
5803 count++;
5804 if (count > max_count)
5805 {
5806 wait = 0;
5807 }
5808 else
5809 {
5810 Thread.sleep(400);
5811 }
5812 }
5813 catch (Exception e)
5814 {
5815 }
5816 }
5817 }
5818 };
5819 zoom_to_route_005.start();
5820 // zoom_to_route();
5821
5822 // ---------- DEBUG: write route to file ----------
5823 // ---------- DEBUG: write route to file ----------
5824 // ---------- DEBUG: write route to file ----------
5825 if (PREF_enable_debug_write_gpx)
5826 {
5827 write_route_to_gpx_file();
5828 }
5829 // ---------- DEBUG: write route to file ----------
5830 // ---------- DEBUG: write route to file ----------
5831
5832 try
5833 {
5834 Navit.follow_button_on();
5835 }
5836 catch (Exception e2)
5837 {
5838 e2.printStackTrace();
5839 }
5840
5841 // if (Navit.use_index_search)
5842 // {
5843 // 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));
5844 // }
5845 // else
5846 // {
5847 // show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
5848 // }
5849 }
5850 }
5851 catch (NumberFormatException e)
5852 {
5853 Log.d("Navit", "NumberFormatException selected_id");
5854 }
5855 catch (Exception e)
5856 {
5857
5858 }
5859 }
5860 else
5861 {
5862 // user pressed back key
5863 }
5864 }
5865 catch (Exception e)
5866 {
5867 Log.d("Navit", "error on onActivityResult");
5868 e.printStackTrace();
5869 }
5870 break;
5871 case NavitAddressSearch_id_gmaps:
5872 try
5873 {
5874 if (resultCode == ActionBarActivity.RESULT_OK)
5875 {
5876
5877 }
5878 }
5879 catch (Exception e)
5880 {
5881 e.printStackTrace();
5882 }
5883 break;
5884 case NavitAddressSearch_id_sharedest:
5885 try
5886 {
5887 if (resultCode == ActionBarActivity.RESULT_OK)
5888 {
5889
5890 }
5891 Log.d("Navit", "sharedest: finished");
5892 }
5893 catch (Exception e)
5894 {
5895 e.printStackTrace();
5896 }
5897 break;
5898 case NavitGeoCoordEnter_id:
5899 try
5900 {
5901 if (resultCode == ActionBarActivity.RESULT_OK)
5902 {
5903 // lat lon enter activitiy result
5904
5905 try
5906 {
5907 if (data.getStringExtra("what").equals("view"))
5908 {
5909 // get the coords for the destination
5910 float lat = Float.parseFloat(data.getStringExtra("lat"));
5911 float lon = Float.parseFloat(data.getStringExtra("lon"));
5912
5913 Log.d("Navit", "coord picker: " + lat);
5914 Log.d("Navit", "coord picker: " + lon);
5915
5916 // set nice zoomlevel before we show destination
5917 // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
5918 // //
5919 // Message msg = new Message();
5920 // Bundle b = new Bundle();
5921 // b.putInt("Callback", 33);
5922 // b.putString("s", Integer.toString(zoom_want));
5923 // msg.setData(b);
5924 // try
5925 // {
5926 // N_NavitGraphics.callback_handler.sendMessage(msg);
5927 // Navit.GlobalScaleLevel = zoom_want;
5928 // }
5929 // catch (Exception e)
5930 // {
5931 // e.printStackTrace();
5932 // }
5933 // if (PREF_save_zoomlevel)
5934 // {
5935 // setPrefs_zoomlevel();
5936 // }
5937 // set nice zoomlevel before we show destination
5938
5939 try
5940 {
5941 Navit.follow_button_off();
5942 }
5943 catch (Exception e2)
5944 {
5945 e2.printStackTrace();
5946 }
5947
5948 show_geo_on_screen(lat, lon); 6637 show_geo_on_screen(lat, lon);
5949 } 6638 }
5950 else 6639 else
5951 { 6640 {
5952 // get the coords for the destination 6641 // get the coords for the destination
5960 dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon); 6649 dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon);
5961 if ((dest_name.equals(" ")) || (dest_name == null)) 6650 if ((dest_name.equals(" ")) || (dest_name == null))
5962 { 6651 {
5963 dest_name = "manual coordinates"; 6652 dest_name = "manual coordinates";
5964 } 6653 }
5965 Navit.remember_destination(dest_name, lat, lon); 6654 // Navit.remember_destination(dest_name, lat, lon);
5966 // save points 6655 // // save points
5967 write_map_points(); 6656 // write_map_points();
5968 } 6657 }
5969 catch (Exception e) 6658 catch (Exception e)
5970 { 6659 {
5971 e.printStackTrace(); 6660 e.printStackTrace();
5972 } 6661 }
5973 6662
5974 // DEBUG: clear route rectangle list 6663 // // DEBUG: clear route rectangle list
5975 NavitGraphics.route_rects.clear(); 6664 // NavitGraphics.route_rects.clear();
5976 6665 //
5977 if (NavitGraphics.navit_route_status == 0) 6666 // if (NavitGraphics.navit_route_status == 0)
5978 { 6667 // {
5979 Navit.destination_set(); 6668 // Navit.destination_set();
5980 6669 //
5981 Message msg = new Message(); 6670 // Message msg = new Message();
5982 Bundle b = new Bundle(); 6671 // Bundle b = new Bundle();
5983 b.putInt("Callback", 3); 6672 // b.putInt("Callback", 3);
5984 b.putString("lat", String.valueOf(lat)); 6673 // b.putString("lat", String.valueOf(lat));
5985 b.putString("lon", String.valueOf(lon)); 6674 // b.putString("lon", String.valueOf(lon));
5986 b.putString("q", dest_name); 6675 // b.putString("q", dest_name);
5987 msg.setData(b); 6676 // msg.setData(b);
5988 NavitGraphics.callback_handler.sendMessage(msg); 6677 // NavitGraphics.callback_handler.sendMessage(msg);
5989 } 6678 // }
5990 else 6679 // else
5991 { 6680 // {
5992 Message msg = new Message(); 6681 // Message msg = new Message();
5993 Bundle b = new Bundle(); 6682 // Bundle b = new Bundle();
5994 b.putInt("Callback", 48); 6683 // b.putInt("Callback", 48);
5995 b.putString("lat", String.valueOf(lat)); 6684 // b.putString("lat", String.valueOf(lat));
5996 b.putString("lon", String.valueOf(lon)); 6685 // b.putString("lon", String.valueOf(lon));
5997 b.putString("q", dest_name); 6686 // b.putString("q", dest_name);
5998 msg.setData(b); 6687 // msg.setData(b);
5999 NavitGraphics.callback_handler.sendMessage(msg); 6688 // NavitGraphics.callback_handler.sendMessage(msg);
6689 // }
6000 } 6690 //
6691
6692 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
6001 6693
6002 final Thread zoom_to_route_006 = new Thread() 6694 final Thread zoom_to_route_006 = new Thread()
6003 { 6695 {
6004 int wait = 1; 6696 int wait = 1;
6005 int count = 0; 6697 int count = 0;
6042 // zoom_to_route(); 6734 // zoom_to_route();
6043 6735
6044 // ---------- DEBUG: write route to file ---------- 6736 // ---------- DEBUG: write route to file ----------
6045 // ---------- DEBUG: write route to file ---------- 6737 // ---------- DEBUG: write route to file ----------
6046 // ---------- DEBUG: write route to file ---------- 6738 // ---------- DEBUG: write route to file ----------
6047 if (PREF_enable_debug_write_gpx) 6739 if (p.PREF_enable_debug_write_gpx)
6048 { 6740 {
6049 write_route_to_gpx_file(); 6741 write_route_to_gpx_file();
6050 } 6742 }
6051 // ---------- DEBUG: write route to file ---------- 6743 // ---------- DEBUG: write route to file ----------
6052 // ---------- DEBUG: write route to file ---------- 6744 // ---------- DEBUG: write route to file ----------
6085 { 6777 {
6086 Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id"))); 6778 Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id")));
6087 // get the coords for the destination 6779 // get the coords for the destination
6088 int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); 6780 int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
6089 6781
6090 // ok now set target 6782 if (data.getStringExtra("what").equals("view"))
6091 String dest_name = Navit.map_points.get(destination_id).point_name;
6092 float lat = Navit.map_points.get(destination_id).lat;
6093 float lon = Navit.map_points.get(destination_id).lon;
6094
6095 Navit_Point_on_Map t = Navit.map_points.get(destination_id);
6096 add_map_point(t);
6097
6098 // DEBUG: clear route rectangle list
6099 NavitGraphics.route_rects.clear();
6100
6101 if (NavitGraphics.navit_route_status == 0)
6102 { 6783 {
6103 Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + dest_name, Toast.LENGTH_SHORT).show(); //TRANS 6784 try
6104 Navit.destination_set(); 6785 {
6786 Navit.follow_button_off();
6787 }
6788 catch (Exception e2)
6789 {
6790 e2.printStackTrace();
6791 }
6105 6792
6106 Message msg = new Message(); 6793 float lat = Navit.map_points.get(destination_id).lat;
6107 Bundle b = new Bundle(); 6794 float lon = Navit.map_points.get(destination_id).lon;
6108 b.putInt("Callback", 3); 6795 show_geo_on_screen_with_zoom_and_delay(lat, lon, 150);
6109 b.putString("lat", String.valueOf(lat));
6110 b.putString("lon", String.valueOf(lon));
6111 b.putString("q", dest_name);
6112 msg.setData(b);
6113 NavitGraphics.callback_handler.sendMessage(msg);
6114 } 6796 }
6115 else 6797 else
6116 { 6798 {
6117 Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + dest_name, Toast.LENGTH_SHORT).show(); //TRANS 6799 // ok now set target
6118 Message msg = new Message(); 6800 String dest_name = Navit.map_points.get(destination_id).point_name;
6119 Bundle b = new Bundle(); 6801 float lat = Navit.map_points.get(destination_id).lat;
6120 b.putInt("Callback", 48); 6802 float lon = Navit.map_points.get(destination_id).lon;
6121 b.putString("lat", String.valueOf(lat));
6122 b.putString("lon", String.valueOf(lon));
6123 b.putString("q", dest_name);
6124 msg.setData(b);
6125 NavitGraphics.callback_handler.sendMessage(msg);
6126 }
6127 6803
6804 // System.out.println("XXXXXX:" + lat + " " + lon);
6805
6806 route_wrapper(dest_name, 0, 0, false, lat, lon, true);
6807
6128 final Thread zoom_to_route_007 = new Thread() 6808 final Thread zoom_to_route_007 = new Thread()
6129 {
6130 int wait = 1;
6131 int count = 0;
6132 int max_count = 60;
6133
6134 @Override
6135 public void run()
6136 { 6809 {
6137 while (wait == 1) 6810 int wait = 1;
6811 int count = 0;
6812 int max_count = 60;
6813
6814 @Override
6815 public void run()
6138 { 6816 {
6139 try 6817 while (wait == 1)
6140 { 6818 {
6141 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) 6819 try
6142 { 6820 {
6821 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33))
6822 {
6143 zoom_to_route(); 6823 zoom_to_route();
6144 wait = 0; 6824 wait = 0;
6825 }
6826 else
6827 {
6828 wait = 1;
6829 }
6830
6831 count++;
6832 if (count > max_count)
6833 {
6834 wait = 0;
6835 }
6836 else
6837 {
6838 Thread.sleep(400);
6839 }
6145 } 6840 }
6146 else 6841 catch (Exception e)
6147 { 6842 {
6148 wait = 1;
6149 }
6150
6151 count++;
6152 if (count > max_count)
6153 {
6154 wait = 0;
6155 }
6156 else
6157 {
6158 Thread.sleep(400);
6159 } 6843 }
6160 } 6844 }
6161 catch (Exception e)
6162 {
6163 }
6164 } 6845 }
6846 };
6847 zoom_to_route_007.start();
6848
6849 // ---------- DEBUG: write route to file ----------
6850 // ---------- DEBUG: write route to file ----------
6851 // ---------- DEBUG: write route to file ----------
6852 if (p.PREF_enable_debug_write_gpx)
6853 {
6854 write_route_to_gpx_file();
6165 } 6855 }
6166 };
6167 zoom_to_route_007.start();
6168 // zoom_to_route();
6169
6170 // ---------- DEBUG: write route to file ---------- 6856 // ---------- DEBUG: write route to file ----------
6171 // ---------- DEBUG: write route to file ---------- 6857 // ---------- DEBUG: write route to file ----------
6172 // ---------- DEBUG: write route to file ---------- 6858
6173 if (PREF_enable_debug_write_gpx) 6859 try
6174 { 6860 {
6175 write_route_to_gpx_file(); 6861 Navit.follow_button_on();
6862 }
6863 catch (Exception e2)
6864 {
6865 e2.printStackTrace();
6866 }
6867
6176 } 6868 }
6177 // ---------- DEBUG: write route to file ----------
6178 // ---------- DEBUG: write route to file ----------
6179
6180 try
6181 {
6182 Navit.follow_button_on();
6183 }
6184 catch (Exception e2)
6185 {
6186 e2.printStackTrace();
6187 }
6188
6189 // show_geo_on_screen(lat, lon);
6190
6191 } 6869 }
6192 } 6870 }
6193 catch (Exception e) 6871 catch (Exception e)
6194 { 6872 {
6195 e.printStackTrace(); 6873 e.printStackTrace();
6212 if (Navit_Largemap_DonateVersion_Installed) 6890 if (Navit_Largemap_DonateVersion_Installed)
6213 { 6891 {
6214 subject_d_version = subject_d_version + "L,"; 6892 subject_d_version = subject_d_version + "L,";
6215 } 6893 }
6216 6894
6895 try
6896 {
6897 int rl = get_reglevel();
6898
6899 if (rl > 0)
6900 {
6901 subject_d_version = "U" + rl + ",";
6902 }
6903 }
6904 catch (Exception e)
6905 {
6906 e.printStackTrace();
6907 }
6908
6909 String FD_addon = "";
6910 if (FDBL)
6911 {
6912 FD_addon = ",FD";
6913 }
6914
6217 sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text); 6915 sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + FD_addon + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text);
6218 } 6916 }
6219 } 6917 }
6220 catch (Exception e) 6918 catch (Exception e)
6221 { 6919 {
6222 e.printStackTrace(); 6920 e.printStackTrace();
6437 7135
6438 boolean your_are_speeding_old = Navit.your_are_speeding; 7136 boolean your_are_speeding_old = Navit.your_are_speeding;
6439 7137
6440 if ((Navit.cur_max_speed != -1) && (Navit.isGPSFix)) 7138 if ((Navit.cur_max_speed != -1) && (Navit.isGPSFix))
6441 { 7139 {
6442 if ((location.getSpeed() * 3.6f) > Navit.cur_max_speed) 7140 if ((location.getSpeed() * 3.6f) > ((float) Navit.cur_max_speed * (((float) p.PREF_roadspeed_warning_margin + 100.0f) / 100.0f)))
6443 { 7141 {
6444 Navit.your_are_speeding = true; 7142 Navit.your_are_speeding = true;
6445 7143
6446 try 7144 try
6447 { 7145 {
6449 if (!toneG_heared) 7147 if (!toneG_heared)
6450 { 7148 {
6451 // make "beep" sound to indicate we are going to fast!! 7149 // make "beep" sound to indicate we are going to fast!!
6452 if (toneG != null) 7150 if (toneG != null)
6453 { 7151 {
6454 if (Navit.PREF_roadspeed_warning) 7152 if (p.PREF_roadspeed_warning)
6455 { 7153 {
6456 toneG.stopTone(); 7154 toneG.stopTone();
6457 toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 500); 7155 toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 500);
6458 } 7156 }
6459 toneG_heared = true; 7157 toneG_heared = true;
6478 } 7176 }
6479 7177
6480 if (your_are_speeding_old != Navit.your_are_speeding) 7178 if (your_are_speeding_old != Navit.your_are_speeding)
6481 { 7179 {
6482 //System.out.println("xx paint 6 xx"); 7180 //System.out.println("xx paint 6 xx");
6483 NavitOSDJava.draw_real_wrapper(false, true); 7181 // NavitOSDJava.draw_real_wrapper(false, true);
7182 ZANaviLinearLayout.redraw_OSD(8);
6484 } 7183 }
6485 7184
6486 if (queue6.size() > 5) 7185 if (queue6.size() > 5)
6487 { 7186 {
6488 while (queue6.size() > 5) 7187 while (queue6.size() > 5)
6517 { 7216 {
6518 float lat = 0; 7217 float lat = 0;
6519 float lon = 0; 7218 float lon = 0;
6520 try 7219 try
6521 { 7220 {
6522 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); 7221 // 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);
7222 String lat_lon = "";
7223 if (Navit.GFX_OVERSPILL)
7224 {
7225 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));
7226 }
7227 else
7228 {
7229 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);
7230 }
7231
6523 String tmp[] = lat_lon.split(":", 2); 7232 String tmp[] = lat_lon.split(":", 2);
6524 //System.out.println("tmp=" + lat_lon); 7233 //System.out.println("tmp=" + lat_lon);
6525 lat = Float.parseFloat(tmp[0]); 7234 lat = Float.parseFloat(tmp[0]);
6526 lon = Float.parseFloat(tmp[1]); 7235 lon = Float.parseFloat(tmp[1]);
6527 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon); 7236 //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
6642 // -- set map detail level (after app startup) -- 7351 // -- set map detail level (after app startup) --
6643 // -- set map detail level (after app startup) -- 7352 // -- set map detail level (after app startup) --
6644 try 7353 try
6645 { 7354 {
6646 getPrefs_more_map_detail(); 7355 getPrefs_more_map_detail();
6647 if (PREF_more_map_detail > 0) 7356 if (p.PREF_more_map_detail > 0)
6648 { 7357 {
6649 Message msg2 = new Message(); 7358 Message msg2 = new Message();
6650 Bundle b2 = new Bundle(); 7359 Bundle b2 = new Bundle();
6651 b2.putInt("Callback", 78); 7360 b2.putInt("Callback", 78);
6652 b2.putString("s", "" + PREF_more_map_detail); 7361 b2.putString("s", "" + p.PREF_more_map_detail);
6653 msg2.setData(b2); 7362 msg2.setData(b2);
6654 NavitGraphics.callback_handler.sendMessage(msg2); 7363 NavitGraphics.callback_handler.sendMessage(msg2);
6655 } 7364 }
6656 } 7365 }
6657 catch (Exception e) 7366 catch (Exception e)
6665 // -- set map DPI factor (after app startup) -- 7374 // -- set map DPI factor (after app startup) --
6666 // -- set map DPI factor (after app startup) -- 7375 // -- set map DPI factor (after app startup) --
6667 // -- set map DPI factor (after app startup) -- 7376 // -- set map DPI factor (after app startup) --
6668 try 7377 try
6669 { 7378 {
6670 if ((Navit.metrics.densityDpi >= 320) && (!PREF_shrink_on_high_dpi)) 7379 if ((Navit.metrics.densityDpi >= 320) && (!p.PREF_shrink_on_high_dpi))
6671 { 7380 {
6672 double factor; 7381 double factor;
6673 factor = (double) Navit.metrics.densityDpi / (double) NavitGraphics.Global_Scaled_DPI_normal; 7382 factor = (double) Navit.metrics.densityDpi / (double) NavitGraphics.Global_Scaled_DPI_normal;
6674 7383
6675 Message msg2 = new Message(); 7384 Message msg2 = new Message();
6685 // e.printStackTrace(); 7394 // e.printStackTrace();
6686 } 7395 }
6687 // -- set map DPI factor (after app startup) -- 7396 // -- set map DPI factor (after app startup) --
6688 // -- set map DPI factor (after app startup) -- 7397 // -- set map DPI factor (after app startup) --
6689 // -- set map DPI factor (after app startup) -- 7398 // -- set map DPI factor (after app startup) --
6690
6691 Global_Init_Finished = 1; 7399 Global_Init_Finished = 1;
6692 //x.runOnUiThread(new Runnable() 7400 //x.runOnUiThread(new Runnable()
6693 //{ 7401 //{
6694 // public void run() 7402 // public void run()
6695 // { 7403 // {
6894 { 7602 {
6895 if (l8.type == 1) 7603 if (l8.type == 1)
6896 { 7604 {
6897 Navit.OSD_nextturn.nextturn_streetname_systematic = ""; 7605 Navit.OSD_nextturn.nextturn_streetname_systematic = "";
6898 Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(8, l8.b, l8.c); 7606 Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(8, l8.b, l8.c);
6899 if (Navit.PREF_item_dump) 7607 if (p.PREF_item_dump)
6900 { 7608 {
6901 // -------- DEBUG ------- DEBUG --------- 7609 // -------- DEBUG ------- DEBUG ---------
6902 // -------- DEBUG ------- DEBUG --------- 7610 // -------- DEBUG ------- DEBUG ---------
6903 // -------- DEBUG ------- DEBUG --------- 7611 // -------- DEBUG ------- DEBUG ---------
6904 Navit.debug_item_dump = NavitGraphics.CallbackGeoCalc(9, l8.b, l8.c); 7612 Navit.debug_item_dump = NavitGraphics.CallbackGeoCalc(9, l8.b, l8.c);
6908 // -------- DEBUG ------- DEBUG --------- 7616 // -------- DEBUG ------- DEBUG ---------
6909 // -------- DEBUG ------- DEBUG --------- 7617 // -------- DEBUG ------- DEBUG ---------
6910 } 7618 }
6911 //System.out.println("OSD postinvalidate***"); 7619 //System.out.println("OSD postinvalidate***");
6912 //System.out.println("xx paint 7 xx"); 7620 //System.out.println("xx paint 7 xx");
6913 NavitOSDJava.draw_real_wrapper(true, false); 7621 // NavitOSDJava.draw_real_wrapper(true, false);
7622 ZANaviLinearLayout.redraw_OSD(1);
6914 //++ NavitGraphics.NavitAOSDJava_.postInvalidate(); 7623 //++ NavitGraphics.NavitAOSDJava_.postInvalidate();
6915 } 7624 }
6916 else if (l8.type == 2) 7625 else if (l8.type == 2)
6917 { 7626 {
6918 NavitGraphics.CallbackGeoCalc(l8.a, l8.b, l8.c); 7627 NavitGraphics.CallbackGeoCalc(l8.a, l8.b, l8.c);
7628 }
7629 else if (l8.type == 13)
7630 {
7631 try
7632 {
7633 // get roadbook
7634 // String road_book_res = NavitGraphics.CallbackGeoCalc(13, l8.b, l8.c);
7635 String[] separated = NavitGraphics.GetRoadBookItems(12345);
7636 // System.out.println("ROADBOOK_RES=" + separated);
7637
7638 // parse roadbook data ------------
7639 road_book_items.clear();
7640 ZANaviListViewAdapter.ListViewItem l = null;
7641
7642 // String[] separated = road_book_res.split("\13");
7643 int jk = 0;
7644 int ResId = 0;
7645 for (jk = 0; jk < separated.length; jk++)
7646 {
7647 if (jk > 1)
7648 {
7649 // System.out.println("ROADBOOK_RES=" + jk + ":" + separated[jk]);
7650 String[] values = separated[jk].split(":");
7651 // 0 string:distance short form
7652 // 1 lat
7653 // 2 lon
7654 // 3 icon name
7655 // 4 text
7656
7657 // System.out.println("RBI:008:img=" + values[3]);
7658
7659 if (values[3].compareTo("nav_waypoint") == 0)
7660 {
7661 try
7662 {
7663 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_waypoint_bk_center", null, null);
7664 }
7665 catch (Exception e_res_id)
7666 {
7667 ResId = 0;
7668 e_res_id.printStackTrace();
7669 }
7670 }
7671 else if (values[3].compareTo("nav_destination") == 0)
7672 {
7673 try
7674 {
7675 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + "nav_destination_bk_center", null, null);
7676 }
7677 catch (Exception e_res_id)
7678 {
7679 ResId = 0;
7680 e_res_id.printStackTrace();
7681 }
7682 }
7683 else
7684 {
7685
7686 try
7687 {
7688 ResId = Navit.res_.getIdentifier("com.zoffcc.applications.zanavi:drawable/" + values[3] + "_bk", null, null);
7689 }
7690 catch (Exception e_res_id)
7691 {
7692 ResId = 0;
7693 e_res_id.printStackTrace();
7694 }
7695 }
7696
7697 // System.out.println("RBI:008+" + ResId);
7698 if (ResId != 0)
7699 {
7700 l = new ListViewItem(values[0], res_.getDrawable(ResId), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7701 }
7702 else
7703 {
7704 l = new ListViewItem(values[0], res_.getDrawable(R.drawable.mini_roundabout), "", values[4], Float.parseFloat(values[1]), Float.parseFloat(values[2]));
7705 }
7706 // System.out.println("RBI:008");
7707 road_book_items.add(l);
7708 // System.out.println("RBI:009");
7709 }
7710 }
7711 // System.out.println("RBI:010");
7712
7713 try
7714 {
7715 Message msg = Navit_progress_h.obtainMessage();
7716 Bundle b = new Bundle();
7717 msg.what = 33;
7718 msg.setData(b);
7719 Navit_progress_h.sendMessage(msg);
7720 }
7721 catch (Exception e)
7722 {
7723 e.printStackTrace();
7724 }
7725 // System.out.println("RBI:011");
7726 }
7727 catch (Exception eerb)
7728 {
7729 eerb.printStackTrace();
7730 }
7731 // parse roadbook data ------------
7732
6919 } 7733 }
6920 } 7734 }
6921 } 7735 }
6922 catch (Exception e) 7736 catch (Exception e)
6923 { 7737 {
7335 { 8149 {
7336 open_search_result_list(); 8150 open_search_result_list();
7337 } 8151 }
7338 else 8152 else
7339 { 8153 {
7340 // not results found, show toast 8154 // no results found, show toast
7341 msg = mHandler.obtainMessage(); 8155 msg = mHandler.obtainMessage();
7342 b = new Bundle(); 8156 b = new Bundle();
7343 msg.what = 2; 8157 msg.what = 2;
7344 b.putString("text", Navit.get_text("No Results found!")); //TRANS 8158 b.putString("text", Navit.get_text("No Results found!")); //TRANS
7345 msg.setData(b); 8159 msg.setData(b);
7404 else if (msg.getData().getInt("Callback") == 2) 8218 else if (msg.getData().getInt("Callback") == 2)
7405 { 8219 {
7406 // zoom out 8220 // zoom out
7407 NavitGraphics.CallbackMessageChannel(2, ""); 8221 NavitGraphics.CallbackMessageChannel(2, "");
7408 } 8222 }
8223 else if (msg.getData().getInt("Callback") == 55599)
8224 {
8225 // calc route after adding points
8226 NavitGraphics.CallbackMessageChannel(55599, "");
8227 }
8228 else if (msg.getData().getInt("Callback") == 55503)
8229 {
8230 try
8231 {
8232 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0);
8233 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8234 }
8235 catch (Exception e)
8236 {
8237 }
8238
8239 // get values
8240 String lat = msg.getData().getString("lat");
8241 String lon = msg.getData().getString("lon");
8242 String q = msg.getData().getString("q");
8243 // set routing target to lat,lon
8244 NavitGraphics.CallbackMessageChannel(55503, lat + "#" + lon + "#" + q);
8245 }
7409 else if (msg.getData().getInt("Callback") == 3) 8246 else if (msg.getData().getInt("Callback") == 3)
7410 { 8247 {
7411 try 8248 try
7412 { 8249 {
7413 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0); 8250 NavitVehicle.pos_recording_add(2, 0, 0, 0, 0, 0);
7421 String lat = msg.getData().getString("lat"); 8258 String lat = msg.getData().getString("lat");
7422 String lon = msg.getData().getString("lon"); 8259 String lon = msg.getData().getString("lon");
7423 String q = msg.getData().getString("q"); 8260 String q = msg.getData().getString("q");
7424 // set routing target to lat,lon 8261 // set routing target to lat,lon
7425 NavitGraphics.CallbackMessageChannel(3, lat + "#" + lon + "#" + q); 8262 NavitGraphics.CallbackMessageChannel(3, lat + "#" + lon + "#" + q);
8263 }
8264 else if (msg.getData().getInt("Callback") == 55548)
8265 {
8266 try
8267 {
8268 NavitVehicle.pos_recording_add(3, Float.parseFloat(msg.getData().getString("lat")), Float.parseFloat(msg.getData().getString("lon")), 0, 0, 0);
8269 }
8270 catch (Exception e)
8271 {
8272 }
8273
8274 // get values
8275 String lat = msg.getData().getString("lat");
8276 String lon = msg.getData().getString("lon");
8277 String q = msg.getData().getString("q");
8278 // append to routing, add waypoint at lat,lon
8279 NavitGraphics.CallbackMessageChannel(55548, lat + "#" + lon + "#" + q);
7426 } 8280 }
7427 else if (msg.getData().getInt("Callback") == 48) 8281 else if (msg.getData().getInt("Callback") == 48)
7428 { 8282 {
7429 try 8283 try
7430 { 8284 {
7931 else if (msg.getData().getInt("Callback") == 102) 8785 else if (msg.getData().getInt("Callback") == 102)
7932 { 8786 {
7933 // set gpsfix flag 8787 // set gpsfix flag
7934 String s = msg.getData().getString("s"); 8788 String s = msg.getData().getString("s");
7935 NavitGraphics.CallbackMessageChannel(102, s); 8789 NavitGraphics.CallbackMessageChannel(102, s);
8790 }
8791 else if (msg.getData().getInt("Callback") == 103)
8792 {
8793 // draw location of self (car) x% lower than screen center
8794 String s = msg.getData().getString("s");
8795 NavitGraphics.CallbackMessageChannel(103, s);
8796 }
8797 else if (msg.getData().getInt("Callback") == 104)
8798 {
8799 // send OVERSPILL_FACTOR to C-code
8800 String s;
8801 if (Navit.GFX_OVERSPILL)
8802 {
8803 s = msg.getData().getString("" + (OVERSPILL_FACTOR * 100));
8804 }
8805 else
8806 {
8807 s = msg.getData().getString("" + 100);
8808 }
8809 NavitGraphics.CallbackMessageChannel(104, s);
8810 }
8811 else if (msg.getData().getInt("Callback") == 105)
8812 {
8813 // zoom to specific zoomlevel without redrawing the map!
8814 String s = msg.getData().getString("s");
8815 NavitGraphics.CallbackMessageChannel(105, s);
8816 }
8817 else if (msg.getData().getInt("Callback") == 106)
8818 {
8819 // factor for routing/road speed
8820 String s = msg.getData().getString("s");
8821 NavitGraphics.CallbackMessageChannel(106, s);
8822 }
8823 else if (msg.getData().getInt("Callback") == 107)
8824 {
8825 // level 0 announcement seconds
8826 String s = msg.getData().getString("s");
8827 NavitGraphics.CallbackMessageChannel(107, s);
8828 }
8829 else if (msg.getData().getInt("Callback") == 108)
8830 {
8831 // level 1 announcement seconds
8832 String s = msg.getData().getString("s");
8833 NavitGraphics.CallbackMessageChannel(108, s);
8834 }
8835 else if (msg.getData().getInt("Callback") == 109)
8836 {
8837 // level 2 announcement seconds
8838 String s = msg.getData().getString("s");
8839 NavitGraphics.CallbackMessageChannel(109, s);
8840 }
8841 else if (msg.getData().getInt("Callback") == 110)
8842 {
8843 // generic int option CallBack [<option name>:<option value "int">]
8844 String s = msg.getData().getString("s");
8845 NavitGraphics.CallbackMessageChannel(110, s);
8846 }
8847 else if (msg.getData().getInt("Callback") == 111)
8848 {
8849 // show real gps position on map
8850 String s = msg.getData().getString("s");
8851 NavitGraphics.CallbackMessageChannel(111, s);
7936 } 8852 }
7937 else if (msg.getData().getInt("Callback") == 9901) 8853 else if (msg.getData().getInt("Callback") == 9901)
7938 { 8854 {
7939 // if follow mode is on, then dont show freeview streetname 8855 // if follow mode is on, then dont show freeview streetname
7940 //if (!Navit.PREF_follow_gps) 8856 //if (!Navit.PREF_follow_gps)
8116 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity); 9032 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
8117 9033
8118 try 9034 try
8119 { 9035 {
8120 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification); 9036 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9037 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9038 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9039 // {
9040 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9041 // }
9042
8121 } 9043 }
8122 catch (Exception e) 9044 catch (Exception e)
8123 { 9045 {
8124 e.printStackTrace(); 9046 e.printStackTrace();
8125 9047
8127 { 9049 {
8128 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT); 9050 p_activity = PendingIntent.getActivity(getBaseContext_, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);
8129 9051
8130 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity); 9052 notification.setLatestEventInfo(getBaseContext_, Notification_header, Notification_text, p_activity);
8131 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification); 9053 nm.notify(ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2, notification);
9054 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2++;
9055 // if (ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 > 2000)
9056 // {
9057 // ZANaviMapDownloaderService.NOTIFICATION_ID__DUMMY2 = 1001;
9058 // }
8132 } 9059 }
8133 catch (Exception e2) 9060 catch (Exception e2)
8134 { 9061 {
8135 e2.printStackTrace(); 9062 e2.printStackTrace();
8136 } 9063 }
8463 e.printStackTrace(); 9390 e.printStackTrace();
8464 } 9391 }
8465 9392
8466 break; 9393 break;
8467 case 25: 9394 case 25:
8468 Log.e("Navit", "nav: 25"); 9395 // Log.e("Navit", "nav: 25");
8469 NavitGraphics.deactivate_nav_wakelock_real(); 9396 NavitGraphics.deactivate_nav_wakelock_real();
8470 break; 9397 break;
8471 case 26: 9398 case 26:
8472 Log.e("Navit", "nav: 26"); 9399 // Log.e("Navit", "nav: 26");
8473 NavitGraphics.activate_nav_wakelock_real(); 9400 NavitGraphics.activate_nav_wakelock_real();
8474 break; 9401 break;
8475 case 27: 9402 case 27:
8476 show_status_bar(); 9403 show_status_bar();
8477 break; 9404 break;
8488 } 9415 }
8489 catch (Exception e) 9416 catch (Exception e)
8490 { 9417 {
8491 e.printStackTrace(); 9418 e.printStackTrace();
8492 } 9419 }
9420 break;
9421 case 31:
9422 try
9423 {
9424 // map download menu
9425 Intent map_download_list_activity = new Intent(getBaseContext_, NavitDownloadSelectMapActivity.class);
9426 startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
9427 }
9428 catch (Exception e)
9429 {
9430 e.printStackTrace();
9431 }
9432 break;
9433 case 32:
9434 try
9435 {
9436 if (p.PREF_follow_gps)
9437 {
9438 push_pin_view.setImageResource(R.drawable.pin1_down);
9439 }
9440 else
9441 {
9442 push_pin_view.setImageResource(R.drawable.pin1_up);
9443 }
9444 }
9445 catch (Exception e)
9446 {
9447 e.printStackTrace();
9448 }
9449 break;
9450 case 33:
9451 if (road_book != null)
9452 {
9453 if (road_book_items != null)
9454 {
9455 try
9456 {
9457 // send new roadbook items to fragment and reload it
9458 road_book.reload_items(road_book_items);
9459 }
9460 catch (Exception e)
9461 {
9462 }
9463 }
9464 }
9465 break;
9466 case 34:
9467 // show bubble
9468 NavitGraphics.whats_here_container_wrap.setVisibility(View.VISIBLE);
9469 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9470 break;
9471 case 35:
9472 // hide bubble
9473 NavitGraphics.whats_here_container_wrap.setVisibility(View.INVISIBLE);
9474 NavitGraphics.whats_here_text.setText(" " + Navit.get_text("loading ...") + " ");
9475 // and move out of screen
9476
9477 if (!Navit.PAINT_OLD_API)
9478 {
9479 NavitGraphics.whats_here_container_wrap.setX(-2000);
9480 NavitGraphics.whats_here_container_wrap.setY(-2000);
9481 // NavitGraphics.whats_here_container_wrap.requestLayout();
9482
9483 NavitGraphics.whats_here_pointer_image.setX(0);
9484 }
9485 else
9486 {
9487 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9488 NavitGraphics.params_whats_here_container_wrap.leftMargin = -2000;
9489 NavitGraphics.params_whats_here_container_wrap.topMargin = -2000;
9490 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9491 NavitGraphics.whats_here_container_wrap.requestLayout();
9492
9493 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9494 // NavitGraphics.params_whats_here_pointer_image.leftMargin = 0;
9495 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9496 NavitGraphics.whats_here_pointer_image.requestLayout();
9497
9498 }
9499 break;
9500 case 36:
9501 // move bubble to x,y
9502 int width_in_px = getResources().getDimensionPixelSize(R.dimen.whats_here_container_width);
9503 int new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x;
9504 int new_diff = 0;
9505 if ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) > NavitGraphics.mCanvasWidth)
9506 {
9507 new_diff = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9508 new_x = NavitGraphics.NavitAOverlay_s.bubble_001.x - ((NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth);
9509 }
9510
9511 new_x = new_x - NavitGraphics.dp_to_px(17);
9512
9513 if (!Navit.PAINT_OLD_API)
9514 {
9515 NavitGraphics.whats_here_container_wrap.setX(new_x);
9516 NavitGraphics.whats_here_container_wrap.setY(NavitGraphics.NavitAOverlay_s.bubble_001.y + NavitGraphics.dp_to_px(17));
9517 // NavitGraphics.whats_here_container_wrap.requestLayout();
9518
9519 NavitGraphics.whats_here_pointer_image.setX(new_diff);
9520 }
9521 else
9522 {
9523 NavitGraphics.params_whats_here_container_wrap = (android.widget.RelativeLayout.LayoutParams) NavitGraphics.whats_here_container_wrap.getLayoutParams();
9524 NavitGraphics.params_whats_here_container_wrap.leftMargin = new_x;
9525 NavitGraphics.params_whats_here_container_wrap.topMargin = NavitGraphics.NavitAOverlay_s.bubble_001.y - NavitGraphics.whats_here_container_wrap.getHeight() + NavitGraphics.dp_to_px(17);
9526 NavitGraphics.whats_here_container_wrap.setLayoutParams(NavitGraphics.params_whats_here_container_wrap);
9527 NavitGraphics.whats_here_container_wrap.requestLayout();
9528
9529 NavitGraphics.params_whats_here_pointer_image = (RelativeLayout.LayoutParams) NavitGraphics.whats_here_pointer_image.getLayoutParams();
9530 // NavitGraphics.params_whats_here_pointer_image.leftMargin = (NavitGraphics.NavitAOverlay_s.bubble_001.x + width_in_px) - NavitGraphics.mCanvasWidth;
9531 NavitGraphics.whats_here_pointer_image.setLayoutParams(NavitGraphics.params_whats_here_pointer_image);
9532 NavitGraphics.whats_here_pointer_image.requestLayout();
9533 }
9534 break;
9535 case 37:
9536 // set text for point on screen
9537 String dest_name = "Point on Screen";
9538
9539 try
9540 {
9541 if (Navit.GFX_OVERSPILL)
9542 {
9543 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);
9544 }
9545 else
9546 {
9547 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);
9548 }
9549
9550 if ((dest_name.equals(" ")) || (dest_name == null))
9551 {
9552 dest_name = "Point on Screen";
9553 }
9554 }
9555 catch (Exception e)
9556 {
9557 e.printStackTrace();
9558 }
9559
9560 NavitGraphics.whats_here_text.setText(dest_name);
9561 break;
9562 case 38:
9563 try
9564 {
9565 NavitAddressSearchActivity.adapter.clear();
9566 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9567 // NavitAddressSearchActivity.listview.postInvalidate();
9568 }
9569 catch (Exception e)
9570 {
9571 System.out.println("AAEE:001");
9572 }
9573 break;
9574 case 39:
9575 try
9576 {
9577 NavitAddressSearchActivity.adapter.notifyDataSetChanged();
9578 }
9579 catch (Exception e)
9580 {
9581 System.out.println("AAEE:008");
9582 }
9583 break;
8493 case 99: 9584 case 99:
8494 // dismiss dialog, remove dialog - generic 9585 // dismiss dialog, remove dialog - generic
8495 try 9586 try
8496 { 9587 {
8497 Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num")); 9588 Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
8628 9719
8629 DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener() 9720 DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener()
8630 { 9721 {
8631 public void onDismiss(DialogInterface dialog) 9722 public void onDismiss(DialogInterface dialog)
8632 { 9723 {
8633 LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes(); 9724 android.view.WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
8634 mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams); 9725 mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
8635 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); 9726 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
8636 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); 9727 mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
8637 Log.e("Navit", "onDismiss: mapdownloader_dialog pri"); 9728 Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
8638 dialog.dismiss(); 9729 dialog.dismiss();
8837 9928
8838 public static void set_2d3d_mode_in_settings() 9929 public static void set_2d3d_mode_in_settings()
8839 { 9930 {
8840 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 9931 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
8841 SharedPreferences.Editor editor = prefs.edit(); 9932 SharedPreferences.Editor editor = prefs.edit();
8842 editor.putBoolean("show_3d_map", PREF_show_3d_map); 9933 editor.putBoolean("show_3d_map", p.PREF_show_3d_map);
8843 editor.commit(); 9934 editor.commit();
8844 } 9935 }
8845 9936
8846 public static void follow_button_on() 9937 public static void follow_button_on()
8847 { 9938 {
8848 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 9939 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
8849 SharedPreferences.Editor editor = prefs.edit(); 9940 SharedPreferences.Editor editor = prefs.edit();
8850 Navit.follow_current = Navit.follow_on; 9941 Navit.follow_current = Navit.follow_on;
8851 PREF_follow_gps = true; 9942 p.PREF_follow_gps = true;
8852 editor.putBoolean("follow_gps", PREF_follow_gps); 9943 editor.putBoolean("follow_gps", p.PREF_follow_gps);
8853 editor.commit(); 9944 editor.commit();
8854 9945
8855 // hold all map drawing ----------- 9946 // hold all map drawing -----------
8856 Message msg = new Message(); 9947 Message msg = new Message();
8857 Bundle b = new Bundle(); 9948 Bundle b = new Bundle();
8865 { 9956 {
8866 e.printStackTrace(); 9957 e.printStackTrace();
8867 } 9958 }
8868 // hold all map drawing ----------- 9959 // hold all map drawing -----------
8869 9960
9961 msg = Navit_progress_h.obtainMessage();
9962 b = new Bundle();
9963 msg.what = 32;
9964 try
9965 {
9966 Navit_progress_h.sendMessage(msg);
9967 }
9968 catch (Exception e)
9969 {
9970 }
9971
8870 getPrefs(); 9972 getPrefs();
8871 activatePrefs(1); 9973 activatePrefs(1);
8872 9974
8873 // follow mode ON ----------- 9975 // follow mode ON -----------
8874 msg = new Message(); 9976 msg = new Message();
8911 public static void follow_button_off() 10013 public static void follow_button_off()
8912 { 10014 {
8913 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 10015 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
8914 SharedPreferences.Editor editor = prefs.edit(); 10016 SharedPreferences.Editor editor = prefs.edit();
8915 Navit.follow_current = Navit.follow_off; 10017 Navit.follow_current = Navit.follow_off;
8916 PREF_follow_gps = false; 10018 p.PREF_follow_gps = false;
8917 editor.putBoolean("follow_gps", PREF_follow_gps); 10019 editor.putBoolean("follow_gps", p.PREF_follow_gps);
8918 editor.commit(); 10020 editor.commit();
8919 getPrefs(); 10021 getPrefs();
8920 activatePrefs(1); 10022 activatePrefs(1);
8921 10023
8922 // follow mode OFF ----------- 10024 // follow mode OFF -----------
8931 catch (Exception e) 10033 catch (Exception e)
8932 { 10034 {
8933 } 10035 }
8934 // follow mode OFF ----------- 10036 // follow mode OFF -----------
8935 10037
10038 msg = Navit_progress_h.obtainMessage();
10039 b = new Bundle();
10040 msg.what = 32;
10041 try
10042 {
10043 Navit_progress_h.sendMessage(msg);
10044 }
10045 catch (Exception e)
10046 {
10047 }
10048
8936 // JB fix 10049 // JB fix
8937 //NavitGraphics.NavitAOSDJava_.postInvalidate(); 10050 //NavitGraphics.NavitAOSDJava_.postInvalidate();
8938 //System.out.println("xx paint 13 xx"); 10051 //System.out.println("xx paint 13 xx");
8939 NavitGraphics.OSD_new.postInvalidate(); 10052 NavitGraphics.OSD_new.postInvalidate();
8940 NavitGraphics.NavitAOverlay_s.postInvalidate(); 10053 NavitGraphics.NavitAOverlay_s.postInvalidate();
8941 10054
8942 } 10055 }
8943 10056
10057 public static void toggle_poi_pref()
10058 {
10059 // PREF_show_poi_on_map
10060 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10061 SharedPreferences.Editor editor = prefs.edit();
10062 if (p.PREF_show_poi_on_map)
10063 {
10064 p.PREF_show_poi_on_map = false;
10065 }
10066 else
10067 {
10068 p.PREF_show_poi_on_map = true;
10069 }
10070 editor.putBoolean("show_poi_on_map", p.PREF_show_poi_on_map);
10071 editor.commit();
10072 }
10073
8944 public static void toggle_follow_button() 10074 public static void toggle_follow_button()
8945 { 10075 {
8946 // the "red needle" OSD calls this function only!! 10076 // the "red needle" OSD calls this function only!!
8947 //Log.e("NavitVehicle", "toggle_follow_button"); 10077 //Log.e("NavitVehicle", "toggle_follow_button");
8948 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 10078 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
8949 SharedPreferences.Editor editor = prefs.edit(); 10079 SharedPreferences.Editor editor = prefs.edit();
8950 if (PREF_follow_gps) 10080 if (p.PREF_follow_gps)
8951 { 10081 {
8952 Navit.follow_current = Navit.follow_off; 10082 Navit.follow_current = Navit.follow_off;
8953 PREF_follow_gps = false; 10083 p.PREF_follow_gps = false;
8954 10084
8955 // follow mode OFF ----------- 10085 // follow mode OFF -----------
8956 Message msg = new Message(); 10086 Message msg = new Message();
8957 Bundle b = new Bundle(); 10087 Bundle b = new Bundle();
8958 b.putInt("Callback", 75); 10088 b.putInt("Callback", 75);
8969 // follow mode OFF ----------- 10099 // follow mode OFF -----------
8970 } 10100 }
8971 else 10101 else
8972 { 10102 {
8973 Navit.follow_current = Navit.follow_on; 10103 Navit.follow_current = Navit.follow_on;
8974 PREF_follow_gps = true; 10104 p.PREF_follow_gps = true;
8975 10105
8976 // follow mode ON ----------- 10106 // follow mode ON -----------
8977 Message msg = new Message(); 10107 Message msg = new Message();
8978 Bundle b = new Bundle(); 10108 Bundle b = new Bundle();
8979 b.putInt("Callback", 74); 10109 b.putInt("Callback", 74);
8986 { 10116 {
8987 e.printStackTrace(); 10117 e.printStackTrace();
8988 } 10118 }
8989 // follow mode ON ----------- 10119 // follow mode ON -----------
8990 } 10120 }
8991 editor.putBoolean("follow_gps", PREF_follow_gps); 10121 editor.putBoolean("follow_gps", p.PREF_follow_gps);
8992 editor.commit(); 10122 editor.commit();
8993 //if (!PREF_follow_gps) 10123 //if (!PREF_follow_gps)
8994 //{ 10124 //{
8995 // // no compass turning without follow mode! 10125 // // no compass turning without follow mode!
8996 // PREF_use_compass_heading_base = false; 10126 // PREF_use_compass_heading_base = false;
8999 //{ 10129 //{
9000 // // child is always "false" when parent is "false" !! 10130 // // child is always "false" when parent is "false" !!
9001 // PREF_use_compass_heading_always = false; 10131 // PREF_use_compass_heading_always = false;
9002 //} 10132 //}
9003 10133
10134 Message msg = Navit_progress_h.obtainMessage();
10135 Bundle b = new Bundle();
10136 msg.what = 32;
10137 try
10138 {
10139 Navit_progress_h.sendMessage(msg);
10140 }
10141 catch (Exception e)
10142 {
10143 }
10144
9004 // hold all map drawing ----------- 10145 // hold all map drawing -----------
9005 Message msg = new Message(); 10146 msg = new Message();
9006 Bundle b = new Bundle(); 10147 b = new Bundle();
9007 b.putInt("Callback", 69); 10148 b.putInt("Callback", 69);
9008 msg.setData(b); 10149 msg.setData(b);
9009 try 10150 try
9010 { 10151 {
9011 NavitGraphics.callback_handler.sendMessage(msg); 10152 NavitGraphics.callback_handler.sendMessage(msg);
9046 { 10187 {
9047 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 10188 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
9048 10189
9049 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 10190 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
9050 SharedPreferences.Editor editor = prefs.edit(); 10191 SharedPreferences.Editor editor = prefs.edit();
9051 editor.putInt("search_country_id", PREF_search_country); 10192 editor.putInt("search_country_id", p.PREF_search_country);
9052 editor.commit(); 10193 editor.commit();
9053 10194
9054 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 10195 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
9055 } 10196 }
9056 10197
9072 { 10213 {
9073 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 10214 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
9074 10215
9075 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 10216 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
9076 SharedPreferences.Editor editor = prefs.edit(); 10217 SharedPreferences.Editor editor = prefs.edit();
9077 editor.putString("last_selected_dir_gpxfiles", PREF_last_selected_dir_gpxfiles); 10218 editor.putString("last_selected_dir_gpxfiles", p.PREF_last_selected_dir_gpxfiles);
9078 editor.commit(); 10219 editor.commit();
9079 10220
9080 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 10221 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
9081 } 10222 }
9082 10223
9086 10227
9087 // int ret = 0; 10228 // int ret = 0;
9088 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 10229 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
9089 try 10230 try
9090 { 10231 {
9091 PREF_more_map_detail = Integer.parseInt(prefs.getString("more_map_detail", "0")); 10232 p.PREF_more_map_detail = Integer.parseInt(prefs.getString("more_map_detail", "0"));
9092 } 10233 }
9093 catch (Exception e) 10234 catch (Exception e)
9094 { 10235 {
9095 PREF_more_map_detail = 0; 10236 p.PREF_more_map_detail = 0;
9096 } 10237 }
9097 10238
9098 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 10239 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
9099 } 10240 }
9100 10241
9103 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 10244 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
9104 10245
9105 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 10246 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
9106 try 10247 try
9107 { 10248 {
9108 PREF_shrink_on_high_dpi = prefs.getBoolean("shrink_on_high_dpi", true); 10249 p.PREF_shrink_on_high_dpi = prefs.getBoolean("shrink_on_high_dpi", true);
9109 } 10250 }
9110 catch (Exception e) 10251 catch (Exception e)
9111 { 10252 {
9112 PREF_shrink_on_high_dpi = true; 10253 p.PREF_shrink_on_high_dpi = true;
9113 } 10254 }
9114 10255
9115 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 10256 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
9116 } 10257 }
9117 10258
9177 10318
9178 private static void getPrefs() 10319 private static void getPrefs()
9179 { 10320 {
9180 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 10321 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
9181 10322
10323 // save old pref values ---------------
10324 ZANaviPrefs.deep_copy(p, p_old);
10325 // save old pref values ---------------
10326
9182 // Get the xml/preferences.xml preferences 10327 // Get the xml/preferences.xml preferences
9183 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 10328 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
9184 PREF_use_fast_provider = prefs.getBoolean("use_fast_provider", true); 10329 p.PREF_use_fast_provider = prefs.getBoolean("use_fast_provider", true);
9185 PREF_allow_gui_internal = prefs.getBoolean("allow_gui_internal", false); 10330 p.PREF_allow_gui_internal = prefs.getBoolean("allow_gui_internal", false);
9186 PREF_follow_gps = prefs.getBoolean("follow_gps", true); 10331 p.PREF_follow_gps = prefs.getBoolean("follow_gps", true);
9187 PREF_use_compass_heading_base = prefs.getBoolean("use_compass_heading_base", false); 10332 p.PREF_use_compass_heading_base = prefs.getBoolean("use_compass_heading_base", false);
9188 PREF_use_compass_heading_always = prefs.getBoolean("use_compass_heading_always", false); 10333 p.PREF_use_compass_heading_always = prefs.getBoolean("use_compass_heading_always", false);
9189 PREF_use_compass_heading_fast = prefs.getBoolean("use_compass_heading_fast", false); 10334 p.PREF_use_compass_heading_fast = prefs.getBoolean("use_compass_heading_fast", false);
9190 PREF_use_anti_aliasing = prefs.getBoolean("use_anti_aliasing", true); 10335 p.PREF_use_anti_aliasing = prefs.getBoolean("use_anti_aliasing", true);
9191 PREF_use_map_filtering = prefs.getBoolean("use_map_filtering", true); 10336 p.PREF_use_map_filtering = prefs.getBoolean("use_map_filtering", true);
9192 PREF_gui_oneway_arrows = prefs.getBoolean("gui_oneway_arrows", true); 10337 p.PREF_gui_oneway_arrows = prefs.getBoolean("gui_oneway_arrows", true);
9193 PREF_c_linedrawing = prefs.getBoolean("c_linedrawing", false); 10338 p.PREF_c_linedrawing = prefs.getBoolean("c_linedrawing", false);
9194 10339
9195 PREF_show_debug_messages = prefs.getBoolean("show_debug_messages", false); 10340 p.PREF_show_debug_messages = prefs.getBoolean("show_debug_messages", false);
9196 10341
9197 PREF_show_3d_map = prefs.getBoolean("show_3d_map", false); 10342 p.PREF_show_3d_map = prefs.getBoolean("show_3d_map", false);
10343 send_data_to_plugin_bg(PLUGIN_MSG_CAT_3d_mode, String.valueOf(p.PREF_show_3d_map));
9198 10344
9199 PREF_use_smooth_drawing = prefs.getBoolean("use_smooth_drawing", true); 10345 p.PREF_use_smooth_drawing = prefs.getBoolean("use_smooth_drawing", true);
9200 PREF_use_more_smooth_drawing = prefs.getBoolean("use_more_smooth_drawing", false); 10346 p.PREF_use_more_smooth_drawing = prefs.getBoolean("use_more_smooth_drawing", false);
9201 if (PREF_use_smooth_drawing == false) 10347 if (p.PREF_use_smooth_drawing == false)
9202 { 10348 {
9203 PREF_use_more_smooth_drawing = false; 10349 p.PREF_use_more_smooth_drawing = false;
9204 } 10350 }
9205 if (PREF_use_more_smooth_drawing == true) 10351 if (p.PREF_use_more_smooth_drawing == true)
9206 { 10352 {
9207 PREF_use_smooth_drawing = true; 10353 p.PREF_use_smooth_drawing = true;
10354 }
10355
10356 boolean b1 = prefs.getBoolean("show_real_gps_pos", false);
10357 if (b1 == false)
9208 } 10358 {
10359 p.PREF_show_real_gps_pos = 0;
10360 }
10361 else
10362 {
10363 p.PREF_show_real_gps_pos = 1;
10364 }
9209 10365
9210 if (Navit.PREF_use_more_smooth_drawing) 10366 if (p.PREF_use_more_smooth_drawing)
9211 { 10367 {
9212 NavitGraphics.Vehicle_delay_real_gps_position = 595; 10368 NavitGraphics.Vehicle_delay_real_gps_position = 595;
9213 } 10369 }
9214 else 10370 else
9215 { 10371 {
9216 NavitGraphics.Vehicle_delay_real_gps_position = 450; 10372 NavitGraphics.Vehicle_delay_real_gps_position = 450;
9217 } 10373 }
9218 10374
9219 PREF_use_lock_on_roads = prefs.getBoolean("use_lock_on_roads", true); 10375 p.PREF_use_lock_on_roads = prefs.getBoolean("use_lock_on_roads", true);
9220 PREF_use_route_highways = prefs.getBoolean("use_route_highways", true); 10376 p.PREF_use_route_highways = prefs.getBoolean("use_route_highways", true);
9221 PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true); 10377 p.PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true);
9222 PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL* 10378 p.PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL*
9223 PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 174698); // default zoom level = 174698 // shows almost the whole world 10379 p.PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 174698); // default zoom level = 174698 // shows almost the whole world
9224 PREF_show_sat_status = prefs.getBoolean("show_sat_status", false); 10380 p.PREF_show_sat_status = prefs.getBoolean("show_sat_status", true);
9225 PREF_use_agps = prefs.getBoolean("use_agps", true); 10381 p.PREF_use_agps = prefs.getBoolean("use_agps", true);
9226 PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false); 10382 p.PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false);
9227 10383
9228 try 10384 try
9229 { 10385 {
9230 // recreate the manu items 10386 // recreate the menu items
9231 Message msg = Navit_progress_h.obtainMessage(); 10387 Message msg = Navit_progress_h.obtainMessage();
9232 Bundle b = new Bundle(); 10388 Bundle b = new Bundle();
9233 msg.what = 29; 10389 msg.what = 29;
9234 msg.setData(b); 10390 msg.setData(b);
9235 Navit_progress_h.sendMessage(msg); 10391 Navit_progress_h.sendMessage(msg);
9237 catch (Exception e) 10393 catch (Exception e)
9238 { 10394 {
9239 e.printStackTrace(); 10395 e.printStackTrace();
9240 } 10396 }
9241 10397
9242 PREF_enable_debug_write_gpx = prefs.getBoolean("enable_debug_write_gpx", false); 10398 p.PREF_enable_debug_write_gpx = prefs.getBoolean("enable_debug_write_gpx", false);
9243 PREF_enable_debug_enable_comm = prefs.getBoolean("enable_debug_enable_comm", false); 10399 p.PREF_enable_debug_enable_comm = prefs.getBoolean("enable_debug_enable_comm", false);
9244 10400
9245 PREF_speak_street_names = prefs.getBoolean("speak_street_names", true); 10401 p.PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
9246 PREF_use_custom_font = prefs.getBoolean("use_custom_font", true); 10402 p.PREF_use_custom_font = prefs.getBoolean("use_custom_font", true);
9247 PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true); 10403 p.PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
9248 PREF_streetsearch_r = prefs.getString("streetsearch_r", "2"); 10404 p.PREF_streetsearch_r = prefs.getString("streetsearch_r", "2");
9249 PREF_route_style = prefs.getString("route_style", "3"); 10405 p.PREF_route_style = prefs.getString("route_style", "3");
9250 PREF_item_dump = prefs.getBoolean("item_dump", false); 10406 p.PREF_item_dump = prefs.getBoolean("item_dump", false);
9251 PREF_show_route_rects = prefs.getBoolean("show_route_rects", false); 10407 p.PREF_show_route_rects = prefs.getBoolean("show_route_rects", false);
9252 PREF_trafficlights_delay = prefs.getString("trafficlights_delay", "0"); 10408 p.PREF_trafficlights_delay = prefs.getString("trafficlights_delay", "0");
9253 boolean tmp = prefs.getBoolean("avoid_sharp_turns", false); 10409 boolean tmp = prefs.getBoolean("avoid_sharp_turns", false);
9254 PREF_avoid_sharp_turns = "0"; 10410 p.PREF_avoid_sharp_turns = "0";
9255 if (tmp) 10411 //if (tmp)
9256 { 10412 //{
9257 PREF_avoid_sharp_turns = "1"; 10413 // p.PREF_avoid_sharp_turns = "1";
9258 } 10414 //}
9259 PREF_autozoom_flag = prefs.getBoolean("autozoom_flag", true); 10415 p.PREF_autozoom_flag = prefs.getBoolean("autozoom_flag", true);
9260 10416
9261 PREF_show_multipolygons = prefs.getBoolean("show_multipolygons", true); 10417 p.PREF_show_multipolygons = prefs.getBoolean("show_multipolygons", true);
9262 PREF_use_index_search = prefs.getBoolean("use_index_search", true); 10418 p.PREF_use_index_search = true; // prefs.getBoolean("use_index_search", true);
10419
9263 PREF_show_2d3d_toggle = prefs.getBoolean("show_2d3d_toggle", true); 10420 // PREF_show_2d3d_toggle = prefs.getBoolean("show_2d3d_toggle", true);
10421 p.PREF_show_2d3d_toggle = true;
10422
9264 PREF_show_vehicle_3d = prefs.getBoolean("show_vehicle_3d", true); 10423 // PREF_show_vehicle_3d = prefs.getBoolean("show_vehicle_3d", true);
10424 p.PREF_show_vehicle_3d = true;
10425
9265 PREF_speak_filter_special_chars = prefs.getBoolean("speak_filter_special_chars", true); 10426 p.PREF_speak_filter_special_chars = prefs.getBoolean("speak_filter_special_chars", true);
9266
9267 PREF_routing_profile = prefs.getString("routing_profile", "car");
9268 PREF_road_priority_001 = (prefs.getInt("road_priority_001", (68 - 10)) + 10); // must ADD minimum value!!
9269 PREF_road_priority_002 = (prefs.getInt("road_priority_002", (329 - 10)) + 10); // must ADD minimum value!!
9270 PREF_road_priority_003 = (prefs.getInt("road_priority_003", (5000 - 10)) + 10); // must ADD minimum value!!
9271 PREF_road_priority_004 = (prefs.getInt("road_priority_004", (5 - 0)) + 0); // must ADD minimum value!!
9272
9273 PREF_tracking_connected_pref = (prefs.getInt("tracking_connected_pref", (250 - 0)) + 0); // must ADD minimum value!!
9274 PREF_tracking_angle_pref = (prefs.getInt("tracking_angle_pref", (40 - 0)) + 0); // must ADD minimum value!!
9275
9276 PREF_streets_only = prefs.getBoolean("streets_only", false);
9277 PREF_show_status_bar = prefs.getBoolean("show_status_bar", true);
9278 PREF_last_selected_dir_gpxfiles = prefs.getString("last_selected_dir_gpxfiles", MAP_FILENAME_PATH + "/../");
9279
9280 PREF_roadspeed_warning = prefs.getBoolean("roadspeed_warning", false);
9281 PREF_lane_assist = prefs.getBoolean("lane_assist", false);
9282
9283 PREF_StreetSearchStrings = loadArray("xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
9284
9285 try 10427 try
9286 { 10428 {
9287 PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0")); 10429 p.PREF_routing_engine = Integer.parseInt(prefs.getString("routing_engine", "0"));
9288 } 10430 }
9289 catch (Exception e) 10431 catch (Exception e)
9290 { 10432 {
10433 p.PREF_routing_engine = 0;
10434 }
10435
10436 // send to C code --------
10437 NavitGraphics.CallbackMessageChannel(55598, "" + p.PREF_routing_engine);
10438 // send to C code --------
10439
10440 p.PREF_routing_profile = prefs.getString("routing_profile", "car");
10441 p.PREF_road_priority_001 = (prefs.getInt("road_priority_001", (68 - 10)) + 10); // must ADD minimum value!!
10442 p.PREF_road_priority_002 = (prefs.getInt("road_priority_002", (329 - 10)) + 10); // must ADD minimum value!!
10443 p.PREF_road_priority_003 = (prefs.getInt("road_priority_003", (5000 - 10)) + 10); // must ADD minimum value!!
10444 p.PREF_road_priority_004 = (prefs.getInt("road_priority_004", (5 - 0)) + 0); // must ADD minimum value!!
10445
10446 // p.PREF_road_prio_weight_street_1_city = (prefs.getInt("road_prio_weight_street_1_city", (30 - 10)) + 10); // must ADD minimum value!!
10447
10448 p.PREF_traffic_speed_factor = (prefs.getInt("traffic_speed_factor", (83 - 20)) + 20); // must ADD minimum value!!
10449
10450 p.PREF_tracking_connected_pref = (prefs.getInt("tracking_connected_pref", (250 - 0)) + 0); // must ADD minimum value!!
10451 p.PREF_tracking_angle_pref = (prefs.getInt("tracking_angle_pref", (40 - 0)) + 0); // must ADD minimum value!!
10452
10453 p.PREF_streets_only = prefs.getBoolean("streets_only", false);
10454 p.PREF_show_status_bar = prefs.getBoolean("show_status_bar", true);
10455 p.PREF_show_poi_on_map = prefs.getBoolean("show_poi_on_map", false);
10456 p.PREF_last_selected_dir_gpxfiles = prefs.getString("last_selected_dir_gpxfiles", MAP_FILENAME_PATH + "/../");
10457
10458 p.PREF_roadspeed_warning = prefs.getBoolean("roadspeed_warning", false);
10459 p.PREF_lane_assist = prefs.getBoolean("lane_assist", false);
10460
10461 try
10462 {
10463 p.PREF_roadspeed_warning_margin = Integer.parseInt(prefs.getString("roadspeed_warning_margin", "20"));
10464 }
10465 catch (Exception e)
10466 {
10467 p.PREF_roadspeed_warning_margin = 20;
10468 }
10469
10470 p.PREF_StreetSearchStrings = loadArray("xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT);
10471
10472 try
10473 {
10474 p.PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
10475 }
10476 catch (Exception e)
10477 {
9291 PREF_drawatorder = 0; 10478 p.PREF_drawatorder = 0;
9292 } 10479 }
9293 10480
9294 //try 10481 //try
9295 //{ 10482 //{
9296 // PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1")); 10483 // PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1"));
9297 //} 10484 //}
9298 //catch (Exception e) 10485 //catch (Exception e)
9299 //{ 10486 //{
9300 PREF_cancel_map_drawing_timeout = 1; 10487 p.PREF_cancel_map_drawing_timeout = 1;
9301 //} 10488 //}
9302 10489
9303 try 10490 try
9304 { 10491 {
9305 PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "2")); 10492 p.PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "3"));
9306 } 10493 }
9307 catch (Exception e) 10494 catch (Exception e)
9308 { 10495 {
9309 PREF_map_font_size = 2; 10496 p.PREF_map_font_size = 2;
9310 } 10497 }
9311 10498
9312 Navit_last_address_search_country_id = PREF_search_country; 10499 Navit_last_address_search_country_id = p.PREF_search_country;
9313 Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[PREF_search_country][0]; 10500 Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[p.PREF_search_country][0];
9314 10501
9315 if (!PREF_follow_gps) 10502 if (!p.PREF_follow_gps)
9316 { 10503 {
9317 // no compass turning without follow mode! 10504 // no compass turning without follow mode!
9318 PREF_use_compass_heading_base = false; 10505 p.PREF_use_compass_heading_base = false;
9319 } 10506 }
9320 10507
9321 if (!PREF_use_compass_heading_base) 10508 if (!p.PREF_use_compass_heading_base)
9322 { 10509 {
9323 // child is always "false" when parent is "false" !! 10510 // child is always "false" when parent is "false" !!
9324 PREF_use_compass_heading_always = false; 10511 p.PREF_use_compass_heading_always = false;
9325 } 10512 }
9326 PREF_show_vehicle_in_center = prefs.getBoolean("show_vehicle_in_center", false); 10513 p.PREF_show_vehicle_in_center = prefs.getBoolean("show_vehicle_in_center", false);
9327 PREF_use_imperial = prefs.getBoolean("use_imperial", false); 10514 p.PREF_use_imperial = prefs.getBoolean("use_imperial", false);
9328 Navit.cur_max_speed = -1; // to update speedwarning graphics 10515 Navit.cur_max_speed = -1; // to update speedwarning graphics
9329 10516
9330 // System.out.println("get settings"); 10517 // System.out.println("get settings");
9331 // System.out.println("PREF_search_country=" + PREF_search_country); 10518 // System.out.println("PREF_search_country=" + PREF_search_country);
9332 // System.out.println("PREF_follow_gps=" + PREF_follow_gps); 10519 // System.out.println("PREF_follow_gps=" + PREF_follow_gps);
9344 { 10531 {
9345 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 10532 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
9346 10533
9347 activatePrefs(1); 10534 activatePrefs(1);
9348 10535
9349 if (PREF_save_zoomlevel) 10536 if (p.PREF_save_zoomlevel)
9350 { 10537 {
9351 // only if really started, but NOT if returning from our own child activities!! 10538 // only if really started, but NOT if returning from our own child activities!!
9352 10539
9353 //System.out.println("3 restore zoom level: " + Navit.GlobalScaleLevel); 10540 //System.out.println("3 restore zoom level: " + Navit.GlobalScaleLevel);
9354 //System.out.println("4 restore zoom level: " + PREF_zoomlevel_num); 10541 //System.out.println("4 restore zoom level: " + PREF_zoomlevel_num);
9355 10542
9356 Message msg = new Message(); 10543 Message msg = new Message();
9357 Bundle b = new Bundle(); 10544 Bundle b = new Bundle();
9358 b.putInt("Callback", 33); 10545 b.putInt("Callback", 33);
9359 b.putString("s", Integer.toString(PREF_zoomlevel_num)); 10546 b.putString("s", Integer.toString(p.PREF_zoomlevel_num));
9360 msg.setData(b); 10547 msg.setData(b);
9361 try 10548 try
9362 { 10549 {
9363 NavitGraphics.callback_handler.sendMessage(msg); 10550 NavitGraphics.callback_handler.sendMessage(msg);
9364 Navit.GlobalScaleLevel = PREF_zoomlevel_num; 10551 Navit.GlobalScaleLevel = p.PREF_zoomlevel_num;
9365 //System.out.println("5 restore zoom level: " + PREF_zoomlevel_num); 10552 //System.out.println("5 restore zoom level: " + PREF_zoomlevel_num);
9366 } 10553 }
9367 catch (Exception e) 10554 catch (Exception e)
9368 { 10555 {
9369 } 10556 }
9370 } 10557 }
9371 else 10558 else
9372 { 10559 {
9373 PREF_zoomlevel_num = Navit.GlobalScaleLevel; 10560 p.PREF_zoomlevel_num = Navit.GlobalScaleLevel;
9374 } 10561 }
9375 10562
9376 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 10563 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
9377 } 10564 }
9378 10565
10566 private static void set_poi_layers()
10567 {
10568 int on_ = 59;
10569 int off_ = 60;
10570
10571 // System.out.println("POI:1");
10572 if (p.PREF_show_poi_on_map)
10573 {
10574 // System.out.println("POI:2");
10575 on_ = 60;
10576 off_ = 59;
10577 }
10578
10579 // toggle the normal POI layers (to avoid double POIs)
10580 Message msg = new Message();
10581 Bundle b = new Bundle();
10582 b.putInt("Callback", on_);
10583 b.putString("s", "POI Symbols");
10584 msg.setData(b);
10585 NavitGraphics.callback_handler.sendMessage(msg);
10586
10587 msg = new Message();
10588 b = new Bundle();
10589 b.putInt("Callback", on_);
10590 b.putString("s", "POI Labels");
10591 msg.setData(b);
10592 NavitGraphics.callback_handler.sendMessage(msg);
10593
10594 // toggle full POI icons on/off
10595 msg = new Message();
10596 b = new Bundle();
10597 b.putInt("Callback", off_);
10598 b.putString("s", "Android-POI-Icons-full");
10599 msg.setData(b);
10600 NavitGraphics.callback_handler.sendMessage(msg);
10601
10602 msg = new Message();
10603 b = new Bundle();
10604 b.putInt("Callback", off_);
10605 b.putString("s", "Android-POI-Labels-full");
10606 msg.setData(b);
10607 NavitGraphics.callback_handler.sendMessage(msg);
10608
10609 // draw_map();
10610 }
10611
9379 private static void activatePrefs(int dummy) 10612 private static void activatePrefs(int dummy)
9380 { 10613 {
10614
10615 need_recalc_route = false; // do we need to recalc the route?
10616
9381 // call some functions to activate the new settings 10617 // call some functions to activate the new settings
9382 if (PREF_follow_gps) 10618 if (p.PREF_follow_gps)
9383 { 10619 {
9384 Navit.follow_current = Navit.follow_on; 10620 Navit.follow_current = Navit.follow_on;
9385 } 10621 }
9386 else 10622 else
9387 { 10623 {
9388 Navit.follow_current = Navit.follow_off; 10624 Navit.follow_current = Navit.follow_off;
9389 } 10625 }
9390 10626
9391 if (PREF_use_fast_provider) 10627 if (p.PREF_use_fast_provider)
9392 { 10628 {
9393 NavitVehicle.turn_on_fast_provider(); 10629 NavitVehicle.turn_on_fast_provider();
9394 } 10630 }
9395 else 10631 else
9396 { 10632 {
9397 NavitVehicle.turn_off_fast_provider(); 10633 NavitVehicle.turn_off_fast_provider();
9398 } 10634 }
9399 10635
9400 if (PREF_show_sat_status) 10636 if (p.PREF_show_sat_status)
9401 { 10637 {
9402 NavitVehicle.turn_on_sat_status(); 10638 NavitVehicle.turn_on_sat_status();
9403 } 10639 }
9404 else 10640 else
9405 { 10641 {
9407 // 10643 //
9408 // NavitVehicle.turn_off_sat_status(); 10644 // NavitVehicle.turn_off_sat_status();
9409 NavitVehicle.turn_on_sat_status(); 10645 NavitVehicle.turn_on_sat_status();
9410 } 10646 }
9411 10647
9412 if (PREF_show_status_bar) 10648 if (p.PREF_show_status_bar)
9413 { 10649 {
9414 show_status_bar_wrapper(); 10650 show_status_bar_wrapper();
9415 } 10651 }
9416 else 10652 else
9417 { 10653 {
9418 hide_status_bar_wrapper(); 10654 hide_status_bar_wrapper();
9419 } 10655 }
9420 10656
9421 if (PREF_allow_gui_internal) 10657 if (p.PREF_allow_gui_internal)
9422 { 10658 {
9423 Message msg = new Message(); 10659 Message msg = new Message();
9424 Bundle b = new Bundle(); 10660 Bundle b = new Bundle();
9425 b.putInt("Callback", 10); 10661 b.putInt("Callback", 10);
9426 msg.setData(b); 10662 msg.setData(b);
9445 catch (Exception e) 10681 catch (Exception e)
9446 { 10682 {
9447 } 10683 }
9448 } 10684 }
9449 10685
9450 if (PREF_use_compass_heading_base) 10686 if (p.PREF_use_compass_heading_base)
9451 { 10687 {
9452 // turn on compass 10688 // turn on compass
9453 msg_to_msg_handler(new Bundle(), 12); 10689 msg_to_msg_handler(new Bundle(), 12);
9454 Message msg = new Message(); 10690 Message msg = new Message();
9455 Bundle b = new Bundle(); 10691 Bundle b = new Bundle();
9478 catch (Exception e) 10714 catch (Exception e)
9479 { 10715 {
9480 } 10716 }
9481 } 10717 }
9482 10718
10719 if (p.PREF_show_real_gps_pos == 1)
10720 {
10721 // show real gps pos
10722 Message msg = new Message();
10723 Bundle b = new Bundle();
10724 b.putInt("Callback", 111);
10725 b.putString("s", "1");
10726 msg.setData(b);
10727 try
10728 {
10729 NavitGraphics.callback_handler.sendMessage(msg);
10730 }
10731 catch (Exception e)
10732 {
10733 }
10734 }
10735 else
10736 {
10737 Message msg = new Message();
10738 Bundle b = new Bundle();
10739 b.putInt("Callback", 111);
10740 b.putString("s", "0");
10741 msg.setData(b);
10742 try
10743 {
10744 NavitGraphics.callback_handler.sendMessage(msg);
10745 }
10746 catch (Exception e)
10747 {
10748 }
10749 }
10750
9483 // search radius for housenumbers near streets ----------------- 10751 // search radius for housenumbers near streets -----------------
9484 Message msg43 = new Message(); 10752 Message msg43 = new Message();
9485 Bundle b43 = new Bundle(); 10753 Bundle b43 = new Bundle();
9486 b43.putInt("Callback", 89); 10754 b43.putInt("Callback", 89);
9487 b43.putString("s", "1500"); 10755 b43.putString("s", "1500");
9499 if (Navit_Largemap_DonateVersion_Installed == true) 10767 if (Navit_Largemap_DonateVersion_Installed == true)
9500 { 10768 {
9501 Message msg43a = new Message(); 10769 Message msg43a = new Message();
9502 Bundle b43a = new Bundle(); 10770 Bundle b43a = new Bundle();
9503 b43a.putInt("Callback", 90); 10771 b43a.putInt("Callback", 90);
9504 b43a.putString("s", PREF_routing_profile); // set routing profile 10772 b43a.putString("s", p.PREF_routing_profile); // set routing profile
9505 msg43a.setData(b43a); 10773 msg43a.setData(b43a);
9506 try 10774 try
9507 { 10775 {
9508 NavitGraphics.callback_handler.sendMessage(msg43a); 10776 NavitGraphics.callback_handler.sendMessage(msg43a);
9509 } 10777 }
9510 catch (Exception e) 10778 catch (Exception e)
9511 { 10779 {
9512 } 10780 }
10781
10782 // need_recalc_route = true;
9513 } 10783 }
9514 // set routing profile ----------------- 10784 // set routing profile -----------------
9515 10785
9516 Message msg99a = new Message(); 10786 Message msg99a = new Message();
9517 Bundle b99a = new Bundle(); 10787 Bundle b99a = new Bundle();
9518 b99a.putInt("Callback", 98); 10788 b99a.putInt("Callback", 98);
9519 System.out.println("tracking_connected_pref=" + PREF_tracking_connected_pref); 10789 // System.out.println("tracking_connected_pref=" + PREF_tracking_connected_pref);
9520 b99a.putString("s", "" + PREF_tracking_connected_pref); // set routing profile 10790 b99a.putString("s", "" + p.PREF_tracking_connected_pref); // set routing profile
9521 msg99a.setData(b99a); 10791 msg99a.setData(b99a);
9522 try 10792 try
9523 { 10793 {
9524 NavitGraphics.callback_handler.sendMessage(msg99a); 10794 NavitGraphics.callback_handler.sendMessage(msg99a);
9525 } 10795 }
9528 } 10798 }
9529 10799
9530 msg99a = new Message(); 10800 msg99a = new Message();
9531 b99a = new Bundle(); 10801 b99a = new Bundle();
9532 b99a.putInt("Callback", 99); 10802 b99a.putInt("Callback", 99);
9533 System.out.println("tracking_angle_pref=" + PREF_tracking_angle_pref); 10803 // System.out.println("tracking_angle_pref=" + PREF_tracking_angle_pref);
9534 b99a.putString("s", "" + PREF_tracking_angle_pref); // set routing profile 10804 b99a.putString("s", "" + p.PREF_tracking_angle_pref); // set routing profile
9535 msg99a.setData(b99a); 10805 msg99a.setData(b99a);
9536 try 10806 try
9537 { 10807 {
9538 NavitGraphics.callback_handler.sendMessage(msg99a); 10808 NavitGraphics.callback_handler.sendMessage(msg99a);
9539 } 10809 }
9542 } 10812 }
9543 10813
9544 // change road profile ----------------- 10814 // change road profile -----------------
9545 if (Navit_Largemap_DonateVersion_Installed == true) 10815 if (Navit_Largemap_DonateVersion_Installed == true)
9546 { 10816 {
9547 if (PREF_routing_profile.equals("bike-normal")) 10817 if (p.PREF_routing_profile.equals("bike-normal"))
9548 { 10818 {
9549 Message msg43b = new Message(); 10819 Message msg43b = new Message();
9550 Bundle b43b = new Bundle(); 10820 Bundle b43b = new Bundle();
9551 b43b.putInt("Callback", 91); 10821 b43b.putInt("Callback", 91);
9552 System.out.println("road_priority_001=" + PREF_road_priority_001); 10822 System.out.println("road_priority_001=" + p.PREF_road_priority_001);
9553 b43b.putString("s", "" + PREF_road_priority_001); // set routing profile 10823 b43b.putString("s", "" + p.PREF_road_priority_001); // set routing profile
9554 msg43b.setData(b43b); 10824 msg43b.setData(b43b);
9555 try 10825 try
9556 { 10826 {
9557 NavitGraphics.callback_handler.sendMessage(msg43b); 10827 NavitGraphics.callback_handler.sendMessage(msg43b);
9558 } 10828 }
9561 } 10831 }
9562 10832
9563 msg43b = new Message(); 10833 msg43b = new Message();
9564 b43b = new Bundle(); 10834 b43b = new Bundle();
9565 b43b.putInt("Callback", 92); 10835 b43b.putInt("Callback", 92);
9566 System.out.println("road_priority_002=" + PREF_road_priority_002); 10836 System.out.println("road_priority_002=" + p.PREF_road_priority_002);
9567 b43b.putString("s", "" + PREF_road_priority_002); // set routing profile 10837 b43b.putString("s", "" + p.PREF_road_priority_002); // set routing profile
9568 msg43b.setData(b43b); 10838 msg43b.setData(b43b);
9569 try 10839 try
9570 { 10840 {
9571 NavitGraphics.callback_handler.sendMessage(msg43b); 10841 NavitGraphics.callback_handler.sendMessage(msg43b);
9572 } 10842 }
9575 } 10845 }
9576 10846
9577 msg43b = new Message(); 10847 msg43b = new Message();
9578 b43b = new Bundle(); 10848 b43b = new Bundle();
9579 b43b.putInt("Callback", 93); 10849 b43b.putInt("Callback", 93);
9580 System.out.println("road_priority_003=" + PREF_road_priority_003); 10850 System.out.println("road_priority_003=" + p.PREF_road_priority_003);
9581 b43b.putString("s", "" + PREF_road_priority_003); // set routing profile 10851 b43b.putString("s", "" + p.PREF_road_priority_003); // set routing profile
9582 msg43b.setData(b43b); 10852 msg43b.setData(b43b);
9583 try 10853 try
9584 { 10854 {
9585 NavitGraphics.callback_handler.sendMessage(msg43b); 10855 NavitGraphics.callback_handler.sendMessage(msg43b);
9586 } 10856 }
9589 } 10859 }
9590 10860
9591 msg43b = new Message(); 10861 msg43b = new Message();
9592 b43b = new Bundle(); 10862 b43b = new Bundle();
9593 b43b.putInt("Callback", 94); 10863 b43b.putInt("Callback", 94);
9594 System.out.println("road_priority_004=" + PREF_road_priority_004); 10864 System.out.println("road_priority_004=" + p.PREF_road_priority_004);
9595 b43b.putString("s", "" + PREF_road_priority_004); // set routing profile 10865 b43b.putString("s", "" + p.PREF_road_priority_004); // set routing profile
9596 msg43b.setData(b43b); 10866 msg43b.setData(b43b);
9597 try 10867 try
9598 { 10868 {
9599 NavitGraphics.callback_handler.sendMessage(msg43b); 10869 NavitGraphics.callback_handler.sendMessage(msg43b);
9600 } 10870 }
9666 // switch ON layers -------------------- 10936 // switch ON layers --------------------
9667 } 10937 }
9668 } 10938 }
9669 // change road profile ----------------- 10939 // change road profile -----------------
9670 10940
10941 // -- debug -- change some prio weights --
10942 // if ((!p.PREF_routing_profile.equals("bike-normal")) && (!p.PREF_routing_profile.equals("bike-no-oneway")) && (!p.PREF_routing_profile.equals("bike-avoid-roads")))
10943 // {
10944 // Message msg93 = new Message();
10945 // Bundle b93 = new Bundle();
10946 // b93.putInt("Callback", 110);
10947 // b93.putString("s", "street_1_city#route_prio_weight:" + p.PREF_road_prio_weight_street_1_city);
10948 // msg93.setData(b93);
10949 // try
10950 // {
10951 // NavitGraphics.callback_handler.sendMessage(msg93);
10952 // }
10953 // catch (Exception e)
10954 // {
10955 // }
10956 //
10957 // if (p_old.PREF_road_prio_weight_street_1_city != p.PREF_road_prio_weight_street_1_city)
10958 // {
10959 // need_recalc_route = true;
10960 // }
10961 // }
10962 // -- debug -- change some prio weights --
10963
9671 if (NavitGraphics.navit_route_status == 0) 10964 if (NavitGraphics.navit_route_status == 0)
9672 { 10965 {
9673 if (PREF_c_linedrawing) 10966 if (p.PREF_c_linedrawing)
9674 { 10967 {
9675 Message msg = new Message(); 10968 Message msg = new Message();
9676 Bundle b = new Bundle(); 10969 Bundle b = new Bundle();
9677 b.putInt("Callback", 85); 10970 b.putInt("Callback", 85);
9678 b.putString("s", "1"); 10971 b.putString("s", "1");
9700 { 10993 {
9701 } 10994 }
9702 } 10995 }
9703 } 10996 }
9704 10997
10998 Message msg33 = new Message();
10999 Bundle b33 = new Bundle();
11000 b33.putInt("Callback", 103);
9705 if (PREF_show_vehicle_in_center) 11001 if (p.PREF_show_vehicle_in_center)
9706 {
9707 Message msg = new Message();
9708 Bundle b = new Bundle();
9709 b.putInt("Callback", 14);
9710 msg.setData(b);
9711 try
9712 { 11002 {
9713 NavitGraphics.callback_handler.sendMessage(msg); 11003 b33.putString("s", "0");
9714 }
9715 catch (Exception e)
9716 {
9717 }
9718 } 11004 }
9719 else 11005 else
9720 { 11006 {
9721 Message msg = new Message(); 11007 b33.putString("s", "" + NavitGraphics.lower_than_center_percent);
9722 Bundle b = new Bundle(); 11008 }
9723 b.putInt("Callback", 13);
9724 msg.setData(b); 11009 msg33.setData(b33);
9725 try 11010 try
9726 { 11011 {
9727 NavitGraphics.callback_handler.sendMessage(msg); 11012 NavitGraphics.callback_handler.sendMessage(msg33);
9728 } 11013 }
9729 catch (Exception e) 11014 catch (Exception e88)
9730 { 11015 {
9731 } 11016 }
9732 }
9733 11017
9734 if (PREF_use_imperial) 11018 if (p.PREF_use_imperial)
9735 { 11019 {
9736 Message msg = new Message(); 11020 Message msg = new Message();
9737 Bundle b = new Bundle(); 11021 Bundle b = new Bundle();
9738 b.putInt("Callback", 16); 11022 b.putInt("Callback", 16);
9739 msg.setData(b); 11023 msg.setData(b);
9758 catch (Exception e) 11042 catch (Exception e)
9759 { 11043 {
9760 } 11044 }
9761 } 11045 }
9762 11046
9763 if (PREF_show_debug_messages) 11047 if (p.PREF_show_debug_messages)
9764 { 11048 {
9765 Message msg = new Message(); 11049 Message msg = new Message();
9766 Bundle b = new Bundle(); 11050 Bundle b = new Bundle();
9767 b.putInt("Callback", 24); 11051 b.putInt("Callback", 24);
9768 msg.setData(b); 11052 msg.setData(b);
9816 // catch (Exception e) 11100 // catch (Exception e)
9817 // { 11101 // {
9818 // } 11102 // }
9819 // } 11103 // }
9820 11104
9821 if (PREF_use_lock_on_roads) 11105 if (p.PREF_use_lock_on_roads)
9822 { 11106 {
9823 Message msg = new Message(); 11107 Message msg = new Message();
9824 Bundle b = new Bundle(); 11108 Bundle b = new Bundle();
9825 b.putInt("Callback", 36); 11109 b.putInt("Callback", 36);
9826 msg.setData(b); 11110 msg.setData(b);
9876 // catch (Exception e) 11160 // catch (Exception e)
9877 // { 11161 // {
9878 // } 11162 // }
9879 // } 11163 // }
9880 11164
9881 if (PREF_use_route_highways) 11165 if (p.PREF_use_route_highways)
9882 { 11166 {
9883 Message msg = new Message(); 11167 Message msg = new Message();
9884 Bundle b = new Bundle(); 11168 Bundle b = new Bundle();
9885 b.putInt("Callback", 42); 11169 b.putInt("Callback", 42);
9886 msg.setData(b); 11170 msg.setData(b);
9908 } 11192 }
9909 11193
9910 Message msg7 = new Message(); 11194 Message msg7 = new Message();
9911 Bundle b7 = new Bundle(); 11195 Bundle b7 = new Bundle();
9912 b7.putInt("Callback", 57); 11196 b7.putInt("Callback", 57);
9913 b7.putString("s", "" + PREF_drawatorder); 11197 b7.putString("s", "" + p.PREF_drawatorder);
9914 msg7.setData(b7); 11198 msg7.setData(b7);
9915 try 11199 try
9916 { 11200 {
9917 NavitGraphics.callback_handler.sendMessage(msg7); 11201 NavitGraphics.callback_handler.sendMessage(msg7);
9918 } 11202 }
9921 } 11205 }
9922 11206
9923 msg7 = new Message(); 11207 msg7 = new Message();
9924 b7 = new Bundle(); 11208 b7 = new Bundle();
9925 b7.putInt("Callback", 58); 11209 b7.putInt("Callback", 58);
9926 b7.putString("s", PREF_streetsearch_r); 11210 b7.putString("s", p.PREF_streetsearch_r);
9927 msg7.setData(b7); 11211 msg7.setData(b7);
9928 try 11212 try
9929 { 11213 {
9930 NavitGraphics.callback_handler.sendMessage(msg7); 11214 NavitGraphics.callback_handler.sendMessage(msg7);
9931 } 11215 }
9932 catch (Exception e) 11216 catch (Exception e)
9933 { 11217 {
9934 } 11218 }
9935 11219
9936 if (PREF_speak_street_names) 11220 if (p.PREF_speak_street_names)
9937 { 11221 {
9938 Message msg = new Message(); 11222 Message msg = new Message();
9939 Bundle b = new Bundle(); 11223 Bundle b = new Bundle();
9940 b.putInt("Callback", 54); 11224 b.putInt("Callback", 54);
9941 msg.setData(b); 11225 msg.setData(b);
9963 11247
9964 } 11248 }
9965 11249
9966 try 11250 try
9967 { 11251 {
9968 NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[PREF_cancel_map_drawing_timeout]; 11252 NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[p.PREF_cancel_map_drawing_timeout];
9969 NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[PREF_cancel_map_drawing_timeout]; 11253 NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[p.PREF_cancel_map_drawing_timeout];
9970 NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[PREF_cancel_map_drawing_timeout]; 11254 NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[p.PREF_cancel_map_drawing_timeout];
9971 } 11255 }
9972 catch (Exception e) 11256 catch (Exception e)
9973 { 11257 {
9974 11258
9975 } 11259 }
10018 11302
10019 // turn on the wanted route style 11303 // turn on the wanted route style
10020 msg67 = new Message(); 11304 msg67 = new Message();
10021 b67 = new Bundle(); 11305 b67 = new Bundle();
10022 b67.putInt("Callback", 59); 11306 b67.putInt("Callback", 59);
10023 b67.putString("s", "route_00" + PREF_route_style); 11307 b67.putString("s", "route_00" + p.PREF_route_style);
10024 msg67.setData(b67); 11308 msg67.setData(b67);
10025 try 11309 try
10026 { 11310 {
10027 NavitGraphics.callback_handler.sendMessage(msg67); 11311 NavitGraphics.callback_handler.sendMessage(msg67);
10028 } 11312 }
10030 { 11314 {
10031 } 11315 }
10032 // route variant 11316 // route variant
10033 11317
10034 // show route rectanlges ----- 11318 // show route rectanlges -----
10035 if (PREF_show_route_rects) 11319 if (p.PREF_show_route_rects)
10036 { 11320 {
10037 msg67 = new Message(); 11321 msg67 = new Message();
10038 b67 = new Bundle(); 11322 b67 = new Bundle();
10039 b67.putInt("Callback", 76); 11323 b67.putInt("Callback", 76);
10040 msg67.setData(b67); 11324 msg67.setData(b67);
10061 } 11345 }
10062 } 11346 }
10063 // show route rectanlges ----- 11347 // show route rectanlges -----
10064 11348
10065 // show route multipolygons ----- 11349 // show route multipolygons -----
10066 if (PREF_show_multipolygons) 11350 if (p.PREF_show_multipolygons)
10067 { 11351 {
10068 msg67 = new Message(); 11352 msg67 = new Message();
10069 b67 = new Bundle(); 11353 b67 = new Bundle();
10070 b67.putInt("Callback", 66); 11354 b67.putInt("Callback", 66);
10071 msg67.setData(b67); 11355 msg67.setData(b67);
10097 msg67 = new Message(); 11381 msg67 = new Message();
10098 b67 = new Bundle(); 11382 b67 = new Bundle();
10099 b67.putInt("Callback", 79); 11383 b67.putInt("Callback", 79);
10100 //System.out.println("traffic lights delay:" + PREF_trafficlights_delay); 11384 //System.out.println("traffic lights delay:" + PREF_trafficlights_delay);
10101 // (PREF_trafficlights_delay / 10) seconds delay for each traffic light 11385 // (PREF_trafficlights_delay / 10) seconds delay for each traffic light
10102 b67.putString("s", PREF_trafficlights_delay); // (delay in 1/10 of a second) 11386 b67.putString("s", p.PREF_trafficlights_delay); // (delay in 1/10 of a second)
10103 msg67.setData(b67); 11387 msg67.setData(b67);
10104 try 11388 try
10105 { 11389 {
10106 NavitGraphics.callback_handler.sendMessage(msg67); 11390 NavitGraphics.callback_handler.sendMessage(msg67);
10107 } 11391 }
10112 11396
10113 // avoid sharp turns ---- 11397 // avoid sharp turns ----
10114 msg67 = new Message(); 11398 msg67 = new Message();
10115 b67 = new Bundle(); 11399 b67 = new Bundle();
10116 b67.putInt("Callback", 86); 11400 b67.putInt("Callback", 86);
10117 b67.putString("s", PREF_avoid_sharp_turns); 11401 b67.putString("s", p.PREF_avoid_sharp_turns);
10118 msg67.setData(b67); 11402 msg67.setData(b67);
10119 try 11403 try
10120 { 11404 {
10121 NavitGraphics.callback_handler.sendMessage(msg67); 11405 NavitGraphics.callback_handler.sendMessage(msg67);
10122 } 11406 }
10153 11437
10154 // autozoom flag ---- 11438 // autozoom flag ----
10155 msg67 = new Message(); 11439 msg67 = new Message();
10156 b67 = new Bundle(); 11440 b67 = new Bundle();
10157 b67.putInt("Callback", 80); 11441 b67.putInt("Callback", 80);
10158 if (PREF_autozoom_flag) 11442 if (p.PREF_autozoom_flag)
10159 { 11443 {
10160 b67.putString("s", "1"); // (0 or 1) 11444 b67.putString("s", "1"); // (0 or 1)
10161 } 11445 }
10162 else 11446 else
10163 { 11447 {
10178 { 11462 {
10179 // use pref 11463 // use pref
10180 } 11464 }
10181 else 11465 else
10182 { 11466 {
10183 PREF_roadspeed_warning = false; 11467 p.PREF_roadspeed_warning = false;
10184 } 11468 }
10185 11469
10186 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed)) 11470 if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed))
10187 { 11471 {
10188 // use pref 11472 // use pref
10189 } 11473 }
10190 else 11474 else
10191 { 11475 {
10192 PREF_lane_assist = false; 11476 p.PREF_lane_assist = false;
10193 } 11477 }
10194 11478
10195 if (PREF_streets_only) 11479 if (p.PREF_streets_only)
10196 { 11480 {
10197 // ----------------------- streets only pref ------------------- 11481 // ----------------------- streets only pref -------------------
10198 // 59 -> enable 11482 // 59 -> enable
10199 // 60 -> disable 11483 // 60 -> disable
10200 Message msg31 = new Message(); 11484 Message msg31 = new Message();
10371 msg31.setData(b31); 11655 msg31.setData(b31);
10372 NavitGraphics.callback_handler.sendMessage(msg31); 11656 NavitGraphics.callback_handler.sendMessage(msg31);
10373 // ----------------------- streets only pref ------------------- 11657 // ----------------------- streets only pref -------------------
10374 } 11658 }
10375 11659
10376 System.out.println("CheckPOINT:001"); 11660 // ---------- set traffic factor for road speeds ------------
11661 try
11662 {
11663 Message msg_ss1 = new Message();
11664 Bundle b_ss1 = new Bundle();
11665 b_ss1.putInt("Callback", 106);
11666 b_ss1.putString("s", Integer.toString(p.PREF_traffic_speed_factor));
11667 msg_ss1.setData(b_ss1);
11668 NavitGraphics.callback_handler.sendMessage(msg_ss1);
11669 }
11670 catch (Exception e)
11671 {
11672 }
11673 // ---------- set traffic factor for road speeds ------------
11674
11675 // ------- PREF_show_poi_on_map ---------------------------------
11676 set_poi_layers();
11677 // ------- PREF_show_poi_on_map ---------------------------------
10377 11678
10378 // set vars for mapdir change (only really takes effect after restart!) 11679 // set vars for mapdir change (only really takes effect after restart!)
10379 getPrefs_mapdir(); 11680 getPrefs_mapdir();
10380 11681
10381 System.out.println("CheckPOINT:002"); 11682 if (need_recalc_route)
11683 {
11684 recalculate_route();
11685 need_recalc_route = false;
11686 }
11687
10382 } 11688 }
10383 11689
10384 @SuppressLint("NewApi") 11690 @SuppressLint("NewApi")
10385 private static void getPrefs_mapdir() 11691 private static void getPrefs_mapdir()
10386 { 11692 {
10518 ret = ret.replaceAll("\\\\", ""); // "\" -> "" 11824 ret = ret.replaceAll("\\\\", ""); // "\" -> ""
10519 if (!ret.endsWith("/")) 11825 if (!ret.endsWith("/"))
10520 { 11826 {
10521 ret = ret + "/"; 11827 ret = ret + "/";
10522 } 11828 }
10523 System.out.println("sanity check:" + ret); 11829 // System.out.println("sanity check:" + ret);
10524 return ret; 11830 return ret;
10525 } 11831 }
10526 11832
10527 private static void activatePrefs_mapdir(Boolean at_startup) 11833 private static void activatePrefs_mapdir(Boolean at_startup)
10528 { 11834 {
10572 { 11878 {
10573 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 11879 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
10574 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0")); 11880 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
10575 // 0 -> Navit.DEFAULT_THEME_OLD_DARK 11881 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
10576 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT 11882 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
10577 PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK; 11883 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
10578 if (theme_tmp == 1) 11884 if (theme_tmp == 1)
10579 { 11885 {
10580 PREF_current_theme = Navit.DEFAULT_THEME_OLD_LIGHT; 11886 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_LIGHT;
10581 } 11887 }
10582 else 11888 else
10583 { 11889 {
10584 PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK; 11890 p.PREF_current_theme = Navit.DEFAULT_THEME_OLD_DARK;
10585 } 11891 }
10586 11892
10587 } 11893 }
10588 11894
10589 private void getPrefs_theme_main() 11895 private void getPrefs_theme_main()
10590 { 11896 {
10591 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 11897 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
10592 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0")); 11898 int theme_tmp = Integer.parseInt(prefs.getString("current_theme", "0"));
10593 // 0 -> Navit.DEFAULT_THEME_OLD_DARK 11899 // 0 -> Navit.DEFAULT_THEME_OLD_DARK
10594 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT 11900 // 1 -> Navit.DEFAULT_THEME_OLD_LIGHT
10595 PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M; 11901 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
10596 if (theme_tmp == 1) 11902 if (theme_tmp == 1)
10597 { 11903 {
10598 PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_LIGHT_M; 11904 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_LIGHT_M;
10599 } 11905 }
10600 else 11906 else
10601 { 11907 {
10602 PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M; 11908 p.PREF_current_theme_M = Navit.DEFAULT_THEME_OLD_DARK_M;
10603 } 11909 }
10604 11910
10605 } 11911 }
10606 11912
10607 private static void getPrefs_loc() 11913 private static void getPrefs_loc()
10608 { 11914 {
10609 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 11915 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10610 11916
10611 // Get the xml/preferences.xml preferences 11917 // Get the xml/preferences.xml preferences
10612 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 11918 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10613 PREF_navit_lang = prefs.getString("navit_lang", "*DEFAULT*"); 11919 p.PREF_navit_lang = prefs.getString("navit_lang", "*DEFAULT*");
10614 System.out.println("**** ***** **** pref lang=" + PREF_navit_lang); 11920 System.out.println("**** ***** **** pref lang=" + p.PREF_navit_lang);
10615 11921
10616 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 11922 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10617 } 11923 }
10618 11924
10619 private static void activatePrefs_loc() 11925 private static void activatePrefs_loc()
10620 { 11926 {
10621 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 11927 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10622 11928
10623 // creating locale 11929 // creating locale
10624 if (!PREF_navit_lang.equals("*DEFAULT*")) 11930 if (!p.PREF_navit_lang.equals("*DEFAULT*"))
10625 { 11931 {
10626 Locale locale2 = null; 11932 Locale locale2 = null;
10627 if (PREF_navit_lang.contains("_")) 11933 if (p.PREF_navit_lang.contains("_"))
10628 { 11934 {
10629 String _lang = PREF_navit_lang.split("_", 2)[0]; 11935 String _lang = p.PREF_navit_lang.split("_", 2)[0];
10630 String _country = PREF_navit_lang.split("_", 2)[1]; 11936 String _country = p.PREF_navit_lang.split("_", 2)[1];
10631 System.out.println("l=" + _lang + " c=" + _country); 11937 System.out.println("l=" + _lang + " c=" + _country);
10632 locale2 = new Locale(_lang, _country); 11938 locale2 = new Locale(_lang, _country);
10633 } 11939 }
10634 else 11940 else
10635 { 11941 {
10636 locale2 = new Locale(PREF_navit_lang); 11942 locale2 = new Locale(p.PREF_navit_lang);
10637 } 11943 }
10638 Locale.setDefault(locale2); 11944 Locale.setDefault(locale2);
10639 Configuration config2 = new Configuration(); 11945 Configuration config2 = new Configuration();
10640 config2.locale = locale2; 11946 config2.locale = locale2;
10641 // updating locale 11947 // updating locale
10648 private static void getPrefs_mapcache() 11954 private static void getPrefs_mapcache()
10649 { 11955 {
10650 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_); 11956 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
10651 try 11957 try
10652 { 11958 {
10653 PREF_mapcache = Integer.parseInt(prefs.getString("mapcache", "" + (10 * 1024))); 11959 p.PREF_mapcache = Integer.parseInt(prefs.getString("mapcache", "" + (10 * 1024)));
10654 } 11960 }
10655 catch (Exception e) 11961 catch (Exception e)
10656 { 11962 {
10657 e.printStackTrace(); 11963 e.printStackTrace();
10658 PREF_mapcache = 10 * 1024; 11964 p.PREF_mapcache = 10 * 1024;
10659 } 11965 }
10660 System.out.println("**** ***** **** pref mapcache=" + PREF_mapcache); 11966 System.out.println("**** ***** **** pref mapcache=" + p.PREF_mapcache);
10661 } 11967 }
10662 11968
10663 private static void activatePrefs_mapcache() 11969 private static void activatePrefs_mapcache()
10664 { 11970 {
10665 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0); 11971 // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);
10668 h_temp2 = NavitGraphics.callback_handler_s; 11974 h_temp2 = NavitGraphics.callback_handler_s;
10669 System.out.println("activatePrefs_mapcache " + NavitGraphics.callback_handler_s); 11975 System.out.println("activatePrefs_mapcache " + NavitGraphics.callback_handler_s);
10670 Message msg7 = new Message(); 11976 Message msg7 = new Message();
10671 Bundle b7 = new Bundle(); 11977 Bundle b7 = new Bundle();
10672 b7.putInt("Callback", 55); 11978 b7.putInt("Callback", 55);
10673 b7.putString("s", String.valueOf(PREF_mapcache * 1024)); 11979 b7.putString("s", String.valueOf(p.PREF_mapcache * 1024));
10674 msg7.setData(b7); 11980 msg7.setData(b7);
10675 h_temp2.sendMessage(msg7); 11981 h_temp2.sendMessage(msg7);
10676 11982
10677 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 11983 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10678 } 11984 }
10709 } 12015 }
10710 search_intent.putExtra("partial_match", pm_temp); 12016 search_intent.putExtra("partial_match", pm_temp);
10711 this.startActivityForResult(search_intent, NavitAddressSearch_id_offline); 12017 this.startActivityForResult(search_intent, NavitAddressSearch_id_offline);
10712 } 12018 }
10713 12019
10714 private void share_location(String lat, String lon, String name, String subject_text) 12020 private void share_location(String lat, String lon, String name, String subject_text, String time_at_destination, boolean is_dest)
10715 { 12021 {
10716 Intent intent = new Intent(Intent.ACTION_SEND); 12022 Intent intent = new Intent(Intent.ACTION_SEND);
10717 intent.setType("text/plain"); 12023 intent.setType("text/plain");
10718 String url; 12024 String url;
10719 final String map_zoomlevel = "18"; 12025 final String map_zoomlevel = "18";
10720 // url = "" + lat + "," + lon + "\n" + name; 12026 // url = "" + lat + "," + lon + "\n" + name;
10721 url = "http://maps.google.com/?q=" + lat + "," + lon + "&z=" + map_zoomlevel + "\n\n" + name; 12027 url = "http://maps.google.com/?q=" + lat + "," + lon + "&z=" + map_zoomlevel + "\n\n" + name;
12028
12029 if (is_dest)
12030 {
12031 if (time_at_destination.compareTo("") != 0)
12032 {
12033 url = url + " " + time_at_destination;
12034 }
12035 }
10722 12036
10723 intent.putExtra(Intent.EXTRA_TEXT, url); 12037 intent.putExtra(Intent.EXTRA_TEXT, url);
10724 intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject_text); 12038 intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject_text);
10725 //Uri uri = Uri.parse("geo:0,0?z=16&q=" + lat + "," + lon); 12039 //Uri uri = Uri.parse("geo:0,0?z=16&q=" + lat + "," + lon);
10726 //intent.putExtra(Intent.EXTRA_STREAM, uri); 12040 //intent.putExtra(Intent.EXTRA_STREAM, uri);
10782 NavitGraphics.callback_handler.sendMessage(msg); 12096 NavitGraphics.callback_handler.sendMessage(msg);
10783 12097
10784 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1); 12098 // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
10785 } 12099 }
10786 12100
12101 static public void show_geo_on_screen_with_zoom_and_delay(float lat, float lon)
12102 {
12103 show_geo_on_screen_with_zoom_and_delay(lat, lon, 0);
12104 }
12105
12106 @SuppressLint("NewApi")
12107 static public void show_geo_on_screen_with_zoom_and_delay(final float lat, final float lon, final int millis_start_delay)
12108 {
12109 System.out.println("XSOM:010");
12110
12111 // if (api_version_int < 11)
12112 // {
12113 //
12114 // new AsyncTask<Void, Void, String>()
12115 // {
12116 // @Override
12117 // protected String doInBackground(Void... params)
12118 // {
12119 // System.out.println("XSOM:011");
12120 //
12121 // try
12122 // {
12123 // System.out.println("XSOM:001");
12124 // Thread.sleep((long) millis_start_delay);
12125 // Navit.show_geo_on_screen_no_draw(lat, lon);
12126 // System.out.println("XSOM:002");
12127 // Thread.sleep(100);
12128 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12129 // System.out.println("XSOM:004");
12130 // Thread.sleep(120);
12131 // Navit.draw_map();
12132 // System.out.println("XSOM:005");
12133 // }
12134 // catch (Exception e)
12135 // {
12136 // }
12137 //
12138 // return "";
12139 // }
12140 //
12141 // @Override
12142 // protected void onPostExecute(String msg)
12143 // {
12144 //
12145 // }
12146 // }.execute(null, null, null);
12147 //
12148 // }
12149 // else
12150 // {
12151 // new AsyncTask<Void, Void, String>()
12152 // {
12153 // @Override
12154 // protected String doInBackground(Void... params)
12155 // {
12156 // System.out.println("XSOM:011");
12157 //
12158 // try
12159 // {
12160 // System.out.println("XSOM:001");
12161 // Thread.sleep((long) millis_start_delay);
12162 // Navit.show_geo_on_screen_no_draw(lat, lon);
12163 // System.out.println("XSOM:002");
12164 // Thread.sleep(100);
12165 // Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12166 // System.out.println("XSOM:004");
12167 // Thread.sleep(120);
12168 // Navit.draw_map();
12169 // System.out.println("XSOM:005");
12170 // }
12171 // catch (Exception e)
12172 // {
12173 // }
12174 //
12175 // return "";
12176 // }
12177 //
12178 // @Override
12179 // protected void onPostExecute(String msg)
12180 // {
12181 //
12182 // }
12183 // }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
12184 //
12185 // }
12186
12187 final Thread temp_work_thread = new Thread()
12188 {
12189 @Override
12190 public void run()
12191 {
12192 try
12193 {
12194 Thread.sleep((long) millis_start_delay);
12195 Navit.show_geo_on_screen_no_draw(lat, lon);
12196 Thread.sleep(500);
12197 Navit.set_zoom_level_no_draw(Navit.Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL);
12198 Thread.sleep(120);
12199 Navit.draw_map();
12200 }
12201 catch (Exception e2)
12202 {
12203 e2.printStackTrace();
12204 }
12205 }
12206 };
12207 temp_work_thread.start();
12208 }
12209
10787 public void show_geo_on_screen(float lat, float lng) 12210 static public void show_geo_on_screen(float lat, float lng)
10788 { 12211 {
10789 // -> let follow mode stay as it now is ### Navit.follow_button_off();
10790
10791 // this function sets screen center to "lat, lon", and just returns a dummy string! 12212 // this function sets screen center to "lat, lon", and just returns a dummy string!
10792 Navit.cwthr.CallbackGeoCalc2(2, 3, lat, lng); 12213 Navit.cwthr.CallbackGeoCalc2(2, 3, lat, lng);
10793 } 12214 }
10794 12215
12216 static public void show_geo_on_screen_no_draw(float lat, float lng)
12217 {
12218 // this function sets screen center to "lat, lon", and just returns a dummy string!
12219 Navit.cwthr.CallbackGeoCalc2(2, 15, lat, lng);
12220 }
12221
10795 public void zoom_to_route() 12222 public static void zoom_to_route()
10796 { 12223 {
10797 try 12224 try
10798 { 12225 {
10799 //System.out.println(""); 12226 //System.out.println("");
10800 //System.out.println("*** Zoom to ROUTE ***"); 12227 //System.out.println("*** Zoom to ROUTE ***");
10817 try 12244 try
10818 { 12245 {
10819 Message msg = new Message(); 12246 Message msg = new Message();
10820 Bundle b = new Bundle(); 12247 Bundle b = new Bundle();
10821 b.putInt("Callback", 51); 12248 b.putInt("Callback", 51);
12249
12250 if (Navit.GFX_OVERSPILL)
12251 {
12252 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
12253 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
12254 }
12255 else
12256 {
10822 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2)); 12257 b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
10823 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2)); 12258 b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
12259 }
10824 msg.setData(b); 12260 msg.setData(b);
10825 NavitGraphics.callback_handler.sendMessage(msg); 12261 NavitGraphics.callback_handler.sendMessage(msg);
10826 } 12262 }
10827 catch (Exception e) 12263 catch (Exception e)
10828 { 12264 {
10831 12267
10832 public void turn_on_compass() 12268 public void turn_on_compass()
10833 { 12269 {
10834 try 12270 try
10835 { 12271 {
10836 if (!PREF_use_compass_heading_fast) 12272 if (!p.PREF_use_compass_heading_fast)
10837 12273
10838 { 12274 {
10839 // Slower 12275 // Slower
10840 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); 12276 sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL);
10841 } 12277 }
10892 // compass 12328 // compass
10893 } 12329 }
10894 12330
10895 public void hide_status_bar() 12331 public void hide_status_bar()
10896 { 12332 {
10897 if (!PREF_show_status_bar) 12333 if (!p.PREF_show_status_bar)
10898 { 12334 {
10899 // Hide the Status Bar 12335 // Hide the Status Bar
10900 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN); 12336 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN);
10901 } 12337 }
10902 } 12338 }
11014 if (map_points == null) 12450 if (map_points == null)
11015 { 12451 {
11016 map_points = new ArrayList<Navit_Point_on_Map>(); 12452 map_points = new ArrayList<Navit_Point_on_Map>();
11017 } 12453 }
11018 12454
12455 int el_pos = get_destination_pos(element);
12456 // int home_id = find_home_point();
12457 boolean is_home = is_home_element(element);
12458
12459 // System.out.println("EEPOS:el_pos=" + el_pos + " is_home=" + is_home);
12460
12461 if (is_home)
12462 {
12463 // its the "home" destination
12464 return;
12465 }
12466
11019 if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS) 12467 if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
11020 { 12468 {
11021 try 12469 try
11022 { 12470 {
11023 // map_points.remove(0); 12471 // map_points.remove(0);
11026 catch (Exception e) 12474 catch (Exception e)
11027 { 12475 {
11028 } 12476 }
11029 } 12477 }
11030 12478
11031 int el_pos = check_dup_destination_pos(element);
11032 if (el_pos == -1) 12479 if (el_pos == -1)
11033 { 12480 {
11034 // if not duplicate, then add 12481 // if not duplicate, then add
11035 map_points.add(element); 12482 map_points.add(element);
11036 readd_home_point(); 12483 readd_home_point();
11232 12679
11233 static void remember_destination_xy(String name, int x, int y) 12680 static void remember_destination_xy(String name, int x, int y)
11234 { 12681 {
11235 // i=1 -> pixel a,b (x,y) -> geo string "lat(float):lng(float)" 12682 // i=1 -> pixel a,b (x,y) -> geo string "lat(float):lng(float)"
11236 // i=2 -> geo a,b (lat,lng) -> pixel string "x(int):y(int)" 12683 // i=2 -> geo a,b (lat,lng) -> pixel string "x(int):y(int)"
11237 String lat_lon = NavitGraphics.CallbackGeoCalc(1, x * NavitGraphics.Global_dpi_factor, y * NavitGraphics.Global_dpi_factor); 12684 String lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
11238 try 12685 try
11239 { 12686 {
11240 String tmp[] = lat_lon.split(":", 2); 12687 String tmp[] = lat_lon.split(":", 2);
11241 //System.out.println("tmp=" + lat_lon); 12688 //System.out.println("tmp=" + lat_lon);
11242 float lat = Float.parseFloat(tmp[0]); 12689 float lat = Float.parseFloat(tmp[0]);
11303 } 12750 }
11304 } 12751 }
11305 return ret; 12752 return ret;
11306 } 12753 }
11307 12754
11308 static int check_dup_destination_pos(Navit_Point_on_Map element) 12755 static int get_destination_pos(Navit_Point_on_Map element)
11309 { 12756 {
11310 int ret = -1; 12757 int ret = -1;
11311 Navit_Point_on_Map t; 12758 Navit_Point_on_Map t;
11312 for (int i = 0; i < map_points.size(); i++) 12759 for (int i = 0; i < map_points.size(); i++)
11313 { 12760 {
11326 return i; 12773 return i;
11327 } 12774 }
11328 } 12775 }
11329 } 12776 }
11330 return ret; 12777 return ret;
12778 }
12779
12780 static boolean is_home_element(Navit_Point_on_Map element)
12781 {
12782 int home_id = find_home_point();
12783 if (home_id != -1)
12784 {
12785 Navit_Point_on_Map home_element = map_points.get(home_id);
12786
12787 if ((home_element.point_name.equals(element.point_name)) && (home_element.lat == element.lat) && (home_element.lon == element.lon))
12788 {
12789 return true;
12790 }
12791
12792 }
12793
12794 return false;
11331 } 12795 }
11332 12796
11333 static NavitSpeech2 get_speech_object() 12797 static NavitSpeech2 get_speech_object()
11334 { 12798 {
11335 System.out.println("get_speech_object"); 12799 System.out.println("get_speech_object");
11393 public String roundTwoDecimals(double d) 12857 public String roundTwoDecimals(double d)
11394 { 12858 {
11395 return String.format(Locale.US, "%.2f", d); 12859 return String.format(Locale.US, "%.2f", d);
11396 } 12860 }
11397 12861
12862 /* ZZ GEO TRANS ZZ */
12863 static double __EARTH_RADIUS__ = 6378137.000;
12864 static double __GEO_ACCURACY_FACTOR__ = 2.000;
12865 final static double M_PI_div_360 = 0.008726646259971647884618;
12866 final static double M_PI_div_180 = 0.01745329251994329576;
12867 final static double M_PI_mul_360 = 1130.97335529232556584560;
12868 final static double M_PI_mul_180 = 565.48667764616278292280;
12869
12870 /* ZZ GEO TRANS ZZ */
12871
11398 public static int transform_from_geo_lat(double lat) 12872 public static int transform_from_geo_lat(double lat)
11399 { 12873 {
11400 /* slower */ 12874 /* ZZ GEO TRANS ZZ */
11401 // int ret = log(tan(M_PI_4 + lat * M_PI / 360)) * 6371000.0; 12875 int ret = (int) ((Math.log(Math.tan((Math.PI / 4f) + lat * M_PI_div_360)) * __EARTH_RADIUS__) * __GEO_ACCURACY_FACTOR__);
11402 /* slower */
11403
11404 /* fast */
11405 int ret = (int) (Math.log(Math.tan((Math.PI / 4f) + lat * 0.008726646259971647884618)) * 6371000.0f); // already calced (M_PI/360)
11406 /* fast */
11407
11408 return ret; 12876 return ret;
11409 } 12877 }
11410 12878
11411 public static int transform_from_geo_lon(double lon) 12879 public static int transform_from_geo_lon(double lon)
11412 { 12880 {
11413 /* slower */ 12881 /* ZZ GEO TRANS ZZ */
11414 // int ret = lon * 6371000.0 * M_PI / 180; 12882 int ret = (int) ((lon * __EARTH_RADIUS__ * M_PI_div_180) * __GEO_ACCURACY_FACTOR__);
11415 /* slower */
11416
11417 /* fast */
11418 int ret = (int) (lon * 111194.9266445587373); // already calced (6371000.0*M_PI/180)
11419 /* fast */
11420 12883
11421 return ret; 12884 return ret;
11422 } 12885 }
11423 12886
11424 public static double transform_to_geo_lat(float lat) // y 12887 public static double transform_to_geo_lat(float y) // y
11425 { 12888 {
11426 return (Math.atan(Math.exp(lat / 6371000.0)) / Math.PI * 360 - 90); 12889 /* ZZ GEO TRANS ZZ */
12890 return (Math.atan(Math.exp((y / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__)) / M_PI_div_360 - 90);
11427 } 12891 }
11428 12892
11429 public static double transform_to_geo_lon(float lon) // x 12893 public static double transform_to_geo_lon(float x) // x
11430 { 12894 {
11431 // g->lng=c->x/6371000.0/M_PI*180; 12895 /* ZZ GEO TRANS ZZ */
11432 return (lon * 0.00000899322); // simpler 12896 return ((x / __GEO_ACCURACY_FACTOR__) / __EARTH_RADIUS__ / M_PI_div_180);
11433 } 12897 }
11434 12898
11435 public static boolean allow_use_index_search() 12899 public static boolean allow_use_index_search()
11436 { 12900 {
11437 if ((!Navit_DonateVersion_Installed) && (!Navit_Largemap_DonateVersion_Installed)) 12901 if ((!Navit_DonateVersion_Installed) && (!Navit_Largemap_DonateVersion_Installed))
11438 { 12902 {
11439 // no donate version installed 12903 // no donate version installed
11440 Log.e("Navit", "no donate version installed"); 12904 Log.e("Navit", "no donate version installed");
12905
12906 Navit_index_on_but_no_idx_files = false;
11441 return false; 12907 return false;
11442 } 12908 }
11443 12909
11444 if (!PREF_use_index_search) 12910 boolean ret = false;
11445 {
11446 // user does not want to use index search (it was disabled via preferences)
11447 return false;
11448 }
11449 12911
11450 // MAP_FILENAME_PATH 12912 // MAP_FILENAME_PATH
11451 File folder = new File(MAP_FILENAME_PATH); 12913 File folder = new File(MAP_FILENAME_PATH);
11452 File[] listOfFiles = folder.listFiles(); 12914 File[] listOfFiles = folder.listFiles();
12915 File idx = null;
12916 File md5_file = null;
12917 FileOutputStream fos = null;
12918
12919 int files = 0;
12920 int file_without_index = 0;
11453 12921
11454 for (File file : listOfFiles) 12922 for (File file : listOfFiles)
11455 { 12923 {
11456 if (file.isFile()) 12924 if (file.isFile())
11457 { 12925 {
11458 System.out.println(file.getName()); 12926 // System.out.println("FFNN:" + file.getName());
12927
12928 if (file.getName().endsWith(".bin"))
12929 {
12930 if (!file.getName().equals("borders.bin"))
12931 {
12932 if (!file.getName().equals("coastline.bin"))
12933 {
12934 files++;
12935 idx = new File(folder, file.getName() + ".idx");
12936 if (idx.exists())
12937 {
12938 }
12939 else
12940 {
12941 file_without_index++;
12942
12943 String servername = "";
12944 try
12945 {
12946 servername = NavitMapDownloader.is_in_cat_file_disk_name(file.getName()).split(":", 2)[1];
12947 }
12948 catch (Exception ee)
12949 {
12950 }
12951
12952 if (!servername.equals(""))
12953 {
12954
12955 // index for this map is missing. hack MD5 file so we can download it again
12956 md5_file = new File(Navit.MAPMD5_FILENAME_PATH + "/" + servername + ".md5");
12957
12958 // System.out.println("FFNN:hack MD5:" + md5_file.getAbsolutePath() + " s=" + servername);
12959
12960 if ((md5_file.exists()) && (md5_file.canWrite()))
12961 {
12962 try
12963 {
12964 fos = new FileOutputStream(md5_file);
12965 fos.write(65);
12966 fos.write(65);
12967 fos.write(65);
12968 fos.close();
12969 }
12970 catch (Exception e1)
12971 {
12972 // System.out.println("FFNN:EEEEEEEEEEEEEE");
12973 }
12974 }
12975 }
12976 }
12977 }
12978 }
12979 }
12980
11459 if (file.getName().endsWith(".bin.idx")) 12981 if (file.getName().endsWith(".bin.idx"))
11460 { 12982 {
11461 return true; 12983 ret = true;
11462 }
11463 } 12984 }
11464 } 12985 }
12986 }
12987
12988 if (files > 0)
12989 {
12990 if (file_without_index > 0)
12991 {
12992 Navit_index_on_but_no_idx_files = true;
12993 }
12994 else
12995 {
12996 Navit_index_on_but_no_idx_files = false;
12997 }
12998 }
12999
11465 return false; 13000 return ret;
11466 } 13001 }
11467 13002
11468 private void sendEmail(String recipient, String subject, String message) 13003 private void sendEmail(String recipient, String subject, String message)
11469 { 13004 {
11470 try 13005 try
11565 public void run() 13100 public void run()
11566 { 13101 {
11567 Navit_doubleBackToExitPressedOnce = false; 13102 Navit_doubleBackToExitPressedOnce = false;
11568 } 13103 }
11569 }, NAVIT_BACKBUTTON_TO_EXIT_TIME); 13104 }, NAVIT_BACKBUTTON_TO_EXIT_TIME);
13105 }
13106 catch (Exception e)
13107 {
13108 }
13109
13110 try
13111 {
13112 // if bottom bar is up, animate it down on "back" press
13113 animate_bottom_bar_down();
11570 } 13114 }
11571 catch (Exception e) 13115 catch (Exception e)
11572 { 13116 {
11573 } 13117 }
11574 13118
11676 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " "; 13220 if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
11677 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line); 13221 tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
11678 } 13222 }
11679 } 13223 }
11680 13224
11681 // DEBUG: clear route rectangle list 13225 // // DEBUG: clear route rectangle list
11682 NavitGraphics.route_rects.clear(); 13226 // NavitGraphics.route_rects.clear();
11683 13227 //
11684 System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon); 13228 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
11685 13229 //
11686 try 13230 // try
11687 { 13231 // {
11688 Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon); 13232 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
11689 // save points 13233 // // save points
11690 write_map_points(); 13234 // write_map_points();
11691 } 13235 // }
11692 catch (Exception e) 13236 // catch (Exception e)
11693 { 13237 // {
11694 e.printStackTrace(); 13238 // e.printStackTrace();
11695 } 13239 // }
11696 13240 //
11697 if (NavitGraphics.navit_route_status == 0) 13241 // if (NavitGraphics.navit_route_status == 0)
11698 { 13242 // {
11699 Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS 13243 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
11700 Navit.destination_set(); 13244 // Navit.destination_set();
11701 13245 //
11702 Message msg = new Message(); 13246 // Message msg = new Message();
11703 Bundle b = new Bundle(); 13247 // Bundle b = new Bundle();
11704 b.putInt("Callback", 3); 13248 // b.putInt("Callback", 3);
11705 b.putString("lat", String.valueOf(tmp_addr.lat)); 13249 // b.putString("lat", String.valueOf(tmp_addr.lat));
11706 b.putString("lon", String.valueOf(tmp_addr.lon)); 13250 // b.putString("lon", String.valueOf(tmp_addr.lon));
11707 b.putString("q", tmp_addr.addr); 13251 // b.putString("q", tmp_addr.addr);
11708 msg.setData(b); 13252 // msg.setData(b);
11709 NavitGraphics.callback_handler.sendMessage(msg); 13253 // NavitGraphics.callback_handler.sendMessage(msg);
11710 } 13254 // }
11711 else 13255 // else
11712 { 13256 // {
11713 Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS 13257 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
11714 Message msg = new Message(); 13258 // Message msg = new Message();
11715 Bundle b = new Bundle(); 13259 // Bundle b = new Bundle();
11716 b.putInt("Callback", 48); 13260 // b.putInt("Callback", 48);
11717 b.putString("lat", String.valueOf(tmp_addr.lat)); 13261 // b.putString("lat", String.valueOf(tmp_addr.lat));
11718 b.putString("lon", String.valueOf(tmp_addr.lon)); 13262 // b.putString("lon", String.valueOf(tmp_addr.lon));
11719 b.putString("q", tmp_addr.addr); 13263 // b.putString("q", tmp_addr.addr);
11720 msg.setData(b); 13264 // msg.setData(b);
11721 NavitGraphics.callback_handler.sendMessage(msg); 13265 // NavitGraphics.callback_handler.sendMessage(msg);
11722 } 13266 // }
13267
13268 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
11723 13269
11724 // ---------- DEBUG: write route to file ---------- 13270 // ---------- DEBUG: write route to file ----------
11725 // ---------- DEBUG: write route to file ---------- 13271 // ---------- DEBUG: write route to file ----------
11726 // ---------- DEBUG: write route to file ---------- 13272 // ---------- DEBUG: write route to file ----------
11727 if (PREF_enable_debug_write_gpx) 13273 if (p.PREF_enable_debug_write_gpx)
11728 { 13274 {
11729 write_route_to_gpx_file(); 13275 write_route_to_gpx_file();
11730 } 13276 }
11731 // ---------- DEBUG: write route to file ---------- 13277 // ---------- DEBUG: write route to file ----------
11732 // ---------- DEBUG: write route to file ---------- 13278 // ---------- DEBUG: write route to file ----------
11760 tmp_addr.item_id = "0"; 13306 tmp_addr.item_id = "0";
11761 tmp_addr.lat = (float) lat; 13307 tmp_addr.lat = (float) lat;
11762 tmp_addr.lon = (float) lon; 13308 tmp_addr.lon = (float) lon;
11763 tmp_addr.addr = addr; 13309 tmp_addr.addr = addr;
11764 13310
11765 // DEBUG: clear route rectangle list 13311 // // DEBUG: clear route rectangle list
11766 NavitGraphics.route_rects.clear(); 13312 // NavitGraphics.route_rects.clear();
11767 13313 //
11768 System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon); 13314 // System.out.println("found:" + tmp_addr.addr + " " + tmp_addr.lat + " " + tmp_addr.lon);
11769 13315 //
11770 try 13316 // try
11771 { 13317 // {
11772 Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon); 13318 // Navit.remember_destination(tmp_addr.addr, tmp_addr.lat, tmp_addr.lon);
11773 // save points 13319 // // save points
11774 write_map_points(); 13320 // write_map_points();
11775 } 13321 // }
11776 catch (Exception e) 13322 // catch (Exception e)
11777 { 13323 // {
11778 e.printStackTrace(); 13324 // e.printStackTrace();
11779 } 13325 // }
11780 13326 //
11781 if (NavitGraphics.navit_route_status == 0) 13327 // if (NavitGraphics.navit_route_status == 0)
11782 { 13328 // {
11783 Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS 13329 // Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
11784 Navit.destination_set(); 13330 // Navit.destination_set();
11785 13331 //
11786 Message msg = new Message(); 13332 // Message msg = new Message();
11787 Bundle b = new Bundle(); 13333 // Bundle b = new Bundle();
11788 b.putInt("Callback", 3); 13334 // b.putInt("Callback", 3);
11789 b.putString("lat", String.valueOf(tmp_addr.lat)); 13335 // b.putString("lat", String.valueOf(tmp_addr.lat));
11790 b.putString("lon", String.valueOf(tmp_addr.lon)); 13336 // b.putString("lon", String.valueOf(tmp_addr.lon));
11791 b.putString("q", tmp_addr.addr); 13337 // b.putString("q", tmp_addr.addr);
11792 msg.setData(b); 13338 // msg.setData(b);
11793 NavitGraphics.callback_handler.sendMessage(msg); 13339 // NavitGraphics.callback_handler.sendMessage(msg);
11794 } 13340 // }
11795 else 13341 // else
11796 { 13342 // {
11797 Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS 13343 // Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + tmp_addr.addr, Toast.LENGTH_SHORT).show(); //TRANS
11798 Message msg = new Message(); 13344 // Message msg = new Message();
11799 Bundle b = new Bundle(); 13345 // Bundle b = new Bundle();
11800 b.putInt("Callback", 48); 13346 // b.putInt("Callback", 48);
11801 b.putString("lat", String.valueOf(tmp_addr.lat)); 13347 // b.putString("lat", String.valueOf(tmp_addr.lat));
11802 b.putString("lon", String.valueOf(tmp_addr.lon)); 13348 // b.putString("lon", String.valueOf(tmp_addr.lon));
11803 b.putString("q", tmp_addr.addr); 13349 // b.putString("q", tmp_addr.addr);
11804 msg.setData(b); 13350 // msg.setData(b);
11805 NavitGraphics.callback_handler.sendMessage(msg); 13351 // NavitGraphics.callback_handler.sendMessage(msg);
11806 } 13352 // }
13353
13354 route_wrapper(tmp_addr.addr, 0, 0, false, tmp_addr.lat, tmp_addr.lon, true);
11807 13355
11808 try 13356 try
11809 { 13357 {
11810 Navit.follow_button_on(); 13358 Navit.follow_button_on();
11811 } 13359 }
11815 } 13363 }
11816 13364
11817 // ---------- DEBUG: write route to file ---------- 13365 // ---------- DEBUG: write route to file ----------
11818 // ---------- DEBUG: write route to file ---------- 13366 // ---------- DEBUG: write route to file ----------
11819 // ---------- DEBUG: write route to file ---------- 13367 // ---------- DEBUG: write route to file ----------
11820 if (PREF_enable_debug_write_gpx) 13368 if (p.PREF_enable_debug_write_gpx)
11821 { 13369 {
11822 write_route_to_gpx_file(); 13370 write_route_to_gpx_file();
11823 } 13371 }
11824 // ---------- DEBUG: write route to file ---------- 13372 // ---------- DEBUG: write route to file ----------
11825 // ---------- DEBUG: write route to file ---------- 13373 // ---------- DEBUG: write route to file ----------
11834 } 13382 }
11835 } 13383 }
11836 13384
11837 void open_voice_recog_screen() 13385 void open_voice_recog_screen()
11838 { 13386 {
11839 Intent map_delete_list_activity2 = new Intent(this, ZANaviVoiceInput.class); 13387 Intent ii = new Intent(this, ZANaviVoiceInput.class);
11840 this.startActivityForResult(map_delete_list_activity2, Navit.ZANaviVoiceInput_id); 13388 this.startActivityForResult(ii, Navit.ZANaviVoiceInput_id);
11841 } 13389 }
11842 13390
11843 static void dim_screen_wrapper() 13391 static void dim_screen_wrapper()
11844 { 13392 {
11845 try 13393 try
12135 } 13683 }
12136 13684
12137 void convert_gpx_file_real(String gpx_file) 13685 void convert_gpx_file_real(String gpx_file)
12138 { 13686 {
12139 File tt2 = new File(gpx_file); 13687 File tt2 = new File(gpx_file);
12140 PREF_last_selected_dir_gpxfiles = tt2.getParent(); 13688 p.PREF_last_selected_dir_gpxfiles = tt2.getParent();
12141 Log.e("Navit", "last_selected_dir_gpxfiles " + PREF_last_selected_dir_gpxfiles); 13689 Log.e("Navit", "last_selected_dir_gpxfiles " + p.PREF_last_selected_dir_gpxfiles);
12142 setPrefs_selected_gpx_dir(); 13690 setPrefs_selected_gpx_dir();
12143 13691
12144 String out_ = MAP_FILENAME_PATH + "/gpxtracks.txt"; 13692 String out_ = MAP_FILENAME_PATH + "/gpxtracks.txt";
12145 Log.e("Navit", "onActivityResult 002 " + gpx_file + " " + out_); 13693 Log.e("Navit", "onActivityResult 002 " + gpx_file + " " + out_);
12146 MainFrame.do_conversion(gpx_file, out_); 13694 MainFrame.do_conversion(gpx_file, out_);
12523 private com.zoffcc.applications.zanavi_msg.ZListener.Stub zclientListener = new com.zoffcc.applications.zanavi_msg.ZListener.Stub() 14071 private com.zoffcc.applications.zanavi_msg.ZListener.Stub zclientListener = new com.zoffcc.applications.zanavi_msg.ZListener.Stub()
12524 { 14072 {
12525 @Override 14073 @Override
12526 public String handleUpdated(String data) throws RemoteException 14074 public String handleUpdated(String data) throws RemoteException
12527 { 14075 {
12528 Log.i("NavitPlugin", "update from Plugin=" + data); 14076 // Log.i("NavitPlugin", "update from Plugin=" + data);
12529 return "Navit says:\"PONG\""; 14077 return "Navit says:\"PONG\"";
12530 } 14078 }
12531 }; 14079 };
14080
14081 static Object sync_plugin_send = new Object();
14082
14083 public static void send_data_to_plugin_bg(final int msg_cat, final String data)
14084 {
14085 // send data to plugin (plugin will send to server) in another task! --------------------------
14086 new AsyncTask<Void, Void, String>()
14087 {
14088 @Override
14089 protected String doInBackground(Void... params)
14090 {
14091 synchronized (sync_plugin_send)
14092 {
14093 try
14094 {
14095 if (plugin_api == null)
14096 {
14097 try
14098 {
14099 Thread.sleep(3000); // wait until the service is bound
14100 }
14101 catch (Exception e)
14102 {
14103 }
14104 }
14105
14106 String response = plugin_api.getResult(PLUGIN_MSG_ID, msg_cat, data);
14107
14108 }
14109 catch (RemoteException e)
14110 {
14111 // Log.e("NavitPlugin", "Failed(1) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14112 }
14113 catch (Exception e)
14114 {
14115 // Log.e("NavitPlugin", "Failed(2) to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + data, e);
14116 }
14117 }
14118 return "";
14119 }
14120
14121 @Override
14122 protected void onPostExecute(String msg)
14123 {
14124
14125 }
14126 }.execute(null, null, null);
14127 // send data to plugin (plugin will send to server) in another task! --------------------------
14128 }
12532 14129
12533 private ServiceConnection serviceConnection = new ServiceConnection() 14130 private ServiceConnection serviceConnection = new ServiceConnection()
12534 { 14131 {
12535 @Override 14132 @Override
12536 public void onServiceConnected(ComponentName name, IBinder service) 14133 public void onServiceConnected(ComponentName name, IBinder service)
12543 { 14140 {
12544 plugin_api.addListener(zclientListener); 14141 plugin_api.addListener(zclientListener);
12545 } 14142 }
12546 catch (RemoteException e) 14143 catch (RemoteException e)
12547 { 14144 {
12548 Log.e("NavitPlugin", "Failed to add listener", e); 14145 Log.e("NavitPlugin", "Failed(1) to add listener", e);
14146 }
14147 catch (Exception e)
14148 {
14149 Log.e("NavitPlugin", "Failed(2) to add listener", e);
14150 }
14151
14152 send_installed_maps_to_plugin();
14153 send_data_to_plugin_bg(PLUGIN_MSG_CAT_zanavi_version, Navit.NavitAppVersion);
14154 }
14155
14156 @Override
14157 public void onServiceDisconnected(ComponentName name)
14158 {
14159 plugin_api = null;
14160 Log.i("NavitPlugin", "Service connection closed");
14161 }
14162 };
14163
14164 /**
14165 * send installed maps and download date/time (time up to minute) in UTC to plugin
14166 */
14167 static void send_installed_maps_to_plugin()
14168 {
14169 try
14170 {
14171 /*
14172 * { "201502032311":"austria.bin","201502032312":"germany.bin" }
14173 */
14174
14175 String data = "";
14176
14177 // dirty hardcode JSON data struct
14178 final String maps_and_timestamp_data_start = "{ \"";
14179 final String maps_and_timestamp_data_sep1 = "\":\"";
14180 final String maps_and_timestamp_data_sep2 = "\",\"";
14181 final String maps_and_timestamp_data_end = "\" }";
14182
14183 NavitMapDownloader.init_cat_file_maps_timestamps();
14184
14185 data = data + maps_and_timestamp_data_start;
14186
14187 String map_name = "";
14188 Iterator<String> k = NavitMapDownloader.map_catalogue_date.listIterator();
14189 while (k.hasNext())
14190 {
14191 map_name = k.next();
14192 data = data + map_name.split(":", 2)[1];
14193 data = data + maps_and_timestamp_data_sep1;
14194 data = data + map_name.split(":", 2)[0];
14195 if (k.hasNext())
14196 {
14197 data = data + maps_and_timestamp_data_sep2;
12549 } 14198 }
14199 }
14200 data = data + maps_and_timestamp_data_end;
12550 14201
12551 // send data to plugin (plugin will send to server) in another task! -------------------------- 14202 // System.out.println("PLUGIN:MAPS:" + data);
12552 new AsyncTask<Void, Void, String>() 14203
14204 send_data_to_plugin_bg(PLUGIN_MSG_CAT_installed_maps, data);
14205 }
14206 catch (Exception e)
14207 {
14208 }
14209 }
14210
14211 static boolean have_maps_installed()
14212 {
14213 int count_maps_installed = NavitMapDownloader.cat_file_maps_have_installed_any();
14214 if (count_maps_installed == 0)
14215 {
14216 return false;
14217 }
14218 else
14219 {
14220 return true;
14221 }
14222 }
14223
14224 /**
14225 * auto start map download/update
14226 *
14227 * @param map_name
14228 * mapfilename with ending ".bin"
14229 */
14230 void auto_start_update_map(String map_name)
14231 {
14232
14233 int count = NavitMapDownloader.z_OSM_MAPS.length;
14234 Navit.download_map_id = -1;
14235 for (int i = 0; i < count; i++)
14236 {
14237 if (!NavitMapDownloader.z_OSM_MAPS[i].is_continent)
14238 {
14239 // System.out.println("mmm1=" + NavitMapDownloader.z_OSM_MAPS[i].url);
14240 if (NavitMapDownloader.z_OSM_MAPS[i].url.equals(map_name))
14241 {
14242 Navit.download_map_id = i;
14243 System.out.println("mMM2=" + NavitMapDownloader.z_OSM_MAPS[i].map_name);
14244 }
14245 }
14246 }
14247
14248 // show the map download progressbar, and download the map
14249 if (Navit.download_map_id > -1)
14250 {
14251 // new method in service
14252 Message msg = progress_handler.obtainMessage();
14253 Bundle b = new Bundle();
14254 msg.what = 22;
14255 progress_handler.sendMessage(msg);
14256 }
14257 }
14258
14259 void show_case_001()
14260 {
14261 // try
14262 // {
14263 // new ShowcaseView.Builder(this).setTarget(new ViewTarget(R.id.no_maps_button, this)).setContentTitle("").setContentText("").singleShot(Navit.SHOWCASEVIEW_ID_001).build();
14264 // }
14265 // catch (Exception e1)
14266 // {
14267 // }
14268 // catch (NoSuchMethodError e2)
14269 // {
14270 // }
14271 // catch (NoClassDefFoundError e3)
14272 // {
14273 // }
14274 }
14275
14276 static void set_zoom_level(int want_zoom_level)
14277 {
14278 try
14279 {
14280 Bundle b = new Bundle();
14281 Message msg = new Message();
14282 b.putInt("Callback", 33);
14283 b.putString("s", Integer.toString(want_zoom_level));
14284 msg.setData(b);
14285 NavitGraphics.callback_handler.sendMessage(msg);
14286 }
14287 catch (Exception e)
14288 {
14289 e.printStackTrace();
14290 }
14291 }
14292
14293 static void set_zoom_level_no_draw(int want_zoom_level)
14294 {
14295 try
14296 {
14297 Bundle b = new Bundle();
14298 Message msg = new Message();
14299 b.putInt("Callback", 105);
14300 b.putString("s", Integer.toString(want_zoom_level));
14301 msg.setData(b);
14302 NavitGraphics.callback_handler.sendMessage(msg);
14303 }
14304 catch (Exception e)
14305 {
14306 e.printStackTrace();
14307 }
14308 }
14309
14310 static void draw_map()
14311 {
14312 try
14313 {
14314 // draw map no-async
14315 Message msg = new Message();
14316 Bundle b = new Bundle();
14317 b.putInt("Callback", 64);
14318 msg.setData(b);
14319 NavitGraphics.callback_handler.sendMessage(msg);
14320 }
14321 catch (Exception e)
14322 {
14323 e.printStackTrace();
14324 }
14325 }
14326
14327 final static int bottom_bar_snap_duration = 190;
14328
14329 void animate_bottom_bar_up()
14330 {
14331 final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
14332 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -cur_y_margin_bottom_bar_touch);
14333 animation.setDuration(bottom_bar_snap_duration); // animation duration
14334 animation.setFillAfter(true);
14335 animation.setFillEnabled(true);
14336 animation.setRepeatCount(0); // animation repeat count
14337 animation.setAnimationListener(new AnimationListener()
14338 {
14339 @Override
14340 public void onAnimationStart(Animation animation)
14341 {
14342 }
14343
14344 @Override
14345 public void onAnimationRepeat(Animation animation)
14346 {
14347 }
14348
14349 @Override
14350 public void onAnimationEnd(Animation animation)
14351 {
14352 cur_y_margin_bottom_bar_touch = 0;
14353 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14354 relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14355 a.setLayoutParams(relativeParams);
14356 a.requestLayout();
14357
14358 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14359 anim.setFillAfter(true);
14360 anim.setFillEnabled(true);
14361 anim.setDuration(1);
14362 a.startAnimation(anim);
14363 }
14364 });
14365 a.startAnimation(animation);
14366 }
14367
14368 static void animate_bottom_bar_down()
14369 {
14370 final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide);
14371
14372 // System.out.println("FRAG:animate_bottom_bar_down:014");
14373
14374 // set bottom end positon correctly??
14375 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14376
14377 final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch);
14378 TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); // new TranslateAnimation(xFrom,xTo, yFrom,yTo)
14379 animation.setDuration(bottom_bar_snap_duration); // animation duration
14380 animation.setFillAfter(true);
14381 animation.setFillEnabled(true);
14382 animation.setRepeatCount(0); // animation repeat count
14383 animation.setAnimationListener(new AnimationListener()
14384 {
14385
14386 @Override
14387 public void onAnimationStart(Animation animation)
14388 {
14389 }
14390
14391 @Override
14392 public void onAnimationRepeat(Animation animation)
14393 {
14394 }
14395
14396 @Override
14397 public void onAnimationEnd(Animation animation)
14398 {
14399 // set bottom end positon correctly??
14400 bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px;
14401
14402 cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch;
14403 RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
14404 relativeParams.setMargins(0, (int) bottom_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
14405 a.setLayoutParams(relativeParams);
14406 a.requestLayout();
14407
14408 TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
14409 anim.setFillAfter(true);
14410 anim.setFillEnabled(true);
14411 anim.setDuration(1);
14412 a.startAnimation(anim);
14413
14414 // remove roadbook fragment -----------
14415 try
14416 {
14417 if (road_book != null)
14418 {
14419 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
14420 // System.out.println("FRAG:dettach:002");
14421 fragmentTransaction.detach(road_book);
14422 fragmentTransaction.remove(road_book).commit();
14423 road_book = null;
14424 }
14425 }
14426 catch (Exception ef)
14427 {
14428 }
14429 // remove roadbook fragment -----------
14430
14431 }
14432 });
14433 a.startAnimation(animation);
14434 }
14435
14436 synchronized static int find_max_font_size_for_height(String sample_text, int height, int max_font_size, int padding_in_dp)
14437 {
14438 String s = sample_text;
14439 int bh = 0;
14440 Paint p = new Paint();
14441 Rect bounds = new Rect();
14442 p.setTextSize(max_font_size);
14443 // p.measureText(s);
14444 p.getTextBounds(s, 0, s.length(), bounds);
14445
14446 int ret_font_size = max_font_size;
14447
14448 int loop_counter_max = 400;
14449 int loop_counter = 0;
14450 int padding_in_px = 0;
14451 if (padding_in_dp > 0)
14452 {
14453 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14454 }
14455
14456 bh = bounds.height();
14457 //System.out.println("bh(1)=" + bh);
14458 while ((bh + padding_in_px) > height)
14459 {
14460 loop_counter++;
14461 if (loop_counter > loop_counter_max)
14462 {
14463 break;
14464 }
14465
14466 ret_font_size--;
14467 p.setTextSize(ret_font_size);
14468 // p.measureText(s);
14469 p.getTextBounds(s, 0, s.length(), bounds);
14470 bh = bounds.height();
14471 }
14472
14473 return ret_font_size;
14474 }
14475
14476 synchronized static int find_max_letters_for_width_and_fontsize(String max_length_text, int width, int max_font_size, int padding_in_dp)
14477 {
14478 int ret_max_letters = 10;
14479
14480 int padding_in_px = 0;
14481 if (padding_in_dp > 0)
14482 {
14483 //System.out.println("aaa2:l:1:x:" + padding_in_dp);
14484 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14485 //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);
14486 }
14487 //System.out.println("aaa2:l:1:x:1=" + padding_in_px);
14488
14489 int c = 0;
14490 Paint p = new Paint();
14491 p.setTextSize(max_font_size);
14492
14493 String s = max_length_text;
14494
14495 if ((s == null) || (s.equals("")))
14496 {
14497 s = "Mlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwoMlox3miwo";
14498 }
14499
14500 int l = s.length();
14501 ret_max_letters = l;
14502 float mt = p.measureText(s);
14503 //System.out.println("aaa2:l:1:" + l + " " + s);
14504 //System.out.println("aaa2:l:22:." + mt + " padding_in_px=" + padding_in_px + " " + width);
14505
14506 while (mt + padding_in_px > width)
14507 {
14508 //System.out.println("aaa2:l:22:+" + mt + " " + padding_in_px + " " + width);
14509
14510 c++;
14511 if (c == l)
14512 {
14513 // no more letters
14514 //System.out.println("aaa2:l:1:no more letters:" + l + " " + s);
14515 break;
14516 }
14517 s = s.substring(0, s.length() - 1);
14518 mt = p.measureText(s);
14519 ret_max_letters--;
14520 }
14521
14522 //System.out.println("aaa2:l:1:res=" + ret_max_letters);
14523 return ret_max_letters;
14524 }
14525
14526 synchronized static int find_max_font_size_for_width(String sample_text, int width, int max_font_size, int padding_in_dp)
14527 {
14528 final String s = sample_text;
14529 int bh = 0;
14530 Paint p = new Paint();
14531 Rect bounds = new Rect();
14532 p.setTextSize(max_font_size);
14533 p.getTextBounds(s, 0, s.length(), bounds);
14534
14535 int ret_font_size = max_font_size;
14536
14537 int loop_counter_max = 400;
14538 int loop_counter = 0;
14539 int padding_in_px = 0;
14540 if (padding_in_dp > 0)
14541 {
14542 padding_in_px = NavitGraphics.dp_to_px(padding_in_dp);
14543 }
14544
14545 bh = bounds.width();
14546 while ((bh + padding_in_px) > width)
14547 {
14548 loop_counter++;
14549 if (loop_counter > loop_counter_max)
14550 {
14551 break;
14552 }
14553
14554 ret_font_size--;
14555 p.setTextSize(ret_font_size);
14556 p.getTextBounds(s, 0, s.length(), bounds);
14557 bh = bounds.width();
14558 // mt = p.measureText(s);
14559 }
14560
14561 return ret_font_size;
14562 }
14563
14564 static int last_orientation = Configuration.ORIENTATION_LANDSCAPE;
14565
14566 @Override
14567 public void onConfigurationChanged(Configuration newConfig)
14568 {
14569 super.onConfigurationChanged(newConfig);
14570
14571 if (last_orientation != newConfig.orientation)
14572 {
14573 // Checks the orientation of the screen
14574 if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
14575 {
14576 // setContentView(R.layout.main_layout);
14577
14578 // -- bottom bar --
14579 int h = NavitGraphics.mCanvasHeight;
14580 try
14581 {
14582 int h001;
14583 android.view.ViewGroup.LayoutParams lp001;
14584
14585 View v003 = (View) findViewById(R.id.osd_nextturn_new);
14586 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
14587 lp001 = v003.getLayoutParams();
14588 lp001.height = h001;
14589 v003.requestLayout();
14590
14591 v003 = (View) findViewById(R.id.bottom_bar);
14592 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
14593 lp001 = v003.getLayoutParams();
14594 lp001.height = h001;
14595 v003.requestLayout();
14596
14597 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
14598 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
14599 lp001 = v002.getLayoutParams();
14600 lp001.height = h001;
14601 v002.requestLayout();
14602
14603 v003 = (View) findViewById(R.id.osd_timetodest_new);
14604 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
14605 lp001 = v003.getLayoutParams();
14606 lp001.height = h001;
14607 v003.requestLayout();
14608
14609 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
14610 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
14611 lp001 = v002.getLayoutParams();
14612 lp001.height = h001;
14613 v002.requestLayout();
14614
14615 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
14616 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
14617 lp001 = v001.getLayoutParams();
14618 lp001.height = h001;
14619 v001.requestLayout();
14620
14621 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
14622 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
14623 v003 = (View) findViewById(R.id.view_speeding);
14624 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
14625 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
14626 v003.setLayoutParams(relativeParams_001);
14627 v003.requestLayout();
14628
14629 // Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
14630
14631 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
14632 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
14633
14634 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
14635 }
14636 catch (Exception e)
14637 {
14638 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
14639 }
14640 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
14641 // -- bottom bar --
14642 }
14643 else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
14644 {
14645 // setContentView(R.layout.main_layout);
14646
14647 // -- bottom bar --
14648 int h = NavitGraphics.mCanvasHeight;
14649 try
14650 {
14651 int h001;
14652 android.view.ViewGroup.LayoutParams lp001;
14653
14654 View v003 = (View) findViewById(R.id.osd_nextturn_new);
14655 h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
14656 lp001 = v003.getLayoutParams();
14657 lp001.height = h001;
14658 v003.requestLayout();
14659
14660 v003 = (View) findViewById(R.id.bottom_bar);
14661 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
14662 lp001 = v003.getLayoutParams();
14663 lp001.height = h001;
14664 v003.requestLayout();
14665
14666 LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
14667 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
14668 lp001 = v002.getLayoutParams();
14669 lp001.height = h001;
14670 v002.requestLayout();
14671
14672 v003 = (View) findViewById(R.id.osd_timetodest_new);
14673 h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
14674 lp001 = v003.getLayoutParams();
14675 lp001.height = h001;
14676 v003.requestLayout();
14677
14678 v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
14679 h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
14680 lp001 = v002.getLayoutParams();
14681 lp001.height = h001;
14682 v002.requestLayout();
14683
14684 RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
14685 h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
14686 lp001 = v001.getLayoutParams();
14687 lp001.height = h001;
14688 v001.requestLayout();
14689
14690 int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
14691 int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
14692 v003 = (View) findViewById(R.id.view_speeding);
14693 RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003.getLayoutParams();
14694 relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
14695 v003.setLayoutParams(relativeParams_001);
14696 v003.requestLayout();
14697
14698 // Toast.makeText(this, "protrait", Toast.LENGTH_SHORT).show();
14699
14700 bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
14701 bottom_bar_slider_shadow_px = (int) getResources().getDimension(R.dimen.bottom_slide_view_shadow_compat_height);
14702
14703 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
14704 }
14705 catch (Exception e)
14706 {
14707 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
14708 }
14709 Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
14710 // -- bottom bar --
14711 }
14712
14713 last_orientation = newConfig.orientation;
14714 }
14715 }
14716
14717 static void long_toast(String msg)
14718 {
14719 try
14720 {
14721 Message msg7 = Navit_progress_h.obtainMessage();
14722 Bundle b7 = new Bundle();
14723 msg7.what = 2; // long Toast message
14724 b7.putString("text", msg);
14725 msg7.setData(b7);
14726 Navit_progress_h.sendMessage(msg7);
14727 }
14728 catch (Exception e)
14729 {
14730 }
14731 }
14732
14733 static void short_toast(String msg)
14734 {
14735 try
14736 {
14737 Message msg7 = Navit_progress_h.obtainMessage();
14738 Bundle b7 = new Bundle();
14739 msg7.what = 3; // short Toast message
14740 b7.putString("text", msg);
14741 msg7.setData(b7);
14742 Navit_progress_h.sendMessage(msg7);
14743 }
14744 catch (Exception e)
14745 {
14746 }
14747 }
14748
14749 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)
14750 {
14751 if (p.PREF_routing_engine == 1)
14752 {
14753 route_online_OSRM(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
14754 }
14755 else if (p.PREF_routing_engine == 0)
14756 {
14757 route_offline_ZANavi(addr, lat_start, lon_start, start_coords_valid, lat_end, lon_end, remember_dest);
14758 }
14759 }
14760
14761 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)
14762 {
14763 if (remember_dest)
14764 {
14765 try
14766 {
14767 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
14768 // save points
14769 write_map_points();
14770 }
14771 catch (Exception e)
14772 {
14773 e.printStackTrace();
14774 }
14775 }
14776
14777 // DEBUG: clear route rectangle list
14778 NavitGraphics.route_rects.clear();
14779
14780 if (NavitGraphics.navit_route_status == 0)
14781 {
14782 short_toast(Navit.get_text("setting destination to") + "\n" + addr);
14783
14784 Navit.destination_set();
14785
14786 Message msg = new Message();
14787 Bundle b = new Bundle();
14788 b.putInt("Callback", 3);
14789 b.putString("lat", "" + lat_end);
14790 b.putString("lon", "" + lon_end);
14791 b.putString("q", addr);
14792 msg.setData(b);
14793 NavitGraphics.callback_handler.sendMessage(msg);
14794 }
14795 else
14796 {
14797 short_toast(Navit.get_text("new Waypoint") + "\n" + addr);
14798
14799 Message msg = new Message();
14800 Bundle b = new Bundle();
14801 b.putInt("Callback", 48);
14802 b.putString("lat", "" + lat_end);
14803 b.putString("lon", "" + lon_end);
14804 b.putString("q", addr);
14805 msg.setData(b);
14806 NavitGraphics.callback_handler.sendMessage(msg);
14807 }
14808
14809 }
14810
14811 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)
14812 {
14813 // http://router.project-osrm.org/viaroute?loc=46.3456438,17.450&loc=47.34122,17.5332&instructions=false&alt=false
14814
14815 if (!start_coords_valid)
14816 {
14817 location_coords cur_target = new location_coords();
14818 try
14819 {
14820 geo_coord tmp = get_current_vehicle_position();
14821 cur_target.lat = tmp.Latitude;
14822 cur_target.lon = tmp.Longitude;
14823 }
14824 catch (Exception e)
14825 {
14826 }
14827
14828 try
14829 {
14830 lat_start = (float) cur_target.lat;
14831 lon_start = (float) cur_target.lon;
14832 }
14833 catch (Exception e)
14834 {
14835 e.printStackTrace();
14836 Log.e("Navit", "problem with location!");
14837 }
14838 }
14839
14840 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);
14841
14842 // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
14843 // StrictMode.setThreadPolicy(policy);
14844
14845 try
14846 {
14847 // System.out.println("XML:S:001 url=" + request_url);
14848 final URL url = new URL(request_url);
14849 // System.out.println("XML:S:002");
14850 // SAXParserFactory factory = SAXParserFactory.newInstance();
14851 // System.out.println("XML:S:003");
14852 // SAXParser parser = factory.newSAXParser();
14853 // System.out.println("XML:S:004");
14854 // XMLReader xmlreader = parser.getXMLReader();
14855 // System.out.println("XML:S:005");
14856 // xmlreader.setContentHandler(new ZANaviXMLHandler());
14857 // System.out.println("XML:S:006");
14858
14859 final Thread add_to_route = new Thread()
12553 { 14860 {
12554 @Override 14861 @Override
12555 protected String doInBackground(Void... params) 14862 public void run()
12556 { 14863 {
12557 try 14864 try
12558 { 14865 {
12559 // send current app version to plugin 14866
12560 Log.e("NavitPlugin", "send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version + " data=" + Navit.NavitAppVersion); 14867 // --------------
12561 String dummy_res = plugin_api.getResult(PLUGIN_MSG_ID, PLUGIN_MSG_CAT_zanavi_version, Navit.NavitAppVersion); 14868 // --------------
12562 Log.e("NavitPlugin", "send msg to plugin:result=" + dummy_res); 14869 // --------------
14870 // ------- allow this HTTPS cert ---
14871 // --------------
14872 // --------------
14873 // --------------
14874 // X509HostnameVerifier hnv = new X509HostnameVerifier()
14875 // {
14876 //
14877 // @Override
14878 // public void verify(String hostname, SSLSocket arg1) throws IOException
14879 // {
14880 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14881 // }
14882 //
14883 // @Override
14884 // public void verify(String hostname, X509Certificate cert) throws SSLException
14885 // {
14886 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14887 // }
14888 //
14889 // @Override
14890 // public void verify(String hostname, String[] cns, String[] subjectAlts) throws SSLException
14891 // {
14892 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14893 // }
14894 //
14895 // @Override
14896 // public boolean verify(String hostname, SSLSession session)
14897 // {
14898 // Log.d("SSL", "DANGER !!! trusted hostname=" + hostname + " DANGER !!!");
14899 // return true;
14900 // }
14901 // };
14902 //
14903 // SSLContext context = SSLContext.getInstance("TLS");
14904 // context.init(null, new X509TrustManager[] { new X509TrustManager()
14905 // {
14906 // public java.security.cert.X509Certificate[] getAcceptedIssuers()
14907 // {
14908 // return new java.security.cert.X509Certificate[0];
14909 // }
14910 //
14911 // @Override
14912 // public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
14913 // {
14914 // }
14915 //
14916 // @Override
14917 // public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException
14918 // {
14919 // }
14920 // } }, new SecureRandom());
14921 // javax.net.ssl.SSLSocketFactory sslf = context.getSocketFactory();
14922 //
14923 // HostnameVerifier hnv_default = HttpsURLConnection.getDefaultHostnameVerifier();
14924 // javax.net.ssl.SSLSocketFactory sslf_default = HttpsURLConnection.getDefaultSSLSocketFactory();
14925 // HttpsURLConnection.setDefaultHostnameVerifier(hnv);
14926 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf);
14927 //
14928 // DefaultHttpClient client = new DefaultHttpClient();
14929 //
14930 // SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
14931 // SchemeRegistry registry = new SchemeRegistry();
14932 // registry.register(new Scheme("https", socketFactory, 443));
14933 // ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(client.getParams(), registry);
14934 // DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
14935 //
14936 // socketFactory.setHostnameVerifier(hnv);
14937 //
14938 // HttpGet get_request = new HttpGet(request_url);
14939 // HttpResponse http_response = httpClient.execute(get_request);
14940 // HttpEntity responseEntity = http_response.getEntity();
14941 //
14942 // HttpsURLConnection.setDefaultHostnameVerifier(hnv_default);
14943 // HttpsURLConnection.setDefaultSSLSocketFactory(sslf_default);
14944 // --------------
14945 // --------------
14946 // --------------
14947 // ------- allow this HTTPS cert ---
14948 // --------------
14949 // --------------
14950 // --------------
14951
14952 InputSource is = new InputSource();
14953 is.setEncoding("utf-8");
14954 // is.setByteStream(responseEntity.getContent());
14955 is.setByteStream(url.openStream());
14956 // System.out.println("XML:S:007");
14957
14958 String response = slurp(is.getByteStream(), 16384);
14959 // response = response.replaceAll("&", "&amp;");
14960
14961 // System.out.println("XML:S:007.a res=" + response);
14962
14963 final JSONObject obj = new JSONObject(response);
14964
14965 // System.out.println(person.getInt("id"));
14966
14967 final String route_geometry = obj.getString("route_geometry");
14968 final JSONArray route_instructions_array = obj.getJSONArray("route_instructions");
14969
14970 int loop_i = 0;
14971 JSONArray instruction;
14972 int[] instruction_pos = new int[route_instructions_array.length()];
14973 for (loop_i = 0; loop_i < route_instructions_array.length(); loop_i++)
14974 {
14975 instruction = (JSONArray) route_instructions_array.get(loop_i);
14976 instruction_pos[loop_i] = Integer.parseInt(instruction.get(3).toString());
14977 // System.out.println("XML:instr. pos=" + instruction_pos[loop_i]);
14978 }
14979
14980 // System.out.println("XML:S:009 o=" + route_geometry);
14981
14982 List<geo_coord> gc_list = decode_function(route_geometry, 6);
14983
14984 if (gc_list.size() < 2)
14985 {
14986 // no real route found!! (only 1 point)
14987 }
14988 else
14989 {
14990
14991 Message msg = new Message();
14992 Bundle b = new Bundle();
14993
14994 int loop = 0;
14995
14996 geo_coord cur = new geo_coord();
14997 geo_coord old = new geo_coord();
14998 geo_coord corr = new geo_coord();
14999
15000 cur.Latitude = gc_list.get(loop).Latitude;
15001 cur.Longitude = gc_list.get(loop).Longitude;
15002
15003 int first_found = 1;
15004
15005 if (gc_list.size() > 2)
15006 {
15007 int instr_count = 1;
15008
15009 for (loop = 1; loop < gc_list.size(); loop++)
15010 {
15011
15012 old.Latitude = cur.Latitude;
15013 old.Longitude = cur.Longitude;
15014 cur.Latitude = gc_list.get(loop).Latitude;
15015 cur.Longitude = gc_list.get(loop).Longitude;
15016
15017 if ((instruction_pos[instr_count] == loop) || (loop == (gc_list.size() - 1)))
15018 {
15019
15020 if (loop == (gc_list.size() - 1))
15021 {
15022 corr = cur;
15023 }
15024 else
15025 {
15026 corr = get_point_on_line(old, cur, 70);
15027 }
15028
15029 // -- add waypoint --
15030 // b.putInt("Callback", 55548);
15031 // b.putString("lat", "" + corr.Latitude);
15032 // b.putString("lon", "" + corr.Longitude);
15033 // b.putString("q", " ");
15034 // msg.setData(b);
15035 try
15036 {
15037 // NavitGraphics.callback_handler.sendMessage(msg);
15038 if (first_found == 1)
15039 {
15040 first_found = 0;
15041 NavitGraphics.CallbackMessageChannel(55503, corr.Latitude + "#" + corr.Longitude + "#" + "");
15042 // System.out.println("XML:rR:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15043 }
15044 else
15045 {
15046 NavitGraphics.CallbackMessageChannel(55548, corr.Latitude + "#" + corr.Longitude + "#" + "");
15047 // System.out.println("XML:rw:" + loop + " " + corr.Latitude + " " + corr.Longitude);
15048 }
15049 // Thread.sleep(25);
15050 }
15051 catch (Exception e)
15052 {
15053 e.printStackTrace();
15054 }
15055 // -- add waypoint --
15056
15057 instr_count++;
15058
15059 }
15060
15061 }
15062 }
15063
15064 if (remember_dest)
15065 {
15066 try
15067 {
15068 Navit.remember_destination(addr, "" + lat_end, "" + lon_end);
15069 // save points
15070 write_map_points();
15071 }
15072 catch (Exception e)
15073 {
15074 e.printStackTrace();
15075 }
15076 }
15077
15078 b.putInt("Callback", 55599);
15079 msg.setData(b);
15080 try
15081 {
15082 // System.out.println("XML:calc:");
15083 Thread.sleep(10);
15084 NavitGraphics.callback_handler.sendMessage(msg);
15085 }
15086 catch (Exception e)
15087 {
15088 e.printStackTrace();
15089 }
15090
15091 }
15092
12563 } 15093 }
12564 catch (RemoteException e) 15094 catch (Exception e2)
12565 { 15095 {
12566 Log.e("NavitPlugin", "Failed to send msg to plugin:cat=" + PLUGIN_MSG_CAT_zanavi_version, e); 15096 e2.printStackTrace();
12567 } 15097 }
12568 return ""; 15098 }
15099 };
15100 add_to_route.start();
15101
15102 // convert to coords -------------
15103 // convert to coords -------------
15104
15105 }
15106 catch (Exception e)
15107 {
15108 // System.out.println("XML:S:EEE");
15109 e.printStackTrace();
15110 }
15111 }
15112
15113 static List<geo_coord> decode_function(String encoded, double precision)
15114 {
15115
15116 precision = Math.pow(10, -precision);
15117 int len = encoded.length();
15118 int index = 0;
15119 int lat = 0;
15120 int lng = 0;
15121 double lat_f;
15122 double lon_f;
15123
15124 final List<geo_coord> latLongList = new ArrayList<geo_coord>();
15125 latLongList.clear();
15126
15127 while (index < len)
15128 {
15129
15130 int b;
15131 int shift = 0;
15132 int result = 0;
15133
15134 do
15135 {
15136 b = encoded.charAt(index++) - 63;
15137 result |= (b & 0x1f) << shift;
15138 shift += 5;
15139
12569 } 15140 }
15141 while (b >= 0x20);
12570 15142
12571 @Override 15143 int dlat = 0;
12572 protected void onPostExecute(String msg) 15144 if ((result & 1) != 0)
15145 {
15146 dlat = ~(result >> 1);
15147 }
15148 else
15149 {
15150 dlat = (result >> 1);
15151 }
15152
15153 lat += dlat;
15154 shift = 0;
15155 result = 0;
15156
15157 do
15158 {
15159 b = encoded.charAt(index++) - 63;
15160 result |= (b & 0x1f) << shift;
15161 shift += 5;
15162 }
15163 while (b >= 0x20);
15164
15165 int dlng = 0;
15166 if ((result & 1) != 0)
15167 {
15168 dlng = ~(result >> 1);
15169 }
15170 else
15171 {
15172 dlng = (result >> 1);
15173 }
15174
15175 lng += dlng;
15176 //array.push( {lat: lat * precision, lng: lng * precision} );
15177 // array.push( [lat * precision, lng * precision] );
15178
15179 // System.out.println("XML:lat=" + (lat * precision) + " lon=" + (lng * precision));
15180
15181 lat_f = lat * precision;
15182 lon_f = lng * precision;
15183
15184 geo_coord gc = new geo_coord();
15185 gc.Latitude = lat_f;
15186 gc.Longitude = lon_f;
15187 latLongList.add(gc);
15188 }
15189
15190 return latLongList;
15191 }
15192
15193 public static class geo_coord
15194 {
15195 public double Latitude;
15196 public double Longitude;
15197 }
15198
15199 static geo_coord get_current_vehicle_position()
15200 {
15201 geo_coord ret = new geo_coord();
15202 String current_target_string2 = NavitGraphics.CallbackGeoCalc(14, 1, 1);
15203 // System.out.println("GET CUR POS:" + current_target_string2);
15204 ret.Latitude = 0;
15205 ret.Longitude = 0;
15206 try
15207 {
15208 String tmp[] = current_target_string2.split(":", 2);
15209 ret.Latitude = Double.parseDouble(tmp[0]);
15210 ret.Longitude = Double.parseDouble(tmp[1]);
15211 }
15212 catch (Exception e)
15213 {
15214 // System.out.println("GET CUR POS:ERROR " + e.getMessage());
15215 }
15216 return ret;
15217 }
15218
15219 static int[] geo_to_px(float lat, float lon)
15220 {
15221 int[] ret = new int[3];
15222
15223 ret[0] = -100;
15224 ret[1] = -100;
15225 ret[2] = 0; // invalid
15226
15227 try
15228 {
15229 String x_y = NavitGraphics.CallbackGeoCalc(2, lat, lon);
15230
15231 if (Navit.GFX_OVERSPILL)
15232 {
15233 String tmp[] = x_y.split(":", 2);
15234 int x = Integer.parseInt(tmp[0]);
15235 int y = Integer.parseInt(tmp[1]);
15236
15237 ret[0] = (int) (((float) x + (float) NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor);
15238 ret[1] = (int) (((float) y + (float) NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15239
15240 ret[2] = 1; // VALID
15241 }
15242 else
15243 {
15244 String tmp[] = x_y.split(":", 2);
15245 int x = Integer.parseInt(tmp[0]);
15246 int y = Integer.parseInt(tmp[1]);
15247
15248 ret[0] = (int) ((float) x * NavitGraphics.Global_dpi_factor);
15249 ret[1] = (int) ((float) y * NavitGraphics.Global_dpi_factor);
15250
15251 ret[2] = 1; // VALID
15252 }
15253
15254 }
15255 catch (Exception e)
15256 {
15257 }
15258
15259 return ret;
15260 }
15261
15262 static geo_coord px_to_geo(int x, int y)
15263 {
15264 geo_coord out = new geo_coord();
15265 try
15266 {
15267
15268 String lat_lon = "";
15269 if (Navit.GFX_OVERSPILL)
15270 {
15271 lat_lon = NavitGraphics.CallbackGeoCalc(1, (x + NavitGraphics.mCanvasWidth_overspill) * NavitGraphics.Global_dpi_factor, (y + NavitGraphics.mCanvasHeight_overspill) * NavitGraphics.Global_dpi_factor);
15272 }
15273 else
15274 {
15275 lat_lon = NavitGraphics.CallbackGeoCalc(1, x * NavitGraphics.Global_dpi_factor, y * NavitGraphics.Global_dpi_factor);
15276 }
15277
15278 String tmp[] = lat_lon.split(":", 2);
15279 out.Latitude = Float.parseFloat(tmp[0]);
15280 out.Longitude = Float.parseFloat(tmp[1]);
15281 }
15282 catch (Exception e)
15283 {
15284 }
15285
15286 return out;
15287 }
15288
15289 static double get_percent_coord(double start, double end, int perecent_pos)
15290 {
15291 double out = start + (end - start) * ((float) perecent_pos / 100.0f);
15292 return out;
15293 }
15294
15295 static geo_coord get_point_on_line(geo_coord start, geo_coord end, int perecent_pos)
15296 {
15297 geo_coord out = new geo_coord();
15298
15299 out.Latitude = start.Latitude + (end.Latitude - start.Latitude) * ((float) perecent_pos / 100.0f);
15300 out.Longitude = start.Longitude + (end.Longitude - start.Longitude) * ((float) perecent_pos / 100.0f);
15301
15302 return out;
15303 }
15304
15305 public static String slurp(final InputStream is, final int bufferSize)
15306 {
15307 final char[] buffer = new char[bufferSize];
15308 final StringBuilder out = new StringBuilder();
15309 Reader in = null;
15310
15311 try
15312 {
15313
15314 in = new InputStreamReader(is, "UTF-8");
15315
15316 for (;;)
15317 {
15318 int rsz;
15319 rsz = in.read(buffer, 0, buffer.length);
15320
15321 if (rsz < 0)
15322 {
15323 break;
15324 }
15325 out.append(buffer, 0, rsz);
15326 }
15327
15328 }
15329 catch (IOException e)
15330 {
15331 }
15332 catch (Exception ex)
15333 {
15334 }
15335
15336 return out.toString();
15337 }
15338
15339 public static Handler UIHandler;
15340 static
15341 {
15342 UIHandler = new Handler(Looper.getMainLooper());
15343 }
15344
15345 public static void recalculate_route()
15346 {
15347 try
15348 {
15349 // update route, if a route is set
15350 Message msg = new Message();
15351 Bundle b = new Bundle();
15352 b.putInt("Callback", 73);
15353 msg.setData(b);
15354 NavitGraphics.callback_handler.sendMessage(msg);
15355 }
15356 catch (Exception e)
15357 {
15358 }
15359 }
15360
15361 public static void runOnUI(Runnable runnable)
15362 {
15363 UIHandler.post(runnable);
15364 }
15365
15366 String substring_without_ioobe(String in, int start, int end)
15367 {
15368 String ret = ";:;:****no match****;:;:";
15369
15370 try
15371 {
15372 ret = in.substring(start, end);
15373 }
15374 catch (Exception e)
15375 {
15376 // return dummy-no-match String
15377 }
15378
15379 return ret;
15380 }
15381
15382 static private int get_reglevel()
15383 {
15384 int ret = 0;
15385
15386 try
15387 {
15388 Uri uri = CR_CONTENT_URI;
15389 Cursor c = content_resolver.query(uri, null, null, null, null);
15390
15391 if (c == null)
15392 {
15393 System.out.println("CPVD:Cursor c == null.");
15394 System.out.println("CPVD:reg(0)=" + ret);
15395 return ret;
15396 }
15397
15398 while (c.moveToNext())
15399 {
15400 String column1 = c.getString(0);
15401 String column2 = c.getString(1);
15402 String column3 = c.getString(2);
15403
15404 System.out.println("CPVD:column1=" + column1 + " column2=" + column2 + " column3=" + column3);
15405
15406 if (Integer.parseInt(column1) == 1)
15407 {
15408 if (column2.equals("reg"))
12573 { 15409 {
12574 15410 ret = Integer.parseInt(column3);
15411 System.out.println("CPVD:reg(1)=" + ret);
12575 } 15412 }
12576 }.execute(null, null, null); 15413 }
12577 // send data to plugin (plugin will send to server) in another task! --------------------------
12578
12579 } 15414 }
15415 c.close();
15416 }
15417 catch (Exception e)
15418 {
15419 e.printStackTrace();
15420 }
12580 15421
12581 @Override 15422 System.out.println("CPVD:reg(2)=" + ret);
12582 public void onServiceDisconnected(ComponentName name) 15423 return ret;
15424 }
15425
15426 static void take_map_screenshot(String dir_name, String name_base)
15427 {
15428 try
15429 {
15430 View v1 = Navit.N_NavitGraphics.view;
15431 v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
15432 v1.setDrawingCacheEnabled(true);
15433 Bitmap bm = v1.getDrawingCache();
15434
15435 FileOutputStream out = null;
15436 try
12583 { 15437 {
12584 plugin_api = null; 15438 out = new FileOutputStream(dir_name + "/" + name_base + ".png");
12585 Log.i("NavitPlugin", "Service connection closed"); 15439 bm.compress(Bitmap.CompressFormat.PNG, 100, out);
12586 } 15440 }
15441 catch (Exception e)
15442 {
15443 e.printStackTrace();
15444 System.out.println("TSCR:004 " + e.getMessage());
15445 }
15446 finally
15447 {
15448 v1.setDrawingCacheEnabled(false);
15449
15450 try
15451 {
15452 if (out != null)
15453 {
15454 out.close();
15455 }
15456 }
15457 catch (IOException e)
15458 {
15459 e.printStackTrace();
15460 }
15461 }
15462 }
15463 catch (Exception e4)
15464 {
15465 }
12587 }; 15466 }
12588} 15467}

Legend:
Removed from v.40  
changed lines
  Added in v.41

   
Visit the ZANavi Wiki