@neilrackett neilrackett released this Jan 17, 2017 · 1 commit to master since this release

Assets 3

Release notes

This release adds a new setSystemUiVisibility method which can be used in the same way as Android's native method of the same name to request that the visibility of the status bar or other screen/window decorations be changed.

This ANE is released under BSD license and requires Adobe AIR 24+.

How does it work?

This ANE enables developers to offer users a true full screen experience in the Adobe AIR apps for Android.

Using Android 4.0+, you can use true full screen in "lean mode", the way you see in apps like YouTube, expanding the app right to the edges of the screen, hiding the status and navigation bars until the user next interacts. This is ideally suited to video or cut-scene content.

In Android 4.4+, however, you can now enter true full screen, fully interactive immersive mode. In this mode, your app will remain in true full screen until you choose otherwise; users can swipe down from the top of the screen to temporarily display the system UI.

If you need to fix it, fork it!

This is a free, open-source project, so if you find the ANE doesn't work as you might like with a specific device, configuration or library you're using: fork it, fix it, let us know.

Before you start

To avoid cropping, always ensure that you're using <fullScreen>false</fullScreen> in your app.xml and stage.displayState is set to StageDisplayState.NORMAL when using any of the full screen modes invoked by this ANE.

The examples below show how to achieve the best possible full screen experience.

Code example

Using the ANE in your app couldn't be easier:

import com.mesmotronic.ane.AndroidFullScreen;

// Methods

AndroidFullScreen.stage = stage; // Set this to your app's stage
AndroidFullScreen.isSupported; // Is this ANE supported?
AndroidFullScreen.isImmersiveModeSupported; // Is immersive mode supported?
AndroidFullScreen.immersiveWidth; // The width of the screen in immersive mode
AndroidFullScreen.immersiveHeight; // The height of the screen in immersive mode
AndroidFullScreen.fullScreenWidth; // The width of the screen in the best available full screen mode
AndroidFullScreen.fullScreenHeight; // The height of the screen in the best available full screen mode

AndroidFullScreen.fullScreen(); // Switch your app to the best available full screen mode
AndroidFullScreen.showSystemUI(); // Show system UI
AndroidFullScreen.leanMode(); // Hide system UI until user interacts
AndroidFullScreen.showUnderSystemUI(); // Extend your app underneath the system UI (Android 4.4+ only)
AndroidFullScreen.immersiveMode(); // Hide system UI and keep it hidden (Android 4.4+ only)
AndroidFullScreen.immersiveMode(false); // Hide system UI until user swipes from top (Android 4.4+ only)

// Example custom full screen mode

AndroidFullScreen.setSystemUiVisibility(AndroidFullScreen.SYSTEM_UI_FLAG_FULLSCREEN | AndroidFullScreen.SYSTEM_UI_FLAG_LOW_PROFILE);

// Events (will only work if ANE is supported)

NativeApplication.nativeApplication.addEventListener(AndroidFullScreen.ANDROID_WINDOW_FOCUS_IN, focusHandler);
NativeApplication.nativeApplication.addEventListene(AndroidFullScreen.ANDROID_WINDOW_FOCUS_OUT, focusHandler);

function focusHandler(event:Event):void
{
    trace(event.type);
} 

All methods return Boolean values: true if the action was successful, false if it wasn't (or isn't supported); if you're using the ANE in an app for a platform other than Android, all properties and methods will return false.

The immersiveWidth and immersiveHeight properties return the screen width and height available in immersive mode (or with the system UI hidden), or 0 if the ANE isn't supported.

Therefore, the simplest way to give users the best possible interactive full screen experience in your app is to start your app with <fullScreen>false</fullScreen> in your app.xml and use:

AndroidFullScreen.stage = stage;
AndroidFullScreen.fullScreen();

An easy way to extend your app underneath the status and navigation bars is:

if (!AndroidFullScreen.showUnderSystemUI())
{
    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}

And a great way to offer full screen video playback is:

if (!AndroidFullScreen.leanMode())
{
    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}

Getting the immersive screen size

You can use the immersiveWidth and immersiveHeight properties to find out the dimensions of the screen with the system UI hidden, regardless of the current screen state.

To find out the stage size after calling fullScreen(), immersiveMode() or leanMode(), you must wait until the next RESIZE event before the stage.stageWidth and stage.stageHeight properties are updated; the properties of the Capabilities object are not updated and are therefore incorrect.

Starling

To use this ANE with Starling, add Starling.handleLostContext = true; at the start of your ActionScript code to prevent Stage3D lost context errors breaking your app when switching between the normal app state and true full screen.

Examples

Examples are in the example-* folders of the source download for this release.

To use the examples, you will need to copy the ANE into the appropriate folder, extensions in most cases, before building.

@neilrackett neilrackett released this Jan 17, 2016 · 8 commits to master since this release

