[sword-svn] r3584 - in trunk/bindings: Android/SWORD Android/SWORD/app cordova/org.crosswire.sword.cordova.SWORD/src/android java-jni/jni java-jni/src/org/crosswire/android/sword
scribe at crosswire.org
scribe at crosswire.org
Tue May 15 18:38:26 MST 2018
Author: scribe
Date: 2018-05-15 18:38:25 -0700 (Tue, 15 May 2018)
New Revision: 3584
Modified:
trunk/bindings/Android/SWORD/app/CMakeLists.txt
trunk/bindings/Android/SWORD/app/build.gradle
trunk/bindings/Android/SWORD/build.gradle
trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java
trunk/bindings/java-jni/jni/swordstub.cpp
trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java
Log:
Updated to Android bindings to work with latest NDK and BibleSync 2.0
Modified: trunk/bindings/Android/SWORD/app/CMakeLists.txt
===================================================================
--- trunk/bindings/Android/SWORD/app/CMakeLists.txt 2018-05-16 01:38:15 UTC (rev 3583)
+++ trunk/bindings/Android/SWORD/app/CMakeLists.txt 2018-05-16 01:38:25 UTC (rev 3584)
@@ -193,7 +193,8 @@
../../../../../biblesync/src/biblesync.cc
- ../../../../../biblesync/src/ifaddrs.c
+ ../../../../../biblesync/src/Android/ifaddrs.c
+ ../../../../../biblesync/src/Android/uuid.c
)
@@ -201,6 +202,7 @@
../../../../include
../../../../../biblesync/include
+ ../../../../../biblesync/src/Android/
)
# Searches for a specified prebuilt library and stores the path as a
Modified: trunk/bindings/Android/SWORD/app/build.gradle
===================================================================
--- trunk/bindings/Android/SWORD/app/build.gradle 2018-05-16 01:38:15 UTC (rev 3583)
+++ trunk/bindings/Android/SWORD/app/build.gradle 2018-05-16 01:38:25 UTC (rev 3584)
@@ -1,18 +1,19 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 25
+ compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "org.crosswire.sword"
minSdkVersion 14
- targetSdkVersion 25
+ targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
+ arguments "-DANDROID_STL=c++_static"
}
}
}
Modified: trunk/bindings/Android/SWORD/build.gradle
===================================================================
--- trunk/bindings/Android/SWORD/build.gradle 2018-05-16 01:38:15 UTC (rev 3583)
+++ trunk/bindings/Android/SWORD/build.gradle 2018-05-16 01:38:25 UTC (rev 3584)
@@ -6,7 +6,7 @@
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.0'
+ classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Modified: trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java
===================================================================
--- trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java 2018-05-16 01:38:15 UTC (rev 3583)
+++ trunk/bindings/cordova/org.crosswire.sword.cordova.SWORD/src/android/SWORD.java 2018-05-16 01:38:25 UTC (rev 3584)
@@ -370,11 +370,29 @@
@Override
public void run() {
mgr.startBibleSync(appName, userName, passphrase, new SWMgr.BibleSyncListener() {
- public void messageReceived(String message) {
- PluginResult result = new PluginResult(PluginResult.Status.OK, message);
- result.setKeepCallback(true);
- bibleSyncListener.sendPluginResult(result);
+ public void navReceived(String message) {
+ try {
+ JSONObject m = new JSONObject();
+ m.put("cmd", "nav");
+ m.put("osisRef", message);
+ PluginResult result = new PluginResult(PluginResult.Status.OK, m);
+ result.setKeepCallback(true);
+ bibleSyncListener.sendPluginResult(result);
+ }
+ catch (Exception e) { e.printStackTrace(); }
}
+ public void chatReceived(String user, String message) {
+ try {
+ JSONObject m = new JSONObject();
+ m.put("cmd", "chat");
+ m.put("user", user);
+ m.put("message", message);
+ PluginResult result = new PluginResult(PluginResult.Status.OK, m);
+ result.setKeepCallback(true);
+ bibleSyncListener.sendPluginResult(result);
+ }
+ catch (Exception e) { e.printStackTrace(); }
+ }
});
}
});
Modified: trunk/bindings/java-jni/jni/swordstub.cpp
===================================================================
--- trunk/bindings/java-jni/jni/swordstub.cpp 2018-05-16 01:38:15 UTC (rev 3583)
+++ trunk/bindings/java-jni/jni/swordstub.cpp 2018-05-16 01:38:25 UTC (rev 3584)
@@ -68,8 +68,8 @@
JNIEnv *bibleSyncListenerEnv = 0;
#endif
static SWBuf STORAGE_BASE;
-static char *SWORD_PATH = "/sdcard/sword";
-static char *AND_BIBLE_MODULES_PATH = "/sdcard/Android/data/net.bible.android.activity/files";
+const char *SWORD_PATH = "/sdcard/sword";
+const char *AND_BIBLE_MODULES_PATH = "/sdcard/Android/data/net.bible.android.activity/files";
//ANativeActivity *_activity;
// this method converts a UTF8 encoded SWBuf to a Java String, avoiding a bug in jni NewStringUTF
@@ -201,6 +201,11 @@
SWLog::getSystemLog()->logDebug("libsword: init() augmenting modules from: %s", AND_BIBLE_MODULES_PATH);
// for And Bible modules
mgr->augmentModules(AND_BIBLE_MODULES_PATH, true);
+ // if our basedir isn't the sdcard, let's augment the sdcard
+ if (strcmp(baseDir.c_str(), SWORD_PATH)) {
+SWLog::getSystemLog()->logDebug("libsword: init() augmenting modules from: %s", SWORD_PATH);
+ mgr->augmentModules(SWORD_PATH, true);
+ }
SWLog::getSystemLog()->logDebug("libsword: init() end.");
}
}
@@ -244,34 +249,50 @@
void bibleSyncCallback(char cmd, string pkt_uuid, string bible, string ref, string alt, string group, string domain, string info, string dump) {
SWLog::getSystemLog()->logDebug("bibleSync callback msg: %c; pkt_uuid: %s; bible: %s; ref: %s; alt: %s; group: %s; domain: %s; info: %s; dump: %s", cmd, pkt_uuid.c_str(), bible.c_str(), ref.c_str(), alt.c_str(), group.c_str(), domain.c_str(), info.c_str(), dump.c_str());
if (::bibleSyncListener) {
-SWLog::getSystemLog()->logDebug("bibleSync listener is true");
+ SWLog::getSystemLog()->logDebug("bibleSync listener is true");
jclass cls = bibleSyncListenerEnv->GetObjectClass(::bibleSyncListener);
- jmethodID mid = bibleSyncListenerEnv->GetMethodID(cls, "messageReceived", "(Ljava/lang/String;)V");
-SWLog::getSystemLog()->logDebug("bibleSync listener mid: %ld", mid);
- if (mid) {
-SWLog::getSystemLog()->logDebug("bibleSync listener mid is available");
- switch(cmd) {
+ switch (cmd) {
// error
case 'E':
- // mismatch
+ // mismatch
case 'M':
- // new speaker
+ // new speaker
case 'S':
- // dead speaker
+ // dead speaker
case 'D':
- // announce
+ // announce
case 'A':
break;
- // navigation
- case 'N':
-SWLog::getSystemLog()->logDebug("bibleSync Nav Received: %s", ref.c_str());
- jstring msg = strToUTF8Java(bibleSyncListenerEnv, ref.c_str());
- bibleSyncListenerEnv->CallVoidMethod(::bibleSyncListener, mid, msg);
- bibleSyncListenerEnv->DeleteLocalRef(msg);
+ // chat message
+ case 'C': {
+ SWLog::getSystemLog()->logDebug("bibleSync Chat Received: %s", ref.c_str());
+ jmethodID mid = bibleSyncListenerEnv->GetMethodID(cls, "chatReceived",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+ if (mid) {
+ SWLog::getSystemLog()->logDebug("bibleSync listener mid is available");
+ jstring user = strToUTF8Java(bibleSyncListenerEnv, group.c_str());
+ jstring msg = strToUTF8Java(bibleSyncListenerEnv, alt.c_str());
+ bibleSyncListenerEnv->CallVoidMethod(::bibleSyncListener, mid, user, msg);
+ bibleSyncListenerEnv->DeleteLocalRef(user);
+ bibleSyncListenerEnv->DeleteLocalRef(msg);
+ }
break;
}
+ // navigation
+ case 'N': {
+ SWLog::getSystemLog()->logDebug("bibleSync Nav Received: %s", ref.c_str());
+ jmethodID mid = bibleSyncListenerEnv->GetMethodID(cls, "navReceived",
+ "(Ljava/lang/String;)V");
+ if (mid) {
+ SWLog::getSystemLog()->logDebug("bibleSync listener mid is available");
+ jstring msg = strToUTF8Java(bibleSyncListenerEnv, ref.c_str());
+ bibleSyncListenerEnv->CallVoidMethod(::bibleSyncListener, mid, msg);
+ bibleSyncListenerEnv->DeleteLocalRef(msg);
+ }
+ break;
+ }
}
-SWLog::getSystemLog()->logDebug("bibleSync listener deleting local ref to cls");
+ SWLog::getSystemLog()->logDebug("bibleSync listener deleting local ref to cls");
bibleSyncListenerEnv->DeleteLocalRef(cls);
}
}
@@ -2016,7 +2037,7 @@
if (modNamePrefix) modName = modNamePrefix;
#ifdef BIBLESYNC
- BibleSync_xmit_status result = bibleSync->Transmit(BSP_SYNC, modName.c_str(), osisRef.c_str());
+ BibleSync_xmit_status result = bibleSync->Transmit(modName.c_str(), osisRef.c_str());
#endif
SWLog::getSystemLog()->logDebug("libsword: sendBibleSyncMessage() finished with status code: %d", result);
Modified: trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java
===================================================================
--- trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java 2018-05-16 01:38:15 UTC (rev 3583)
+++ trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java 2018-05-16 01:38:25 UTC (rev 3584)
@@ -84,7 +84,8 @@
*/
}
public static interface BibleSyncListener {
- public void messageReceived(String osisRef);
+ public void navReceived(String osisRef);
+ public void chatReceived(String user, String message);
}
public native void startBibleSync(String appName, String userName, String passphrase, BibleSyncListener listener);
public native void stopBibleSync();
More information about the sword-cvs
mailing list