You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/03/27 20:59:14 UTC
[1/2] android commit: Moving init code into the WebView
Updated Branches:
refs/heads/CordovaWebView 6dabe4c01 -> 59ff94fef
Moving init code into the WebView
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/59ff94fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/59ff94fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/59ff94fe
Branch: refs/heads/CordovaWebView
Commit: 59ff94fefb912bf078ece0561017c3e341995bc4
Parents: f3c2984
Author: Joe Bowser <bo...@apache.org>
Authored: Tue Mar 27 11:28:55 2012 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue Mar 27 11:28:55 2012 -0700
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaWebView.java | 39 ++++++++++++++-
framework/src/org/apache/cordova/DroidGap.java | 26 +---------
2 files changed, 39 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/59ff94fe/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index b24fc2c..c55877f 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -14,7 +14,9 @@ import org.xmlpull.v1.XmlPullParserException;
import android.content.Context;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
+import android.webkit.WebSettings;
import android.webkit.WebView;
+import android.webkit.WebSettings.LayoutAlgorithm;
public class CordovaWebView extends WebView {
@@ -22,26 +24,61 @@ public class CordovaWebView extends WebView {
/** The authorization tokens. */
private Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<String, AuthenticationToken>();
-
+ private Context mCtx;
/** The whitelist **/
private ArrayList<Pattern> whiteList = new ArrayList<Pattern>();
private HashMap<String, Boolean> whiteListCache = new HashMap<String,Boolean>();
public CordovaWebView(Context context) {
super(context);
+ mCtx = context;
+ setup();
}
public CordovaWebView(Context context, AttributeSet attrs) {
super(context, attrs);
+ mCtx = context;
+ setup();
}
public CordovaWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ mCtx = context;
+ setup();
}
public CordovaWebView(Context context, AttributeSet attrs, int defStyle,
boolean privateBrowsing) {
super(context, attrs, defStyle, privateBrowsing);
+ mCtx = context;
+ setup();
+ }
+
+ private void setup()
+ {
+ this.setInitialScale(0);
+ this.setVerticalScrollBarEnabled(false);
+ this.requestFocusFromTouch();
+
+ // Enable JavaScript
+ WebSettings settings = this.getSettings();
+ settings.setJavaScriptEnabled(true);
+ settings.setJavaScriptCanOpenWindowsAutomatically(true);
+ settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
+
+ //Set the nav dump for HTC
+ settings.setNavDump(true);
+
+ // Enable database
+ settings.setDatabaseEnabled(true);
+ String databasePath = mCtx.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
+ settings.setDatabasePath(databasePath);
+
+ // Enable DOM storage
+ settings.setDomStorageEnabled(true);
+
+ // Enable built-in geolocation
+ settings.setGeolocationEnabled(true);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/59ff94fe/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 07eb837..f586419 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -288,30 +288,6 @@ public class DroidGap extends Activity implements CordovaInterface {
this.appView.setWebChromeClient(webChromeClient);
this.setWebViewClient(this.appView, webViewClient);
- this.appView.setInitialScale(0);
- this.appView.setVerticalScrollBarEnabled(false);
- this.appView.requestFocusFromTouch();
-
- // Enable JavaScript
- WebSettings settings = this.appView.getSettings();
- settings.setJavaScriptEnabled(true);
- settings.setJavaScriptCanOpenWindowsAutomatically(true);
- settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
-
- //Set the nav dump for HTC
- settings.setNavDump(true);
-
- // Enable database
- settings.setDatabaseEnabled(true);
- String databasePath = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
- settings.setDatabasePath(databasePath);
-
- // Enable DOM storage
- settings.setDomStorageEnabled(true);
-
- // Enable built-in geolocation
- settings.setGeolocationEnabled(true);
-
// Add web view but make it invisible while loading URL
this.appView.setVisibility(View.INVISIBLE);
root.addView(this.appView);
@@ -321,7 +297,7 @@ public class DroidGap extends Activity implements CordovaInterface {
this.cancelLoadUrl = false;
// Create plugin manager
- this.pluginManager = new PluginManager(this.appView, this);
+ this.pluginManager = new PluginManager(this.appView, this);
}
/**