You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2014/02/03 04:01:26 UTC

[1/2] git commit: [flex-sdk] [refs/heads/develop] - changed to use mx.utils.Platform calls

Updated Branches:
  refs/heads/develop bc01330d9 -> 3b75f126b


changed to use mx.utils.Platform calls


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

Branch: refs/heads/develop
Commit: 9b8d6cec366baa57ea27d3cb0312a0ce3928dcff
Parents: bc01330
Author: Justin Mclean <jm...@apache.org>
Authored: Mon Feb 3 13:59:22 2014 +1100
Committer: Justin Mclean <jm...@apache.org>
Committed: Mon Feb 3 13:59:22 2014 +1100

----------------------------------------------------------------------
 .../framework/src/mx/core/RuntimeDPIProvider.as  | 12 ++++++------
 .../framework/src/mx/managers/FocusManager.as    |  5 +++--
 .../framework/src/mx/utils/LoaderUtil.as         |  2 ++
 .../framework/src/mx/utils/MediaQueryParser.as   | 19 ++++++++++++-------
 .../supportClasses/ScrollableStageText.as        |  5 +++--
 .../supportClasses/StyleableStageText.as         |  5 +++--
 .../ViewNavigatorApplicationBase.as              |  7 +++----
 .../src/spark/skins/mobile/StageTextAreaSkin.as  |  3 ++-
 .../src/spark/skins/mobile/TextAreaSkin.as       |  3 ++-
 .../src/spark/skins/mobile/TextInputSkin.as      |  3 ++-
 .../projects/mx/src/mx/core/Application.as       |  6 +++---
 .../spark/src/spark/components/Application.as    | 15 ++++++---------
 .../supportClasses/SkinnableTextBase.as          |  3 ++-
 .../supportClasses/TouchScrollHelper.as          |  3 ++-
 14 files changed, 51 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/framework/src/mx/core/RuntimeDPIProvider.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/core/RuntimeDPIProvider.as b/frameworks/projects/framework/src/mx/core/RuntimeDPIProvider.as
index 46db6ad..d9b7e50 100644
--- a/frameworks/projects/framework/src/mx/core/RuntimeDPIProvider.as
+++ b/frameworks/projects/framework/src/mx/core/RuntimeDPIProvider.as
@@ -25,6 +25,7 @@ import flash.system.Capabilities;
 
 import mx.core.mx_internal;
 import mx.managers.SystemManager;
+import mx.utils.Platform;
 
 use namespace mx_internal;
 
