Skip to content

Commit

Permalink
Adds log() and crash() methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
rozd committed Jul 21, 2015
1 parent 89fde46 commit 047425f
Show file tree
Hide file tree
Showing 22 changed files with 341 additions and 336 deletions.
Binary file modified bin/deviceinfo.ane
Binary file not shown.
Binary file modified bin/deviceinfo.swc
Binary file not shown.
2 changes: 1 addition & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ unzip -o deviceinfo.swc

unzip -o default/deviceinfo-default.swc -d default

adt -package -storetype pkcs12 -keystore ~/certs/rozd.p12 -storepass vopli -target ane deviceinfo.ane extension.xml -swc deviceinfo.swc -platform iPhone-ARM libDeviceInfo.a library.swf -platformoptions platform-ios.xml -platform iPhone-x86 libDeviceInfoSimulator.a library.swf -platform Android-ARM libDeviceInfo.jar library.swf -platform default -C default library.swf
adt -package -storetype pkcs12 -keystore $AIR_CERTIFICATE -storepass $AIR_CERTIFICATE_STOREPASS -target ane deviceinfo.ane extension.xml -swc deviceinfo.swc -platform iPhone-ARM libDeviceInfo.a library.swf -platformoptions platform-ios.xml -platform iPhone-x86 libDeviceInfoSimulator.a library.swf -platform Android-ARM libDeviceInfo.jar library.swf -platform default -C default library.swf

cp -R deviceinfo.ane ../deviceinfo-air/deviceinfo-debug/ane/deviceinfo.ane

Expand Down
22 changes: 1 addition & 21 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,34 +176,14 @@
<arg line="-platform default -C default/ ."/>
</exec>

<!--<exec executable="${air.sdk}/bin/adt${bin.ext}" failonerror="true" dir="temp">-->
<!--<arg value="-package"/>-->
<!--<arg value="-storetype"/>-->
<!--<arg value="pkcs12"/>-->
<!--<arg value="-keystore"/>-->
<!--<arg value="${keystore.file}"/>-->
<!--<arg value="-storepass"/>-->
<!--<arg value="${keystore.password}"/>-->
<!--<arg value="-target"/>-->
<!--<arg value="ane"/>-->
<!--<arg value="${name}.ane"/>-->
<!--<arg value="../extension.xml"/>-->
<!--<arg line="-swc swc/${name}.swc"/>-->
<!--<arg line="-platform iPhone-ARM -platformoptions ../platform-ios.xml -C ios/ ."/>-->
<!--<arg line="-platform iPhone-x86 -platformoptions ../platform-ios.xml -C ios-simulator/ ."/>-->
<!--<arg line="-platform Android-ARM -platformoptions ../platform-android.xml -C android/ ."/>-->
<!--&lt;!&ndash;<arg line="-platform Android-x86 -platformoptions ../platform-android.xml -C android/ ."/>&ndash;&gt;-->
<!--<arg line="-platform default -C default/ ."/>-->
<!--</exec>-->

<!-- Move packaged .ANE file to /bin directory -->
<move file="temp/${name}.ane" todir="../bin"/>

<!-- Move default .SWC library to /bin directory -->
<copy file="temp/default/${name}.swc" todir="../bin"/>

<!-- Remove temporary directory -->
<!--<delete dir="temp"/>-->
<delete dir="temp"/>
</target>

</project>
Binary file modified build/deviceinfo.ane
Binary file not shown.
9 changes: 4 additions & 5 deletions build/example.build.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
name = Flurry

sdk.home = /path/to/your/flexsdk/folder

bin.ext =

# The location of the .p12 certificate file
Expand All @@ -13,4 +9,7 @@ keystore.file = /path/to/your/certificate/selfSignedTestCert.p12
keystore.password = selfSignedTestPassword

# Location of the android sdk
android.sdk = path/to/your/android-sdk/platforms/android-8
android.sdk = path/to/your/android-sdk/platforms/android-8

# Location of the AIR SDK
air.sdk = path/to/airsdk/folder
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.2</versionNumber>
<versionNumber>1.3</versionNumber>
<platforms>
<platform name="iPhone-ARM">
<applicationDeployment>
Expand Down
Binary file modified build/libDeviceInfo.a
Binary file not shown.
Binary file removed build/libDeviceInfo.jar
Binary file not shown.
Binary file modified deviceinfo-air/deviceinfo-debug/ane/deviceinfo.ane
Binary file not shown.
17 changes: 17 additions & 0 deletions deviceinfo-air/deviceinfo-debug/src/DeviceInfoDebug.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
DeviceInfo.sharedInstance().battery.startMonitoring();
}
}
private function log_clickHandler(event:MouseEvent):void
{
DeviceInfo.sharedInstance().log(logInput.text);
}
private function crash_clickHandler(event:MouseEvent):void
{
DeviceInfo.sharedInstance().crash();
}
]]>
</fx:Script>

