JNIEnv *jnienv;
jobject *android_activity;
struct callback_list *android_activity_cbl;
+int android_version;
int
}
JNIEXPORT void JNICALL
-Java_org_navitproject_navit_Navit_NavitMain( JNIEnv* env, jobject thiz, jobject activity, jobject lang)
+Java_org_navitproject_navit_Navit_NavitMain( JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version)
{
char *strings[]={"/data/data/org.navitproject.navit/bin/navit",NULL};
char *langstr;
+ android_version=version;
__android_log_print(ANDROID_LOG_ERROR,"test","called");
android_activity_cbl=callback_list_new();
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);
+ dbg(0,"enter env=%p thiz=%p activity=%p lang=%s version=%d\n",env,thiz,activity,langstr,version);
setenv("LANG",langstr,1);
(*env)->ReleaseStringUTFChars(env, lang, langstr);
main_real(1, strings);
extern JNIEnv *jnienv;
extern jobject *android_activity;
extern struct callback_list *android_activity_cbl;
+extern int android_version;
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);
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.navitproject.navit"
+ android:sharedUserId="org.navitproject.navit"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
+ <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
import android.os.Handler;
import android.os.PowerManager;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
import android.util.Log;
import java.util.Locale;
{
public Handler handler;
private PowerManager.WakeLock wl;
+ private NavitActivityResult ActivityResults[];
private boolean extractRes(String resname, String result)
{
int slash=-1;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
+ ActivityResults=new NavitActivityResult[16];
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();
Log.e("Navit","Failed to extract navit.xml");
}
// Debug.startMethodTracing("calc");
- NavitMain(this, langu);
+ NavitMain(this, langu, android.os.Build.VERSION.SDK_INT);
NavitActivity(3);
}
@Override public void onStart()
NavitActivity(-3);
}
+ protected void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ Log.e("Navit","onActivityResult "+requestCode+" "+resultCode);
+ ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
+ }
+ public void setActivityResult(int requestCode, NavitActivityResult ActivityResult)
+ {
+ ActivityResults[requestCode]=ActivityResult;
+ }
+
+
public void disableSuspend()
{
wl.acquire();
* 'hello-jni' native library, which is packaged
* with this application.
*/
- public native void NavitMain(Navit x, String lang);
+ public native void NavitMain(Navit x, String lang, int version);
public native void NavitActivity(int activity);
/* this is used to load the 'hello-jni' library on application
--- /dev/null
+package org.navitproject.navit;
+import android.content.Intent;
+
+public interface NavitActivityResult {
+ public void onActivityResult(int requestCode, int resultCode, Intent data);
+};
float fy=y;
// Log.e("NavitGraphics","Text size "+size + " vs " + paint.getTextSize());
paint.setTextSize((float)size/15);
+ paint.setStyle(Paint.Style.FILL);
if (dx == 0x10000 && dy == 0) {
draw_canvas.drawText(text, fx, fy, paint);
} else {
private String what;
private Thread thread;
- NavitSpeech(Context context)
+ NavitSpeech(Navit navit)
{
ttsInitListener = new TTS.InitListener() {
public void onInit(int version) {
}
};
- tts=new TTS(context, ttsInitListener, true);
+ tts=new TTS(navit, ttsInitListener, true);
}
public void run()
{
--- /dev/null
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+package org.navitproject.navit;
+
+import java.lang.Thread;
+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.content.Intent;
+import android.util.Log;
+import android.speech.tts.TextToSpeech;
+
+
+public class NavitSpeech2 implements TextToSpeech.OnInitListener, NavitActivityResult {
+ private TextToSpeech mTts;
+ private Navit navit;
+ int MY_DATA_CHECK_CODE=1;
+
+
+ public void onInit(int status)
+ {
+ Log.e("NavitSpeech2","Status "+status);
+ }
+
+ public void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ Log.e("NavitSpeech2","onActivityResult "+requestCode+" "+resultCode);
+ if (requestCode == MY_DATA_CHECK_CODE) {
+ if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
+ // success, create the TTS instance
+ mTts = new TextToSpeech(navit, this);
+ } else {
+ // missing data, install it
+ Intent installIntent = new Intent();
+ installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
+ navit.startActivity(installIntent);
+ }
+ }
+ }
+
+ NavitSpeech2(Navit navit)
+ {
+ this.navit=navit;
+ navit.setActivityResult(1, this);
+ Log.e("NavitSpeech2","Create");
+ Intent checkIntent = new Intent();
+ checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
+ navit.startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
+ }
+ public void say(String what)
+ {
+ if (mTts != null) {
+ mTts.speak(what, TextToSpeech.QUEUE_FLUSH, null);
+ }
+ }
+}
+
jclass NavitSpeechClass;
jobject NavitSpeech;
jmethodID NavitSpeech_say;
+ int flags;
};
static int
jstring string;
int i;
- for (i = 0 ; i < strlen(str) ; i++) {
- if (str[i] == 0xc3 && str[i+1] == 0x84) {
- str[i]='A';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0x96) {
- str[i]='O';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0x9c) {
- str[i]='U';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0xa4) {
- str[i]='a';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0xb6) {
- str[i]='o';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0xbc) {
- str[i]='u';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0x9f) {
- str[i]='s';
- str[i+1]='s';
+ if (this->flags & 2) {
+ for (i = 0 ; i < strlen(str) ; i++) {
+ if (str[i] == 0xc3 && str[i+1] == 0x84) {
+ str[i]='A';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0x96) {
+ str[i]='O';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0x9c) {
+ str[i]='U';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0xa4) {
+ str[i]='a';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0xb6) {
+ str[i]='o';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0xbc) {
+ str[i]='u';
+ str[i+1]='e';
+ }
+ if (str[i] == 0xc3 && str[i+1] == 0x9f) {
+ str[i]='s';
+ str[i+1]='s';
+ }
}
}
string = (*jnienv)->NewStringUTF(jnienv, str);
speech_android_init(struct speech_priv *ret)
{
jmethodID cid;
+ char *class="org/navitproject/navit/NavitSpeech2";
- if (!android_find_class_global("org/navitproject/navit/NavitSpeech", &ret->NavitSpeechClass))
+ if (ret->flags & 1)
+ class="org/navitproject/navit/NavitSpeech";
+
+ if (!android_find_class_global(class, &ret->NavitSpeechClass)) {
+ dbg(0,"No class found\n");
return 0;
+ }
dbg(0,"at 3\n");
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitSpeechClass, "<init>", "(Landroid/content/Context;)V");
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitSpeechClass, "<init>", "(Lorg/navitproject/navit/Navit;)V");
if (cid == NULL) {
dbg(0,"no method found\n");
return 0; /* exception thrown */
}
static struct speech_priv *
-speech_android_new(struct speech_methods *meth, struct attr **attrs) {
+speech_android_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
struct speech_priv *this;
+ struct attr *flags;
*meth=speech_android_meth;
this=g_new(struct speech_priv,1);
if (!speech_android_init(this)) {
g_free(this);
this=NULL;
}
- speech_android_say(this, "Demnächst der Straße folgen");
+ if (android_version < 4)
+ this->flags=3;
+ if ((flags = attr_search(attrs, NULL, attr_flags)))
+ this->flags=flags->u.num;
+
return this;
}