Giter Site home page Giter Site logo

mesmotronic / cordova-plugin-fullscreen Goto Github PK

View Code? Open in Web Editor NEW
167.0 10.0 54.0 62 KB

Plugin for Cordova (PhoneGap) to enable Android's various full screen modes

License: BSD 3-Clause "New" or "Revised" License

JavaScript 12.79% HTML 18.18% Java 69.03%

cordova-plugin-fullscreen's Introduction

Full Screen Plugin for Cordova

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

Released under BSD license; see LICENSE for details.

How does it work?

This plugin enables developers to offer users a true full screen experience in their 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 cordova-plugin-fullscreen

PhoneGap

phonegap local plugin add cordova-plugin-fullscreen

Notes

From version 1.0.2, the plugin ID has changed to cordova-plugin-fullscreen in line with the official Cordova plugin naming coventions following the switch to NPM. We therefore recommend that any previous version be uninstalled before upgrading to this release.

Since the release of [email protected], setting <preference name="Fullscreen" value="true" /> in config.xml will use immersive mode, where available, even without this plugin.

Code example

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

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

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

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

// Is this plugin supported?
AndroidFullScreen.isSupported(successFunction, errorFunction);

// Is immersive mode supported?
AndroidFullScreen.isImmersiveModeSupported(successFunction, 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.leanMode(successFunction, errorFunction);

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

// Extend your app underneath the status bar (Android 4.4+ only)
AndroidFullScreen.showUnderStatusBar(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);

// Custom full screen mode
// See https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)
AndroidFullScreen.setSystemUiVisibility(AndroidFullScreen.SYSTEM_UI_FLAG_FULLSCREEN | AndroidFullScreen.SYSTEM_UI_FLAG_LOW_PROFILE, 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.

Make a donation

If you find this project useful, why not buy us a coffee (or as many as you think it's worth)?

Make a donation

cordova-plugin-fullscreen's People

Contributors

agamemnus avatar cnspaha avatar ivanguardado avatar neilrackett avatar spodjasek avatar ulisesceca avatar virvar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-fullscreen's Issues

A black gap on the screen bottom

Android 6.0.1
Cordova 6.0.0
cordova-plugin-fullscreen 1.1.0

Sometimes (about 50% reproduce attempts) I got black gap on bottom of the screen (please see screenshot)

twii1

Show System UI doenst work when in Lean Mode

Hey there,

When in lean mode (leanMode function), if i try to Show the UI using the showSystemUI function, it behaves in the same way.

If i set it to immersive and after that try to use showSystemUI it works.

How can i fix this?

Thank you!

AndroidFullScreen.leanMode is not defined

// Hide system UI until user interacts
AndroidFullScreen.leanMode(successFunction, errorFunction);
throws error
VM126:3 Uncaught TypeError: AndroidFullScreen.leanMode is not a function
    at <anonymous>:3:19
    at Object.InjectedScript._evaluateOn (<anonymous>:895:140)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
    at Object.InjectedScript.evaluate (<anonymous>:694:21)

immersiveHeight() returns "OK" and nothing more

I'm trying to get the display cutout for the notch devices. So I went to your plugin to see how you return values from Java (I'm new to cordova) and just wanted to test if immersiveHeight returned like it should, I follow your example in your Readme, but it only returns OK, it doesn't give me the height of the screen.

I'm using andriod studio emulator, API 28, Pixel XL.

Your ImmersiveMode() works really great, I just add a few things to the config.xml and the immersive worked on android devices with notch

Ionic 4 - not working

Hello,
I have no luck to run this plugin with Ionic 4.

I added AndroidFullScreen into app.module.ts imports. Nothing more. And I get this error:

compiler.js:2175 Uncaught Error: Unexpected value 'AndroidFullScreen' imported by the module 'AppModule'. Please add a @NgModule annotation. at syntaxError (compiler.js:2175) at compiler.js:19833 at Array.forEach (<anonymous>) at CompileMetadataResolver.getNgModuleMetadata (compiler.js:19808) at JitCompiler._loadModules (compiler.js:25582) at JitCompiler._compileModuleAndComponents (compiler.js:25565) at JitCompiler.compileModuleAsync (compiler.js:25527) at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:216) at compileNgModuleFactory__PRE_R3__ (core.js:34647) at PlatformRef.bootstrapModule (core.js:34956)

The error is the same for a WebBrowser and for a native build.

Is anyone using this plugin with Ionic 4?

Borderless/notch devices doesn't display a fully fullscreen mode

Hello, thanks for this plugin.
I'm not sure where I should open this issue so I first try here. (Should I ask this question on Cordova Github or Cordova Android Github?)

Infos:

  • Cordova 9.0.1
  • Android 8.1.0
  • Fullscreen plugin 1.2.0

Problem:
The fullscreen mode doesn't works on new very wide and borderless devices such as Samsung Galaxy s10, Google Pixel 3XL or OnePlus 6T. As you can see on the attached file, the app is disturbed/displaced from the top which is displaying a black area.

android-bordeless-fullscreen-ultrawide

What should be expected:
The app webview should be displayed correctly, 100% fullscreen, without that black area.

Temporary fix:
I found some help on StackOverflow about how to fix this issue. It's a bit tricky. But this solution isn't clean enough, it solves the fullscreen problem but causes other problems such as (see attached file):

  • the Status Bar can't be hiding during app launch.
  • the Splaschreen can't appears fullscreen (there is still an empty area on left side whatever the width size you give to your image).

android-theme-full

Anyone with same problem? Any advises to give about how to use 100% fullscreen on borderless devices? Thanks!

disable leanMode

is there a way to disable leanMode?
what im trying to do is when a user full screen the video it will enable the leanmode then if not full screen disable leanmode

thanks!

android:windowSoftInputMode is ignored when the fullscreen plugin is enabled

Before installing cordova-plugin-fullscreen plugin, I had this option:

android:windowSoftInputMode="adjustResize"

Which resized the webview window when the user brought the soft keyboard.

However, after installing and enabling the fullscreen plugin, the soft keyboard doesn't push (resize) the webview. Instead, it appears over the webview, hidding webcontent, and the input elements that have been focused most of the time.

Is it intended? Is there a workaround?

Interoperability with cordova-plugin-inappbrowser

Hi,

I am cross-linking the issue I submitted in cordova-plugin-inappbrowser

Is it possible to make the in-app-browser show in full-screen without the system status bar?
I enabled immersive mode this.androidFullScreen.immersiveMode() and then launch in-app-browser with fullscreen: yes but the system status bar becomes visible as soon as in-app-browser is open
It looks like the immersive mode applies only to the main window, and in-app-browser launches in the new modal/screen and this mode does not propagate

cordova-plugin-inappbrowser: issue #380

Android 4.4.4 - should I use latest plugin version?

Hi,

I remember from the readme.md file there was a line like this:
IMPORTANT: If you are targeting API <= 22 you should continue using version 1.0.2.

Since it was removed, does this mean it is "safe" to use latest version for overall development which targets both API<22 and API >= 22 ?

Error loading cordova-browser

When I run cordova plugin add cordova-plugin-fullscreen I get the following output:

Fetching plugin "cordova-plugin-fullscreen" via npm
Installing "cordova-plugin-fullscreen" for android
ANDROID_HOME=d:\sdk\android
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
:clean
:CordovaLib:clean

BUILD SUCCESSFUL

Total time: 1.427 secs
Installing "cordova-plugin-fullscreen" for browser
Error loading cordova-browser

Should I be worried about this?

Problems with Android 8 & 9.0?

Actually I have an app with ionic and fullscreen-plugin.
My android version is 7.0 Moto G5 and it works fine.
In other devices with Android 8.0 and 9.0 the plugin isn't work properly.

Other problem I'm having too is about minimize the app and reopen it again.
In this momment the leanMode isnt't working because the bars don't hide anymore.

Is there any bug with these versions? Thanks by the way.

Not possible to reset the SystemUI after showUnderSystemUI or immersiveMode

After calling showUnderSystemUI() there's no way to reset that behavior (stop being under SystemUI).

Partial workaround is to call setSystemUiVisibility(AndroidSystemUiFlags.Visible) that brings back the navbar, but the upper part of the screen remains under the statusbar.

The same issue is also applicable to the immersiveMode().

Any workaround on this

Remove at the bottom

Hello!

It's been almost a week, I can't figure out how to remove the full-screen mode at the bottom of the device Honor 8x (most likely somewhere else there is this problem, maybe Samsung... some models) - here is such a band is saved in any mode, it is not possible to remove it in any way...

It suggests that I switch to full-screen display, I assumed that the problem is the difference between the screens and the application, but when trying to install all attempts are exhausted... what can I do? the plugin also doesn't help

Android 10
EMUI 10.0.0

alt text

Documentation lack?

Hey, just implemented this plugin. But, i saw that this function
// Is this plugin supported?
AndroidFullScreen.isSupported(supportedFunction, errorFunction);

For success callback has supportedFunction

Shouldn't this be successFunction ?

Nice plugin!

Regards

BSF Cordova Ecosystem Crowdfunding Plan

Hello everyone,

I'm Jason.z, the founder of BSF.

We've noticed that this project has remained very popular in the past.

However, unfortunately, it seems that this project has not been maintained for some time,

which is unfortunate for users who want to continue using and supporting the project.

Based on this, BSF has initiated the Cordova Ecosystem Crowdfunding Plan ,

with the main purpose of addressing the upgrading and maintenance of old Cordova projects,

as well as compatibility and adaptability for new platforms.

You can learn more about it by clicking on this link.

So, if you feel that this project needs continued upgrading and maintenance,

please let us know through voting.

We will decide whether to launch a crowdfunding plan for this project based on the voting results and the recruitment of maintainers,

as well as the subsequent development and maintenance plans.

If you are willing to be a long-term maintainer of the project, you can also contact us.

Of course, if you do not agree with the operating model of BSF Software Foundation,

or if you are a maintenance team for this project and believe that this ISSUE infringes and damages your rights,

you can also delete this ISSUE.

We sincerely apologize for any inconvenience this may cause.

BSF is our bold attempt and exploration of the sustainable development of software projects.

We hope to contribute to the development of software projects through the power of the community!

Property 'immersiveMode' does not exist on type 'typeof AndroidFullScreen'

Hello,

When I tried to enable immersivemode() i get this : -

[ng] ✖ Failed to compile.
[ng] 
[ng] Error: src/app/home/home.page.ts:19:23 - error TS2339: Property 'immersiveMode' does not exist on type 'typeof AndroidFullScreen'.
[ng] 
[ng] 19     AndroidFullScreen.immersiveMode();

What am I doing wrong here!

Fullscreen disabled when softkeyboard shows

I don't know if this is a cordova-plugin-fullscreen related bug, but when using fullscreen preference mode to true, it works perfectly until you focus on an input. Then, the softkeyboard shows up and the fullscreen/inmersive mode disables itself. After that, you could hide the keyboard and expect the fullscreen mode to enable again, but it gets disabled until you swipe the app with another one or close and reopen the app.

I dont know if this is related to the cordova-plugin-crosswalk-webview i'm currently using or not, I'll post the same issue there.

Thank you for your work.

what about IOS ??

this plugin works well for android .. do we have any option for IOS as well ???

override abstract method onWindowStartingActionMode

Hi, I get the following error with this recent release: http://cordova.apache.org/announcements/2015/11/09/cordova-android-5.0.0.html

platforms/android/src/com/mesmotronic/plugins/FullScreenPlugin.java:360: error: <anonymous com.mesmotronic.plugins.FullScreenPlugin$6$3> is not abstract and does not override abstract method onWindowStartingActionMode(android.view.ActionMode.Callback,int) in android.view.Window.Callback

Maybe to do with the bump to API level 23?

plugin in not working

Hi
I installed plugin using cordova plugin add https://github.com/mesmotronic/cordova-fullscreen-plugin.git
and it was installed successfully I can see the plugin in the plugin dir

I copied the example file and ran the example using phonegap developer app on htc m8
but nothing happens, it more annoying because phonegap doesn't throw any error or success log

can somebody help me to verify that plugin is installed correctly and what am i missing for it not to work.

other plugins works fine except this one

Thank you

Status bar hidden

I'm updating an old Ionic 5, cordova app to ionic 7.4.x/cordova 12.x. Both have the [email protected] dependency but I have found a difference in the behaviour of the plugin. In the old version of the app, the navigation bar was hidden but the status bar was visible in any moment (except during the splash screen).

If I uninstall the plugin, both the status bar and the navigation bar are visible. Once the plugin is installed the bars remain hidden and the webview uses all the screen. Would it be possible to change this behaviour somehow? Am I missing something?

Thanks in advance.

How to use this plugin in phonegap-build?

Hi fellas, i really need this plugin for buid.phonegap which allows me only to do stuff in the config.xml.
Is it possible to use this plugin there?
If yes, than how?

isSupported function needs callbacks

The readme documentation had seemed to indicate that isSupported() would return a boolean but I could only make it work with success and failure callbacks i.e. isSupported(success, failure) - this was tested to work with IntelXDK in Debug mode on Android 5.0 - maybe the intel xdk version of the plugin is different?

showUnderStatusBar (translucent) is not affected until input is focused (keyboard forces to resize the window)

showUnderStatusBar should call window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
which makes the status bar translucent and goes above navbar.

Unfortunately, it does not take effect until I focus some input on android device. After this my window resizes and navbar moves up, behind the status bar, status bar becomes translucent.

I thought it could be that after setting the flags we need to refresh the view, and tried to make decorView.invalidate() in order to force android to redraw everything, but it seems not working.

Does anyone knows what to do?

https://github.com/lain-me/cordova-plugin-fullscreen/commit/92cb320cb4f751b88105531adaae7b521066192f
https://github.com/lain-me/cordova-plugin-fullscreen/commit/f136f201b3f37cf4c8f506becedb2c2b6968eb7d

BackButton

Hi there,

thnaks for your excellent Plugin. I just noticed, that the "Backbutton" is not working anymore, once the App is in Immersive Mode. I know, that it once worked without any Issues, but since a while, it seems to stop working.
Are you aware of that and/or have a solution for this?
(android 6.0.1 on a nexus 6p with latest Cordova (5.4.1))

Thanks a lot!

Uncaught ReferenceError: AndroidFullScreen is not defined

I get this ReferenceError:
Uncaught ReferenceError: AndroidFullScreen is not defined

Here is my code:

<body>
    <h1>This is a local web app</h1>
    <p id="dimention"></p>
</body>
<script src="cordova.js"></script>
<script>
    const dimentions = `${window.innerWidth}x${window.innerHeight}`;
    document.getElementById('dimention').innerText = dimentions;

    AndroidFullScreen.setSystemUiVisibility(AndroidFullScreen.SYSTEM_UI_FLAG_FULLSCREEN | AndroidFullScreen.SYSTEM_UI_FLAG_LOW_PROFILE, () => console.log('Full Screen'), () => console.log('Error Full Screen'));
</script>

I use Cordova 12.0.0 ([email protected]) on Windows 11.
plugin version: cordova-plugin-fullscreen 1.3.0

On Android 4.4.4 got plugin_not_installed

cordova plugin ls
cordova-plugin-fullscreen 1.1.0 "cordova-plugin-fullscreen"


10:46:35] console.log: plugin_not_installed
[10:46:36] console.warn: Native: tried calling AndroidFullScreen.leanMode, but the AndroidFullScreen plugin is not
installed.
[10:46:36] console.warn: Install the AndroidFullScreen plugin: 'ionic cordova plugin add cordova-plugin-fullscreen'

