Add:Android:generic message channel, make menu zoom work
authorzoff99 <zoff99@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 21 Jan 2011 19:03:37 +0000 (19:03 +0000)
committerzoff99 <zoff99@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 21 Jan 2011 19:03:37 +0000 (19:03 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3943 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/android.c
navit/navit/android/src/org/navitproject/navit/Navit.java
navit/navit/android/src/org/navitproject/navit/NavitGraphics.java
navit/navit/navit.c

index c7eafda..bd2064e 100644 (file)
@@ -11,7 +11,6 @@ jobject *android_activity;
 struct callback_list *android_activity_cbl;
 int android_version;
 
-
 int
 android_find_class_global(char *name, jclass *ret)
 {
@@ -169,4 +168,25 @@ Java_org_navitproject_navit_NavitSensors_SensorCallback( JNIEnv* env, jobject th
        callback_call_4((struct callback *)id, sensor, &x, &y, &z);
 }
 
-
+JNIEXPORT void JNICALL
+Java_org_navitproject_navit_NavitGraphics_CallbackMessageChannel( JNIEnv* env, jobject thiz, int i, jobject str)
+{
+       char *s;
+       dbg(0,"enter %p %p\n",(struct callback *)i,str);
+       s=(*env)->GetStringUTFChars(env, str, NULL);
+       dbg(0,"string=%s\n",s);
+       if (i)
+       {
+               if (i == 1)
+               {
+                       // zoom in
+                       navit_cmd_zoom_in_void();
+               }
+               if (i == 2)
+               {
+                       // zoom out
+                       navit_cmd_zoom_out_void();
+               }
+       }
+       (*env)->ReleaseStringUTFChars(env, str, s);
+}
index f8b7d7c..8cf7c0c 100644 (file)
@@ -317,7 +317,7 @@ public class Navit extends Activity implements Handler.Callback
                                s = java.lang.String.valueOf((char) 15);\r
                                msg = new Message();\r
                                b = new Bundle();\r
-                               b.putInt("Callback", 1);\r
+                               b.putInt("Callback", 2);\r
                                b.putString("s", s);\r
                                msg.setData(b);\r
                                N_NavitGraphics.callback_handler.sendMessage(msg);\r
index 5d1678b..65a5e30 100644 (file)
@@ -305,31 +305,36 @@ public class NavitGraphics
                                                                        if (scale > 1.3)
                                                                        {
                                                                                // zoom in
-                                                                               String s = java.lang.String.valueOf((char) 17);
-                                                                               KeypressCallback(KeypressCallbackID, s);
+                                                                               //String s = java.lang.String.valueOf((char) 17);
+                                                                               //KeypressCallback(KeypressCallbackID, s);
+
 
                                                                                // next lines are a hack, without it screen will not get updated anymore!
-                                                                               ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
-                                                                               MotionCallback(MotionCallbackID, x+15, y);
-                                                                               MotionCallback(MotionCallbackID, x-15, y);
-                                                                               ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
+                                                                               //ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
+                                                                               //MotionCallback(MotionCallbackID, x+15, y);
+                                                                               //MotionCallback(MotionCallbackID, x-15, y);
+                                                                               //ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
                                                                                //this.postInvalidate();
 
+                                                                               CallbackMessageChannel(1,"");
+
                                                                                //Log.e("NavitGraphics", "onTouch zoom in");
                                                                        }
                                                                        else if (scale < 0.8)
                                                                        {
                                                                                // zoom out    
-                                                                               String s = java.lang.String.valueOf((char) 15);
-                                                                               KeypressCallback(KeypressCallbackID, s);
+                                                                               //String s = java.lang.String.valueOf((char) 15);
+                                                                               //KeypressCallback(KeypressCallbackID, s);
 
                                                                                // next lines are a hack, without it screen will not get updated anymore!
-                                                                               ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
-                                                                               MotionCallback(MotionCallbackID, x+15, y);
-                                                                               MotionCallback(MotionCallbackID, x-15, y);
-                                                                               ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
+                                                                               //ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
+                                                                               //MotionCallback(MotionCallbackID, x+15, y);
+                                                                               //MotionCallback(MotionCallbackID, x-15, y);
+                                                                               //ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
                                                                                //this.postInvalidate();
-                                                                               
+
+                                                                               CallbackMessageChannel(2,"");
+
                                                                                //Log.e("NavitGraphics", "onTouch zoom out");
                                                                        }
 
@@ -362,7 +367,7 @@ public class NavitGraphics
                                                {
                                                        this.touch_now.set(event.getX(), event.getY());
                                                        this.touch_prev.set(event.getX(), event.getY());
-                                                       
+
                                                        //Log.e("NavitGraphics", "zoom 2");
                                                }
                                        }
@@ -834,15 +839,22 @@ public class NavitGraphics
                                                                                                                        if (msg.getData().getInt("Callback") == 1)
                                                                                                                        {
                                                                                                                                //Log.e("NavitGraphics","callback_handler -> handleMessage 1");
-                                                                                                                               KeypressCallback(KeypressCallbackID, msg.getData()
-                                                                                                                                               .getString("s"));
+                                                                                                                               //KeypressCallback(KeypressCallbackID, msg.getData()
+                                                                                                                               //              .getString("s"));
+               CallbackMessageChannel(1,"");
                                                                                                                        }
-                                                                                                                       else if (msg.getData().getInt("Callback") == 2)
+        else if (msg.getData().getInt("Callback") == 2)
+
+        {
+                CallbackMessageChannel(2,"");
+        }
+
+                                                                                                                       else if (msg.getData().getInt("Callback") == 21)
                                                                                                                        {
                                                                                                                                //Log.e("NavitGraphics","callback_handler -> handleMessage 2");
                                                                                                                                ButtonCallback(ButtonCallbackID, 1, 1, 0, 0); // down
                                                                                                                        }
-                                                                                                                       else if (msg.getData().getInt("Callback") == 3)
+                                                                                                                       else if (msg.getData().getInt("Callback") == 22)
                                                                                                                        {
                                                                                                                                //Log.e("NavitGraphics","callback_handler -> handleMessage 3");
                                                                                                                                ButtonCallback(ButtonCallbackID, 0, 1, 0, 0); // up
@@ -975,4 +987,13 @@ public class NavitGraphics
                pos_x = x;
                pos_y = y;
        }
+
+
+
+       /**
+       * generic message channel to C-code
+       */
+       public native int CallbackMessageChannel(int i,String s);
+
+
 }
index 5889fdb..9176651 100644 (file)
@@ -697,6 +697,16 @@ navit_zoom_out_cursor(struct navit *this_, int factor)
                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_)