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/06/07 22:20:55 UTC

[31/50] [abbrv] android commit: CB-779: Verify that fullscreen and backgroundColor preferences are set properly - This check-in enables fullscreen and adds test for it.

CB-779: Verify that fullscreen and backgroundColor preferences are set properly - This check-in enables fullscreen and adds test for it.


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

Branch: refs/heads/master
Commit: 2d7b7160c3f5ec5dfba5358552e030a74305edc2
Parents: 2fbb9c2
Author: Bryce Curtis <cu...@gmail.com>
Authored: Wed May 16 15:49:25 2012 -0500
Committer: Bryce Curtis <cu...@gmail.com>
Committed: Wed May 16 15:49:25 2012 -0500

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaWebView.java     |   60 ++++++++-------
 framework/src/org/apache/cordova/DroidGap.java     |    7 --
 test/AndroidManifest.xml                           |    3 +
 test/assets/www/fullscreen/index.html              |   41 ++++++++++
 test/assets/www/index.html                         |    1 +
 test/src/org/apache/cordova/test/fullscreen.java   |   39 ++++++++++
 6 files changed, 116 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2d7b7160/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 cdd2fbd..2ff342a 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -39,6 +39,7 @@ import android.net.Uri;
 import android.os.Bundle;
 import android.util.AttributeSet;
 import android.util.Log;
+import android.view.WindowManager;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.webkit.WebSettings.LayoutAlgorithm;
@@ -76,40 +77,38 @@ public class CordovaWebView extends WebView {
      */
     public CordovaWebView(Context context) {
         super(context);
-        if(CordovaInterface.class.isInstance(context))
+        if (CordovaInterface.class.isInstance(context))
         {
-          this.mCtx = (CordovaInterface) context;
+            this.mCtx = (CordovaInterface) context;
         }
         else
         {
-          Log.d(TAG, "Your activity must implement CordovaInterface to work");
+            Log.d(TAG, "Your activity must implement CordovaInterface to work");
         }
         this.loadConfiguration();
         this.setup();
     }
 
-    
     /**
      * Constructor.
      * 
-     * 
      * @param context
      * @param attrs
      */
     public CordovaWebView(Context context, AttributeSet attrs) {
-      super(context, attrs);
-      if(CordovaInterface.class.isInstance(context))
-      {
-        this.mCtx = (CordovaInterface) context;
-      }          
-      else
-      {
-        Log.d(TAG, "Your activity must implement CordovaInterface to work");
-      }
-      this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this));
-      this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this));
-      this.loadConfiguration();
-      this.setup();
+        super(context, attrs);
+        if (CordovaInterface.class.isInstance(context))
+        {
+            this.mCtx = (CordovaInterface) context;
+        }
+        else
+        {
+            Log.d(TAG, "Your activity must implement CordovaInterface to work");
+        }
+        this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this));
+        this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this));
+        this.loadConfiguration();
+        this.setup();
     }
 
     /**
@@ -120,15 +119,15 @@ public class CordovaWebView extends WebView {
      * @param defStyle
      * 
      */
-    public CordovaWebView(Context context, AttributeSet attrs, int defStyle)  {
+    public CordovaWebView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
-        if(CordovaInterface.class.isInstance(context))
+        if (CordovaInterface.class.isInstance(context))
         {
-          this.mCtx = (CordovaInterface) context;
+            this.mCtx = (CordovaInterface) context;
         }
         else
         {
-          Log.d(TAG, "Your activity must implement CordovaInterface to work");
+            Log.d(TAG, "Your activity must implement CordovaInterface to work");
         }
         this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this));
         this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this));
