+++ /dev/null
-#include <string.h>
-#include <poll.h>
-#include "android.h"
-#include <android/log.h>
-#include "debug.h"
-#include "event.h"
-#include "callback.h"
-
-JNIEnv *jnienv;
-jobject *android_activity;
-
-
-int
-android_find_class_global(char *name, jclass *ret)
-{
- *ret=(*jnienv)->FindClass(jnienv, name);
- if (! *ret) {
- dbg(0,"Failed to get Class %s\n",name);
- return 0;
- }
- (*jnienv)->NewGlobalRef(jnienv, *ret);
- return 1;
-}
-
-int
-android_find_method(jclass class, char *name, char *args, jmethodID *ret)
-{
- *ret = (*jnienv)->GetMethodID(jnienv, class, name, args);
- if (*ret == NULL) {
- dbg(0,"Failed to get Method %s with signature %s\n",name,args);
- return 0;
- }
- return 1;
-}
-
-int
-android_find_static_method(jclass class, char *name, char *args, jmethodID *ret)
-{
- *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args);
- if (*ret == NULL) {
- dbg(0,"Failed to get static Method %s with signature %s\n",name,args);
- return 0;
- }
- return 1;
-}
-
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_Navit_NavitMain( JNIEnv* env, jobject thiz, jobject activity, jobject lang)
-{
- char *strings[]={"/data/data/org.navitproject.navit/bin/navit",NULL};
- char *langstr;
- __android_log_print(ANDROID_LOG_ERROR,"test","called");
- jnienv=env;
- android_activity=activity;
- (*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_SizeChangedCallback( JNIEnv* env, jobject thiz, int id, int w, int h)
-{
- dbg(0,"enter %p %d %d\n",(struct callback *)id,w,h);
- if (id)
- callback_call_2((struct callback *)id,w,h);
-}
-
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitGraphics_ButtonCallback( JNIEnv* env, jobject thiz, int id, int pressed, int button, int x, int y)
-{
- dbg(1,"enter %p %d %d\n",(struct callback *)id,pressed,button);
- if (id)
- callback_call_4((struct callback *)id,pressed,button,x,y);
-}
-
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitGraphics_MotionCallback( JNIEnv* env, jobject thiz, int id, int x, int y)
-{
- dbg(1,"enter %p %d %d\n",(struct callback *)id,x,y);
- if (id)
- callback_call_2((struct callback *)id,x,y);
-}
-
-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);
- callback_call_0((struct callback *)id);
- if (delete)
- (*jnienv)->DeleteGlobalRef(jnienv, thiz);
-}
-
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitVehicle_VehicleCallback( JNIEnv * env, jobject thiz, int id, jobject location)
-{
- callback_call_1((struct callback *)id, (void *)location);
-}
-
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitIdle_IdleCallback( JNIEnv* env, jobject thiz, int id)
-{
- dbg(1,"enter %p %p\n",thiz, (void *)id);
- callback_call_0((struct callback *)id);
-}
-
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitWatch_poll( JNIEnv* env, jobject thiz, int fd, int cond)
-{
- struct pollfd pfd;
- pfd.fd=fd;
- dbg(1,"%p poll called for %d %d\n",env, fd, cond);
- switch ((enum event_watch_cond)cond) {
- case event_watch_cond_read:
- pfd.events=POLLIN;
- break;
- case event_watch_cond_write:
- pfd.events=POLLOUT;
- break;
- case event_watch_cond_except:
- pfd.events=POLLERR;
- break;
- default:
- pfd.events=0;
- }
- pfd.revents=0;
- poll(&pfd, 1, -1);
-}
-
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitWatch_WatchCallback( JNIEnv* env, jobject thiz, int id)
-{
- dbg(1,"enter %p %p\n",thiz, (void *)id);
- callback_call_0((struct callback *)id);
-}
-
-
+++ /dev/null
-#include <jni.h>
-extern JNIEnv *jnienv;
-extern jobject *android_activity;
-int android_find_class_global(char *name, jclass *ret);
-int android_find_method(jclass class, char *name, char *args, jmethodID *ret);
-int android_find_static_method(jclass class, char *name, char *args, jmethodID *ret);
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.navitproject.navit"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="3" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.INTERNET" />
- <application android:label="@string/app_name">
- <activity android:name="Navit"
- android:label="@string/app_name"
- android:icon="@drawable/icon"
- android:configChanges="locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">Navit</string>
-</resources>
-
+++ /dev/null
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.navitproject.navit;
-
-import android.app.Activity;
-import android.widget.TextView;
-import android.os.Bundle;
-import android.os.Debug;
-import android.os.Message;
-import android.os.Handler;
-import android.os.PowerManager;
-import android.content.Context;
-import android.content.res.Resources;
-import android.util.Log;
-import java.util.Locale;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-
-
-public class Navit extends Activity implements Handler.Callback
-{
- public Handler handler;
- private PowerManager.WakeLock wl;
- private boolean extractRes(String resname, String result)
- {
- int slash=-1;
- boolean needs_update=false;
- File resultfile;
- Resources res=getResources();
- Log.e("Navit","Res Name " + resname);
- Log.e("Navit","result " + result);
- int id=res.getIdentifier(resname,"raw","org.navitproject.navit");
- Log.e("Navit","Res ID " + id);
- if (id == 0)
- return false;
- while ((slash=result.indexOf("/",slash+1)) != -1) {
- if (slash != 0) {
- Log.e("Navit","Checking "+result.substring(0,slash));
- resultfile=new File(result.substring(0,slash));
- if (!resultfile.exists()) {
- Log.e("Navit","Creating dir");
- if (!resultfile.mkdir())
- return false;
- needs_update=true;
- }
- }
- }
- resultfile=new File(result);
- if (!resultfile.exists())
- needs_update=true;
- if (!needs_update) {
- try {
- InputStream resourcestream=res.openRawResource(id);
- FileInputStream resultfilestream=new FileInputStream(resultfile);
- byte[] resourcebuf = new byte[1024];
- byte[] resultbuf = new byte[1024];
- int i = 0;
- while ((i = resourcestream.read(resourcebuf)) != -1) {
- if (resultfilestream.read(resultbuf) != i) {
- Log.e("Navit","Result is too short");
- needs_update=true;
- break;
- }
- for (int j = 0 ; j < i ; j++) {
- if (resourcebuf[j] != resultbuf[j]) {
- Log.e("Navit","Result is different");
- needs_update=true;
- break;
- }
- }
- if (needs_update)
- break;
- }
- if (!needs_update && resultfilestream.read(resultbuf) != -1) {
- Log.e("Navit","Result is too long");
- needs_update=true;
- }
- }
- catch (Exception e) {
- Log.e("Navit","Exception "+e.getMessage());
- return false;
- }
- }
- if (needs_update) {
- Log.e("Navit","Extracting resource");
-
- try {
- InputStream resourcestream=res.openRawResource(id);
- FileOutputStream resultfilestream=new FileOutputStream(resultfile);
- byte[] buf = new byte[1024];
- int i = 0;
- while ((i = resourcestream.read(buf)) != -1) {
- resultfilestream.write(buf, 0, i);
- }
- }
- catch (Exception e) {
- Log.e("Navit","Exception "+e.getMessage());
- return false;
- }
- }
- return true;
- }
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
- wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE, "NavitDoNotDimScreen");
- Locale locale=java.util.Locale.getDefault();
- String lang=locale.getLanguage();
- String langu=lang;
- String langc=lang;
- int pos=langu.indexOf('_');
- 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);
-
- if (!extractRes(langc,"/data/data/org.navitproject.navit/locale/"+langc+"/LC_MESSAGES/navit.mo")) {
- Log.e("Navit","Failed to extract language resource "+langc);
- }
- if (!extractRes("navit","/data/data/org.navitproject.navit/share/navit.xml")) {
- Log.e("Navit","Failed to extract navit.xml");
- }
- // Debug.startMethodTracing("calc");
- NavitMain(this, langu);
- }
- @Override public void onStart()
- {
- super.onStart();
- Log.e("Navit","OnStart");
- }
- @Override public void onRestart()
- {
- super.onRestart();
- Log.e("Navit","OnRestart");
- }
- @Override public void onResume()
- {
- super.onResume();
- Log.e("Navit","OnResume");
- }
- @Override public void onPause()
- {
- super.onPause();
- Log.e("Navit","OnPause");
- }
- @Override public void onStop()
- {
- super.onStop();
- Log.e("Navit","OnStop");
- }
- @Override public void onDestroy()
- {
- super.onDestroy();
- Log.e("Navit","OnDestroy");
- }
-
- public void disableSuspend()
- {
- wl.acquire();
- wl.release();
- }
-
- public void exit()
- {
- finish();
- }
-
- public boolean handleMessage(Message m) {
- Log.e("Navit","Handler received message");
- return true;
- }
-
- /* A native method that is implemented by the
- * 'hello-jni' native library, which is packaged
- * with this application.
- */
- public native void NavitMain(Navit x, String lang);
-
- /* this is used to load the 'hello-jni' library on application
- * startup. The library has already been unpacked into
- * /data/data/com.example.Navit/lib/libhello-jni.so at
- * installation time by the package manager.
- */
- static {
- System.loadLibrary("navit");
- }
-}
-
+++ /dev/null
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.navitproject.navit;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.*;
-import android.os.Bundle;
-import android.os.Debug;
-import android.view.*;
-import android.util.Log;
-import java.util.ArrayList;
-import java.lang.String;
-
-public class NavitGraphics {
- private NavitGraphics parent_graphics;
- private ArrayList overlays=new ArrayList();
- int bitmap_w;
- int bitmap_h;
- int pos_x;
- 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) {
- view=new View(activity) {
- @Override protected void onDraw(Canvas canvas)
- {
- super.onDraw(canvas);
- canvas.drawBitmap(draw_bitmap, pos_x, pos_y, null);
- if (overlay_disabled == 0) {
- Object overlays_array[];
- overlays_array=overlays.toArray();
- for (Object overlay : overlays_array) {
- NavitGraphics overlay_graphics=(NavitGraphics)overlay;
- if (overlay_graphics.overlay_disabled == 0) {
- int x=overlay_graphics.pos_x;
- int y=overlay_graphics.pos_y;
- if (overlay_graphics.pos_wraparound != 0 && x < 0)
- x+=bitmap_w;
- if (overlay_graphics.pos_wraparound != 0 && y < 0)
- y+=bitmap_h;
- canvas.drawBitmap(overlay_graphics.draw_bitmap, x, y, null);
- }
- }
- }
- }
- @Override protected void onSizeChanged(int w, int h, int oldw, int oldh)
- {
- super.onSizeChanged(w, h, oldw, oldh);
- draw_bitmap=Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- draw_canvas=new Canvas(draw_bitmap);
- bitmap_w=w;
- bitmap_h=h;
- SizeChangedCallback(SizeChangedCallbackID, w, h);
- }
- @Override public boolean onTouchEvent(MotionEvent event)
- {
- super.onTouchEvent(event);
- int action = event.getAction();
- int x=(int)event.getX();
- int y=(int)event.getY();
- if (action == MotionEvent.ACTION_DOWN) {
- // Log.e("NavitGraphics", "onTouch down");
- ButtonCallback(ButtonCallbackID, 1, 1, x, y);
- }
- if (action == MotionEvent.ACTION_UP) {
- // Log.e("NavitGraphics", "onTouch up");
- ButtonCallback(ButtonCallbackID, 0, 1, x, y);
- // if (++count == 3)
- // Debug.stopMethodTracing();
- }
- if (action == MotionEvent.ACTION_MOVE) {
- // Log.e("NavitGraphics", "onTouch move");
- MotionCallback(MotionCallbackID, x, y);
- }
- return true;
- }
- @Override public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- int i;
- String s=null;
- i=event.getUnicodeChar();
- Log.e("NavitGraphics","onKeyDown "+keyCode+" "+i);
- // Log.e("NavitGraphics","Unicode "+event.getUnicodeChar());
- if (i == 0) {
- if (keyCode == android.view.KeyEvent.KEYCODE_DEL) {
- s=java.lang.String.valueOf((char)8);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_MENU) {
- s=java.lang.String.valueOf((char)1);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_SEARCH) {
- s=java.lang.String.valueOf((char)19);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_BACK) {
- s=java.lang.String.valueOf((char)27);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_CALL) {
- } else if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_UP) {
- } else if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_DOWN) {
- } else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_CENTER) {
- s=java.lang.String.valueOf((char)13);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_DOWN) {
- s=java.lang.String.valueOf((char)16);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_LEFT) {
- s=java.lang.String.valueOf((char)2);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_RIGHT) {
- s=java.lang.String.valueOf((char)6);
- } else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_UP) {
- s=java.lang.String.valueOf((char)16);
- }
- } else if (i == 10) {
- s=java.lang.String.valueOf((char)13);
- } else {
- s=java.lang.String.valueOf((char)i);
- }
- if (s != null) {
- KeypressCallback(KeypressCallbackID, s);
- }
- return true;
- }
- @Override public boolean onKeyUp(int keyCode, KeyEvent event)
- {
- Log.e("NavitGraphics","onKeyUp "+keyCode);
- return true;
- }
- @Override public boolean onTrackballEvent(MotionEvent event)
- {
- Log.e("NavitGraphics","onTrackball "+event.getAction() + " " +event.getX()+" "+event.getY());
- String s=null;
- if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
- s=java.lang.String.valueOf((char)13);
- }
- if (event.getAction() == android.view.MotionEvent.ACTION_MOVE) {
- trackball_x+=event.getX();
- trackball_y+=event.getY();
- 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;
- bitmap_h=h;
- pos_x=x;
- pos_y=y;
- pos_wraparound=wraparound;
- draw_canvas=new Canvas(draw_bitmap);
- parent.overlays.add(this);
- }
- parent_graphics=parent;
- }
- 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,KeypressCallbackID;
- // private int count;
-
- public void setSizeChangedCallback(int id)
- {
- SizeChangedCallbackID=id;
- }
- public void setButtonCallback(int id)
- {
- ButtonCallbackID=id;
- }
- public void setMotionCallback(int id)
- {
- MotionCallbackID=id;
- }
- public void setKeypressCallback(int id)
- {
- KeypressCallbackID=id;
- }
-
- protected void draw_polyline(Paint paint,int c[])
- {
- paint.setStyle(Paint.Style.STROKE);
- Path path = new Path();
- path.moveTo(c[0], c[1]);
- for (int i = 2 ; i < c.length ; i+=2) {
- path.lineTo(c[i], c[i+1]);
- }
- draw_canvas.drawPath(path, paint);
- }
-
- protected void draw_polygon(Paint paint,int c[])
- {
- paint.setStyle(Paint.Style.FILL);
- Path path = new Path();
- path.moveTo(c[0], c[1]);
- for (int i = 2 ; i < c.length ; i+=2) {
- path.lineTo(c[i], c[i+1]);
- }
- draw_canvas.drawPath(path, paint);
- }
- protected void draw_rectangle(Paint paint,int x, int y, int w, int h)
- {
- Rect r = new Rect(x, y, x+w, y+h);
- paint.setStyle(Paint.Style.FILL);
- draw_canvas.drawRect(r, paint);
- }
- protected void draw_circle(Paint paint,int x, int y, int r)
- {
- float fx=x;
- float fy=y;
- float fr=r/2;
- paint.setStyle(Paint.Style.STROKE);
- draw_canvas.drawCircle(fx, fy, fr, paint);
- }
- protected void draw_text(Paint paint,int x, int y, String text, int size, int dx, int dy)
- {
- float fx=x;
- float fy=y;
- // Log.e("NavitGraphics","Text size "+size + " vs " + paint.getTextSize());
- paint.setTextSize((float)size/15);
- if (dx == 0x10000 && dy == 0) {
- draw_canvas.drawText(text, fx, fy, paint);
- } else {
- Path path = new Path();
- path.moveTo(x, y);
- path.rLineTo(dx, dy);
- paint.setTextAlign(android.graphics.Paint.Align.LEFT);
- draw_canvas.drawTextOnPath(text, path, 0, 0, paint);
- }
- }
- protected void draw_image(Paint paint, int x, int y, Bitmap bitmap)
- {
- float fx=x;
- float fy=y;
- draw_canvas.drawBitmap(bitmap, fx, fy, paint);
- }
- protected void draw_mode(int mode)
- {
- if (mode == 1 && parent_graphics == null)
- view.invalidate();
- if (mode == 0 && parent_graphics != null)
- draw_bitmap.eraseColor(0);
-
- }
- protected void draw_drag(int x, int y)
- {
- pos_x=x;
- pos_y=y;
- }
- protected void overlay_disable(int disable)
- {
- overlay_disabled=disable;
- }
- protected void overlay_resize(int x, int y, int w, int h, int alpha, int wraparond)
- {
- pos_x=x;
- pos_y=y;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.navitproject.navit;
-
-import android.app.Activity;
-import android.widget.TextView;
-import android.os.Bundle;
-import android.os.Debug;
-import android.os.Message;
-import android.os.Handler;
-import android.content.Context;
-import android.util.Log;
-import com.google.tts.TTS;
-
-
-public class NavitSpeech {
- private TTS tts;
- private TTS.InitListener ttsInitListener;
- NavitSpeech(Context context)
- {
- ttsInitListener = new TTS.InitListener() {
- public void onInit(int version) {
- }
- };
- tts=new TTS(context, ttsInitListener, true);
- }
- public void say(String what)
- {
- Log.e("NavitSpeech","In "+what);
- tts.speak(what, 0, null);
- }
-}
-
+++ /dev/null
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.navitproject.navit;
-
-import android.app.Activity;
-import android.widget.TextView;
-import android.os.Bundle;
-import android.os.Debug;
-import android.os.Message;
-import android.os.Handler;
-import android.content.Context;
-import android.util.Log;
-
-
-
-public class NavitTimeout implements Runnable {
- private static Handler handler =new Handler() {
- public void handleMessage(Message m) {
- Log.e("Navit","Handler received message");
- }
- };
- private boolean event_multi;
- private int event_callbackid;
- private int event_timeout;
- public native void TimeoutCallback(int del, int id);
-
- NavitTimeout(int timeout, boolean multi, int callbackid)
- {
- event_timeout=timeout;
- event_multi=multi;
- event_callbackid=callbackid;
- handler.postDelayed(this, event_timeout);
- }
- public void run() {
- // Log.e("Navit","Handle Event");
- if (event_multi) {
- handler.postDelayed(this, event_timeout);
- TimeoutCallback(0, event_callbackid);
- } else
- TimeoutCallback(1, event_callbackid);
- }
- public void remove()
- {
- handler.removeCallbacks(this);
- }
-}
-
+++ /dev/null
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.navitproject.navit;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.*;
-import android.os.Bundle;
-import android.os.Debug;
-import android.view.*;
-import android.util.Log;
-import android.location.*;
-
-public class NavitVehicle {
- private LocationManager locationManager;
- private int vehicle_callbackid;
- public native void VehicleCallback(int id, Location location);
-
- NavitVehicle (Context context, int callbackid) {
- locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
-
- Criteria criteria = new Criteria();
- criteria.setAccuracy(Criteria.ACCURACY_FINE);
- criteria.setAltitudeRequired(true);
- criteria.setBearingRequired(true);
- criteria.setCostAllowed(true);
- criteria.setPowerRequirement(Criteria.POWER_HIGH);
-
-
- Log.e("NavitVehicle", "Providers "+locationManager.getAllProviders());
- String provider = locationManager.getBestProvider(criteria, false);
- Log.e("NavitVehicle", "Provider "+provider);
- Location location = locationManager.getLastKnownLocation(provider);
- vehicle_callbackid=callbackid;
- locationManager.requestLocationUpdates(provider, 0, 0, locationListener);
- }
- private final LocationListener locationListener = new LocationListener() {
- public void onLocationChanged(Location location) {
-
- // Log.e("NavitVehicle", "LocationChanged Accuracy " + location.getAccuracy() + " Altitude " + location.getAltitude() + " Bearing " + location.getBearing() + " Speed " + location.getSpeed() + " Latitude " + location.getLatitude() + " Longitude " + location.getLongitude());
- VehicleCallback(vehicle_callbackid, location);
- }
- public void onProviderDisabled(String provider){}
- public void onProviderEnabled(String provider) {}
- public void onStatusChanged(String provider, int status, Bundle extras) {}
- };
-}
+++ /dev/null
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.navitproject.navit;
-
-import java.lang.Thread;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-public class NavitWatch implements Runnable {
- private Thread thread;
- private static Handler handler =new Handler() {
- public void handleMessage(Message m) {
- Log.e("NavitWatch","Handler received message");
- }
- };
- private boolean removed;
- private int watch_fd;
- private int watch_cond;
- private int watch_callbackid;
- private boolean callback_pending;
- private Runnable callback_runnable;
- public native void poll(int fd, int cond);
- public native void WatchCallback(int id);
-
- NavitWatch(int fd, int cond, int callbackid)
- {
- // 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;
- final NavitWatch navitwatch=this;
- callback_runnable = new Runnable() {
- public void run()
- {
- navitwatch.callback();
- }
- };
- thread = new Thread(this, "poll thread");
- thread.start();
- }
- public void run()
- {
- for (;;) {
- // Log.e("NavitWatch","Polling "+watch_fd+" "+watch_cond + " from " + java.lang.Thread.currentThread().getName());
- poll(watch_fd, watch_cond);
- // Log.e("NavitWatch","poll returned");
- if (removed)
- break;
- callback_pending=true;
- handler.post(callback_runnable);
- try {
- // Log.e("NavitWatch","wait");
- synchronized(this) {
- if (callback_pending)
- this.wait();
- }
- // Log.e("NavitWatch","wait returned");
- } catch (Exception e) {
- Log.e("NavitWatch","Exception "+e.getMessage());
- }
- if (removed)
- break;
- }
- }
- public void callback()
- {
- // Log.e("NavitWatch","Calling Callback");
- if (!removed)
- WatchCallback(watch_callbackid);
- synchronized(this) {
- callback_pending=false;
- // Log.e("NavitWatch","Waking up");
- this.notify();
- }
- }
- public void remove()
- {
- removed=true;
- thread.interrupt();
- }
-}
-