Expand All @@ -72,6 +82,13 @@
</s:HGroup>
</s:VGroup>

<s:HGroup contentBackgroundColor="#FFFFFF">
<s:TextInput id="logInput" width="100%" />
<s:Button label="Log" click="log_clickHandler(event)" />
</s:HGroup>

<s:Button label="Crash" click="crash_clickHandler(event)" />

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

<s:Button label="Vendor Identifier" click="iosVendorIdentifier_clickHandler(event)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,15 @@ public class DeviceInfo

return null;
}

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

public function crash():void
{
trace("DeviceInfo is not supported for " + Capabilities.os);
}
}
}
90 changes: 90 additions & 0 deletions deviceinfo-air/deviceinfo/src/com/github/airext/DeviceInfo.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.github.airext.core.device_info;
import com.github.airext.data.DeviceInfoBattery;
import com.github.airext.data.DeviceInfoGeneral;

import flash.desktop.NativeApplication;

import flash.events.StatusEvent;

import flash.external.ExtensionContext;
Expand Down Expand Up @@ -53,13 +55,29 @@ public class DeviceInfo
//
//--------------------------------------------------------------------------

/**
* Indicates if DeviceInfo extension is supported on current platform.
*
* @return <code>true</code> if DeviceInfo is supported or <code>false</code>
* otherwise.
*/
public static function isSupported():Boolean
{
return context != null && context.call("isSupported");
}

//-------------------------------------
// sharedInstance
//-------------------------------------

/** @private */
private static var instance:DeviceInfo;

/**
* Provides acces for shared instance of DeviceInfo object.
*
* @return
*/
public static function sharedInstance():DeviceInfo
{
if (instance == null)
Expand Down Expand Up @@ -101,8 +119,12 @@ public class DeviceInfo
// imei
//-------------------------------------

/** @private */
private var _imei:String;

/**
* Returns IMEI if supporte, or <code>null</code> otherwise.
*/
public function get imei():String
{
if (_imei == null)
Expand All @@ -117,8 +139,13 @@ public class DeviceInfo
// general
//-------------------------------------

/** @private */
private var _general:DeviceInfoGeneral;

/**
* Provides access for DeviceInfoGeneral object that describes device's
* general info.
*/
public function get general():DeviceInfoGeneral
{
if (_general == null)
Expand All @@ -133,8 +160,12 @@ public class DeviceInfo
// battery
//-------------------------------------

/** @private */
private var _battery:DeviceInfoBattery;

/**
* Provides access for DeviceInfoBattery object that describes Battery state.
*/
public function get battery():DeviceInfoBattery
{
if (_battery == null)
Expand All @@ -159,21 +190,80 @@ public class DeviceInfo
//
//--------------------------------------------------------------------------

/**
* Gathers general info and returns it as DeviceInfoGeneral object.
*
* @return Instance of DeviceInfoGeneral class.
*/
public function getGeneral():DeviceInfoGeneral
{
return context.call("getGeneralInfo") as DeviceInfoGeneral;
}

/**
* Gathers Battery's info and returns it as DeviceInfoBattery object.
*
* @return Instance of DeviceInfoBattery class.
*/
public function getBattery():DeviceInfoBattery
{
return new DeviceInfoBattery();
}

/**
* Returns IMEI if supported.
*
* @return actual IMEI on Android, or <code>null</code> on iOS
*/
public function getIMEI():String
{
return context.call("getIMEI") as String;
}

/**
* Logs specified message through NSLog on iOS and Log.w on Android. Could
* take one or two params:
*
* <code>DeviceInfo.sharedInstance().log("Logging message");</code>
* or
* <code>DeviceInfo.sharedInstance().log("TAG", "Logging message");</code>
* if TAG is not specified the Application's id will used. TAG is always
* ignored on iOS.
*
* @param args TAG and/or logging message.
*/
public function log(...args):void
{
var params:Array = ["log"];

switch (args.length)
{
case 0 :
params.concat(NativeApplication.nativeApplication.applicationID);
params.concat("");
break;

case 1 :
params = params.concat(NativeApplication.nativeApplication.applicationID);
params = params.concat(args);
break;

default :
params = params.concat(args);
break;
}

context.call.apply(null, params);
}

/**
* Simulates out-of-range run time error.
*/
public function crash():void
{
context.call("crash");
}

//--------------------------------------------------------------------------
//
// Handlers
Expand Down
2 changes: 1 addition & 1 deletion deviceinfo-android/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions deviceinfo-android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 047425f

Please sign in to comment.