@@ -146,13 +145,13 @@ public class CordovaWebView extends WebView {
      */
     public CordovaWebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
         super(context, attrs, defStyle, privateBrowsing);
-        if(CordovaInterface.class.isInstance(context))
+        if (CordovaInterface.class.isInstance(context))
         {
-          this.mCtx = (CordovaInterface) context;
+            this.mCtx = (CordovaInterface) context;
         }
         else
         {
-          Log.d(TAG, "Your activity must implement CordovaInterface to work");
+            Log.d(TAG, "Your activity must implement CordovaInterface to work");
         }
         this.setWebChromeClient(new CordovaChromeClient(this.mCtx));
         this.setWebViewClient(new CordovaWebViewClient(this.mCtx));
@@ -192,10 +191,10 @@ public class CordovaWebView extends WebView {
 
         //Start up the plugin manager
         try {
-          this.pluginManager = new PluginManager(this, mCtx);
+            this.pluginManager = new PluginManager(this, this.mCtx);
         } catch (Exception e) {
-          // TODO Auto-generated catch block
-          e.printStackTrace();
+            // TODO Auto-generated catch block
+            e.printStackTrace();
         }
     }
 
@@ -637,6 +636,11 @@ public class CordovaWebView extends WebView {
         else {
             this.useBrowserHistory = false;
         }
+
+        if ("true".equals(this.getProperty("fullscreen", "false"))) {
+            this.mCtx.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+            this.mCtx.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2d7b7160/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 aeca772..2af6c9c 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -250,15 +250,8 @@ public class DroidGap extends Activity implements CordovaInterface {
         super.onCreate(savedInstanceState);
 
         getWindow().requestFeature(Window.FEATURE_NO_TITLE);
-
-        // TODO @bc - What about fullscreen?
-        //if (preferences.prefMatches("fullscreen", "true")) {
-        //    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
-        //            WindowManager.LayoutParams.FLAG_FULLSCREEN);
-        //} else {
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
                 WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
-        //}
 
         // This builds the view.  We could probably get away with NOT having a LinearLayout, but I like having a bucket!
         Display display = getWindowManager().getDefaultDisplay();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2d7b7160/test/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml
index 4918fe5..0d280ba 100755
--- a/test/AndroidManifest.xml
+++ b/test/AndroidManifest.xml
@@ -147,5 +147,8 @@
         <activity android:name="basicauth" android:label="@string/app_name" 
                   android:configChanges="orientation|keyboardHidden">
         </activity>
+        <activity android:name="fullscreen" android:label="@string/app_name" 
+                  android:configChanges="orientation|keyboardHidden">
+        </activity>
         </application>
 </manifest> 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2d7b7160/test/assets/www/fullscreen/index.html
----------------------------------------------------------------------
diff --git a/test/assets/www/fullscreen/index.html b/test/assets/www/fullscreen/index.html
new file mode 100755
index 0000000..ab910ac
--- /dev/null
+++ b/test/assets/www/fullscreen/index.html
@@ -0,0 +1,41 @@
+<!--
+         Licensed to the Apache Software Foundation (ASF) under one
+         or more contributor license agreements.  See the NOTICE file
+         distributed with this work for additional information
+         regarding copyright ownership.  The ASF licenses this file
+         to you under the Apache License, Version 2.0 (the
+         "License"); you may not use this file except in compliance
+         with the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+         Unless required by applicable law or agreed to in writing,
+         software distributed under the License is distributed on an
+         "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+         KIND, either express or implied.  See the License for the
+         specific language governing permissions and limitations
+         under the License.
+-->
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <meta name="viewport" content="width=320; user-scalable=no" />
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+    <title>Cordova Tests</title>
+      <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title">
+      <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+      <script type="text/javascript" charset="utf-8" src="../main.js"></script>
+  </head>
+  <body onload="init();" id="stage" class="theme">
+    <h1>Full Screen Test</h1>
+    <div id="info">
+        <h4>Platform: <span id="platform"> &nbsp;</span>,   Version: <span id="version">&nbsp;</span></h4>
+        <h4>UUID: <span id="uuid"> &nbsp;</span>,   Name: <span id="name">&nbsp;</span></h4>
+        <h4>Width: <span id="width"> &nbsp;</span>,   Height: <span id="height">&nbsp;
+                   </span>, Color Depth: <span id="colorDepth"></span></h4>
+     </div>
+     <div id="info">
+     The app should take over the entire screen.  The top Android status bar should not be shown. <br>
+     </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2d7b7160/test/assets/www/index.html
----------------------------------------------------------------------
diff --git a/test/assets/www/index.html b/test/assets/www/index.html
index 6838156..d1a770a 100755
--- a/test/assets/www/index.html
+++ b/test/assets/www/index.html
@@ -51,6 +51,7 @@
     <button class="btn large" onclick="startActivity('org.apache.cordova.test.backbuttonmultipage');">Backbutton with multiple pages</button>
     <button class="btn large" onclick="startActivity('org.apache.cordova.test.basicauth');">Basic Authentication</button>
     <button class="btn large" onclick="startActivity('org.apache.cordova.test.errorurl');">Error URL</button>
+    <button class="btn large" onclick="startActivity('org.apache.cordova.test.fullscreen');">Full Screen</button>
     <button class="btn large" onclick="startActivity('org.apache.cordova.test.htmlnotfound');">HTML not found</button>
     <button class="btn large" onclick="startActivity('org.apache.cordova.test.iframe');">IFrame</button>
     <button class="btn large" onclick="startActivity('org.apache.cordova.test.lifecycle');">Lifecycle</button>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2d7b7160/test/src/org/apache/cordova/test/fullscreen.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/fullscreen.java b/test/src/org/apache/cordova/test/fullscreen.java
new file mode 100755
index 0000000..8b14624
--- /dev/null
+++ b/test/src/org/apache/cordova/test/fullscreen.java
@@ -0,0 +1,39 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+package org.apache.cordova.test;
+
+import android.os.Bundle;
+import android.webkit.WebView;
+
+import org.apache.cordova.*;
+import org.apache.cordova.api.LOG;
+
+public class fullscreen extends DroidGap {
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        // Properties must be set before init() is called, since some are processed during init(). 
+        super.setBooleanProperty("fullscreen", true);
+
+        super.init();
+        super.loadUrl("file:///android_asset/www/fullscreen/index.html");
+    }
+
+}