Repository: flex-asjs
Updated Branches:
  refs/heads/tlf f131187cd -> 65c599330


Update mobile Cordova Camera package so that it works again on Android and Air. 
Note that PhotoLibrary (for Cordova) is not available in this release.


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

Branch: refs/heads/tlf
Commit: 4c292836760365cd78b2b0a295751de3b6362022
Parents: ff24a87
Author: Peter Ent <[email protected]>
Authored: Tue May 30 14:49:59 2017 -0400
Committer: Peter Ent <[email protected]>
Committed: Tue May 30 14:49:59 2017 -0400

----------------------------------------------------------------------
 .../Mobile/src/main/flex/CordovaClasses.as      |   8 +-
 .../main/flex/org/apache/cordova/Application.as |  86 ---------
 .../src/main/flex/org/apache/cordova/Weinre.as  |  88 ---------
 .../flex/org/apache/cordova/camera/Camera.as    | 192 -------------------
 .../apache/cordova/geolocation/Geolocation.as   |  61 ------
 .../flex/org/apache/flex/cordova/Application.as |  86 +++++++++
 .../main/flex/org/apache/flex/cordova/Camera.as | 173 +++++++++++++++++
 .../main/flex/org/apache/flex/cordova/Weinre.as |  88 +++++++++
 .../flex/cordova/geolocation/Geolocation.as     |  61 ++++++
 .../src/main/resources/cordova-manifest.xml     |   8 +-
 10 files changed, 416 insertions(+), 435 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/CordovaClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/src/main/flex/CordovaClasses.as 
b/frameworks/projects/Mobile/src/main/flex/CordovaClasses.as
index 1c0b98e..73a73a8 100644
--- a/frameworks/projects/Mobile/src/main/flex/CordovaClasses.as
+++ b/frameworks/projects/Mobile/src/main/flex/CordovaClasses.as
@@ -27,10 +27,10 @@ package
  */
 internal class CordovaClasses
 {
-       import org.apache.cordova.camera.Camera; Camera;
-       import org.apache.cordova.Application; Application;
-       import org.apache.cordova.Weinre; Weinre;
-       import org.apache.cordova.geolocation.Geolocation; Geolocation;
+       import org.apache.flex.cordova.Camera; Camera;
+       import org.apache.flex.cordova.Application; Application;
+       import org.apache.flex.cordova.Weinre; Weinre;
+       import org.apache.flex.cordova.geolocation.Geolocation; Geolocation;
 }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Application.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Application.as 
