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
29 changes: 25 additions & 4 deletions src/android/CDVIonicKeyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class CDVIonicKeyboard extends CordovaPlugin {
private View rootView;
private View mChildOfContent;
private int usableHeightPrevious;
private int previosOrientation;
private FrameLayout.LayoutParams frameLayoutParams;

public void initialize(CordovaInterface cordova, CordovaWebView webView) {
Expand All @@ -38,7 +39,6 @@ public boolean execute(String action, JSONArray args, final CallbackContext call
if ("hide".equals(action)) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
//http://stackoverflow.com/a/7696791/1091751
InputMethodManager inputManager = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
View v = cordova.getActivity().getCurrentFocus();

Expand Down Expand Up @@ -124,16 +124,26 @@ else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelH

private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
int orientationNow = computeOrientation();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard/4)) {
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
int height = usableHeightNow;

if (heightDifference < 0) {
height = usableHeightNow;
}
else if (heightDifference > (usableHeightSansKeyboard/4)) {
height = usableHeightSansKeyboard - heightDifference;
} else {
frameLayoutParams.height = usableHeightSansKeyboard;
height = usableHeightSansKeyboard;
}

frameLayoutParams.height = height;

mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
previosOrientation = orientationNow;
}
}

Expand All @@ -142,6 +152,17 @@ private int computeUsableHeight() {
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom - r.top);
}

private int computeOrientation() {
int h = mChildOfContent.getRootView().getHeight();
int w = mChildOfContent.getRootView().getWidth();

if(w < h){
return 0;
}else {
return 1;
}
}
};

mChildOfContent = content.getChildAt(0);
Expand Down