/** * Hides the the keyboard if it was opened for the ContentView. * * @param postHideTask A task to run after the keyboard is done hiding and the view's layout has * been updated. If the keyboard was not shown, the task will run immediately. */ public void hideKeyboard(Runnable postHideTask) { // When this is called we actually want to hide the keyboard whatever owns it. // This includes hiding the keyboard, and dropping focus from the URL bar. // See http://crbug/236424 // TODO(aberent) Find a better place to put this, possibly as part of a wider // redesign of focus control. if (mUrlBar != null) mUrlBar.clearFocus(); boolean wasVisible = false; if (hasFocus()) { wasVisible = UiUtils.hideKeyboard(this); } if (wasVisible) { mPostHideKeyboardTask = postHideTask; } else { postHideTask.run(); } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); mIsKeyboardShowing = UiUtils.isKeyboardShowing(getContext(), this); }