Browse Source

Android: ensure “hide native keyboard message” is sent only after the keyboard was actually shown.

tags/2021-05-28
Lukasz Kozakiewicz 7 years ago
parent
commit
0b030331f1
1 changed files with 24 additions and 6 deletions
  1. +24
    -6
      modules/juce_core/native/java/JuceAppActivity.java

+ 24
- 6
modules/juce_core/native/java/JuceAppActivity.java View File

@@ -808,20 +808,38 @@ public class JuceAppActivity extends $$JuceAppActivityBaseClass$$
}
private class TreeObserver implements ViewTreeObserver.OnGlobalLayoutListener
{
{
TreeObserver()
{
keyboardShown = false;
}
@Override
public void onGlobalLayout()
{
Rect r = new Rect();

ViewGroup parentView = (ViewGroup) getParent();

if (parentView == null)
return;
view.getWindowVisibleDisplayFrame(r);
parentView.getWindowVisibleDisplayFrame (r);
int diff = view.getHeight() - (r.bottom - r.top);
int diff = parentView.getHeight() - (r.bottom - r.top);
// Arbitrary threshold, surely keyboard would take more than 20 pix.
if (diff < 20)
handleKeyboardHidden (view.host);
};
if (diff < 20 && keyboardShown)
{
keyboardShown = false;
handleKeyboardHidden (view.host);
}

if (! keyboardShown && diff > 20)
keyboardShown = true;
};

private boolean keyboardShown;
};
private ComponentPeerView view;


Loading…
Cancel
Save