Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/android/CDVIonicKeyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;

// import additionally required classes for calculating screen height
Expand Down Expand Up @@ -125,13 +126,7 @@ else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelH
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard/4)) {
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
} else {
frameLayoutParams.height = usableHeightSansKeyboard;
}
frameLayoutParams.height = usableHeightNow;
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
Expand All @@ -140,7 +135,28 @@ private void possiblyResizeChildOfContent() {
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom - r.top);

/*
Child content getWindowVisibleDisplayFrame return the area which the user can view the content.
The top position is below the status bar. The bottom position is above the navigation bar, keyboard
and other UI element from the bottom.

If app is in full screen mode, then the actual usable height is the distance from the top of the
screen to the bottom of the Rect.

SO:
If app is in full screen, return the bottom position of the rect.

If app is not in full screen, then should use the height of the visible area
*/
return isFullScreen() ? r.bottom : r.height();
}

private boolean isFullScreen() {
final Window window = cordova.getActivity().getWindow();
// Flag set by status bar plugin to make content full screen
int fullScreenFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
return (window.getDecorView().getSystemUiVisibility() & fullScreenFlag) == fullScreenFlag;
}
};

Expand Down