ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
529 stars 594 forks source link

@capacitor/keyboard does not recognize Full-Screen app #2183

Open flgubler-ergon opened 2 months ago

flgubler-ergon commented 2 months ago

Bug Report

Plugin(s)

@capacitor/keyboard

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 6.1.2
  @capacitor/core: 6.1.2
  @capacitor/android: 6.1.2
  @capacitor/ios: 6.1.2

Installed Dependencies:

  @capacitor/cli: 6.1.0
  @capacitor/android: 6.1.0
  @capacitor/core: 6.1.0
  @capacitor/ios: 6.1.0

Platform(s)

Android

Current Behavior

As you surely know, the flag View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN has been deprecated by Android for some time now. For that reason, I am using the newer WindowCompat.setDecorFitsSystemWindows(window, false) to configure my app as a full-screen app (i.e. to make sure that the web-view covers the entire screen).

However, the Keyboard class contains the following method

private boolean isOverlays() {
  final Window window = activity.getWindow();
  return ((window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
  );
}

As a result, this logic does not recognize that my app is a full-screen app and the method computeUsableHeight() returns the wrong value. As a consequence, the web-view's height is reduced more than it needs to be, leaving some empty space between the keyboard and the web-view.

Expected Behavior

The new way of configuring a full-screen app, namely WindowCompat.setDecorFitsSystemWindows(window, false) which is officially recommended by Google (see Google Developer Documentation) should also be recognized as full-screen. => the height of the keyboard should be computed correctly. This can easilby be done using window.decorFitsSystemWindows() which returns a boolean: if the boolean is false, it is a full-screen app. Update: unfortunately, that method is hidden in the API. Therefore, the fix may be a bit more complicated.

Ionitron commented 2 months ago

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.

Please see the Contributing Guide for how to create a Sample App.

Thanks! Ionitron 💙

flgubler-ergon commented 2 months ago

Here you go https://github.com/flgubler-ergon/capacitor-bug-full-screen-detection

If you open the app on Android and click into the input-field, you will notice a light-grey bar between the keyboard and the web-view (I set a blue back-ground-color in the webview to make this more obvious).

Aso you will be able to see, the app is in full-screen mode (some text is behind the status-bar). However, they keyboard-plugin does not recognize this - due to the problem described above.

As the bug only appears in Android, I only created an android app (no iOS)