Closed kilisio closed 4 years ago
My main reason for asking about fullscreen toggling is because when I enabled immersive mode and an input element came to focus, it would get hidden behind either the keyboard or the status barand also I needed my webview to resize based on my css. So i thought it would be better to control the fullscreen visibility manually, but i found a better hack. I modified the original plugin immersive mode function and commented out the layout flags.
protected boolean immersiveMode()
{
if (!isImmersiveModeSupported())
{
context.error("Not supported");
return false;
}
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
{
try
{
resetWindow();
final int uiOptions =
// View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
// window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
decorView.setSystemUiVisibility(uiOptions);
decorView.setOnFocusChangeListener(new View.OnFocusChangeListener()
{
@Override
public void onFocusChange(View v, boolean hasFocus)
{
if (hasFocus)
{
decorView.setSystemUiVisibility(uiOptions);
}
}
});
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener()
{
@Override
public void onSystemUiVisibilityChange(int visibility)
{
decorView.setSystemUiVisibility(uiOptions);
}
});
context.success();
}
catch (Exception e)
{
context.error(e.getMessage());
}
}
});
return true;
}
then simply added the plugin using my modified fork i.e
cordova plugin add https://github.com/kilisio/cordova-plugin-fullscreen.git#forked_dev
I dont know java, but it was a fun hacking and learning something new... thanks for the great plugin
Great to hear you found a solution!
is it possible to toggle fullscreen on and off?