Android: Fix QInputMethod's visible property
There are many cases in which finishComposingText is called and it does not mean the keyboard will be hidden. Add a check that there are space reserved for the keyboard before closing it. This is not helping with floating keyboards, but it's already better. [ChangeLog] Made QInputMethod's visible more accurate Task-number: QTBUG-42444 Change-Id: I4d706f1ea5ba2f0f6d3ec1921139317bc4f8dafb Reviewed-by: BogDan Vatra <bogdan@kdab.com>bb10
parent
270aa5b58d
commit
7908da98f0
|
|
@ -40,6 +40,9 @@ import android.view.inputmethod.CompletionInfo;
|
|||
import android.view.inputmethod.ExtractedText;
|
||||
import android.view.inputmethod.ExtractedTextRequest;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.graphics.Rect;
|
||||
import android.app.Activity;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
class QtExtractedText
|
||||
{
|
||||
|
|
@ -80,7 +83,15 @@ class HideKeyboardRunnable implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
QtNative.activityDelegate().setKeyboardVisibility(false, m_hideTimeStamp);
|
||||
// Check that the keyboard is really no longer there.
|
||||
Activity activity = QtNative.activity();
|
||||
Rect r = new Rect();
|
||||
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
final int kbHeight = metrics.heightPixels - r.bottom;
|
||||
if (kbHeight < 100)
|
||||
QtNative.activityDelegate().setKeyboardVisibility(false, m_hideTimeStamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue