Skip to content

Commit

Permalink
Refactors API, adds battery information for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
rozd committed Feb 18, 2015
1 parent 2dc5e79 commit 0407d95
Show file tree
Hide file tree
Showing 42 changed files with 1,373 additions and 184 deletions.
Binary file modified bin/deviceinfo.ane
Binary file not shown.
Binary file modified build/default/deviceinfo-default.swc
Binary file not shown.
Binary file modified build/deviceinfo.ane
Binary file not shown.
Binary file modified build/deviceinfo.swc
Binary file not shown.
2 changes: 1 addition & 1 deletion build/extension.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension xmlns="http://ns.adobe.com/air/extension/4.0">
<id>com.github.airext.DeviceInfo</id>
<versionNumber>1.0.0</versionNumber>
<versionNumber>1.1.0</versionNumber>
<platforms>
<platform name="iPhone-ARM">
<applicationDeployment>
Expand Down
Binary file modified build/libDeviceInfo.a
Binary file not shown.
2 changes: 1 addition & 1 deletion build/platform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<description></description>
<sdkVersion>6.0</sdkVersion>
<linkerOptions>
<!-- <option>-framework CoreTelephony</option> -->
<!-- <option></option> -->
</linkerOptions>
<!-- <packagedDependencies>
<packagedDependency></packagedDependency>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified deviceinfo-air/deviceinfo-debug/ane/deviceinfo.ane
Binary file not shown.
11 changes: 7 additions & 4 deletions deviceinfo-air/deviceinfo-debug/deviceinfo-debug.iml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
<module type="Flex" version="4">
<component name="FlexBuildConfigurationManager" active="deviceinfo-debug">
<configurations>
<configuration name="deviceinfo-debug" target-platform="Mobile" pure-as="true" main-class="DeviceInfoDebug" output-file="DeviceInfoDebug.swf" output-folder="$MODULE_DIR$/bin-debug">
<dependencies target-player="11.6">
<configuration name="deviceinfo-debug" target-platform="Mobile" main-class="DeviceInfoDebug" output-file="DeviceInfoDebug.swf" output-folder="$MODULE_DIR$/bin-debug">
<dependencies>
<entries>
<entry library-id="c31ee848-4372-498b-b644-a67e612b0d60">
<dependency linkage="Merged" />
</entry>
</entries>
<sdk name="4.0.0" />
<sdk name="4.13.0" />
</dependencies>
<compiler-options />
<packaging-air-desktop />
<packaging-android enabled="true" use-generated-descriptor="false" custom-descriptor-path="$MODULE_DIR$/DeviceInfoDebug-app.xml" package-file-name="DeviceInfoDebug" />
<packaging-ios enabled="true" use-generated-descriptor="false" custom-descriptor-path="$MODULE_DIR$/DeviceInfoDebug-app.xml" package-file-name="DeviceInfoDebug">
<files-to-package>
<FilePathAndPathInPackage file-path="$MODULE_DIR$/[email protected]" path-in-package="[email protected]" />
</files-to-package>
<AirSigningOptions keystore-path="$USER_HOME$/ios/certificate/ios_air_development.p12" provisioning-profile-path="$USER_HOME$/ios/provisioning/Generic_Profile.mobileprovision" />
</packaging-ios>
</configuration>
Expand All @@ -26,7 +29,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="4.0.0" jdkType="Flex SDK Type (new)" />
<orderEntry type="jdk" jdkName="4.13.0" jdkType="Flex SDK Type (new)" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" exported="">
<library type="flex">
Expand Down
55 changes: 55 additions & 0 deletions deviceinfo-air/deviceinfo-debug/src/DeviceInfoDebug.mxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<!--
Created by max on 10/23/14.
-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" backgroundColor="#00AAAA">

<fx:Script>
<![CDATA[
import com.github.airext.DeviceInfo;
import com.github.airext.data.DeviceInfoGeneral;
import spark.components.Alert;
private function imei_clickHandler(event:MouseEvent):void
{
Alert.show(String(DeviceInfo.sharedInstance().getIMEI()));
}
private function general_clickHandler(event:MouseEvent):void
{
var general:DeviceInfoGeneral = DeviceInfo.sharedInstance().general;
Alert.show(String(general));
}
private function iosVendorIdentifier_clickHandler(event:MouseEvent):void
{
var general:DeviceInfoGeneral = DeviceInfo.sharedInstance().general;
Alert.show(String(general.ios.getVendorIdentifier()));
}
]]>
</fx:Script>

<s:layout>
<s:VerticalLayout horizontalAlign="justify" gap="30" paddingTop="30" />
</s:layout>

<s:Button label="IMEI" click="imei_clickHandler(event)" />

<s:Button label="General" click="general_clickHandler(event)" />

<s:SkinnableContainer backgroundColor="#FFFFFF">
<s:layout><s:HorizontalLayout paddingLeft="10" paddingTop="10" paddingBottom="10" /></s:layout>
<s:Label text="Battery State:{DeviceInfo.sharedInstance().battery.state}" />
<s:Label text="Battery Level:{DeviceInfo.sharedInstance().battery.level}" />
</s:SkinnableContainer>

<s:Label text="IOS SPECIFIC" />

<s:Button label="Vendor Identifier" click="iosVendorIdentifier_clickHandler(event)" />

