#include <string.h>
#include <poll.h>
+#include <glib.h>
+#include <stdlib.h>
#include "android.h"
#include <android/log.h>
#include "debug.h"
#include "event.h"
#include "callback.h"
+#include "projection.h"
+#include "map.h"
+
JNIEnv *jnienv;
jobject *android_activity;
struct callback_list *android_activity_cbl;
int android_version;
+struct navit *global_navit;
+
+struct attr attr;
+struct config {
+ struct attr **attrs;
+ struct callback_list *cbl;
+} *config;
+
+
int
android_find_class_global(char *name, jclass *ret)
{
{
char *s;
dbg(0,"enter %p %p\n",(struct callback *)i,str);
- s=(*env)->GetStringUTFChars(env, str, NULL);
- dbg(0,"string=%s\n",s);
+
+ config_get_attr(config, attr_navit, &attr, NULL);
+ // attr.u.navit
+
if (i)
{
if (i == 1)
{
// zoom in
- navit_cmd_zoom_in_void();
+ navit_zoom_in_cursor(global_navit, 2);
+ // navit_zoom_in_cursor(attr.u.navit, 2);
}
- if (i == 2)
+ else if (i == 2)
{
// zoom out
- navit_cmd_zoom_out_void();
+ navit_zoom_out_cursor(global_navit, 2);
+ // navit_zoom_out_cursor(attr.u.navit, 2);
+ }
+ else if (i == 3)
+ {
+ s=(*env)->GetStringUTFChars(env, str, NULL);
+ dbg(0,"*****string=%s\n",s);
+
+ // set destination to (lat#lon#title)
+ struct coord_geo g;
+ char *p;
+ char name[strlen(s)];
+ char *stopstring;
+
+ // lat
+ p = strtok (s,"#");
+ g.lat = strtof(p, &stopstring);
+ // lon
+ p = strtok (NULL, "#");
+ g.lng = strtof(p, &stopstring);
+ // description
+ *name = strtok (NULL, "#");
+
+ dbg(0,"lat=%f\n",g.lat);
+ dbg(0,"lng=%f\n",g.lng);
+ dbg(0,"str1=%s\n",name);
+
+ struct coord c;
+ transform_from_geo(projection_mg, &g, &c);
+
+ struct pcoord pc;
+ pc.x=c.x;
+ pc.y=c.y;
+ pc.pro=projection_mg;
+
+ dbg(0,"c x=%f\n",c.x);
+ dbg(0,"c y=%f\n",c.y);
+
+ dbg(0,"pc x=%f\n",pc.x);
+ dbg(0,"pc y=%f\n",pc.y);
+
+ // start navigation asynchronous
+ navit_set_destination(global_navit, &pc, &name, 1);
+
+ (*env)->ReleaseStringUTFChars(env, str, s);
}
}
- (*env)->ReleaseStringUTFChars(env, str, s);
}
super.onCreate(savedInstanceState);\r
\r
Intent startup_intent=this.getIntent();\r
- Log.e("Navit","****A "+startup_intent.getAction());\r
- Log.e("Navit","****D "+startup_intent.getDataString());\r
+ Log.e("Navit","**1**A "+startup_intent.getAction());\r
+ Log.e("Navit","**1**D "+startup_intent.getDataString());\r
\r
ActivityResults = new NavitActivityResult[16];\r
setVolumeControlStream(AudioManager.STREAM_MUSIC);\r
Log.e("Navit", "OnResume");\r
//InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);\r
NavitActivity(1);\r
+\r
+ Intent startup_intent=this.getIntent();\r
+ Log.e("Navit","**2**A "+startup_intent.getAction());\r
+ Log.e("Navit","**2**D "+startup_intent.getDataString());\r
+\r
+ String intent_data=startup_intent.getDataString();\r
+ if (intent_data != null)\r
+ {\r
+ // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse\r
+ // b: google.navigation:q=48.25676,16.643\r
+ String lat;\r
+ String lon;\r
+ String q;\r
+\r
+ String temp1=null;\r
+ String temp2=null;\r
+ String temp3=null;\r
+\r
+ // if b: then remodel the input string\r
+ if (intent_data.substring(0,20).equals("google.navigation:q="))\r
+ {\r
+ intent_data="ll="+intent_data.split("q=",-1)[1]+"&q=Target";\r
+ }\r
+\r
+\r
+ // now split the parts off\r
+ temp1=intent_data.split("&q=",-1)[0];\r
+ try\r
+ {\r
+ temp3=temp1.split("ll=",-1)[1];\r
+ temp2=intent_data.split("&q=",-1)[1];\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ // java.lang.ArrayIndexOutOfBoundsException most likely\r
+ // so let's assume we dont have '&q=xxxx'\r
+ temp3=temp1;\r
+ }\r
+\r
+ if (temp2 == null)\r
+ {\r
+ // use some default name\r
+ temp2 = "Target";\r
+ }\r
+\r
+ lat=temp3.split(",",-1)[0];\r
+ lon=temp3.split(",",-1)[1];\r
+ q=temp2;\r
+\r
+ Message msg = new Message();\r
+ Bundle b = new Bundle();\r
+ b.putInt("Callback", 3);\r
+ b.putString("lat", lat);\r
+ b.putString("lon", lon);\r
+ b.putString("q", q);\r
+ msg.setData(b);\r
+ N_NavitGraphics.callback_handler.sendMessage(msg);\r
+ }\r
+\r
}\r
@Override\r
public void onPause()\r
{
CallbackMessageChannel(2,"");
}
+ else if (msg.getData().getInt("Callback") == 3)
+ {
+ String lat=msg.getData().getString("lat");
+ String lon=msg.getData().getString("lon");
+ String q=msg.getData().getString("q");
+ CallbackMessageChannel(3,lat+"#"+lon+"#"+q);
+ }
else if (msg.getData().getInt("Callback") == 21)
{
//Log.e("NavitGraphics","callback_handler -> handleMessage 2");
navit_zoom_out(this_, 2, NULL);
}
-// zoom without args
-int navit_cmd_zoom_in_void()
-{
- navit_zoom_in_cursor(global_navit, 2);
-}
-
-int navit_cmd_zoom_out_void()
-{
- navit_zoom_out_cursor(global_navit, 2);
-}
-
static int
navit_cmd_zoom_in(struct navit *this_)
{
if (c) {
this_->destination=*c;
this_->destination_valid=1;
+
+ dbg(1, "navit->navit_set_destination %i\n", c->x);
+ dbg(1, "navit->navit_set_destination %i\n", c->y);
+
} else
this_->destination_valid=0;
char *destination_file = bookmarks_get_destination_file(TRUE);