flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [26/55] [abbrv] git commit: [flex-asjs] [refs/heads/develop] - fixes to get CordovaCameraExample to compile
Date Thu, 17 Dec 2015 07:54:36 GMT
fixes to get CordovaCameraExample to compile


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/9a4afd6d
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/9a4afd6d
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/9a4afd6d

Branch: refs/heads/develop
Commit: 9a4afd6d8ba748e65b23dc896e641c47b33c8ddb
Parents: 3cfd365
Author: Alex Harui <aharui@apache.org>
Authored: Fri Dec 11 14:33:37 2015 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Dec 11 14:33:37 2015 -0800

----------------------------------------------------------------------
 .../Mobile/as/src/org/apache/cordova/Weinre.as  | 24 ++++-
 .../as/src/org/apache/cordova/camera/Camera.as  | 92 ++++++++++++--------
 .../projects/Mobile/compile-asjs-config.xml     |  6 +-
 frameworks/projects/Mobile/compile-config.xml   |  5 ++
 4 files changed, 86 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9a4afd6d/frameworks/projects/Mobile/as/src/org/apache/cordova/Weinre.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/as/src/org/apache/cordova/Weinre.as b/frameworks/projects/Mobile/as/src/org/apache/cordova/Weinre.as
index b405a2e..2e4b579 100644
--- a/frameworks/projects/Mobile/as/src/org/apache/cordova/Weinre.as
+++ b/frameworks/projects/Mobile/as/src/org/apache/cordova/Weinre.as
@@ -18,8 +18,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.cordova
 {
-	import flash.net.URLRequest;
-	import flash.net.navigateToURL;
+    COMPILE::AS3
+    {
+        import flash.net.URLRequest;
+        import flash.net.navigateToURL;            
+    }
 	
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IStrand;
@@ -61,10 +64,25 @@ package org.apache.cordova
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
 		 *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion HTMLScriptElement
+         *  @flexjsignorecoercion HTMLHeadElement
 		 */
 		public function set guid(value:String):void
 		{
-			navigateToURL(new URLRequest("http://debug.phonegap.com/client/#" + value), "_blank");
+            COMPILE::AS3
+            {
+                navigateToURL(new URLRequest("http://debug.phonegap.com/client/#" + value),
"_blank");                    
+            }
+            COMPILE::JS
+            {
+                var scriptNode:HTMLScriptElement = document.createElement('SCRIPT') as HTMLScriptElement;
+                scriptNode.type = 'text/javascript';
+                scriptNode.src = 'http://debug.phonegap.com/target/target-script-min.js#'
+ value;
+                
+                var headNode:HTMLHeadElement = document.getElementsByTagName('HEAD') as HTMLHeadElement;
+                if (headNode[0] != null)
+                    headNode[0].appendChild(scriptNode);
+            }
 		}
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9a4afd6d/frameworks/projects/Mobile/as/src/org/apache/cordova/camera/Camera.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/as/src/org/apache/cordova/camera/Camera.as b/frameworks/projects/Mobile/as/src/org/apache/cordova/camera/Camera.as
index 3984b44..faea7c0 100644
--- a/frameworks/projects/Mobile/as/src/org/apache/cordova/camera/Camera.as
+++ b/frameworks/projects/Mobile/as/src/org/apache/cordova/camera/Camera.as
@@ -18,24 +18,27 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.cordova.camera
 {
-	import flash.display.BitmapData;
-	import flash.display.DisplayObject;
-	import flash.display.DisplayObjectContainer;
-	import flash.display.Sprite;
-	import flash.events.ActivityEvent;
-	import flash.events.KeyboardEvent;
-	import flash.events.MouseEvent;
-	import flash.filesystem.File;
-	import flash.filesystem.FileMode;
-	import flash.filesystem.FileStream;
-	import flash.geom.Rectangle;
-	import flash.media.Camera;
-	import flash.media.Video;
-	import flash.ui.Keyboard;
-	import flash.utils.ByteArray;
-	
-	import org.apache.flex.utils.PNGEncoder;
-
+    COMPILE::AS3
+    {
+        import flash.display.BitmapData;
+        import flash.display.DisplayObject;
+        import flash.display.DisplayObjectContainer;
+        import flash.display.Sprite;
+        import flash.events.ActivityEvent;
+        import flash.events.KeyboardEvent;
+        import flash.events.MouseEvent;
+        import flash.filesystem.File;
+        import flash.filesystem.FileMode;
+        import flash.filesystem.FileStream;
+        import flash.geom.Rectangle;
+        import flash.media.Camera;
+        import flash.media.Video;
+        import flash.ui.Keyboard;
+        import flash.utils.ByteArray;
+        
+        import org.apache.flex.utils.PNGEncoder;
+    }
+    
 	[Mixin]
 	public class Camera
 	{
@@ -67,8 +70,10 @@ package org.apache.cordova.camera
 			FRONT : 1      // Use the front-facing camera
 		};
 
+        COMPILE::AS3
 		private static var root:DisplayObjectContainer;
 		
+        COMPILE::AS3
 		public static function init(r:DisplayObjectContainer):void
 		{
 			root = r;		
@@ -91,35 +96,47 @@ package org.apache.cordova.camera
 		
 		private var cameraSuccess:Function;
 		private var cameraError:Function;
+        COMPILE::AS3
 		private var ui:Sprite;
+        COMPILE::AS3
 		private var camera:flash.media.Camera;
 		
 		public function getPicture( cameraSuccess:Function, cameraError:Function, cameraOptions:Object
) : void
 		{
-			this.cameraSuccess = cameraSuccess;
-			this.cameraError = cameraError;
-			
-			camera = flash.media.Camera.getCamera();
-			
-			if (camera != null) {
-				ui = new Sprite();
-				var video:Video = new Video(camera.width * 2, camera.height * 2);
-				video.attachCamera(camera);
-				ui.addChild(video);
-				root.addChild(ui);
-				ui.addEventListener(MouseEvent.CLICK, mouseClickHandler);
-				ui.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
-			} else {
-				trace("You need a camera.");
-			}
+            COMPILE::AS3
+            {
+                this.cameraSuccess = cameraSuccess;
+                this.cameraError = cameraError;
+                
+                camera = flash.media.Camera.getCamera();
+                
+                if (camera != null) {
+                    ui = new Sprite();
+                    var video:Video = new Video(camera.width * 2, camera.height * 2);
+                    video.attachCamera(camera);
+                    ui.addChild(video);
+                    root.addChild(ui);
+                    ui.addEventListener(MouseEvent.CLICK, mouseClickHandler);
+                    ui.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
+                } else {
+                    trace("You need a camera.");
+                }                    
+            }
+            COMPILE::JS
+            {
+                // TODO: (aharui) Cordova externs
+                navigator["camera"].getPicture(cameraSuccess, cameraError, cameraOptions);
+            }
 		}
 		
+        COMPILE::AS3
 		private function mouseClickHandler(event:MouseEvent):void
 		{
 			savePicture();
 			root.removeChild(ui);
 		}
 		
+        COMPILE::AS3
 		private function keyDownHandler(event:KeyboardEvent):void
 		{
 			if (event.keyCode == Keyboard.ESCAPE)
@@ -131,6 +148,7 @@ package org.apache.cordova.camera
 			}
 		}
 
+        COMPILE::AS3
 		private function savePicture():void
 		{
 			var f:File = File.createTempFile();
@@ -151,7 +169,11 @@ package org.apache.cordova.camera
 		
 		public function cleanup( cameraSuccess:Function, cameraError:Function ) : void
 		{
-			// no cleanup required in Flash
+            // no cleanup required in Flash
+            COMPILE::JS
+            {
+                navigator["camera"].cleanup();                
+            }
 		}
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9a4afd6d/frameworks/projects/Mobile/compile-asjs-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/compile-asjs-config.xml b/frameworks/projects/Mobile/compile-asjs-config.xml
index face373..ba49185 100644
--- a/frameworks/projects/Mobile/compile-asjs-config.xml
+++ b/frameworks/projects/Mobile/compile-asjs-config.xml
@@ -55,10 +55,10 @@
                 <uri>library://ns.apache.org/flexjs/basic</uri>
                 <manifest>basic-manifest.xml</manifest>
             </namespace>
-            <!--<namespace>
+            <namespace>
                 <uri>library://ns.apache.org/flexjs/cordova</uri>
                 <manifest>cordova-manifest.xml</manifest>
-            </namespace>-->
+            </namespace>
         </namespaces>
         
         <source-path>
@@ -76,11 +76,11 @@
     
     <include-classes>
         <class>MobileClasses</class>
-        <!-- <class>CordovaClasses</class> -->
     </include-classes>
     
     <include-namespaces>
         <uri>library://ns.apache.org/flexjs/basic</uri>
+        <uri>library://ns.apache.org/flexjs/cordova</uri>
     </include-namespaces>
         
     <target-player>${playerglobal.version}</target-player>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9a4afd6d/frameworks/projects/Mobile/compile-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/compile-config.xml b/frameworks/projects/Mobile/compile-config.xml
index 1738229..8a4b4ed 100644
--- a/frameworks/projects/Mobile/compile-config.xml
+++ b/frameworks/projects/Mobile/compile-config.xml
@@ -52,6 +52,10 @@
                 <uri>library://ns.apache.org/flexjs/basic</uri>
                 <manifest>basic-manifest.xml</manifest>
             </namespace>
+            <namespace>
+                <uri>library://ns.apache.org/flexjs/cordova</uri>
+                <manifest>cordova-manifest.xml</manifest>
+            </namespace>
         </namespaces>
         
         <source-path>
@@ -76,6 +80,7 @@
     
     <include-namespaces>
         <uri>library://ns.apache.org/flexjs/basic</uri>
+        <uri>library://ns.apache.org/flexjs/cordova</uri>
     </include-namespaces>
         
     <target-player>${playerglobal.version}</target-player>


Mime
View raw message