Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CDE519880 for ; Tue, 27 Mar 2012 18:59:14 +0000 (UTC) Received: (qmail 3212 invoked by uid 500); 27 Mar 2012 18:59:14 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 3180 invoked by uid 500); 27 Mar 2012 18:59:14 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 3173 invoked by uid 99); 27 Mar 2012 18:59:14 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Mar 2012 18:59:14 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4059B9690; Tue, 27 Mar 2012 18:59:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bowserj@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [1/2] android commit: Moving init code into the WebView Message-Id: <20120327185914.4059B9690@tyr.zones.apache.org> Date: Tue, 27 Mar 2012 18:59:14 +0000 (UTC) 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 Authored: Tue Mar 27 11:28:55 2012 -0700 Committer: Joe Bowser 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 authenticationTokens = new Hashtable(); - + private Context mCtx; /** The whitelist **/ private ArrayList whiteList = new ArrayList(); private HashMap whiteListCache = new HashMap(); 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); } /**