/cordova-fullscreen-plugin

Plugin for Cordova (or PhoneGap) to enable true full screen on Android

Primary LanguageJavaBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Full Screen Plugin for Cordova

Plugin for Cordova (or PhoneGap) 3.0+ to enable true full screen on Android, ported from our popular ANE for Adobe AIR.

How does it work?

This plugin enables developers to offer users a true full screen experience in the Cordova and PhoneGap 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 find that the plugin doesn't work as you might like on a specific device or Android configuration you're using, don't forget that this project is open source, so feel free to fork the project and adapt it to work in any way you like!

Installation

Cordova

cordova plugin add https://github.com/mesmotronic/cordova-fullscreen-plugin.git

PhoneGap

phonegap local plugin add https://github.com/mesmotronic/cordova-fullscreen-plugin.git

Configuration

If you are intending to use immersive mode, add <preference name="Fullscreen" value="true" /> to your config.xml to ensure the status bar is hidden correctly.

Code example

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

function successFunction() 
{
	console.log("It worked!");
}

function errorFunction(error)
{
    console.log(error);
}

function trace(value)
{
	console.log(value);
}

// Is fullscreen supported?
AndroidFullScreen.isSupported(trace, errorFunction);

// Is immersive mode supported?
AndroidFullScreen.isImmersiveModeSupported(trace, errorFunction);

// The width of the screen in immersive mode
AndroidFullScreen.immersiveWidth(trace, errorFunction);

// The height of the screen in immersive mode
AndroidFullScreen.immersiveHeight(trace, errorFunction);

// Hide system UI until user interacts
AndroidFullScreen.hideSystemUI(successFunction, errorFunction);

// Show system UI
AndroidFullScreen.showSystemUI(successFunction, errorFunction);

// Extend your app underneath the system UI (Android 4.4+ only)
AndroidFullScreen.showUnderSystemUI(successFunction, errorFunction);

// Hide system UI and keep it hidden (Android 4.4+ only)
AndroidFullScreen.immersiveMode(successFunction, errorFunction);

All methods will call the successFunction callback if the action was successful and the errorFunction if it wasn't (or isn't supported); if you're using the plugin in an app for a platform other than Android, all methods will fail.

The immersiveWidth and immersiveHeight properties return the screen width and height available in immersive mode (or with the system UI hidden), where supported.

Getting the immersive screen size

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

License

This project has been released under BSD license; see LICENSE for details.