You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2017/06/03 20:33:14 UTC

[02/25] git commit: [flex-asjs] [refs/heads/tlf] - Updated CordovaCameraExample

Updated CordovaCameraExample


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

Branch: refs/heads/tlf
Commit: 73ea1686036094c5ba6f39ddbf593fa7084c9005
Parents: 4c29283
Author: Peter Ent <pe...@apache.org>
Authored: Tue May 30 14:51:37 2017 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Tue May 30 14:51:37 2017 -0400

----------------------------------------------------------------------
 .../CordovaCameraExample-app.xml                |  2 +-
 examples/flexjs/CordovaCameraExample/README.txt | 25 +++++-----
 examples/flexjs/CordovaCameraExample/build.xml  | 51 ++++++++------------
 .../src/main/flex/CordovaCameraExample.mxml     | 11 ++---
 .../src/main/flex/MyInitialView.mxml            | 29 ++++-------
 5 files changed, 49 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/73ea1686/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml b/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml
index 2e94c41..716ed13 100644
--- a/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml
+++ b/examples/flexjs/CordovaCameraExample/CordovaCameraExample-app.xml
@@ -17,7 +17,7 @@
   limitations under the License.
 
 -->
-<application xmlns="http://ns.adobe.com/air/application/4.0">
+<application xmlns="http://ns.adobe.com/air/application/16.0">
 
 <!-- Adobe AIR Application Descriptor File Template.
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/73ea1686/examples/flexjs/CordovaCameraExample/README.txt
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/README.txt b/examples/flexjs/CordovaCameraExample/README.txt
index a3ebcaf..74a4e48 100644
--- a/examples/flexjs/CordovaCameraExample/README.txt
+++ b/examples/flexjs/CordovaCameraExample/README.txt
@@ -2,26 +2,27 @@ Running the CordovaCameraExample on an Android Device
 
 From Flash Builder or the command line, run the FlexJS cross compiler, FalconJX, to build the HTML/JavaScript version of your app.
 % cd ~/dev/flex-asjs/examples/CordovaCameraExample
-% ant
+% ant all
 
-Go to your mobile development directory:
-%cd ~/mobile
+The ANT script will build the application and then create the Cordova template in the app/CordovaCameraExample directory.
 
-Copy into this directory, the cordova-build.xml ANT script:
-% cp ~/dev/flex-asjs/cordova-build.xml .
+Now install the Android platform:
 
-Create the Cordova project for your FlexJS application:
-% ant -f cordova-build.xml -DPROJECT_NAME=CordovaCameraExample -DTARGET_DIR=. -DPROJECT_DIR=/Users/home/dev/flex-asjs/examples/flexjs/CordovaCameraExample
+% cd app/CordovaCameraExample
+% cordova platform add android
+
+Now install the plugin:
 
-Load the Cordova camera plugin:
-cd CordovaCameraExample
 % cordova plugin add cordova-plugin-camera
 
-Modify the www/index.html file to include the cordova.js source (place this line with the other <script> elements):
-<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+Once this is complete, you can connect your Android device to your computer and run it:
 
-Run your app on your connected device:
+EITHER (if still in the Cordova app/CordovaCameraExample directory):
 % cordova run
 
+OR (return to top-level example directory):
+% cd flex-asjs/examples/flexjs/CordovaCameraExample
+% ant run
+
 Or run on the simulator
 % cordova emulate android
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/73ea1686/examples/flexjs/CordovaCameraExample/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/build.xml b/examples/flexjs/CordovaCameraExample/build.xml
index c40f3ff..e293491 100644
--- a/examples/flexjs/CordovaCameraExample/build.xml
+++ b/examples/flexjs/CordovaCameraExample/build.xml
@@ -20,63 +20,52 @@
 
 
 <project name="cordovacameraexample" default="main" basedir=".">
-    <property name="FLEXJS_HOME" location="../../.."/>
+   <property name="FLEXJS_HOME" location="../../.."/>
     <property name="example" value="CordovaCameraExample" />
     
-    <!-- this project needs AIR 3.4 FP 11.4 -->
     <property name="swf.version" value="17" />
     <property name="playerglobal.version" value="11.4" />
     
-    <property file="${FLEXJS_HOME}/env.properties"/>
     <property environment="env"/>
     <property file="${FLEXJS_HOME}/local.properties"/>
     <property file="${FLEXJS_HOME}/build.properties"/>
     <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
-    
     <property name="AIR_HOME" value="${env.AIR_HOME}"/>
-    <property name="config_arg" value="air"/>
+    <property name="config_arg" value="air" />
     
+    <include file="${basedir}/../../build_example.xml" />
+
+    <target name="main" depends="clean,build_example.compile,build_example.compile.cordova" description="Clean build of ${example}">
+    </target>
     
-    <condition property="adl" value="adl.exe">
-        <os family="windows"/>
-    </condition>
+    <target name="cordova" description="Executes the Cordova build script to create Cordova app">
+    	<ant antfile="../../../cordova-build.xml" />
+    </target>
     
-    <condition property="adl" value="adl">
-        <os family="mac"/>
-    </condition>
+    <target name="run-android" description="Executes the Cordova build script to run the app on a device.">
+    	<ant antfile="../../../cordova-build.xml" target="run" />
+    </target>
     
