if [ "$(builddir)" != "$(srcdir)" ]; then cp -rp $(srcdir)/android $(builddir)/android; fi
android update project -t 3 -p android
-apk: all-am android/build.xml
+apk: all android/build.xml
mkdir -p android/libs/armeabi
cp .libs/*.so */*/.libs/*.so android/libs/armeabi
for i in $(shell cd $(srcdir)/xpm && echo *.xpm); do convert $(srcdir)/xpm/$$i android/res/drawable/$${i%.xpm}.png; done
(*jnienv)->NewGlobalRef(jnienv, activity);
langstr=(*env)->GetStringUTFChars(env, lang, NULL);
dbg(0,"enter env=%p thiz=%p activity=%p lang=%s\n",env,thiz,activity,langstr);
+ setenv("LANG",langstr,1);
(*env)->ReleaseStringUTFChars(env, lang, langstr);
main_real(1, strings);
}
}
JNIEXPORT void JNICALL
+Java_org_navitproject_navit_NavitGraphics_KeypressCallback( JNIEnv* env, jobject thiz, int id, jobject str)
+{
+ char *s;
+ dbg(0,"enter %p %p\n",(struct callback *)id,str);
+ s=(*env)->GetStringUTFChars(env, str, NULL);
+ dbg(0,"key=%s\n",s);
+ if (id)
+ callback_call_1((struct callback *)id,s);
+ (*env)->ReleaseStringUTFChars(env, str, s);
+}
+
+JNIEXPORT void JNICALL
Java_org_navitproject_navit_NavitTimeout_TimeoutCallback( JNIEnv* env, jobject thiz, int delete, int id)
{
dbg(1,"enter %p %d %p\n",thiz, delete, (void *)id);
if (pos != -1) {
langc=langu.substring(0, pos);
langu=langc + langu.substring(pos).toUpperCase(locale);
+ } else {
+ String country=locale.getCountry();
+ Log.e("Navit","Country "+country);
+ langu=langc + "_" + country.toUpperCase(locale);
}
Log.e("Navit","Language " + lang);
Resources res=getResources();
import android.view.*;
import android.util.Log;
import java.util.ArrayList;
+import java.lang.String;
public class NavitGraphics {
private NavitGraphics parent_graphics;
int pos_y;
int pos_wraparound;
int overlay_disabled;
+ float trackball_x,trackball_y;
View view;
public NavitGraphics(Activity activity, NavitGraphics parent, int x, int y, int w, int h, int alpha, int wraparound) {
if (parent == null) {
}
@Override public boolean onTouchEvent(MotionEvent event)
{
+ super.onTouchEvent(event);
int action = event.getAction();
int x=(int)event.getX();
int y=(int)event.getY();
}
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
{
- Log.e("NavitGraphics","onKeyDown"+keyCode);
+ int i;
+ i=event.getUnicodeChar();
+ Log.e("NavitGraphics","onKeyDown "+keyCode+" "+i);
+ // Log.e("NavitGraphics","Unicode "+event.getUnicodeChar());
+ if (i != 0) {
+ String s=java.lang.String.valueOf((char)i);
+ KeypressCallback(KeypressCallbackID, s);
+ }
return true;
}
@Override public boolean onKeyUp(int keyCode, KeyEvent event)
{
- Log.e("NavitGraphics","onKeyUp"+keyCode);
+ Log.e("NavitGraphics","onKeyUp "+keyCode);
return true;
}
@Override public boolean onTrackballEvent(MotionEvent event)
{
- Log.e("NavitGraphics","onTrackball");
+ Log.e("NavitGraphics","onTrackball "+event.getX()+" "+event.getY());
+ trackball_x+=event.getX();
+ trackball_y+=event.getY();
+ String s=null;
+ Log.e("NavitGraphics","trackball "+trackball_x+" "+trackball_y);
+ if (trackball_x <= -1) {
+ s=java.lang.String.valueOf((char)2);
+ trackball_x+=1;
+ }
+ if (trackball_x >= 1) {
+ s=java.lang.String.valueOf((char)6);
+ trackball_x-=1;
+ }
+ if (trackball_y <= -1) {
+ s=java.lang.String.valueOf((char)16);
+ trackball_y+=1;
+ }
+ if (trackball_y >= 1) {
+ s=java.lang.String.valueOf((char)14);
+ trackball_y-=1;
+ }
+ if (s != null) {
+ KeypressCallback(KeypressCallbackID, s);
+ }
return true;
}
+ @Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
+ {
+ super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
+ Log.e("NavitGraphics","FocusChange "+gainFocus);
+ }
};
view.setFocusable(true);
+ view.setFocusableInTouchMode(true);
activity.setContentView(view);
+ view.requestFocus();
} else {
draw_bitmap=Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
bitmap_w=w;
public native void SizeChangedCallback(int id, int x, int y);
public native void ButtonCallback(int id, int pressed, int button, int x, int y);
public native void MotionCallback(int id, int x, int y);
+ public native void KeypressCallback(int id, String s);
private Canvas draw_canvas;
private Bitmap draw_bitmap;
- private int SizeChangedCallbackID,ButtonCallbackID,MotionCallbackID;
+ private int SizeChangedCallbackID,ButtonCallbackID,MotionCallbackID,KeypressCallbackID;
// private int count;
public void setSizeChangedCallback(int id)
{
MotionCallbackID=id;
}
+ public void setKeypressCallback(int id)
+ {
+ KeypressCallbackID=id;
+ }
protected void draw_polyline(Paint paint,int c[])
{
NavitWatch(int fd, int cond, int callbackid)
{
- Log.e("NavitWatch","Creating new thread for "+fd+" "+cond+" from current thread " + java.lang.Thread.currentThread().getName());
+ // Log.e("NavitWatch","Creating new thread for "+fd+" "+cond+" from current thread " + java.lang.Thread.currentThread().getName());
watch_fd=fd;
watch_cond=cond;
watch_callbackid=callbackid;
public void run()
{
for (;;) {
- Log.e("NavitWatch","Polling "+watch_fd+" "+watch_cond + " from " + java.lang.Thread.currentThread().getName());
+ // Log.e("NavitWatch","Polling "+watch_fd+" "+watch_cond + " from " + java.lang.Thread.currentThread().getName());
poll(watch_fd, watch_cond);
- Log.e("NavitWatch","poll returned");
+ // Log.e("NavitWatch","poll returned");
if (removed)
break;
handler.post(callback_runnable);
}
public void callback()
{
- Log.e("NavitWatch","Calling Callback");
+ // Log.e("NavitWatch","Calling Callback");
if (!removed)
WatchCallback(watch_callbackid);
synchronized(this) {
}
static void
+keypress_callback(struct graphics_priv *gra, char *s)
+{
+ dbg(0,"enter %s\n",s);
+ callback_list_call_attr_1(gra->cbl, attr_keypress, s);
+}
+
+static void
button_callback(struct graphics_priv *gra, int pressed, int button, int x, int y)
{
struct point p;
cb=callback_new_1(callback_cast(motion_callback), ret);
(*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setKeypressCallback", "(I)V");
+ if (cid == NULL) {
+ dbg(0,"no SetKeypressCallback method found\n");
+ return 0; /* exception thrown */
+ }
+ cb=callback_new_1(callback_cast(keypress_callback), ret);
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+
if (!find_method(ret->NavitGraphicsClass, "draw_polyline", "(Landroid/graphics/Paint;[I)V", &ret->NavitGraphics_draw_polyline))
return 0;
if (!find_method(ret->NavitGraphicsClass, "draw_polygon", "(Landroid/graphics/Paint;[I)V", &ret->NavitGraphics_draw_polygon))
#define NAVIT_KEY_ZOOM_OUT 15
#define NAVIT_KEY_UP 16
#define NAVIT_KEY_ZOOM_IN 17
+#define NAVIT_KEY_MENU 1