b/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Application.as
deleted file mode 100644
index 2564637..0000000
--- a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Application.as
+++ /dev/null
@@ -1,86 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  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
-{
-       import org.apache.flex.events.Event;
-       import org.apache.flex.core.Application;
-       import org.apache.flex.core.IFlexInfo;
-
-       /**
-        *  A customized Application that dispatches the Cordova deviceReady 
event
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 10.2
-        *  @playerversion AIR 2.6
-        *  @productversion FlexJS 0.0
-        */
-       public class Application extends org.apache.flex.core.Application 
implements IFlexInfo
-       {
-               /**
-                * FalconJX will inject html into the index.html file.  
Surround with
-                * "inject_html" tag as follows:
-                *
-                * <inject_html>
-                * <meta name="viewport" content="width=device-width, 
initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
-                * <script type="text/javascript" src="cordova.js"></script>
-                * </inject_html>
-                */
-               public function Application()
-               {
-                       super();
-               }
-               
-               public var isDeviceReady:Boolean = false
-               
-               /**
-                * @private
-                */
-               COMPILE::JS
-               override public function start():void
-               {
-                       // listen for Cordova's deviceReady event
-                       document.addEventListener("deviceReady", startOnReady, 
false);
-                       
-                       // listen for preinitialize event which will be 
cancelled until
-                       // the Cordova 'deviceReady' event is received.
-                       addEventListener("preinitialize", handlePreInit);
-                       
-                       super.start();
-               }
-               
-               /**
-                * @private
-                */
-               private function handlePreInit(event:Event):void
-               {
-                       if (!isDeviceReady) {
-                               event.preventDefault(); // basically, cancel 
the event until the device is ready
-                       }
-               }
-               
-               /**
-                * @private
-                */
-               private function startOnReady(event:*):void
-               {
-                       isDeviceReady = true;
-                       removeEventListener("preinitialize", handlePreInit);
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Weinre.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Weinre.as 
b/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Weinre.as
deleted file mode 100644
index ae32d47..0000000
--- a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/Weinre.as
+++ /dev/null
@@ -1,88 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  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
-{
-    COMPILE::SWF
-    {
-        import flash.net.URLRequest;
-        import flash.net.navigateToURL;            
-    }
-       
-       import org.apache.flex.core.IBead;
-       import org.apache.flex.core.IStrand;
-       
-       /**
-        *  A class that helps set up to use Weinre for debugging
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 10.2
-        *  @playerversion AIR 2.6
-        *  @productversion FlexJS 0.0
-        */
-       public class Weinre implements IBead
-       {
-               public function Weinre()
-               {
-               }
-
-               private var _strand:IStrand;
-               
-               /**
-                *  @copy org.apache.flex.core.IBead#strand
-                *  
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion FlexJS 0.0
-                */
-               public function set strand(value:IStrand):void
-               {
-                       _strand = value;
-               }
-               
-               /**
-                *  The guid to use at the Weinre server
-                *  http://debug.phonegap.com
-                *  
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion FlexJS 0.0
-         *  @flexjsignorecoercion HTMLScriptElement
-         *  @flexjsignorecoercion HTMLHeadElement
-                */
-               public function set guid(value:String):void
-               {
-            COMPILE::SWF
-            {
-                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);
-            }
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/camera/Camera.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/camera/Camera.as 
b/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/camera/Camera.as
deleted file mode 100644
index 8adf787..0000000
--- 
a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/camera/Camera.as
+++ /dev/null
@@ -1,192 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  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.camera
-{
-    COMPILE::SWF
-    {
-        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]
-       /**
-        * The Camera class implements the Cordova Camera
-        * 
-        * @langversion 3.0
-        * @playerversion Flash 10.2
-        * @playerversion AIR 2.6
-        * @productversion FlexJS 0.0
-        * @flexjscordovaplugin cordova-plugin-camera
-        * @flexjsignorecoercion FileEntry
-        * @flexjsignorecoercion FileWriter
-        * @flexjsignorecoercion window
-     * @flexjsignorecoercion Blob
-        */
-       public class Camera
-       {
-               public static var DestinationType:Object = {
-                       DATA_URL : 0,      // Return image as base64-encoded 
string
-                       FILE_URI : 1,      // Return image file URI
-                       NATIVE_URI : 2     // Return image native URI (e.g., 
assets-library:// on iOS or content:// on Android)
-               };
-               
-               public static var PictureSourceType:Object = {
-                       PHOTOLIBRARY : 0,
-                       CAMERA : 1,
-                       SAVEDPHOTOALBUM : 2
-               };
-               
-               public static var EncodingType:Object = {
-                       JPEG : 0,               // Return JPEG encoded image
-                       PNG : 1                 // Return PNG encoded image
-               };
-               
-               public static var MediaType:Object = {
-                       PICTURE: 0,    // allow selection of still pictures 
only. DEFAULT. Will return format specified via DestinationType
-                       VIDEO: 1,      // allow selection of video only, WILL 
ALWAYS RETURN FILE_URI
-                       ALLMEDIA : 2   // allow selection from all media types
-               };
-               
-               public static var Direction:Object = {
-                       BACK : 0,      // Use the back-facing camera
-                       FRONT : 1      // Use the front-facing camera
-               };
-
-        COMPILE::SWF
-               private static var root:DisplayObjectContainer;
-               
-        COMPILE::SWF
-               public static function init(r:DisplayObjectContainer):void
-               {
-                       root = r;               
-               }
-               
-               public function Camera()
-               {
-                       pictureSourceType = 
org.apache.cordova.camera.Camera.PictureSourceType.PHOTOLIBRARY;
-                       destinationType = 
org.apache.cordova.camera.Camera.DestinationType.DATA_URL;
-                       mediaType = 
org.apache.cordova.camera.Camera.MediaType.PICTURE;
-                       encodingType = 
org.apache.cordova.camera.Camera.EncodingType.JPEG;
-                       direction = 
org.apache.cordova.camera.Camera.Direction.BACK;
-               }
-               
-               public var pictureSourceType:int;
-               public var destinationType:int;
-               public var mediaType:int;
-               public var encodingType:int;
-               public var direction:int;
-               
-               private var cameraSuccess:Function;
-               private var cameraError:Function;
-        COMPILE::SWF
-               private var ui:Sprite;
-        COMPILE::SWF
-               private var camera:flash.media.Camera;
-               
-               public function getPicture( cameraSuccess:Function, 
cameraError:Function, cameraOptions:Object ) : void
-               {
-            COMPILE::SWF
-            {
-                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::SWF
-               private function mouseClickHandler(event:MouseEvent):void
-               {
-                       savePicture();
-                       root.removeChild(ui);
-               }
-               
-        COMPILE::SWF
-               private function keyDownHandler(event:KeyboardEvent):void
-               {
-                       if (event.keyCode == Keyboard.ESCAPE)
-                               root.removeChild(ui);
-                       else if (event.keyCode == Keyboard.ENTER || 
event.keyCode == Keyboard.SPACE)
-                       {
-                               savePicture();
-                               root.removeChild(ui);
-                       }
-               }
-
-        COMPILE::SWF
-               private function savePicture():void
-               {
-                       var f:File = File.createTempFile();
-                       var bd:BitmapData = new BitmapData(camera.width, 
camera.height, false);
-                       var pix:ByteArray = new ByteArray();
-                       var rect:Rectangle = new Rectangle(0, 0, camera.width, 
camera.height);
-                       camera.copyToByteArray(rect, pix);
-                       pix.position = 0;
-                       bd.setPixels(rect, pix);
-                       var png:PNGEncoder = new PNGEncoder();
-                       var ba:ByteArray = png.encode(bd);
-                       var fs:FileStream = new FileStream();
-                       fs.open(f, FileMode.WRITE);
-                       fs.writeBytes(ba);
-                       fs.close();
-                       cameraSuccess(f.url);
-               }
-               
-               public function cleanup( cameraSuccess:Function, 
cameraError:Function ) : void
-               {
-            // no cleanup required in Flash
-            COMPILE::JS
-            {
-                navigator["camera"].cleanup();                
-            }
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/geolocation/Geolocation.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/geolocation/Geolocation.as
 
b/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/geolocation/Geolocation.as
deleted file mode 100644
index 97e99eb..0000000
--- 
a/frameworks/projects/Mobile/src/main/flex/org/apache/cordova/geolocation/Geolocation.as
+++ /dev/null
@@ -1,61 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  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.geolocation
-{
-       /**
-        * Geolocation provides the interface to the Cordova Geolocation plugin.
-        */
-
-       [Mixin]
-       /**
-        * The Geolocation class implements Cordova geolocation plugin
-        * 
-        * @langversion 3.0
-        * @playerversion Flash 10.2
-        * @playerversion AIR 2.6
-        * @productversion FlexJS 0.0
-        * @flexjscordovaplugin cordova-plugin-geolocation
-        * @flexjsignorecoercion FileEntry
-        * @flexjsignorecoercion FileWriter
-        * @flexjsignorecoercion window
-     * @flexjsignorecoercion Blob
-        */
-       public class Geolocation
-       {
-               /**
-                * Constructor
-                */
-               public function Geolocation()
-               {
-               }
-
-               /**
-                * Gets the device current location. If successful, the 
onSuccess function is
-                * called with position parameter (see Cordova documentation). 
If failure, the
-                * onError function is called with an error parameter (.code 
and .message members).
-                */
-               public function getCurrentPosition(onSuccess:Function, 
onError:Function):void
-               {
-                       COMPILE::JS {
-                               // TODO: (pent) Cordova externs
-                               
navigator["geolocation"].getCurrentPosition(onSuccess, onError);
-                       }
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Application.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Application.as
 
b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Application.as
new file mode 100644
index 0000000..52de8d6
--- /dev/null
+++ 
b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Application.as
@@ -0,0 +1,86 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.cordova
+{
+       import org.apache.flex.events.Event;
+       import org.apache.flex.core.Application;
+       import org.apache.flex.core.IFlexInfo;
+
+       /**
+        *  A customized Application that dispatches the Cordova deviceReady 
event
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public class Application extends org.apache.flex.core.Application 
implements IFlexInfo
+       {
+               /**
+                * FalconJX will inject html into the index.html file.  
Surround with
+                * "inject_html" tag as follows:
+                *
+                * <inject_html>
+                * <meta name="viewport" content="width=device-width, 
initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+                * <script type="text/javascript" src="cordova.js"></script>
+                * </inject_html>
+                */
+               public function Application()
+               {
+                       super();
+               }
+               
+               public var isDeviceReady:Boolean = false
+               
+               /**
+                * @private
+                */
+               COMPILE::JS
+               override public function start():void
+               {
+                       // listen for Cordova's deviceReady event
+                       document.addEventListener("deviceReady", startOnReady, 
false);
+                       
+                       // listen for preinitialize event which will be 
cancelled until
+                       // the Cordova 'deviceReady' event is received.
+                       addEventListener("preinitialize", handlePreInit);
+                       
+                       super.start();
+               }
+               
+               /**
+                * @private
+                */
+               private function handlePreInit(event:Event):void
+               {
+                       if (!isDeviceReady) {
+                               event.preventDefault(); // basically, cancel 
the event until the device is ready
+                       }
+               }
+               
+               /**
+                * @private
+                */
+               private function startOnReady(event:*):void
+               {
+                       isDeviceReady = true;
+                       removeEventListener("preinitialize", handlePreInit);
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Camera.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Camera.as 
b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Camera.as
new file mode 100644
index 0000000..8333fb2
--- /dev/null
+++ b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Camera.as
@@ -0,0 +1,173 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.cordova
+{
+       COMPILE::SWF
+       {
+               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;
+       }
+               
+       /**
+        * The Camera class implements the Cordova Camera
+        * 
+        * @langversion 3.0
+        * @playerversion Flash 10.2
+        * @playerversion AIR 2.6
+        * @productversion FlexJS 0.0
+        * @flexjscordovaplugin cordova-plugin-camera
+        * @flexjsignorecoercion FileEntry
+        * @flexjsignorecoercion FileWriter
+        * @flexjsignorecoercion window
+     * @flexjsignorecoercion Blob
+        */
+       COMPILE::JS
+       public class Camera
+       {
+               private var pictureSource:*;   // picture source
+               private var destinationType:*; // sets the format of returned 
value
+               
+               public function Camera()
+               {
+                       pictureSource=navigator['camera'].PictureSourceType;
+                       destinationType=navigator['camera'].DestinationType;
+               }
+               
+               public function capturePhoto(onPhotoDataSuccess:Function, 
onFail:Function):void
+               {
+                       // Take picture using device camera and retrieve image 
as base64-encoded string
+                       navigator['camera'].getPicture(onPhotoDataSuccess, 
onFail, { quality: 50,
+                               destinationType: destinationType.FILE_URI }); 
//DATA_URL
+               }
+               
+               public function getPhotoFromLibrary(onPhotoURISuccess:Function, 
onFail:Function):void
+               {
+                       // Retrieve image file location from specified source
+                       navigator['camera'].getPicture(onPhotoURISuccess, 
onFail, { quality: 50,
+                               destinationType: destinationType.FILE_URI,
+                               sourceType: 
navigator['camera'].PictureSourceType.PHOTOLIBRARY });
+               }
+               
+               public function cleanup( cameraSuccess:Function, 
cameraError:Function ) : void
+               {
+                       navigator["camera"].cleanup();
+               }
+       }
+       
+       [Mixin]
+       COMPILE::SWF
+       public class Camera
+       {
+               private var cameraSuccess:Function;
+               private var cameraError:Function;
+               private var ui:Sprite;
+               private var camera:flash.media.Camera;
+               
+               private static var root:DisplayObjectContainer;
+               
+               public static function init(r:DisplayObjectContainer):void
+               {
+                       root = r;               
+               }
+               
+               public function Camera()
+               {
+               }
+               
+               public function capturePhoto(onPhotoDataSuccess:Function, 
onFail:Function):void
+               {
+                       this.cameraSuccess = onPhotoDataSuccess;
+                       this.cameraError = onFail;
+                       
+                       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.");
+                       }
+               }
+               
+               public function getPhotoFromLibrary(onPhotoURISuccess:Function, 
onFail:Function):void
+               {
+                       // TBD
+               }
+               
+               private function mouseClickHandler(event:MouseEvent):void
+               {
+                       savePicture();
+                       root.removeChild(ui);
+               }
+               
+               private function keyDownHandler(event:KeyboardEvent):void
+               {
+                       if (event.keyCode == Keyboard.ESCAPE)
+                               root.removeChild(ui);
+                       else if (event.keyCode == Keyboard.ENTER || 
event.keyCode == Keyboard.SPACE)
+                       {
+                               savePicture();
+                               root.removeChild(ui);
+                       }
+               }
+               
+               private function savePicture():void
+               {
+                       var f:File = File.createTempFile();
+                       var bd:BitmapData = new BitmapData(camera.width, 
camera.height, false);
+                       var pix:ByteArray = new ByteArray();
+                       var rect:Rectangle = new Rectangle(0, 0, camera.width, 
camera.height);
+                       camera.copyToByteArray(rect, pix);
+                       pix.position = 0;
+                       bd.setPixels(rect, pix);
+                       var png:PNGEncoder = new PNGEncoder();
+                       var ba:ByteArray = png.encode(bd);
+                       var fs:FileStream = new FileStream();
+                       fs.open(f, FileMode.WRITE);
+                       fs.writeBytes(ba);
+                       fs.close();
+                       cameraSuccess(f.url);
+               }
+               
+               public function cleanup( cameraSuccess:Function, 
cameraError:Function ) : void
+               {
+                       // not required for SWF version
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Weinre.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Weinre.as 
b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Weinre.as
new file mode 100644
index 0000000..2daf982
--- /dev/null
+++ b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/Weinre.as
@@ -0,0 +1,88 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.cordova
+{
+    COMPILE::SWF
+    {
+        import flash.net.URLRequest;
+        import flash.net.navigateToURL;            
+    }
+       
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IStrand;
+       
+       /**
+        *  A class that helps set up to use Weinre for debugging
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public class Weinre implements IBead
+       {
+               public function Weinre()
+               {
+               }
+
+               private var _strand:IStrand;
+               
+               /**
+                *  @copy org.apache.flex.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+               }
+               
+               /**
+                *  The guid to use at the Weinre server
+                *  http://debug.phonegap.com
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+         *  @flexjsignorecoercion HTMLScriptElement
+         *  @flexjsignorecoercion HTMLHeadElement
+                */
+               public function set guid(value:String):void
+               {
+            COMPILE::SWF
+            {
+                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);
+            }
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/geolocation/Geolocation.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/geolocation/Geolocation.as
 
b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/geolocation/Geolocation.as
new file mode 100644
index 0000000..830d2cc
--- /dev/null
+++ 
b/frameworks/projects/Mobile/src/main/flex/org/apache/flex/cordova/geolocation/Geolocation.as
@@ -0,0 +1,61 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.flex.cordova.geolocation
+{
+       /**
+        * Geolocation provides the interface to the Cordova Geolocation plugin.
+        */
+
+       [Mixin]
+       /**
+        * The Geolocation class implements Cordova geolocation plugin
+        * 
+        * @langversion 3.0
+        * @playerversion Flash 10.2
+        * @playerversion AIR 2.6
+        * @productversion FlexJS 0.0
+        * @flexjscordovaplugin cordova-plugin-geolocation
+        * @flexjsignorecoercion FileEntry
+        * @flexjsignorecoercion FileWriter
+        * @flexjsignorecoercion window
+     * @flexjsignorecoercion Blob
+        */
+       public class Geolocation
+       {
+               /**
+                * Constructor
+                */
+               public function Geolocation()
+               {
+               }
+
+               /**
+                * Gets the device current location. If successful, the 
onSuccess function is
+                * called with position parameter (see Cordova documentation). 
If failure, the
+                * onError function is called with an error parameter (.code 
and .message members).
+                */
+               public function getCurrentPosition(onSuccess:Function, 
onError:Function):void
+               {
+                       COMPILE::JS {
+                               // TODO: (pent) Cordova externs
+                               
navigator["geolocation"].getCurrentPosition(onSuccess, onError);
+                       }
+               }
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4c292836/frameworks/projects/Mobile/src/main/resources/cordova-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/src/main/resources/cordova-manifest.xml 
b/frameworks/projects/Mobile/src/main/resources/cordova-manifest.xml
index d20b9ff..274b7fb 100644
--- a/frameworks/projects/Mobile/src/main/resources/cordova-manifest.xml
+++ b/frameworks/projects/Mobile/src/main/resources/cordova-manifest.xml
@@ -21,9 +21,9 @@
 
 <componentPackage>
 
-    <component id="Application" class="org.apache.cordova.Application"/>
-    <component id="Camera" class="org.apache.cordova.camera.Camera"/>
-    <component id="Weinre" class="org.apache.cordova.Weinre"/>
-    <component id="Geolocation" 
class="org.apache.cordova.geolocation.Geolocation" />
+    <component id="Application" class="org.apache.flex.cordova.Application"/>
+    <component id="Camera" class="org.apache.flex.cordova.Camera"/>
+    <component id="Weinre" class="org.apache.flex.cordova.Weinre"/>
+    <component id="Geolocation" 
class="org.apache.flex.cordova.geolocation.Geolocation" />
 
 </componentPackage>

Reply via email to