diff --git a/xwords4/android/XWords4-dbg/AndroidManifest.xml b/xwords4/android/XWords4-dbg/AndroidManifest.xml index d12be4963..0f12e377d 100644 --- a/xwords4/android/XWords4-dbg/AndroidManifest.xml +++ b/xwords4/android/XWords4-dbg/AndroidManifest.xml @@ -22,7 +22,7 @@ to come from a domain that you own or have control over. --> @@ -70,6 +70,7 @@ + + + + @@ -52,7 +55,7 @@ - + diff --git a/xwords4/android/XWords4-dbg/libs/crittercism_v4_4_0_sdkonly.jar b/xwords4/android/XWords4-dbg/libs/crittercism_v4_4_0_sdkonly.jar deleted file mode 100644 index d582845bd..000000000 Binary files a/xwords4/android/XWords4-dbg/libs/crittercism_v4_4_0_sdkonly.jar and /dev/null differ diff --git a/xwords4/android/XWords4-dbg/libs/crittercism_v5_2_0_sdkonly.jar b/xwords4/android/XWords4-dbg/libs/crittercism_v5_2_0_sdkonly.jar new file mode 100644 index 000000000..128ab1004 Binary files /dev/null and b/xwords4/android/XWords4-dbg/libs/crittercism_v5_2_0_sdkonly.jar differ diff --git a/xwords4/android/XWords4-dbg/res/layout/.gitignore b/xwords4/android/XWords4-dbg/res/layout/.gitignore index 03ac4e859..d98ed5c93 100644 --- a/xwords4/android/XWords4-dbg/res/layout/.gitignore +++ b/xwords4/android/XWords4-dbg/res/layout/.gitignore @@ -41,5 +41,6 @@ conn_types_display.xml expander_header.xml msg_label_and_edit.xml not_again_view.xml +relayinviter.xml remote_dict_details.xml toolbar.xml diff --git a/xwords4/android/XWords4-dbg/res/menu/.gitignore b/xwords4/android/XWords4-dbg/res/menu/.gitignore index d53bc34bc..07ed661b4 100644 --- a/xwords4/android/XWords4-dbg/res/menu/.gitignore +++ b/xwords4/android/XWords4-dbg/res/menu/.gitignore @@ -1,10 +1,11 @@ board_menu.xml chat_menu.xml dicts_item_menu.xml -games_list_item_menu.xml games_list_menu.xml dicts_menu.xml studylist.xml loc_menu.xml empty.xml loc_item_menu.xml +games_list_group_menu.xml +games_list_game_menu.xml diff --git a/xwords4/android/XWords4-dbg/res/values/app_name.xml b/xwords4/android/XWords4-dbg/res/values/app_name.xml deleted file mode 100644 index ffccc195b..000000000 --- a/xwords4/android/XWords4-dbg/res/values/app_name.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - 4.4-dbg beta 80 - diff --git a/xwords4/android/XWords4-dbg/res_src/values-ba_CK/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-ba_CK/.gitignore index 1e28ff4b4..aa5ea40dd 100644 --- a/xwords4/android/XWords4-dbg/res_src/values-ba_CK/.gitignore +++ b/xwords4/android/XWords4-dbg/res_src/values-ba_CK/.gitignore @@ -1 +1,2 @@ /strings.xml +strings.xml diff --git a/xwords4/android/XWords4-dbg/res_src/values-ca/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-ca/.gitignore new file mode 100644 index 000000000..be5186f01 --- /dev/null +++ b/xwords4/android/XWords4-dbg/res_src/values-ca/.gitignore @@ -0,0 +1 @@ +strings.xml diff --git a/xwords4/android/XWords4-dbg/res_src/values-ca_PS/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-ca_PS/.gitignore index 1e28ff4b4..aa5ea40dd 100644 --- a/xwords4/android/XWords4-dbg/res_src/values-ca_PS/.gitignore +++ b/xwords4/android/XWords4-dbg/res_src/values-ca_PS/.gitignore @@ -1 +1,2 @@ /strings.xml +strings.xml diff --git a/xwords4/android/XWords4-dbg/res_src/values-cs/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-cs/.gitignore new file mode 100644 index 000000000..be5186f01 --- /dev/null +++ b/xwords4/android/XWords4-dbg/res_src/values-cs/.gitignore @@ -0,0 +1 @@ +strings.xml diff --git a/xwords4/android/XWords4-dbg/res_src/values-fr/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-fr/.gitignore new file mode 100644 index 000000000..be5186f01 --- /dev/null +++ b/xwords4/android/XWords4-dbg/res_src/values-fr/.gitignore @@ -0,0 +1 @@ +strings.xml diff --git a/xwords4/android/XWords4-dbg/res_src/values-nl/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-nl/.gitignore new file mode 100644 index 000000000..be5186f01 --- /dev/null +++ b/xwords4/android/XWords4-dbg/res_src/values-nl/.gitignore @@ -0,0 +1 @@ +strings.xml diff --git a/xwords4/android/XWords4-dbg/res_src/values-pt/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-pt/.gitignore new file mode 100644 index 000000000..be5186f01 --- /dev/null +++ b/xwords4/android/XWords4-dbg/res_src/values-pt/.gitignore @@ -0,0 +1 @@ +strings.xml diff --git a/xwords4/android/XWords4-dbg/res_src/values-sk/.gitignore b/xwords4/android/XWords4-dbg/res_src/values-sk/.gitignore new file mode 100644 index 000000000..be5186f01 --- /dev/null +++ b/xwords4/android/XWords4-dbg/res_src/values-sk/.gitignore @@ -0,0 +1 @@ +strings.xml diff --git a/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore b/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore index 1a3815e06..cf33b4575 100644 --- a/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore +++ b/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore @@ -1,4 +1,3 @@ -#CrashTrack.java# /DlgID.java /LookupAlert.java ABUtils.java @@ -113,11 +112,16 @@ GroupStateListener.java ListGroup.java ConnViaViewLayout.java Delegator.java +DevID.java HeaderWithExpander.java LangListPreference.java ListDelegator.java NagTurnReceiver.java NotAgainView.java OnBootReceiver.java +RelayInviteActivity.java +RelayInviteDelegate.java XWConnAddrPreference.java +XWDevIDPreference.java XWExpListAdapter.java +RequestCode.java diff --git a/xwords4/android/XWords4/.gitignore b/xwords4/android/XWords4/.gitignore index b35181c70..5dfbbc251 100644 --- a/xwords4/android/XWords4/.gitignore +++ b/xwords4/android/XWords4/.gitignore @@ -1,9 +1,19 @@ *.apk +.DS_Store +.gradle +/.idea/libraries +/.idea/workspace.xml +/build +/captures +/libs-debug +/libs-release +/local.properties +/obj-debug +/obj-release ant_out.txt -local.properties bin gen -libs -proguard.cfg +local.properties obj +proguard.cfg res/drawable*/*gen.png diff --git a/xwords4/android/XWords4/.idea/.name b/xwords4/android/XWords4/.idea/.name new file mode 100644 index 000000000..68f9bd49d --- /dev/null +++ b/xwords4/android/XWords4/.idea/.name @@ -0,0 +1 @@ +XWords4 \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/codeStyleSettings.xml b/xwords4/android/XWords4/.idea/codeStyleSettings.xml new file mode 100644 index 000000000..ded962ca0 --- /dev/null +++ b/xwords4/android/XWords4/.idea/codeStyleSettings.xml @@ -0,0 +1,231 @@ + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/compiler.xml b/xwords4/android/XWords4/.idea/compiler.xml new file mode 100644 index 000000000..96cc43efa --- /dev/null +++ b/xwords4/android/XWords4/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/copyright/profiles_settings.xml b/xwords4/android/XWords4/.idea/copyright/profiles_settings.xml new file mode 100644 index 000000000..e7bedf337 --- /dev/null +++ b/xwords4/android/XWords4/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/gradle.xml b/xwords4/android/XWords4/.idea/gradle.xml new file mode 100644 index 000000000..1bbc21dc2 --- /dev/null +++ b/xwords4/android/XWords4/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/misc.xml b/xwords4/android/XWords4/.idea/misc.xml new file mode 100644 index 000000000..22b2cf0aa --- /dev/null +++ b/xwords4/android/XWords4/.idea/misc.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.7 + + + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/modules.xml b/xwords4/android/XWords4/.idea/modules.xml new file mode 100644 index 000000000..c0244711b --- /dev/null +++ b/xwords4/android/XWords4/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/runConfigurations.xml b/xwords4/android/XWords4/.idea/runConfigurations.xml new file mode 100644 index 000000000..7f68460d8 --- /dev/null +++ b/xwords4/android/XWords4/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/.idea/vcs.xml b/xwords4/android/XWords4/.idea/vcs.xml new file mode 100644 index 000000000..c2365ab11 --- /dev/null +++ b/xwords4/android/XWords4/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index f711fbee6..537238beb 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -22,7 +22,7 @@ to come from a domain that you own or have control over. --> @@ -37,6 +37,7 @@ android:largeScreens="true" android:xlargeScreens="true" /> + @@ -102,6 +103,11 @@ android:configChanges="keyboardHidden|orientation|screenSize" android:screenOrientation="sensor" /> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/app/.gitignore b/xwords4/android/XWords4/app/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/xwords4/android/XWords4/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/xwords4/android/XWords4/app/app.iml b/xwords4/android/XWords4/app/app.iml new file mode 100644 index 000000000..7dabaa34a --- /dev/null +++ b/xwords4/android/XWords4/app/app.iml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xwords4/android/XWords4/app/build.gradle b/xwords4/android/XWords4/app/build.gradle new file mode 100644 index 000000000..6766c9cc8 --- /dev/null +++ b/xwords4/android/XWords4/app/build.gradle @@ -0,0 +1,209 @@ +def VARIANT_NAME = 'xw4' +def INITIAL_CLIENT_VERS = 6 +def CHAT_ENABLED = true +def THUMBNAIL_ENABLED = true +def LIBS_DEBUG = 'libs-debug' +def LIBS_RELEASE = 'libs-release' + +apply plugin: 'com.android.application' + +dependencies { + compile files('../libs/gcm.jar') +} + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + defaultConfig { + applicationId "org.eehouse.android.xw4" + minSdkVersion 7 + targetSdkVersion 14 + } + + // Rename all output artifacts to include version information + applicationVariants.all { variant -> + renameArtifact(variant) + } + + // flavorDimensions "variant", "abi" + // productFlavors { + // xw4 { + // dimension "variant" + // } + // xw4dbg { + // dimension "variant" + // } + // armeabiv7a { + // dimension "abi" + // } + + // armeabi { + // dimension "abi" + // } + + // x86 { + // dimension "abi" + // } + + // } + + signingConfigs { + release { + storeFile file(System.getenv("HOME") + "/.keystore") + keyAlias "mykey" + + // These two lines make gradle believe that the signingConfigs + // section is complete. Without them, tasks like installRelease + // will not be available! + storePassword "notReal" + keyPassword "notReal" + } + } + + buildTypes { + release { + signingConfig signingConfigs.release + debuggable false + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + debug { + debuggable true + // This doesn't work on marshmallow: duplicate permission error + // applicationIdSuffix ".debug" + } + } + + sourceSets { + // Use symlinks instead of setting non-conventional + // directories here. AS doesn't respect what's set here: it'll + // compile, but post-install app launch and source-level + // debugging don't work. + release { + jniLibs.srcDir "../$LIBS_RELEASE" + } + debug { + jniLibs.srcDir "../$LIBS_DEBUG" + } + } + + lintOptions { + abortOnError false + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) +} + +task genVers(type: Exec) { + workingDir '../' + commandLine '../scripts/genvers.sh', '--variant', VARIANT_NAME, + '--client-vers', INITIAL_CLIENT_VERS, '--chat-enabled', CHAT_ENABLED, + '--thumbnail-enabled', THUMBNAIL_ENABLED, + '--vers-outfile', "assets/gitvers.txt" +} + +task mkImages(type: Exec) { + workingDir '../' + commandLine '../scripts/mkimages.sh' +} + +task copyStrings(type: Exec) { + workingDir '../' + commandLine '../scripts/copy-strings.py' +} + +task ndkSetup(type: Exec) { + workingDir '../' + commandLine "../scripts/ndksetup.sh" +} + +task genGcmid(type: Exec) { + workingDir '../' + commandLine '../scripts/gen_gcmid.sh', + '-o', "src/org/eehouse/android/$VARIANT_NAME/GCMConsts.java", + '-v', "$VARIANT_NAME" +} + +task myPreBuild(dependsOn: ['genVers', 'ndkSetup', 'mkImages', 'copyStrings', 'mkXml', 'genGcmid']) { +} +preBuild.dependsOn myPreBuild + +task ndkBuildDebug(type: Exec) { + workingDir '../' + commandLine '../scripts/ndkbuild.sh', '-j3', "CHAT_ENABLED=$CHAT_ENABLED", + "THUMBNAIL_ENABLED=$THUMBNAIL_ENABLED", 'BUILD_TARGET=debug', + "INITIAL_CLIENT_VERS=$INITIAL_CLIENT_VERS", "VARIANT=$VARIANT_NAME", + "NDK_LIBS_OUT=$LIBS_DEBUG", 'NDK_OUT=./obj-debug' +} + +task ndkBuildRelease(type: Exec) { + workingDir '../' + commandLine '../scripts/ndkbuild.sh', '-j3', "CHAT_ENABLED=$CHAT_ENABLED", + "THUMBNAIL_ENABLED=$THUMBNAIL_ENABLED", 'BUILD_TARGET=release', + "INITIAL_CLIENT_VERS=$INITIAL_CLIENT_VERS", "VARIANT=$VARIANT_NAME", + "NDK_LIBS_OUT=$LIBS_RELEASE", 'NDK_OUT=./obj-release' +} + +task mkXml(type: Exec) { + workingDir '../' + commandLine '../scripts/mk_xml.py', '-o', + "src/org/eehouse/android/$VARIANT_NAME/loc/LocIDsData.java", + '-t', "debug", '-v', "$VARIANT_NAME" +} + +afterEvaluate { + compileReleaseNdk.dependsOn ndkBuildRelease + compileDebugNdk.dependsOn ndkBuildDebug +} + +task askForPassword << { + def password = System.getenv("ANDROID_KEY_PASS") + if (null == password || 0 == password.length()) { + if ( null != System.console() ) { + password = new String(System.console() + .readPassword("ANDROID_KEY_PASS not set; " + + "Keystore password: ")) + } else { + password = null + println( "ANDROID_KEY_PASS not set and no console; " ) + println( "sign it yerself later. (Or you might try" ) + println( " running gradlew with the --no-daemon flag)" ) + } + } + + if ( null != password ) { + android.signingConfigs.release.storePassword = password + android.signingConfigs.release.keyPassword = password + } +} + +tasks.whenTaskAdded { theTask -> + if (theTask.name.equals("packageRelease")) { + theTask.dependsOn "askForPassword" + } +} + +def getVersionName() { + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'describe', '--dirty' + standardOutput = stdout + } + return stdout.toString().trim() + } + catch (ignored) { + return null; + } +} + +def renameArtifact(variant) { + variant.outputs.each { output -> + def name = String.format( "XWords4-%s-%s.apk", variant.name, + getVersionName() ) + output.outputFile = new File( (String)output.outputFile.parent, + (String)name ) + } +} diff --git a/xwords4/android/XWords4/app/proguard-rules.pro b/xwords4/android/XWords4/app/proguard-rules.pro new file mode 100644 index 000000000..9f4fe14b6 --- /dev/null +++ b/xwords4/android/XWords4/app/proguard-rules.pro @@ -0,0 +1,34 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/eehouse/android/android-sdk-linux/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Keep everything. Useful maybe for confirming that proguard's causing +# a problem? +# -keep class ** { *; } + +# Don't turn this on until it's clear that proguard isn't messing +# anything else up. It'll make crash reports useless. + +-dontobfuscate + +# Uncomment this if obfuscation is enabled (by removing the line +# above), and save the mapping.txt file or confirm it can be rebuilt +# from a tag. +# -keepattributes SourceFile,LineNumberTable + +# Prevents crash when jni code calls setInt on various jin.* classes +-keep public class org.eehouse.android.xw4.jni.** { public *; } diff --git a/xwords4/android/XWords4/app/src/main/AndroidManifest.xml b/xwords4/android/XWords4/app/src/main/AndroidManifest.xml new file mode 120000 index 000000000..4db074ab1 --- /dev/null +++ b/xwords4/android/XWords4/app/src/main/AndroidManifest.xml @@ -0,0 +1 @@ +../../../AndroidManifest.xml \ No newline at end of file diff --git a/xwords4/android/XWords4/app/src/main/assets b/xwords4/android/XWords4/app/src/main/assets new file mode 120000 index 000000000..f86487ffc --- /dev/null +++ b/xwords4/android/XWords4/app/src/main/assets @@ -0,0 +1 @@ +../../../assets/ \ No newline at end of file diff --git a/xwords4/android/XWords4/app/src/main/java b/xwords4/android/XWords4/app/src/main/java new file mode 120000 index 000000000..a1d005e30 --- /dev/null +++ b/xwords4/android/XWords4/app/src/main/java @@ -0,0 +1 @@ +../../../src/ \ No newline at end of file diff --git a/xwords4/android/XWords4/app/src/main/res b/xwords4/android/XWords4/app/src/main/res new file mode 120000 index 000000000..fc8850136 --- /dev/null +++ b/xwords4/android/XWords4/app/src/main/res @@ -0,0 +1 @@ +../../../res \ No newline at end of file diff --git a/xwords4/android/XWords4/assets/.gitignore b/xwords4/android/XWords4/assets/.gitignore new file mode 100644 index 000000000..122521cd8 --- /dev/null +++ b/xwords4/android/XWords4/assets/.gitignore @@ -0,0 +1 @@ +/gitvers.txt diff --git a/xwords4/android/XWords4/assets/changes.html b/xwords4/android/XWords4/assets/changes.html index 014a45e00..2adb1f7b2 100644 --- a/xwords4/android/XWords4/assets/changes.html +++ b/xwords4/android/XWords4/assets/changes.html @@ -13,10 +13,10 @@ -