</s:Application>
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package {

import com.github.airext.DeviceInfo;
import com.github.airext.data.DeviceInfoGeneral;

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.text.TextField;

public class DeviceInfoDebug extends Sprite
public class DeviceInfoDebugStarling extends Sprite
{
public function DeviceInfoDebug()
public function DeviceInfoDebugStarling()
{
super();

Expand All @@ -19,8 +20,8 @@ public class DeviceInfoDebug extends Sprite
{
tf.text += "getting imei... \n";

tf.text += "imei: " + DeviceInfo.getInstance().getIMEI() + "\n";
trace(DeviceInfo.getInstance().getIMEI());
tf.text += "imei: " + DeviceInfo.sharedInstance().getIMEI() + "\n";
trace(DeviceInfo.sharedInstance().getIMEI());
}
);

Expand All @@ -29,8 +30,8 @@ public class DeviceInfoDebug extends Sprite
{
tf.text += "getting identifier... \n";

tf.text += "deviceIdentifier: " + DeviceInfo.getInstance().getDeviceIdentifier() + "\n";
trace(DeviceInfo.getInstance().getDeviceIdentifier());
tf.text += "getVendorIdentifier: " + DeviceInfo.sharedInstance().general.ios.getVendorIdentifier() + "\n";
trace(DeviceInfo.sharedInstance().general.ios.getVendorIdentifier());
}
);

Expand All @@ -39,7 +40,7 @@ public class DeviceInfoDebug extends Sprite
{
tf.text += "getting info... \n";

var info:Object = DeviceInfo.getInstance().getDeviceInfo() || {};
var info:DeviceInfoGeneral = DeviceInfo.sharedInstance().general || {};

tf.text += "name: " + info.name + "\n";
tf.text += "model: " + info.model + "\n";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/**
* Created by mobitile on 10/22/14.
*/
package com.github.airext.data
{
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.system.Capabilities;

public class DeviceInfoBattery extends EventDispatcher
{
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------

public function DeviceInfoBattery()
{
super();
}

//--------------------------------------------------------------------------
//
// Properties
//
//--------------------------------------------------------------------------

//------------------------------------
// level
//------------------------------------

private var _level:Number;

[Bindable(event="levelChanged")]
public function get level():Number
{
if (isNaN(_level))
{
_level = getLevel();
}

return _level;
}

private function setLevel(value:Number):void
{
if (value == _level) return;
_level = value;
dispatchEvent(new Event("levelChanged"));
}

//------------------------------------
// state
//------------------------------------

private var _state:String;

[Bindable(event="stateChanged")]
public function get state():String
{
if (_state == null)
{
_state = getState();
}

return _state;
}

private function setState(value:String):void
{
if (value == _state) return;
_state = value;
dispatchEvent(new Event("stateChanged"));
}

//--------------------------------------------------------------------------
//
// Methods
//
//--------------------------------------------------------------------------

public function getLevel():Number
{
trace("DeviceInfo is not supported for " + Capabilities.os);

return null;
}

public function getState():String
{
trace("DeviceInfo is not supported for " + Capabilities.os);

return null;
}

public function startMonitoring():void
{
trace("DeviceInfo is not supported for " + Capabilities.os);
}

public function stopMonitoring():void
{
trace("DeviceInfo is not supported for " + Capabilities.os);
}

//--------------------------------------------------------------------------
//
// Overridden methods
//
//--------------------------------------------------------------------------

override public function toString():String
{
return '[DeviceInfoBattery level="'+_level+'", state="'+_state+'"]';
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* Created by mobitile on 10/22/14.
*/
package com.github.airext.data
{

public class DeviceInfoGeneral
{
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------

public function DeviceInfoGeneral()
{
super();
}

//--------------------------------------------------------------------------
//
// Properties
//
//--------------------------------------------------------------------------

//-------------------------------------
// name
//-------------------------------------

public var name:String;

//-------------------------------------
// model
//-------------------------------------

public var model:String;

//-------------------------------------
// manufacturer
//-------------------------------------

public var manufacturer:String;

//-------------------------------------
// systemName
//-------------------------------------

public var systemName:String;

//-------------------------------------
// systemVersion
//-------------------------------------

public var systemVersion:String;

//-------------------------------------
// platform
//-------------------------------------

public var platform:String;

//--------------------------------------------------------------------------
//
// Platform-specific properties
//
//--------------------------------------------------------------------------

//-------------------------------------
// ios
//-------------------------------------

private var _ios:DeviceInfoGeneralIOS;

public function get ios():DeviceInfoGeneralIOS
{
if (_ios == null)
{
_ios = new DeviceInfoGeneralIOS();
}

return _ios;
}

//-------------------------------------
// osx
//-------------------------------------

//-------------------------------------
// win
//-------------------------------------

//--------------------------------------------------------------------------
//
// Methods
//
//--------------------------------------------------------------------------

public function toString():String
{
return '[DeviceInfoGeneral ' +
'name="'+name+'", ' +
'model="'+model+'", ' +
'manufacturer="'+manufacturer+', ' +
'systemName="'+systemName+'", ' +
'systemVersion="'+systemVersion+'", ' +
'ios="'+ios+'"]';
}
}
}
Loading

0 comments on commit 0407d95

Please sign in to comment.