-    <condition property="runtime" value="win">
-        <os family="windows"/>
-    </condition>
+    <target name="all" depends="main, cordova" description="Builds the app then runs the Cordova script">
+    </target>
     
-    <condition property="runtime" value="mac">
-        <os family="mac"/>
-    </condition>
-
-    <include file="${basedir}/../../build_example.xml" />
-
-    <target name="main" depends="clean,build_example.compile,build_example.compile.cordova" description="Clean build of ${example}">
+    <target name="run">
+        <property name="which" value="debug" />
+        <antcall target="build_example.run.air.desktop" />
     </target>
     
     <target name="clean">
         <delete dir="${basedir}/bin" failonerror="false" />
         <delete dir="${basedir}/bin-debug" failonerror="false" />
         <delete dir="${basedir}/bin-release" failonerror="false" />
+        <delete dir="${basedir}/app" failonerror="false" />
         <delete dir="${basedir}/target" failonerror="false" />
     </target>
     
-    <target name="run">
-        <antcall target="build_example.run.air" >
-            <param name="profile" value="mobileDevice" />
-        </antcall>
-    </target>
-    
     <target name="examine" depends="build_example.get.browser">
         <property name="which" value="debug" />
-        <echo message="Take a picture."/>
-        <antcall target="build_example.run.air" >
-            <param name="profile" value="mobileDevice" />
-        </antcall>
+        <echo message="Take a picture with the camera."/>
+        <antcall target="build_example.run.air" />
         <antcall target="build_example.run.cordova" />
     </target>
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/73ea1686/examples/flexjs/CordovaCameraExample/src/main/flex/CordovaCameraExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/src/main/flex/CordovaCameraExample.mxml b/examples/flexjs/CordovaCameraExample/src/main/flex/CordovaCameraExample.mxml
index a745202..7c2d5db 100644
--- a/examples/flexjs/CordovaCameraExample/src/main/flex/CordovaCameraExample.mxml
+++ b/examples/flexjs/CordovaCameraExample/src/main/flex/CordovaCameraExample.mxml
@@ -19,12 +19,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 -->
 <cordova:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
-				   xmlns:local="*"
-				   xmlns:models="models.*"
-				   xmlns:js="library://ns.apache.org/flexjs/basic" 
-				   xmlns:cordova="library://ns.apache.org/flexjs/cordova"
-				   isDeviceReady="MyInitialView(initialView).ready = true"
-				   >
+                 xmlns:js="library://ns.apache.org/flexjs/basic"
+                 xmlns:cordova="library://ns.apache.org/flexjs/cordova"
+                 xmlns:google="library://ns.apache.org/flexjs/google"
+                 xmlns:local="*"
+                 applicationComplete="MyInitialView(initialView).ready = true">
 	
 	<cordova:valuesImpl>
 		<js:SimpleCSSValuesImpl />

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/73ea1686/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml b/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml
index 0b291b2..dcdd742 100644
--- a/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml
+++ b/examples/flexjs/CordovaCameraExample/src/main/flex/MyInitialView.mxml
@@ -23,9 +23,9 @@ limitations under the License.
     <fx:Script>
         <![CDATA[
 			
-			import org.apache.cordova.camera.Camera;
+			import org.apache.flex.cordova.Camera;
 			
-			private var cam:org.apache.cordova.camera.Camera = new org.apache.cordova.camera.Camera();
+			private var cam:Camera;
 			
 			public function set ready(value:Boolean):void
 			{
@@ -34,14 +34,16 @@ limitations under the License.
 			
 			public function snapPicture() : void
 			{
-				trace("snapping");
-				cam.getPicture(success,failure,{quality:100, destinationType:org.apache.cordova.camera.Camera.DestinationType.FILE_URI});
+				if (cam == null) {
+					cam = new Camera();
+				}
+				cam.capturePhoto(snapSuccess,failure);
 			}
 			
-			private function success(data:Object):void
+			private function snapSuccess(imageData:Object):void
 			{
-				output.text = "Success: "+String(data);
-				image.src = String(data);
+				output.text = "Snapped photo file: " + String(imageData);
+				image.src = String(imageData);
 			}
 			
 			private function failure(message:Object):void
@@ -49,23 +51,12 @@ limitations under the License.
 				output.text = "Failed: "+String(message);
 			}
 			
-			private function onFromPhotoLibrary() : void
-			{
-				cam.getPicture(success,failure,{ quality: 50,
-					destinationType: org.apache.cordova.camera.Camera.DestinationType.FILE_URI,
-					sourceType: org.apache.cordova.camera.Camera.PictureSourceType.PHOTOLIBRARY });
-			}
-			
 		]]>
     </fx:Script>
-	
-	<fx:Style>
-	
-	</fx:Style>
+    
 	
 	<js:Label id="status" x="20" y="140" width="400" text="loading..."/>
 	
-	<js:TextButton text="From Photo Library" x="20" y="20" click="onFromPhotoLibrary()" />
 	<js:TextButton text="Snap Picture" x="20" y="55" click="snapPicture()" />
 	
 	<js:Label id="output" x="20" y="110" width="400"/>