Crosswords 4.4 beta 98 release

+

Crosswords 4.4 beta 101 release

-

This release is mostly to get the new Dutch translation out - there, and to catch up Catalan and French.

+

This is the second of two releases that together fix stalling + issues in network games.

Please take @@ -26,23 +26,8 @@

New with this release

    -
  • Complete and up-to-date translations into Dutch, French and - Catalan. What language is next?
  • - -
  • Allow copying invitation URL to clipboard so you can paste - it into any messaging app you like
  • - -
  • Improvements to in-game chat experience (but more are coming)
  • - -
  • Show a "toast" when hint button can't find any moves
  • - -
  • Add SMS to the list of ways you can invite somebody
  • - -
  • When displaying Bluetooth-connected devices to invite, skip - stuff like headphones
  • -
  • Turn off email invite attachments. They didn't seem to work anyway, - and aren't needed on modern Android.
  • -
  • Fix very old memory leak
  • +
  • Fix to send correctly calculated identifier for game + state.

(The full changelog @@ -51,8 +36,9 @@

Next up

  • Offer "Rematch" when game's over (Easy via - SMS and Bluetooth; harder via the internet/relay)
  • -
  • Look into supporting play via peer-to-peer wifi
  • + SMS and Bluetooth; harder via the internet/relay) +
  • Take advantage of Marshmallow's new permissions model (where + the app only asks for them when it needs them.)

