import android.media.AudioManager;\r
import android.net.Uri;\r
import android.os.Bundle;\r
-import android.os.Handler;\r
import android.os.Message;\r
import android.os.PowerManager;\r
import android.text.SpannableString;\r
import android.widget.Toast;\r
\r
\r
-public class Navit extends Activity implements Handler.Callback\r
+public class Navit extends Activity\r
{\r
public static final class Navit_Address_Result_Struct\r
{\r
String addr;\r
}\r
\r
- public Handler handler;\r
- public NavitDialogs dialogs;\r
- private PowerManager.WakeLock wl;\r
- private NavitActivityResult ActivityResults[];\r
- public static InputMethodManager mgr = null;\r
- public static DisplayMetrics metrics = null;\r
- public static Boolean show_soft_keyboard = false;\r
- public static Boolean show_soft_keyboard_now_showing = false;\r
- public static long last_pressed_menu_key = 0L;\r
- public static long time_pressed_menu_key = 0L;\r
- private static Intent startup_intent = null;\r
- private static long startup_intent_timestamp = 0L;\r
- public static String my_display_density = "mdpi";\r
- private boolean searchBoxShown = false;\r
- public static final int ADDRESS_RESULTS_DIALOG_MAX = 10;\r
- public static final int NavitDownloaderPriSelectMap_id = 967;\r
- public static final int NavitDownloaderSecSelectMap_id = 968;\r
- public static int search_results_towns = 0;\r
- public static int search_results_streets = 0;\r
- public static int search_results_streets_hn = 0;\r
- public static final int MAP_NUM_PRIMARY = 11;\r
- public static final int NavitAddressSearch_id = 70;\r
- public static final int NavitAddressResultList_id = 71;\r
- public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems = new ArrayList<Navit_Address_Result_Struct>();\r
-\r
-\r
- public static final int MAP_NUM_SECONDARY = 12;\r
- static final String MAP_FILENAME_PATH = "/sdcard/navit/";\r
- static final String NAVIT_DATA_DIR = "/data/data/org.navitproject.navit";\r
- static final String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR\r
- + "/share";\r
- static final String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR\r
- + "/has_run_once.txt";\r
+ public NavitDialogs dialogs;\r
+ private PowerManager.WakeLock wl;\r
+ private NavitActivityResult ActivityResults[];\r
+ public static InputMethodManager mgr = null;\r
+ public static DisplayMetrics metrics = null;\r
+ public static Boolean show_soft_keyboard = false;\r
+ public static Boolean show_soft_keyboard_now_showing = false;\r
+ public static long last_pressed_menu_key = 0L;\r
+ public static long time_pressed_menu_key = 0L;\r
+ private static Intent startup_intent = null;\r
+ private static long startup_intent_timestamp = 0L;\r
+ public static String my_display_density = "mdpi";\r
+ private boolean searchBoxShown = false;\r
+ public static final int ADDRESS_RESULTS_DIALOG_MAX = 10;\r
+ public static final int NavitDownloaderPriSelectMap_id = 967;\r
+ public static final int NavitDownloaderSecSelectMap_id = 968;\r
+ public static int search_results_towns = 0;\r
+ public static int search_results_streets = 0;\r
+ public static int search_results_streets_hn = 0;\r
+ public static final int MAP_NUM_PRIMARY = 11;\r
+ public static final int NavitAddressSearch_id = 70;\r
+ public static final int NavitAddressResultList_id = 71;\r
+ public static List<Navit_Address_Result_Struct> NavitAddressResultList_foundItems \r
+ = new ArrayList<Navit_Address_Result_Struct>();\r
+\r
+ public static final int MAP_NUM_SECONDARY = 12;\r
+ static final String MAP_FILENAME_PATH = "/sdcard/navit/";\r
+ static final String NAVIT_DATA_DIR = "/data/data/org.navitproject.navit";\r
+ static final String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";\r
+ static final String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";\r
\r
public static String get_text(String in)\r
{\r
// Android 1.1 2\r
// Android 1.0 1\r
\r
- NavitActivity(3);\r
-\r
Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);\r
\r
// unpack some localized Strings\r
String x = NavitGraphics.getLocalizedString("Austria");\r
Log.e("Navit", "x=" + x);\r
}\r
- @Override\r
- public void onStart()\r
- {\r
- super.onStart();\r
- Log.e("Navit", "OnStart");\r
- NavitActivity(2);\r
- }\r
-\r
- @Override\r
- public void onRestart()\r
- {\r
- super.onRestart();\r
- Log.e("Navit", "OnRestart");\r
- NavitActivity(0);\r
- }\r
\r
@Override\r
public void onResume()\r
super.onResume();\r
Log.e("Navit", "OnResume");\r
//InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);\r
- NavitActivity(1);\r
\r
String intent_data = null;\r
if (startup_intent != null)\r
if ((intent_data != null) && (intent_data.substring(0, 18).equals("google.navigation:")))\r
{\r
// better use regex later, but for now to test this feature its ok :-)\r
- // better use regex later, but for now to test this feature its ok :-)\r
\r
// d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)\r
// a: google.navigation:ll=48.25676,16.643&q=blabla-strasse\r
boolean unparsable_info_box = true;\r
\r
// DEBUG\r
- // DEBUG\r
- // DEBUG\r
// intent_data = "google.navigation:q=Wien Burggasse 27";\r
// intent_data = "google.navigation:q=48.25676,16.643";\r
// intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";\r
// intent_data = "google.navigation:ll=48.25676,16.643";\r
- // DEBUG\r
- // DEBUG\r
- // DEBUG\r
\r
Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));\r
Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));\r
}\r
}\r
}\r
- @Override\r
- public void onPause()\r
- {\r
- super.onPause();\r
- Log.e("Navit", "OnPause");\r
- NavitActivity(-1);\r
- }\r
-\r
- @Override\r
- public void onStop()\r
- {\r
- super.onStop();\r
- Log.e("Navit", "OnStop");\r
- NavitActivity(-2);\r
- }\r
-\r
- @Override\r
- public void onDestroy()\r
- {\r
- super.onDestroy();\r
- Log.e("Navit", "OnDestroy");\r
- NavitActivity(-3);\r
- }\r
-\r
\r
public void setActivityResult(int requestCode, NavitActivityResult ActivityResult)\r
{\r
}\r
\r
@Override\r
- public boolean onCreateOptionsMenu(Menu menu)\r
- {\r
- super.onCreateOptionsMenu(menu);\r
- //Log.e("Navit","onCreateOptionsMenu");\r
- return true;\r
- }\r
-\r
- @Override\r
public boolean onPrepareOptionsMenu(Menu menu)\r
{\r
super.onPrepareOptionsMenu(menu);\r
finish();\r
}\r
\r
- public boolean handleMessage(Message m)\r
- {\r
- //Log.e("Navit", "Handler received message");\r
- return true;\r
- }\r
-\r
public native void NavitMain(Navit x, String lang, int version, String display_density_string, String path);\r
\r
- public native void NavitActivity(int activity);\r
-\r
/*\r
* this is used to load the 'navit' native library on\r
* application startup. The library has already been unpacked at\r
{
switch (msg.what)
{
- case MSG_REMOVE_PROGRESS_BAR :
- // dismiss dialog, remove dialog
- mActivity.dismissDialog(DIALOG_MAPDOWNLOAD);
- mActivity.removeDialog(DIALOG_MAPDOWNLOAD);
+ case MSG_REMOVE_PROGRESS_BAR :
+ // dismiss dialog, remove dialog
+ mActivity.dismissDialog(DIALOG_MAPDOWNLOAD);
+ mActivity.removeDialog(DIALOG_MAPDOWNLOAD);
- // exit_code=0 -> OK, map was downloaded fine
- if (msg.getData().getInt("value1") == 0)
- {
- // try to use the new downloaded map (works fine now!)
- Log.d("Navit", "instance count=" + Navit.getInstanceCount());
- //mActivity.onStop();
- //mActivity.onCreate(mActivity.getIntent().getExtras());
- }
- break;
- case MSG_PROGRESS_BAR :
- // change progressbar values
- mapdownloader_dialog.setMax(msg.getData().getInt("value1"));
- mapdownloader_dialog.setProgress(msg.getData().getInt("value2"));
- mapdownloader_dialog.setTitle(msg.getData().getString("title"));
- mapdownloader_dialog.setMessage(msg.getData().getString("text"));
- break;
- case MSG_TOAST :
- Toast.makeText(mActivity, msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
- break;
- case MSG_TOAST_LONG :
- Toast.makeText(mActivity, msg.getData().getString("text"), Toast.LENGTH_LONG).show();
- break;
- case MSG_PROGRESS_BAR_SEARCH :
- // change values - generic
- int what_dialog_generic = msg.getData().getInt("dialog_num");
- if (what_dialog_generic == DIALOG_SEARCHRESULTS_WAIT)
- {
- search_results_wait.setMax(msg.getData().getInt("value1"));
- search_results_wait.setProgress(msg.getData().getInt("value2"));
- search_results_wait.setTitle(msg.getData().getString("title"));
- search_results_wait.setMessage(msg.getData().getString("text"));
- }
- break;
- case MSG_SEARCH :
- // show dialog - generic
- mActivity.showDialog(DIALOG_SEARCHRESULTS_WAIT);
- break;
- case MSG_START_MAP_DOWNLOAD:
+ // exit_code=0 -> OK, map was downloaded fine
+ if (msg.getData().getInt("value1") == 0)
+ {
+ // try to use the new downloaded map (works fine now!)
+ Log.d("Navit", "instance count=" + Navit.getInstanceCount());
+ //mActivity.onStop();
+ //mActivity.onCreate(mActivity.getIntent().getExtras());
+ }
+ break;
+ case MSG_PROGRESS_BAR :
+ // change progressbar values
+ mapdownloader_dialog.setMax(msg.getData().getInt("value1"));
+ mapdownloader_dialog.setProgress(msg.getData().getInt("value2"));
+ mapdownloader_dialog.setTitle(msg.getData().getString("title"));
+ mapdownloader_dialog.setMessage(msg.getData().getString("text"));
+ break;
+ case MSG_TOAST :
+ Toast.makeText(mActivity, msg.getData().getString("text"), Toast.LENGTH_SHORT).show();
+ break;
+ case MSG_TOAST_LONG :
+ Toast.makeText(mActivity, msg.getData().getString("text"), Toast.LENGTH_LONG).show();
+ break;
+ case MSG_PROGRESS_BAR_SEARCH :
+ // change values - generic
+ int what_dialog_generic = msg.getData().getInt("dialog_num");
+ if (what_dialog_generic == DIALOG_SEARCHRESULTS_WAIT)
{
- int map_selected = msg.arg1;
- int map_slot = msg.arg2;
- Log.d("Navit", "PRI id=" + map_selected);
- // set map id to download
+ search_results_wait.setMax(msg.getData().getInt("value1"));
+ search_results_wait.setProgress(msg.getData().getInt("value2"));
+ search_results_wait.setTitle(msg.getData().getString("title"));
+ search_results_wait.setMessage(msg.getData().getString("text"));
+ }
+ break;
+ case MSG_SEARCH :
+ // show dialog - generic
+ mActivity.showDialog(DIALOG_SEARCHRESULTS_WAIT);
+ break;
+ case MSG_START_MAP_DOWNLOAD:
+ {
+ int map_selected = msg.arg1;
+ int map_slot = msg.arg2;
+ Log.d("Navit", "PRI id=" + map_selected);
+ // set map id to download
- int download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[map_selected];
- // show the map download progressbar, and download the map
- if (download_map_id > -1)
- {
- mActivity.showDialog(NavitDialogs.DIALOG_MAPDOWNLOAD);
+ int download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[map_selected];
+ // show the map download progressbar, and download the map
+ if (download_map_id > -1)
+ {
+ mActivity.showDialog(NavitDialogs.DIALOG_MAPDOWNLOAD);
- mapdownloader = new NavitMapDownloader(download_map_id
- , NavitDialogs.DIALOG_MAPDOWNLOAD, map_slot);
- mapdownloader.start();
+ mapdownloader = new NavitMapDownloader(download_map_id
+ , NavitDialogs.DIALOG_MAPDOWNLOAD, map_slot);
+ mapdownloader.start();
- }
}
+ }
+ break;
+
+ case 99 :
+ // dismiss dialog, remove dialog - generic
+ mActivity.dismissDialog(msg.getData().getInt("dialog_num"));
+ mActivity.removeDialog(msg.getData().getInt("dialog_num"));
break;
-
- case 99 :
- // dismiss dialog, remove dialog - generic
- mActivity.dismissDialog(msg.getData().getInt("dialog_num"));
- mActivity.removeDialog(msg.getData().getInt("dialog_num"));
- break;
}
}