1 |
/**
|
2 |
* ZANavi, Zoff Android Navigation system.
|
3 |
* Copyright (C) 2011-2012 Zoff <zoff@zoff.cc>
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* version 2 as published by the Free Software Foundation.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the
|
16 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17 |
* Boston, MA 02110-1301, USA.
|
18 |
*/
|
19 |
|
20 |
/**
|
21 |
* Navit, a modular navigation system.
|
22 |
* Copyright (C) 2005-2008 Navit Team
|
23 |
*
|
24 |
* This program is free software; you can redistribute it and/or
|
25 |
* modify it under the terms of the GNU General Public License
|
26 |
* version 2 as published by the Free Software Foundation.
|
27 |
*
|
28 |
* This program is distributed in the hope that it will be useful,
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
31 |
* GNU General Public License for more details.
|
32 |
*
|
33 |
* You should have received a copy of the GNU General Public License
|
34 |
* along with this program; if not, write to the
|
35 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
36 |
* Boston, MA 02110-1301, USA.
|
37 |
*/
|
38 |
|
39 |
package com.zoffcc.applications.zanavi;
|
40 |
|
41 |
import java.io.File;
|
42 |
import java.io.FileInputStream;
|
43 |
import java.io.FileNotFoundException;
|
44 |
import java.io.FileOutputStream;
|
45 |
import java.io.IOException;
|
46 |
import java.io.InputStream;
|
47 |
import java.io.ObjectInputStream;
|
48 |
import java.io.ObjectOutputStream;
|
49 |
import java.io.OutputStream;
|
50 |
import java.io.OutputStreamWriter;
|
51 |
import java.io.Serializable;
|
52 |
import java.net.URLDecoder;
|
53 |
import java.nio.channels.FileChannel;
|
54 |
import java.util.ArrayList;
|
55 |
import java.util.Calendar;
|
56 |
import java.util.Collections;
|
57 |
import java.util.Date;
|
58 |
import java.util.HashSet;
|
59 |
import java.util.List;
|
60 |
import java.util.Locale;
|
61 |
import java.util.Random;
|
62 |
import java.util.Set;
|
63 |
import java.util.TimeZone;
|
64 |
import java.util.concurrent.LinkedBlockingQueue;
|
65 |
|
66 |
import android.app.Activity;
|
67 |
import android.app.AlertDialog;
|
68 |
import android.app.Dialog;
|
69 |
import android.app.ProgressDialog;
|
70 |
import android.content.Context;
|
71 |
import android.content.DialogInterface;
|
72 |
import android.content.DialogInterface.OnCancelListener;
|
73 |
import android.content.Intent;
|
74 |
import android.content.SharedPreferences;
|
75 |
import android.content.pm.PackageInfo;
|
76 |
import android.content.pm.PackageManager.NameNotFoundException;
|
77 |
import android.content.res.Configuration;
|
78 |
import android.content.res.Resources;
|
79 |
import android.graphics.Bitmap;
|
80 |
import android.graphics.BitmapFactory;
|
81 |
import android.graphics.Color;
|
82 |
import android.graphics.Typeface;
|
83 |
import android.hardware.Sensor;
|
84 |
import android.hardware.SensorEvent;
|
85 |
import android.hardware.SensorEventListener;
|
86 |
import android.hardware.SensorManager;
|
87 |
import android.location.Address;
|
88 |
import android.location.Geocoder;
|
89 |
import android.location.GpsStatus;
|
90 |
import android.location.Location;
|
91 |
import android.location.LocationManager;
|
92 |
import android.media.AudioManager;
|
93 |
import android.net.Uri;
|
94 |
import android.os.Bundle;
|
95 |
import android.os.Debug;
|
96 |
import android.os.Environment;
|
97 |
import android.os.Handler;
|
98 |
import android.os.Message;
|
99 |
import android.os.PowerManager;
|
100 |
import android.os.SystemClock;
|
101 |
import android.preference.PreferenceManager;
|
102 |
import android.text.SpannableString;
|
103 |
import android.text.method.LinkMovementMethod;
|
104 |
import android.text.util.Linkify;
|
105 |
import android.util.DisplayMetrics;
|
106 |
import android.util.Log;
|
107 |
import android.util.TypedValue;
|
108 |
import android.view.Display;
|
109 |
import android.view.Gravity;
|
110 |
import android.view.Menu;
|
111 |
import android.view.MenuItem;
|
112 |
import android.view.View;
|
113 |
import android.view.Window;
|
114 |
import android.view.WindowManager;
|
115 |
import android.view.inputmethod.InputMethodManager;
|
116 |
import android.widget.RelativeLayout;
|
117 |
import android.widget.TextView;
|
118 |
import android.widget.Toast;
|
119 |
import bpi.sdbm.illuminance.SolarPosition;
|
120 |
|
121 |
import com.lamerman.FileDialog;
|
122 |
import com.lamerman.SelectionMode;
|
123 |
import com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator;
|
124 |
import com.luckycatlabs.sunrisesunset.calculator.SolarEventCalculator;
|
125 |
import com.luckycatlabs.sunrisesunset.dto.Location2;
|
126 |
import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
|
127 |
|
128 |
import de.oberoner.gpx2navit_txt.MainFrame;
|
129 |
|
130 |
public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
131 |
{
|
132 |
public static final String VERSION_TEXT_LONG_INC_REV = "762";
|
133 |
public static String NavitAppVersion = "0";
|
134 |
public static String NavitAppVersion_prev = "-1";
|
135 |
public static String NavitAppVersion_string = "0";
|
136 |
public final Boolean NAVIT_IS_EMULATOR = false; // when running on emulator set to true!!
|
137 |
|
138 |
public static int Global_Init_Finished = 0; // 0 -> no init
|
139 |
// 1 -> all C structures are ready for use
|
140 |
|
141 |
// define graphics here (this is bad, please fix me!)
|
142 |
public static NavitGraphics N_NavitGraphics = null;
|
143 |
|
144 |
public static int usedMegs_old = -1;
|
145 |
public static int Routgraph_enabled = 0;
|
146 |
|
147 |
// -------- SUN / MOON ----------
|
148 |
long sun_moon__mLastCalcSunMillis = -1L;
|
149 |
public double azmiuth_cache = -1;
|
150 |
public double zenith_cache = -1;
|
151 |
public static String sunrise_cache = "";
|
152 |
public static boolean is_night = false;
|
153 |
public static boolean is_twilight = false;
|
154 |
public static String sunset_cache = "";
|
155 |
public static double elevation = 0;
|
156 |
public double moon_azimuth_cache = -1;
|
157 |
public double moon_evelation_cache = -1;
|
158 |
Boolean sun_moon__must_calc_new = true;
|
159 |
SunriseSunsetCalculator sun_moon__calc = null;
|
160 |
Calendar sun_moon__cx = null;
|
161 |
SolarPosition.SunCoordinates sun_moon__sc = null;
|
162 |
public static boolean calc_sun_enabled = true;
|
163 |
// -------- SUN / MOON ----------
|
164 |
|
165 |
public static CWorkerThread cwthr = null;
|
166 |
public static NavitGraphics NG__map_main = null;
|
167 |
public static NavitGraphics NG__vehicle = null;
|
168 |
public static NavitVehicle NV = null;
|
169 |
public static NavitSpeech2 NSp = null;
|
170 |
|
171 |
public static boolean use_index_search = false;
|
172 |
|
173 |
static AlertDialog.Builder generic_alert_box = null;
|
174 |
|
175 |
private Boolean xmlconfig_unpack_file = true;
|
176 |
private Boolean write_new_version_file = true;
|
177 |
final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
|
178 |
final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
|
179 |
final static int Navit_Status_NORMAL_STARTUP = 0;
|
180 |
static Boolean Navit_DonateVersion_Installed = false;
|
181 |
static Boolean Navit_Largemap_DonateVersion_Installed = false;
|
182 |
private int startup_status = Navit_Status_NORMAL_STARTUP;
|
183 |
final static int Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL = 8;
|
184 |
static Boolean unsupported = false;
|
185 |
static Boolean Navit_maps_loaded = false;
|
186 |
final static int Navit_MAX_RECENT_DESTINATIONS = 50;
|
187 |
static String debug_item_dump = "";
|
188 |
|
189 |
// for future use ...
|
190 |
// public static String NavitDataDirectory = "/sdcard/";
|
191 |
public static String NavitDataDirectory_Maps = "/sdcard/zanavi/maps/";
|
192 |
|
193 |
public static int GlobalScaleLevel = 0;
|
194 |
|
195 |
public class CopyFiles
|
196 |
{
|
197 |
public void copyFiles(File sourceLocation, File targetLocation) throws IOException
|
198 |
{
|
199 |
if (sourceLocation.isDirectory())
|
200 |
{
|
201 |
if (!targetLocation.exists())
|
202 |
{
|
203 |
targetLocation.mkdir();
|
204 |
}
|
205 |
File[] files = sourceLocation.listFiles();
|
206 |
for (File file : files)
|
207 |
{
|
208 |
InputStream in = new FileInputStream(file);
|
209 |
OutputStream out = new FileOutputStream(targetLocation + "/" + file.getName());
|
210 |
|
211 |
// Copy the bits from input stream to output stream
|
212 |
byte[] buf = new byte[1024];
|
213 |
int len;
|
214 |
while ((len = in.read(buf)) > 0)
|
215 |
{
|
216 |
out.write(buf, 0, len);
|
217 |
}
|
218 |
in.close();
|
219 |
out.close();
|
220 |
}
|
221 |
}
|
222 |
}
|
223 |
}
|
224 |
|
225 |
private static void copyFile(File sourceFile, File destFile) throws IOException
|
226 |
{
|
227 |
if (!sourceFile.exists())
|
228 |
{
|
229 |
return;
|
230 |
}
|
231 |
if (!destFile.exists())
|
232 |
{
|
233 |
destFile.createNewFile();
|
234 |
}
|
235 |
FileChannel source = null;
|
236 |
FileChannel destination = null;
|
237 |
source = new FileInputStream(sourceFile).getChannel();
|
238 |
destination = new FileOutputStream(destFile).getChannel();
|
239 |
if (destination != null && source != null)
|
240 |
{
|
241 |
destination.transferFrom(source, 0, source.size());
|
242 |
}
|
243 |
if (source != null)
|
244 |
{
|
245 |
source.close();
|
246 |
}
|
247 |
if (destination != null)
|
248 |
{
|
249 |
destination.close();
|
250 |
}
|
251 |
|
252 |
}
|
253 |
|
254 |
public static final class Navit_Address_Result_Struct implements Comparable<Navit_Address_Result_Struct>
|
255 |
{
|
256 |
String result_type; // TWN,STR,SHN
|
257 |
String item_id; // H<ddddd>L<ddddd> -> item.id_hi item.id_lo
|
258 |
float lat;
|
259 |
float lon;
|
260 |
String addr;
|
261 |
|
262 |
// function to sort address result list
|
263 |
public int compareTo(Navit_Address_Result_Struct comp)
|
264 |
{
|
265 |
return this.addr.toLowerCase().compareTo(comp.addr.toLowerCase());
|
266 |
}
|
267 |
}
|
268 |
|
269 |
public static final class Navit_Point_on_Map implements Serializable
|
270 |
{
|
271 |
/**
|
272 |
* struct for a point on the map
|
273 |
*/
|
274 |
private static final long serialVersionUID = 6899215049749155051L;
|
275 |
String point_name = "";
|
276 |
String addon = null;
|
277 |
float lat = 0.0f;
|
278 |
float lon = 0.0f;
|
279 |
}
|
280 |
|
281 |
static ArrayList<Navit_Point_on_Map> map_points;
|
282 |
|
283 |
public static Set<String> Navit_Address_Result_double_index = new HashSet<String>();
|
284 |
|
285 |
public NavitAndroidOverlay NavitAOverlay2;
|
286 |
public static NavitAndroidOverlay NavitAOverlay2_s;
|
287 |
|
288 |
public static final class Navit_OSD_compass
|
289 |
{
|
290 |
Boolean angle_north_valid = false;
|
291 |
float angle_north = 0.0f;
|
292 |
Boolean angle_target_valid = false;
|
293 |
float angle_target = 0.0f;
|
294 |
Boolean direct_distance_to_target_valid = false;
|
295 |
String direct_distance_to_target = "";
|
296 |
}
|
297 |
|
298 |
public static final class Navit_OSD_route_001
|
299 |
{
|
300 |
Boolean driving_distance_to_target_valid = false;
|
301 |
String driving_distance_to_target = "";
|
302 |
Boolean arriving_time_valid = false;
|
303 |
String arriving_time = "";
|
304 |
}
|
305 |
|
306 |
public static final class Navit_OSD_route_nextturn
|
307 |
{
|
308 |
Boolean nextturn_image_filename_valid = false;
|
309 |
String nextturn_image_filename = "";
|
310 |
Boolean nextturn_image_valid = false;
|
311 |
Bitmap nextturn_image = null;
|
312 |
Boolean nextturn_distance_valid = false;
|
313 |
String nextturn_distance = "";
|
314 |
String nextturn_streetname = "";
|
315 |
String nextturn_streetname_systematic = "";
|
316 |
}
|
317 |
|
318 |
public static final class Navit_OSD_scale
|
319 |
{
|
320 |
Boolean scale_valid = false;
|
321 |
String scale_text = "";
|
322 |
int base = 0;
|
323 |
int var = 0;
|
324 |
}
|
325 |
|
326 |
public static Navit_OSD_compass OSD_compass = new Navit_OSD_compass();
|
327 |
public static Navit_OSD_route_001 OSD_route_001 = new Navit_OSD_route_001();
|
328 |
public static Navit_OSD_route_nextturn OSD_nextturn = new Navit_OSD_route_nextturn();
|
329 |
public static Navit_OSD_scale OSD_scale = new Navit_OSD_scale();
|
330 |
|
331 |
SimGPS Simulate = null;
|
332 |
WatchMem watchmem = null;
|
333 |
|
334 |
public static int sats = 0;
|
335 |
public static int satsInFix = 0;
|
336 |
|
337 |
// public static Vibrator vibrator = null;
|
338 |
|
339 |
public Handler handler;
|
340 |
private PowerManager.WakeLock wl;
|
341 |
private NavitActivityResult ActivityResults[];
|
342 |
public static InputMethodManager mgr = null;
|
343 |
public static DisplayMetrics metrics = null;
|
344 |
public static Boolean show_soft_keyboard = false;
|
345 |
public static Boolean show_soft_keyboard_now_showing = false;
|
346 |
public static long last_pressed_menu_key = 0L;
|
347 |
public static long time_pressed_menu_key = 0L;
|
348 |
private static Intent startup_intent = null;
|
349 |
private static long startup_intent_timestamp = 0L;
|
350 |
public static String my_display_density = "mdpi";
|
351 |
private boolean searchBoxShown = false;
|
352 |
public static final int MAPDOWNLOAD_PRI_DIALOG = 1;
|
353 |
public static final int MAPDOWNLOAD_SEC_DIALOG = 2;
|
354 |
public static final int SEARCHRESULTS_WAIT_DIALOG = 3;
|
355 |
public static final int SEARCHRESULTS_WAIT_DIALOG_OFFLINE = 4;
|
356 |
public static final int ADDRESS_RESULTS_DIALOG_MAX = 10;
|
357 |
public ProgressDialog mapdownloader_dialog_pri = null;
|
358 |
public ProgressDialog mapdownloader_dialog_sec = null;
|
359 |
public ProgressDialog search_results_wait = null;
|
360 |
public ProgressDialog search_results_wait_offline = null;
|
361 |
public static Handler Navit_progress_h = null;
|
362 |
public static NavitMapDownloader mapdownloader_pri = null;
|
363 |
public static NavitMapDownloader mapdownloader_sec = null;
|
364 |
public static final int NavitDownloaderPriSelectMap_id = 967;
|
365 |
public static final int NavitDownloaderSecSelectMap_id = 968;
|
366 |
public static final int NavitDeleteSecSelectMap_id = 969;
|
367 |
public static final int NavitRecentDest_id = 970;
|
368 |
public static final int NavitGeoCoordEnter_id = 971;
|
369 |
public static final int NavitGPXConvChooser_id = 972;
|
370 |
public static int download_map_id = 0;
|
371 |
ProgressThread progressThread_pri = null;
|
372 |
ProgressThread progressThread_sec = null;
|
373 |
public static int search_results_towns = 0;
|
374 |
public static int search_results_streets = 0;
|
375 |
public static int search_results_streets_hn = 0;
|
376 |
public static Boolean search_hide_duplicates = false;
|
377 |
public static Boolean NavitStartupAlreadySearching = false;
|
378 |
SearchResultsThread searchresultsThread = null;
|
379 |
SearchResultsThread searchresultsThread_offline = null;
|
380 |
SearchResultsThreadSpinnerThread spinner_thread = null;
|
381 |
SearchResultsThreadSpinnerThread spinner_thread_offline = null;
|
382 |
public static Boolean NavitAddressSearchSpinnerActive = false;
|
383 |
public static final int MAP_NUM_PRIMARY = 11;
|
384 |
public static final int NavitAddressSearch_id_offline = 70;
|
385 |
public static final int NavitAddressSearch_id_online = 73;
|
386 |
public static final int NavitAddressResultList_id = 71;
|
387 |
public static final int NavitAddressSearchCountry_id = 74;
|
388 |
public static final int NavitMapPreview_id = 75;
|
389 |
public static final int NavitAddressSearch_id_gmaps = 76;
|
390 |
public static int NavitSearchresultBarIndex = -1;
|
391 |
public static String NavitSearchresultBar_title = "";
|
392 |
public static String NavitSearchresultBar_text = "";
|
393 |
public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();
|
394 |
|
395 |
public static Boolean DemoVehicle = false;
|
396 |
|
397 |
static Typeface NavitStreetnameFont = null;
|
398 |
|
399 |
public SensorManager sensorManager = null;
|
400 |
//private static SensorManager sensorManager_ = null;
|
401 |
|
402 |
public static Context getBaseContext_ = null;
|
403 |
public static GpsStatus gps_st = null;
|
404 |
|
405 |
public static Bitmap follow_on = null;
|
406 |
public static Bitmap follow_off = null;
|
407 |
public static Bitmap follow_current = null;
|
408 |
public static Bitmap zoomin = null;
|
409 |
public static Bitmap zoomout = null;
|
410 |
public static Bitmap bigmap_bitmap = null;
|
411 |
public static Bitmap oneway_arrow = null;
|
412 |
public static Bitmap nav_arrow_stopped = null;
|
413 |
public static Bitmap nav_arrow_moving = null;
|
414 |
public static Bitmap nav_arrow_moving_shadow = null;
|
415 |
|
416 |
public static String Navit_last_address_search_string = "";
|
417 |
public static String Navit_last_address_hn_string = "";
|
418 |
public static Boolean Navit_last_address_full_file_search = false;
|
419 |
public static String Navit_last_address_search_country_iso2_string = "";
|
420 |
public static int Navit_last_address_search_country_flags = 3;
|
421 |
public static int Navit_last_address_search_country_id = 0;
|
422 |
public static Boolean Navit_last_address_partial_match = false;
|
423 |
public static Geocoder Navit_Geocoder = null;
|
424 |
public static String UserAgentString = null;
|
425 |
public static String UserAgentString_bind = null;
|
426 |
public static Boolean first_ever_startup = false;
|
427 |
|
428 |
public static Boolean Navit_Announcer = true;
|
429 |
|
430 |
public static final int MAP_NUM_SECONDARY = 12;
|
431 |
static String MAP_FILENAME_PATH = "/sdcard/zanavi/maps/";
|
432 |
static String MAPMD5_FILENAME_PATH = "/sdcard/zanavi/md5/";
|
433 |
static String CFG_FILENAME_PATH = "/sdcard/zanavi/";
|
434 |
static final String NAVIT_DATA_DIR = "/data/data/com.zoffcc.applications.zanavi";
|
435 |
static final String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
|
436 |
static final String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
|
437 |
static final String VERSION_FILE = NAVIT_DATA_SHARE_DIR + "/version.txt";
|
438 |
static final String Navit_DEST_FILENAME = "destinations.dat";
|
439 |
|
440 |
static boolean PREF_use_fast_provider;
|
441 |
static boolean PREF_follow_gps;
|
442 |
static boolean PREF_use_compass_heading_base;
|
443 |
static boolean PREF_use_compass_heading_always;
|
444 |
static boolean PREF_allow_gui_internal;
|
445 |
static boolean PREF_show_vehicle_in_center;
|
446 |
static boolean PREF_use_imperial;
|
447 |
static boolean PREF_use_compass_heading_fast;
|
448 |
static boolean PREF_use_anti_aliasing;
|
449 |
static boolean PREF_use_map_filtering;
|
450 |
static boolean PREF_gui_oneway_arrows;
|
451 |
static boolean PREF_show_debug_messages;
|
452 |
static boolean PREF_show_3d_map = false;
|
453 |
static boolean PREF_use_lock_on_roads;
|
454 |
static boolean PREF_use_route_highways;
|
455 |
static boolean PREF_save_zoomlevel;
|
456 |
static boolean PREF_show_sat_status;
|
457 |
static boolean PREF_use_agps;
|
458 |
static boolean PREF_enable_debug_functions;
|
459 |
static boolean PREF_speak_street_names;
|
460 |
static int PREF_search_country = 1; // default=*ALL*
|
461 |
static int PREF_zoomlevel_num = 2 * 2 * 2 * 2 * 2;
|
462 |
static boolean PREF_use_custom_font = true;
|
463 |
static int PREF_map_font_size = 2; // 1 -> small, 2 -> normal, 3 -> large, 4-> extra large, 4-> mega large
|
464 |
static int PREF_cancel_map_drawing_timeout = 1; // 0 -> short, 1-> normal, 2-> long, 3-> almost unlimited
|
465 |
static boolean PREF_draw_polyline_circles = true; // true -> yes (default) false -> no
|
466 |
static int PREF_mapcache = 10 * 1024; // in kbytes
|
467 |
static String PREF_navit_lang;
|
468 |
static int PREF_drawatorder = 1;
|
469 |
static String PREF_streetsearch_r = "1"; // street search radius factor (multiplier)
|
470 |
static String PREF_route_style = "1"; // 1 -> under green 2 -> on top blue
|
471 |
static String PREF_trafficlights_delay = "0"; // 0 -> dont calc traffic lights delay
|
472 |
static boolean PREF_item_dump = false;
|
473 |
static boolean PREF_use_smooth_drawing = true;
|
474 |
static boolean PREF_show_route_rects = false;
|
475 |
static int PREF_more_map_detail = 0; // 0 -> *normal* , higher values show more detail (and use a lot more CPU!!)
|
476 |
static boolean PREF_show_multipolygons = true;
|
477 |
static boolean PREF_use_index_search = true;
|
478 |
|
479 |
static Resources res_ = null;
|
480 |
|
481 |
public static String get_text(String in)
|
482 |
{
|
483 |
return NavitTextTranslations.get_text(in);
|
484 |
}
|
485 |
|
486 |
private boolean extractRes(String resname, String result)
|
487 |
{
|
488 |
int slash = -1;
|
489 |
boolean needs_update = false;
|
490 |
File resultfile;
|
491 |
Resources res = getResources();
|
492 |
Log.e("Navit", "Res Name " + resname);
|
493 |
Log.e("Navit", "result " + result);
|
494 |
int id = res.getIdentifier(resname, "raw", "com.zoffcc.applications.zanavi");
|
495 |
Log.e("Navit", "Res ID " + id);
|
496 |
|
497 |
if (id == 0)
|
498 |
{
|
499 |
return false;
|
500 |
}
|
501 |
|
502 |
while ((slash = result.indexOf("/", slash + 1)) != -1)
|
503 |
{
|
504 |
if (slash != 0)
|
505 |
{
|
506 |
Log.e("Navit", "Checking " + result.substring(0, slash));
|
507 |
resultfile = new File(result.substring(0, slash));
|
508 |
if (!resultfile.exists())
|
509 |
{
|
510 |
Log.e("Navit", "Creating dir");
|
511 |
if (!resultfile.mkdir()) return false;
|
512 |
needs_update = true;
|
513 |
}
|
514 |
}
|
515 |
}
|
516 |
|
517 |
resultfile = new File(result);
|
518 |
|
519 |
if (!resultfile.exists())
|
520 |
{
|
521 |
needs_update = true;
|
522 |
}
|
523 |
|
524 |
if (!needs_update)
|
525 |
{
|
526 |
try
|
527 |
{
|
528 |
InputStream resourcestream = res.openRawResource(id);
|
529 |
FileInputStream resultfilestream = new FileInputStream(resultfile);
|
530 |
byte[] resourcebuf = new byte[1024];
|
531 |
byte[] resultbuf = new byte[1024];
|
532 |
int i = 0;
|
533 |
while ((i = resourcestream.read(resourcebuf)) != -1)
|
534 |
{
|
535 |
if (resultfilestream.read(resultbuf) != i)
|
536 |
{
|
537 |
Log.e("Navit", "Result is too short");
|
538 |
needs_update = true;
|
539 |
break;
|
540 |
}
|
541 |
for (int j = 0; j < i; j++)
|
542 |
{
|
543 |
if (resourcebuf[j] != resultbuf[j])
|
544 |
{
|
545 |
Log.e("Navit", "Result is different");
|
546 |
needs_update = true;
|
547 |
break;
|
548 |
}
|
549 |
}
|
550 |
if (needs_update) break;
|
551 |
}
|
552 |
if (!needs_update && resultfilestream.read(resultbuf) != -1)
|
553 |
{
|
554 |
Log.e("Navit", "Result is too long");
|
555 |
needs_update = true;
|
556 |
}
|
557 |
|
558 |
}
|
559 |
catch (Exception e)
|
560 |
{
|
561 |
Log.e("Navit", "Exception " + e.getMessage());
|
562 |
return false;
|
563 |
}
|
564 |
}
|
565 |
|
566 |
if (needs_update)
|
567 |
{
|
568 |
Log.e("Navit", "Extracting resource");
|
569 |
try
|
570 |
{
|
571 |
InputStream resourcestream = res.openRawResource(id);
|
572 |
FileOutputStream resultfilestream = new FileOutputStream(resultfile);
|
573 |
byte[] buf = new byte[1024];
|
574 |
int i = 0;
|
575 |
while ((i = resourcestream.read(buf)) != -1)
|
576 |
{
|
577 |
resultfilestream.write(buf, 0, i);
|
578 |
}
|
579 |
}
|
580 |
catch (Exception e)
|
581 |
{
|
582 |
Log.e("Navit", "Exception " + e.getMessage());
|
583 |
return false;
|
584 |
}
|
585 |
}
|
586 |
return true;
|
587 |
}
|
588 |
|
589 |
/** Called when the activity is first created. */
|
590 |
@Override
|
591 |
public void onCreate(Bundle savedInstanceState)
|
592 |
{
|
593 |
|
594 |
// ------- only after API level 9 -------
|
595 |
// if (DEVELOPER_MODE)
|
596 |
// {
|
597 |
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll()
|
598 |
// // or .detectAll() for all detectable problems
|
599 |
// .penaltyLog().build());
|
600 |
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
|
601 |
// }
|
602 |
|
603 |
super.onCreate(savedInstanceState);
|
604 |
|
605 |
getBaseContext_ = getBaseContext();
|
606 |
|
607 |
System.out.println("Navit:onCreate:JTHREAD ID=" + Thread.currentThread().getId());
|
608 |
System.out.println("Navit:onCreate:THREAD ID=" + NavitGraphics.GetThreadId());
|
609 |
|
610 |
// paint for bitmapdrawing on map
|
611 |
NavitGraphics.paint_for_map_display.setAntiAlias(true);
|
612 |
NavitGraphics.paint_for_map_display.setFilterBitmap(true);
|
613 |
|
614 |
// sky
|
615 |
NavitGraphics.paint_sky_day.setAntiAlias(true);
|
616 |
NavitGraphics.paint_sky_day.setColor(Color.parseColor("#79BAEC"));
|
617 |
NavitGraphics.paint_sky_night.setAntiAlias(true);
|
618 |
NavitGraphics.paint_sky_night.setColor(Color.parseColor("#090909"));
|
619 |
// stars
|
620 |
NavitGraphics.paint_sky_night_stars.setColor(Color.parseColor("#DEDDEF"));
|
621 |
// twilight
|
622 |
NavitGraphics.paint_sky_twilight1.setColor(Color.parseColor("#090909"));
|
623 |
NavitGraphics.paint_sky_twilight2.setColor(Color.parseColor("#113268"));
|
624 |
NavitGraphics.paint_sky_twilight3.setColor(Color.parseColor("#79BAEC"));
|
625 |
|
626 |
Random m = new Random();
|
627 |
int i6 = 0;
|
628 |
for (i6 = 0; i6 < (NavitGraphics.max_stars + 1); i6++)
|
629 |
{
|
630 |
NavitGraphics.stars_x[i6] = m.nextFloat();
|
631 |
NavitGraphics.stars_y[i6] = m.nextFloat();
|
632 |
NavitGraphics.stars_size[i6] = m.nextInt(3) + 1;
|
633 |
}
|
634 |
|
635 |
res_ = getResources();
|
636 |
int ii = 0;
|
637 |
NavitGraphics.dl_thread_cur = 0;
|
638 |
for (ii = 0; ii < NavitGraphics.dl_thread_max; ii++)
|
639 |
{
|
640 |
NavitGraphics.dl_thread[ii] = null;
|
641 |
}
|
642 |
|
643 |
String font_file_name = "Roboto-Regular.ttf"; // "LiberationSans-Regular.ttf";
|
644 |
NavitStreetnameFont = Typeface.createFromAsset(getBaseContext().getAssets(), font_file_name);
|
645 |
// System.out.println("NavitStreetnameFont" + NavitStreetnameFont);
|
646 |
|
647 |
Navit_maps_loaded = false;
|
648 |
|
649 |
// only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
|
650 |
Navit.startup_intent = this.getIntent();
|
651 |
// hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
652 |
Navit.startup_intent_timestamp = System.currentTimeMillis();
|
653 |
Log.e("Navit", "**1**A " + startup_intent.getAction());
|
654 |
Log.e("Navit", "**1**D " + startup_intent.getDataString());
|
655 |
|
656 |
startup_status = Navit_Status_NORMAL_STARTUP;
|
657 |
|
658 |
// init translated text
|
659 |
NavitTextTranslations.init();
|
660 |
|
661 |
// set the new locale here -----------------------------------
|
662 |
getPrefs_loc();
|
663 |
activatePrefs_loc();
|
664 |
// set the new locale here -----------------------------------
|
665 |
|
666 |
// set map cache size here -----------------------------------
|
667 |
getPrefs_mapcache();
|
668 |
activatePrefs_mapcache();
|
669 |
// set map cache size here -----------------------------------
|
670 |
|
671 |
// get map data dir and set it -----------------------------
|
672 |
getPrefs_mapdir();
|
673 |
activatePrefs_mapdir(true);
|
674 |
// get map data dir and set it -----------------------------
|
675 |
|
676 |
// make sure the new path for the navitmap.bin file(s) exist!!
|
677 |
File navit_maps_dir = new File(MAP_FILENAME_PATH);
|
678 |
navit_maps_dir.mkdirs();
|
679 |
// create nomedia files
|
680 |
File nomedia_file = new File(MAP_FILENAME_PATH + ".nomedia");
|
681 |
try
|
682 |
{
|
683 |
nomedia_file.createNewFile();
|
684 |
}
|
685 |
catch (IOException e1)
|
686 |
{
|
687 |
e1.printStackTrace();
|
688 |
}
|
689 |
// create nomedia files
|
690 |
|
691 |
// check if we already have a borders.bin file (if not, then extract the included simplified one)
|
692 |
File b_ = new File(MAP_FILENAME_PATH + "/borders.bin");
|
693 |
try
|
694 |
{
|
695 |
if (!b_.exists())
|
696 |
{
|
697 |
try
|
698 |
{
|
699 |
File c_ = new File(MAPMD5_FILENAME_PATH + "/borders.bin.md5");
|
700 |
c_.delete();
|
701 |
}
|
702 |
catch (Exception e2)
|
703 |
{
|
704 |
|
705 |
}
|
706 |
Log.e("Navit", "trying to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
|
707 |
if (!extractRes("borders_simple", MAP_FILENAME_PATH + "/borders.bin"))
|
708 |
{
|
709 |
Log.e("Navit", "Failed to extract borders simple resource to:" + MAP_FILENAME_PATH + "/borders.bin");
|
710 |
}
|
711 |
}
|
712 |
}
|
713 |
catch (Exception e)
|
714 |
{
|
715 |
|
716 |
}
|
717 |
// check if we already have a borders.bin file
|
718 |
|
719 |
// get the local language -------------
|
720 |
Locale locale = java.util.Locale.getDefault();
|
721 |
String lang = locale.getLanguage();
|
722 |
String langu = lang;
|
723 |
String langc = lang;
|
724 |
Log.e("Navit", "lang=" + lang);
|
725 |
int pos = langu.indexOf('_');
|
726 |
if (pos != -1)
|
727 |
{
|
728 |
langc = langu.substring(0, pos);
|
729 |
langu = langc + langu.substring(pos).toUpperCase(locale);
|
730 |
Log.e("Navit", "substring lang " + langu.substring(pos).toUpperCase(locale));
|
731 |
// set lang. for translation
|
732 |
NavitTextTranslations.main_language = langc;
|
733 |
NavitTextTranslations.sub_language = langu.substring(pos).toUpperCase(locale);
|
734 |
}
|
735 |
else
|
736 |
{
|
737 |
String country = locale.getCountry();
|
738 |
Log.e("Navit", "Country1 " + country);
|
739 |
Log.e("Navit", "Country2 " + country.toUpperCase(locale));
|
740 |
langu = langc + "_" + country.toUpperCase(locale);
|
741 |
// set lang. for translation
|
742 |
NavitTextTranslations.main_language = langc;
|
743 |
NavitTextTranslations.sub_language = country.toUpperCase(locale);
|
744 |
}
|
745 |
Log.e("Navit", "Language " + lang);
|
746 |
// get the local language -------------
|
747 |
|
748 |
// make sure the new path for config files exist
|
749 |
File navit_cfg_dir = new File(CFG_FILENAME_PATH);
|
750 |
navit_cfg_dir.mkdirs();
|
751 |
|
752 |
// make sure the new path for the navitmap.bin file(s) exist!!
|
753 |
File navit_mapsmd5_dir = new File(MAPMD5_FILENAME_PATH);
|
754 |
navit_mapsmd5_dir.mkdirs();
|
755 |
|
756 |
// make sure the share dir exists, otherwise the infobox will not show
|
757 |
File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR);
|
758 |
navit_data_share_dir.mkdirs();
|
759 |
|
760 |
// try to create cat. file if it does not exist
|
761 |
File navit_maps_catalogue = new File(CFG_FILENAME_PATH + NavitMapDownloader.CAT_FILE);
|
762 |
if (!navit_maps_catalogue.exists())
|
763 |
{
|
764 |
FileOutputStream fos_temp;
|
765 |
try
|
766 |
{
|
767 |
fos_temp = new FileOutputStream(navit_maps_catalogue);
|
768 |
fos_temp.write((NavitMapDownloader.MAP_CAT_HEADER + "\n").getBytes()); // just write header to the file
|
769 |
fos_temp.flush();
|
770 |
fos_temp.close();
|
771 |
}
|
772 |
catch (Exception e)
|
773 |
{
|
774 |
e.printStackTrace();
|
775 |
}
|
776 |
}
|
777 |
|
778 |
// ---------- downloader threads ----------------
|
779 |
NavitMapDownloader.MULTI_NUM_THREADS = 1;
|
780 |
PackageInfo pkgInfo;
|
781 |
Navit_DonateVersion_Installed = false;
|
782 |
try
|
783 |
{
|
784 |
// is the donate version installed?
|
785 |
pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_donate", 0);
|
786 |
String sharedUserId = pkgInfo.sharedUserId;
|
787 |
System.out.println("str nd=" + sharedUserId);
|
788 |
if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
789 |
{
|
790 |
System.out.println("##bonus 001##");
|
791 |
Navit_DonateVersion_Installed = true;
|
792 |
NavitMapDownloader.MULTI_NUM_THREADS = 3;
|
793 |
}
|
794 |
}
|
795 |
catch (NameNotFoundException e)
|
796 |
{
|
797 |
e.printStackTrace();
|
798 |
}
|
799 |
catch (Exception e)
|
800 |
{
|
801 |
e.printStackTrace();
|
802 |
}
|
803 |
|
804 |
try
|
805 |
{
|
806 |
// is the "large map" donate version installed?
|
807 |
pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_largemap_donate", 0);
|
808 |
String sharedUserId = pkgInfo.sharedUserId;
|
809 |
System.out.println("str lm=" + sharedUserId);
|
810 |
|
811 |
if (sharedUserId.equals("com.zoffcc.applications.zanavi"))
|
812 |
{
|
813 |
System.out.println("##bonus 002##");
|
814 |
Navit_DonateVersion_Installed = true;
|
815 |
Navit_Largemap_DonateVersion_Installed = true;
|
816 |
NavitMapDownloader.MULTI_NUM_THREADS = 3;
|
817 |
}
|
818 |
}
|
819 |
catch (NameNotFoundException e)
|
820 |
{
|
821 |
e.printStackTrace();
|
822 |
}
|
823 |
catch (Exception e)
|
824 |
{
|
825 |
e.printStackTrace();
|
826 |
}
|
827 |
// update map list
|
828 |
NavitMapDownloader.init_maps_without_donate_largemaps();
|
829 |
// ---------- downloader threads ----------------
|
830 |
|
831 |
Navit.follow_on = BitmapFactory.decodeResource(getResources(), R.drawable.follow);
|
832 |
Navit.follow_off = BitmapFactory.decodeResource(getResources(), R.drawable.follow_off);
|
833 |
Navit.follow_current = Navit.follow_on;
|
834 |
|
835 |
Navit.nav_arrow_stopped = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_stopped);
|
836 |
Navit.nav_arrow_moving = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving);
|
837 |
Navit.nav_arrow_moving_shadow = BitmapFactory.decodeResource(getResources(), R.drawable.navigation_arrow_moving_shadow);
|
838 |
|
839 |
Navit.zoomin = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_in_32_32);
|
840 |
Navit.zoomout = BitmapFactory.decodeResource(getResources(), R.drawable.zoom_out_32_32);
|
841 |
|
842 |
//Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway);
|
843 |
Navit.oneway_arrow = BitmapFactory.decodeResource(getResources(), R.drawable.oneway_large);
|
844 |
|
845 |
// *******************
|
846 |
// *******************
|
847 |
// *******************
|
848 |
// *******************
|
849 |
// check/init the catalogue file for downloaded maps
|
850 |
NavitMapDownloader.init_cat_file();
|
851 |
// *******************
|
852 |
// *******************
|
853 |
// *******************
|
854 |
// *******************
|
855 |
|
856 |
xmlconfig_unpack_file = false;
|
857 |
write_new_version_file = false;
|
858 |
try
|
859 |
{
|
860 |
NavitAppVersion = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionCode;
|
861 |
NavitAppVersion_string = "" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
|
862 |
}
|
863 |
catch (NameNotFoundException e)
|
864 |
{
|
865 |
e.printStackTrace();
|
866 |
NavitAppVersion = "1";
|
867 |
NavitAppVersion_string = "1";
|
868 |
}
|
869 |
catch (Exception e)
|
870 |
{
|
871 |
e.printStackTrace();
|
872 |
NavitAppVersion = "2";
|
873 |
NavitAppVersion_string = "2";
|
874 |
}
|
875 |
|
876 |
try
|
877 |
{
|
878 |
File navit_version = new File(VERSION_FILE);
|
879 |
if (!navit_version.exists())
|
880 |
{
|
881 |
System.out.println("version file does not exist");
|
882 |
NavitAppVersion_prev = "-1";
|
883 |
write_new_version_file = true;
|
884 |
}
|
885 |
else
|
886 |
{
|
887 |
// files exists, read in the prev. verison number
|
888 |
System.out.println("version file is here");
|
889 |
FileInputStream fos_temp;
|
890 |
byte[] buffer = new byte[101];
|
891 |
fos_temp = new FileInputStream(navit_version);
|
892 |
int len = fos_temp.read(buffer, 0, 100);
|
893 |
if (len != -1)
|
894 |
{
|
895 |
// use only len bytes to make the string (the rest is garbage!!)
|
896 |
NavitAppVersion_prev = new String(buffer).substring(0, len);
|
897 |
}
|
898 |
else
|
899 |
{
|
900 |
NavitAppVersion_prev = "-1";
|
901 |
write_new_version_file = true;
|
902 |
}
|
903 |
fos_temp.close();
|
904 |
}
|
905 |
|
906 |
}
|
907 |
catch (Exception e)
|
908 |
{
|
909 |
NavitAppVersion_prev = "-1";
|
910 |
write_new_version_file = true;
|
911 |
e.printStackTrace();
|
912 |
}
|
913 |
|
914 |
System.out.println("vprev:" + NavitAppVersion_prev + " vcur:" + NavitAppVersion);
|
915 |
|
916 |
if (NavitAppVersion_prev.compareTo(NavitAppVersion) != 0)
|
917 |
{
|
918 |
// different version
|
919 |
System.out.println("different version!!");
|
920 |
write_new_version_file = true;
|
921 |
xmlconfig_unpack_file = true;
|
922 |
|
923 |
//if ((NavitAppVersion_prev.compareTo("-1") != 0) && (NavitAppVersion.compareTo("-1") != 0))
|
924 |
//{
|
925 |
// user has upgraded to a new version of ZANavi
|
926 |
startup_status = Navit_Status_UPGRADED_TO_NEW_VERSION;
|
927 |
//}
|
928 |
}
|
929 |
else
|
930 |
{
|
931 |
// same version
|
932 |
System.out.println("same version");
|
933 |
xmlconfig_unpack_file = false;
|
934 |
}
|
935 |
|
936 |
// write new version file
|
937 |
if (write_new_version_file)
|
938 |
{
|
939 |
try
|
940 |
{
|
941 |
System.out.println("write version file");
|
942 |
FileOutputStream fos_temp;
|
943 |
File navit_version = new File(VERSION_FILE);
|
944 |
navit_version.delete();
|
945 |
fos_temp = new FileOutputStream(navit_version);
|
946 |
fos_temp.write(NavitAppVersion.getBytes());
|
947 |
fos_temp.flush();
|
948 |
fos_temp.close();
|
949 |
}
|
950 |
catch (Exception e)
|
951 |
{
|
952 |
e.printStackTrace();
|
953 |
}
|
954 |
}
|
955 |
|
956 |
// Sample useragent strings:
|
957 |
//
|
958 |
// Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110616 Firefox/7.0a1 SeaMonkey/2.4a1
|
959 |
// Dalvik/1.4.0 (Linux; U; Android 2.3.3; GT-I9100 Build/GINGERBREAD)
|
960 |
// Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5830 Build/FROYO)
|
961 |
// Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Desire S Build/GRI40)
|
962 |
// Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-179)
|
963 |
// Dalvik/1.4.0 (Linux; U; Android 2.3.3; HTC Wildfire S A510e Build/GRI40)
|
964 |
// Wget/1.10.2
|
965 |
// Dalvik/1.4.0 (Linux; U; Android 2.3.3; sdk Build/GRI34)
|
966 |
// Dalvik/1.2.0 (Linux; U; Android 2.2.2; MB525 Build/3.4.2-164)
|
967 |
// Dalvik/1.2.0 (Linux; U; Android 2.2; GT-I9000 Build/FROYO)
|
968 |
// Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5570L Build/FROYO)
|
969 |
// Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-I9000 Build/FROYO)
|
970 |
// Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)
|
971 |
String ANDROID = android.os.Build.VERSION.SDK; //The current development codename, or the string "REL" if this is a release build.
|
972 |
//String BOARD = android.os.Build.BOARD; //The name of the underlying board, like "goldfish".
|
973 |
//String BOOTLOADER = android.os.Build.BOOTLOADER; // The system bootloader version number.
|
974 |
String BRAND = android.os.Build.BRAND; //The brand (e.g., carrier) the software is customized for, if any.
|
975 |
//String CPU_ABI = android.os.Build.CPU_ABI; //The name of the instruction set (CPU type + ABI convention) of native code.
|
976 |
//String CPU_ABI2 = android.os.Build.CPU_ABI2; // The name of the second instruction set (CPU type + ABI convention) of native code.
|
977 |
String DEVICE = android.os.Build.DEVICE; // The name of the industrial design.
|
978 |
String DISPLAY = android.os.Build.DISPLAY; //A build ID string meant for displaying to the user
|
979 |
//String FINGERPRINT = android.os.Build.FINGERPRINT; //A string that uniquely identifies this build.
|
980 |
//String HARDWARE = android.os.Build.HARDWARE; //The name of the hardware (from the kernel command line or /proc).
|
981 |
//String HOST = android.os.Build.HOST;
|
982 |
//String ID = android.os.Build.ID; //Either a changelist number, or a label like "M4-rc20".
|
983 |
String MANUFACTURER = android.os.Build.MANUFACTURER; //The manufacturer of the product/hardware.
|
984 |
//String MODEL = android.os.Build.MODEL; //The end-user-visible name for the end product.
|
985 |
//String PRODUCT = android.os.Build.PRODUCT; //The name of the overall product.
|
986 |
//String RADIO = android.os.Build.RADIO; //The radio firmware version number.
|
987 |
//String TAGS = android.os.Build.TAGS; //Comma-separated tags describing the build, like "unsigned,debug".
|
988 |
//String TYPE = android.os.Build.TYPE; //The type of build, like "user" or "eng".
|
989 |
//String USER = android.os.Build.USER;
|
990 |
|
991 |
String android_version = "Android " + ANDROID;
|
992 |
String android_device = MANUFACTURER + " " + BRAND + " " + DEVICE;
|
993 |
|
994 |
// debug
|
995 |
// debug
|
996 |
// android_device = "telechips telechips m801";
|
997 |
// debug
|
998 |
// debug
|
999 |
|
1000 |
String android_rom_name = DISPLAY;
|
1001 |
if (Navit_DonateVersion_Installed == false)
|
1002 |
{
|
1003 |
UserAgentString = "Mozilla/5.0 (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
1004 |
UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "Z" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
1005 |
}
|
1006 |
else
|
1007 |
{
|
1008 |
if (Navit_Largemap_DonateVersion_Installed == false)
|
1009 |
{
|
1010 |
UserAgentString = "Mozilla/5.0 (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
1011 |
UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "donateZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
1012 |
}
|
1013 |
else
|
1014 |
|
1015 |
{
|
1016 |
UserAgentString = "Mozilla/5.0 (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
1017 |
UserAgentString_bind = "Mozilla/5.0 @__THREAD__@ (Linux; U; " + "LMdonateLMZ" + NavitAppVersion + "; " + android_version + "; " + android_device + " " + android_rom_name + ")";
|
1018 |
}
|
1019 |
}
|
1020 |
// System.out.println("UA=" + UserAgentString);
|
1021 |
|
1022 |
unsupported = false;
|
1023 |
try
|
1024 |
{
|
1025 |
if (android_device.toLowerCase().contains("telechips"))
|
1026 |
{
|
1027 |
if (android_device.toLowerCase().contains("m801"))
|
1028 |
{
|
1029 |
// if the donate version is already installed, dont disable the app
|
1030 |
if (Navit_DonateVersion_Installed == false)
|
1031 |
{
|
1032 |
if (Navit_Largemap_DonateVersion_Installed == false)
|
1033 |
{
|
1034 |
// activate [Weltbild] Cat Nova again (19.12.2011)
|
1035 |
// ** // unsupported = true;
|
1036 |
}
|
1037 |
}
|
1038 |
}
|
1039 |
}
|
1040 |
}
|
1041 |
catch (Exception e)
|
1042 |
{
|
1043 |
e.printStackTrace();
|
1044 |
}
|
1045 |
|
1046 |
try
|
1047 |
{
|
1048 |
// this hangs the emulator, if emulator < 2.3 (only works in emulator >= 2.3)!!
|
1049 |
if (!NAVIT_IS_EMULATOR)
|
1050 |
{
|
1051 |
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
1052 |
}
|
1053 |
}
|
1054 |
catch (Exception e3)
|
1055 |
{
|
1056 |
e3.printStackTrace();
|
1057 |
}
|
1058 |
|
1059 |
// try
|
1060 |
// {
|
1061 |
// vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
1062 |
// }
|
1063 |
// catch (Exception e)
|
1064 |
// {
|
1065 |
// e.printStackTrace();
|
1066 |
// }
|
1067 |
//sensorManager_ = sensorManager;
|
1068 |
|
1069 |
generic_alert_box = new AlertDialog.Builder(this);
|
1070 |
/*
|
1071 |
* show info box for first time users
|
1072 |
*/
|
1073 |
AlertDialog.Builder infobox = new AlertDialog.Builder(this);
|
1074 |
//. english text: Welcome to ZANavi
|
1075 |
infobox.setTitle(Navit.get_text("__INFO_BOX_TITLE__")); //TRANS
|
1076 |
infobox.setCancelable(false);
|
1077 |
final TextView message = new TextView(this);
|
1078 |
message.setFadingEdgeLength(20);
|
1079 |
message.setVerticalFadingEdgeEnabled(true);
|
1080 |
message.setPadding(10, 5, 10, 5);
|
1081 |
message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
1082 |
message.setGravity(Gravity.LEFT);
|
1083 |
// message.setScrollBarStyle(TextView.SCROLLBARS_INSIDE_OVERLAY);
|
1084 |
// message.setVerticalScrollBarEnabled(true);
|
1085 |
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
|
1086 |
rlp.leftMargin = 7;
|
1087 |
rlp.rightMargin = 7;
|
1088 |
|
1089 |
Navit.Navit_Geocoder = null;
|
1090 |
try
|
1091 |
{
|
1092 |
// for online search
|
1093 |
Navit.Navit_Geocoder = new Geocoder(this);
|
1094 |
}
|
1095 |
catch (Exception e)
|
1096 |
{
|
1097 |
e.printStackTrace();
|
1098 |
}
|
1099 |
|
1100 |
//TRANS
|
1101 |
infobox.setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
|
1102 |
{
|
1103 |
public void onClick(DialogInterface arg0, int arg1)
|
1104 |
{
|
1105 |
Log.e("Navit", "Ok, user saw the infobox");
|
1106 |
}
|
1107 |
});
|
1108 |
|
1109 |
//TRANS
|
1110 |
infobox.setNeutralButton(Navit.get_text("More info"), new DialogInterface.OnClickListener()
|
1111 |
{
|
1112 |
public void onClick(DialogInterface arg0, int arg1)
|
1113 |
{
|
1114 |
Log.e("Navit", "user wants more info, show the website");
|
1115 |
// URL to ZANavi Manual (in english language)
|
1116 |
String url = "http://zanavi.cc/index.php/Manual";
|
1117 |
Intent i = new Intent(Intent.ACTION_VIEW);
|
1118 |
i.setData(Uri.parse(url));
|
1119 |
startActivity(i);
|
1120 |
}
|
1121 |
});
|
1122 |
|
1123 |
File navit_first_startup = new File(FIRST_STARTUP_FILE);
|
1124 |
// if file does NOT exist, show the info box
|
1125 |
if (!navit_first_startup.exists())
|
1126 |
{
|
1127 |
// set first-ever-startup flag
|
1128 |
first_ever_startup = true;
|
1129 |
startup_status = Navit_Status_COMPLETE_NEW_INSTALL;
|
1130 |
FileOutputStream fos_temp;
|
1131 |
try
|
1132 |
{
|
1133 |
fos_temp = new FileOutputStream(navit_first_startup);
|
1134 |
fos_temp.write((int) 65); // just write an "A" to the file, but it really doesnt matter
|
1135 |
fos_temp.flush();
|
1136 |
fos_temp.close();
|
1137 |
|
1138 |
message.setLayoutParams(rlp);
|
1139 |
//. TRANSLATORS: multiline info text for first startup of application (see en_US for english text)
|
1140 |
final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
|
1141 |
Linkify.addLinks(s, Linkify.WEB_URLS);
|
1142 |
message.setText(s);
|
1143 |
message.setMovementMethod(LinkMovementMethod.getInstance());
|
1144 |
infobox.setView(message);
|
1145 |
|
1146 |
infobox.show();
|
1147 |
}
|
1148 |
catch (Exception e)
|
1149 |
{
|
1150 |
e.printStackTrace();
|
1151 |
}
|
1152 |
}
|
1153 |
/*
|
1154 |
* show info box for first time users
|
1155 |
*/
|
1156 |
|
1157 |
// show info box for upgrade
|
1158 |
if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
|
1159 |
{
|
1160 |
try
|
1161 |
{
|
1162 |
message.setLayoutParams(rlp);
|
1163 |
// upgrade message
|
1164 |
String upgrade_summary = "\n\n********\n";
|
1165 |
// upgrade message
|
1166 |
final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded" + upgrade_summary);
|
1167 |
Linkify.addLinks(s, Linkify.WEB_URLS);
|
1168 |
message.setText(s);
|
1169 |
message.setMovementMethod(LinkMovementMethod.getInstance());
|
1170 |
infobox.setView(message);
|
1171 |
|
1172 |
infobox.show();
|
1173 |
}
|
1174 |
catch (Exception e)
|
1175 |
{
|
1176 |
e.printStackTrace();
|
1177 |
}
|
1178 |
|
1179 |
}
|
1180 |
// show info box for upgrade
|
1181 |
|
1182 |
// make handler statically available for use in "msg_to_msg_handler"
|
1183 |
Navit_progress_h = this.progress_handler;
|
1184 |
|
1185 |
Display display_ = getWindowManager().getDefaultDisplay();
|
1186 |
int width_ = display_.getWidth();
|
1187 |
int height_ = display_.getHeight();
|
1188 |
metrics = new DisplayMetrics();
|
1189 |
display_.getMetrics(Navit.metrics);
|
1190 |
Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_);
|
1191 |
Log.e("Navit", "Navit -> dpi=" + Navit.metrics.densityDpi);
|
1192 |
Log.e("Navit", "Navit -> density=" + Navit.metrics.density);
|
1193 |
Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);
|
1194 |
|
1195 |
try
|
1196 |
{
|
1197 |
Navit.bigmap_bitmap = BitmapFactory.decodeResource(getResources(), R.raw.bigmap_colors_zanavi2);
|
1198 |
}
|
1199 |
catch (Exception e)
|
1200 |
{
|
1201 |
// when not enough memory is available, then disable large world overview map!
|
1202 |
System.gc();
|
1203 |
Navit.bigmap_bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
|
1204 |
}
|
1205 |
// ------no----- // Navit.bigmap_bitmap.setDensity(120); // set our dpi!!
|
1206 |
|
1207 |
try
|
1208 |
{
|
1209 |
ActivityResults = new NavitActivityResult[16];
|
1210 |
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
1211 |
}
|
1212 |
catch (Exception e)
|
1213 |
{
|
1214 |
e.printStackTrace();
|
1215 |
}
|
1216 |
|
1217 |
try
|
1218 |
{
|
1219 |
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
1220 |
// wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1221 |
wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
|
1222 |
}
|
1223 |
catch (Exception e)
|
1224 |
{
|
1225 |
e.printStackTrace();
|
1226 |
wl = null;
|
1227 |
}
|
1228 |
|
1229 |
try
|
1230 |
{
|
1231 |
if (wl != null)
|
1232 |
{
|
1233 |
wl.acquire();
|
1234 |
}
|
1235 |
}
|
1236 |
catch (Exception e)
|
1237 |
{
|
1238 |
e.printStackTrace();
|
1239 |
}
|
1240 |
|
1241 |
Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
|
1242 |
if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
|
1243 |
{
|
1244 |
Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language);
|
1245 |
}
|
1246 |
|
1247 |
Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
|
1248 |
if (!extractRes(NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase(), NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language + "/LC_MESSAGES/navit.mo"))
|
1249 |
{
|
1250 |
Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language + "_" + NavitTextTranslations.sub_language.toLowerCase());
|
1251 |
}
|
1252 |
|
1253 |
Log.e("Navit", "trying to extract language resource " + NavitTextTranslations.main_language);
|
1254 |
if (!extractRes(NavitTextTranslations.main_language, NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo"))
|
1255 |
{
|
1256 |
Log.e("Navit", "Failed to extract language resource " + NavitTextTranslations.main_language);
|
1257 |
}
|
1258 |
|
1259 |
// DEBUG - check if language file is on SDCARD -
|
1260 |
try
|
1261 |
{
|
1262 |
File debug_mo_src = new File("/sdcard/zanavi/debug/navit.mo");
|
1263 |
File debug_mo_dest = new File(NAVIT_DATA_DIR + "/locale/" + NavitTextTranslations.main_language + "/LC_MESSAGES/navit.mo");
|
1264 |
//* File navit_debug_dir = new File("/sdcard/zanavi/debug/");
|
1265 |
//* navit_debug_dir.mkdirs();
|
1266 |
copyFile(debug_mo_src, debug_mo_dest);
|
1267 |
}
|
1268 |
catch (Exception e)
|
1269 |
{
|
1270 |
e.printStackTrace();
|
1271 |
}
|
1272 |
// DEBUG - check if language file is on SDCARD -
|
1273 |
|
1274 |
File navit_config_xml_file = new File(NAVIT_DATA_DIR + "/share/navit.xml");
|
1275 |
if (!navit_config_xml_file.exists())
|
1276 |
{
|
1277 |
xmlconfig_unpack_file = true;
|
1278 |
Log.e("Navit", "navit.xml does not exist, unpacking in any case");
|
1279 |
}
|
1280 |
|
1281 |
my_display_density = "mdpi";
|
1282 |
// ldpi display (120 dpi)
|
1283 |
|
1284 |
if (Navit.metrics.densityDpi <= 120)
|
1285 |
{
|
1286 |
my_display_density = "ldpi";
|
1287 |
if (xmlconfig_unpack_file)
|
1288 |
{
|
1289 |
if (!extractRes("navitldpi", NAVIT_DATA_DIR + "/share/navit.xml"))
|
1290 |
{
|
1291 |
Log.e("Navit", "Failed to extract navit.xml for ldpi device(s)");
|
1292 |
}
|
1293 |
}
|
1294 |
}
|
1295 |
// mdpi display (160 dpi)
|
1296 |
else if ((Navit.metrics.densityDpi > 120) && (Navit.metrics.densityDpi <= 160))
|
1297 |
{
|
1298 |
my_display_density = "mdpi";
|
1299 |
if (xmlconfig_unpack_file)
|
1300 |
{
|
1301 |
if (!extractRes("navitmdpi", NAVIT_DATA_DIR + "/share/navit.xml"))
|
1302 |
{
|
1303 |
Log.e("Navit", "Failed to extract navit.xml for mdpi device(s)");
|
1304 |
}
|
1305 |
}
|
1306 |
}
|
1307 |
// hdpi display (240 dpi)
|
1308 |
else if ((Navit.metrics.densityDpi > 160) && (Navit.metrics.densityDpi < 320))
|
1309 |
//else if (Navit.metrics.densityDpi == 240)
|
1310 |
{
|
1311 |
my_display_density = "hdpi";
|
1312 |
if (xmlconfig_unpack_file)
|
1313 |
{
|
1314 |
if (!extractRes("navithdpi", NAVIT_DATA_DIR + "/share/navit.xml"))
|
1315 |
{
|
1316 |
Log.e("Navit", "Failed to extract navit.xml for hdpi device(s)");
|
1317 |
}
|
1318 |
}
|
1319 |
}
|
1320 |
// xhdpi display (320 dpi)
|
1321 |
else if (Navit.metrics.densityDpi >= 320)
|
1322 |
{
|
1323 |
Log.e("Navit", "found xhdpi device, this is not fully supported!!");
|
1324 |
Log.e("Navit", "using hdpi values");
|
1325 |
my_display_density = "hdpi";
|
1326 |
if (xmlconfig_unpack_file)
|
1327 |
{
|
1328 |
if (!extractRes("navithdpi", NAVIT_DATA_DIR + "/share/navit.xml"))
|
1329 |
{
|
1330 |
Log.e("Navit", "Failed to extract navit.xml for xhdpi device(s)");
|
1331 |
}
|
1332 |
}
|
1333 |
}
|
1334 |
else
|
1335 |
{
|
1336 |
/* default, meaning we just dont know what display this is */
|
1337 |
if (xmlconfig_unpack_file)
|
1338 |
{
|
1339 |
if (!extractRes("navitmdpi", NAVIT_DATA_DIR + "/share/navit.xml"))
|
1340 |
{
|
1341 |
Log.e("Navit", "Failed to extract navit.xml (default version)");
|
1342 |
}
|
1343 |
}
|
1344 |
}
|
1345 |
// Debug.startMethodTracing("calc");
|
1346 |
|
1347 |
// if (unsupported)
|
1348 |
// {
|
1349 |
// class CustomListener implements View.OnClickListener
|
1350 |
// {
|
1351 |
// private final Dialog dialog;
|
1352 |
//
|
1353 |
// public CustomListener(Dialog dialog)
|
1354 |
// {
|
1355 |
// this.dialog = dialog;
|
1356 |
// }
|
1357 |
//
|
1358 |
// @Override
|
1359 |
// public void onClick(View v)
|
1360 |
// {
|
1361 |
//
|
1362 |
// // Do whatever you want here
|
1363 |
//
|
1364 |
// // If tou want to close the dialog, uncomment the line below
|
1365 |
// //dialog.dismiss();
|
1366 |
// }
|
1367 |
// }
|
1368 |
//
|
1369 |
// AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
1370 |
// dialog.setTitle(Navit.get_text("WeltBild Tablet")); //TRANS
|
1371 |
// dialog.setCancelable(false);
|
1372 |
// dialog.setMessage("Your device is not supported!");
|
1373 |
// dialog.show();
|
1374 |
// //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
1375 |
// //theButton.setOnClickListener(new CustomListener(dialog));
|
1376 |
// }
|
1377 |
|
1378 |
// setup graphics objects
|
1379 |
// setup graphics objects
|
1380 |
// setup graphics objects
|
1381 |
NG__vehicle = new NavitGraphics(this, 1, 0, 0, 50, 50, 65535, 0, 0);
|
1382 |
NG__map_main = new NavitGraphics(this, 0, 0, 0, 100, 100, 0, 0, 0);
|
1383 |
Navit.N_NavitGraphics = NG__map_main;
|
1384 |
// setup graphics objects
|
1385 |
// setup graphics objects
|
1386 |
// setup graphics objects
|
1387 |
|
1388 |
NV = new NavitVehicle(this);
|
1389 |
NSp = new NavitSpeech2(this);
|
1390 |
|
1391 |
// --> dont use!! NavitMain(this, langu, android.os.Build.VERSION.SDK_INT);
|
1392 |
Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
|
1393 |
|
1394 |
cwthr = new CWorkerThread();
|
1395 |
cwthr.start();
|
1396 |
// --new--
|
1397 |
cwthr.StartMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density);
|
1398 |
// --old--
|
1399 |
// NavitMain(this, langu, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density);
|
1400 |
// --old--
|
1401 |
// NavitActivity(3);
|
1402 |
|
1403 |
// CAUTION: don't use android.os.Build.VERSION.SDK_INT if <uses-sdk android:minSdkVersion="3" />
|
1404 |
// You will get exception on all devices with Android 1.5 and lower
|
1405 |
// because Build.VERSION.SDK_INT is since SDK 4 (Donut 1.6)
|
1406 |
|
1407 |
// (see: http://developer.android.com/guide/appendix/api-levels.html)
|
1408 |
// Platform Version API Level
|
1409 |
// =============================================
|
1410 |
// Android 4.0.3 15
|
1411 |
// Android 4.0, 4.0.1, 4.0.2 14
|
1412 |
// Android 3.2 13
|
1413 |
// Android 3.1 12
|
1414 |
// Android 3.0 11
|
1415 |
// Android 2.3.3 10
|
1416 |
// Android 2.3.1 9
|
1417 |
// Android 2.2 8
|
1418 |
// Android 2.1 7
|
1419 |
// Android 2.0.1 6
|
1420 |
// Android 2.0 5
|
1421 |
// Android 1.6 4
|
1422 |
// Android 1.5 3
|
1423 |
// Android 1.1 2
|
1424 |
// Android 1.0 1
|
1425 |
|
1426 |
Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
1427 |
|
1428 |
//try
|
1429 |
//{
|
1430 |
// Thread.sleep(2000);
|
1431 |
//}
|
1432 |
//catch (InterruptedException e)
|
1433 |
//{
|
1434 |
//}
|
1435 |
|
1436 |
//getPrefs();
|
1437 |
//activatePrefs();
|
1438 |
|
1439 |
// unpack some localized Strings
|
1440 |
// a test now, later we will unpack all needed strings for java, here at this point!!
|
1441 |
//String x = NavitGraphics.getLocalizedString("Austria");
|
1442 |
//Log.e("Navit", "x=" + x);
|
1443 |
Navit.show_mem_used();
|
1444 |
|
1445 |
/*
|
1446 |
* GpsStatus.Listener listener = new GpsStatus.Listener()
|
1447 |
* {
|
1448 |
* public void onGpsStatusChanged(int event)
|
1449 |
* {
|
1450 |
* //System.out.println("xxxxx");
|
1451 |
* if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS)
|
1452 |
* {
|
1453 |
* }
|
1454 |
* }
|
1455 |
* };
|
1456 |
*/
|
1457 |
}
|
1458 |
|
1459 |
// private void setOnKeyListener(OnKeyListener onKeyListener)
|
1460 |
// {
|
1461 |
//
|
1462 |
// }
|
1463 |
|
1464 |
public static void show_mem_used() // wrapper
|
1465 |
{
|
1466 |
try
|
1467 |
{
|
1468 |
Message msg = Navit_progress_h.obtainMessage();
|
1469 |
Bundle b = new Bundle();
|
1470 |
msg.what = 14;
|
1471 |
msg.setData(b);
|
1472 |
Navit_progress_h.sendMessage(msg);
|
1473 |
}
|
1474 |
catch (Exception e)
|
1475 |
{
|
1476 |
e.printStackTrace();
|
1477 |
}
|
1478 |
}
|
1479 |
|
1480 |
public static void show_mem_used_real()
|
1481 |
{
|
1482 |
try
|
1483 |
{
|
1484 |
if (PREF_show_debug_messages)
|
1485 |
{
|
1486 |
int usedMegs;
|
1487 |
//System.gc();
|
1488 |
usedMegs = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
|
1489 |
//Debug.MemoryInfo meminfo = new Debug.MemoryInfo();
|
1490 |
//Debug.getMemoryInfo(meminfo);
|
1491 |
|
1492 |
if (usedMegs_old != usedMegs)
|
1493 |
{
|
1494 |
String usedMegsString = String.format("Memory Used: %d MB", usedMegs);
|
1495 |
//System.out.println("" + meminfo.dalvikPrivateDirty + " " + meminfo.dalvikPss + " " + meminfo.dalvikSharedDirty + " nP:" + meminfo.nativePrivateDirty + " nPss:" + meminfo.nativePss + " nSh:" + meminfo.nativeSharedDirty + " o1:" + meminfo.otherPrivateDirty + " o2:" + meminfo.otherPss + " o3:" + meminfo.otherSharedDirty);
|
1496 |
Navit.set_debug_messages2(usedMegsString);
|
1497 |
}
|
1498 |
usedMegs_old = usedMegs;
|
1499 |
}
|
1500 |
}
|
1501 |
catch (Exception e)
|
1502 |
{
|
1503 |
e.printStackTrace();
|
1504 |
}
|
1505 |
}
|
1506 |
|
1507 |
public static void set_debug_messages(String texta, String textb, String textc)
|
1508 |
{
|
1509 |
try
|
1510 |
{
|
1511 |
NavitGraphics.debug_line_1 = texta;
|
1512 |
NavitGraphics.debug_line_2 = textb;
|
1513 |
NavitGraphics.debug_line_3 = textc;
|
1514 |
NavitGraphics.NavitMsgTv_.setMaxLines(4);
|
1515 |
NavitGraphics.NavitMsgTv_.setLines(4);
|
1516 |
NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
|
1517 |
//System.out.println("invalidate 022");
|
1518 |
NavitGraphics.NavitMsgTv_.postInvalidate();
|
1519 |
}
|
1520 |
catch (Exception e)
|
1521 |
{
|
1522 |
e.printStackTrace();
|
1523 |
}
|
1524 |
}
|
1525 |
|
1526 |
public static void set_debug_messages1(String text)
|
1527 |
{
|
1528 |
try
|
1529 |
{
|
1530 |
NavitGraphics.debug_line_1 = text;
|
1531 |
NavitGraphics.NavitMsgTv_.setMaxLines(4);
|
1532 |
NavitGraphics.NavitMsgTv_.setLines(4);
|
1533 |
NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
|
1534 |
//System.out.println("invalidate 023");
|
1535 |
NavitGraphics.NavitMsgTv_.postInvalidate();
|
1536 |
}
|
1537 |
catch (Exception e)
|
1538 |
{
|
1539 |
e.printStackTrace();
|
1540 |
}
|
1541 |
}
|
1542 |
|
1543 |
public static void set_debug_messages2(String text)
|
1544 |
{
|
1545 |
try
|
1546 |
{
|
1547 |
NavitGraphics.debug_line_2 = text;
|
1548 |
//NavitGraphics.NavitMsgTv_.setMaxLines(4);
|
1549 |
//NavitGraphics.NavitMsgTv_.setLines(4);
|
1550 |
|
1551 |
NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
|
1552 |
//System.out.println("invalidate 024");
|
1553 |
NavitGraphics.NavitMsgTv_.postInvalidate();
|
1554 |
}
|
1555 |
catch (Exception e)
|
1556 |
{
|
1557 |
e.printStackTrace();
|
1558 |
}
|
1559 |
}
|
1560 |
|
1561 |
public static void set_debug_messages3(String text)
|
1562 |
{
|
1563 |
try
|
1564 |
{
|
1565 |
NavitGraphics.debug_line_3 = text;
|
1566 |
NavitGraphics.NavitMsgTv_.setMaxLines(4);
|
1567 |
NavitGraphics.NavitMsgTv_.setLines(4);
|
1568 |
NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
|
1569 |
//System.out.println("invalidate 025");
|
1570 |
NavitGraphics.NavitMsgTv_.postInvalidate();
|
1571 |
}
|
1572 |
catch (Exception e)
|
1573 |
{
|
1574 |
e.printStackTrace();
|
1575 |
}
|
1576 |
}
|
1577 |
|
1578 |
public static void set_debug_messages4(String text)
|
1579 |
{
|
1580 |
try
|
1581 |
{
|
1582 |
NavitGraphics.debug_line_4 = text;
|
1583 |
NavitGraphics.NavitMsgTv_.setMaxLines(4);
|
1584 |
NavitGraphics.NavitMsgTv_.setLines(4);
|
1585 |
NavitGraphics.NavitMsgTv_.setText(" " + NavitGraphics.debug_line_1 + "\n " + NavitGraphics.debug_line_2 + "\n " + NavitGraphics.debug_line_3 + "\n " + NavitGraphics.debug_line_4);
|
1586 |
//System.out.println("invalidate 026");
|
1587 |
NavitGraphics.NavitMsgTv_.postInvalidate();
|
1588 |
}
|
1589 |
catch (Exception e)
|
1590 |
{
|
1591 |
e.printStackTrace();
|
1592 |
}
|
1593 |
}
|
1594 |
|
1595 |
public static void set_debug_messages3_wrapper(String text)
|
1596 |
{
|
1597 |
try
|
1598 |
{
|
1599 |
Message msg = Navit_progress_h.obtainMessage();
|
1600 |
Bundle b = new Bundle();
|
1601 |
msg.what = 15;
|
1602 |
b.putString("text", text);
|
1603 |
msg.setData(b);
|
1604 |
Navit_progress_h.sendMessage(msg);
|
1605 |
}
|
1606 |
catch (Exception e)
|
1607 |
{
|
1608 |
e.printStackTrace();
|
1609 |
}
|
1610 |
}
|
1611 |
|
1612 |
@Override
|
1613 |
public void onStart()
|
1614 |
{
|
1615 |
Navit.show_mem_used();
|
1616 |
|
1617 |
System.gc();
|
1618 |
super.onStart();
|
1619 |
|
1620 |
Log.e("Navit", "OnStart");
|
1621 |
|
1622 |
while (Global_Init_Finished == 0)
|
1623 |
{
|
1624 |
Log.e("Navit", "OnStart:Global_Init_Finished==0 !!!!!");
|
1625 |
try
|
1626 |
{
|
1627 |
Thread.sleep(250, 0); // 1/4 sec sleep
|
1628 |
}
|
1629 |
catch (InterruptedException e)
|
1630 |
{
|
1631 |
}
|
1632 |
}
|
1633 |
|
1634 |
cwthr.NavitActivity2(2);
|
1635 |
|
1636 |
getPrefs();
|
1637 |
activatePrefs();
|
1638 |
sun_moon__mLastCalcSunMillis = -1L;
|
1639 |
|
1640 |
// paint for bitmapdrawing on map
|
1641 |
if (PREF_use_anti_aliasing)
|
1642 |
{
|
1643 |
NavitGraphics.paint_for_map_display.setAntiAlias(true);
|
1644 |
}
|
1645 |
else
|
1646 |
{
|
1647 |
NavitGraphics.paint_for_map_display.setAntiAlias(false);
|
1648 |
}
|
1649 |
if (PREF_use_map_filtering)
|
1650 |
{
|
1651 |
NavitGraphics.paint_for_map_display.setFilterBitmap(true);
|
1652 |
}
|
1653 |
else
|
1654 |
{
|
1655 |
NavitGraphics.paint_for_map_display.setFilterBitmap(false);
|
1656 |
}
|
1657 |
|
1658 |
// activate gps AFTER 3g-location
|
1659 |
NavitVehicle.turn_on_precise_provider();
|
1660 |
|
1661 |
Navit.show_mem_used();
|
1662 |
|
1663 |
// restore points
|
1664 |
read_map_points();
|
1665 |
}
|
1666 |
|
1667 |
@Override
|
1668 |
public void onRestart()
|
1669 |
{
|
1670 |
super.onRestart();
|
1671 |
Log.e("Navit", "OnRestart");
|
1672 |
|
1673 |
while (Global_Init_Finished == 0)
|
1674 |
{
|
1675 |
Log.e("Navit", "onRestart:Global_Init_Finished==0 !!!!!");
|
1676 |
try
|
1677 |
{
|
1678 |
Thread.sleep(250, 0); // 1/4 sec sleep
|
1679 |
}
|
1680 |
catch (InterruptedException e)
|
1681 |
{
|
1682 |
}
|
1683 |
}
|
1684 |
|
1685 |
cwthr.NavitActivity2(0);
|
1686 |
NavitVehicle.turn_on_sat_status();
|
1687 |
}
|
1688 |
|
1689 |
@Override
|
1690 |
public void onResume()
|
1691 |
{
|
1692 |
// System.gc();
|
1693 |
super.onResume();
|
1694 |
|
1695 |
Log.e("Navit", "OnResume");
|
1696 |
|
1697 |
while (Global_Init_Finished == 0)
|
1698 |
{
|
1699 |
Log.e("Navit", "OnResume:Global_Init_Finished==0 !!!!!");
|
1700 |
try
|
1701 |
{
|
1702 |
Thread.sleep(250, 0); // 1/4 sec sleep
|
1703 |
}
|
1704 |
catch (InterruptedException e)
|
1705 |
{
|
1706 |
}
|
1707 |
}
|
1708 |
|
1709 |
//InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
1710 |
cwthr.NavitActivity2(1);
|
1711 |
|
1712 |
NavitVehicle.turn_on_sat_status();
|
1713 |
|
1714 |
try
|
1715 |
{
|
1716 |
if (wl != null)
|
1717 |
{
|
1718 |
wl.acquire();
|
1719 |
}
|
1720 |
}
|
1721 |
catch (Exception e)
|
1722 |
{
|
1723 |
e.printStackTrace();
|
1724 |
}
|
1725 |
|
1726 |
//Intent caller = this.getIntent();
|
1727 |
//System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
|
1728 |
//System.out.println("C=" + caller.getComponent().flattenToString());
|
1729 |
|
1730 |
if (unsupported)
|
1731 |
{
|
1732 |
class CustomListener implements View.OnClickListener
|
1733 |
{
|
1734 |
private final Dialog dialog;
|
1735 |
|
1736 |
public CustomListener(Dialog dialog)
|
1737 |
{
|
1738 |
this.dialog = dialog;
|
1739 |
}
|
1740 |
|
1741 |
@Override
|
1742 |
public void onClick(View v)
|
1743 |
{
|
1744 |
|
1745 |
// Do whatever you want here
|
1746 |
|
1747 |
// If tou want to close the dialog, uncomment the line below
|
1748 |
//dialog.dismiss();
|
1749 |
}
|
1750 |
}
|
1751 |
|
1752 |
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
1753 |
dialog.setTitle("WeltBild Tablet");
|
1754 |
dialog.setCancelable(false);
|
1755 |
dialog.setMessage("Your device is not supported!");
|
1756 |
dialog.show();
|
1757 |
//Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
1758 |
//theButton.setOnClickListener(new CustomListener(dialog));
|
1759 |
}
|
1760 |
|
1761 |
if (Navit_maps_loaded == false)
|
1762 |
{
|
1763 |
Navit_maps_loaded = true;
|
1764 |
// activate all maps
|
1765 |
Log.e("Navit", "**** LOAD ALL MAPS **** start");
|
1766 |
Message msg3 = new Message();
|
1767 |
Bundle b3 = new Bundle();
|
1768 |
b3.putInt("Callback", 20);
|
1769 |
msg3.setData(b3);
|
1770 |
N_NavitGraphics.callback_handler.sendMessage(msg3);
|
1771 |
Log.e("Navit", "**** LOAD ALL MAPS **** end");
|
1772 |
}
|
1773 |
|
1774 |
String intent_data = null;
|
1775 |
if (startup_intent != null)
|
1776 |
{
|
1777 |
if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
|
1778 |
{
|
1779 |
Log.e("Navit", "**2**A " + startup_intent.getAction());
|
1780 |
Log.e("Navit", "**2**D " + startup_intent.getDataString());
|
1781 |
intent_data = startup_intent.getDataString();
|
1782 |
}
|
1783 |
else
|
1784 |
{
|
1785 |
Log.e("Navit", "timestamp for navigate_to expired! not using data");
|
1786 |
}
|
1787 |
}
|
1788 |
|
1789 |
if ((intent_data != null) && (intent_data.substring(0, 18).equals("google.navigation:")))
|
1790 |
{
|
1791 |
// better use regex later, but for now to test this feature its ok :-)
|
1792 |
// better use regex later, but for now to test this feature its ok :-)
|
1793 |
|
1794 |
// g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
|
1795 |
// d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
|
1796 |
// b: google.navigation:q=48.25676,16.643
|
1797 |
// a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
|
1798 |
// e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
|
1799 |
// sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
|
1800 |
// -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
|
1801 |
// f: google.navigation:ll=48.25676,16.643&...
|
1802 |
// c: google.navigation:ll=48.25676,16.643
|
1803 |
|
1804 |
String lat;
|
1805 |
String lon;
|
1806 |
String q;
|
1807 |
|
1808 |
String temp1 = null;
|
1809 |
String temp2 = null;
|
1810 |
String temp3 = null;
|
1811 |
boolean parsable = false;
|
1812 |
boolean unparsable_info_box = true;
|
1813 |
try
|
1814 |
{
|
1815 |
intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
1816 |
}
|
1817 |
catch (Exception e1)
|
1818 |
{
|
1819 |
e1.printStackTrace();
|
1820 |
}
|
1821 |
|
1822 |
// DEBUG
|
1823 |
// DEBUG
|
1824 |
// DEBUG
|
1825 |
// intent_data = "google.navigation:q=Wien Burggasse 27";
|
1826 |
// intent_data = "google.navigation:q=48.25676,16.643";
|
1827 |
// intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
|
1828 |
// intent_data = "google.navigation:ll=48.25676,16.643";
|
1829 |
// DEBUG
|
1830 |
// DEBUG
|
1831 |
// DEBUG
|
1832 |
|
1833 |
try
|
1834 |
{
|
1835 |
Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
|
1836 |
Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
|
1837 |
Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
|
1838 |
Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
|
1839 |
Log.e("Navit", "found DEBUG 4.1: yy" + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
|
1840 |
Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
|
1841 |
}
|
1842 |
catch (Exception e)
|
1843 |
{
|
1844 |
e.printStackTrace();
|
1845 |
}
|
1846 |
|
1847 |
if (!Navit.NavitStartupAlreadySearching)
|
1848 |
{
|
1849 |
if (intent_data.length() > 19)
|
1850 |
{
|
1851 |
// if d: then start target search
|
1852 |
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]"))))
|
1853 |
{
|
1854 |
Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
|
1855 |
Navit.NavitStartupAlreadySearching = true;
|
1856 |
start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
1857 |
// dont use this here, already starting search, so set to "false"
|
1858 |
parsable = false;
|
1859 |
unparsable_info_box = false;
|
1860 |
}
|
1861 |
// if b: then remodel the input string to look like a:
|
1862 |
else if (intent_data.substring(0, 20).equals("google.navigation:q="))
|
1863 |
{
|
1864 |
intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
|
1865 |
Log.e("Navit", "target found (b): " + intent_data);
|
1866 |
parsable = true;
|
1867 |
}
|
1868 |
// if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
|
1869 |
else if (intent_data.substring(0, 25).equals("google.navigation:///?ll="))
|
1870 |
{
|
1871 |
intent_data = "google.navigation:ll=" + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
|
1872 |
Log.e("Navit", "target found (g): " + intent_data);
|
1873 |
parsable = true;
|
1874 |
}
|
1875 |
// if e: then remodel the input string to look like a:
|
1876 |
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")))
|
1877 |
{
|
1878 |
int idx = intent_data.indexOf("&");
|
1879 |
intent_data = intent_data.substring(0, idx) + "&q=Target";
|
1880 |
Log.e("Navit", "target found (e): " + intent_data);
|
1881 |
parsable = true;
|
1882 |
}
|
1883 |
// if f: then remodel the input string to look like a:
|
1884 |
else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&").length > 1))
|
1885 |
{
|
1886 |
int idx = intent_data.indexOf("&");
|
1887 |
intent_data = intent_data.substring(0, idx) + "&q=Target";
|
1888 |
Log.e("Navit", "target found (f): " + intent_data);
|
1889 |
parsable = true;
|
1890 |
}
|
1891 |
// already looks like a: just set flag
|
1892 |
else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length > 1))
|
1893 |
{
|
1894 |
// dummy, just set the flag
|
1895 |
Log.e("Navit", "target found (a): " + intent_data);
|
1896 |
Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
|
1897 |
parsable = true;
|
1898 |
}
|
1899 |
// if c: then remodel the input string to look like a:
|
1900 |
else if ((intent_data.substring(0, 21).equals("google.navigation:ll=")) && (intent_data.split("&q=").length < 2))
|
1901 |
{
|
1902 |
|
1903 |
intent_data = intent_data + "&q=Target";
|
1904 |
Log.e("Navit", "target found (c): " + intent_data);
|
1905 |
parsable = true;
|
1906 |
}
|
1907 |
}
|
1908 |
}
|
1909 |
else
|
1910 |
{
|
1911 |
Log.e("Navit", "already started search from startup intent");
|
1912 |
parsable = false;
|
1913 |
unparsable_info_box = false;
|
1914 |
}
|
1915 |
|
1916 |
if (parsable)
|
1917 |
{
|
1918 |
// now string should be in form --> a:
|
1919 |
// now split the parts off
|
1920 |
temp1 = intent_data.split("&q=", -1)[0];
|
1921 |
try
|
1922 |
{
|
1923 |
temp3 = temp1.split("ll=", -1)[1];
|
1924 |
temp2 = intent_data.split("&q=", -1)[1];
|
1925 |
}
|
1926 |
catch (Exception e)
|
1927 |
{
|
1928 |
// java.lang.ArrayIndexOutOfBoundsException most likely
|
1929 |
// so let's assume we dont have '&q=xxxx'
|
1930 |
temp3 = temp1;
|
1931 |
}
|
1932 |
|
1933 |
if (temp2 == null)
|
1934 |
{
|
1935 |
// use some default name
|
1936 |
temp2 = "Target";
|
1937 |
}
|
1938 |
|
1939 |
lat = temp3.split(",", -1)[0];
|
1940 |
lon = temp3.split(",", -1)[1];
|
1941 |
q = temp2;
|
1942 |
// is the "search name" url-encoded? i think so, lets url-decode it here
|
1943 |
q = URLDecoder.decode(q);
|
1944 |
// System.out.println();
|
1945 |
|
1946 |
Navit.remember_destination(q, lat, lon);
|
1947 |
Navit.destination_set();
|
1948 |
|
1949 |
Message msg = new Message();
|
1950 |
Bundle b = new Bundle();
|
1951 |
b.putInt("Callback", 3);
|
1952 |
b.putString("lat", lat);
|
1953 |
b.putString("lon", lon);
|
1954 |
b.putString("q", q);
|
1955 |
msg.setData(b);
|
1956 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
1957 |
|
1958 |
// zoom_to_route();
|
1959 |
try
|
1960 |
{
|
1961 |
Thread.sleep(400);
|
1962 |
}
|
1963 |
catch (InterruptedException e)
|
1964 |
{
|
1965 |
}
|
1966 |
|
1967 |
try
|
1968 |
{
|
1969 |
show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
|
1970 |
}
|
1971 |
catch (Exception e2)
|
1972 |
{
|
1973 |
e2.printStackTrace();
|
1974 |
}
|
1975 |
|
1976 |
try
|
1977 |
{
|
1978 |
Navit.follow_button_on();
|
1979 |
}
|
1980 |
catch (Exception e2)
|
1981 |
|
1982 |
{
|
1983 |
e2.printStackTrace();
|
1984 |
}
|
1985 |
}
|
1986 |
else
|
1987 |
{
|
1988 |
if (unparsable_info_box && !searchBoxShown)
|
1989 |
{
|
1990 |
try
|
1991 |
{
|
1992 |
searchBoxShown = true;
|
1993 |
String searchString = intent_data.split("q=")[1];
|
1994 |
searchString = searchString.split("&")[0];
|
1995 |
searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
1996 |
Log.e("Navit", "Search String :" + searchString);
|
1997 |
executeSearch(searchString);
|
1998 |
}
|
1999 |
catch (Exception e)
|
2000 |
{
|
2001 |
// safety net
|
2002 |
try
|
2003 |
{
|
2004 |
Log.e("Navit", "problem with startup search 7 str=" + intent_data);
|
2005 |
}
|
2006 |
catch (Exception e2)
|
2007 |
{
|
2008 |
e2.printStackTrace();
|
2009 |
}
|
2010 |
}
|
2011 |
}
|
2012 |
}
|
2013 |
}
|
2014 |
else if ((intent_data != null) && (intent_data.substring(0, 10).equals("geo:0,0?q=")))
|
2015 |
{
|
2016 |
// g: geo:0,0?q=wien%20burggasse
|
2017 |
|
2018 |
boolean parsable = false;
|
2019 |
boolean unparsable_info_box = true;
|
2020 |
try
|
2021 |
{
|
2022 |
intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
2023 |
}
|
2024 |
catch (Exception e1)
|
2025 |
{
|
2026 |
e1.printStackTrace();
|
2027 |
}
|
2028 |
|
2029 |
if (!Navit.NavitStartupAlreadySearching)
|
2030 |
{
|
2031 |
if (intent_data.length() > 10)
|
2032 |
{
|
2033 |
// if g: then start target search
|
2034 |
Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
|
2035 |
Navit.NavitStartupAlreadySearching = true;
|
2036 |
start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
|
2037 |
// dont use this here, already starting search, so set to "false"
|
2038 |
parsable = false;
|
2039 |
unparsable_info_box = false;
|
2040 |
}
|
2041 |
}
|
2042 |
else
|
2043 |
{
|
2044 |
Log.e("Navit", "already started search from startup intent");
|
2045 |
parsable = false;
|
2046 |
unparsable_info_box = false;
|
2047 |
}
|
2048 |
|
2049 |
if (unparsable_info_box && !searchBoxShown)
|
2050 |
{
|
2051 |
try
|
2052 |
{
|
2053 |
searchBoxShown = true;
|
2054 |
String searchString = intent_data.split("q=")[1];
|
2055 |
searchString = searchString.split("&")[0];
|
2056 |
searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
|
2057 |
Log.e("Navit", "Search String :" + searchString);
|
2058 |
executeSearch(searchString);
|
2059 |
}
|
2060 |
catch (Exception e)
|
2061 |
{
|
2062 |
// safety net
|
2063 |
try
|
2064 |
{
|
2065 |
Log.e("Navit", "problem with startup search 88 str=" + intent_data);
|
2066 |
}
|
2067 |
catch (Exception e2)
|
2068 |
{
|
2069 |
e2.printStackTrace();
|
2070 |
}
|
2071 |
}
|
2072 |
}
|
2073 |
|
2074 |
}
|
2075 |
else if ((intent_data != null) && (intent_data.substring(0, 4).equals("geo:")))
|
2076 |
{
|
2077 |
// g: geo:16.8,46.3?z=15
|
2078 |
|
2079 |
boolean parsable = false;
|
2080 |
boolean unparsable_info_box = true;
|
2081 |
|
2082 |
String tmp1;
|
2083 |
String tmp2;
|
2084 |
String tmp3;
|
2085 |
float lat1 = 0;
|
2086 |
float lon1 = 0;
|
2087 |
int zoom1 = 15;
|
2088 |
|
2089 |
try
|
2090 |
{
|
2091 |
intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
|
2092 |
}
|
2093 |
catch (Exception e1)
|
2094 |
{
|
2095 |
e1.printStackTrace();
|
2096 |
}
|
2097 |
|
2098 |
if (!Navit.NavitStartupAlreadySearching)
|
2099 |
{
|
2100 |
try
|
2101 |
{
|
2102 |
tmp1 = intent_data.split(":", 2)[1];
|
2103 |
tmp2 = tmp1.split("\\?", 2)[0];
|
2104 |
tmp3 = tmp1.split("\\?", 2)[1];
|
2105 |
lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
|
2106 |
lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
|
2107 |
zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
|
2108 |
parsable = true;
|
2109 |
}
|
2110 |
catch (Exception e4)
|
2111 |
{
|
2112 |
e4.printStackTrace();
|
2113 |
}
|
2114 |
}
|
2115 |
|
2116 |
if (parsable)
|
2117 |
{
|
2118 |
// geo: intent -> only show destination on map!
|
2119 |
|
2120 |
// set zoomlevel before we show destination
|
2121 |
int zoom_want = zoom1;
|
2122 |
//
|
2123 |
Message msg = new Message();
|
2124 |
Bundle b = new Bundle();
|
2125 |
b.putInt("Callback", 33);
|
2126 |
b.putString("s", Integer.toString(zoom_want));
|
2127 |
msg.setData(b);
|
2128 |
try
|
2129 |
{
|
2130 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2131 |
Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
|
2132 |
if ((zoom_want > 8) && (zoom_want < 17))
|
2133 |
{
|
2134 |
Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
|
2135 |
System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
|
2136 |
}
|
2137 |
}
|
2138 |
catch (Exception e)
|
2139 |
{
|
2140 |
e.printStackTrace();
|
2141 |
}
|
2142 |
if (PREF_save_zoomlevel)
|
2143 |
{
|
2144 |
setPrefs_zoomlevel();
|
2145 |
}
|
2146 |
// set nice zoomlevel before we show destination
|
2147 |
|
2148 |
try
|
2149 |
{
|
2150 |
Navit.follow_button_off();
|
2151 |
}
|
2152 |
catch (Exception e2)
|
2153 |
{
|
2154 |
e2.printStackTrace();
|
2155 |
}
|
2156 |
|
2157 |
show_geo_on_screen(lat1, lon1);
|
2158 |
}
|
2159 |
}
|
2160 |
|
2161 |
// hold all map drawing -----------
|
2162 |
Message msg = new Message();
|
2163 |
Bundle b = new Bundle();
|
2164 |
b.putInt("Callback", 69);
|
2165 |
msg.setData(b);
|
2166 |
try
|
2167 |
{
|
2168 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2169 |
}
|
2170 |
catch (Exception e)
|
2171 |
{
|
2172 |
}
|
2173 |
// hold all map drawing -----------
|
2174 |
|
2175 |
getPrefs();
|
2176 |
activatePrefs();
|
2177 |
sun_moon__mLastCalcSunMillis = -1L;
|
2178 |
|
2179 |
// paint for bitmapdrawing on map
|
2180 |
if (PREF_use_anti_aliasing)
|
2181 |
{
|
2182 |
NavitGraphics.paint_for_map_display.setAntiAlias(true);
|
2183 |
}
|
2184 |
else
|
2185 |
{
|
2186 |
NavitGraphics.paint_for_map_display.setAntiAlias(false);
|
2187 |
}
|
2188 |
if (PREF_use_map_filtering)
|
2189 |
{
|
2190 |
NavitGraphics.paint_for_map_display.setFilterBitmap(true);
|
2191 |
}
|
2192 |
else
|
2193 |
{
|
2194 |
NavitGraphics.paint_for_map_display.setFilterBitmap(false);
|
2195 |
}
|
2196 |
|
2197 |
// activate gps AFTER 3g-location
|
2198 |
NavitVehicle.turn_on_precise_provider();
|
2199 |
|
2200 |
// allow all map drawing -----------
|
2201 |
msg = new Message();
|
2202 |
b = new Bundle();
|
2203 |
b.putInt("Callback", 70);
|
2204 |
msg.setData(b);
|
2205 |
try
|
2206 |
{
|
2207 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2208 |
}
|
2209 |
catch (Exception e)
|
2210 |
{
|
2211 |
}
|
2212 |
// allow all map drawing -----------
|
2213 |
|
2214 |
NavitVehicle.set_last_known_pos_fast_provider();
|
2215 |
|
2216 |
try
|
2217 |
{
|
2218 |
//Simulate = new SimGPS(NavitVehicle.vehicle_handler_);
|
2219 |
//Simulate.start();
|
2220 |
}
|
2221 |
catch (Exception e)
|
2222 |
{
|
2223 |
e.printStackTrace();
|
2224 |
}
|
2225 |
|
2226 |
try
|
2227 |
{
|
2228 |
watchmem = new WatchMem();
|
2229 |
watchmem.start();
|
2230 |
}
|
2231 |
catch (Exception e)
|
2232 |
{
|
2233 |
e.printStackTrace();
|
2234 |
}
|
2235 |
}
|
2236 |
|
2237 |
@Override
|
2238 |
public void onPause()
|
2239 |
{
|
2240 |
System.out.println("@@ onPause @@");
|
2241 |
try
|
2242 |
{
|
2243 |
setPrefs_zoomlevel();
|
2244 |
}
|
2245 |
catch (Exception e)
|
2246 |
{
|
2247 |
e.printStackTrace();
|
2248 |
}
|
2249 |
|
2250 |
try
|
2251 |
{
|
2252 |
watchmem.stop_me();
|
2253 |
}
|
2254 |
catch (Exception e)
|
2255 |
{
|
2256 |
e.printStackTrace();
|
2257 |
}
|
2258 |
|
2259 |
try
|
2260 |
{
|
2261 |
//watchmem.join();
|
2262 |
}
|
2263 |
catch (Exception e)
|
2264 |
{
|
2265 |
e.printStackTrace();
|
2266 |
}
|
2267 |
|
2268 |
try
|
2269 |
{
|
2270 |
//Simulate.stop_me();
|
2271 |
}
|
2272 |
catch (Exception e)
|
2273 |
{
|
2274 |
e.printStackTrace();
|
2275 |
}
|
2276 |
|
2277 |
try
|
2278 |
{
|
2279 |
//Simulate.join();
|
2280 |
}
|
2281 |
catch (Exception e)
|
2282 |
{
|
2283 |
e.printStackTrace();
|
2284 |
}
|
2285 |
|
2286 |
Navit.show_mem_used();
|
2287 |
|
2288 |
super.onPause();
|
2289 |
|
2290 |
turn_off_compass();
|
2291 |
NavitVehicle.turn_off_all_providers();
|
2292 |
NavitVehicle.turn_off_sat_status();
|
2293 |
|
2294 |
Log.e("Navit", "OnPause");
|
2295 |
cwthr.NavitActivity2(-1);
|
2296 |
|
2297 |
Navit.show_mem_used();
|
2298 |
|
2299 |
try
|
2300 |
{
|
2301 |
if (wl != null)
|
2302 |
{
|
2303 |
wl.release();
|
2304 |
}
|
2305 |
}
|
2306 |
catch (Exception e)
|
2307 |
{
|
2308 |
e.printStackTrace();
|
2309 |
}
|
2310 |
|
2311 |
}
|
2312 |
|
2313 |
@Override
|
2314 |
public void onStop()
|
2315 |
{
|
2316 |
super.onStop();
|
2317 |
Log.e("Navit", "OnStop");
|
2318 |
|
2319 |
NavitVehicle.turn_off_all_providers();
|
2320 |
NavitVehicle.turn_off_sat_status();
|
2321 |
|
2322 |
cwthr.NavitActivity2(-2);
|
2323 |
System.gc();
|
2324 |
Navit.show_mem_used();
|
2325 |
|
2326 |
// save points
|
2327 |
write_map_points();
|
2328 |
}
|
2329 |
|
2330 |
@Override
|
2331 |
public void onDestroy()
|
2332 |
{
|
2333 |
super.onDestroy();
|
2334 |
Log.e("Navit", "OnDestroy");
|
2335 |
NavitActivity(-3);
|
2336 |
System.gc();
|
2337 |
Navit.show_mem_used();
|
2338 |
}
|
2339 |
|
2340 |
public void setActivityResult(int requestCode, NavitActivityResult ActivityResult)
|
2341 |
{
|
2342 |
Log.e("Navit", "setActivityResult " + requestCode);
|
2343 |
ActivityResults[requestCode] = ActivityResult;
|
2344 |
}
|
2345 |
|
2346 |
@Override
|
2347 |
public boolean onCreateOptionsMenu(Menu menu)
|
2348 |
{
|
2349 |
super.onCreateOptionsMenu(menu);
|
2350 |
//Log.e("Navit","onCreateOptionsMenu");
|
2351 |
return true;
|
2352 |
}
|
2353 |
|
2354 |
@Override
|
2355 |
public boolean onPrepareOptionsMenu(Menu menu)
|
2356 |
{
|
2357 |
super.onPrepareOptionsMenu(menu);
|
2358 |
//Log.e("Navit","onPrepareOptionsMenu");
|
2359 |
// this gets called every time the menu is opened!!
|
2360 |
// change menu items here!
|
2361 |
menu.clear();
|
2362 |
|
2363 |
// group-id,item-id,sort order number
|
2364 |
// menu.add(1, 1, 100, get_text("zoom in")); //leave out
|
2365 |
// menu.add(1, 2, 200, get_text("zoom out")); //leave out
|
2366 |
|
2367 |
menu.add(1, 6, 300, get_text("address search (online)")); //TRANS
|
2368 |
menu.add(1, 7, 310, get_text("address search (offline)")); //TRANS
|
2369 |
if (NavitGraphics.CallbackDestinationValid2() > 0)
|
2370 |
{
|
2371 |
menu.add(1, 9, 450, get_text("Stop Navigation")); //TRANS
|
2372 |
menu.add(1, 11, 455, get_text("Zoom to Route")); //TRANS
|
2373 |
//. TRANSLATORS: it means: "show current target in google maps"
|
2374 |
//. TRANSLATORS: please keep this text short, to fit in the android menu!
|
2375 |
menu.add(1, 15, 457, get_text("Target in gmaps")); //TRANS
|
2376 |
}
|
2377 |
//. TRANSLATORS: text to translate is: exit ZANavi
|
2378 |
menu.add(1, 99, 480, get_text("exit navit")); //TRANS
|
2379 |
menu.add(1, 5, 485, get_text("toggle POI")); //TRANS
|
2380 |
menu.add(1, 10, 490, get_text("Settings")); //TRANS
|
2381 |
|
2382 |
//menu.add(1, 18, 491, get_text("Coord Dialog 2")); //TRANS
|
2383 |
menu.add(1, 19, 492, get_text("Coord Dialog")); //TRANS
|
2384 |
|
2385 |
if (Navit_Announcer == true)
|
2386 |
{
|
2387 |
menu.add(1, 12, 496, get_text("Announcer Off")); //TRANS
|
2388 |
}
|
2389 |
else
|
2390 |
{
|
2391 |
menu.add(1, 13, 495, get_text("Announcer On")); //TRANS
|
2392 |
}
|
2393 |
|
2394 |
menu.add(1, 14, 497, get_text("Recent destinations")); //TRANS
|
2395 |
menu.add(1, 21, 498, get_text("add Traffic block")); //TRANS
|
2396 |
menu.add(1, 22, 499, get_text("clear Traffic blocks")); //TRANS
|
2397 |
menu.add(1, 3, 500, get_text("download maps")); //TRANS
|
2398 |
menu.add(1, 8, 505, get_text("delete maps")); //TRANS
|
2399 |
menu.add(1, 17, 508, get_text("show Maps age")); //TRANS
|
2400 |
menu.add(1, 20, 510, get_text("convert GPX file")); //TRANS
|
2401 |
menu.add(1, 23, 511, get_text("clear GPX map")); //TRANS
|
2402 |
|
2403 |
if (PREF_enable_debug_functions)
|
2404 |
{
|
2405 |
menu.add(1, 88, 9001, "--");
|
2406 |
menu.add(1, 601, 9001, get_text("Demo Vehicle") + " [normal]"); //TRANS
|
2407 |
menu.add(1, 604, 9002, get_text("Demo Vehicle") + " [fast]"); //TRANS
|
2408 |
menu.add(1, 602, 9003, get_text("Speech Texts")); //TRANS
|
2409 |
menu.add(1, 603, 9004, get_text("Nav. Commands")); //TRANS
|
2410 |
menu.add(1, 605, 9005, get_text("toggle Routegraph")); //TRANS
|
2411 |
}
|
2412 |
|
2413 |
menu.add(1, 88, 11000, "--");
|
2414 |
menu.add(1, 16, 11001, get_text("online Help")); //TRANS
|
2415 |
|
2416 |
// menu.add(1, 88, 800, "--");
|
2417 |
return true;
|
2418 |
}
|
2419 |
|
2420 |
// callback id gets set here when called from NavitGraphics
|
2421 |
/*
|
2422 |
* public static void setKeypressCallback(int kp_cb_id, NavitGraphics ng)
|
2423 |
* {
|
2424 |
* //Log.e("Navit", "setKeypressCallback -> id1=" + kp_cb_id);
|
2425 |
* //Log.e("Navit", "setKeypressCallback -> ng=" + String.valueOf(ng));
|
2426 |
* //N_KeypressCallbackID = kp_cb_id;
|
2427 |
* N_NavitGraphics = ng;
|
2428 |
* }
|
2429 |
*/
|
2430 |
|
2431 |
/*
|
2432 |
* public static void setMotionCallback(int mo_cb_id, NavitGraphics ng)
|
2433 |
* {
|
2434 |
* //Log.e("Navit", "setKeypressCallback -> id2=" + mo_cb_id);
|
2435 |
* //Log.e("Navit", "setKeypressCallback -> ng=" + String.valueOf(ng));
|
2436 |
* //N_MotionCallbackID = mo_cb_id;
|
2437 |
* N_NavitGraphics = ng;
|
2438 |
* }
|
2439 |
*/
|
2440 |
|
2441 |
//public native void KeypressCallback(int id, String s);
|
2442 |
|
2443 |
public void start_targetsearch_from_intent(String target_address)
|
2444 |
{
|
2445 |
Navit_last_address_partial_match = false;
|
2446 |
Navit_last_address_search_string = target_address;
|
2447 |
Navit_last_address_hn_string = "";
|
2448 |
|
2449 |
// ----------- CONFIG ---------
|
2450 |
// ----------- CONFIG ---------
|
2451 |
// ----------- CONFIG ---------
|
2452 |
Boolean use_online_searchmode_here = true;
|
2453 |
Boolean hide_duplicates_searchmode_here = false;
|
2454 |
// ----------- CONFIG ---------
|
2455 |
// ----------- CONFIG ---------
|
2456 |
// ----------- CONFIG ---------
|
2457 |
|
2458 |
int dialog_num_;
|
2459 |
|
2460 |
if (use_online_searchmode_here)
|
2461 |
{
|
2462 |
dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG;
|
2463 |
Navit.use_index_search = false;
|
2464 |
}
|
2465 |
else
|
2466 |
{
|
2467 |
dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE;
|
2468 |
Navit.use_index_search = Navit.allow_use_index_search();
|
2469 |
}
|
2470 |
|
2471 |
// clear results
|
2472 |
Navit.NavitAddressResultList_foundItems.clear();
|
2473 |
Navit.Navit_Address_Result_double_index.clear();
|
2474 |
Navit.NavitSearchresultBarIndex = -1;
|
2475 |
Navit.NavitSearchresultBar_title = "";
|
2476 |
Navit.NavitSearchresultBar_text = "";
|
2477 |
search_hide_duplicates = false;
|
2478 |
|
2479 |
if (Navit_last_address_search_string.equals(""))
|
2480 |
{
|
2481 |
// empty search string entered
|
2482 |
Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
|
2483 |
}
|
2484 |
else
|
2485 |
{
|
2486 |
// show dialog
|
2487 |
try
|
2488 |
{
|
2489 |
Log.e("Navit", "call-11: (0)num " + dialog_num_);
|
2490 |
}
|
2491 |
catch (Exception e)
|
2492 |
{
|
2493 |
e.printStackTrace();
|
2494 |
}
|
2495 |
|
2496 |
if (hide_duplicates_searchmode_here)
|
2497 |
{
|
2498 |
search_hide_duplicates = true;
|
2499 |
// hide duplicates when searching
|
2500 |
// hide duplicates when searching
|
2501 |
Message msg22 = new Message();
|
2502 |
Bundle b22 = new Bundle();
|
2503 |
b22.putInt("Callback", 45);
|
2504 |
msg22.setData(b22);
|
2505 |
N_NavitGraphics.callback_handler.sendMessage(msg22);
|
2506 |
// hide duplicates when searching
|
2507 |
// hide duplicates when searching
|
2508 |
}
|
2509 |
|
2510 |
Message msg = progress_handler.obtainMessage();
|
2511 |
Bundle b = new Bundle();
|
2512 |
msg.what = 11;
|
2513 |
b.putInt("dialog_num", dialog_num_);
|
2514 |
msg.setData(b);
|
2515 |
progress_handler.sendMessage(msg);
|
2516 |
}
|
2517 |
}
|
2518 |
|
2519 |
@Override
|
2520 |
public boolean onOptionsItemSelected(MenuItem item)
|
2521 |
{
|
2522 |
// Handle item selection
|
2523 |
switch (item.getItemId())
|
2524 |
{
|
2525 |
case 1:
|
2526 |
// zoom in
|
2527 |
Message msg = new Message();
|
2528 |
Bundle b = new Bundle();
|
2529 |
b.putInt("Callback", 1);
|
2530 |
msg.setData(b);
|
2531 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2532 |
// if we zoom, hide the bubble
|
2533 |
if (N_NavitGraphics.NavitAOverlay != null)
|
2534 |
{
|
2535 |
N_NavitGraphics.NavitAOverlay.hide_bubble();
|
2536 |
}
|
2537 |
Log.e("Navit", "onOptionsItemSelected -> zoom in");
|
2538 |
break;
|
2539 |
case 2:
|
2540 |
// zoom out
|
2541 |
msg = new Message();
|
2542 |
b = new Bundle();
|
2543 |
b.putInt("Callback", 2);
|
2544 |
msg.setData(b);
|
2545 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2546 |
// if we zoom, hide the bubble
|
2547 |
if (N_NavitGraphics.NavitAOverlay != null)
|
2548 |
{
|
2549 |
N_NavitGraphics.NavitAOverlay.hide_bubble();
|
2550 |
}
|
2551 |
Log.e("Navit", "onOptionsItemSelected -> zoom out");
|
2552 |
break;
|
2553 |
case 3:
|
2554 |
// map download menu
|
2555 |
Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
|
2556 |
this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
|
2557 |
break;
|
2558 |
case 5:
|
2559 |
// toggle the normal POI layers (to avoid double POIs)
|
2560 |
msg = new Message();
|
2561 |
b = new Bundle();
|
2562 |
b.putInt("Callback", 5);
|
2563 |
b.putString("cmd", "toggle_layer(\"POI Symbols\");");
|
2564 |
msg.setData(b);
|
2565 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2566 |
// toggle full POI icons on/off
|
2567 |
msg = new Message();
|
2568 |
b = new Bundle();
|
2569 |
b.putInt("Callback", 5);
|
2570 |
b.putString("cmd", "toggle_layer(\"Android-POI-Icons-full\");");
|
2571 |
msg.setData(b);
|
2572 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2573 |
break;
|
2574 |
case 6:
|
2575 |
// ok startup address search activity (online google maps search)
|
2576 |
Navit.use_index_search = false;
|
2577 |
Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
|
2578 |
search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
|
2579 |
search_intent.putExtra("address_string", Navit_last_address_search_string);
|
2580 |
//search_intent.putExtra("hn_string", Navit_last_address_hn_string);
|
2581 |
search_intent.putExtra("type", "online");
|
2582 |
String pm_temp = "0";
|
2583 |
if (Navit_last_address_partial_match)
|
2584 |
{
|
2585 |
pm_temp = "1";
|
2586 |
}
|
2587 |
search_intent.putExtra("partial_match", pm_temp);
|
2588 |
this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
|
2589 |
break;
|
2590 |
case 7:
|
2591 |
// ok startup address search activity (offline binfile search)
|
2592 |
Navit.use_index_search = Navit.allow_use_index_search();
|
2593 |
Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
|
2594 |
search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
|
2595 |
search_intent2.putExtra("address_string", Navit_last_address_search_string);
|
2596 |
search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
|
2597 |
search_intent2.putExtra("type", "offline");
|
2598 |
search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);
|
2599 |
|
2600 |
String pm_temp2 = "0";
|
2601 |
if (Navit_last_address_partial_match)
|
2602 |
{
|
2603 |
pm_temp2 = "1";
|
2604 |
}
|
2605 |
|
2606 |
search_intent2.putExtra("partial_match", pm_temp2);
|
2607 |
this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
|
2608 |
break;
|
2609 |
case 8:
|
2610 |
// map delete menu
|
2611 |
Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class);
|
2612 |
this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id);
|
2613 |
break;
|
2614 |
case 9:
|
2615 |
// stop navigation (this menu should only appear when navigation is actually on!)
|
2616 |
Message msg2 = new Message();
|
2617 |
Bundle b2 = new Bundle();
|
2618 |
b2.putInt("Callback", 7);
|
2619 |
msg2.setData(b2);
|
2620 |
N_NavitGraphics.callback_handler.sendMessage(msg2);
|
2621 |
break;
|
2622 |
case 10:
|
2623 |
// open settings menu
|
2624 |
Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
|
2625 |
startActivity(settingsActivity);
|
2626 |
break;
|
2627 |
case 11:
|
2628 |
//zoom_to_route
|
2629 |
zoom_to_route();
|
2630 |
break;
|
2631 |
case 12:
|
2632 |
// announcer off
|
2633 |
Navit_Announcer = false;
|
2634 |
msg = new Message();
|
2635 |
b = new Bundle();
|
2636 |
b.putInt("Callback", 34);
|
2637 |
msg.setData(b);
|
2638 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2639 |
break;
|
2640 |
case 13:
|
2641 |
// announcer on
|
2642 |
Navit_Announcer = true;
|
2643 |
msg = new Message();
|
2644 |
b = new Bundle();
|
2645 |
b.putInt("Callback", 35);
|
2646 |
msg.setData(b);
|
2647 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2648 |
break;
|
2649 |
case 14:
|
2650 |
// show recent destination list
|
2651 |
Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
|
2652 |
this.startActivityForResult(i2, Navit.NavitRecentDest_id);
|
2653 |
break;
|
2654 |
case 15:
|
2655 |
// show current target on googlemaps
|
2656 |
String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1);
|
2657 |
// Log.e("Navit", "got target 1: "+current_target_string);
|
2658 |
if (current_target_string.equals("x:x"))
|
2659 |
{
|
2660 |
Log.e("Navit", "no target set!");
|
2661 |
}
|
2662 |
else
|
2663 |
{
|
2664 |
try
|
2665 |
{
|
2666 |
String tmp[] = current_target_string.split(":", 2);
|
2667 |
googlemaps_show(tmp[0], tmp[1], "ZANavi Target");
|
2668 |
}
|
2669 |
catch (Exception e)
|
2670 |
{
|
2671 |
e.printStackTrace();
|
2672 |
Log.e("Navit", "problem with target!");
|
2673 |
}
|
2674 |
}
|
2675 |
break;
|
2676 |
case 16:
|
2677 |
// show online manual
|
2678 |
Log.e("Navit", "user wants online help, show the website lang=" + NavitTextTranslations.main_language.toLowerCase());
|
2679 |
// URL to ZANavi Manual (in english language)
|
2680 |
String url = "http://zanavi.cc/index.php/Manual";
|
2681 |
if (NavitTextTranslations.main_language.toLowerCase().equals("de"))
|
2682 |
{
|
2683 |
// show german manual
|
2684 |
url = "http://zanavi.cc/index.php/Manual/de";
|
2685 |
}
|
2686 |
|
2687 |
Intent i = new Intent(Intent.ACTION_VIEW);
|
2688 |
i.setData(Uri.parse(url));
|
2689 |
startActivity(i);
|
2690 |
break;
|
2691 |
case 17:
|
2692 |
// show age of maps (online)
|
2693 |
Intent i3 = new Intent(Intent.ACTION_VIEW);
|
2694 |
i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL));
|
2695 |
startActivity(i3);
|
2696 |
break;
|
2697 |
case 18:
|
2698 |
Intent intent_latlon = new Intent(Intent.ACTION_MAIN);
|
2699 |
//intent_latlon.setAction("android.intent.action.POINTPICK");
|
2700 |
intent_latlon.setPackage("com.cruthu.latlongcalc1");
|
2701 |
intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain");
|
2702 |
//intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick");
|
2703 |
try
|
2704 |
{
|
2705 |
startActivity(intent_latlon);
|
2706 |
}
|
2707 |
catch (Exception e88)
|
2708 |
{
|
2709 |
e88.printStackTrace();
|
2710 |
// show install page
|
2711 |
try
|
2712 |
{
|
2713 |
// String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1";
|
2714 |
String urlx = "market://details?id=com.cruthu.latlongcalc1";
|
2715 |
Intent ix = new Intent(Intent.ACTION_VIEW);
|
2716 |
ix.setData(Uri.parse(urlx));
|
2717 |
startActivity(ix);
|
2718 |
}
|
2719 |
catch (Exception ex)
|
2720 |
{
|
2721 |
ex.printStackTrace();
|
2722 |
}
|
2723 |
}
|
2724 |
break;
|
2725 |
case 19:
|
2726 |
// GeoCoordEnterDialog
|
2727 |
Intent it001 = new Intent(this, GeoCoordEnterDialog.class);
|
2728 |
this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id);
|
2729 |
break;
|
2730 |
case 20:
|
2731 |
// convert GPX file
|
2732 |
Intent intent77 = new Intent(getBaseContext(), FileDialog.class);
|
2733 |
File a = new File(MAP_FILENAME_PATH + "/../");
|
2734 |
try
|
2735 |
{
|
2736 |
// convert the "/../" in the path to normal absolut dir
|
2737 |
intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath());
|
2738 |
//can user select directories or not
|
2739 |
intent77.putExtra(FileDialog.CAN_SELECT_DIR, false);
|
2740 |
// disable the "new" button
|
2741 |
intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
|
2742 |
//alternatively you can set file filter
|
2743 |
//intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" });
|
2744 |
startActivityForResult(intent77, Navit.NavitGPXConvChooser_id);
|
2745 |
}
|
2746 |
catch (IOException e1)
|
2747 |
{
|
2748 |
e1.printStackTrace();
|
2749 |
}
|
2750 |
break;
|
2751 |
case 21:
|
2752 |
// add traffic block (like blocked road, or construction site) at current location of crosshair
|
2753 |
try
|
2754 |
{
|
2755 |
String traffic = NavitGraphics.CallbackGeoCalc(7, (int) (NavitGraphics.mCanvasWidth / 2), (int) (NavitGraphics.mCanvasHeight / 2));
|
2756 |
// System.out.println("traffic=" + traffic);
|
2757 |
File traffic_file_dir = new File(MAP_FILENAME_PATH);
|
2758 |
traffic_file_dir.mkdirs();
|
2759 |
File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
|
2760 |
FileOutputStream fOut = null;
|
2761 |
OutputStreamWriter osw = null;
|
2762 |
try
|
2763 |
{
|
2764 |
fOut = new FileOutputStream(traffic_file, true);
|
2765 |
osw = new OutputStreamWriter(fOut);
|
2766 |
osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header
|
2767 |
osw.write(traffic); // item coordinates
|
2768 |
osw.close();
|
2769 |
fOut.close();
|
2770 |
}
|
2771 |
catch (Exception ef)
|
2772 |
{
|
2773 |
ef.printStackTrace();
|
2774 |
}
|
2775 |
|
2776 |
// update route, if a route is set
|
2777 |
msg = new Message();
|
2778 |
b = new Bundle();
|
2779 |
b.putInt("Callback", 73);
|
2780 |
msg.setData(b);
|
2781 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2782 |
|
2783 |
// draw map no-async
|
2784 |
msg = new Message();
|
2785 |
b = new Bundle();
|
2786 |
b.putInt("Callback", 64);
|
2787 |
msg.setData(b);
|
2788 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2789 |
}
|
2790 |
catch (Exception e)
|
2791 |
{
|
2792 |
e.printStackTrace();
|
2793 |
}
|
2794 |
break;
|
2795 |
case 22:
|
2796 |
// clear all traffic blocks
|
2797 |
try
|
2798 |
{
|
2799 |
File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
|
2800 |
traffic_file.delete();
|
2801 |
|
2802 |
// update route, if a route is set
|
2803 |
msg = new Message();
|
2804 |
b = new Bundle();
|
2805 |
b.putInt("Callback", 73);
|
2806 |
msg.setData(b);
|
2807 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2808 |
|
2809 |
// draw map no-async
|
2810 |
msg = new Message();
|
2811 |
b = new Bundle();
|
2812 |
b.putInt("Callback", 64);
|
2813 |
msg.setData(b);
|
2814 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2815 |
}
|
2816 |
catch (Exception e)
|
2817 |
{
|
2818 |
|
2819 |
}
|
2820 |
break;
|
2821 |
case 23:
|
2822 |
// clear all GPX maps
|
2823 |
try
|
2824 |
{
|
2825 |
File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt");
|
2826 |
gpx_file.delete();
|
2827 |
|
2828 |
// draw map no-async
|
2829 |
msg = new Message();
|
2830 |
b = new Bundle();
|
2831 |
b.putInt("Callback", 64);
|
2832 |
msg.setData(b);
|
2833 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2834 |
}
|
2835 |
catch (Exception e)
|
2836 |
{
|
2837 |
|
2838 |
}
|
2839 |
break;
|
2840 |
case 88:
|
2841 |
// dummy entry, just to make "breaks" in the menu
|
2842 |
break;
|
2843 |
case 601:
|
2844 |
// DEBUG: activate demo vehicle and set position to position to screen center
|
2845 |
|
2846 |
Navit.DemoVehicle = true;
|
2847 |
|
2848 |
msg = new Message();
|
2849 |
b = new Bundle();
|
2850 |
b.putInt("Callback", 52);
|
2851 |
b.putString("s", "45"); // speed in km/h of Demo-Vehicle
|
2852 |
msg.setData(b);
|
2853 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2854 |
|
2855 |
msg = new Message();
|
2856 |
b = new Bundle();
|
2857 |
b.putInt("Callback", 51);
|
2858 |
b.putInt("x", (int) (Navit.NG__map_main.view.getWidth() / 2));
|
2859 |
b.putInt("y", (int) (Navit.NG__map_main.view.getHeight() / 2));
|
2860 |
msg.setData(b);
|
2861 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2862 |
|
2863 |
break;
|
2864 |
case 602:
|
2865 |
// DEBUG: toggle textview with spoken and translated string (to help with translation)
|
2866 |
try
|
2867 |
{
|
2868 |
if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE)
|
2869 |
{
|
2870 |
NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE);
|
2871 |
NavitGraphics.NavitMsgTv2_.setEnabled(false);
|
2872 |
}
|
2873 |
else
|
2874 |
{
|
2875 |
NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
|
2876 |
NavitGraphics.NavitMsgTv2_.setEnabled(true);
|
2877 |
}
|
2878 |
}
|
2879 |
catch (Exception e)
|
2880 |
{
|
2881 |
e.printStackTrace();
|
2882 |
}
|
2883 |
break;
|
2884 |
case 603:
|
2885 |
// DEBUG: show all possible navigation commands (also translated)
|
2886 |
NavitGraphics.generate_all_speech_commands();
|
2887 |
break;
|
2888 |
case 604:
|
2889 |
// DEBUG: activate FAST driving demo vehicle and set position to screen center
|
2890 |
|
2891 |
Navit.DemoVehicle = true;
|
2892 |
|
2893 |
msg = new Message();
|
2894 |
b = new Bundle();
|
2895 |
b.putInt("Callback", 52);
|
2896 |
b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle
|
2897 |
msg.setData(b);
|
2898 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2899 |
|
2900 |
msg = new Message();
|
2901 |
b = new Bundle();
|
2902 |
b.putInt("Callback", 51);
|
2903 |
b.putInt("x", (int) (Navit.NG__map_main.view.getWidth() / 2));
|
2904 |
|
2905 |
b.putInt("y", (int) (Navit.NG__map_main.view.getHeight() / 2));
|
2906 |
msg.setData(b);
|
2907 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2908 |
|
2909 |
break;
|
2910 |
case 605:
|
2911 |
// DEBUG: toggle Routgraph on/off
|
2912 |
msg = new Message();
|
2913 |
b = new Bundle();
|
2914 |
b.putInt("Callback", 71);
|
2915 |
Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled;
|
2916 |
b.putString("s", "" + Navit.Routgraph_enabled);
|
2917 |
msg.setData(b);
|
2918 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2919 |
break;
|
2920 |
case 99:
|
2921 |
// exit
|
2922 |
this.onPause();
|
2923 |
this.onStop();
|
2924 |
this.exit();
|
2925 |
//msg = new Message();
|
2926 |
//b = new Bundle();
|
2927 |
//b.putInt("Callback", 5);
|
2928 |
//b.putString("cmd", "quit();");
|
2929 |
//msg.setData(b);
|
2930 |
//N_NavitGraphics.callback_handler.sendMessage(msg);
|
2931 |
break;
|
2932 |
}
|
2933 |
return true;
|
2934 |
}
|
2935 |
|
2936 |
//private class PickerListener implements NumberPicker.ValueChangeListener
|
2937 |
//{
|
2938 |
// @Override
|
2939 |
// public void onNumberPickerValueChange(NumberPicker picker, int value)
|
2940 |
// {
|
2941 |
//if (picker.getId() == R.id.SpinRate)
|
2942 |
//{
|
2943 |
// mBeatsPerMin = value;
|
2944 |
//}
|
2945 |
// return;
|
2946 |
// }
|
2947 |
//}
|
2948 |
|
2949 |
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
2950 |
{
|
2951 |
//Log.e("Navit", "onActivityResult");
|
2952 |
switch (requestCode)
|
2953 |
{
|
2954 |
case Navit.NavitGPXConvChooser_id:
|
2955 |
try
|
2956 |
{
|
2957 |
if (resultCode == Activity.RESULT_OK)
|
2958 |
{
|
2959 |
String in_ = data.getStringExtra(FileDialog.RESULT_PATH);
|
2960 |
String out_ = MAP_FILENAME_PATH + "/gpxtracks.txt";
|
2961 |
MainFrame.do_conversion(in_, out_);
|
2962 |
|
2963 |
// draw map no-async
|
2964 |
Message msg = new Message();
|
2965 |
Bundle b = new Bundle();
|
2966 |
b.putInt("Callback", 64);
|
2967 |
msg.setData(b);
|
2968 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2969 |
}
|
2970 |
}
|
2971 |
catch (Exception e77)
|
2972 |
{
|
2973 |
e77.printStackTrace();
|
2974 |
}
|
2975 |
break;
|
2976 |
case Navit.NavitDeleteSecSelectMap_id:
|
2977 |
try
|
2978 |
{
|
2979 |
if (resultCode == Activity.RESULT_OK)
|
2980 |
{
|
2981 |
// remove all sdcard maps
|
2982 |
Message msg = new Message();
|
2983 |
Bundle b = new Bundle();
|
2984 |
b.putInt("Callback", 19);
|
2985 |
msg.setData(b);
|
2986 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
2987 |
|
2988 |
Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
2989 |
String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
|
2990 |
Log.d("Navit", "delete map full line=" + map_full_line);
|
2991 |
|
2992 |
String del_map_name = MAP_FILENAME_PATH + map_full_line.split(":", 2)[0];
|
2993 |
System.out.println("del map file :" + del_map_name);
|
2994 |
// remove from cat file
|
2995 |
NavitMapDownloader.remove_from_cat_file(map_full_line);
|
2996 |
// remove from disk
|
2997 |
File del_map_name_file = new File(del_map_name);
|
2998 |
del_map_name_file.delete();
|
2999 |
for (int jkl = 1; jkl < 51; jkl++)
|
3000 |
{
|
3001 |
File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl));
|
3002 |
del_map_name_fileSplit.delete();
|
3003 |
}
|
3004 |
// also remove index file
|
3005 |
File del_map_name_file_idx = new File(del_map_name + ".idx");
|
3006 |
del_map_name_file_idx.delete();
|
3007 |
// remove also any MD5 files for this map that may be on disk
|
3008 |
try
|
3009 |
{
|
3010 |
String tmp = map_full_line.split(":", 2)[1];
|
3011 |
if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN))
|
3012 |
{
|
3013 |
tmp = tmp.replace("*", "");
|
3014 |
tmp = tmp.replace("/", "");
|
3015 |
tmp = tmp.replace("\\", "");
|
3016 |
tmp = tmp.replace(" ", "");
|
3017 |
tmp = tmp.replace(">", "");
|
3018 |
tmp = tmp.replace("<", "");
|
3019 |
System.out.println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
|
3020 |
File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5");
|
3021 |
md5_final_filename.delete();
|
3022 |
}
|
3023 |
}
|
3024 |
catch (Exception e)
|
3025 |
{
|
3026 |
e.printStackTrace();
|
3027 |
}
|
3028 |
|
3029 |
// remove map, and zoom out
|
3030 |
// ***** onStop();
|
3031 |
// ***** onCreate(getIntent().getExtras());
|
3032 |
|
3033 |
// add all sdcard maps
|
3034 |
msg = new Message();
|
3035 |
b = new Bundle();
|
3036 |
b.putInt("Callback", 20);
|
3037 |
msg.setData(b);
|
3038 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3039 |
|
3040 |
zoom_out_full();
|
3041 |
}
|
3042 |
}
|
3043 |
catch (Exception e)
|
3044 |
{
|
3045 |
Log.d("Navit", "error on onActivityResult 3");
|
3046 |
e.printStackTrace();
|
3047 |
}
|
3048 |
break;
|
3049 |
case Navit.NavitDownloaderPriSelectMap_id:
|
3050 |
try
|
3051 |
{
|
3052 |
if (resultCode == Activity.RESULT_OK)
|
3053 |
{
|
3054 |
try
|
3055 |
{
|
3056 |
Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
3057 |
// set map id to download
|
3058 |
Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
|
3059 |
// show the map download progressbar, and download the map
|
3060 |
if (Navit.download_map_id > -1)
|
3061 |
{
|
3062 |
showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG);
|
3063 |
}
|
3064 |
}
|
3065 |
catch (NumberFormatException e)
|
3066 |
{
|
3067 |
Log.d("Navit", "NumberFormatException selected_id");
|
3068 |
}
|
3069 |
}
|
3070 |
else
|
3071 |
{
|
3072 |
// user pressed back key
|
3073 |
}
|
3074 |
}
|
3075 |
catch (Exception e)
|
3076 |
{
|
3077 |
Log.d("Navit", "error on onActivityResult");
|
3078 |
e.printStackTrace();
|
3079 |
}
|
3080 |
break;
|
3081 |
case Navit.NavitDownloaderSecSelectMap_id:
|
3082 |
try
|
3083 |
{
|
3084 |
if (resultCode == Activity.RESULT_OK)
|
3085 |
{
|
3086 |
try
|
3087 |
{
|
3088 |
Log.d("Navit", "SEC id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
3089 |
// set map id to download
|
3090 |
Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer.parseInt(data.getStringExtra("selected_id"))];
|
3091 |
// show the map download progressbar, and download the map
|
3092 |
if (Navit.download_map_id > -1)
|
3093 |
{
|
3094 |
showDialog(Navit.MAPDOWNLOAD_SEC_DIALOG);
|
3095 |
}
|
3096 |
}
|
3097 |
catch (NumberFormatException e)
|
3098 |
{
|
3099 |
Log.d("Navit", "NumberFormatException selected_id");
|
3100 |
}
|
3101 |
}
|
3102 |
else
|
3103 |
{
|
3104 |
// user pressed back key
|
3105 |
}
|
3106 |
}
|
3107 |
catch (Exception e)
|
3108 |
{
|
3109 |
Log.d("Navit", "error on onActivityResult");
|
3110 |
e.printStackTrace();
|
3111 |
}
|
3112 |
break;
|
3113 |
case NavitAddressSearch_id_online:
|
3114 |
case NavitAddressSearch_id_offline:
|
3115 |
try
|
3116 |
{
|
3117 |
if (resultCode == Activity.RESULT_OK)
|
3118 |
{
|
3119 |
try
|
3120 |
{
|
3121 |
String addr = data.getStringExtra("address_string");
|
3122 |
String hn = "";
|
3123 |
try
|
3124 |
{
|
3125 |
// only from offline mask!
|
3126 |
hn = data.getStringExtra("hn_string");
|
3127 |
}
|
3128 |
catch (Exception e)
|
3129 |
{
|
3130 |
hn = "";
|
3131 |
}
|
3132 |
|
3133 |
Boolean partial_match = false;
|
3134 |
try
|
3135 |
{
|
3136 |
// only from offline mask!
|
3137 |
partial_match = data.getStringExtra("partial_match").equals("1");
|
3138 |
}
|
3139 |
catch (Exception e)
|
3140 |
{
|
3141 |
}
|
3142 |
|
3143 |
Message msg2 = new Message();
|
3144 |
Bundle b2 = new Bundle();
|
3145 |
b2.putInt("Callback", 44);
|
3146 |
msg2.setData(b2);
|
3147 |
N_NavitGraphics.callback_handler.sendMessage(msg2);
|
3148 |
|
3149 |
if (requestCode == NavitAddressSearch_id_offline)
|
3150 |
{
|
3151 |
search_hide_duplicates = false;
|
3152 |
try
|
3153 |
{
|
3154 |
Boolean hide_dup = data.getStringExtra("hide_dup").equals("1");
|
3155 |
if (hide_dup)
|
3156 |
{
|
3157 |
search_hide_duplicates = true;
|
3158 |
Message msg = new Message();
|
3159 |
Bundle b = new Bundle();
|
3160 |
b.putInt("Callback", 45);
|
3161 |
msg.setData(b);
|
3162 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3163 |
}
|
3164 |
}
|
3165 |
catch (Exception e)
|
3166 |
{
|
3167 |
}
|
3168 |
Navit.use_index_search = Navit.allow_use_index_search();
|
3169 |
}
|
3170 |
else
|
3171 |
{
|
3172 |
Navit.use_index_search = false;
|
3173 |
}
|
3174 |
|
3175 |
Navit_last_address_partial_match = partial_match;
|
3176 |
Navit_last_address_search_string = addr;
|
3177 |
Navit_last_address_hn_string = hn;
|
3178 |
|
3179 |
try
|
3180 |
{
|
3181 |
// only from offline mask!
|
3182 |
Navit_last_address_full_file_search = data.getStringExtra("full_file_search").equals("1");
|
3183 |
}
|
3184 |
catch (Exception e)
|
3185 |
{
|
3186 |
Navit_last_address_full_file_search = false;
|
3187 |
}
|
3188 |
|
3189 |
try
|
3190 |
{
|
3191 |
// only from offline mask!
|
3192 |
Navit_last_address_search_country_iso2_string = data.getStringExtra("address_country_iso2");
|
3193 |
|
3194 |
Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3);
|
3195 |
// System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags);
|
3196 |
Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL*
|
3197 |
PREF_search_country = Navit_last_address_search_country_id;
|
3198 |
setPrefs_search_country();
|
3199 |
}
|
3200 |
catch (Exception e)
|
3201 |
{
|
3202 |
|
3203 |
}
|
3204 |
|
3205 |
// clear results
|
3206 |
Navit.NavitAddressResultList_foundItems.clear();
|
3207 |
Navit.Navit_Address_Result_double_index.clear();
|
3208 |
Navit.NavitSearchresultBarIndex = -1;
|
3209 |
Navit.NavitSearchresultBar_title = "";
|
3210 |
Navit.NavitSearchresultBar_text = "";
|
3211 |
Navit.search_results_towns = 0;
|
3212 |
Navit.search_results_streets = 0;
|
3213 |
Navit.search_results_streets_hn = 0;
|
3214 |
|
3215 |
if (addr.equals(""))
|
3216 |
{
|
3217 |
// empty search string entered
|
3218 |
Toast.makeText(getApplicationContext(), Navit.get_text("No search string entered"), Toast.LENGTH_LONG).show(); //TRANS
|
3219 |
}
|
3220 |
else
|
3221 |
{
|
3222 |
if (requestCode == NavitAddressSearch_id_online)
|
3223 |
{
|
3224 |
// online googlemaps search
|
3225 |
try
|
3226 |
{
|
3227 |
Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG);
|
3228 |
}
|
3229 |
catch (Exception e)
|
3230 |
{
|
3231 |
e.printStackTrace();
|
3232 |
}
|
3233 |
|
3234 |
System.out.println("online googlemaps search");
|
3235 |
Message msg = progress_handler.obtainMessage();
|
3236 |
Bundle b = new Bundle();
|
3237 |
msg.what = 11;
|
3238 |
b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
|
3239 |
msg.setData(b);
|
3240 |
progress_handler.sendMessage(msg);
|
3241 |
}
|
3242 |
else if (requestCode == NavitAddressSearch_id_offline)
|
3243 |
{
|
3244 |
// offline binfile search
|
3245 |
try
|
3246 |
{
|
3247 |
Log.e("Navit", "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
|
3248 |
}
|
3249 |
catch (Exception e)
|
3250 |
{
|
3251 |
e.printStackTrace();
|
3252 |
}
|
3253 |
|
3254 |
// show dialog, and start search for the results
|
3255 |
// make it indirect, to give our activity a chance to startup
|
3256 |
// (remember we come straight from another activity and ours is still paused!)
|
3257 |
Message msg = progress_handler.obtainMessage();
|
3258 |
Bundle b = new Bundle();
|
3259 |
msg.what = 11;
|
3260 |
b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
|
3261 |
msg.setData(b);
|
3262 |
progress_handler.sendMessage(msg);
|
3263 |
}
|
3264 |
}
|
3265 |
}
|
3266 |
catch (NumberFormatException e)
|
3267 |
{
|
3268 |
Log.d("Navit", "NumberFormatException selected_id");
|
3269 |
}
|
3270 |
}
|
3271 |
else
|
3272 |
{
|
3273 |
// user pressed back key
|
3274 |
}
|
3275 |
}
|
3276 |
catch (Exception e)
|
3277 |
{
|
3278 |
Log.d("Navit", "error on onActivityResult");
|
3279 |
e.printStackTrace();
|
3280 |
}
|
3281 |
break;
|
3282 |
case Navit.NavitAddressResultList_id:
|
3283 |
try
|
3284 |
{
|
3285 |
if (resultCode == Activity.RESULT_OK)
|
3286 |
{
|
3287 |
try
|
3288 |
{
|
3289 |
if (data.getStringExtra("what").equals("view"))
|
3290 |
{
|
3291 |
// get the coords for the destination
|
3292 |
int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
|
3293 |
|
3294 |
// set nice zoomlevel before we show destination
|
3295 |
int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
|
3296 |
//
|
3297 |
Message msg = new Message();
|
3298 |
Bundle b = new Bundle();
|
3299 |
b.putInt("Callback", 33);
|
3300 |
b.putString("s", Integer.toString(zoom_want));
|
3301 |
msg.setData(b);
|
3302 |
try
|
3303 |
{
|
3304 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3305 |
Navit.GlobalScaleLevel = zoom_want;
|
3306 |
}
|
3307 |
catch (Exception e)
|
3308 |
{
|
3309 |
e.printStackTrace();
|
3310 |
}
|
3311 |
if (PREF_save_zoomlevel)
|
3312 |
{
|
3313 |
setPrefs_zoomlevel();
|
3314 |
}
|
3315 |
// set nice zoomlevel before we show destination
|
3316 |
|
3317 |
try
|
3318 |
{
|
3319 |
Navit.follow_button_off();
|
3320 |
}
|
3321 |
catch (Exception e2)
|
3322 |
{
|
3323 |
e2.printStackTrace();
|
3324 |
}
|
3325 |
|
3326 |
if (Navit.use_index_search)
|
3327 |
{
|
3328 |
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));
|
3329 |
}
|
3330 |
else
|
3331 |
{
|
3332 |
show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
|
3333 |
}
|
3334 |
}
|
3335 |
else
|
3336 |
{
|
3337 |
Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
3338 |
// get the coords for the destination
|
3339 |
int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
|
3340 |
|
3341 |
// (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)
|
3342 |
// (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)
|
3343 |
|
3344 |
// ok now set target
|
3345 |
try
|
3346 |
{
|
3347 |
if (Navit.use_index_search)
|
3348 |
{
|
3349 |
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));
|
3350 |
}
|
3351 |
else
|
3352 |
{
|
3353 |
Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
|
3354 |
}
|
3355 |
// save points
|
3356 |
write_map_points();
|
3357 |
}
|
3358 |
catch (Exception e)
|
3359 |
{
|
3360 |
e.printStackTrace();
|
3361 |
}
|
3362 |
|
3363 |
// DEBUG: clear route rectangle list
|
3364 |
NavitGraphics.route_rects.clear();
|
3365 |
|
3366 |
if (NavitGraphics.navit_route_status == 0)
|
3367 |
{
|
3368 |
Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Toast.LENGTH_LONG).show(); //TRANS
|
3369 |
Navit.destination_set();
|
3370 |
|
3371 |
Message msg = new Message();
|
3372 |
Bundle b = new Bundle();
|
3373 |
b.putInt("Callback", 3);
|
3374 |
if (Navit.use_index_search)
|
3375 |
{
|
3376 |
b.putString("lat", String.valueOf((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)));
|
3377 |
b.putString("lon", String.valueOf((float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)));
|
3378 |
}
|
3379 |
else
|
3380 |
{
|
3381 |
b.putString("lat", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lat));
|
3382 |
b.putString("lon", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
|
3383 |
}
|
3384 |
b.putString("q", Navit.NavitAddressResultList_foundItems.get(destination_id).addr);
|
3385 |
msg.setData(b);
|
3386 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3387 |
}
|
3388 |
else
|
3389 |
{
|
3390 |
Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Toast.LENGTH_LONG).show(); //TRANS
|
3391 |
Message msg = new Message();
|
3392 |
Bundle b = new Bundle();
|
3393 |
b.putInt("Callback", 48);
|
3394 |
if (Navit.use_index_search)
|
3395 |
{
|
3396 |
b.putString("lat", String.valueOf((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat)));
|
3397 |
b.putString("lon", String.valueOf((float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)));
|
3398 |
}
|
3399 |
else
|
3400 |
{
|
3401 |
b.putString("lat", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lat));
|
3402 |
b.putString("lon", String.valueOf(Navit.NavitAddressResultList_foundItems.get(destination_id).lon));
|
3403 |
}
|
3404 |
b.putString("q", Navit.NavitAddressResultList_foundItems.get(destination_id).addr);
|
3405 |
msg.setData(b);
|
3406 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3407 |
}
|
3408 |
|
3409 |
// zoom_to_route();
|
3410 |
try
|
3411 |
{
|
3412 |
Thread.sleep(400);
|
3413 |
}
|
3414 |
catch (InterruptedException e)
|
3415 |
{
|
3416 |
}
|
3417 |
|
3418 |
try
|
3419 |
{
|
3420 |
Navit.follow_button_on();
|
3421 |
}
|
3422 |
catch (Exception e2)
|
3423 |
{
|
3424 |
e2.printStackTrace();
|
3425 |
}
|
3426 |
|
3427 |
if (Navit.use_index_search)
|
3428 |
{
|
3429 |
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));
|
3430 |
}
|
3431 |
else
|
3432 |
{
|
3433 |
show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon);
|
3434 |
}
|
3435 |
}
|
3436 |
}
|
3437 |
catch (NumberFormatException e)
|
3438 |
{
|
3439 |
Log.d("Navit", "NumberFormatException selected_id");
|
3440 |
}
|
3441 |
catch (Exception e)
|
3442 |
{
|
3443 |
|
3444 |
}
|
3445 |
}
|
3446 |
else
|
3447 |
{
|
3448 |
// user pressed back key
|
3449 |
}
|
3450 |
}
|
3451 |
catch (Exception e)
|
3452 |
{
|
3453 |
Log.d("Navit", "error on onActivityResult");
|
3454 |
e.printStackTrace();
|
3455 |
}
|
3456 |
break;
|
3457 |
case NavitAddressSearch_id_gmaps:
|
3458 |
try
|
3459 |
{
|
3460 |
if (resultCode == Activity.RESULT_OK)
|
3461 |
{
|
3462 |
|
3463 |
}
|
3464 |
}
|
3465 |
catch (Exception e)
|
3466 |
{
|
3467 |
e.printStackTrace();
|
3468 |
}
|
3469 |
break;
|
3470 |
case NavitGeoCoordEnter_id:
|
3471 |
try
|
3472 |
{
|
3473 |
if (resultCode == Activity.RESULT_OK)
|
3474 |
{
|
3475 |
// lat lon enter activitiy result
|
3476 |
|
3477 |
try
|
3478 |
{
|
3479 |
if (data.getStringExtra("what").equals("view"))
|
3480 |
{
|
3481 |
// get the coords for the destination
|
3482 |
float lat = Float.parseFloat(data.getStringExtra("lat"));
|
3483 |
float lon = Float.parseFloat(data.getStringExtra("lon"));
|
3484 |
|
3485 |
Log.d("Navit", "coord picker: " + lat);
|
3486 |
Log.d("Navit", "coord picker: " + lon);
|
3487 |
|
3488 |
// set nice zoomlevel before we show destination
|
3489 |
int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
|
3490 |
//
|
3491 |
Message msg = new Message();
|
3492 |
Bundle b = new Bundle();
|
3493 |
b.putInt("Callback", 33);
|
3494 |
b.putString("s", Integer.toString(zoom_want));
|
3495 |
msg.setData(b);
|
3496 |
try
|
3497 |
{
|
3498 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3499 |
Navit.GlobalScaleLevel = zoom_want;
|
3500 |
}
|
3501 |
catch (Exception e)
|
3502 |
{
|
3503 |
e.printStackTrace();
|
3504 |
}
|
3505 |
if (PREF_save_zoomlevel)
|
3506 |
{
|
3507 |
setPrefs_zoomlevel();
|
3508 |
}
|
3509 |
// set nice zoomlevel before we show destination
|
3510 |
|
3511 |
try
|
3512 |
{
|
3513 |
Navit.follow_button_off();
|
3514 |
}
|
3515 |
catch (Exception e2)
|
3516 |
{
|
3517 |
e2.printStackTrace();
|
3518 |
}
|
3519 |
|
3520 |
show_geo_on_screen(lat, lon);
|
3521 |
}
|
3522 |
else
|
3523 |
{
|
3524 |
// get the coords for the destination
|
3525 |
float lat = Float.parseFloat(data.getStringExtra("lat"));
|
3526 |
float lon = Float.parseFloat(data.getStringExtra("lat"));
|
3527 |
String dest_name = "manual coordinates";
|
3528 |
|
3529 |
// ok now set target
|
3530 |
try
|
3531 |
{
|
3532 |
dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon);
|
3533 |
if ((dest_name.equals(" ")) || (dest_name == null))
|
3534 |
{
|
3535 |
dest_name = "manual coordinates";
|
3536 |
}
|
3537 |
Navit.remember_destination(dest_name, lat, lon);
|
3538 |
// save points
|
3539 |
write_map_points();
|
3540 |
}
|
3541 |
catch (Exception e)
|
3542 |
{
|
3543 |
e.printStackTrace();
|
3544 |
}
|
3545 |
|
3546 |
// DEBUG: clear route rectangle list
|
3547 |
NavitGraphics.route_rects.clear();
|
3548 |
|
3549 |
if (NavitGraphics.navit_route_status == 0)
|
3550 |
{
|
3551 |
Navit.destination_set();
|
3552 |
|
3553 |
Message msg = new Message();
|
3554 |
Bundle b = new Bundle();
|
3555 |
b.putInt("Callback", 3);
|
3556 |
b.putString("lat", String.valueOf(lat));
|
3557 |
b.putString("lon", String.valueOf(lon));
|
3558 |
b.putString("q", dest_name);
|
3559 |
msg.setData(b);
|
3560 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3561 |
}
|
3562 |
else
|
3563 |
{
|
3564 |
Message msg = new Message();
|
3565 |
Bundle b = new Bundle();
|
3566 |
b.putInt("Callback", 48);
|
3567 |
b.putString("lat", String.valueOf(lat));
|
3568 |
b.putString("lon", String.valueOf(lon));
|
3569 |
b.putString("q", dest_name);
|
3570 |
msg.setData(b);
|
3571 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3572 |
}
|
3573 |
|
3574 |
// zoom_to_route();
|
3575 |
try
|
3576 |
{
|
3577 |
Thread.sleep(400);
|
3578 |
}
|
3579 |
catch (InterruptedException e)
|
3580 |
{
|
3581 |
}
|
3582 |
|
3583 |
try
|
3584 |
{
|
3585 |
Navit.follow_button_on();
|
3586 |
}
|
3587 |
catch (Exception e2)
|
3588 |
{
|
3589 |
e2.printStackTrace();
|
3590 |
}
|
3591 |
|
3592 |
show_geo_on_screen(lat, lon);
|
3593 |
}
|
3594 |
}
|
3595 |
catch (NumberFormatException e)
|
3596 |
{
|
3597 |
Log.d("Navit", "NumberFormatException selected_id");
|
3598 |
}
|
3599 |
catch (Exception e)
|
3600 |
{
|
3601 |
|
3602 |
}
|
3603 |
}
|
3604 |
}
|
3605 |
catch (Exception e)
|
3606 |
{
|
3607 |
e.printStackTrace();
|
3608 |
}
|
3609 |
break;
|
3610 |
case NavitRecentDest_id:
|
3611 |
try
|
3612 |
{
|
3613 |
if (resultCode == Activity.RESULT_OK)
|
3614 |
{
|
3615 |
Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id")));
|
3616 |
// get the coords for the destination
|
3617 |
int destination_id = Integer.parseInt(data.getStringExtra("selected_id"));
|
3618 |
|
3619 |
// ok now set target
|
3620 |
String dest_name = Navit.map_points.get(destination_id).point_name;
|
3621 |
float lat = Navit.map_points.get(destination_id).lat;
|
3622 |
float lon = Navit.map_points.get(destination_id).lon;
|
3623 |
|
3624 |
// DEBUG: clear route rectangle list
|
3625 |
NavitGraphics.route_rects.clear();
|
3626 |
|
3627 |
if (NavitGraphics.navit_route_status == 0)
|
3628 |
{
|
3629 |
Toast.makeText(getApplicationContext(), Navit.get_text("setting destination to") + "\n" + dest_name, Toast.LENGTH_LONG).show(); //TRANS
|
3630 |
Navit.destination_set();
|
3631 |
|
3632 |
Message msg = new Message();
|
3633 |
Bundle b = new Bundle();
|
3634 |
b.putInt("Callback", 3);
|
3635 |
b.putString("lat", String.valueOf(lat));
|
3636 |
b.putString("lon", String.valueOf(lon));
|
3637 |
b.putString("q", dest_name);
|
3638 |
msg.setData(b);
|
3639 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3640 |
}
|
3641 |
else
|
3642 |
{
|
3643 |
Toast.makeText(getApplicationContext(), Navit.get_text("new Waypoint") + "\n" + dest_name, Toast.LENGTH_LONG).show(); //TRANS
|
3644 |
Message msg = new Message();
|
3645 |
Bundle b = new Bundle();
|
3646 |
b.putInt("Callback", 48);
|
3647 |
b.putString("lat", String.valueOf(lat));
|
3648 |
b.putString("lon", String.valueOf(lon));
|
3649 |
b.putString("q", dest_name);
|
3650 |
msg.setData(b);
|
3651 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
3652 |
}
|
3653 |
|
3654 |
// zoom_to_route();
|
3655 |
try
|
3656 |
{
|
3657 |
Thread.sleep(400);
|
3658 |
}
|
3659 |
catch (InterruptedException e)
|
3660 |
{
|
3661 |
}
|
3662 |
|
3663 |
try
|
3664 |
{
|
3665 |
Navit.follow_button_on();
|
3666 |
}
|
3667 |
catch (Exception e2)
|
3668 |
{
|
3669 |
e2.printStackTrace();
|
3670 |
}
|
3671 |
|
3672 |
show_geo_on_screen(lat, lon);
|
3673 |
|
3674 |
}
|
3675 |
}
|
3676 |
catch (Exception e)
|
3677 |
{
|
3678 |
e.printStackTrace();
|
3679 |
}
|
3680 |
break;
|
3681 |
default:
|
3682 |
Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode);
|
3683 |
try
|
3684 |
{
|
3685 |
ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
|
3686 |
}
|
3687 |
catch (Exception e)
|
3688 |
{
|
3689 |
e.printStackTrace();
|
3690 |
}
|
3691 |
break;
|
3692 |
}
|
3693 |
Log.e("Navit", "onActivityResult finished");
|
3694 |
}
|
3695 |
|
3696 |
public class SCCB_object
|
3697 |
{
|
3698 |
int w;
|
3699 |
int h;
|
3700 |
}
|
3701 |
|
3702 |
public class CMC_object
|
3703 |
{
|
3704 |
int i;
|
3705 |
String s;
|
3706 |
}
|
3707 |
|
3708 |
public class MCB_object
|
3709 |
{
|
3710 |
int x1;
|
3711 |
int y1;
|
3712 |
int x2;
|
3713 |
int y2;
|
3714 |
}
|
3715 |
|
3716 |
public class TCB_object
|
3717 |
{
|
3718 |
int del;
|
3719 |
int id;
|
3720 |
NavitTimeout nt;
|
3721 |
}
|
3722 |
|
3723 |
public class GeCB_Object
|
3724 |
{
|
3725 |
int type;
|
3726 |
int a;
|
3727 |
float b;
|
3728 |
float c;
|
3729 |
}
|
3730 |
|
3731 |
public class CWorkerThread extends Thread
|
3732 |
{
|
3733 |
private Boolean running;
|
3734 |
Boolean startmain = false;
|
3735 |
private CMC_object l2;
|
3736 |
private Integer l3;
|
3737 |
private MCB_object l4;
|
3738 |
private TCB_object l5;
|
3739 |
private SCCB_object l6;
|
3740 |
private Location l7;
|
3741 |
private GeCB_Object l8;
|
3742 |
|
3743 |
Navit x;
|
3744 |
String lang;
|
3745 |
int version;
|
3746 |
String display_density_string;
|
3747 |
int timeout_loop_counter = 0;
|
3748 |
|
3749 |
private final LinkedBlockingQueue<CMC_object> queue = new LinkedBlockingQueue<CMC_object>();
|
3750 |
private final LinkedBlockingQueue<Integer> queue2 = new LinkedBlockingQueue<Integer>();
|
3751 |
private final LinkedBlockingQueue<MCB_object> queue3 = new LinkedBlockingQueue<MCB_object>();
|
3752 |
private final LinkedBlockingQueue<TCB_object> queue4 = new LinkedBlockingQueue<TCB_object>();
|
3753 |
private final LinkedBlockingQueue<SCCB_object> queue5 = new LinkedBlockingQueue<SCCB_object>();
|
3754 |
private final LinkedBlockingQueue<Location> queue6 = new LinkedBlockingQueue<Location>();
|
3755 |
private final LinkedBlockingQueue<GeCB_Object> queue7 = new LinkedBlockingQueue<GeCB_Object>();
|
3756 |
|
3757 |
CWorkerThread()
|
3758 |
{
|
3759 |
this.running = true;
|
3760 |
}
|
3761 |
|
3762 |
public void SizeChangedCallback(int w, int h)
|
3763 |
{
|
3764 |
SCCB_object sccbo = new SCCB_object();
|
3765 |
sccbo.w = w;
|
3766 |
sccbo.h = h;
|
3767 |
queue5.offer(sccbo);
|
3768 |
this.interrupt();
|
3769 |
}
|
3770 |
|
3771 |
public void TimeoutCallback2(NavitTimeout nt, int del, int id)
|
3772 |
{
|
3773 |
TCB_object tcbo = new TCB_object();
|
3774 |
tcbo.del = del;
|
3775 |
tcbo.id = id;
|
3776 |
tcbo.nt = nt;
|
3777 |
queue4.offer(tcbo);
|
3778 |
this.interrupt();
|
3779 |
//timeout_loop_counter++;
|
3780 |
|
3781 |
//if (timeout_loop_counter > 100)
|
3782 |
//{
|
3783 |
// timeout_loop_counter = 0;
|
3784 |
// // run GC at every 100th loop
|
3785 |
// // System.gc();
|
3786 |
//}
|
3787 |
}
|
3788 |
|
3789 |
public void CallbackMessageChannel(int i, String s)
|
3790 |
{
|
3791 |
CMC_object cmco = new CMC_object();
|
3792 |
cmco.i = i;
|
3793 |
cmco.s = s;
|
3794 |
queue.offer(cmco);
|
3795 |
this.interrupt();
|
3796 |
}
|
3797 |
|
3798 |
public void MotionCallback(int x1, int y1, int x2, int y2)
|
3799 |
{
|
3800 |
MCB_object mcbo = new MCB_object();
|
3801 |
mcbo.x1 = x1;
|
3802 |
mcbo.y1 = y1;
|
3803 |
mcbo.x2 = x2;
|
3804 |
mcbo.y2 = y2;
|
3805 |
queue3.offer(mcbo);
|
3806 |
this.interrupt();
|
3807 |
}
|
3808 |
|
3809 |
public void NavitActivity2(int i)
|
3810 |
{
|
3811 |
queue2.offer(Integer.valueOf(i));
|
3812 |
this.interrupt();
|
3813 |
}
|
3814 |
|
3815 |
public void CallbackGeoCalc2(int type, int a, float b, float c)
|
3816 |
{
|
3817 |
GeCB_Object gcco = new GeCB_Object();
|
3818 |
gcco.type = type;
|
3819 |
gcco.a = a;
|
3820 |
gcco.b = b;
|
3821 |
gcco.c = c;
|
3822 |
queue7.offer(gcco);
|
3823 |
this.interrupt();
|
3824 |
}
|
3825 |
|
3826 |
public void StartMain(Navit x, String lang, int version, String display_density_string)
|
3827 |
{
|
3828 |
//System.out.println("CWorkerThread:StartMain:JTHREAD ID=" + this.getId());
|
3829 |
//System.out.println("CWorkerThread:StartMain:THREAD ID=" + NavitGraphics.GetThreadId());
|
3830 |
|
3831 |
this.startmain = true;
|
3832 |
this.x = x;
|
3833 |
this.lang = lang;
|
3834 |
this.version = version;
|
3835 |
this.display_density_string = display_density_string;
|
3836 |
this.interrupt();
|
3837 |
}
|
3838 |
|
3839 |
public void VehicleCallback3(Location location)
|
3840 |
{
|
3841 |
queue6.offer(location);
|
3842 |
this.interrupt();
|
3843 |
}
|
3844 |
|
3845 |
public void calc_sun_stats()
|
3846 |
{
|
3847 |
//
|
3848 |
//
|
3849 |
// SUN ----------------
|
3850 |
//
|
3851 |
//
|
3852 |
sun_moon__must_calc_new = (SystemClock.elapsedRealtime() - sun_moon__mLastCalcSunMillis) > (60000 * 3); // calc new every 3 minutes
|
3853 |
|
3854 |
if ((sun_moon__must_calc_new) || (azmiuth_cache == -1))
|
3855 |
{
|
3856 |
float lat = 0;
|
3857 |
float lon = 0;
|
3858 |
try
|
3859 |
{
|
3860 |
String lat_lon = NavitGraphics.CallbackGeoCalc(1, NG__map_main.view.getWidth() / 2, NG__map_main.view.getHeight() / 2);
|
3861 |
String tmp[] = lat_lon.split(":", 2);
|
3862 |
//System.out.println("tmp=" + lat_lon);
|
3863 |
lat = Float.parseFloat(tmp[0]);
|
3864 |
lon = Float.parseFloat(tmp[1]);
|
3865 |
//System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
|
3866 |
}
|
3867 |
catch (Exception e)
|
3868 |
{
|
3869 |
|
3870 |
}
|
3871 |
|
3872 |
sun_moon__mLastCalcSunMillis = SystemClock.elapsedRealtime();
|
3873 |
TimeZone t = TimeZone.getDefault(); // Since the user's time zone changes dynamically, avoid caching this value. Instead, use this method to look it up for each use.
|
3874 |
//System.out.println(t.getID());
|
3875 |
sun_moon__calc = new SunriseSunsetCalculator(new Location2(String.valueOf(lat), String.valueOf(lon)), t.getID());
|
3876 |
sun_moon__cx = Calendar.getInstance();
|
3877 |
sun_moon__sc = SolarPosition.getSunPosition(new Date(), lat, lon);
|
3878 |
|
3879 |
azmiuth_cache = sun_moon__sc.azimuth;
|
3880 |
zenith_cache = sun_moon__sc.zenithAngle;
|
3881 |
sunrise_cache = sun_moon__calc.getOfficialSunriseForDate(sun_moon__cx);
|
3882 |
sunset_cache = sun_moon__calc.getOfficialSunsetForDate(sun_moon__cx);
|
3883 |
//System.out.println("calc moon");
|
3884 |
SolarEventCalculator.moonCoor_ret moon_stats = sun_moon__calc.computeMoon(sun_moon__cx);
|
3885 |
moon_azimuth_cache = moon_stats.az;
|
3886 |
moon_evelation_cache = moon_stats.alt;
|
3887 |
}
|
3888 |
//
|
3889 |
elevation = 90 - zenith_cache;
|
3890 |
//
|
3891 |
// day -> +90.0 to - 0.83
|
3892 |
// evening dusk -> - 0.83 to -10.00
|
3893 |
if (elevation < -0.83)
|
3894 |
{
|
3895 |
is_night = true;
|
3896 |
if (elevation < -10.00)
|
3897 |
{
|
3898 |
is_twilight = false;
|
3899 |
}
|
3900 |
else
|
3901 |
{
|
3902 |
is_twilight = true;
|
3903 |
}
|
3904 |
//System.out.println("***NIGHT***");
|
3905 |
}
|
3906 |
else
|
3907 |
{
|
3908 |
is_night = false;
|
3909 |
//System.out.println("###DAY###");
|
3910 |
}
|
3911 |
//
|
3912 |
// SUN ----------------
|
3913 |
//
|
3914 |
//
|
3915 |
}
|
3916 |
|
3917 |
public void do_sun_calc()
|
3918 |
{
|
3919 |
//
|
3920 |
//
|
3921 |
// SUN ----------------
|
3922 |
//
|
3923 |
//
|
3924 |
try
|
3925 |
{
|
3926 |
this.calc_sun_stats();
|
3927 |
}
|
3928 |
catch (Exception e)
|
3929 |
{
|
3930 |
// on some systems BigInteger seems to crash, or maybe some values are out of range
|
3931 |
// until the bug is found, night modus is deactivated
|
3932 |
calc_sun_enabled = false;
|
3933 |
is_twilight = false;
|
3934 |
is_night = false;
|
3935 |
}
|
3936 |
//System.out.println("sunrise: " + sunrise_cache);
|
3937 |
//System.out.println("sunset: " + sunset_cache);
|
3938 |
//System.out.println("azimuth: " + roundTwoDecimals(azmiuth_cache));
|
3939 |
//System.out.println("elevation: " + elevation);
|
3940 |
//
|
3941 |
//
|
3942 |
// SUN ----------------
|
3943 |
//
|
3944 |
//
|
3945 |
}
|
3946 |
|
3947 |
public void run()
|
3948 |
{
|
3949 |
//System.out.println("CWorkerThread -- started --");
|
3950 |
while (this.running)
|
3951 |
{
|
3952 |
if (queue4.size() == 0)
|
3953 |
{
|
3954 |
try
|
3955 |
{
|
3956 |
Thread.sleep(20000); // 20 secs.
|
3957 |
}
|
3958 |
catch (InterruptedException e)
|
3959 |
{
|
3960 |
}
|
3961 |
}
|
3962 |
|
3963 |
if (this.startmain)
|
3964 |
{
|
3965 |
//System.out.println("CWorkerThread:startup_calls:JTHREAD ID=" + this.getId());
|
3966 |
//System.out.println("CWorkerThread:startup_calls:THREAD ID=" + NavitGraphics.GetThreadId());
|
3967 |
|
3968 |
this.startmain = false;
|
3969 |
System.out.println("CWorkerThread -- NavitMain --");
|
3970 |
NavitMain(x, lang, version, display_density_string);
|
3971 |
System.out.println("CWorkerThread -- NavitActivity(3) --");
|
3972 |
NavitActivity(3);
|
3973 |
|
3974 |
// -- set map detail level (after app startup) --
|
3975 |
// -- set map detail level (after app startup) --
|
3976 |
// -- set map detail level (after app startup) --
|
3977 |
try
|
3978 |
{
|
3979 |
getPrefs_more_map_detail();
|
3980 |
if (PREF_more_map_detail > 0)
|
3981 |
{
|
3982 |
Message msg2 = new Message();
|
3983 |
Bundle b2 = new Bundle();
|
3984 |
b2.putInt("Callback", 78);
|
3985 |
b2.putString("s", "" + PREF_more_map_detail);
|
3986 |
msg2.setData(b2);
|
3987 |
N_NavitGraphics.callback_handler.sendMessage(msg2);
|
3988 |
}
|
3989 |
}
|
3990 |
catch (Exception e)
|
3991 |
{
|
3992 |
// e.printStackTrace();
|
3993 |
}
|
3994 |
// -- set map detail level (after app startup) --
|
3995 |
// -- set map detail level (after app startup) --
|
3996 |
// -- set map detail level (after app startup) --
|
3997 |
|
3998 |
Global_Init_Finished = 1;
|
3999 |
//x.runOnUiThread(new Runnable()
|
4000 |
//{
|
4001 |
// public void run()
|
4002 |
// {
|
4003 |
// NavitActivity(3);
|
4004 |
// }
|
4005 |
//});
|
4006 |
|
4007 |
//**getPrefs();
|
4008 |
//**activatePrefs();
|
4009 |
|
4010 |
System.out.println("CWorkerThread -- calling:ready --");
|
4011 |
}
|
4012 |
|
4013 |
while (queue6.size() > 0)
|
4014 |
{
|
4015 |
try
|
4016 |
{
|
4017 |
// blocking call
|
4018 |
// l2 = queue6.take();
|
4019 |
// non-blocking call
|
4020 |
l7 = queue6.poll();
|
4021 |
if (l2 != null)
|
4022 |
{
|
4023 |
NavitVehicle.VehicleCallback(l7);
|
4024 |
}
|
4025 |
}
|
4026 |
catch (Exception e)
|
4027 |
{
|
4028 |
}
|
4029 |
|
4030 |
}
|
4031 |
|
4032 |
while (queue.size() > 0)
|
4033 |
{
|
4034 |
try
|
4035 |
{
|
4036 |
// blocking call
|
4037 |
// l2 = queue.take();
|
4038 |
// non-blocking call
|
4039 |
l2 = queue.poll();
|
4040 |
if (l2 != null)
|
4041 |
{
|
4042 |
//System.out.println("CWorkerThread:CallbackMessageChannelReal_call:JTHREAD ID=" + this.getId());
|
4043 |
//System.out.println("CWorkerThread:CallbackMessageChannelReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
|
4044 |
//System.out.println("CWorkerThread:CallbackMessageChannelReal:" + l2.i);
|
4045 |
NavitGraphics.CallbackMessageChannelReal(l2.i, l2.s);
|
4046 |
}
|
4047 |
}
|
4048 |
catch (Exception e)
|
4049 |
{
|
4050 |
}
|
4051 |
|
4052 |
}
|
4053 |
|
4054 |
while (queue5.size() > 0)
|
4055 |
{
|
4056 |
try
|
4057 |
{
|
4058 |
// blocking call
|
4059 |
// l6 = queue5.take();
|
4060 |
// non-blocking call
|
4061 |
l6 = queue5.poll();
|
4062 |
if (l6 != null)
|
4063 |
{
|
4064 |
//System.out.println("CWorkerThread:SizeChangedCallbackReal_call:JTHREAD ID=" + this.getId());
|
4065 |
//System.out.println("CWorkerThread:SizeChangedCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
|
4066 |
NavitGraphics.SizeChangedCallbackReal(l6.w, l6.h);
|
4067 |
}
|
4068 |
}
|
4069 |
catch (Exception e)
|
4070 |
{
|
4071 |
}
|
4072 |
|
4073 |
}
|
4074 |
|
4075 |
int count_timeout_callbacks = 0;
|
4076 |
while (count_timeout_callbacks < 100 && queue4.size() > 0)
|
4077 |
{
|
4078 |
count_timeout_callbacks++;
|
4079 |
try
|
4080 |
{
|
4081 |
// blocking call
|
4082 |
// l5 = queue4.take();
|
4083 |
// non-blocking call
|
4084 |
l5 = queue4.poll();
|
4085 |
if (l5 != null)
|
4086 |
{
|
4087 |
//System.out.println("CWorkerThread:TimeoutCallback_call:JTHREAD ID=" + this.getId());
|
4088 |
//System.out.println("CWorkerThread:TimeoutCallback_call:THREAD ID=" + NavitGraphics.GetThreadId());
|
4089 |
if ((l5.nt.running) || (!l5.nt.event_multi))
|
4090 |
{
|
4091 |
NavitGraphics.TimeoutCallback(l5.del, l5.id);
|
4092 |
}
|
4093 |
else
|
4094 |
{
|
4095 |
// System.out.println("CWorkerThread:TimeoutCallback_call:running=false! cid=" + l5.id);
|
4096 |
}
|
4097 |
}
|
4098 |
}
|
4099 |
catch (Exception e)
|
4100 |
{
|
4101 |
}
|
4102 |
|
4103 |
}
|
4104 |
|
4105 |
while (queue3.size() > 0)
|
4106 |
{
|
4107 |
try
|
4108 |
{
|
4109 |
// blocking call
|
4110 |
// l4 = queue3.take();
|
4111 |
// non-blocking call
|
4112 |
l4 = queue3.poll();
|
4113 |
if (l4 != null)
|
4114 |
{
|
4115 |
//System.out.println("CWorkerThread:MotionCallbackReal_call:JTHREAD ID=" + this.getId());
|
4116 |
//System.out.println("CWorkerThread:MotionCallbackReal_call:THREAD ID=" + NavitGraphics.GetThreadId());
|
4117 |
NavitGraphics.MotionCallbackReal(l4.x1, l4.y1, l4.x2, l4.y2);
|
4118 |
}
|
4119 |
}
|
4120 |
catch (Exception e)
|
4121 |
{
|
4122 |
}
|
4123 |
|
4124 |
}
|
4125 |
|
4126 |
while (queue7.size() > 0)
|
4127 |
{
|
4128 |
try
|
4129 |
{
|
4130 |
l8 = queue7.poll();
|
4131 |
if (l8 != null)
|
4132 |
{
|
4133 |
if (l8.type == 1)
|
4134 |
{
|
4135 |
Navit.OSD_nextturn.nextturn_streetname_systematic = "";
|
4136 |
Navit.OSD_nextturn.nextturn_streetname = NavitGraphics.CallbackGeoCalc(8, l8.b, l8.c);
|
4137 |
if (Navit.PREF_item_dump)
|
4138 |
{
|
4139 |
// -------- DEBUG ------- DEBUG ---------
|
4140 |
// -------- DEBUG ------- DEBUG ---------
|
4141 |
// -------- DEBUG ------- DEBUG ---------
|
4142 |
Navit.debug_item_dump = NavitGraphics.CallbackGeoCalc(9, l8.b, l8.c);
|
4143 |
// -------- DEBUG ------- DEBUG ---------
|
4144 |
// -------- DEBUG ------- DEBUG ---------
|
4145 |
// -------- DEBUG ------- DEBUG ---------
|
4146 |
}
|
4147 |
//System.out.println("OSD postinvalidate***");
|
4148 |
NavitGraphics.NavitAOSDJava_.postInvalidate();
|
4149 |
}
|
4150 |
else if (l8.type == 2)
|
4151 |
{
|
4152 |
NavitGraphics.CallbackGeoCalc(l8.a, l8.b, l8.c);
|
4153 |
}
|
4154 |
}
|
4155 |
}
|
4156 |
catch (Exception e)
|
4157 |
{
|
4158 |
}
|
4159 |
|
4160 |
}
|
4161 |
|
4162 |
while (queue2.size() > 0)
|
4163 |
{
|
4164 |
try
|
4165 |
{
|
4166 |
// blocking call
|
4167 |
// l3 = queue2.take();
|
4168 |
// non-blocking call
|
4169 |
l3 = queue2.poll();
|
4170 |
if (l3 != null)
|
4171 |
{
|
4172 |
int i3 = l3.intValue();
|
4173 |
//System.out.println("CWorkerThread:NavitActivity_call:JTHREAD ID=" + this.getId());
|
4174 |
//System.out.println("CWorkerThread:NavitActivity_call:THREAD ID=" + NavitGraphics.GetThreadId());
|
4175 |
//System.out.println("CWorkerThread:NavitActivity:" + i3);
|
4176 |
NavitActivity(i3);
|
4177 |
}
|
4178 |
}
|
4179 |
catch (Exception e)
|
4180 |
{
|
4181 |
}
|
4182 |
}
|
4183 |
|
4184 |
// check sun position (and after interval, recalc values)
|
4185 |
do_sun_calc();
|
4186 |
}
|
4187 |
//System.out.println("CWorkerThread -- stopped --");
|
4188 |
}
|
4189 |
|
4190 |
public void stop_me()
|
4191 |
{
|
4192 |
this.running = false;
|
4193 |
this.interrupt();
|
4194 |
}
|
4195 |
|
4196 |
}
|
4197 |
|
4198 |
public class SmoothVehicle extends Thread
|
4199 |
{
|
4200 |
private Boolean running;
|
4201 |
|
4202 |
SmoothVehicle()
|
4203 |
{
|
4204 |
this.running = true;
|
4205 |
}
|
4206 |
|
4207 |
public void run()
|
4208 |
{
|
4209 |
while (this.running)
|
4210 |
{
|
4211 |
try
|
4212 |
{
|
4213 |
Thread.sleep(5000); // 5 secs.
|
4214 |
}
|
4215 |
catch (InterruptedException e)
|
4216 |
{
|
4217 |
}
|
4218 |
}
|
4219 |
}
|
4220 |
|
4221 |
public void stop_me()
|
4222 |
{
|
4223 |
this.running = false;
|
4224 |
}
|
4225 |
}
|
4226 |
|
4227 |
public class WatchMem extends Thread
|
4228 |
{
|
4229 |
private Boolean running;
|
4230 |
|
4231 |
WatchMem()
|
4232 |
{
|
4233 |
this.running = true;
|
4234 |
}
|
4235 |
|
4236 |
public void run()
|
4237 |
{
|
4238 |
//System.out.println("WatchMem -- started --");
|
4239 |
while (this.running)
|
4240 |
{
|
4241 |
Navit.show_mem_used();
|
4242 |
|
4243 |
try
|
4244 |
{
|
4245 |
Thread.sleep(5000); // 5 secs.
|
4246 |
}
|
4247 |
catch (InterruptedException e)
|
4248 |
{
|
4249 |
}
|
4250 |
}
|
4251 |
//System.out.println("WatchMem -- stopped --");
|
4252 |
}
|
4253 |
|
4254 |
public void stop_me()
|
4255 |
{
|
4256 |
this.running = false;
|
4257 |
}
|
4258 |
}
|
4259 |
|
4260 |
public class SimGPS extends Thread
|
4261 |
{
|
4262 |
private Boolean running;
|
4263 |
private Handler h;
|
4264 |
|
4265 |
SimGPS(Handler h_)
|
4266 |
{
|
4267 |
System.out.println("SimGPS -- inited --");
|
4268 |
this.h = h_;
|
4269 |
this.running = true;
|
4270 |
}
|
4271 |
|
4272 |
public void run()
|
4273 |
{
|
4274 |
System.out.println("SimGPS -- started --");
|
4275 |
while (this.running)
|
4276 |
{
|
4277 |
float rnd_heading = (float) (Math.random() * 360d);
|
4278 |
float lat = 48.216023f;
|
4279 |
float lng = 16.391664f;
|
4280 |
//Location l = new Location("Network");
|
4281 |
//l.setLatitude(lat);
|
4282 |
//l.setLongitude(lng);
|
4283 |
//l.setBearing(rnd_heading);
|
4284 |
// NavitVehicle.set_mock_location__fast(l);
|
4285 |
// NavitVehicle.update_compass_heading(rnd_heading);
|
4286 |
if (this.h != null)
|
4287 |
{
|
4288 |
Message msg = this.h.obtainMessage();
|
4289 |
Bundle b = new Bundle();
|
4290 |
msg.what = 1;
|
4291 |
b.putFloat("b", rnd_heading);
|
4292 |
b.putFloat("lat", lat);
|
4293 |
b.putFloat("lng", lng);
|
4294 |
msg.setData(b);
|
4295 |
this.h.sendMessage(msg);
|
4296 |
}
|
4297 |
try
|
4298 |
{
|
4299 |
Thread.sleep(800);
|
4300 |
}
|
4301 |
catch (InterruptedException e)
|
4302 |
{
|
4303 |
}
|
4304 |
}
|
4305 |
System.out.println("SimGPS -- stopped --");
|
4306 |
}
|
4307 |
|
4308 |
public void stop_me()
|
4309 |
{
|
4310 |
this.running = false;
|
4311 |
}
|
4312 |
}
|
4313 |
|
4314 |
public class SearchResultsThreadSpinnerThread extends Thread
|
4315 |
{
|
4316 |
int dialog_num;
|
4317 |
int spinner_current_value;
|
4318 |
private Boolean running;
|
4319 |
Handler mHandler;
|
4320 |
|
4321 |
SearchResultsThreadSpinnerThread(Handler h, int dialog_num)
|
4322 |
{
|
4323 |
this.dialog_num = dialog_num;
|
4324 |
this.mHandler = h;
|
4325 |
this.spinner_current_value = 0;
|
4326 |
|
4327 |
this.running = true;
|
4328 |
Log.e("Navit", "SearchResultsThreadSpinnerThread created");
|
4329 |
}
|
4330 |
|
4331 |
public void run()
|
4332 |
{
|
4333 |
Log.e("Navit", "SearchResultsThreadSpinnerThread started");
|
4334 |
while (this.running)
|
4335 |
{
|
4336 |
if (Navit.NavitAddressSearchSpinnerActive == false)
|
4337 |
{
|
4338 |
this.running = false;
|
4339 |
}
|
4340 |
else
|
4341 |
{
|
4342 |
Message msg = mHandler.obtainMessage();
|
4343 |
Bundle b = new Bundle();
|
4344 |
msg.what = 10;
|
4345 |
b.putInt("dialog_num", this.dialog_num);
|
4346 |
b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
|
4347 |
b.putInt("cur", this.spinner_current_value % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
|
4348 |
if ((Navit.NavitSearchresultBar_title.equals("")) && (Navit.NavitSearchresultBar_text.equals("")))
|
4349 |
{
|
4350 |
b.putString("title", Navit.get_text("getting search results")); //TRANS
|
4351 |
b.putString("text", Navit.get_text("searching ...")); //TRANS
|
4352 |
}
|
4353 |
else
|
4354 |
{
|
4355 |
b.putString("title", Navit.NavitSearchresultBar_title);
|
4356 |
b.putString("text", Navit.NavitSearchresultBar_text);
|
4357 |
}
|
4358 |
msg.setData(b);
|
4359 |
mHandler.sendMessage(msg);
|
4360 |
try
|
4361 |
{
|
4362 |
Thread.sleep(700);
|
4363 |
}
|
4364 |
catch (InterruptedException e)
|
4365 |
{
|
4366 |
// e.printStackTrace();
|
4367 |
}
|
4368 |
this.spinner_current_value++;
|
4369 |
}
|
4370 |
}
|
4371 |
Log.e("Navit", "SearchResultsThreadSpinnerThread ended");
|
4372 |
}
|
4373 |
}
|
4374 |
|
4375 |
public class SearchResultsThread extends Thread
|
4376 |
{
|
4377 |
private Boolean running;
|
4378 |
Handler mHandler;
|
4379 |
int my_dialog_num;
|
4380 |
|
4381 |
SearchResultsThread(Handler h, int dialog_num)
|
4382 |
{
|
4383 |
this.running = true;
|
4384 |
this.mHandler = h;
|
4385 |
this.my_dialog_num = dialog_num;
|
4386 |
Log.e("Navit", "SearchResultsThread created");
|
4387 |
}
|
4388 |
|
4389 |
public void stop_me()
|
4390 |
{
|
4391 |
this.running = false;
|
4392 |
}
|
4393 |
|
4394 |
public void run()
|
4395 |
{
|
4396 |
Log.e("Navit", "SearchResultsThread started");
|
4397 |
|
4398 |
// initialize the dialog with sane values
|
4399 |
Message msg = mHandler.obtainMessage();
|
4400 |
Bundle b = new Bundle();
|
4401 |
msg.what = 10;
|
4402 |
b.putInt("dialog_num", this.my_dialog_num);
|
4403 |
b.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
|
4404 |
b.putInt("cur", 0);
|
4405 |
b.putString("title", Navit.get_text("getting search results")); //TRANS
|
4406 |
b.putString("text", Navit.get_text("searching ...")); //TRANS
|
4407 |
msg.setData(b);
|
4408 |
mHandler.sendMessage(msg);
|
4409 |
|
4410 |
int partial_match_i = 0;
|
4411 |
if (Navit_last_address_partial_match)
|
4412 |
{
|
4413 |
partial_match_i = 1;
|
4414 |
}
|
4415 |
|
4416 |
if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
|
4417 |
{
|
4418 |
// start the search, this could take a long time!!
|
4419 |
Log.e("Navit", "SearchResultsThread run1");
|
4420 |
// need lowercase to find stuff !!
|
4421 |
Navit_last_address_search_string = filter_bad_chars(Navit_last_address_search_string).toLowerCase();
|
4422 |
if ((Navit_last_address_hn_string != null) && (Navit_last_address_hn_string.equals("")))
|
4423 |
{
|
4424 |
Navit_last_address_hn_string = filter_bad_chars(Navit_last_address_hn_string).toLowerCase();
|
4425 |
}
|
4426 |
|
4427 |
if (Navit_last_address_full_file_search)
|
4428 |
{
|
4429 |
// flags (18) -> order level to search at
|
4430 |
// ================
|
4431 |
// 0#0 0 -> search full world
|
4432 |
// lat#lon radius -> search only this area, around lat,lon
|
4433 |
// ================
|
4434 |
N_NavitGraphics.SearchResultList(3, partial_match_i, Navit_last_address_search_string, "", "", 18, Navit_last_address_search_country_iso2_string, "0#0", 0);
|
4435 |
}
|
4436 |
else
|
4437 |
{
|
4438 |
if (Navit.use_index_search)
|
4439 |
{
|
4440 |
// new method with index search
|
4441 |
// -----------------
|
4442 |
//Navit_last_address_search_string
|
4443 |
String street_ = "";
|
4444 |
String town_ = "";
|
4445 |
String hn_ = Navit_last_address_hn_string;
|
4446 |
|
4447 |
int last_space = Navit_last_address_search_string.lastIndexOf(" ");
|
4448 |
if (last_space != -1)
|
4449 |
{
|
4450 |
street_ = Navit_last_address_search_string.substring(0, last_space);
|
4451 |
town_ = Navit_last_address_search_string.substring(last_space);
|
4452 |
}
|
4453 |
else
|
4454 |
{
|
4455 |
street_ = Navit_last_address_search_string;
|
4456 |
town_ = "";
|
4457 |
}
|
4458 |
N_NavitGraphics.SearchResultList(2, partial_match_i, street_, town_, hn_, Navit_last_address_search_country_flags, Navit_last_address_search_country_iso2_string, "0#0", 0);
|
4459 |
|
4460 |
// sort result list
|
4461 |
Collections.sort(Navit.NavitAddressResultList_foundItems);
|
4462 |
}
|
4463 |
else
|
4464 |
{
|
4465 |
// old method search
|
4466 |
// -----------------
|
4467 |
// flags --> 3: search all countries
|
4468 |
// 2: search <iso2 string> country
|
4469 |
// 1: search default country (what you have set as language in prefs)
|
4470 |
N_NavitGraphics.SearchResultList(29, partial_match_i, Navit_last_address_search_string, "", "", Navit_last_address_search_country_flags, Navit_last_address_search_country_iso2_string, "0#0", 0);
|
4471 |
|
4472 |
// sort result list
|
4473 |
Collections.sort(Navit.NavitAddressResultList_foundItems);
|
4474 |
}
|
4475 |
}
|
4476 |
Log.e("Navit", "SearchResultsThread run2");
|
4477 |
}
|
4478 |
else if (this.my_dialog_num == Navit.SEARCHRESULTS_WAIT_DIALOG)
|
4479 |
{
|
4480 |
// online googlemaps search
|
4481 |
// google search
|
4482 |
Log.e("Navit", "SearchResultsThread run1 -> online googlemaps search");
|
4483 |
String addressInput = filter_bad_chars(Navit_last_address_search_string);
|
4484 |
try
|
4485 |
{
|
4486 |
List<Address> foundAdresses = Navit.Navit_Geocoder.getFromLocationName(addressInput, 30); //Search addresses
|
4487 |
System.out.println("found " + foundAdresses.size() + " results");
|
4488 |
// System.out.println("addr=" + foundAdresses.get(0).getLatitude() + " " + foundAdresses.get(0).getLongitude() + "" + foundAdresses.get(0).getAddressLine(0));
|
4489 |
|
4490 |
Navit.NavitAddressSearchSpinnerActive = false;
|
4491 |
|
4492 |
for (int results_step = 0; results_step < foundAdresses.size(); results_step++)
|
4493 |
{
|
4494 |
Navit.Navit_Address_Result_Struct tmp_addr = new Navit_Address_Result_Struct();
|
4495 |
tmp_addr.result_type = "STR";
|
4496 |
tmp_addr.item_id = "0";
|
4497 |
tmp_addr.lat = (float) foundAdresses.get(results_step).getLatitude();
|
4498 |
tmp_addr.lon = (float) foundAdresses.get(results_step).getLongitude();
|
4499 |
tmp_addr.addr = "";
|
4500 |
|
4501 |
String c_code = foundAdresses.get(results_step).getCountryCode();
|
4502 |
if (c_code != null)
|
4503 |
{
|
4504 |
tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getCountryCode() + ",";
|
4505 |
}
|
4506 |
|
4507 |
String p_code = foundAdresses.get(results_step).getPostalCode();
|
4508 |
if (p_code != null)
|
4509 |
{
|
4510 |
tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getPostalCode() + " ";
|
4511 |
}
|
4512 |
|
4513 |
if (foundAdresses.get(results_step).getMaxAddressLineIndex() > -1)
|
4514 |
{
|
4515 |
for (int addr_line = 0; addr_line < foundAdresses.get(results_step).getMaxAddressLineIndex(); addr_line++)
|
4516 |
{
|
4517 |
if (addr_line > 0) tmp_addr.addr = tmp_addr.addr + " ";
|
4518 |
tmp_addr.addr = tmp_addr.addr + foundAdresses.get(results_step).getAddressLine(addr_line);
|
4519 |
}
|
4520 |
}
|
4521 |
|
4522 |
Navit.NavitAddressResultList_foundItems.add(tmp_addr);
|
4523 |
|
4524 |
if (tmp_addr.result_type.equals("TWN"))
|
4525 |
{
|
4526 |
Navit.search_results_towns++;
|
4527 |
}
|
4528 |
else if (tmp_addr.result_type.equals("STR"))
|
4529 |
{
|
4530 |
Navit.search_results_streets++;
|
4531 |
}
|
4532 |
else if (tmp_addr.result_type.equals("SHN"))
|
4533 |
{
|
4534 |
Navit.search_results_streets_hn++;
|
4535 |
}
|
4536 |
|
4537 |
// make the dialog move its bar ...
|
4538 |
Bundle b2 = new Bundle();
|
4539 |
b2.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG);
|
4540 |
b2.putInt("max", Navit.ADDRESS_RESULTS_DIALOG_MAX);
|
4541 |
b2.putInt("cur", Navit.NavitAddressResultList_foundItems.size() % (Navit.ADDRESS_RESULTS_DIALOG_MAX + 1));
|
4542 |
b2.putString("title", Navit.get_text("loading search results")); //TRANS
|
4543 |
b2.putString("text", Navit.get_text("towns") + ":" + Navit.search_results_towns + " " + Navit.get_text("Streets") + ":" + Navit.search_results_streets + "/" + Navit.search_results_streets_hn);
|
4544 |
Navit.msg_to_msg_handler(b2, 10);
|
4545 |
}
|
4546 |
}
|
4547 |
catch (Exception e)
|
4548 |
{
|
4549 |
e.printStackTrace();
|
4550 |
System.out.println("seems googlemaps API is not working, try offline search");
|
4551 |
}
|
4552 |
}
|
4553 |
|
4554 |
Navit.NavitAddressSearchSpinnerActive = false;
|
4555 |
|
4556 |
if (Navit.NavitAddressResultList_foundItems.size() > 0)
|
4557 |
{
|
4558 |
open_search_result_list();
|
4559 |
}
|
4560 |
else
|
4561 |
{
|
4562 |
// not results found, show toast
|
4563 |
msg = mHandler.obtainMessage();
|
4564 |
b = new Bundle();
|
4565 |
msg.what = 3;
|
4566 |
b.putString("text", Navit.get_text("No Results found!")); //TRANS
|
4567 |
msg.setData(b);
|
4568 |
mHandler.sendMessage(msg);
|
4569 |
}
|
4570 |
|
4571 |
// ok, remove dialog
|
4572 |
msg = mHandler.obtainMessage();
|
4573 |
b = new Bundle();
|
4574 |
msg.what = 99;
|
4575 |
b.putInt("dialog_num", this.my_dialog_num);
|
4576 |
msg.setData(b);
|
4577 |
mHandler.sendMessage(msg);
|
4578 |
|
4579 |
// reset the startup-search flag
|
4580 |
Navit.NavitStartupAlreadySearching = false;
|
4581 |
|
4582 |
Log.e("Navit", "SearchResultsThread ended");
|
4583 |
}
|
4584 |
}
|
4585 |
|
4586 |
public static String filter_bad_chars(String in)
|
4587 |
{
|
4588 |
String out = in;
|
4589 |
out = out.replaceAll("\\n", " "); // newline -> space
|
4590 |
out = out.replaceAll("\\r", " "); // return -> space
|
4591 |
out = out.replaceAll("\\t", " "); // tab -> space
|
4592 |
out = out.trim();
|
4593 |
return out;
|
4594 |
}
|
4595 |
|
4596 |
public static void msg_to_msg_handler(Bundle b, int id)
|
4597 |
{
|
4598 |
Message msg = Navit_progress_h.obtainMessage();
|
4599 |
msg.what = id;
|
4600 |
msg.setData(b);
|
4601 |
Navit_progress_h.sendMessage(msg);
|
4602 |
}
|
4603 |
|
4604 |
public void open_search_result_list()
|
4605 |
{
|
4606 |
// open result list
|
4607 |
Intent address_result_list_activity = new Intent(this, NavitAddressResultListActivity.class);
|
4608 |
this.startActivityForResult(address_result_list_activity, Navit.NavitAddressResultList_id);
|
4609 |
}
|
4610 |
|
4611 |
public Handler progress_handler = new Handler()
|
4612 |
{
|
4613 |
public void handleMessage(Message msg)
|
4614 |
{
|
4615 |
switch (msg.what)
|
4616 |
{
|
4617 |
case 0:
|
4618 |
// dismiss dialog, remove dialog
|
4619 |
try
|
4620 |
{
|
4621 |
Log.e("Navit", "0: dismiss dialog num " + msg.getData().getInt("dialog_num"));
|
4622 |
}
|
4623 |
catch (Exception e)
|
4624 |
{
|
4625 |
e.printStackTrace();
|
4626 |
}
|
4627 |
dismissDialog(msg.getData().getInt("dialog_num"));
|
4628 |
removeDialog(msg.getData().getInt("dialog_num"));
|
4629 |
|
4630 |
// exit_code=0 -> OK, map was downloaded fine
|
4631 |
if (msg.getData().getInt("exit_code") == 0)
|
4632 |
{
|
4633 |
// try to use the new downloaded map (works fine now!)
|
4634 |
//Log.d("Navit", "instance count=" + Navit.getInstanceCount()); // where did this go to?
|
4635 |
|
4636 |
// **** onStop();
|
4637 |
// **** onCreate(getIntent().getExtras());
|
4638 |
|
4639 |
// reload sdcard maps
|
4640 |
Message msg2 = new Message();
|
4641 |
Bundle b2 = new Bundle();
|
4642 |
b2.putInt("Callback", 18);
|
4643 |
msg2.setData(b2);
|
4644 |
N_NavitGraphics.callback_handler.sendMessage(msg2);
|
4645 |
|
4646 |
zoom_out_full();
|
4647 |
|
4648 |
/*
|
4649 |
* Intent intent = getIntent();
|
4650 |
* System.out.println("ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ**********************");
|
4651 |
* startActivity(intent);
|
4652 |
* System.out.println("FFFFFFFFFFFFFFFFFFF**********************");
|
4653 |
* Log.d("Navit", "instance count=" + Navit.getInstanceCount());
|
4654 |
* onStop();
|
4655 |
* System.out.println("HHHHHHHHHHHHHHHHHHH**********************");
|
4656 |
*/
|
4657 |
|
4658 |
//Message msg2 = new Message();
|
4659 |
//Bundle b2 = new Bundle();
|
4660 |
//b2.putInt("Callback", 6);
|
4661 |
//msg2.setData(b2);
|
4662 |
//N_NavitGraphics.callback_handler.sendMessage(msg2);
|
4663 |
}
|
4664 |
break;
|
4665 |
case 1:
|
4666 |
// change progressbar values
|
4667 |
int what_dialog = msg.getData().getInt("dialog_num");
|
4668 |
if (what_dialog == MAPDOWNLOAD_PRI_DIALOG)
|
4669 |
{
|
4670 |
mapdownloader_dialog_pri.setMax(msg.getData().getInt("max"));
|
4671 |
mapdownloader_dialog_pri.setProgress(msg.getData().getInt("cur"));
|
4672 |
mapdownloader_dialog_pri.setTitle(msg.getData().getString("title"));
|
4673 |
mapdownloader_dialog_pri.setMessage(msg.getData().getString("text"));
|
4674 |
}
|
4675 |
else if (what_dialog == MAPDOWNLOAD_SEC_DIALOG)
|
4676 |
{
|
4677 |
mapdownloader_dialog_sec.setMax(msg.getData().getInt("max"));
|
4678 |
mapdownloader_dialog_sec.setProgress(msg.getData().getInt("cur"));
|
4679 |
mapdownloader_dialog_sec.setTitle(msg.getData().getString("title"));
|
4680 |
mapdownloader_dialog_sec.setMessage(msg.getData().getString("text"));
|
4681 |
}
|
4682 |
break;
|
4683 |
case 2:
|
4684 |
Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
|
4685 |
break;
|
4686 |
case 3:
|
4687 |
Toast.makeText(getApplicationContext(), msg.getData().getString("text"), Toast.LENGTH_LONG).show();
|
4688 |
break;
|
4689 |
case 10:
|
4690 |
// change values - generic
|
4691 |
int what_dialog_generic = msg.getData().getInt("dialog_num");
|
4692 |
if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG)
|
4693 |
{
|
4694 |
search_results_wait.setMax(msg.getData().getInt("max"));
|
4695 |
search_results_wait.setProgress(msg.getData().getInt("cur"));
|
4696 |
search_results_wait.setTitle(msg.getData().getString("title"));
|
4697 |
search_results_wait.setMessage(msg.getData().getString("text"));
|
4698 |
}
|
4699 |
else if (what_dialog_generic == SEARCHRESULTS_WAIT_DIALOG_OFFLINE)
|
4700 |
{
|
4701 |
search_results_wait_offline.setMax(msg.getData().getInt("max"));
|
4702 |
search_results_wait_offline.setProgress(msg.getData().getInt("cur"));
|
4703 |
search_results_wait_offline.setTitle(msg.getData().getString("title"));
|
4704 |
search_results_wait_offline.setMessage(msg.getData().getString("text"));
|
4705 |
}
|
4706 |
break;
|
4707 |
case 11:
|
4708 |
// show dialog - generic
|
4709 |
try
|
4710 |
{
|
4711 |
// just in case, remove the dialog if it should be shown already!
|
4712 |
dismissDialog(msg.getData().getInt("dialog_num"));
|
4713 |
removeDialog(msg.getData().getInt("dialog_num"));
|
4714 |
}
|
4715 |
catch (Exception e)
|
4716 |
{
|
4717 |
// System.out.println("Ex D1: " + e.toString());
|
4718 |
}
|
4719 |
showDialog(msg.getData().getInt("dialog_num"));
|
4720 |
break;
|
4721 |
case 12:
|
4722 |
// turn on compass
|
4723 |
turn_on_compass();
|
4724 |
break;
|
4725 |
case 13:
|
4726 |
// turn off compass
|
4727 |
turn_off_compass();
|
4728 |
break;
|
4729 |
case 14:
|
4730 |
// set used mem in textview
|
4731 |
show_mem_used_real();
|
4732 |
break;
|
4733 |
case 15:
|
4734 |
// set debug text line 3
|
4735 |
Navit.set_debug_messages3(msg.getData().getString("text"));
|
4736 |
break;
|
4737 |
case 16:
|
4738 |
// refresh NavitAndriodOverlay
|
4739 |
try
|
4740 |
{
|
4741 |
//Log.e("NavitGraphics", "xx 1");
|
4742 |
//System.out.println("invalidate 027");
|
4743 |
NavitGraphics.NavitAOverlay_s.invalidate();
|
4744 |
//Log.e("NavitGraphics", "xx 2");
|
4745 |
}
|
4746 |
catch (Exception e)
|
4747 |
{
|
4748 |
e.printStackTrace();
|
4749 |
}
|
4750 |
break;
|
4751 |
case 17:
|
4752 |
try
|
4753 |
{
|
4754 |
|
4755 |
generic_alert_box.setMessage(Navit.get_text("Possibly not enough space on your device!")).setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener() // TRANS
|
4756 |
{
|
4757 |
public void onClick(DialogInterface dialog, int id)
|
4758 |
{
|
4759 |
// Handle Ok
|
4760 |
}
|
4761 |
}).create();
|
4762 |
generic_alert_box.setCancelable(false);
|
4763 |
generic_alert_box.setTitle(Navit.get_text("device space")); // TRANS
|
4764 |
generic_alert_box.show();
|
4765 |
}
|
4766 |
catch (Exception e)
|
4767 |
{
|
4768 |
e.printStackTrace();
|
4769 |
}
|
4770 |
break;
|
4771 |
case 99:
|
4772 |
// dismiss dialog, remove dialog - generic
|
4773 |
try
|
4774 |
{
|
4775 |
Log.e("Navit", "99: dismiss dialog num " + msg.getData().getInt("dialog_num"));
|
4776 |
}
|
4777 |
catch (Exception e)
|
4778 |
{
|
4779 |
e.printStackTrace();
|
4780 |
}
|
4781 |
try
|
4782 |
{
|
4783 |
dismissDialog(msg.getData().getInt("dialog_num"));
|
4784 |
}
|
4785 |
catch (Exception e)
|
4786 |
{
|
4787 |
e.printStackTrace();
|
4788 |
}
|
4789 |
try
|
4790 |
{
|
4791 |
removeDialog(msg.getData().getInt("dialog_num"));
|
4792 |
}
|
4793 |
catch (Exception e)
|
4794 |
{
|
4795 |
e.printStackTrace();
|
4796 |
}
|
4797 |
break;
|
4798 |
}
|
4799 |
}
|
4800 |
};
|
4801 |
|
4802 |
protected Dialog onCreateDialog(int id)
|
4803 |
{
|
4804 |
switch (id)
|
4805 |
{
|
4806 |
case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
|
4807 |
search_results_wait_offline = new ProgressDialog(this);
|
4808 |
search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
4809 |
search_results_wait_offline.setTitle("--");
|
4810 |
search_results_wait_offline.setMessage("--");
|
4811 |
search_results_wait_offline.setCancelable(true); // allow to stop search
|
4812 |
search_results_wait_offline.setProgress(0);
|
4813 |
search_results_wait_offline.setMax(10);
|
4814 |
|
4815 |
search_results_wait_offline.setOnCancelListener(new OnCancelListener()
|
4816 |
{
|
4817 |
public void onCancel(DialogInterface dialog)
|
4818 |
{
|
4819 |
Message msg = new Message();
|
4820 |
Bundle b = new Bundle();
|
4821 |
b.putInt("Callback", 46);
|
4822 |
msg.setData(b);
|
4823 |
try
|
4824 |
{
|
4825 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
4826 |
}
|
4827 |
catch (Exception e)
|
4828 |
{
|
4829 |
}
|
4830 |
Log.e("Navit", "onCancel: search_results_wait offline");
|
4831 |
}
|
4832 |
});
|
4833 |
|
4834 |
/*
|
4835 |
* search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
|
4836 |
* {
|
4837 |
* public void onClick(DialogInterface dialog, int which)
|
4838 |
* {
|
4839 |
* // Use either finish() or return() to either close the activity or just the dialog
|
4840 |
* return;
|
4841 |
* }
|
4842 |
* });
|
4843 |
*/
|
4844 |
|
4845 |
DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener()
|
4846 |
{
|
4847 |
public void onDismiss(DialogInterface dialog)
|
4848 |
{
|
4849 |
Log.e("Navit", "onDismiss: search_results_wait offline");
|
4850 |
dialog.dismiss();
|
4851 |
dialog.cancel();
|
4852 |
searchresultsThread_offline.stop_me();
|
4853 |
}
|
4854 |
};
|
4855 |
search_results_wait_offline.setOnDismissListener(mOnDismissListener4);
|
4856 |
searchresultsThread_offline = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
|
4857 |
searchresultsThread_offline.start();
|
4858 |
|
4859 |
NavitAddressSearchSpinnerActive = true;
|
4860 |
spinner_thread_offline = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
|
4861 |
spinner_thread_offline.start();
|
4862 |
|
4863 |
return search_results_wait_offline;
|
4864 |
case Navit.SEARCHRESULTS_WAIT_DIALOG:
|
4865 |
search_results_wait = new ProgressDialog(this);
|
4866 |
search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
4867 |
search_results_wait.setTitle("--");
|
4868 |
search_results_wait.setMessage("--");
|
4869 |
search_results_wait.setCancelable(false);
|
4870 |
search_results_wait.setProgress(0);
|
4871 |
search_results_wait.setMax(10);
|
4872 |
|
4873 |
DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener()
|
4874 |
{
|
4875 |
public void onDismiss(DialogInterface dialog)
|
4876 |
{
|
4877 |
Log.e("Navit", "onDismiss: search_results_wait");
|
4878 |
dialog.dismiss();
|
4879 |
dialog.cancel();
|
4880 |
searchresultsThread.stop_me();
|
4881 |
}
|
4882 |
};
|
4883 |
search_results_wait.setOnDismissListener(mOnDismissListener3);
|
4884 |
searchresultsThread = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
|
4885 |
searchresultsThread.start();
|
4886 |
|
4887 |
NavitAddressSearchSpinnerActive = true;
|
4888 |
spinner_thread = new SearchResultsThreadSpinnerThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
|
4889 |
spinner_thread.start();
|
4890 |
|
4891 |
return search_results_wait;
|
4892 |
case Navit.MAPDOWNLOAD_PRI_DIALOG:
|
4893 |
mapdownloader_dialog_pri = new ProgressDialog(this);
|
4894 |
mapdownloader_dialog_pri.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
4895 |
mapdownloader_dialog_pri.setTitle("--");
|
4896 |
mapdownloader_dialog_pri.setMessage("--");
|
4897 |
mapdownloader_dialog_pri.setCancelable(true);
|
4898 |
mapdownloader_dialog_pri.setProgress(0);
|
4899 |
mapdownloader_dialog_pri.setMax(200);
|
4900 |
DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener()
|
4901 |
{
|
4902 |
public void onDismiss(DialogInterface dialog)
|
4903 |
{
|
4904 |
Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
|
4905 |
dialog.dismiss();
|
4906 |
dialog.cancel();
|
4907 |
progressThread_pri.stop_thread();
|
4908 |
}
|
4909 |
};
|
4910 |
mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
|
4911 |
mapdownloader_pri = new NavitMapDownloader(this);
|
4912 |
progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
|
4913 |
progressThread_pri.start();
|
4914 |
// show license for OSM maps
|
4915 |
//. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
|
4916 |
Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_LONG).show(); //TRANS
|
4917 |
return mapdownloader_dialog_pri;
|
4918 |
case Navit.MAPDOWNLOAD_SEC_DIALOG:
|
4919 |
mapdownloader_dialog_sec = new ProgressDialog(this);
|
4920 |
mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
4921 |
mapdownloader_dialog_sec.setTitle("--");
|
4922 |
mapdownloader_dialog_sec.setMessage("--");
|
4923 |
|
4924 |
mapdownloader_dialog_sec.setCancelable(true);
|
4925 |
mapdownloader_dialog_sec.setProgress(0);
|
4926 |
mapdownloader_dialog_sec.setMax(200);
|
4927 |
DialogInterface.OnDismissListener mOnDismissListener2 = new DialogInterface.OnDismissListener()
|
4928 |
{
|
4929 |
public void onDismiss(DialogInterface dialog)
|
4930 |
{
|
4931 |
Log.e("Navit", "onDismiss: mapdownloader_dialog sec");
|
4932 |
dialog.dismiss();
|
4933 |
dialog.cancel();
|
4934 |
progressThread_sec.stop_thread();
|
4935 |
}
|
4936 |
};
|
4937 |
mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
|
4938 |
mapdownloader_sec = new NavitMapDownloader(this);
|
4939 |
progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler, NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
|
4940 |
progressThread_sec.start();
|
4941 |
// show license for OSM maps
|
4942 |
//. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
|
4943 |
Toast.makeText(getApplicationContext(), Navit.get_text("Map data (c) OpenStreetMap contributors, CC-BY-SA"), Toast.LENGTH_LONG).show(); //TRANS
|
4944 |
return mapdownloader_dialog_sec;
|
4945 |
}
|
4946 |
// should never get here!!
|
4947 |
return null;
|
4948 |
}
|
4949 |
|
4950 |
public void disableSuspend()
|
4951 |
{
|
4952 |
// wl.acquire();
|
4953 |
// wl.release();
|
4954 |
}
|
4955 |
|
4956 |
public void exit2()
|
4957 |
{
|
4958 |
System.out.println("in exit2");
|
4959 |
}
|
4960 |
|
4961 |
public void exit()
|
4962 |
{
|
4963 |
NavitVehicle.turn_off_all_providers();
|
4964 |
//try
|
4965 |
//{
|
4966 |
// NavitSpeech.stop_me();
|
4967 |
//}
|
4968 |
//catch (Exception s)
|
4969 |
//{
|
4970 |
// s.printStackTrace();
|
4971 |
//}
|
4972 |
|
4973 |
try
|
4974 |
{
|
4975 |
NavitSpeech2.stop_me();
|
4976 |
}
|
4977 |
catch (Exception s)
|
4978 |
{
|
4979 |
s.printStackTrace();
|
4980 |
}
|
4981 |
Log.e("Navit", "1***************** exit called ****************");
|
4982 |
Log.e("Navit", "2***************** exit called ****************");
|
4983 |
Log.e("Navit", "3***************** exit called ****************");
|
4984 |
Log.e("Navit", "4***************** exit called ****************");
|
4985 |
Log.e("Navit", "5***************** exit called ****************");
|
4986 |
Log.e("Navit", "6***************** exit called ****************");
|
4987 |
Log.e("Navit", "7***************** exit called ****************");
|
4988 |
Log.e("Navit", "8***************** exit called ****************");
|
4989 |
System.gc();
|
4990 |
NavitActivity(-4);
|
4991 |
Log.e("Navit", "XX1***************** exit called ****************");
|
4992 |
finish();
|
4993 |
Log.e("Navit", "XX2***************** exit called ****************");
|
4994 |
System.runFinalizersOnExit(true);
|
4995 |
Log.e("Navit", "XX3***************** exit called ****************");
|
4996 |
System.exit(0);
|
4997 |
Log.e("Navit", "XX4***************** exit called ****************");
|
4998 |
}
|
4999 |
|
5000 |
public boolean handleMessage(Message m)
|
5001 |
{
|
5002 |
//Log.e("Navit", "Handler received message");
|
5003 |
return true;
|
5004 |
}
|
5005 |
|
5006 |
//public static void set_zanavi_revision_in_settings()
|
5007 |
//{
|
5008 |
// // can it be that this is never used anymore??
|
5009 |
//
|
5010 |
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5011 |
// SharedPreferences.Editor editor = prefs.edit();
|
5012 |
// // editor.commit();
|
5013 |
//}
|
5014 |
|
5015 |
public static void follow_button_on()
|
5016 |
{
|
5017 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5018 |
SharedPreferences.Editor editor = prefs.edit();
|
5019 |
Navit.follow_current = Navit.follow_on;
|
5020 |
PREF_follow_gps = true;
|
5021 |
editor.putBoolean("follow_gps", PREF_follow_gps);
|
5022 |
editor.commit();
|
5023 |
|
5024 |
// hold all map drawing -----------
|
5025 |
Message msg = new Message();
|
5026 |
Bundle b = new Bundle();
|
5027 |
b.putInt("Callback", 69);
|
5028 |
msg.setData(b);
|
5029 |
try
|
5030 |
{
|
5031 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5032 |
}
|
5033 |
catch (Exception e)
|
5034 |
{
|
5035 |
e.printStackTrace();
|
5036 |
}
|
5037 |
// hold all map drawing -----------
|
5038 |
|
5039 |
getPrefs();
|
5040 |
activatePrefs(1);
|
5041 |
|
5042 |
// follow mode ON -----------
|
5043 |
msg = new Message();
|
5044 |
b = new Bundle();
|
5045 |
b.putInt("Callback", 74);
|
5046 |
msg.setData(b);
|
5047 |
try
|
5048 |
{
|
5049 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5050 |
}
|
5051 |
catch (Exception e)
|
5052 |
{
|
5053 |
e.printStackTrace();
|
5054 |
}
|
5055 |
// follow mode ON -----------
|
5056 |
|
5057 |
// allow all map drawing -----------
|
5058 |
msg = new Message();
|
5059 |
b = new Bundle();
|
5060 |
b.putInt("Callback", 70);
|
5061 |
msg.setData(b);
|
5062 |
try
|
5063 |
{
|
5064 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5065 |
}
|
5066 |
catch (Exception e)
|
5067 |
{
|
5068 |
}
|
5069 |
// allow all map drawing -----------
|
5070 |
|
5071 |
NavitVehicle.set_last_known_pos_fast_provider();
|
5072 |
}
|
5073 |
|
5074 |
public static void follow_button_off()
|
5075 |
{
|
5076 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5077 |
SharedPreferences.Editor editor = prefs.edit();
|
5078 |
Navit.follow_current = Navit.follow_off;
|
5079 |
PREF_follow_gps = false;
|
5080 |
editor.putBoolean("follow_gps", PREF_follow_gps);
|
5081 |
editor.commit();
|
5082 |
getPrefs();
|
5083 |
activatePrefs(1);
|
5084 |
|
5085 |
// follow mode OFF -----------
|
5086 |
Message msg = new Message();
|
5087 |
Bundle b = new Bundle();
|
5088 |
b.putInt("Callback", 75);
|
5089 |
msg.setData(b);
|
5090 |
try
|
5091 |
{
|
5092 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5093 |
}
|
5094 |
catch (Exception e)
|
5095 |
{
|
5096 |
}
|
5097 |
// follow mode OFF -----------
|
5098 |
|
5099 |
}
|
5100 |
|
5101 |
public static void toggle_follow_button()
|
5102 |
{
|
5103 |
// the "red needle" OSD calls this function only!!
|
5104 |
//Log.e("NavitVehicle", "toggle_follow_button");
|
5105 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5106 |
SharedPreferences.Editor editor = prefs.edit();
|
5107 |
if (PREF_follow_gps)
|
5108 |
{
|
5109 |
Navit.follow_current = Navit.follow_off;
|
5110 |
PREF_follow_gps = false;
|
5111 |
|
5112 |
// follow mode OFF -----------
|
5113 |
Message msg = new Message();
|
5114 |
Bundle b = new Bundle();
|
5115 |
b.putInt("Callback", 75);
|
5116 |
msg.setData(b);
|
5117 |
try
|
5118 |
{
|
5119 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5120 |
}
|
5121 |
catch (Exception e)
|
5122 |
{
|
5123 |
e.printStackTrace();
|
5124 |
}
|
5125 |
// follow mode OFF -----------
|
5126 |
}
|
5127 |
else
|
5128 |
{
|
5129 |
Navit.follow_current = Navit.follow_on;
|
5130 |
PREF_follow_gps = true;
|
5131 |
|
5132 |
// follow mode ON -----------
|
5133 |
Message msg = new Message();
|
5134 |
Bundle b = new Bundle();
|
5135 |
b.putInt("Callback", 74);
|
5136 |
msg.setData(b);
|
5137 |
try
|
5138 |
{
|
5139 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5140 |
}
|
5141 |
catch (Exception e)
|
5142 |
{
|
5143 |
e.printStackTrace();
|
5144 |
}
|
5145 |
// follow mode ON -----------
|
5146 |
}
|
5147 |
editor.putBoolean("follow_gps", PREF_follow_gps);
|
5148 |
editor.commit();
|
5149 |
//if (!PREF_follow_gps)
|
5150 |
//{
|
5151 |
// // no compass turning without follow mode!
|
5152 |
// PREF_use_compass_heading_base = false;
|
5153 |
//}
|
5154 |
//if (!PREF_use_compass_heading_base)
|
5155 |
//{
|
5156 |
// // child is always "false" when parent is "false" !!
|
5157 |
// PREF_use_compass_heading_always = false;
|
5158 |
//}
|
5159 |
|
5160 |
// hold all map drawing -----------
|
5161 |
Message msg = new Message();
|
5162 |
Bundle b = new Bundle();
|
5163 |
b.putInt("Callback", 69);
|
5164 |
msg.setData(b);
|
5165 |
try
|
5166 |
{
|
5167 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5168 |
}
|
5169 |
catch (Exception e)
|
5170 |
{
|
5171 |
e.printStackTrace();
|
5172 |
}
|
5173 |
// hold all map drawing -----------
|
5174 |
|
5175 |
getPrefs();
|
5176 |
activatePrefs(1);
|
5177 |
|
5178 |
// allow all map drawing -----------
|
5179 |
msg = new Message();
|
5180 |
b = new Bundle();
|
5181 |
b.putInt("Callback", 70);
|
5182 |
msg.setData(b);
|
5183 |
try
|
5184 |
{
|
5185 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5186 |
}
|
5187 |
catch (Exception e)
|
5188 |
{
|
5189 |
}
|
5190 |
// allow all map drawing -----------
|
5191 |
|
5192 |
NavitVehicle.set_last_known_pos_fast_provider();
|
5193 |
}
|
5194 |
|
5195 |
public static void setPrefs_search_country()
|
5196 |
{
|
5197 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5198 |
SharedPreferences.Editor editor = prefs.edit();
|
5199 |
editor.putInt("search_country_id", PREF_search_country);
|
5200 |
editor.commit();
|
5201 |
}
|
5202 |
|
5203 |
public static void setPrefs_zoomlevel()
|
5204 |
{
|
5205 |
System.out.println("1 save zoom level: " + Navit.GlobalScaleLevel);
|
5206 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5207 |
SharedPreferences.Editor editor = prefs.edit();
|
5208 |
editor.putInt("zoomlevel_num", Navit.GlobalScaleLevel);
|
5209 |
editor.commit();
|
5210 |
System.out.println("2 save zoom level: " + Navit.GlobalScaleLevel);
|
5211 |
}
|
5212 |
|
5213 |
private static void getPrefs_more_map_detail()
|
5214 |
{
|
5215 |
int ret = 0;
|
5216 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5217 |
try
|
5218 |
{
|
5219 |
PREF_more_map_detail = Integer.parseInt(prefs.getString("more_map_detail", "0"));
|
5220 |
}
|
5221 |
catch (Exception e)
|
5222 |
{
|
5223 |
PREF_more_map_detail = 0;
|
5224 |
}
|
5225 |
}
|
5226 |
|
5227 |
private static void getPrefs()
|
5228 |
{
|
5229 |
// Get the xml/preferences.xml preferences
|
5230 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5231 |
PREF_use_fast_provider = prefs.getBoolean("use_fast_provider", true);
|
5232 |
PREF_allow_gui_internal = prefs.getBoolean("allow_gui_internal", false);
|
5233 |
PREF_follow_gps = prefs.getBoolean("follow_gps", true);
|
5234 |
PREF_use_compass_heading_base = prefs.getBoolean("use_compass_heading_base", false);
|
5235 |
PREF_use_compass_heading_always = prefs.getBoolean("use_compass_heading_always", false);
|
5236 |
PREF_use_compass_heading_fast = prefs.getBoolean("use_compass_heading_fast", false);
|
5237 |
PREF_use_anti_aliasing = prefs.getBoolean("use_anti_aliasing", true);
|
5238 |
PREF_use_map_filtering = prefs.getBoolean("use_map_filtering", true);
|
5239 |
PREF_gui_oneway_arrows = prefs.getBoolean("gui_oneway_arrows", true);
|
5240 |
|
5241 |
PREF_show_debug_messages = prefs.getBoolean("show_debug_messages", false);
|
5242 |
|
5243 |
PREF_show_3d_map = prefs.getBoolean("show_3d_map", false);
|
5244 |
|
5245 |
PREF_use_smooth_drawing = prefs.getBoolean("use_smooth_drawing", true);
|
5246 |
PREF_use_lock_on_roads = prefs.getBoolean("use_lock_on_roads", true);
|
5247 |
PREF_use_route_highways = prefs.getBoolean("use_route_highways", true);
|
5248 |
PREF_save_zoomlevel = prefs.getBoolean("save_zoomlevel", true);
|
5249 |
PREF_search_country = prefs.getInt("search_country_id", 1); // default=*ALL*
|
5250 |
PREF_zoomlevel_num = prefs.getInt("zoomlevel_num", 2 * 2 * 2 * 2 * 2);
|
5251 |
PREF_show_sat_status = prefs.getBoolean("show_sat_status", false);
|
5252 |
PREF_use_agps = prefs.getBoolean("use_agps", true);
|
5253 |
PREF_enable_debug_functions = prefs.getBoolean("enable_debug_functions", false);
|
5254 |
PREF_speak_street_names = prefs.getBoolean("speak_street_names", true);
|
5255 |
PREF_use_custom_font = prefs.getBoolean("use_custom_font", true);
|
5256 |
PREF_draw_polyline_circles = prefs.getBoolean("draw_polyline_circles", true);
|
5257 |
PREF_streetsearch_r = prefs.getString("streetsearch_r", "2");
|
5258 |
PREF_route_style = prefs.getString("route_style", "2");
|
5259 |
PREF_item_dump = prefs.getBoolean("item_dump", false);
|
5260 |
PREF_show_route_rects = prefs.getBoolean("show_route_rects", false);
|
5261 |
PREF_trafficlights_delay = prefs.getString("trafficlights_delay", "0");
|
5262 |
|
5263 |
PREF_show_multipolygons = prefs.getBoolean("show_multipolygons", true);
|
5264 |
PREF_use_index_search = prefs.getBoolean("use_index_search", true);
|
5265 |
|
5266 |
try
|
5267 |
{
|
5268 |
PREF_drawatorder = Integer.parseInt(prefs.getString("drawatorder", "0"));
|
5269 |
}
|
5270 |
catch (Exception e)
|
5271 |
{
|
5272 |
PREF_drawatorder = 0;
|
5273 |
}
|
5274 |
|
5275 |
//try
|
5276 |
//{
|
5277 |
// PREF_cancel_map_drawing_timeout = Integer.parseInt(prefs.getString("cancel_map_drawing_timeout", "1"));
|
5278 |
//}
|
5279 |
//catch (Exception e)
|
5280 |
//{
|
5281 |
PREF_cancel_map_drawing_timeout = 1;
|
5282 |
//}
|
5283 |
|
5284 |
try
|
5285 |
{
|
5286 |
PREF_map_font_size = Integer.parseInt(prefs.getString("map_font_size", "2"));
|
5287 |
}
|
5288 |
catch (Exception e)
|
5289 |
{
|
5290 |
PREF_map_font_size = 2;
|
5291 |
}
|
5292 |
|
5293 |
Navit_last_address_search_country_id = PREF_search_country;
|
5294 |
Navit_last_address_search_country_iso2_string = NavitAddressSearchCountrySelectActivity.CountryList_Human[PREF_search_country][0];
|
5295 |
|
5296 |
if (!PREF_follow_gps)
|
5297 |
{
|
5298 |
// no compass turning without follow mode!
|
5299 |
PREF_use_compass_heading_base = false;
|
5300 |
}
|
5301 |
|
5302 |
if (!PREF_use_compass_heading_base)
|
5303 |
{
|
5304 |
// child is always "false" when parent is "false" !!
|
5305 |
PREF_use_compass_heading_always = false;
|
5306 |
}
|
5307 |
PREF_show_vehicle_in_center = prefs.getBoolean("show_vehicle_in_center", false);
|
5308 |
PREF_use_imperial = prefs.getBoolean("use_imperial", false);
|
5309 |
|
5310 |
// System.out.println("get settings");
|
5311 |
// System.out.println("PREF_search_country=" + PREF_search_country);
|
5312 |
// System.out.println("PREF_follow_gps=" + PREF_follow_gps);
|
5313 |
// System.out.println("PREF_use_fast_provider=" + PREF_use_fast_provider);
|
5314 |
// System.out.println("PREF_allow_gui_internal=" + PREF_allow_gui_internal);
|
5315 |
// System.out.println("PREF_use_compass_heading_base=" + PREF_use_compass_heading_base);
|
5316 |
// System.out.println("PREF_use_compass_heading_always=" + PREF_use_compass_heading_always);
|
5317 |
// System.out.println("PREF_show_vehicle_in_center=" + PREF_show_vehicle_in_center);
|
5318 |
// System.out.println("PREF_use_imperial=" + PREF_use_imperial);
|
5319 |
}
|
5320 |
|
5321 |
private static void activatePrefs()
|
5322 |
{
|
5323 |
activatePrefs(1);
|
5324 |
|
5325 |
if (PREF_save_zoomlevel)
|
5326 |
{
|
5327 |
// only if really started, but NOT if returning from our own child activities!!
|
5328 |
|
5329 |
System.out.println("3 restore zoom level: " + Navit.GlobalScaleLevel);
|
5330 |
System.out.println("4 restore zoom level: " + PREF_zoomlevel_num);
|
5331 |
|
5332 |
Message msg = new Message();
|
5333 |
Bundle b = new Bundle();
|
5334 |
b.putInt("Callback", 33);
|
5335 |
b.putString("s", Integer.toString(PREF_zoomlevel_num));
|
5336 |
msg.setData(b);
|
5337 |
try
|
5338 |
{
|
5339 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5340 |
Navit.GlobalScaleLevel = PREF_zoomlevel_num;
|
5341 |
System.out.println("5 restore zoom level: " + PREF_zoomlevel_num);
|
5342 |
}
|
5343 |
catch (Exception e)
|
5344 |
{
|
5345 |
}
|
5346 |
}
|
5347 |
else
|
5348 |
{
|
5349 |
PREF_zoomlevel_num = Navit.GlobalScaleLevel;
|
5350 |
}
|
5351 |
}
|
5352 |
|
5353 |
private static void activatePrefs(int dummy)
|
5354 |
{
|
5355 |
// call some functions to activate the new settings
|
5356 |
if (PREF_follow_gps)
|
5357 |
{
|
5358 |
Navit.follow_current = Navit.follow_on;
|
5359 |
}
|
5360 |
else
|
5361 |
{
|
5362 |
Navit.follow_current = Navit.follow_off;
|
5363 |
}
|
5364 |
|
5365 |
if (PREF_use_fast_provider)
|
5366 |
{
|
5367 |
NavitVehicle.turn_on_fast_provider();
|
5368 |
}
|
5369 |
else
|
5370 |
{
|
5371 |
NavitVehicle.turn_off_fast_provider();
|
5372 |
}
|
5373 |
|
5374 |
if (PREF_show_sat_status)
|
5375 |
{
|
5376 |
NavitVehicle.turn_on_sat_status();
|
5377 |
}
|
5378 |
else
|
5379 |
{
|
5380 |
// status always on !
|
5381 |
//
|
5382 |
// NavitVehicle.turn_off_sat_status();
|
5383 |
NavitVehicle.turn_on_sat_status();
|
5384 |
}
|
5385 |
|
5386 |
if (PREF_allow_gui_internal)
|
5387 |
{
|
5388 |
Message msg = new Message();
|
5389 |
Bundle b = new Bundle();
|
5390 |
b.putInt("Callback", 10);
|
5391 |
msg.setData(b);
|
5392 |
try
|
5393 |
{
|
5394 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5395 |
}
|
5396 |
catch (Exception e)
|
5397 |
{
|
5398 |
}
|
5399 |
}
|
5400 |
else
|
5401 |
{
|
5402 |
Message msg = new Message();
|
5403 |
Bundle b = new Bundle();
|
5404 |
b.putInt("Callback", 9);
|
5405 |
msg.setData(b);
|
5406 |
try
|
5407 |
{
|
5408 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5409 |
}
|
5410 |
catch (Exception e)
|
5411 |
{
|
5412 |
}
|
5413 |
}
|
5414 |
|
5415 |
if (PREF_use_compass_heading_base)
|
5416 |
{
|
5417 |
// turn on compass
|
5418 |
msg_to_msg_handler(new Bundle(), 12);
|
5419 |
Message msg = new Message();
|
5420 |
Bundle b = new Bundle();
|
5421 |
b.putInt("Callback", 11);
|
5422 |
msg.setData(b);
|
5423 |
try
|
5424 |
{
|
5425 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5426 |
}
|
5427 |
catch (Exception e)
|
5428 |
{
|
5429 |
}
|
5430 |
}
|
5431 |
else
|
5432 |
{
|
5433 |
// turn off compass
|
5434 |
msg_to_msg_handler(new Bundle(), 13);
|
5435 |
Message msg = new Message();
|
5436 |
Bundle b = new Bundle();
|
5437 |
b.putInt("Callback", 12);
|
5438 |
msg.setData(b);
|
5439 |
try
|
5440 |
{
|
5441 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5442 |
}
|
5443 |
catch (Exception e)
|
5444 |
{
|
5445 |
}
|
5446 |
}
|
5447 |
|
5448 |
if (PREF_show_vehicle_in_center)
|
5449 |
{
|
5450 |
Message msg = new Message();
|
5451 |
Bundle b = new Bundle();
|
5452 |
b.putInt("Callback", 14);
|
5453 |
msg.setData(b);
|
5454 |
try
|
5455 |
{
|
5456 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5457 |
}
|
5458 |
catch (Exception e)
|
5459 |
{
|
5460 |
}
|
5461 |
}
|
5462 |
else
|
5463 |
{
|
5464 |
Message msg = new Message();
|
5465 |
Bundle b = new Bundle();
|
5466 |
b.putInt("Callback", 13);
|
5467 |
msg.setData(b);
|
5468 |
try
|
5469 |
{
|
5470 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5471 |
}
|
5472 |
catch (Exception e)
|
5473 |
{
|
5474 |
}
|
5475 |
}
|
5476 |
|
5477 |
if (PREF_use_imperial)
|
5478 |
{
|
5479 |
Message msg = new Message();
|
5480 |
Bundle b = new Bundle();
|
5481 |
b.putInt("Callback", 16);
|
5482 |
msg.setData(b);
|
5483 |
try
|
5484 |
{
|
5485 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5486 |
}
|
5487 |
catch (Exception e)
|
5488 |
{
|
5489 |
}
|
5490 |
}
|
5491 |
else
|
5492 |
{
|
5493 |
Message msg = new Message();
|
5494 |
Bundle b = new Bundle();
|
5495 |
b.putInt("Callback", 15);
|
5496 |
msg.setData(b);
|
5497 |
try
|
5498 |
{
|
5499 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5500 |
}
|
5501 |
catch (Exception e)
|
5502 |
{
|
5503 |
}
|
5504 |
}
|
5505 |
|
5506 |
if (PREF_show_debug_messages)
|
5507 |
{
|
5508 |
Message msg = new Message();
|
5509 |
Bundle b = new Bundle();
|
5510 |
b.putInt("Callback", 24);
|
5511 |
msg.setData(b);
|
5512 |
try
|
5513 |
{
|
5514 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5515 |
}
|
5516 |
catch (Exception e)
|
5517 |
{
|
5518 |
}
|
5519 |
}
|
5520 |
else
|
5521 |
{
|
5522 |
Message msg = new Message();
|
5523 |
Bundle b = new Bundle();
|
5524 |
b.putInt("Callback", 25);
|
5525 |
msg.setData(b);
|
5526 |
try
|
5527 |
{
|
5528 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5529 |
}
|
5530 |
catch (Exception e)
|
5531 |
{
|
5532 |
}
|
5533 |
}
|
5534 |
|
5535 |
// if (PREF_show_3d_map)
|
5536 |
// {
|
5537 |
// Message msg = new Message();
|
5538 |
// Bundle b = new Bundle();
|
5539 |
// b.putInt("Callback", 31);
|
5540 |
// msg.setData(b);
|
5541 |
// try
|
5542 |
// {
|
5543 |
// N_NavitGraphics.callback_handler.sendMessage(msg);
|
5544 |
// }
|
5545 |
// catch (Exception e)
|
5546 |
// {
|
5547 |
// }
|
5548 |
// }
|
5549 |
// else
|
5550 |
// {
|
5551 |
// Message msg = new Message();
|
5552 |
// Bundle b = new Bundle();
|
5553 |
// b.putInt("Callback", 30);
|
5554 |
// msg.setData(b);
|
5555 |
// try
|
5556 |
// {
|
5557 |
// N_NavitGraphics.callback_handler.sendMessage(msg);
|
5558 |
// }
|
5559 |
// catch (Exception e)
|
5560 |
// {
|
5561 |
// }
|
5562 |
// }
|
5563 |
|
5564 |
if (PREF_use_lock_on_roads)
|
5565 |
{
|
5566 |
Message msg = new Message();
|
5567 |
Bundle b = new Bundle();
|
5568 |
b.putInt("Callback", 36);
|
5569 |
msg.setData(b);
|
5570 |
try
|
5571 |
{
|
5572 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5573 |
}
|
5574 |
catch (Exception e)
|
5575 |
{
|
5576 |
}
|
5577 |
}
|
5578 |
else
|
5579 |
{
|
5580 |
Message msg = new Message();
|
5581 |
Bundle b = new Bundle();
|
5582 |
b.putInt("Callback", 37);
|
5583 |
msg.setData(b);
|
5584 |
try
|
5585 |
{
|
5586 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5587 |
}
|
5588 |
catch (Exception e)
|
5589 |
{
|
5590 |
}
|
5591 |
}
|
5592 |
|
5593 |
// if (PREF_draw_polyline_circles)
|
5594 |
// {
|
5595 |
// Message msg = new Message();
|
5596 |
// Bundle b = new Bundle();
|
5597 |
// b.putString("s", "0");
|
5598 |
// b.putInt("Callback", 56);
|
5599 |
// msg.setData(b);
|
5600 |
// try
|
5601 |
// {
|
5602 |
// N_NavitGraphics.callback_handler.sendMessage(msg);
|
5603 |
// }
|
5604 |
// catch (Exception e)
|
5605 |
// {
|
5606 |
// }
|
5607 |
// }
|
5608 |
// else
|
5609 |
// {
|
5610 |
// Message msg = new Message();
|
5611 |
// Bundle b = new Bundle();
|
5612 |
// b.putString("s", "1");
|
5613 |
// b.putInt("Callback", 56);
|
5614 |
// msg.setData(b);
|
5615 |
// try
|
5616 |
// {
|
5617 |
// N_NavitGraphics.callback_handler.sendMessage(msg);
|
5618 |
// }
|
5619 |
// catch (Exception e)
|
5620 |
// {
|
5621 |
// }
|
5622 |
// }
|
5623 |
|
5624 |
if (PREF_use_route_highways)
|
5625 |
{
|
5626 |
Message msg = new Message();
|
5627 |
Bundle b = new Bundle();
|
5628 |
b.putInt("Callback", 42);
|
5629 |
msg.setData(b);
|
5630 |
try
|
5631 |
{
|
5632 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5633 |
}
|
5634 |
catch (Exception e)
|
5635 |
{
|
5636 |
}
|
5637 |
}
|
5638 |
else
|
5639 |
{
|
5640 |
Message msg = new Message();
|
5641 |
Bundle b = new Bundle();
|
5642 |
b.putInt("Callback", 43);
|
5643 |
msg.setData(b);
|
5644 |
try
|
5645 |
{
|
5646 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5647 |
}
|
5648 |
catch (Exception e)
|
5649 |
{
|
5650 |
}
|
5651 |
}
|
5652 |
|
5653 |
Message msg7 = new Message();
|
5654 |
Bundle b7 = new Bundle();
|
5655 |
b7.putInt("Callback", 57);
|
5656 |
b7.putString("s", "" + PREF_drawatorder);
|
5657 |
msg7.setData(b7);
|
5658 |
try
|
5659 |
{
|
5660 |
N_NavitGraphics.callback_handler.sendMessage(msg7);
|
5661 |
}
|
5662 |
catch (Exception e)
|
5663 |
{
|
5664 |
}
|
5665 |
|
5666 |
msg7 = new Message();
|
5667 |
b7 = new Bundle();
|
5668 |
b7.putInt("Callback", 58);
|
5669 |
b7.putString("s", PREF_streetsearch_r);
|
5670 |
msg7.setData(b7);
|
5671 |
try
|
5672 |
{
|
5673 |
N_NavitGraphics.callback_handler.sendMessage(msg7);
|
5674 |
}
|
5675 |
catch (Exception e)
|
5676 |
{
|
5677 |
}
|
5678 |
|
5679 |
if (PREF_speak_street_names)
|
5680 |
{
|
5681 |
Message msg = new Message();
|
5682 |
Bundle b = new Bundle();
|
5683 |
b.putInt("Callback", 54);
|
5684 |
msg.setData(b);
|
5685 |
try
|
5686 |
{
|
5687 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5688 |
}
|
5689 |
catch (Exception e)
|
5690 |
{
|
5691 |
}
|
5692 |
}
|
5693 |
else
|
5694 |
{
|
5695 |
Message msg = new Message();
|
5696 |
Bundle b = new Bundle();
|
5697 |
b.putInt("Callback", 53);
|
5698 |
msg.setData(b);
|
5699 |
try
|
5700 |
{
|
5701 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
5702 |
}
|
5703 |
catch (Exception e)
|
5704 |
{
|
5705 |
}
|
5706 |
|
5707 |
}
|
5708 |
|
5709 |
try
|
5710 |
{
|
5711 |
NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[PREF_cancel_map_drawing_timeout];
|
5712 |
NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[PREF_cancel_map_drawing_timeout];
|
5713 |
NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[PREF_cancel_map_drawing_timeout];
|
5714 |
}
|
5715 |
catch (Exception e)
|
5716 |
{
|
5717 |
|
5718 |
}
|
5719 |
|
5720 |
// route variant
|
5721 |
Message msg67 = new Message();
|
5722 |
Bundle b67 = new Bundle();
|
5723 |
// turn off 1
|
5724 |
b67.putInt("Callback", 60);
|
5725 |
b67.putString("s", "route_001");
|
5726 |
msg67.setData(b67);
|
5727 |
|
5728 |
try
|
5729 |
{
|
5730 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5731 |
}
|
5732 |
catch (Exception e)
|
5733 |
{
|
5734 |
}
|
5735 |
// turn off 2
|
5736 |
msg67 = new Message();
|
5737 |
b67 = new Bundle();
|
5738 |
b67.putInt("Callback", 60);
|
5739 |
b67.putString("s", "route_002");
|
5740 |
msg67.setData(b67);
|
5741 |
try
|
5742 |
{
|
5743 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5744 |
}
|
5745 |
catch (Exception e)
|
5746 |
{
|
5747 |
}
|
5748 |
|
5749 |
// turn on the wanted route style
|
5750 |
msg67 = new Message();
|
5751 |
b67 = new Bundle();
|
5752 |
b67.putInt("Callback", 59);
|
5753 |
b67.putString("s", "route_00" + PREF_route_style);
|
5754 |
msg67.setData(b67);
|
5755 |
try
|
5756 |
{
|
5757 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5758 |
}
|
5759 |
catch (Exception e)
|
5760 |
{
|
5761 |
}
|
5762 |
// route variant
|
5763 |
|
5764 |
// show route rectanlges -----
|
5765 |
if (PREF_show_route_rects)
|
5766 |
{
|
5767 |
msg67 = new Message();
|
5768 |
b67 = new Bundle();
|
5769 |
b67.putInt("Callback", 76);
|
5770 |
msg67.setData(b67);
|
5771 |
try
|
5772 |
{
|
5773 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5774 |
}
|
5775 |
catch (Exception e)
|
5776 |
{
|
5777 |
}
|
5778 |
}
|
5779 |
else
|
5780 |
{
|
5781 |
msg67 = new Message();
|
5782 |
b67 = new Bundle();
|
5783 |
b67.putInt("Callback", 77);
|
5784 |
msg67.setData(b67);
|
5785 |
try
|
5786 |
{
|
5787 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5788 |
}
|
5789 |
catch (Exception e)
|
5790 |
{
|
5791 |
}
|
5792 |
}
|
5793 |
// show route rectanlges -----
|
5794 |
|
5795 |
// show route multipolygons -----
|
5796 |
if (PREF_show_multipolygons)
|
5797 |
{
|
5798 |
msg67 = new Message();
|
5799 |
b67 = new Bundle();
|
5800 |
b67.putInt("Callback", 66);
|
5801 |
msg67.setData(b67);
|
5802 |
try
|
5803 |
{
|
5804 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5805 |
}
|
5806 |
catch (Exception e)
|
5807 |
{
|
5808 |
}
|
5809 |
}
|
5810 |
else
|
5811 |
{
|
5812 |
msg67 = new Message();
|
5813 |
b67 = new Bundle();
|
5814 |
b67.putInt("Callback", 67);
|
5815 |
msg67.setData(b67);
|
5816 |
try
|
5817 |
{
|
5818 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5819 |
}
|
5820 |
catch (Exception e)
|
5821 |
{
|
5822 |
}
|
5823 |
}
|
5824 |
// show route multipolygons -----
|
5825 |
|
5826 |
// traffic lights delay ----
|
5827 |
msg67 = new Message();
|
5828 |
b67 = new Bundle();
|
5829 |
b67.putInt("Callback", 79);
|
5830 |
System.out.println("traffic lights delay:" + PREF_trafficlights_delay);
|
5831 |
// (PREF_trafficlights_delay / 10) seconds delay for each traffic light
|
5832 |
b67.putString("s", PREF_trafficlights_delay); // (delay in 1/10 of a second)
|
5833 |
msg67.setData(b67);
|
5834 |
try
|
5835 |
{
|
5836 |
N_NavitGraphics.callback_handler.sendMessage(msg67);
|
5837 |
}
|
5838 |
catch (Exception e)
|
5839 |
{
|
5840 |
}
|
5841 |
// traffic lights delay ----
|
5842 |
|
5843 |
// set vars for mapdir change (only really takes effect after restart!)
|
5844 |
getPrefs_mapdir();
|
5845 |
}
|
5846 |
|
5847 |
private static void getPrefs_mapdir()
|
5848 |
{
|
5849 |
// Get the xml/preferences.xml preferences
|
5850 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5851 |
String default_sdcard_dir = Environment.getExternalStorageDirectory().getAbsolutePath();
|
5852 |
//Log.e("Navit", "old sdcard dir=" + NavitDataDirectory_Maps);
|
5853 |
//Log.e("Navit", "default sdcard dir=" + default_sdcard_dir);
|
5854 |
NavitDataDirectory_Maps = prefs.getString("map_directory", default_sdcard_dir + "/zanavi/maps/");
|
5855 |
// ** DEBUG ** NavitDataDirectory_Maps = prefs.getString("navit_mapsdir", "/sdcard" + "/zanavi/maps/");
|
5856 |
//Log.e("Navit", "new sdcard dir=" + NavitDataDirectory_Maps);
|
5857 |
}
|
5858 |
|
5859 |
static String sanity_check_maps_dir(String check_dir)
|
5860 |
{
|
5861 |
String ret = check_dir;
|
5862 |
ret = ret.replaceAll("\\n", ""); // newline -> ""
|
5863 |
ret = ret.replaceAll("\\r", ""); // return -> ""
|
5864 |
ret = ret.replaceAll("\\t", ""); // tab -> ""
|
5865 |
ret = ret.replaceAll(" ", ""); // space -> ""
|
5866 |
ret = ret.replaceAll("\"", ""); // \" -> ""
|
5867 |
ret = ret.replaceAll("'", ""); // \' -> ""
|
5868 |
ret = ret.replaceAll("\\\\", ""); // "\" -> ""
|
5869 |
if (!ret.endsWith("/"))
|
5870 |
{
|
5871 |
ret = ret + "/";
|
5872 |
}
|
5873 |
System.out.println("sanity check:" + ret);
|
5874 |
return ret;
|
5875 |
}
|
5876 |
|
5877 |
private static void activatePrefs_mapdir(Boolean at_startup)
|
5878 |
{
|
5879 |
// activate the new directory
|
5880 |
NavitDataDirectory_Maps = sanity_check_maps_dir(NavitDataDirectory_Maps);
|
5881 |
MAP_FILENAME_PATH = NavitDataDirectory_Maps;
|
5882 |
MAPMD5_FILENAME_PATH = NavitDataDirectory_Maps + "/../md5/";
|
5883 |
CFG_FILENAME_PATH = NavitDataDirectory_Maps + "/../";
|
5884 |
|
5885 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5886 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5887 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5888 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5889 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5890 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5891 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5892 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5893 |
//System.out.println("xxxxxxxx************XXXXXXXXXXX");
|
5894 |
|
5895 |
Handler h_temp = null;
|
5896 |
h_temp = NavitGraphics.callback_handler_s;
|
5897 |
//System.out.println("handler 1=" + h_temp.toString());
|
5898 |
|
5899 |
Message msg1 = new Message();
|
5900 |
Bundle b1 = new Bundle();
|
5901 |
b1.putInt("Callback", 47);
|
5902 |
b1.putString("s", MAP_FILENAME_PATH);
|
5903 |
msg1.setData(b1);
|
5904 |
h_temp.sendMessage(msg1);
|
5905 |
|
5906 |
if (!at_startup)
|
5907 |
{
|
5908 |
Message msg2 = new Message();
|
5909 |
Bundle b2 = new Bundle();
|
5910 |
b2.putInt("Callback", 18);
|
5911 |
msg2.setData(b2);
|
5912 |
h_temp.sendMessage(msg2);
|
5913 |
}
|
5914 |
}
|
5915 |
|
5916 |
private static void getPrefs_loc()
|
5917 |
{
|
5918 |
// Get the xml/preferences.xml preferences
|
5919 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5920 |
PREF_navit_lang = prefs.getString("navit_lang", "*DEFAULT*");
|
5921 |
System.out.println("**** ***** **** pref lang=" + PREF_navit_lang);
|
5922 |
}
|
5923 |
|
5924 |
private static void activatePrefs_loc()
|
5925 |
{
|
5926 |
// creating locale
|
5927 |
if (!PREF_navit_lang.equals("*DEFAULT*"))
|
5928 |
{
|
5929 |
Locale locale2 = null;
|
5930 |
if (PREF_navit_lang.contains("_"))
|
5931 |
{
|
5932 |
String _lang = PREF_navit_lang.split("_", 2)[0];
|
5933 |
String _country = PREF_navit_lang.split("_", 2)[1];
|
5934 |
System.out.println("l=" + _lang + " c=" + _country);
|
5935 |
locale2 = new Locale(_lang, _country);
|
5936 |
}
|
5937 |
else
|
5938 |
{
|
5939 |
locale2 = new Locale(PREF_navit_lang);
|
5940 |
}
|
5941 |
Locale.setDefault(locale2);
|
5942 |
Configuration config2 = new Configuration();
|
5943 |
config2.locale = locale2;
|
5944 |
// updating locale
|
5945 |
getBaseContext_.getResources().updateConfiguration(config2, null);
|
5946 |
}
|
5947 |
}
|
5948 |
|
5949 |
private static void getPrefs_mapcache()
|
5950 |
{
|
5951 |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Navit.getBaseContext_);
|
5952 |
try
|
5953 |
{
|
5954 |
PREF_mapcache = Integer.parseInt(prefs.getString("mapcache", "" + (10 * 1024)));
|
5955 |
}
|
5956 |
catch (Exception e)
|
5957 |
{
|
5958 |
e.printStackTrace();
|
5959 |
PREF_mapcache = 10 * 1024;
|
5960 |
}
|
5961 |
System.out.println("**** ***** **** pref mapcache=" + PREF_mapcache);
|
5962 |
}
|
5963 |
|
5964 |
private static void activatePrefs_mapcache()
|
5965 |
{
|
5966 |
Handler h_temp2 = null;
|
5967 |
h_temp2 = NavitGraphics.callback_handler_s;
|
5968 |
Message msg7 = new Message();
|
5969 |
Bundle b7 = new Bundle();
|
5970 |
b7.putInt("Callback", 55);
|
5971 |
b7.putString("s", String.valueOf(PREF_mapcache * 1024));
|
5972 |
msg7.setData(b7);
|
5973 |
h_temp2.sendMessage(msg7);
|
5974 |
}
|
5975 |
|
5976 |
public native void NavitMain(Navit x, String lang, int version, String display_density_string);
|
5977 |
|
5978 |
public native void NavitActivity(int activity);
|
5979 |
|
5980 |
/*
|
5981 |
* this is used to load the 'navit' native library on
|
5982 |
* application startup. The library has already been unpacked at
|
5983 |
* installation time by the package manager.
|
5984 |
*/
|
5985 |
static
|
5986 |
{
|
5987 |
System.loadLibrary("navit");
|
5988 |
}
|
5989 |
|
5990 |
/*
|
5991 |
* Show a search activity with the string "search" filled in
|
5992 |
*/
|
5993 |
private void executeSearch(String search)
|
5994 |
{
|
5995 |
Navit.use_index_search = Navit.allow_use_index_search();
|
5996 |
Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
|
5997 |
search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
|
5998 |
search_intent.putExtra("address_string", search);
|
5999 |
search_intent.putExtra("type", "offline");
|
6000 |
search_intent.putExtra("search_country_id", Navit_last_address_search_country_id);
|
6001 |
String pm_temp = "0";
|
6002 |
if (Navit_last_address_partial_match)
|
6003 |
{
|
6004 |
pm_temp = "1";
|
6005 |
}
|
6006 |
search_intent.putExtra("partial_match", pm_temp);
|
6007 |
this.startActivityForResult(search_intent, NavitAddressSearch_id_offline);
|
6008 |
}
|
6009 |
|
6010 |
/*
|
6011 |
* open google maps at a given coordinate
|
6012 |
*/
|
6013 |
private void googlemaps_show(String lat, String lon, String name)
|
6014 |
{
|
6015 |
// geo:latitude,longitude
|
6016 |
String url = null;
|
6017 |
Intent gmaps_intent = new Intent(Intent.ACTION_VIEW);
|
6018 |
|
6019 |
//url = "geo:" + lat + "," + lon + "?z=" + "16";
|
6020 |
//url = "geo:0,0?q=" + lat + "," + lon + " (" + name + ")";
|
6021 |
url = "geo:0,0?z=16&q=" + lat + "," + lon + " (" + name + ")";
|
6022 |
|
6023 |
gmaps_intent.setData(Uri.parse(url));
|
6024 |
this.startActivityForResult(gmaps_intent, NavitAddressSearch_id_gmaps);
|
6025 |
}
|
6026 |
|
6027 |
public void zoom_out_full()
|
6028 |
{
|
6029 |
System.out.println("");
|
6030 |
System.out.println("*** Zoom out FULL ***");
|
6031 |
System.out.println("");
|
6032 |
Message msg = new Message();
|
6033 |
Bundle b = new Bundle();
|
6034 |
b.putInt("Callback", 8);
|
6035 |
msg.setData(b);
|
6036 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
6037 |
}
|
6038 |
|
6039 |
public void show_geo_on_screen(float lat, float lng)
|
6040 |
{
|
6041 |
// -> let follow mode stay as it now is ### Navit.follow_button_off();
|
6042 |
|
6043 |
// this function sets screen center to "lat, lon", and just returns a dummy string!
|
6044 |
Navit.cwthr.CallbackGeoCalc2(2, 3, lat, lng);
|
6045 |
}
|
6046 |
|
6047 |
public void zoom_to_route()
|
6048 |
{
|
6049 |
//System.out.println("");
|
6050 |
//System.out.println("*** Zoom to ROUTE ***");
|
6051 |
//System.out.println("");
|
6052 |
Message msg = new Message();
|
6053 |
Bundle b = new Bundle();
|
6054 |
b.putInt("Callback", 17);
|
6055 |
msg.setData(b);
|
6056 |
N_NavitGraphics.callback_handler.sendMessage(msg);
|
6057 |
}
|
6058 |
|
6059 |
public void turn_on_compass()
|
6060 |
{
|
6061 |
try
|
6062 |
{
|
6063 |
if (!PREF_use_compass_heading_fast)
|
6064 |
|
6065 |
{
|
6066 |
// Slower
|
6067 |
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL);
|
6068 |
}
|
6069 |
else
|
6070 |
{
|
6071 |
// FAST
|
6072 |
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI);
|
6073 |
}
|
6074 |
}
|
6075 |
catch (Exception e)
|
6076 |
{
|
6077 |
e.printStackTrace();
|
6078 |
}
|
6079 |
}
|
6080 |
|
6081 |
public void turn_off_compass()
|
6082 |
{
|
6083 |
try
|
6084 |
{
|
6085 |
sensorManager.unregisterListener(this);
|
6086 |
}
|
6087 |
catch (Exception e)
|
6088 |
{
|
6089 |
e.printStackTrace();
|
6090 |
}
|
6091 |
}
|
6092 |
|
6093 |
public void onSensorChanged(SensorEvent event)
|
6094 |
{
|
6095 |
|
6096 |
if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD)
|
6097 |
{
|
6098 |
// System.out.println("Sensor.TYPE_MAGNETIC_FIELD");
|
6099 |
return;
|
6100 |
}
|
6101 |
|
6102 |
if (event.sensor.getType() == Sensor.TYPE_ORIENTATION)
|
6103 |
{
|
6104 |
// System.out.println("Sensor.TYPE_ORIENTATION");
|
6105 |
|
6106 |
// compass
|
6107 |
float myAzimuth = event.values[0];
|
6108 |
// double myPitch = event.values[1];
|
6109 |
// double myRoll = event.values[2];
|
6110 |
|
6111 |
//String out = String.format("Azimuth: %.2f", myAzimuth);
|
6112 |
//System.out.println("compass: " + out);
|
6113 |
NavitVehicle.update_compass_heading(myAzimuth);
|
6114 |
}
|
6115 |
}
|
6116 |
|
6117 |
public void onAccuracyChanged(Sensor sensor, int accuracy)
|
6118 |
{
|
6119 |
// compass
|
6120 |
}
|
6121 |
|
6122 |
public void hide_status_bar()
|
6123 |
{
|
6124 |
// Hide the Status Bar
|
6125 |
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
6126 |
}
|
6127 |
|
6128 |
public void show_status_bar()
|
6129 |
{
|
6130 |
// Hide the Status Bar
|
6131 |
// ??? getWindow().setFlags(0, 0);
|
6132 |
}
|
6133 |
|
6134 |
public void hide_title_bar()
|
6135 |
{
|
6136 |
// Hide the Title Bar - this works ONLY before setcontent in onCreate!!
|
6137 |
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
6138 |
}
|
6139 |
|
6140 |
public void show_title_bar()
|
6141 |
{
|
6142 |
// Hide the Title Bar - this works ONLY before setcontent in onCreate!!
|
6143 |
// ?? requestWindowFeature(Window.);
|
6144 |
}
|
6145 |
|
6146 |
public static Boolean downloadGPSXtra(Context context)
|
6147 |
{
|
6148 |
Boolean ret = false;
|
6149 |
Boolean ret2 = false;
|
6150 |
try
|
6151 |
{
|
6152 |
LocationManager locationmanager2 = (LocationManager) context.getSystemService("location");
|
6153 |
Bundle bundle = new Bundle();
|
6154 |
//ret2 = locationmanager2.sendExtraCommand("gps", "delete_aiding_data", null);
|
6155 |
//ret = ret2;
|
6156 |
// System.out.println("ret0=" + ret);
|
6157 |
ret2 = locationmanager2.sendExtraCommand("gps", "force_xtra_injection", bundle);
|
6158 |
ret = ret2;
|
6159 |
System.out.println("ret1=" + ret2);
|
6160 |
ret2 = locationmanager2.sendExtraCommand("gps", "force_time_injection", bundle);
|
6161 |
ret = ret || ret2;
|
6162 |
System.out.println("ret2=" + ret2);
|
6163 |
}
|
6164 |
catch (Exception e)
|
6165 |
{
|
6166 |
System.out.println("*XX*");
|
6167 |
e.printStackTrace();
|
6168 |
}
|
6169 |
return ret;
|
6170 |
}
|
6171 |
|
6172 |
static void add_map_point(Navit_Point_on_Map element)
|
6173 |
{
|
6174 |
if (element == null)
|
6175 |
{
|
6176 |
return;
|
6177 |
}
|
6178 |
if (map_points == null)
|
6179 |
{
|
6180 |
map_points = new ArrayList<Navit_Point_on_Map>();
|
6181 |
}
|
6182 |
if (map_points.size() > Navit_MAX_RECENT_DESTINATIONS)
|
6183 |
{
|
6184 |
try
|
6185 |
{
|
6186 |
map_points.remove(0);
|
6187 |
}
|
6188 |
catch (Exception e)
|
6189 |
{
|
6190 |
|
6191 |
}
|
6192 |
}
|
6193 |
|
6194 |
if (!check_dup_destination(element))
|
6195 |
{
|
6196 |
// if not duplicate, then add
|
6197 |
map_points.add(element);
|
6198 |
}
|
6199 |
}
|
6200 |
|
6201 |
void read_map_points()
|
6202 |
{
|
6203 |
deserialize_map_points();
|
6204 |
}
|
6205 |
|
6206 |
static void write_map_points()
|
6207 |
{
|
6208 |
if (map_points != null)
|
6209 |
{
|
6210 |
serialize_map_points();
|
6211 |
}
|
6212 |
}
|
6213 |
|
6214 |
private static void serialize_map_points()
|
6215 |
{
|
6216 |
FileOutputStream fos;
|
6217 |
try
|
6218 |
{
|
6219 |
fos = new FileOutputStream(CFG_FILENAME_PATH + Navit_DEST_FILENAME);
|
6220 |
// openFileOutput(CFG_FILENAME_PATH + Navit_DEST_FILENAME, Context.MODE_PRIVATE);
|
6221 |
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
6222 |
oos.writeObject(map_points);
|
6223 |
oos.close();
|
6224 |
}
|
6225 |
catch (FileNotFoundException e)
|
6226 |
{
|
6227 |
e.printStackTrace();
|
6228 |
}
|
6229 |
catch (IOException e)
|
6230 |
{
|
6231 |
e.printStackTrace();
|
6232 |
}
|
6233 |
catch (Exception e)
|
6234 |
{
|
6235 |
e.printStackTrace();
|
6236 |
}
|
6237 |
}
|
6238 |
|
6239 |
@SuppressWarnings("unchecked")
|
6240 |
private void deserialize_map_points()
|
6241 |
{
|
6242 |
try
|
6243 |
{
|
6244 |
FileInputStream fis = new FileInputStream(CFG_FILENAME_PATH + Navit_DEST_FILENAME);
|
6245 |
// openFileInput(CFG_FILENAME_PATH + Navit_DEST_FILENAME);
|
6246 |
ObjectInputStream ois = new ObjectInputStream(fis);
|
6247 |
map_points = (ArrayList<Navit_Point_on_Map>) ois.readObject();
|
6248 |
}
|
6249 |
catch (FileNotFoundException e)
|
6250 |
{
|
6251 |
e.printStackTrace();
|
6252 |
map_points = new ArrayList<Navit_Point_on_Map>();
|
6253 |
}
|
6254 |
catch (IOException e)
|
6255 |
{
|
6256 |
e.printStackTrace();
|
6257 |
map_points = new ArrayList<Navit_Point_on_Map>();
|
6258 |
}
|
6259 |
catch (ClassNotFoundException e)
|
6260 |
{
|
6261 |
e.printStackTrace();
|
6262 |
map_points = new ArrayList<Navit_Point_on_Map>();
|
6263 |
}
|
6264 |
catch (Exception e)
|
6265 |
{
|
6266 |
e.printStackTrace();
|
6267 |
map_points = new ArrayList<Navit_Point_on_Map>();
|
6268 |
}
|
6269 |
|
6270 |
// for (int j = 0; j < map_points.size(); j++)
|
6271 |
// {
|
6272 |
// System.out.println("####******************" + j + ":" + map_points.get(j).point_name);
|
6273 |
// }
|
6274 |
}
|
6275 |
|
6276 |
static void remember_destination_xy(String name, int x, int y)
|
6277 |
{
|
6278 |
// i=1 -> pixel a,b (x,y) -> geo string "lat(float):lng(float)"
|
6279 |
// i=2 -> geo a,b (lat,lng) -> pixel string "x(int):y(int)"
|
6280 |
String lat_lon = NavitGraphics.CallbackGeoCalc(1, x, y);
|
6281 |
try
|
6282 |
{
|
6283 |
String tmp[] = lat_lon.split(":", 2);
|
6284 |
//System.out.println("tmp=" + lat_lon);
|
6285 |
float lat = Float.parseFloat(tmp[0]);
|
6286 |
float lon = Float.parseFloat(tmp[1]);
|
6287 |
//System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
|
6288 |
remember_destination(name, lat, lon);
|
6289 |
}
|
6290 |
catch (Exception e)
|
6291 |
{
|
6292 |
e.printStackTrace();
|
6293 |
}
|
6294 |
}
|
6295 |
|
6296 |
static void remember_destination(String name, String lat, String lon)
|
6297 |
{
|
6298 |
try
|
6299 |
{
|
6300 |
//System.out.println("22 **## " + name + " " + lat + " " + lon + " ##**");
|
6301 |
remember_destination(name, Float.parseFloat(lat), Float.parseFloat(lon));
|
6302 |
}
|
6303 |
catch (Exception e)
|
6304 |
{
|
6305 |
e.printStackTrace();
|
6306 |
}
|
6307 |
}
|
6308 |
|
6309 |
static void remember_destination(String name, float lat, float lon)
|
6310 |
{
|
6311 |
//System.out.println("11 **## " + name + " " + lat + " " + lon + " ##**");
|
6312 |
Navit_Point_on_Map t = new Navit_Point_on_Map();
|
6313 |
t.point_name = name;
|
6314 |
t.lat = lat;
|
6315 |
t.lon = lon;
|
6316 |
add_map_point(t);
|
6317 |
}
|
6318 |
|
6319 |
static void destination_set()
|
6320 |
{
|
6321 |
// status = "destination set"
|
6322 |
NavitGraphics.navit_route_status = 1;
|
6323 |
}
|
6324 |
|
6325 |
static Boolean check_dup_destination(Navit_Point_on_Map element)
|
6326 |
{
|
6327 |
Boolean ret = false;
|
6328 |
Navit_Point_on_Map t;
|
6329 |
for (int i = 0; i < map_points.size(); i++)
|
6330 |
{
|
6331 |
t = map_points.get(i);
|
6332 |
if ((t.point_name.equals(element.point_name)) && (t.lat == element.lat) && (t.lon == element.lon))
|
6333 |
{
|
6334 |
return true;
|
6335 |
}
|
6336 |
}
|
6337 |
return ret;
|
6338 |
}
|
6339 |
|
6340 |
static NavitSpeech2 get_speech_object()
|
6341 |
{
|
6342 |
System.out.println("get_speech_object");
|
6343 |
return NSp;
|
6344 |
}
|
6345 |
|
6346 |
static NavitVehicle get_vehicle_object()
|
6347 |
{
|
6348 |
System.out.println("get_vehicle_object");
|
6349 |
return NV;
|
6350 |
}
|
6351 |
|
6352 |
static NavitGraphics get_graphics_object_by_name(String name)
|
6353 |
{
|
6354 |
System.out.println("get_graphics_object_by_name:*" + name + "*");
|
6355 |
|
6356 |
if (name.equals("type:map-main"))
|
6357 |
{
|
6358 |
System.out.println("map-main");
|
6359 |
return NG__map_main;
|
6360 |
}
|
6361 |
else
|
6362 |
{
|
6363 |
System.out.println("vehicle");
|
6364 |
return NG__vehicle;
|
6365 |
}
|
6366 |
}
|
6367 |
|
6368 |
public static Handler vehicle_handler = new Handler()
|
6369 |
{
|
6370 |
public void handleMessage(Message msg)
|
6371 |
{
|
6372 |
//System.out.println("vehicle_handler:handleMessage:JTHREAD ID=" + Thread.currentThread().getId());
|
6373 |
//System.out.println("vehicle_handler:handleMessage:THREAD ID=" + NavitGraphics.GetThreadId());
|
6374 |
|
6375 |
switch (msg.what)
|
6376 |
{
|
6377 |
case 1:
|
6378 |
Location l = new Location("Network");
|
6379 |
l.setLatitude(msg.getData().getFloat("lat"));
|
6380 |
l.setLongitude(msg.getData().getFloat("lng"));
|
6381 |
l.setBearing(msg.getData().getFloat("b"));
|
6382 |
l.setSpeed(0.8f);
|
6383 |
NavitVehicle.set_mock_location__fast(l);
|
6384 |
break;
|
6385 |
case 2:
|
6386 |
if (NavitVehicle.update_location_in_progress)
|
6387 |
{
|
6388 |
}
|
6389 |
else
|
6390 |
{
|
6391 |
NavitVehicle.update_location_in_progress = true;
|
6392 |
NavitVehicle.VehicleCallback2(NavitVehicle.last_location);
|
6393 |
NavitVehicle.update_location_in_progress = false;
|
6394 |
}
|
6395 |
break;
|
6396 |
}
|
6397 |
}
|
6398 |
};
|
6399 |
|
6400 |
public String roundTwoDecimals(double d)
|
6401 |
{
|
6402 |
return String.format("%.2f", d);
|
6403 |
}
|
6404 |
|
6405 |
public static int transform_from_geo_lat(double lat)
|
6406 |
{
|
6407 |
/* slower */
|
6408 |
// int ret = log(tan(M_PI_4 + lat * M_PI / 360)) * 6371000.0;
|
6409 |
/* slower */
|
6410 |
|
6411 |
/* fast */
|
6412 |
int ret = (int) (Math.log(Math.tan((Math.PI / 4f) + lat * 0.008726646259971647884618)) * 6371000.0f); // already calced (M_PI/360)
|
6413 |
/* fast */
|
6414 |
|
6415 |
return ret;
|
6416 |
}
|
6417 |
|
6418 |
public static int transform_from_geo_lon(double lon)
|
6419 |
{
|
6420 |
/* slower */
|
6421 |
// int ret = lon * 6371000.0 * M_PI / 180;
|
6422 |
/* slower */
|
6423 |
|
6424 |
/* fast */
|
6425 |
int ret = (int) (lon * 111194.9266445587373); // already calced (6371000.0*M_PI/180)
|
6426 |
/* fast */
|
6427 |
|
6428 |
return ret;
|
6429 |
}
|
6430 |
|
6431 |
public static double transform_to_geo_lat(float lat) // y
|
6432 |
{
|
6433 |
return (Math.atan(Math.exp(lat / 6371000.0)) / Math.PI * 360 - 90);
|
6434 |
}
|
6435 |
|
6436 |
public static double transform_to_geo_lon(float lon) // x
|
6437 |
{
|
6438 |
// g->lng=c->x/6371000.0/M_PI*180;
|
6439 |
return (lon * 0.00000899322); // simpler
|
6440 |
}
|
6441 |
|
6442 |
public static boolean allow_use_index_search()
|
6443 |
{
|
6444 |
if ((!Navit_DonateVersion_Installed) && (!Navit_Largemap_DonateVersion_Installed))
|
6445 |
{
|
6446 |
// no donate version installed
|
6447 |
Log.e("Navit", "no donate version installed");
|
6448 |
return false;
|
6449 |
}
|
6450 |
|
6451 |
if (!PREF_use_index_search)
|
6452 |
{
|
6453 |
// user does not want to use index search (it was disabled via preferences)
|
6454 |
return false;
|
6455 |
}
|
6456 |
|
6457 |
// MAP_FILENAME_PATH
|
6458 |
File folder = new File(MAP_FILENAME_PATH);
|
6459 |
File[] listOfFiles = folder.listFiles();
|
6460 |
|
6461 |
for (File file : listOfFiles)
|
6462 |
{
|
6463 |
if (file.isFile())
|
6464 |
{
|
6465 |
System.out.println(file.getName());
|
6466 |
if (file.getName().endsWith(".bin.idx"))
|
6467 |
{
|
6468 |
return true;
|
6469 |
}
|
6470 |
}
|
6471 |
}
|
6472 |
return false;
|
6473 |
}
|
6474 |
}
|