@@ -118,12 +119,11 @@ public class RuntimeDPIProvider
 
     public function get runtimeDPI():Number
     {
+        var isIOS:Boolean = Platform.isIOS;
+        var screenDPI:Number = Capabilities.screenDPI;
 
-        var isIOS:Boolean = Capabilities.version.indexOf("IOS") == 0;
-        var screenDPI : Number= Capabilities.screenDPI;
-
-        if (isIOS) {
-
+        if (isIOS)
+		{
             var root:DisplayObject = SystemManager.getSWFRoot(this);
             if (root != null )  {
                 var stage:Stage = root.stage;
@@ -140,8 +140,8 @@ public class RuntimeDPIProvider
                 }
             }
         }
+		
         return classifyDPI(screenDPI);
-
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/framework/src/mx/managers/FocusManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/managers/FocusManager.as b/frameworks/projects/framework/src/mx/managers/FocusManager.as
index 64d7b22..1459d75 100644
--- a/frameworks/projects/framework/src/mx/managers/FocusManager.as
+++ b/frameworks/projects/framework/src/mx/managers/FocusManager.as
@@ -46,6 +46,7 @@ import mx.core.IUIComponent;
 import mx.core.IVisualElement;
 import mx.core.mx_internal;
 import mx.events.FlexEvent;
+import mx.utils.Platform;
 
 use namespace mx_internal;
 
@@ -141,8 +142,8 @@ public class FocusManager extends EventDispatcher implements IFocusManager
 		this.popup = popup;
 
         IMEEnabled = true;
-        browserMode = Capabilities.playerType == "ActiveX" && !popup;
-        desktopMode = Capabilities.playerType == "Desktop" && !popup;
+        browserMode = Platform.isBrowser && !popup;
+        desktopMode = Platform.isAir && !popup;
         // Flash main windows come up activated, AIR main windows don't
         windowActivated = !desktopMode;
     

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/framework/src/mx/utils/LoaderUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/utils/LoaderUtil.as b/frameworks/projects/framework/src/mx/utils/LoaderUtil.as
index 7f02d4d..a1e1112 100644
--- a/frameworks/projects/framework/src/mx/utils/LoaderUtil.as
+++ b/frameworks/projects/framework/src/mx/utils/LoaderUtil.as
@@ -32,6 +32,8 @@ import mx.core.mx_internal;
 import mx.core.RSLData;
 import mx.events.Request;
 import mx.managers.SystemManagerGlobals;
+import mx.utils.Platform;
+
 import flash.display.Loader;
 
 use namespace mx_internal;

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/framework/src/mx/utils/MediaQueryParser.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/utils/MediaQueryParser.as b/frameworks/projects/framework/src/mx/utils/MediaQueryParser.as
index 3b6832b..55dcadd 100644
--- a/frameworks/projects/framework/src/mx/utils/MediaQueryParser.as
+++ b/frameworks/projects/framework/src/mx/utils/MediaQueryParser.as
@@ -421,33 +421,38 @@ public class MediaQueryParser
      * os on ADL will return the host OS and not the device OS.
      * That why we need to check for a specific sequence for iOS and Android
      * */
-    private function getOSVersion(osPlatform: String ):Number {
-
+    private function getOSVersion(osPlatform:String):Number {
         //TODO (mamsellem)  retrieve  os version for Android, reading  system/build.prop
-
         var os: String = Capabilities.os;
         var osMatch: Array;
-        if (osPlatform == "ios"){
+		
+        if (osPlatform == "ios")
+		{
             osMatch = os.match(/iPhone OS\s([\d\.]+)/);
         }
-        else {
+        else
+		{
             osMatch = os.match(/[A-Za-z\s]+([\d\.]+)/);
         }
-       return osMatch ? convertVersionStringToNumber(osMatch [1]) : 0.0;
+		
+		return osMatch ? convertVersionStringToNumber(osMatch[1]) : 0.0;
     }
 
     /** @private  converts string version such as "X" or "X.Y" or "X.Y.Z" into a number.
      * minor version parts are normalized to 100  so that eg. X.1 < X.10
      * so "7.1" return 7.01 and "7.12" return 7.12
   */
-    private function convertVersionStringToNumber(versionString: String): Number {
+    private function convertVersionStringToNumber(versionString: String): Number
+	{
         var versionParts: Array = versionString.split(".");
         var version: Number = 0;
         var scale: Number = 1;
+		
         for each (var part: String in versionParts) {
             version += Number(part) * scale;
             scale /= 100;
         }
+		
         return version;
     }
 

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as
index 05cfe08..789e869 100644
--- a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as
+++ b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ScrollableStageText.as
@@ -48,6 +48,7 @@ import mx.core.mx_internal;
 import mx.events.FlexEvent;
 import mx.managers.SystemManager;
 import mx.utils.MatrixUtil;
+import mx.utils.Platform;
 
 import spark.components.Application;
 import spark.core.IProxiedStageTextWrapper;
@@ -318,8 +319,8 @@ public class ScrollableStageText extends UIComponent  implements IStyleableEdita
     //
     //--------------------------------------------------------------------------
 
-    protected static const isAndroid:Boolean = Capabilities.version.indexOf("AND") == 0;
-    protected static const isDesktop:Boolean = Capabilities.os.indexOf("Windows") != -1 || Capabilities.os.indexOf("Mac OS") != -1;
+    protected static const isAndroid:Boolean = Platform.isAndroid;
+    protected static const isDesktop:Boolean = Platform.isDesktop;
     /**
      *  Text measuring behavior needs to be slightly different on Android
      *  devices to account for its native text being slightly taller. Without

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableStageText.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableStageText.as b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableStageText.as
index d43e979..6949780 100644
--- a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableStageText.as
+++ b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableStageText.as
@@ -61,6 +61,7 @@ import mx.managers.FocusManager;
 import mx.managers.SystemManager;
 import mx.managers.systemClasses.ActiveWindowManager;
 import mx.utils.MatrixUtil;
+import mx.utils.Platform;
 
 import spark.components.Application;
 import spark.components.ViewNavigator;
@@ -378,8 +379,8 @@ public class StyleableStageText extends UIComponent implements IStyleableEditabl
      *  scroll vertically.
      */
     mx_internal static var androidHeightMultiplier:Number = 1.15;
-    private static const isAndroid:Boolean = Capabilities.version.indexOf("AND") == 0;
-    private static const isDesktop:Boolean = Capabilities.os.indexOf("Windows") != -1 || Capabilities.os.indexOf("Mac OS") != -1;    
+    private static const isAndroid:Boolean = Platform.isAndroid;
+    private static const isDesktop:Boolean = Platform.isDesktop;    
 
     //--------------------------------------------------------------------------
     //

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ViewNavigatorApplicationBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ViewNavigatorApplicationBase.as b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ViewNavigatorApplicationBase.as
index ff0af52..ca56eb1 100644
--- a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ViewNavigatorApplicationBase.as
+++ b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/ViewNavigatorApplicationBase.as
@@ -39,6 +39,7 @@ import mx.events.FlexEvent;
 import mx.events.FlexMouseEvent;
 import mx.events.ResizeEvent;
 import mx.managers.SystemManager;
+import mx.utils.Platform;
 
 import spark.components.Application;
 import spark.components.View;
@@ -554,8 +555,7 @@ public class ViewNavigatorApplicationBase extends Application
         // So the DEACTIVATE event is ignored on desktop machines.
         var os:String = Capabilities.os;
         
-        // TODO (chiedozi): If the framework ever supports Windows Mobile, we'll need to update this check.
-        var runningOnDesktop:Boolean = (os.indexOf("Windows") != -1 || os.indexOf("Mac OS") != -1);
+        var runningOnDesktop:Boolean = Platform.isDesktop;
         if (!runningOnDesktop)
             NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deactivateHandler);
         
@@ -570,8 +570,7 @@ public class ViewNavigatorApplicationBase extends Application
     {
         var os:String = Capabilities.os;
         
-        // TODO (chiedozi): If the framework ever supports Windows Mobile, we'll need to update this check.
-        var runningOnDesktop:Boolean = (os.indexOf("Windows") != -1 || os.indexOf("Mac OS") != -1);
+        var runningOnDesktop:Boolean = Platform.isDesktop;
         if (!runningOnDesktop)
             NativeApplication.nativeApplication.removeEventListener(Event.DEACTIVATE, deactivateHandler);
         

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/mobiletheme/src/spark/skins/mobile/StageTextAreaSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobiletheme/src/spark/skins/mobile/StageTextAreaSkin.as b/frameworks/projects/mobiletheme/src/spark/skins/mobile/StageTextAreaSkin.as
index 729eef9..4ef73c1 100644
--- a/frameworks/projects/mobiletheme/src/spark/skins/mobile/StageTextAreaSkin.as
+++ b/frameworks/projects/mobiletheme/src/spark/skins/mobile/StageTextAreaSkin.as
@@ -23,6 +23,7 @@ import flash.system.Capabilities;
 
 import mx.core.DPIClassification;
 import mx.core.mx_internal;
+import mx.utils.Platform;
 
 import spark.components.TextArea;
 import spark.components.supportClasses.StyleableTextField;
@@ -151,7 +152,7 @@ public class StageTextAreaSkin extends StageTextSkinBase
             var verticalPosAdjustment:Number = 0;
             var heightAdjustment:Number = 0;
             
-            if (Capabilities.version.indexOf("IOS") == 0)
+            if (Platform.isIOS)
             {
                 verticalPosAdjustment = Math.min(iOSVerticalPaddingAdjustment, paddingTop);
                 heightAdjustment = verticalPosAdjustment + Math.min(iOSVerticalPaddingAdjustment, paddingBottom);

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextAreaSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextAreaSkin.as b/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextAreaSkin.as
index 6ac6a67..31cea96 100644
--- a/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextAreaSkin.as
+++ b/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextAreaSkin.as
@@ -35,6 +35,7 @@ import mx.core.EventPriority;
 import mx.core.FlexGlobals;
 import mx.core.mx_internal;
 import mx.events.FlexEvent;
+import mx.utils.Platform;
 
 import spark.components.Group;
 import spark.components.Scroller;
@@ -249,7 +250,7 @@ public class TextAreaSkin extends TextSkinBase
             textDisplay.scrollToRangeDelegate = scrollToRange;
             
             // on iOS, resize the TextField and let the native control handle scrolling
-            _isIOS = (Capabilities.version.indexOf("IOS") == 0);
+            _isIOS = Platform.isIOS;
             
             if (_isIOS)
             {

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextInputSkin.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextInputSkin.as b/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextInputSkin.as
index 98d5def..310ba8f 100644
--- a/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextInputSkin.as
+++ b/frameworks/projects/mobiletheme/src/spark/skins/mobile/TextInputSkin.as
@@ -27,6 +27,7 @@ import mx.core.DPIClassification;
 import mx.core.EventPriority;
 import mx.core.mx_internal;
 import mx.events.FlexEvent;
+import mx.utils.Platform;
 
 import spark.components.TextInput;
 import spark.components.supportClasses.StyleableTextField;
@@ -71,7 +72,7 @@ public class TextInputSkin extends TextSkinBase
         super();
         
         // on iOS, make adjustments for native text rendering
-        _isIOS = (Capabilities.version.indexOf("IOS") == 0);
+        _isIOS = Platform.isIOS;
         
         switch (applicationDPI)
         {

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/mx/src/mx/core/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mx/src/mx/core/Application.as b/frameworks/projects/mx/src/mx/core/Application.as
index e5882aa..9fe0e82 100644
--- a/frameworks/projects/mx/src/mx/core/Application.as
+++ b/frameworks/projects/mx/src/mx/core/Application.as
@@ -43,6 +43,7 @@ import mx.managers.ISystemManager;
 import mx.styles.CSSStyleDeclaration;
 import mx.styles.IStyleClient;
 import mx.utils.LoaderUtil;
+import mx.utils.Platform;
 
 use namespace mx_internal;
 
@@ -1699,9 +1700,8 @@ public class Application extends LayoutContainer
     {
         var version:Array = Capabilities.version.split(' ')[1].split(',');
         
-        synchronousResize = (parseFloat(version[0]) > 10 || 
-            (parseFloat(version[0]) == 10 && parseFloat(version[1]) >= 1))
-            && (Capabilities.playerType != "Desktop");
+		synchronousResize = (parseFloat(version[0]) > 10 ||
+			(parseFloat(version[0]) == 10 && parseFloat(version[1]) >= 1)) && !Platform.isAir;
     }
     
     //--------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/spark/src/spark/components/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/Application.as b/frameworks/projects/spark/src/spark/components/Application.as
index 68048fa..3604668 100644
--- a/frameworks/projects/spark/src/spark/components/Application.as
+++ b/frameworks/projects/spark/src/spark/components/Application.as
@@ -55,6 +55,7 @@ import mx.managers.ToolTipManager;
 import mx.utils.BitFlagUtil;
 import mx.utils.DensityUtil;
 import mx.utils.LoaderUtil;
+import mx.utils.Platform;
 
 import spark.layouts.supportClasses.LayoutBase;
 
@@ -1355,7 +1356,7 @@ public class Application extends SkinnableContainer
             systemManager.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorRedispatcher);
 
         // Determine if we are running on an iOS device
-        isIOS = Capabilities.version.indexOf("IOS") == 0;
+        isIOS = Platform.isIOS;
         
         // To prevent a flicker described in SDK-30133, a flex application listens
         // for orientationChanging events dispatched by iOS AIR applications.
@@ -1854,14 +1855,10 @@ public class Application extends SkinnableContainer
      */
     private function initResizeBehavior():void
     {
-        var version:Array = Capabilities.version.split(' ')[1].split(',');
-        var versionPrefix:String = Capabilities.version.substr(0, 3).toLowerCase();
-        var runningOnMobile:Boolean = (versionPrefix != "win" && 
-                                       versionPrefix != "mac" && 
-                                       versionPrefix != "lnx");
-        
-        synchronousResize = (parseFloat(version[0]) > 10 ||
-                             (parseFloat(version[0]) == 10 && parseFloat(version[1]) >= 1)) && (Capabilities.playerType != "Desktop" || runningOnMobile);
+		var version:Array = Capabilities.version.split(' ')[1].split(',');
+		
+		synchronousResize = (parseFloat(version[0]) > 10 ||
+			(parseFloat(version[0]) == 10 && parseFloat(version[1]) >= 1)) && !Platform.isAir;
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/spark/src/spark/components/supportClasses/SkinnableTextBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/supportClasses/SkinnableTextBase.as b/frameworks/projects/spark/src/spark/components/supportClasses/SkinnableTextBase.as
index 6b6db26..dfd88cc 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/SkinnableTextBase.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/SkinnableTextBase.as
@@ -43,6 +43,7 @@ import mx.events.SandboxMouseEvent;
 import mx.events.TouchInteractionEvent;
 import mx.managers.IFocusManagerComponent;
 import mx.utils.BitFlagUtil;
+import mx.utils.Platform;
 
 import spark.components.Application;
 import spark.components.RichEditableText;
@@ -462,7 +463,7 @@ public class SkinnableTextBase extends SkinnableComponent
      *  @private
      *  Variable that determines whether this application is running on iOS.
      */
-    private static var isIOS:Boolean = (Capabilities.version.indexOf("IOS") == 0);
+    private static var isIOS:Boolean = Platform.isIOS;
     
     //--------------------------------------------------------------------------
     //

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9b8d6cec/frameworks/projects/spark/src/spark/components/supportClasses/TouchScrollHelper.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/supportClasses/TouchScrollHelper.as b/frameworks/projects/spark/src/spark/components/supportClasses/TouchScrollHelper.as
index a4be1f4..b3aff3a 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/TouchScrollHelper.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/TouchScrollHelper.as
@@ -35,6 +35,7 @@ import mx.events.TouchInteractionEvent;
 import mx.events.TouchInteractionReason;
 import mx.managers.ISystemManager;
 import mx.utils.GetTimerUtil;
+import mx.utils.Platform;
 
 use namespace mx_internal;
     
@@ -93,7 +94,7 @@ public class TouchScrollHelper
     {
         super();
         
-        isIOS = (Capabilities.version.indexOf("IOS") == 0);
+        isIOS = Platform.isIOS;
         
         mouseEventCoordinatesHistory = new Vector.<Point>(EVENT_HISTORY_LENGTH);
         mouseEventTimeHistory = new Vector.<int>(EVENT_HISTORY_LENGTH);


[2/2] git commit: [flex-sdk] [refs/heads/develop] - new class to check what platform an application is running on

Posted by jm...@apache.org.
new class to check what platform an application is running on


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/3b75f126
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/3b75f126
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/3b75f126

Branch: refs/heads/develop
Commit: 3b75f126b807c064cb68236db02986c453959f4f
Parents: 9b8d6ce
Author: Justin Mclean <jm...@apache.org>
Authored: Mon Feb 3 14:00:26 2014 +1100
Committer: Justin Mclean <jm...@apache.org>
Committed: Mon Feb 3 14:00:26 2014 +1100

----------------------------------------------------------------------
 .../projects/framework/src/mx/utils/Platform.as | 221 +++++++++++++++++++
 1 file changed, 221 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/3b75f126/frameworks/projects/framework/src/mx/utils/Platform.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/utils/Platform.as b/frameworks/projects/framework/src/mx/utils/Platform.as
new file mode 100644
index 0000000..8c9d65f
--- /dev/null
+++ b/frameworks/projects/framework/src/mx/utils/Platform.as
@@ -0,0 +1,221 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.utils
+{
+	
+import flash.system.Capabilities;
+
+/**
+ *  The Platform utility class constain several static methods to check what
+ *  desktop or mobile platform the application is running on.
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 2.0
+ *  @productversion Flex 4.12
+ */
+public class Platform
+{
+    include "../core/Version.as";
+	
+	protected static var _initilised:Boolean;
+	protected static var _isAndroid:Boolean;
+	protected static var _isIOS:Boolean;
+	protected static var _isBlackBerry:Boolean;
+	protected static var _isMobile:Boolean;
+	protected static var _isMac:Boolean;
+	protected static var _isWindows:Boolean;
+	protected static var _isLinux:Boolean;
+	protected static var _isDesktop:Boolean;
+	protected static var _isBrowser:Boolean;
+	protected static var _isAir:Boolean;
+	
+	/**
+	 *  Returns true if the applciation is runing on IOS.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isIOS():Boolean
+	{
+		getPlatforms();
+		
+		return _isIOS;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on a BlackBerry.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isBlackBerry():Boolean
+	{
+		getPlatforms();
+		
+		return _isBlackBerry;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on Android.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isAndroid():Boolean
+	{
+		getPlatforms();
+		
+		return _isAndroid;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on Windows.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isWindows():Boolean
+	{
+		getPlatforms();
+		
+		return _isWindows;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on a Mac.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isMac():Boolean
+	{
+		getPlatforms();
+		
+		return _isMac;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on Linux.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isLinux():Boolean
+	{
+		getPlatforms();
+		
+		return _isLinux;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on a Desktop OS.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isDesktop():Boolean
+	{
+		getPlatforms();
+		
+		return _isDesktop;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on a Mobile device.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isMobile():Boolean
+	{
+		getPlatforms();
+		
+		return _isMobile;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing on a desktop AIR.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isAir():Boolean
+	{
+		getPlatforms();
+		
+		return _isAir;
+	}
+	
+	/**
+	 *  Returns true if the applciation is runing in a browser.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 2.0
+	 *  @productversion Flex 4.12
+	 */
+	public static function get isBrowser():Boolean
+	{
+		getPlatforms();
+		
+		return _isBrowser;
+	}
+	
+	protected static function getPlatforms():void {
+		if (!_initilised)
+		{
+			_isAndroid = Capabilities.version.indexOf("AND") > -1;
+			_isIOS = Capabilities.version.indexOf('IOS') > -1;
+			_isBlackBerry = Capabilities.version.indexOf('QNX') > -1;
+			_isMobile = _isAndroid || _isIOS || _isBlackBerry;
+			
+			_isMac = Capabilities.os.indexOf("Mac OS") != -1;
+			_isWindows = Capabilities.os.indexOf("Windows") != -1;
+			_isLinux = Capabilities.os.indexOf("Linux") != -1; // note that Android is also Linux
+			_isDesktop = !_isMobile;
+			
+			_isAir = Capabilities.playerType == "Desktop";
+			_isBrowser = (Capabilities.playerType == "Plugin" || Capabilities.playerType == "ActiveX");
+			
+			_initilised = true;
+		}
+	}
+}
+
+}