Nav bar on splash screen

Meizu m1 note phone on Android 4.4.4 (phonу with touch-home-button only)
cordova 5.4.1 / android platform 4.1.1
use [email protected]
I have nav-bar on splashscreen at start and web-content deformation after hide splashscreen.
No effect from plugin(

Ugly Errors when building with v1.0.3 and Android 22

This might be helpful if someone else grabs the latest plugin version and gets the errors below.

Version 1.0.2 works fine with Android, but as documented, 1.0.3 targets Android 23.

Fix is either to specify 1.0.2, or use the correct Android SDK (23).

Errors when building with incorrect Android SDK version:

FullScreenPlugin.java:17: error: cannot find symbol
import android.view.SearchEvent;

FullScreenPlugin.java:392: error: cannot find symbol
public boolean onSearchRequested(SearchEvent event)

FullScreenPlugin.java:362: error: method does not override or implement a method from a supertype

FullScreenPlugin.java:365: error: method onWindowStartingActionMode in interface android.view.Window.Callback cannot be applied to given types;

Safe area

How to calculate safe area with this plugin? Do i need to use another plugin to do it?

karma: AndroidFullScreen is not defined

The AndroidFullScreen works fine, but if I run it my testspecs in karma, the web component can't be created because ReferenceError: AndroidFullSCreen is not defined

Need a new release (1.0.1)

I usually set my dependency with version tag.
Could you please make a new release please.
And perhaps put it on NPM too.

Thanks

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.