mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-28 02:30:05 +00:00
Android: ensure “hide native keyboard message” is sent only after the keyboard was actually shown.
This commit is contained in:
parent
c8b9bc79ba
commit
0b030331f1
1 changed files with 24 additions and 6 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue