… | |
… | |
53 | import android.app.AlertDialog;
|
53 | import android.app.AlertDialog;
|
54 | import android.app.Dialog;
|
54 | import android.app.Dialog;
|
55 | import android.app.ProgressDialog;
|
55 | import android.app.ProgressDialog;
|
56 | import android.content.Context;
|
56 | import android.content.Context;
|
57 | import android.content.DialogInterface;
|
57 | import android.content.DialogInterface;
|
|
|
58 | import android.content.DialogInterface.OnCancelListener;
|
58 | import android.content.Intent;
|
59 | import android.content.Intent;
|
59 | import android.content.SharedPreferences;
|
60 | import android.content.SharedPreferences;
|
60 | import android.content.pm.PackageManager.NameNotFoundException;
|
61 | import android.content.pm.PackageManager.NameNotFoundException;
|
61 | import android.content.res.Configuration;
|
62 | import android.content.res.Configuration;
|
62 | import android.content.res.Resources;
|
63 | import android.content.res.Resources;
|
… | |
… | |
81 | import android.text.SpannableString;
|
82 | import android.text.SpannableString;
|
82 | import android.text.method.LinkMovementMethod;
|
83 | import android.text.method.LinkMovementMethod;
|
83 | import android.text.util.Linkify;
|
84 | import android.text.util.Linkify;
|
84 | import android.util.DisplayMetrics;
|
85 | import android.util.DisplayMetrics;
|
85 | import android.util.Log;
|
86 | import android.util.Log;
|
|
|
87 | import android.util.TypedValue;
|
86 | import android.view.Display;
|
88 | import android.view.Display;
|
|
|
89 | import android.view.Gravity;
|
87 | import android.view.Menu;
|
90 | import android.view.Menu;
|
88 | import android.view.MenuItem;
|
91 | import android.view.MenuItem;
|
89 | import android.view.Window;
|
92 | import android.view.Window;
|
90 | import android.view.WindowManager;
|
93 | import android.view.WindowManager;
|
91 | import android.view.inputmethod.InputMethodManager;
|
94 | import android.view.inputmethod.InputMethodManager;
|
… | |
… | |
95 |
|
98 |
|
96 | import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
|
99 | import com.zoffcc.applications.zanavi.NavitMapDownloader.ProgressThread;
|
97 |
|
100 |
|
98 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
101 | public class Navit extends Activity implements Handler.Callback, SensorEventListener
|
99 | {
|
102 | {
|
100 | public static final String VERSION_TEXT_LONG_INC_REV = "v1.0.0-850";
|
103 | public static final String VERSION_TEXT_LONG_INC_REV = "v1.0.0-930";
|
101 | public static String NavitAppVersion = "0";
|
104 | public static String NavitAppVersion = "0";
|
102 | public static String NavitAppVersion_prev = "-1";
|
105 | public static String NavitAppVersion_prev = "-1";
|
103 | public static String NavitAppVersion_string = "0";
|
106 | public static String NavitAppVersion_string = "0";
|
104 | private Boolean xmlconfig_unpack_file = true;
|
107 | private Boolean xmlconfig_unpack_file = true;
|
105 | private Boolean write_new_version_file = true;
|
108 | private Boolean write_new_version_file = true;
|
|
|
109 | final static int Navit_Status_COMPLETE_NEW_INSTALL = 1;
|
|
|
110 | final static int Navit_Status_UPGRADED_TO_NEW_VERSION = 2;
|
|
|
111 | final static int Navit_Status_NORMAL_STARTUP = 0;
|
|
|
112 | private int startup_status = Navit_Status_NORMAL_STARTUP;
|
106 |
|
113 |
|
107 | // for future use ...
|
114 | // for future use ...
|
108 | public static String NavitDataDirectory = "/sdcard/";
|
115 | public static String NavitDataDirectory = "/sdcard/";
|
109 |
|
116 |
|
110 | public static int GlobalScaleLevel = 0;
|
117 | public static int GlobalScaleLevel = 0;
|
… | |
… | |
372 | // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
379 | // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
|
373 | Navit.startup_intent_timestamp = System.currentTimeMillis();
|
380 | Navit.startup_intent_timestamp = System.currentTimeMillis();
|
374 | Log.e("Navit", "**1**A " + startup_intent.getAction());
|
381 | Log.e("Navit", "**1**A " + startup_intent.getAction());
|
375 | Log.e("Navit", "**1**D " + startup_intent.getDataString());
|
382 | Log.e("Navit", "**1**D " + startup_intent.getDataString());
|
376 |
|
383 |
|
|
|
384 | startup_status = Navit_Status_NORMAL_STARTUP;
|
|
|
385 |
|
377 | // init translated text
|
386 | // init translated text
|
378 | NavitTextTranslations.init();
|
387 | NavitTextTranslations.init();
|
379 |
|
388 |
|
380 | // set the new locale here -----------------------------------
|
389 | // set the new locale here -----------------------------------
|
381 | getPrefs_loc();
|
390 | getPrefs_loc();
|
… | |
… | |
553 | {
|
562 | {
|
554 | // different version
|
563 | // different version
|
555 | System.out.println("different version!!");
|
564 | System.out.println("different version!!");
|
556 | write_new_version_file = true;
|
565 | write_new_version_file = true;
|
557 | xmlconfig_unpack_file = true;
|
566 | xmlconfig_unpack_file = true;
|
|
|
567 |
|
|
|
568 | //if ((NavitAppVersion_prev.compareTo("-1") != 0) && (NavitAppVersion.compareTo("-1") != 0))
|
|
|
569 | //{
|
|
|
570 | // user has upgraded to a new version of ZANavi
|
|
|
571 | startup_status = Navit_Status_UPGRADED_TO_NEW_VERSION;
|
|
|
572 | //}
|
558 | }
|
573 | }
|
559 | else
|
574 | else
|
560 | {
|
575 | {
|
561 | // same version
|
576 | // same version
|
562 | System.out.println("same version");
|
577 | System.out.println("same version");
|
… | |
… | |
626 |
|
641 |
|
627 | try
|
642 | try
|
628 | {
|
643 | {
|
629 | sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
644 | sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
630 | }
|
645 | }
|
631 | catch (Exception e)
|
646 | catch (Exception e3)
|
632 | {
|
647 | {
|
633 | e.printStackTrace();
|
648 | e3.printStackTrace();
|
634 | }
|
649 | }
|
635 |
|
650 |
|
636 | // try
|
651 | // try
|
637 | // {
|
652 | // {
|
638 | // vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
653 | // vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
… | |
… | |
651 | infobox.setCancelable(false);
|
666 | infobox.setCancelable(false);
|
652 | final TextView message = new TextView(this);
|
667 | final TextView message = new TextView(this);
|
653 | message.setFadingEdgeLength(20);
|
668 | message.setFadingEdgeLength(20);
|
654 | message.setVerticalFadingEdgeEnabled(true);
|
669 | message.setVerticalFadingEdgeEnabled(true);
|
655 | message.setPadding(10, 5, 10, 5);
|
670 | message.setPadding(10, 5, 10, 5);
|
|
|
671 | message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
|
|
672 | message.setGravity(Gravity.LEFT);
|
|
|
673 | // message.setScrollBarStyle(TextView.SCROLLBARS_INSIDE_OVERLAY);
|
656 | //message.setVerticalScrollBarEnabled(true);
|
674 | // message.setVerticalScrollBarEnabled(true);
|
657 | RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
|
675 | RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
|
658 | // margins seem not to work, hmm strange
|
676 | rlp.leftMargin = 7;
|
659 | // so add a " " at start of every line. well whadda you gonna do ...
|
677 | rlp.rightMargin = 7;
|
660 | //rlp.leftMargin = 8; -> we use "m" string
|
|
|
661 |
|
678 |
|
662 | message.setLayoutParams(rlp);
|
679 | Navit.Navit_Geocoder = null;
|
663 | final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
|
680 | try
|
664 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
681 | {
|
665 | message.setText(s);
|
|
|
666 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
667 | infobox.setView(message);
|
|
|
668 |
|
|
|
669 | // for online search
|
682 | // for online search
|
670 | Navit.Navit_Geocoder = new Geocoder(this);
|
683 | Navit.Navit_Geocoder = new Geocoder(this);
|
|
|
684 | }
|
|
|
685 | catch (Exception e)
|
|
|
686 | {
|
|
|
687 | e.printStackTrace();
|
|
|
688 | }
|
671 |
|
689 |
|
672 | //TRANS
|
690 | //TRANS
|
673 | infobox.setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
|
691 | infobox.setPositiveButton(Navit.get_text("Ok"), new DialogInterface.OnClickListener()
|
674 | {
|
692 | {
|
675 | public void onClick(DialogInterface arg0, int arg1)
|
693 | public void onClick(DialogInterface arg0, int arg1)
|
… | |
… | |
696 | // if file does NOT exist, show the info box
|
714 | // if file does NOT exist, show the info box
|
697 | if (!navit_first_startup.exists())
|
715 | if (!navit_first_startup.exists())
|
698 | {
|
716 | {
|
699 | // set first-ever-startup flag
|
717 | // set first-ever-startup flag
|
700 | first_ever_startup = true;
|
718 | first_ever_startup = true;
|
|
|
719 | startup_status = Navit_Status_COMPLETE_NEW_INSTALL;
|
701 | FileOutputStream fos_temp;
|
720 | FileOutputStream fos_temp;
|
702 | try
|
721 | try
|
703 | {
|
722 | {
|
704 | fos_temp = new FileOutputStream(navit_first_startup);
|
723 | fos_temp = new FileOutputStream(navit_first_startup);
|
705 | fos_temp.write((int) 65); // just write an "A" to the file, but really doesnt matter
|
724 | fos_temp.write((int) 65); // just write an "A" to the file, but really doesnt matter
|
706 | fos_temp.flush();
|
725 | fos_temp.flush();
|
707 | fos_temp.close();
|
726 | fos_temp.close();
|
|
|
727 |
|
|
|
728 | message.setLayoutParams(rlp);
|
|
|
729 | final SpannableString s = new SpannableString(" " + Navit.get_text("__INFO_BOX_TEXT__")); //TRANS
|
|
|
730 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
|
|
731 | message.setText(s);
|
|
|
732 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
733 | infobox.setView(message);
|
|
|
734 |
|
708 | infobox.show();
|
735 | infobox.show();
|
709 | }
|
736 | }
|
710 | catch (Exception e)
|
737 | catch (Exception e)
|
711 | {
|
738 | {
|
712 | e.printStackTrace();
|
739 | e.printStackTrace();
|
713 | }
|
740 | }
|
714 | }
|
741 | }
|
715 | /*
|
742 | /*
|
716 | * show info box for first time users
|
743 | * show info box for first time users
|
717 | */
|
744 | */
|
|
|
745 |
|
|
|
746 | // show info box for upgrade
|
|
|
747 | if (startup_status == Navit_Status_UPGRADED_TO_NEW_VERSION)
|
|
|
748 | {
|
|
|
749 | try
|
|
|
750 | {
|
|
|
751 | message.setLayoutParams(rlp);
|
|
|
752 | final SpannableString s = new SpannableString("\n" + "ZANavi " + NavitAppVersion_string + "\n\n" + "upgraded");
|
|
|
753 | Linkify.addLinks(s, Linkify.WEB_URLS);
|
|
|
754 | message.setText(s);
|
|
|
755 | message.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
756 | infobox.setView(message);
|
|
|
757 |
|
|
|
758 | infobox.show();
|
|
|
759 | }
|
|
|
760 | catch (Exception e)
|
|
|
761 | {
|
|
|
762 | e.printStackTrace();
|
|
|
763 | }
|
|
|
764 | }
|
|
|
765 | // show info box for upgrade
|
718 |
|
766 |
|
719 | // make handler statically available for use in "msg_to_msg_handler"
|
767 | // make handler statically available for use in "msg_to_msg_handler"
|
720 | Navit_progress_h = this.progress_handler;
|
768 | Navit_progress_h = this.progress_handler;
|
721 |
|
769 |
|
722 | Display display_ = getWindowManager().getDefaultDisplay();
|
770 | Display display_ = getWindowManager().getDefaultDisplay();
|
… | |
… | |
866 |
|
914 |
|
867 | GpsStatus.Listener listener = new GpsStatus.Listener()
|
915 | GpsStatus.Listener listener = new GpsStatus.Listener()
|
868 | {
|
916 | {
|
869 | public void onGpsStatusChanged(int event)
|
917 | public void onGpsStatusChanged(int event)
|
870 | {
|
918 | {
|
871 | System.out.println("xxxxx");
|
919 | //System.out.println("xxxxx");
|
872 | if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS)
|
920 | if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS)
|
873 | {
|
921 | {
|
874 | }
|
922 | }
|
875 | }
|
923 | }
|
876 | };
|
924 | };
|
… | |
… | |
2026 | SearchResultsThreadSpinnerThread(Handler h, int dialog_num)
|
2074 | SearchResultsThreadSpinnerThread(Handler h, int dialog_num)
|
2027 | {
|
2075 | {
|
2028 | this.dialog_num = dialog_num;
|
2076 | this.dialog_num = dialog_num;
|
2029 | this.mHandler = h;
|
2077 | this.mHandler = h;
|
2030 | this.spinner_current_value = 0;
|
2078 | this.spinner_current_value = 0;
|
|
|
2079 |
|
2031 | this.running = true;
|
2080 | this.running = true;
|
2032 | Log.e("Navit", "SearchResultsThreadSpinnerThread created");
|
2081 | Log.e("Navit", "SearchResultsThreadSpinnerThread created");
|
2033 | }
|
2082 | }
|
2034 |
|
2083 |
|
2035 | public void run()
|
2084 | public void run()
|
… | |
… | |
2123 | Log.e("Navit", "SearchResultsThread run1");
|
2172 | Log.e("Navit", "SearchResultsThread run1");
|
2124 | // need lowercase to find stuff !!
|
2173 | // need lowercase to find stuff !!
|
2125 | Navit_last_address_search_string = filter_bad_chars(Navit_last_address_search_string).toLowerCase();
|
2174 | Navit_last_address_search_string = filter_bad_chars(Navit_last_address_search_string).toLowerCase();
|
2126 | if (Navit_last_address_full_file_search)
|
2175 | if (Navit_last_address_full_file_search)
|
2127 | {
|
2176 | {
|
2128 | // flags -> order level to search at
|
2177 | // flags (18) -> order level to search at
|
2129 | // ================
|
2178 | // ================
|
2130 | // 0#0 0 -> search full world
|
2179 | // 0#0 0 -> search full world
|
2131 | // lat#lon radius -> search only this area, around lat,lon
|
2180 | // lat#lon radius -> search only this area, around lat,lon
|
2132 | // ================
|
2181 | // ================
|
2133 | N_NavitGraphics.SearchResultList(3, partial_match_i, Navit_last_address_search_string, 18, Navit_last_address_search_country_iso2_string, "0#0", 0);
|
2182 | N_NavitGraphics.SearchResultList(3, partial_match_i, Navit_last_address_search_string, 18, Navit_last_address_search_country_iso2_string, "0#0", 0);
|
… | |
… | |
2416 | case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
|
2465 | case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
|
2417 | search_results_wait_offline = new ProgressDialog(this);
|
2466 | search_results_wait_offline = new ProgressDialog(this);
|
2418 | search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
2467 | search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
2419 | search_results_wait_offline.setTitle("--");
|
2468 | search_results_wait_offline.setTitle("--");
|
2420 | search_results_wait_offline.setMessage("--");
|
2469 | search_results_wait_offline.setMessage("--");
|
2421 | search_results_wait_offline.setCancelable(false);
|
2470 | search_results_wait_offline.setCancelable(true); // allow to stop search
|
2422 | search_results_wait_offline.setProgress(0);
|
2471 | search_results_wait_offline.setProgress(0);
|
2423 | search_results_wait_offline.setMax(10);
|
2472 | search_results_wait_offline.setMax(10);
|
|
|
2473 |
|
|
|
2474 | search_results_wait_offline.setOnCancelListener(new OnCancelListener()
|
|
|
2475 | {
|
|
|
2476 | public void onCancel(DialogInterface dialog)
|
|
|
2477 | {
|
|
|
2478 | Message msg = new Message();
|
|
|
2479 | Bundle b = new Bundle();
|
|
|
2480 | b.putInt("Callback", 46);
|
|
|
2481 | msg.setData(b);
|
|
|
2482 | try
|
|
|
2483 | {
|
|
|
2484 | N_NavitGraphics.callback_handler.sendMessage(msg);
|
|
|
2485 | }
|
|
|
2486 | catch (Exception e)
|
|
|
2487 | {
|
|
|
2488 | }
|
|
|
2489 | Log.e("Navit", "onCancel: search_results_wait offline");
|
|
|
2490 | }
|
|
|
2491 | });
|
|
|
2492 |
|
|
|
2493 | /*
|
|
|
2494 | * search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
|
|
|
2495 | * {
|
|
|
2496 | * public void onClick(DialogInterface dialog, int which)
|
|
|
2497 | * {
|
|
|
2498 | * // Use either finish() or return() to either close the activity or just the dialog
|
|
|
2499 | * return;
|
|
|
2500 | * }
|
|
|
2501 | * });
|
|
|
2502 | */
|
|
|
2503 |
|
2424 | DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener()
|
2504 | DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener()
|
2425 | {
|
2505 | {
|
2426 | public void onDismiss(DialogInterface dialog)
|
2506 | public void onDismiss(DialogInterface dialog)
|
2427 | {
|
2507 | {
|
2428 | Log.e("Navit", "onDismiss: search_results_wait offline");
|
2508 | Log.e("Navit", "onDismiss: search_results_wait offline");
|
… | |
… | |
2446 | search_results_wait.setTitle("--");
|
2526 | search_results_wait.setTitle("--");
|
2447 | search_results_wait.setMessage("--");
|
2527 | search_results_wait.setMessage("--");
|
2448 | search_results_wait.setCancelable(false);
|
2528 | search_results_wait.setCancelable(false);
|
2449 | search_results_wait.setProgress(0);
|
2529 | search_results_wait.setProgress(0);
|
2450 | search_results_wait.setMax(10);
|
2530 | search_results_wait.setMax(10);
|
|
|
2531 |
|
2451 | DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener()
|
2532 | DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener()
|
2452 | {
|
2533 | {
|
2453 | public void onDismiss(DialogInterface dialog)
|
2534 | public void onDismiss(DialogInterface dialog)
|
2454 | {
|
2535 | {
|
2455 | Log.e("Navit", "onDismiss: search_results_wait");
|
2536 | Log.e("Navit", "onDismiss: search_results_wait");
|