Commit 5648f694 authored by ChitiSims's avatar ChitiSims Committed by Evan W. Patton

Add WebViewStringChange Event

Closes #1036

Change-Id: I616d845134a42b9f93186d0403d4683c1200af35
parent 784e9b7f
...@@ -3615,6 +3615,10 @@ public interface OdeMessages extends Messages { ...@@ -3615,6 +3615,10 @@ public interface OdeMessages extends Messages {
@Description("") @Description("")
String WebViewStringProperties(); String WebViewStringProperties();
@DefaultMessage("WebViewStringChange")
@Description("")
String WebViewStringChangeEvents();
@DefaultMessage("EnableSpeedRegulation") @DefaultMessage("EnableSpeedRegulation")
@Description("") @Description("")
String EnableSpeedRegulationProperties(); String EnableSpeedRegulationProperties();
......
...@@ -1492,7 +1492,7 @@ public final class YoungAndroidFormUpgrader { ...@@ -1492,7 +1492,7 @@ public final class YoungAndroidFormUpgrader {
private static int upgradeWebViewerProperties(Map<String, JSONValue> componentProperties, private static int upgradeWebViewerProperties(Map<String, JSONValue> componentProperties,
int srcCompVersion) { int srcCompVersion) {
if (srcCompVersion < 6) { if (srcCompVersion < 7) {
// The CanGoForward and CanGoBack methods were added. // The CanGoForward and CanGoBack methods were added.
// No properties need to be modified to upgrade to version 2. // No properties need to be modified to upgrade to version 2.
// UsesLocation property added. // UsesLocation property added.
...@@ -1501,7 +1501,8 @@ public final class YoungAndroidFormUpgrader { ...@@ -1501,7 +1501,8 @@ public final class YoungAndroidFormUpgrader {
// No properties need to be modified to upgrade to version 4. // No properties need to be modified to upgrade to version 4.
// IgnoreSslError property added (version 5) // IgnoreSslError property added (version 5)
// ClearCaches method was added (version 6) // ClearCaches method was added (version 6)
srcCompVersion = 6; // WebViewStringChange event was added (version 7)
srcCompVersion = 7;
} }
return srcCompVersion; return srcCompVersion;
} }
......
...@@ -2547,7 +2547,10 @@ Blockly.Versioning.AllUpgradeMaps = ...@@ -2547,7 +2547,10 @@ Blockly.Versioning.AllUpgradeMaps =
5: "noUpgrade", 5: "noUpgrade",
// AI2: Added ClearCaches method // AI2: Added ClearCaches method
6: "noUpgrade" 6: "noUpgrade",
// AI2: Added WebViewStringChange
7: "noUpgrade"
}, // End WebViewer upgraders }, // End WebViewer upgraders
......
...@@ -429,8 +429,10 @@ public class YaVersion { ...@@ -429,8 +429,10 @@ public class YaVersion {
// - MAP_COMPONENT_VERSION was incremented to 4 // - MAP_COMPONENT_VERSION was incremented to 4
// For YOUNG_ANDROID_VERSION 171: // For YOUNG_ANDROID_VERSION 171:
// - FUSIONTABLESCONTROL_COMPONENT_VERSION was incremented to 4 // - FUSIONTABLESCONTROL_COMPONENT_VERSION was incremented to 4
// For YOUNG_ANDROID_VERSION 172:
// - WEBVIEWER_COMPONENT_VERSION was incremented to 7
public static final int YOUNG_ANDROID_VERSION = 171; public static final int YOUNG_ANDROID_VERSION = 172;
// ............................... Blocks Language Version Number ............................... // ............................... Blocks Language Version Number ...............................
...@@ -1139,7 +1141,9 @@ public class YaVersion { ...@@ -1139,7 +1141,9 @@ public class YaVersion {
// - IgnoreSslError property added // - IgnoreSslError property added
// For WEBVIEWER_COMPONENT_VERSION 6: // For WEBVIEWER_COMPONENT_VERSION 6:
// - ClearCaches method was added // - ClearCaches method was added
public static final int WEBVIEWER_COMPONENT_VERSION = 6; // For WEBVIEWER_COMPONENT_VERSiON 7:
// - Added WebViewStringChange event
public static final int WEBVIEWER_COMPONENT_VERSION = 7;
// For MEDIASTORE_COMPONENT_VERSION 1: // For MEDIASTORE_COMPONENT_VERSION 1:
// - Initial Version. // - Initial Version.
......
...@@ -11,6 +11,7 @@ import android.webkit.JavascriptInterface; ...@@ -11,6 +11,7 @@ import android.webkit.JavascriptInterface;
import com.google.appinventor.components.annotations.DesignerComponent; import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty; import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory; import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction; import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject; import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty; import com.google.appinventor.components.annotations.SimpleProperty;
...@@ -440,6 +441,11 @@ public final class WebViewer extends AndroidViewComponent { ...@@ -440,6 +441,11 @@ public final class WebViewer extends AndroidViewComponent {
webview.clearCache(true); webview.clearCache(true);
} }
@SimpleEvent(description = "When the JavaScript calls AppInventor.setWebViewString this event is run.")
public void WebViewStringChange(String value) {
EventDispatcher.dispatchEvent(this, "WebViewStringChange", value);
}
/** /**
* Allows the setting of properties to be monitored from the javascript * Allows the setting of properties to be monitored from the javascript
* in the WebView * in the WebView
...@@ -468,8 +474,14 @@ public final class WebViewer extends AndroidViewComponent { ...@@ -468,8 +474,14 @@ public final class WebViewer extends AndroidViewComponent {
* Sets the web view string * Sets the web view string
*/ */
@JavascriptInterface @JavascriptInterface
public void setWebViewString(String newString) { public void setWebViewString(final String newString) {
webViewString = newString; webViewString = newString;
container.$form().runOnUiThread(new Runnable() {
public void run() {
WebViewStringChange(newString);
}
});
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment