GithubHelp home page GithubHelp logo

vietpv / air-android-utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marpies/air-android-utils

0.0 2.0 0.0 99 KB

Utility extension for Adobe AIR

License: Apache License 2.0

ActionScript 48.03% Java 51.97%

air-android-utils's Introduction

AIRAndroidUtils | Utility extension for Adobe AIR

Simple native extension offering several utility methods for Android platform:

  • Getting full screen width & height of the device
  • Getting DisplayMetrics
  • Getting system version
  • Setting UI visibility flags
  • Setting brightness
  • Setting status bar color

Getting started

Just copy the extension from the bin directory over to your project and modify your app descriptor XML with the extension's ID:

<extensions>
    <extensionID>com.marpies.ane.androidutils</extensionID>
</extensions>

Code snippets

Logs

// If desired, enable logging before calling any API
AIRAndroidUtils.logEnabled = true;

Full screen width & height

trace( AIRAndroidUtils.screenWidth );
trace( AIRAndroidUtils.screenHeight );
const dm:AIRAndroidUtilsDisplayMetrics = AIRAndroidUtils.displayMetrics;
trace( dm.density );
trace( dm.densityDpi );
trace( dm.widthPixels );
trace( dm.heightPixels );
trace( dm.xdpi );
trace( dm.ydpi );

System version

if( AIRAndroidUtils.systemVersion >= AIRAndroidUtilsVersionCodes.KITKAT ) {
    // Use KITKAT's API
}

UI visibility flags

// Immersive full screen
if( AIRAndroidUtils.isImmersiveFullScreenSupported ) {
    AIRAndroidUtils.setUIVisibility(
        AIRAndroidUtilsUIFlags.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // Hides software buttons
        AIRAndroidUtilsUIFlags.SYSTEM_UI_FLAG_FULLSCREEN | // Hides status bar
        AIRAndroidUtilsUIFlags.SYSTEM_UI_FLAG_IMMERSIVE_STICKY // Enters immersive full screen
    );
}

// Temporarily hide the software buttons (appear on touch)
AIRAndroidUtils.setUIVisibility( AIRAndroidUtilsUIFlags.SYSTEM_UI_FLAG_HIDE_NAVIGATION );

See the class AIRAndroidUtilsUIFlags.as for available UI flags.

Brightness

// Use values from 0.0 to 1.0
AIRAndroidUtils.setBrightness( Math.random() );

// Use user's preferences
AIRAndroidUtils.setBrightness( -1 );

Status bar color

if( AIRAndroidUtils.isStatusBarColorSupported ) {
    // Color in the format #RRGGBB or #AARRGGBB, or one of the following values: red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray, darkgray.
    AIRAndroidUtils.setStatusBarColor( "#FF0000" );
}

Build ANE

ANT build scripts are available in the build directory. Edit build.properties to correspond with your local setup.

Author

The ANE has been written by Marcel Piestansky and is distributed under Apache License, version 2.0.

Changelog

November 2, 2015 (v1.0.0)

  • Public release

air-android-utils's People

Contributors

marpies avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.