Assets 3

Release notes

This release improves performance in Android 6 Marshmallow and resolves issues #27, which caused problems when testing apps in the AIR simulator.

This ANE is released under BSD license and requires Adobe AIR 19+.

Workaround for issue #24 (black bar on Android 6.0)

A bug in Android 6.0 means some users are seeing a black bar at the bottom of their screen when using this ANE. This issue is resolved in Android 6.0.1, but if you haven't received the upgrade yet, you can fix it by changing the stage orientation twice, for example:

AndroidFullScreen.stage = stage;
AndroidFullScreen.fullScreen();
stage.setOrientation(StageOrientation.UPSIDE_DOWN);
stage.setOrientation(StageOrientation.UPSIDE_DOWN);

(Thanks to @m72 for the workaround)

Code example

Using the ANE in your app couldn't be easier:

import com.mesmotronic.ane.AndroidFullScreen;

// Methods

AndroidFullScreen.stage = stage; // Set this to your app's stage
AndroidFullScreen.isSupported; // Is this ANE supported?
AndroidFullScreen.isImmersiveModeSupported; // Is immersive mode supported?
AndroidFullScreen.immersiveWidth; // The width of the screen in immersive mode
AndroidFullScreen.immersiveHeight; // The height of the screen in immersive mode
AndroidFullScreen.fullScreenWidth; // The width of the screen in the best available full screen mode
AndroidFullScreen.fullScreenHeight; // The height of the screen in the best available full screen mode

AndroidFullScreen.fullScreen(); // Switch your app to the best available full screen mode
AndroidFullScreen.showSystemUI(); // Show system UI
AndroidFullScreen.leanMode(); // Hide system UI until user interacts
AndroidFullScreen.showUnderSystemUI(); // Extend your app underneath the system UI (Android 4.4+ only)
AndroidFullScreen.immersiveMode(); // Hide system UI and keep it hidden (Android 4.4+ only)
AndroidFullScreen.immersiveMode(false); // Hide system UI until user swipes from top (Android 4.4+ only)

// Events (will only work if ANE is supported)

NativeApplication.nativeApplication.addEventListener(AndroidFullScreen.ANDROID_WINDOW_FOCUS_IN, focusHandler);
NativeApplication.nativeApplication.addEventListene(AndroidFullScreen.ANDROID_WINDOW_FOCUS_OUT, focusHandler);

function focusHandler(event:Event):void
{
    trace(event.type);
} 

All methods return Boolean values: true if the action was successful, false if it wasn't (or isn't supported); if you're using the ANE in an app for a platform other than Android, all methods will return false.

Feb 22, 2016
Updated SWC to fail gracefully and return false instead of throwing e…
…rrors when stage is not set.

@neilrackett neilrackett released this May 23, 2015 · 24 commits to master since this release

Assets 5

Release notes

Version 1.3 handles the change in window focus that occurs when Android displays system dialogues over your AIR app to ensure that immersive mode is maintained even after the dialogue is closed.

This release resolves issue #16, an immersive mode switching issue on Samsung Galaxy S3 Neo.

This ANE is released under BSD license and requires Adobe AIR 17+.

Using the ANE

Add the ANE to your library in the usual way and you're ready to go.

import com.mesmotronic.ane.AndroidFullScreen;

// Methods

AndroidFullScreen.isSupported; // Is this ANE supported?
AndroidFullScreen.isImmersiveModeSupported; // Is immersive mode supported?
AndroidFullScreen.immersiveWidth; // The width of the screen in immersive mode
AndroidFullScreen.immersiveHeight; // The height of the screen in immersive mode

AndroidFullScreen.showSystemUI(); // Show system UI
AndroidFullScreen.leanMode(); // Hide system UI until user interacts
AndroidFullScreen.showUnderSystemUI(); // Extend app underneath system UI (Android 4.4+)
AndroidFullScreen.immersiveMode(); // Hide system UI and keep it hidden (4.4+)
AndroidFullScreen.immersiveMode(false); // Hide system UI until user swipes from top (4.4+)

// Events

NativeApplication.nativeApplication.addEventListener(AndroidFullScreen.ANDROID_WINDOW_FOCUS_IN, focusHandler);
NativeApplication.nativeApplication.addEventListener(AndroidFullScreen.ANDROID_WINDOW_FOCUS_OUT, focusHandler);

function focusHandler(event:Event):void
{
    trace(event.type);
}

All methods return Boolean values: true if the action was successful, false if it wasn't (or isn't supported); if you're using the ANE in an app for a platform other than Android, all properties and methods will return false.

Examples

The examples.zip download contains basic AS3 and Flex examples for Flash Builder, an AS3 example for FlashDevelop and an FLA example created in Flash CC.

To use the examples, you will need to copy the ANE into the appropriate folder, extensions in most cases, before building.