diff --git a/android/.gitignore b/android/.gitignore
old mode 100644
new mode 100755
diff --git a/android/build.gradle b/android/build.gradle
old mode 100644
new mode 100755
index 389c57b..1fb7bd3
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -2,7 +2,9 @@ group 'com.linusu.flutter_marionette'
version '1.0-SNAPSHOT'
buildscript {
- ext.kotlin_version = '1.2.71'
+ ext.kotlin_version = '1.3.50'
+ ext.anko_version='0.10.8'
+
repositories {
google()
jcenter()
@@ -41,4 +43,6 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation "org.jetbrains.anko:anko:$anko_version"
+
}
diff --git a/android/flutter_marionette.iml b/android/flutter_marionette.iml
new file mode 100644
index 0000000..f20d759
--- /dev/null
+++ b/android/flutter_marionette.iml
@@ -0,0 +1,202 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/gradle.properties b/android/gradle.properties
old mode 100644
new mode 100755
diff --git a/android/settings.gradle b/android/settings.gradle
old mode 100644
new mode 100755
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
old mode 100644
new mode 100755
diff --git a/android/src/main/kotlin/com/linusu/flutter_marionette/FlutterMarionettePlugin.kt b/android/src/main/kotlin/com/linusu/flutter_marionette/FlutterMarionettePlugin.kt
old mode 100644
new mode 100755
index a7cb626..2173479
--- a/android/src/main/kotlin/com/linusu/flutter_marionette/FlutterMarionettePlugin.kt
+++ b/android/src/main/kotlin/com/linusu/flutter_marionette/FlutterMarionettePlugin.kt
@@ -1,25 +1,400 @@
package com.linusu.flutter_marionette
+import android.app.Activity
+import android.app.Application
+import android.os.Build
+import android.os.Bundle
+import android.util.JsonReader
+import android.util.JsonToken
+import android.util.Log
+import android.view.ViewGroup
+import android.webkit.*
+import android.widget.LinearLayout
+import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry.Registrar
+import org.jetbrains.anko.doAsync
+import org.jetbrains.anko.longToast
+import org.jetbrains.anko.uiThread
+import org.json.JSONObject
+import java.io.StringReader
+import java.util.*
+import kotlin.collections.HashMap
-class FlutterMarionettePlugin: MethodCallHandler {
- companion object {
- @JvmStatic
- fun registerWith(registrar: Registrar) {
- val channel = MethodChannel(registrar.messenger(), "flutter_marionette")
- channel.setMethodCallHandler(FlutterMarionettePlugin())
+class FlutterMarionettePlugin : MethodCallHandler, FlutterPlugin {
+ override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
+ val channel = MethodChannel(binding.getFlutterEngine().dartExecutor, "flutter_marionette")
+ channel.setMethodCallHandler(FlutterMarionettePlugin(channel))
}
- }
- override fun onMethodCall(call: MethodCall, result: Result) {
- if (call.method == "getPlatformVersion") {
- result.success("Android ${android.os.Build.VERSION.RELEASE}")
- } else {
- result.notImplemented()
+ override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+
+ var methodChannel: MethodChannel
+ var activityLifecycleCallbacks: Application.ActivityLifecycleCallbacks? = null
+// var webView: WebView? = null
+
+ var selector = ""
+ var HELPER_CODE = """ "
+ ""
+ "
"
+ ""
+ ""
+ ""
+ ""
+ "
+ """
+ val TEST_HELPER2 = """ "
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ "
+ """
+
+
+ val TEST_HELPER1 = """ "
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ "
+ """
+
+ companion object {
+ var pages: Map = HashMap() //Map()
+ var activity: Activity? = null
+ var page: WebView? = null
+ fun debugTrace(id: String, info: String) {
+ Log.i(id, info)
+ }
+
+ @JvmStatic
+ fun registerWith(registrar: Registrar) {
+ debugTrace("Registering", "Registering")
+
+ val channel = MethodChannel(registrar.messenger(), "flutter_marionette")
+ activity = registrar.activity()
+ channel.setMethodCallHandler(FlutterMarionettePlugin(channel)) //registrar.activity(),
+ }
+ }
+
+ override fun onMethodCall(call: MethodCall, result: Result) {
+ when {
+ call.method == "getPlatformVersion" -> result.success("Android ${android.os.Build.VERSION.RELEASE}")
+ call.method == "init" -> {
+
+ debugTrace("Starting", "Starting1 init")
+
+ var id = UUID.randomUUID().toString()
+ page = WebView(activity)
+ page?.settings?.javaScriptEnabled = true
+ page?.addJavascriptInterface(WebInterface(result), "Android")
+ page?.webChromeClient = WebChromeClient()
+ debugTrace("id", id)
+ page?.loadUrl("")
+ pages.plus(Pair(id, page))
+
+ result.success(id)
+ }
+ call.method == "dispose" -> {
+ var id = (call.arguments as Map)["id"] as String
+ pages[id]?.destroy()
+ pages?.minus(id)//.remove(id)
+ debugTrace("dispose", "dispose")
+
+ result.success(id)
+ }
+ call.method == "click" -> {
+ val id = (call.arguments as Map)["id"] as String
+ val selector = (call.arguments as Map)["selector"] as String
+ pages[id]?.loadUrl("javascript:window.SwiftMarionetteSimulateClick($selector)")
+// activity?.applicationContext?.longToast("Finished Loading")
+ debugTrace("selector", selector)
+
+ result.success(selector)
+ }
+ call.method == "evaluate" -> {
+ val id = (call.arguments as Map)["id"] as String
+ var script = (call.arguments as Map)["script"] as String
+
+ debugTrace("script", "F " +script)
+ debugTrace("Caller Url", "F " + page?.url)
+
+
+ page?.webViewClient = object : WebViewClient() {
+ override fun onPageFinished(view: WebView?, url: String?) {
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ //(function () { return $script })();
+ debugTrace("Received Url", "F " + view?.url)
+ view?.evaluateJavascript("(()=>{return ($script)})();", ValueCallback {
+ val jsonReader = JsonReader(StringReader(it))
+
+ jsonReader.isLenient = true
+ if (jsonReader.peek() != JsonToken.NULL && jsonReader?.peek() == JsonToken.STRING) {
+ val message = jsonReader.nextString()
+ if (message != null) {
+ result.success("\"$message\"")
+ debugTrace("JSonReader", message)
+ }
+ }
+ })
+ }
+
+ }
+ }
+
+
+ }
+ call.method == "goto" -> {
+ val id = (call.arguments as Map)["id"] as String
+ val url = (call.arguments as Map)["url"] as String
+ page?.loadUrl(url)
+ debugTrace("url", url)
+
+ result.success(url)
+ }
+ call.method == "setContent" -> {
+ val id = (call.arguments as Map)["id"] as String
+ val html = (call.arguments as Map)["html"] as String
+ pages[id]?.loadUrl("javascript:window.SwiftMarionetteSetContent($html)")
+
+ result.success(html)
+ }
+ call.method == "type" -> {
+ val id = (call.arguments as Map)["id"] as String
+ val selector = (call.arguments as Map)["selector"] as String
+ val text = (call.arguments as Map)["text"] as String
+
+ pages[id]?.loadUrl("javascript:window.SwiftMarionetteSimulateType($selector, $text)")
+
+ debugTrace("text", text)
+ result.success(text)
+
+ }
+ call.method == "reload" -> {
+ val id = (call.arguments as Map)["id"] as String
+ pages[id]?.loadUrl("javascript:window.SwiftMarionetteReload()")
+// pages[id]?.reload()
+ debugTrace("reload", "reload")
+
+ result.success(id)
+ }
+ call.method == "waitForFunction" -> {
+ val id = (call.arguments as Map)["id"] as String
+ val fn = (call.arguments as Map)["fn"] as String
+ pages[id]?.loadUrl("javascript:window.SwiftMarionetteWaitForFunction($fn)")
+ debugTrace("fn", fn)
+
+ result.success(fn)
+ }
+ call.method == "waitForNavigation" -> {
+
+ val id = (call.arguments as Map)["id"] as String
+ val page = pages[id]
+ val loaded = page?.progress
+ debugTrace("loaded", "loaded")
+
+ result.success(id)
+
+ }
+ call.method == "waitForSelector" -> {
+ val id = (call.arguments as Map)["id"] as String
+ val selector = (call.arguments as Map)["selector"] as String
+ this.selector = selector
+ pages[id]?.loadUrl("javascript: window.SwiftMarionetteWaitForSelector($selector)")//!.waitForSelector(selector).flutter(result)
+ debugTrace("waitForSelector", "waitForSelector $selector")
+ result.success(selector)
+ }
+ else -> result.notImplemented()
+ }
+
+ }
+
+ constructor(methodChannel: MethodChannel) {//activity: Activity,
+// this.activity = activity
+ this.methodChannel = methodChannel
+ this.methodChannel.setMethodCallHandler(this)
+ debugTrace("Starting", "Starting")
+
+ activity?.applicationContext?.longToast("Starting")
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ this.activityLifecycleCallbacks = object : Application.ActivityLifecycleCallbacks {
+ override fun onActivityPaused(p0: Activity?) {
+ }
+
+ override fun onActivityResumed(p0: Activity?) {
+
+ }
+
+ override fun onActivityStarted(p0: Activity?) {
+ debugTrace("Starting", "onActivityStarted")
+
+ }
+
+ override fun onActivityDestroyed(p0: Activity?) {
+ }
+
+ override fun onActivitySaveInstanceState(p0: Activity?, p1: Bundle?) {
+ debugTrace("Starting", "onActivitySaveInstanceState")
+
+ }
+
+ override fun onActivityStopped(p0: Activity?) {
+ }
+
+ override fun onActivityCreated(p0: Activity?, p1: Bundle?) {
+ debugTrace("Starting", "onActivityCreated")
+
+ }
+ }
+ }
+
+ }
+
+ class WebInterface {
+ val result: Result
+
+ constructor(result: Result) {
+ this.result = result
+ }
+
+ @JavascriptInterface
+ fun doAndroidCall(message: String) {
+ debugTrace("message", message)
+// result.success(message)
+ }
+ }
+
+
+}
+
+
diff --git a/example/android/android.iml b/example/android/android.iml
new file mode 100644
index 0000000..eec168d
--- /dev/null
+++ b/example/android/android.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/android/app/app.iml b/example/android/app/app.iml
new file mode 100644
index 0000000..d91970b
--- /dev/null
+++ b/example/android/app/app.iml
@@ -0,0 +1,195 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
new file mode 100644
index 0000000..5ff3eec
--- /dev/null
+++ b/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
@@ -0,0 +1,25 @@
+package io.flutter.plugins;
+
+import io.flutter.plugin.common.PluginRegistry;
+import com.linusu.flutter_marionette.FlutterMarionettePlugin;
+
+/**
+ * Generated file. Do not edit.
+ */
+public final class GeneratedPluginRegistrant {
+ public static void registerWith(PluginRegistry registry) {
+ if (alreadyRegisteredWith(registry)) {
+ return;
+ }
+ FlutterMarionettePlugin.registerWith(registry.registrarFor("com.linusu.flutter_marionette.FlutterMarionettePlugin"));
+ }
+
+ private static boolean alreadyRegisteredWith(PluginRegistry registry) {
+ final String key = GeneratedPluginRegistrant.class.getCanonicalName();
+ if (registry.hasPlugin(key)) {
+ return true;
+ }
+ registry.registrarFor(key);
+ return false;
+ }
+}
diff --git a/example/android/build.gradle b/example/android/build.gradle
index b7faad8..232bc0d 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,12 +1,12 @@
buildscript {
- ext.kotlin_version = '1.2.71'
+ ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
+ classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 8bd86f6..7be3d8b 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
+android.enableR8=true
diff --git a/example/android/gradle/wrapper/gradle-wrapper.jar b/example/android/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/example/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 2819f02..63ab3ae 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/example/android/gradlew b/example/android/gradlew
new file mode 100644
index 0000000..9d82f78
--- /dev/null
+++ b/example/android/gradlew
@@ -0,0 +1,160 @@
+#!/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
+
+# 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\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+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"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # 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/example/android/gradlew.bat b/example/android/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/example/android/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/example/android/local.properties b/example/android/local.properties
new file mode 100644
index 0000000..ea0d832
--- /dev/null
+++ b/example/android/local.properties
@@ -0,0 +1,3 @@
+sdk.dir=/Users/ittrade/Library/Android/sdk
+flutter.sdk=/Users/ittrade/flutter
+flutter.buildMode=debug
\ No newline at end of file
diff --git a/example/changelog.md b/example/changelog.md
new file mode 100644
index 0000000..bb1ff4c
--- /dev/null
+++ b/example/changelog.md
@@ -0,0 +1,13 @@
+## 0.2.0
+
+- 💥 Avoid app extension restricted APIs
+
+ Migration Guide:
+
+ You now need to specifically need to opt in to registering the `WKWebView` with the first window of the shared application. The reasoning for this is that it's a restricted API that isn't available when writing an App Extension.
+
+ Look at the added section in the readme for the two lines of code you need to add to your `AppDelegate`.
+
+## 0.1.0
+
+- 🎉 Add initial implementation
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index 273cb25..fdd43f0 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -41,7 +41,7 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_marionette/ios"
SPEC CHECKSUMS:
- Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
+ Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_marionette: 58239e57c450e08e91474555ebe1676ef047988c
GenericJSONType: 4e17961cd94ae24ddd07c4f1003acefee74ae7d9
LinusU_JSBridge: 26f133b25556dac6cab3d48ffd96a51137148c50
@@ -51,4 +51,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: ebd43b443038e611b86ede96e613bd6033c49497
-COCOAPODS: 1.6.1
+COCOAPODS: 1.7.5
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index c65321b..b9bbab3 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -239,8 +239,6 @@
buildActionMask = 2147483647;
files = (
);
- inputFileListPaths = (
- );
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
@@ -252,8 +250,6 @@
"${BUILT_PRODUCTS_DIR}/flutter_marionette/flutter_marionette.framework",
);
name = "[CP] Embed Pods Frameworks";
- outputFileListPaths = (
- );
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GenericJSONType.framework",
diff --git a/example/ios/Runner.xcworkspace/xcuserdata/ittrade.xcuserdatad/UserInterfaceState.xcuserstate b/example/ios/Runner.xcworkspace/xcuserdata/ittrade.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..6e9b242
Binary files /dev/null and b/example/ios/Runner.xcworkspace/xcuserdata/ittrade.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/example/ios/Runner/GeneratedPluginRegistrant.h b/example/ios/Runner/GeneratedPluginRegistrant.h
new file mode 100644
index 0000000..ed9a5c6
--- /dev/null
+++ b/example/ios/Runner/GeneratedPluginRegistrant.h
@@ -0,0 +1,17 @@
+//
+// Generated file. Do not edit.
+//
+
+#ifndef GeneratedPluginRegistrant_h
+#define GeneratedPluginRegistrant_h
+
+#import
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface GeneratedPluginRegistrant : NSObject
++ (void)registerWithRegistry:(NSObject*)registry;
+@end
+
+NS_ASSUME_NONNULL_END
+#endif /* GeneratedPluginRegistrant_h */
diff --git a/example/ios/Runner/GeneratedPluginRegistrant.m b/example/ios/Runner/GeneratedPluginRegistrant.m
new file mode 100644
index 0000000..34958c7
--- /dev/null
+++ b/example/ios/Runner/GeneratedPluginRegistrant.m
@@ -0,0 +1,19 @@
+//
+// Generated file. Do not edit.
+//
+
+#import "GeneratedPluginRegistrant.h"
+
+#if __has_include()
+#import
+#else
+@import flutter_marionette;
+#endif
+
+@implementation GeneratedPluginRegistrant
+
++ (void)registerWithRegistry:(NSObject*)registry {
+ [FlutterMarionettePlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterMarionettePlugin"]];
+}
+
+@end
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 4b660fe..2772308 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -36,6 +36,7 @@ class _MyAppState extends State {
setState(() { _result = "evaluate"; });
final result = await page.evaluate("document.querySelector('h1').textContent");
+// print(result);
setState(() { _result = result; });
page.dispose();
}
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 15cbf82..c6750f0 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -1,20 +1,34 @@
# Generated by pub
-# See https://www.dartlang.org/tools/pub/glossary#lockfile
+# See https://dart.dev/tools/pub/glossary#lockfile
packages:
+ archive:
+ dependency: transitive
+ description:
+ name: archive
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.11"
+ args:
+ dependency: transitive
+ description:
+ name: args
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.4.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "1.0.5"
charcode:
dependency: transitive
description:
@@ -29,13 +43,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
+ convert:
+ dependency: transitive
+ description:
+ name: convert
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.1"
+ crypto:
+ dependency: transitive
+ description:
+ name: crypto
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.3"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
- version: "0.1.2"
+ version: "0.1.3"
flutter:
dependency: "direct main"
description: flutter
@@ -53,41 +81,55 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ image:
+ dependency: transitive
+ description:
+ name: image
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.3+1"
+ version: "0.12.6"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.1.8"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.2"
+ version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
- version: "1.4.0"
+ version: "1.8.0+1"
+ petitparser:
+ dependency: transitive
+ description:
+ name: petitparser
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.1"
+ version: "2.0.5"
sky_engine:
dependency: transitive
description: flutter
@@ -99,7 +141,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.5.4"
+ version: "1.5.5"
stack_trace:
dependency: transitive
description:
@@ -113,14 +155,14 @@ packages:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.8"
+ version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "1.0.5"
term_glyph:
dependency: transitive
description:
@@ -134,7 +176,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.2"
+ version: "0.2.11"
typed_data:
dependency: transitive
description:
@@ -149,5 +191,12 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
+ xml:
+ dependency: transitive
+ description:
+ name: xml
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.5.0"
sdks:
- dart: ">=2.1.0 <3.0.0"
+ dart: ">=2.4.0 <3.0.0"
diff --git a/ios/Classes/SwiftFlutterMarionettePlugin.swift b/ios/Classes/SwiftFlutterMarionettePlugin.swift
index cbf2684..5de28dd 100644
--- a/ios/Classes/SwiftFlutterMarionettePlugin.swift
+++ b/ios/Classes/SwiftFlutterMarionettePlugin.swift
@@ -34,6 +34,7 @@ extension Promise where T: Encodable {
func flutter(_ result: @escaping FlutterResult) {
self.done {
let encoder = JSONEncoder()
+
result(String(data: try! encoder.encode([$0]).dropFirst().dropLast(), encoding: .utf8)!)
}.catch {
if let err = $0 as? JSError {
@@ -75,12 +76,12 @@ public class SwiftFlutterMarionettePlugin: NSObject, FlutterPlugin {
case .window(let window): window.addSubview(page.webView)
}
#endif
-
- SwiftFlutterMarionettePlugin.pages[id] = page
+ SwiftFlutterMarionettePlugin.pages[id] = page
result(id)
case "dispose":
let id = (call.arguments as! Dictionary)["id"] as! String
SwiftFlutterMarionettePlugin.pages[id]!.webView.removeFromSuperview()
+
SwiftFlutterMarionettePlugin.pages.removeValue(forKey: id)
case "click":
let id = (call.arguments as! Dictionary)["id"] as! String
@@ -105,6 +106,7 @@ public class SwiftFlutterMarionettePlugin: NSObject, FlutterPlugin {
SwiftFlutterMarionettePlugin.pages[id]!.type(selector, text).flutter(result)
case "reload":
let id = (call.arguments as! Dictionary)["id"] as! String
+
SwiftFlutterMarionettePlugin.pages[id]!.reload().flutter(result)
case "waitForFunction":
let id = (call.arguments as! Dictionary)["id"] as! String
@@ -112,10 +114,13 @@ public class SwiftFlutterMarionettePlugin: NSObject, FlutterPlugin {
SwiftFlutterMarionettePlugin.pages[id]!.waitForFunction(fn).flutter(result)
case "waitForNavigation":
let id = (call.arguments as! Dictionary)["id"] as! String
+
+
SwiftFlutterMarionettePlugin.pages[id]!.waitForNavigation().flutter(result)
case "waitForSelector":
let id = (call.arguments as! Dictionary)["id"] as! String
let selector = (call.arguments as! Dictionary)["selector"] as! String
+
SwiftFlutterMarionettePlugin.pages[id]!.waitForSelector(selector).flutter(result)
default:
result(FlutterMethodNotImplemented)
diff --git a/pubspec.lock b/pubspec.lock
index ea890ff..a1e8431 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.1.0"
boolean_selector:
dependency: transitive
description:
@@ -45,7 +45,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.3+1"
+ version: "0.12.5"
meta:
dependency: transitive
description:
@@ -66,14 +66,14 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
- version: "1.4.0"
+ version: "1.5.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.1"
+ version: "2.0.2"
sky_engine:
dependency: transitive
description: flutter
@@ -85,7 +85,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.5.4"
+ version: "1.5.5"
stack_trace:
dependency: transitive
description:
@@ -99,7 +99,7 @@ packages:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.8"
+ version: "2.0.0"
string_scanner:
dependency: transitive
description:
@@ -120,7 +120,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.2"
+ version: "0.2.4"
typed_data:
dependency: transitive
description:
@@ -136,4 +136,4 @@ packages:
source: hosted
version: "2.0.8"
sdks:
- dart: ">=2.1.0 <3.0.0"
+ dart: ">=2.2.0 <3.0.0"