Repository: flex-asjs Updated Branches: refs/heads/develop 73c03a8ba -> f15776630
add a Cordova Application class and a Weinre bead Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/f1577663 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/f1577663 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/f1577663 Branch: refs/heads/develop Commit: f15776630272608037cbe14d4c4d8e0e7901321c Parents: 73c03a8 Author: Alex Harui <aha...@apache.org> Authored: Thu May 8 11:18:01 2014 -0700 Committer: Alex Harui <aha...@apache.org> Committed: Thu May 8 11:18:01 2014 -0700 ---------------------------------------------------------------------- .../src/CordovaCameraExample.mxml | 19 +++--- .../CordovaCameraExample/src/MyInitialView.mxml | 10 ++- .../as/projects/FlexJSUI/compile-config.xml | 5 ++ .../as/projects/FlexJSUI/cordova-manifest.xml | 28 ++++++++ .../as/projects/FlexJSUI/src/FlexJSUIClasses.as | 2 + .../src/org/apache/cordova/Application.as | 56 +++++++++++++++ .../FlexJSUI/src/org/apache/cordova/Weinre.as | 70 +++++++++++++++++++ .../src/org/apache/cordova/Application.js | 61 +++++++++++++++++ .../js/FlexJS/src/org/apache/cordova/Weinre.js | 71 ++++++++++++++++++++ .../src/org/apache/flex/utils/Language.js | 3 + 10 files changed, 316 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/examples/CordovaCameraExample/src/CordovaCameraExample.mxml ---------------------------------------------------------------------- diff --git a/examples/CordovaCameraExample/src/CordovaCameraExample.mxml b/examples/CordovaCameraExample/src/CordovaCameraExample.mxml index 8d76281..6699d43 100644 --- a/examples/CordovaCameraExample/src/CordovaCameraExample.mxml +++ b/examples/CordovaCameraExample/src/CordovaCameraExample.mxml @@ -18,19 +18,22 @@ // //////////////////////////////////////////////////////////////////////////////// --> -<basic:Application xmlns:fx="http://ns.adobe.com/mxml/2009" +<cordova:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:local="*" xmlns:models="models.*" xmlns:basic="library://ns.apache.org/flexjs/basic" + xmlns:cordova="library://ns.apache.org/flexjs/cordova" + deviceready="MyInitialView(initialView).ready = true" > - <basic:valuesImpl> + <cordova:valuesImpl> <basic:SimpleCSSValuesImpl /> - </basic:valuesImpl> - <basic:initialView> + </cordova:valuesImpl> + <cordova:initialView> <local:MyInitialView /> - </basic:initialView> - <basic:beads> + </cordova:initialView> + <cordova:beads> <basic:MixinManager /> - </basic:beads> -</basic:Application> + <cordova:Weinre guid="aharui" /> + </cordova:beads> +</cordova:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/examples/CordovaCameraExample/src/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/CordovaCameraExample/src/MyInitialView.mxml b/examples/CordovaCameraExample/src/MyInitialView.mxml index 0ab3628..fd0afba 100644 --- a/examples/CordovaCameraExample/src/MyInitialView.mxml +++ b/examples/CordovaCameraExample/src/MyInitialView.mxml @@ -19,7 +19,7 @@ limitations under the License. --> <basic:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:basic="library://ns.apache.org/flexjs/basic" - xmlns:local="*" xmlns:media="org.apache.flex.mobile.media.*"> + xmlns:local="*" > <fx:Script> <![CDATA[ @@ -27,8 +27,14 @@ limitations under the License. private var cam:org.apache.cordova.camera.Camera = new org.apache.cordova.camera.Camera(); + public function set ready(value:Boolean):void + { + status.text = "ready"; + } + public function snapPicture() : void { + trace("snapping"); cam.getPicture(success,failure,{quality:100, destinationType:org.apache.cordova.camera.Camera.DestinationType.FILE_URI}); } @@ -57,6 +63,8 @@ limitations under the License. </fx:Style> + <basic:Label id="status" x="20" y="140" width="400" text="loading..."/> + <basic:TextButton text="From Photo Library" x="20" y="20" click="onFromPhotoLibrary()" /> <basic:TextButton text="Snap Picture" x="20" y="55" click="snapPicture()" /> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/as/projects/FlexJSUI/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/compile-config.xml b/frameworks/as/projects/FlexJSUI/compile-config.xml index 7db518e..21d0dfe 100644 --- a/frameworks/as/projects/FlexJSUI/compile-config.xml +++ b/frameworks/as/projects/FlexJSUI/compile-config.xml @@ -51,6 +51,10 @@ <manifest>createjs-manifest.xml</manifest> </namespace> <namespace> + <uri>library://ns.apache.org/flexjs/cordova</uri> + <manifest>cordova-manifest.xml</manifest> + </namespace> + <namespace> <uri>library://ns.apache.org/flexjs/svg</uri> <manifest>svg-manifest.xml</manifest> </namespace> @@ -77,6 +81,7 @@ <uri>library://ns.adobe.com/flex/mx</uri> <uri>library://ns.apache.org/flexjs/html5</uri> <uri>library://ns.apache.org/flexjs/jquery</uri> + <uri>library://ns.apache.org/flexjs/cordova</uri> <uri>library://ns.apache.org/flexjs/createjs</uri> <uri>library://ns.apache.org/flexjs/svg</uri> </include-namespaces> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/as/projects/FlexJSUI/cordova-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/cordova-manifest.xml b/frameworks/as/projects/FlexJSUI/cordova-manifest.xml new file mode 100644 index 0000000..002eed1 --- /dev/null +++ b/frameworks/as/projects/FlexJSUI/cordova-manifest.xml @@ -0,0 +1,28 @@ +<?xml version="1.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. + +--> + + +<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"/> + +</componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as index 064128e..6b46e35 100644 --- a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as +++ b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as @@ -28,6 +28,8 @@ package internal class FlexJSUIClasses { import org.apache.cordova.camera.Camera; Camera; + import org.apache.cordova.Application; Application; + import org.apache.cordova.Weinre; Weinre; import org.apache.flex.html.accessories.NumericOnlyTextInputBead; NumericOnlyTextInputBead; import org.apache.flex.html.accessories.PasswordInputBead; PasswordInputBead; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Application.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Application.as b/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Application.as new file mode 100644 index 0000000..c19f26a --- /dev/null +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Application.as @@ -0,0 +1,56 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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; + + /** + * Dispatched at startup after the initial view has been + * put on the display list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="deviceready", type="org.apache.flex.events.Event")] + + /** + * 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 + { + public function Application() + { + addEventListener("applicationComplete", appCompleteHandler); + } + + private function appCompleteHandler(event:Event):void + { + dispatchEvent(new Event("deviceready")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Weinre.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Weinre.as b/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Weinre.as new file mode 100644 index 0000000..b405a2e --- /dev/null +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/cordova/Weinre.as @@ -0,0 +1,70 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 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 + */ + public function set guid(value:String):void + { + navigateToURL(new URLRequest("http://debug.phonegap.com/client/#" + value), "_blank"); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/js/FlexJS/src/org/apache/cordova/Application.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/cordova/Application.js b/frameworks/js/FlexJS/src/org/apache/cordova/Application.js new file mode 100644 index 0000000..c26239a --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/cordova/Application.js @@ -0,0 +1,61 @@ +/** + * Licensed 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. + */ + + +/** + * org.apache.cordova.Application + * + * @fileoverview + * + * @suppress {checkTypes} + */ + +goog.provide('org.apache.cordova.Application'); + +goog.require('org.apache.flex.core.Application'); + + + +/** + * @constructor + * @extends {org.apache.flex.core.Application} + */ +org.apache.cordova.Application = function() { + goog.base(this); + + document.addEventListener('deviceready', + goog.bind(this.devicereadyredispatcher, this), + false); +}; +goog.inherits(org.apache.cordova.Application, + org.apache.flex.core.Application); + + +/** + * @protected + * @param {Object} event + */ +org.apache.cordova.Application.prototype.devicereadyredispatcher = function(event) { + this.dispatchEvent('deviceready'); +}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +org.apache.cordova.Application.prototype.FLEXJS_CLASS_INFO = { + names: [{ name: 'Application', qName: 'org.apache.cordova.Application'}] +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/js/FlexJS/src/org/apache/cordova/Weinre.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/cordova/Weinre.js b/frameworks/js/FlexJS/src/org/apache/cordova/Weinre.js new file mode 100644 index 0000000..cc5f604 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/cordova/Weinre.js @@ -0,0 +1,71 @@ +/** + * Licensed 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. + */ + + +/** + * org.apache.cordova.Application + * + * @fileoverview + * + * @suppress {checkTypes} + */ + +goog.provide('org.apache.cordova.Weinre'); + + + +/** + * @constructor + */ +org.apache.cordova.Weinre = function() { +}; + + +/** + * @expose + * @param {Object} value The new host. + */ +org.apache.cordova.Weinre.prototype.set_strand = +function(value) { + + this.strand_ = value; +}; + + +/** + * @expose + * @param {string} value The new guid. + */ +org.apache.cordova.Weinre.prototype.set_guid = +function(value) { + + var scriptNode = document.createElement('SCRIPT'); + scriptNode.type = 'text/javascript'; + scriptNode.src = 'http://debug.phonegap.com/target/target-script-min.js#' + value; + + var headNode = document.getElementsByTagName('HEAD'); + if (headNode[0] != null) + headNode[0].appendChild(scriptNode); + +}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +org.apache.cordova.Weinre.prototype.FLEXJS_CLASS_INFO = { + names: [{ name: 'Weinre', qName: 'org.apache.cordova.Weinre'}] +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1577663/frameworks/js/FlexJS/src/org/apache/flex/utils/Language.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/Language.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/Language.js index 8701c71..2d43ecb 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/utils/Language.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/Language.js @@ -157,6 +157,9 @@ org.apache.flex.utils.Language.trace = function(opt_value) { theConsole = goog.global.console; + if (theConsole === undefined && window.console !== undefined) + theConsole = window.console; + try { if (theConsole && theConsole.log) { theConsole.log(opt_value);