Please let me know diff --git a/xwords4/android/XWords4/build.gradle b/xwords4/android/XWords4/build.gradle new file mode 100644 index 000000000..a1590caf8 --- /dev/null +++ b/xwords4/android/XWords4/build.gradle @@ -0,0 +1,34 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} + +subprojects { + afterEvaluate {project -> + if (project.hasProperty("android")) { + android { + compileSdkVersion 14 + buildToolsVersion '22.0.1' + } + } + } +} diff --git a/xwords4/android/XWords4/build.xml b/xwords4/android/XWords4/build.xml index dd46e1533..a414555a7 100644 --- a/xwords4/android/XWords4/build.xml +++ b/xwords4/android/XWords4/build.xml @@ -1,6 +1,9 @@ + + + @@ -52,7 +55,7 @@ - + diff --git a/xwords4/android/XWords4/gradle.properties b/xwords4/android/XWords4/gradle.properties new file mode 100644 index 000000000..1d3591c8a --- /dev/null +++ b/xwords4/android/XWords4/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true \ No newline at end of file diff --git a/xwords4/android/XWords4/gradle/wrapper/gradle-wrapper.jar b/xwords4/android/XWords4/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..8c0fb64a8 Binary files /dev/null and b/xwords4/android/XWords4/gradle/wrapper/gradle-wrapper.jar differ diff --git a/xwords4/android/XWords4/gradle/wrapper/gradle-wrapper.properties b/xwords4/android/XWords4/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..beaf6ec9f --- /dev/null +++ b/xwords4/android/XWords4/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Nov 09 19:22:17 PST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/xwords4/android/XWords4/gradlew b/xwords4/android/XWords4/gradlew new file mode 100755 index 000000000..91a7e269e --- /dev/null +++ b/xwords4/android/XWords4/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/xwords4/android/XWords4/gradlew.bat b/xwords4/android/XWords4/gradlew.bat new file mode 100644 index 000000000..aec99730b --- /dev/null +++ b/xwords4/android/XWords4/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/xwords4/android/XWords4/jni/Android.mk b/xwords4/android/XWords4/jni/Android.mk index e72775ddb..f33d7dd9b 100644 --- a/xwords4/android/XWords4/jni/Android.mk +++ b/xwords4/android/XWords4/jni/Android.mk @@ -39,6 +39,7 @@ LOCAL_DEFINES += \ -DXWFEATURE_BASE64 \ -DXWFEATURE_DEVID \ -DCOMMON_LAYOUT \ + -DNATIVE_NLI \ -DCOMMS_VERSION=1 \ -DINITIAL_CLIENT_VERS=${INITIAL_CLIENT_VERS} \ -DVARIANT_${VARIANT} \ @@ -84,7 +85,7 @@ COMMON_SRC_FILES += \ $(COMMON_PATH)/memstream.c \ $(COMMON_PATH)/movestak.c \ $(COMMON_PATH)/dbgutil.c \ - + $(COMMON_PATH)/nli.c \ LOCAL_CFLAGS+=$(LOCAL_C_INCLUDES) $(LOCAL_DEFINES) -Wall -std=c99 LOCAL_SRC_FILES := $(linux_SRC_FILES) $(LOCAL_SRC_FILES) $(COMMON_SRC_FILES) diff --git a/xwords4/android/XWords4/jni/anddict.c b/xwords4/android/XWords4/jni/anddict.c index 67a68f93c..5888b1e47 100644 --- a/xwords4/android/XWords4/jni/anddict.c +++ b/xwords4/android/XWords4/jni/anddict.c @@ -1,6 +1,6 @@ -/* -*- compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */ +/* -*- compile-command: "find-and-ant.sh debug install"; -*- */ /* - * Copyright © 2009 - 2011 by Eric House (xwords@eehouse.org). All rights + * Copyright © 2009 - 2016 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -648,7 +648,7 @@ makeDict( MPFORMAL JNIEnv *env, DictMgrCtxt* dictMgr, JNIUtilCtxt* jniutil, jstr anddict->super.langName = getStringCopy( MPPARM(mpool) env, jlangname ); - XP_U32 numEdges; + XP_U32 numEdges = 0; XP_Bool parses = parseDict( anddict, (XP_U8*)anddict->bytes, bytesSize, &numEdges ); if ( !parses || (check && !checkSanity( &anddict->super, diff --git a/xwords4/android/XWords4/jni/andutils.c b/xwords4/android/XWords4/jni/andutils.c index f9c2274e0..a639a265d 100644 --- a/xwords4/android/XWords4/jni/andutils.c +++ b/xwords4/android/XWords4/jni/andutils.c @@ -78,12 +78,14 @@ error error error int getInt( JNIEnv* env, jobject obj, const char* name ) { + // XP_LOGF( "%s(name=%s)", __func__, name ); jclass cls = (*env)->GetObjectClass( env, obj ); XP_ASSERT( !!cls ); jfieldID fid = (*env)->GetFieldID( env, cls, name, "I"); XP_ASSERT( !!fid ); int result = (*env)->GetIntField( env, obj, fid ); deleteLocalRef( env, cls ); + // XP_LOGF( "%s(name=%s) => %d", __func__, name, result ); return result; } @@ -113,12 +115,14 @@ getInts( JNIEnv* env, void* cobj, jobject jobj, const SetInfo* sis, XP_U16 nSis void setInt( JNIEnv* env, jobject obj, const char* name, int value ) { + // XP_LOGF( "%s(name=%s)", __func__, name ); jclass cls = (*env)->GetObjectClass( env, obj ); XP_ASSERT( !!cls ); jfieldID fid = (*env)->GetFieldID( env, cls, name, "I"); XP_ASSERT( !!fid ); (*env)->SetIntField( env, obj, fid, value ); deleteLocalRef( env, cls ); + // XP_LOGF( "%s(name=%s) DONE", __func__, name ); } void @@ -178,6 +182,7 @@ setBools( JNIEnv* env, jobject jobj, void* cobj, const SetInfo* sis, XP_U16 nSis bool setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value ) { + // XP_LOGF( "%s(%s)", __func__, name ); bool success = false; jclass cls = (*env)->GetObjectClass( env, obj ); jfieldID fid = (*env)->GetFieldID( env, cls, name, "Ljava/lang/String;" ); @@ -193,10 +198,32 @@ setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value ) return success; } +void +getStrings( JNIEnv* env, void* cobj, jobject jobj, const SetInfo* sis, XP_U16 nSis ) +{ + for ( int ii = 0; ii < nSis; ++ii ) { + const SetInfo* si = &sis[ii]; + XP_UCHAR* buf = (XP_UCHAR*)(((uint8_t*)cobj) + si->offset); + getString( env, jobj, si->name, buf, si->siz ); + } +} + +void +setStrings( JNIEnv* env, jobject jobj, void* cobj, const SetInfo* sis, XP_U16 nSis ) +{ + for ( int ii = 0; ii < nSis; ++ii ) { + const SetInfo* si = &sis[ii]; + // XP_LOGF( "calling setString(%s)", si->name ); + XP_UCHAR* val = (XP_UCHAR*)(((uint8_t*)cobj) + si->offset); + setString( env, jobj, si->name, val ); + } +} + void getString( JNIEnv* env, jobject obj, const char* name, XP_UCHAR* buf, int bufLen ) { + // XP_LOGF( "%s(%s)", __func__, name ); jclass cls = (*env)->GetObjectClass( env, obj ); XP_ASSERT( !!cls ); jfieldID fid = (*env)->GetFieldID( env, cls, name, "Ljava/lang/String;" ); @@ -214,6 +241,7 @@ getString( JNIEnv* env, jobject obj, const char* name, XP_UCHAR* buf, buf[len] = '\0'; deleteLocalRef( env, cls ); + // XP_LOGF( "%s(%s) DONE", __func__, name ); } XP_UCHAR* @@ -403,9 +431,15 @@ getMethodID( JNIEnv* env, jobject obj, const char* proc, const char* sig ) XP_ASSERT( !!env ); jclass cls = (*env)->GetObjectClass( env, obj ); XP_ASSERT( !!cls ); +#ifdef DEBUG + char buf[128] = {0}; + /* int len = sizeof(buf); */ + /* getClassName( env, obj, buf, &len ); */ +#endif jmethodID mid = (*env)->GetMethodID( env, cls, proc, sig ); if ( !mid ) { - XP_LOGF( "%s: no mid for proc %s, sig %s", __func__, proc, sig ); + XP_LOGF( "%s: no mid for proc %s, sig %s in object of class %s", + __func__, proc, sig, buf ); } XP_ASSERT( !!mid ); deleteLocalRef( env, cls ); @@ -703,8 +737,46 @@ android_debugf( const char* format, ... ) # endif , buf ); } -#endif +/* Print an object's class name into buffer. + * + * NOTE: this must be called in advance of any jni error, because methods on + * env can't be called once there's an exception pending. + */ +#if 0 +static void +getClassName( JNIEnv* env, jobject obj, char* out, int* outLen ) +{ + XP_ASSERT( !!obj ); + jclass cls1 = (*env)->GetObjectClass( env, obj ); + + // First get the class object + jmethodID mid = (*env)->GetMethodID( env, cls1, "getClass", + "()Ljava/lang/Class;" ); + jobject clsObj = (*env)->CallObjectMethod( env, obj, mid ); + + // Now get the class object's class descriptor + jclass cls2 = (*env)->GetObjectClass( env, clsObj ); + // Find the getName() method on the class object + mid = (*env)->GetMethodID( env, cls2, "getName", "()Ljava/lang/String;" ); + + // Call the getName() to get a jstring object back + jstring strObj = (jstring)(*env)->CallObjectMethod( env, clsObj, mid ); + + jint slen = (*env)->GetStringUTFLength( env, strObj ); + if ( slen < *outLen ) { + *outLen = slen; + (*env)->GetStringUTFRegion( env, strObj, 0, slen, out ); + out[slen] = '\0'; + } else { + *outLen = 0; + out[0] = '\0'; + } + deleteLocalRefs( env, clsObj, cls1, cls2, strObj, DELETE_NO_REF ); + LOG_RETURNF( "%s", out ); +} +#endif +#endif /* #ifdef DEBUG */ /* XP_U32 */ diff --git a/xwords4/android/XWords4/jni/andutils.h b/xwords4/android/XWords4/jni/andutils.h index f66af6a89..c48d3678d 100644 --- a/xwords4/android/XWords4/jni/andutils.h +++ b/xwords4/android/XWords4/jni/andutils.h @@ -58,6 +58,10 @@ void setBools( JNIEnv* env, jobject jobj, void* cobj, bool setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value ); void getString( JNIEnv* env, jobject jlp, const char* name, XP_UCHAR* buf, int bufLen ); +void getStrings( JNIEnv* env, void* cobj, jobject jobj, + const SetInfo* sis, XP_U16 nSis ); +void setStrings( JNIEnv* env, jobject jobj, void* cobj, + const SetInfo* sis, XP_U16 nSis ); XP_UCHAR* getStringCopy( MPFORMAL JNIEnv* env, jstring jname ); void setObject( JNIEnv* env, jobject obj, const char* name, const char* sig, jobject val ); diff --git a/xwords4/android/XWords4/jni/xportwrapper.c b/xwords4/android/XWords4/jni/xportwrapper.c index b9d60c108..6be6482bf 100644 --- a/xwords4/android/XWords4/jni/xportwrapper.c +++ b/xwords4/android/XWords4/jni/xportwrapper.c @@ -66,15 +66,16 @@ and_xport_getFlags( void* closure ) } static XP_S16 -and_xport_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr, - CommsConnType conType, XP_U32 gameID, void* closure ) +and_xport_send( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo, + const CommsAddrRec* addr, CommsConnType conType, + XP_U32 gameID, void* closure ) { jint result = -1; LOG_FUNC(); AndTransportProcs* aprocs = (AndTransportProcs*)closure; if ( NULL != aprocs->jxport ) { JNIEnv* env = ENVFORME( aprocs->ti ); - const char* sig = "([BL" PKG_PATH("jni/CommsAddrRec") + const char* sig = "([BLjava/lang/String;L" PKG_PATH("jni/CommsAddrRec") ";L" PKG_PATH("jni/CommsAddrRec$CommsConnType") ";I)I"; jmethodID mid = getMethodID( env, aprocs->jxport, "transportSend", sig ); @@ -83,15 +84,15 @@ and_xport_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr, jobject jaddr = makeJAddr( env, addr ); jobject jConType = intToJEnum(env, conType, PKG_PATH("jni/CommsAddrRec$CommsConnType")); + jstring jMsgNo = !!msgNo ? (*env)->NewStringUTF( env, msgNo ) : NULL; result = (*env)->CallIntMethod( env, aprocs->jxport, mid, - jbytes, jaddr, jConType, gameID ); - deleteLocalRefs( env, jaddr, jbytes, jConType, DELETE_NO_REF ); + jbytes, jMsgNo, jaddr, jConType, gameID ); + deleteLocalRefs( env, jaddr, jbytes, jMsgNo, jConType, DELETE_NO_REF ); } LOG_RETURNF( "%d", result ); return result; } - static void and_xport_relayStatus( void* closure, CommsRelayState newState ) { @@ -126,7 +127,7 @@ and_xport_relayConnd( void* closure, XP_UCHAR* const room, XP_Bool reconnect, } static XP_Bool -and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, +and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo, const XP_UCHAR* relayID, void* closure ) { jboolean result = false; @@ -134,14 +135,15 @@ and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, if ( NULL != aprocs && NULL != aprocs->jxport ) { JNIEnv* env = ENVFORME( aprocs->ti ); - const char* sig = "([BLjava/lang/String;)Z"; + const char* sig = "([BLjava/lang/String;Ljava/lang/String;)Z"; jmethodID mid = getMethodID( env, aprocs->jxport, "relayNoConnProc", sig ); jbyteArray jbytes = makeByteArray( env, len, (jbyte*)buf ); jstring jRelayID = (*env)->NewStringUTF( env, relayID ); + jstring jMsgNo = !!msgNo ? (*env)->NewStringUTF( env, msgNo ) : NULL; result = (*env)->CallBooleanMethod( env, aprocs->jxport, mid, - jbytes, jRelayID ); - deleteLocalRefs( env, jbytes, jRelayID, DELETE_NO_REF ); + jbytes, jMsgNo, jRelayID ); + deleteLocalRefs( env, jbytes, jRelayID, jMsgNo, DELETE_NO_REF ); } LOG_RETURNF( "%d", result ); return result; diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 88b18b050..1534dc3d7 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -32,6 +32,7 @@ #include "dictnry.h" #include "dictiter.h" #include "dictmgr.h" +#include "nli.h" #include "utilwrapper.h" #include "drawwrapper.h" @@ -283,6 +284,46 @@ makeGI( MPFORMAL JNIEnv* env, jobject jgi ) return gi; } /* makeGI */ +static const SetInfo nli_ints[] = { + ARR_MEMBER( NetLaunchInfo, _conTypes ), + ARR_MEMBER( NetLaunchInfo, lang ), + ARR_MEMBER( NetLaunchInfo, forceChannel ), + ARR_MEMBER( NetLaunchInfo, nPlayersT ), + ARR_MEMBER( NetLaunchInfo, nPlayersH ), + ARR_MEMBER( NetLaunchInfo, gameID ), + ARR_MEMBER( NetLaunchInfo, osVers ), +}; + +static const SetInfo nli_bools[] = { + ARR_MEMBER( NetLaunchInfo, isGSM ) +}; + +static const SetInfo nli_strs[] = { + ARR_MEMBER( NetLaunchInfo, dict ), + ARR_MEMBER( NetLaunchInfo, gameName ), + ARR_MEMBER( NetLaunchInfo, room ), + ARR_MEMBER( NetLaunchInfo, btName ), + ARR_MEMBER( NetLaunchInfo, btAddress ), + ARR_MEMBER( NetLaunchInfo, phone ), + ARR_MEMBER( NetLaunchInfo, inviteID ), +}; + +static void +loadNLI( JNIEnv* env, NetLaunchInfo* nli, jobject jnli ) +{ + getInts( env, (void*)nli, jnli, nli_ints, VSIZE(nli_ints) ); + getBools( env, (void*)nli, jnli, nli_bools, VSIZE(nli_bools) ); + getStrings( env, (void*)nli, jnli, nli_strs, VSIZE(nli_strs) ); +} + +static void +setNLI( JNIEnv* env, jobject jnli, const NetLaunchInfo* nli ) +{ + setInts( env, jnli, (void*)nli, nli_ints, VSIZE(nli_ints) ); + setBools( env, jnli, (void*)nli, nli_bools, VSIZE(nli_bools) ); + setStrings( env, jnli, (void*)nli, nli_strs, VSIZE(nli_strs) ); +} + static void setJGI( JNIEnv* env, jobject jgi, const CurGameInfo* gi ) { @@ -453,6 +494,59 @@ Java_org_eehouse_android_xw4_jni_XwJNI_gi_1from_1stream #endif } +JNIEXPORT jbyteArray JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_nli_1to_1stream +( JNIEnv* env, jclass C, jobject njli ) +{ + LOG_FUNC(); + jbyteArray result; +#ifdef MEM_DEBUG + MemPoolCtx* mpool = mpool_make( NULL ); +#endif + NetLaunchInfo nli = {0}; + loadNLI( env, &nli, njli ); + /* CurGameInfo* gi = makeGI( MPPARM(mpool) env, jgi ); */ + VTableMgr* vtMgr = make_vtablemgr( MPPARM_NOCOMMA(mpool) ); + XWStreamCtxt* stream = mem_stream_make( MPPARM(mpool) vtMgr, + NULL, 0, NULL ); + + nli_saveToStream( &nli, stream ); + + result = streamToBArray( env, stream ); + stream_destroy( stream ); + + vtmgr_destroy( MPPARM(mpool) vtMgr ); +#ifdef MEM_DEBUG + mpool_destroy( mpool ); +#endif + return result; +} + +JNIEXPORT void JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_nli_1from_1stream +( JNIEnv* env, jclass C, jobject jnli, jbyteArray jstream ) +{ + LOG_FUNC(); +#ifdef MEM_DEBUG + MemPoolCtx* mpool = mpool_make( NULL ); +#endif + VTableMgr* vtMgr = make_vtablemgr( MPPARM_NOCOMMA(mpool) ); + XWStreamCtxt* stream = streamFromJStream( MPPARM(mpool) env, vtMgr, jstream ); + + NetLaunchInfo nli = {0}; + if ( nli_makeFromStream( &nli, stream ) ) { + setNLI( env, jnli, &nli ); + } else { + XP_LOGF( "%s: game_makeFromStream failed", __func__ ); + } + + stream_destroy( stream ); + vtmgr_destroy( MPPARM(mpool) vtMgr ); +#ifdef MEM_DEBUG + mpool_destroy( mpool ); +#endif +} + JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getInitialAddr ( JNIEnv* env, jclass C, jobject jaddr, jstring jname, jint port ) @@ -1730,6 +1824,25 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1isConnected return result; } +JNIEXPORT jstring JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_comms_1formatRelayID +( JNIEnv* env, jclass C, jint gamePtr, jint indx ) +{ + jstring result = NULL; + XWJNI_START(); + + XP_UCHAR buf[64]; + XP_U16 len = sizeof(buf); + if ( comms_formatRelayID( state->game.comms, indx, buf, &len ) ) { + XP_ASSERT( len < sizeof(buf) ); + LOG_RETURNF( "%s", buf ); + result = (*env)->NewStringUTF( env, buf ); + } + + XWJNI_END(); + return result; +} + JNIEXPORT jstring JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getStats ( JNIEnv* env, jclass C, jint gamePtr ) diff --git a/xwords4/android/XWords4/libs/.gitignore b/xwords4/android/XWords4/libs/.gitignore new file mode 100644 index 000000000..e3f56da7c --- /dev/null +++ b/xwords4/android/XWords4/libs/.gitignore @@ -0,0 +1,2 @@ +/armeabi +/x86 diff --git a/xwords4/android/XWords4/res/layout/game_config.xml b/xwords4/android/XWords4/res/layout/game_config.xml index e2d73b6aa..e92cd4bb9 100644 --- a/xwords4/android/XWords4/res/layout/game_config.xml +++ b/xwords4/android/XWords4/res/layout/game_config.xml @@ -23,6 +23,7 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/game_locked" + android:checked="true" android:visibility="gone" android:layout_alignParentTop="true" /> diff --git a/xwords4/android/XWords4/res/layout/relayinviter.xml b/xwords4/android/XWords4/res/layout/relayinviter.xml new file mode 100644 index 000000000..3ea28f2c6 --- /dev/null +++ b/xwords4/android/XWords4/res/layout/relayinviter.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + +