incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject android commit: Moving preferences into CordovaWebView, need to discuss prefs when using CordovaWebView
Date Fri, 27 Apr 2012 21:44:38 GMT
Updated Branches:
  refs/heads/CordovaWebView 5ab5cf03b -> f4cf2cecb


Moving preferences into CordovaWebView, need to discuss prefs when using CordovaWebView


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/f4cf2cec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/f4cf2cec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/f4cf2cec

Branch: refs/heads/CordovaWebView
Commit: f4cf2cecb59a23068ef5bd69ac85803cd1660597
Parents: 5ab5cf0
Author: Joe Bowser <bowserj@apache.org>
Authored: Fri Apr 27 14:44:19 2012 -0700
Committer: Joe Bowser <bowserj@apache.org>
Committed: Fri Apr 27 14:44:19 2012 -0700

----------------------------------------------------------------------
 framework/res/xml/cordova.xml                      |    2 +-
 .../src/org/apache/cordova/CordovaWebView.java     |   57 +++++++++++++++
 framework/src/org/apache/cordova/DroidGap.java     |    2 +-
 3 files changed, 59 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/f4cf2cec/framework/res/xml/cordova.xml
----------------------------------------------------------------------
diff --git a/framework/res/xml/cordova.xml b/framework/res/xml/cordova.xml
index 8f347e7..ddf3029 100644
--- a/framework/res/xml/cordova.xml
+++ b/framework/res/xml/cordova.xml
@@ -30,7 +30,7 @@
 	<!-- <access origin=".*"/> Allow all domains, suggested development use only -->
 
     <log level="DEBUG"/>
-    <preference name="classicRender" value="true" />
+    <preference name="useWebkitHistory" value="false" />
 </cordova>
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/f4cf2cec/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 59785e8..773f2b8 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -51,6 +51,9 @@ public class CordovaWebView extends WebView {
 
   protected long loadUrlTimeoutValue;
 
+  //preferences read from cordova.xml
+  protected PreferenceSet preferences;
+  
   public CordovaWebView(Context context) {
     super(context);
     mCtx = context;
@@ -450,5 +453,59 @@ public class CordovaWebView extends WebView {
       }
   }
   
+  /**
+   * Load Cordova configuration from res/xml/cordova.xml.
+   * Approved list of URLs that can be loaded into DroidGap
+   *      <access origin="http://server regexp" subdomains="true" />
+   * Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
+   *      <log level="DEBUG" />
+   */
+  private void loadConfiguration() {
+      int id = getResources().getIdentifier("cordova", "xml", mCtx.getPackageName());
+      if (id == 0) {
+          LOG.i("CordovaLog", "cordova.xml missing. Ignoring...");
+          return;
+      }
+      XmlResourceParser xml = getResources().getXml(id);
+      int eventType = -1;
+      while (eventType != XmlResourceParser.END_DOCUMENT) {
+          if (eventType == XmlResourceParser.START_TAG) {
+              String strNode = xml.getName();
+              if (strNode.equals("access")) {
+                  String origin = xml.getAttributeValue(null, "origin");
+                  String subdomains = xml.getAttributeValue(null, "subdomains");
+                  if (origin != null) {
+                      addWhiteListEntry(origin, (subdomains != null) && (subdomains.compareToIgnoreCase("true")
== 0));
+                  }
+              }
+              else if (strNode.equals("log")) {
+                  String level = xml.getAttributeValue(null, "level");
+                  LOG.i("CordovaLog", "Found log level %s", level);
+                  if (level != null) {
+                      LOG.setLogLevel(level);
+                  }
+              }
+              else if (strNode.equals("preference")) {
+                  String name = xml.getAttributeValue(null, "name");
+                  String value = xml.getAttributeValue(null, "value");
+                  String readonlyString = xml.getAttributeValue(null, "readonly");
+
+                  boolean readonly = (readonlyString != null &&
+                                      readonlyString.equals("true"));
+
+                  LOG.i("CordovaLog", "Found preference for %s", name);
+
+                  preferences.add(new PreferenceNode(name, value, readonly));
+              }
+          }
+          try {
+              eventType = xml.next();
+          } catch (XmlPullParserException e) {
+              e.printStackTrace();
+          } catch (IOException e) {
+              e.printStackTrace();
+          }
+      }
+  }
   
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/f4cf2cec/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 b40f708..b084e5d 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -1004,7 +1004,7 @@ public class DroidGap extends Activity implements CordovaInterface {
                     String origin = xml.getAttributeValue(null, "origin");
                     String subdomains = xml.getAttributeValue(null, "subdomains");
                     if (origin != null) {
-                        this.appView.addWhiteListEntry(origin, (subdomains != null) &&
(subdomains.compareToIgnoreCase("true") == 0));
+                        appView.addWhiteListEntry(origin, (subdomains != null) &&
(subdomains.compareToIgnoreCase("true") == 0));
                     }
                 }
                 else if (strNode.equals("log")) {


Mime
View raw message