Skip to content

Commit 90abde4

Browse files
authored
Merge pull request #1 from itbeyond/master
Correct Android Screen Size (resizeOnFullScreen true - not in full sc…
2 parents 0408e72 + 4d23674 commit 90abde4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/android/CDVIonicKeyboard.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import android.view.View;
1616
import android.view.ViewTreeObserver;
1717
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
18+
import android.view.Window;
1819
import android.view.inputmethod.InputMethodManager;
1920

2021
// import additionally required classes for calculating screen height
@@ -125,13 +126,7 @@ else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelH
125126
private void possiblyResizeChildOfContent() {
126127
int usableHeightNow = computeUsableHeight();
127128
if (usableHeightNow != usableHeightPrevious) {
128-
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
129-
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
130-
if (heightDifference > (usableHeightSansKeyboard/4)) {
131-
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
132-
} else {
133-
frameLayoutParams.height = usableHeightSansKeyboard;
134-
}
129+
frameLayoutParams.height = usableHeightNow;
135130
mChildOfContent.requestLayout();
136131
usableHeightPrevious = usableHeightNow;
137132
}
@@ -140,7 +135,14 @@ private void possiblyResizeChildOfContent() {
140135
private int computeUsableHeight() {
141136
Rect r = new Rect();
142137
mChildOfContent.getWindowVisibleDisplayFrame(r);
143-
return (r.bottom - r.top);
138+
return isFullScreen() ? r.bottom - r.top : r.height();
139+
}
140+
141+
private boolean isFullScreen() {
142+
final Window window = cordova.getActivity().getWindow();
143+
// Flag set by status bar plugin to make content full screen
144+
int fullScreenFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
145+
return (window.getDecorView().getSystemUiVisibility() & fullScreenFlag) == fullScreenFlag;
144146
}
145147
};
146148

0 commit comments

Comments
 (0)