Java Code Examples for org.chromium.ui.UiUtils#showKeyboard()

The following examples show how to use org.chromium.ui.UiUtils#showKeyboard() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BookmarkSearchView.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected void onVisibilityChanged(View changedView, int visibility) {
    super.onVisibilityChanged(changedView, visibility);
    // This method might be called very early. Null check on bookmark model here.
    if (mBookmarkModel == null) return;

    if (visibility == View.VISIBLE) {
        mBookmarkModel.addObserver(mModelObserver);
        updateHistoryList();
        mSearchText.requestFocus();
        UiUtils.showKeyboard(mSearchText);
    } else {
        UiUtils.hideKeyboard(mSearchText);
        mBookmarkModel.removeObserver(mModelObserver);
        resetUI();
        clearFocus();
    }
}
 
Example 2
Source File: FindToolbar.java    From delion with Apache License 2.0 6 votes vote down vote up
private void showKeyboard() {
    if (!mFindQuery.hasWindowFocus()) {
        // HACK: showKeyboard() is normally called from activate() which is
        // triggered by an options menu item. Unfortunately, because the
        // options menu is still focused at this point, that means our
        // window doesn't actually have focus when this first gets called,
        // and hence it isn't the target of the Input Method, and in
        // practice that means the soft keyboard never shows up (whatever
        // flags you pass). So as a workaround we postpone asking for the
        // keyboard to be shown until just after the window gets refocused.
        // See onWindowFocusChanged(boolean hasFocus).
        mShowKeyboardOnceWindowIsFocused = true;
        return;
    }
    UiUtils.showKeyboard(mFindQuery);
}
 
Example 3
Source File: BookmarkSearchView.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected void onVisibilityChanged(View changedView, int visibility) {
    super.onVisibilityChanged(changedView, visibility);
    // This method might be called very early. Null check on bookmark model here.
    if (mBookmarkModel == null) return;

    if (visibility == View.VISIBLE) {
        mBookmarkModel.addObserver(mModelObserver);
        updateHistoryList();
        mSearchText.requestFocus();
        UiUtils.showKeyboard(mSearchText);
    } else {
        UiUtils.hideKeyboard(mSearchText);
        mBookmarkModel.removeObserver(mModelObserver);
        resetUI();
        clearFocus();
    }
}
 
Example 4
Source File: FindToolbar.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void showKeyboard() {
    if (!mFindQuery.hasWindowFocus()) {
        // HACK: showKeyboard() is normally called from activate() which is
        // triggered by an options menu item. Unfortunately, because the
        // options menu is still focused at this point, that means our
        // window doesn't actually have focus when this first gets called,
        // and hence it isn't the target of the Input Method, and in
        // practice that means the soft keyboard never shows up (whatever
        // flags you pass). So as a workaround we postpone asking for the
        // keyboard to be shown until just after the window gets refocused.
        // See onWindowFocusChanged(boolean hasFocus).
        mShowKeyboardOnceWindowIsFocused = true;
        return;
    }
    UiUtils.showKeyboard(mFindQuery);
}
 
Example 5
Source File: FindToolbar.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void showKeyboard() {
    if (!mFindQuery.hasWindowFocus()) {
        // HACK: showKeyboard() is normally called from activate() which is
        // triggered by an options menu item. Unfortunately, because the
        // options menu is still focused at this point, that means our
        // window doesn't actually have focus when this first gets called,
        // and hence it isn't the target of the Input Method, and in
        // practice that means the soft keyboard never shows up (whatever
        // flags you pass). So as a workaround we postpone asking for the
        // keyboard to be shown until just after the window gets refocused.
        // See onWindowFocusChanged(boolean hasFocus).
        mShowKeyboardOnceWindowIsFocused = true;
        return;
    }
    UiUtils.showKeyboard(mFindQuery);
}
 
Example 6
Source File: LocationBarTablet.java    From delion with Apache License 2.0 5 votes vote down vote up
private void finishUrlFocusChange(boolean hasFocus) {
    if (hasFocus) {
        if (mSecurityButton.getVisibility() == VISIBLE) mSecurityButton.setVisibility(GONE);
        if (getWindowDelegate().getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) {
            getWindowDelegate().setWindowSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        }
        UiUtils.showKeyboard(mUrlBar);
    } else {
        if (mSecurityButton.getVisibility() == GONE
                && mSecurityButton.getDrawable() != null
                && mSecurityButton.getDrawable().getIntrinsicWidth() > 0
                && mSecurityButton.getDrawable().getIntrinsicHeight() > 0) {
            mSecurityButton.setVisibility(VISIBLE);
        }
        UiUtils.hideKeyboard(mUrlBar);
        Selection.setSelection(mUrlBar.getText(), 0);
        // Convert the keyboard back to resize mode (delay the change for an arbitrary
        // amount of time in hopes the keyboard will be completely hidden before making
        // this change).
        if (getWindowDelegate().getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) {
            postDelayed(mKeyboardResizeModeTask, KEYBOARD_MODE_CHANGE_DELAY_MS);
        }
    }
    setUrlFocusChangeInProgress(false);
}
 
Example 7
Source File: LocationBarTablet.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void finishUrlFocusChange(boolean hasFocus) {
    if (hasFocus) {
        if (mSecurityButton.getVisibility() == VISIBLE) mSecurityButton.setVisibility(GONE);
        if (getWindowDelegate().getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) {
            getWindowDelegate().setWindowSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        }
        UiUtils.showKeyboard(mUrlBar);
    } else {
        if (mSecurityButton.getVisibility() == GONE
                && mSecurityButton.getDrawable() != null
                && mSecurityButton.getDrawable().getIntrinsicWidth() > 0
                && mSecurityButton.getDrawable().getIntrinsicHeight() > 0) {
            mSecurityButton.setVisibility(VISIBLE);
        }
        UiUtils.hideKeyboard(mUrlBar);
        Selection.setSelection(mUrlBar.getText(), 0);
        // Convert the keyboard back to resize mode (delay the change for an arbitrary
        // amount of time in hopes the keyboard will be completely hidden before making
        // this change).
        if (getWindowDelegate().getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) {
            postDelayed(mKeyboardResizeModeTask, KEYBOARD_MODE_CHANGE_DELAY_MS);
        }
    }
    setUrlFocusChangeInProgress(false);
}
 
Example 8
Source File: LocationBarTablet.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void finishUrlFocusChange(boolean hasFocus) {
    if (hasFocus) {
        if (mSecurityButton.getVisibility() == VISIBLE) mSecurityButton.setVisibility(GONE);
        if (getWindowDelegate().getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) {
            getWindowDelegate().setWindowSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        }
        UiUtils.showKeyboard(mUrlBar);
    } else {
        if (mSecurityButton.getVisibility() == GONE
                && mSecurityButton.getDrawable() != null
                && mSecurityButton.getDrawable().getIntrinsicWidth() > 0
                && mSecurityButton.getDrawable().getIntrinsicHeight() > 0) {
            mSecurityButton.setVisibility(VISIBLE);
        }
        UiUtils.hideKeyboard(mUrlBar);
        Selection.setSelection(mUrlBar.getText(), 0);
        // Convert the keyboard back to resize mode (delay the change for an arbitrary
        // amount of time in hopes the keyboard will be completely hidden before making
        // this change).
        if (getWindowDelegate().getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) {
            postDelayed(mKeyboardResizeModeTask, KEYBOARD_MODE_CHANGE_DELAY_MS);
        }
    }
    setUrlFocusChangeInProgress(false);
}
 
Example 9
Source File: SelectableListToolbar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the search edit text box and related views.
 */
public void showSearchView() {
    assert mHasSearchView;

    mIsSearching = true;
    mSelectionDelegate.clearSelection();

    showSearchViewInternal();

    mSearchEditText.requestFocus();
    UiUtils.showKeyboard(mSearchEditText);
    setTitle(null);
}
 
Example 10
Source File: LocationBarLayout.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    UiUtils.showKeyboard(mUrlBar);
}
 
Example 11
Source File: LocationBarPhone.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Handles any actions to be performed after all other actions triggered by the URL focus
 * change.  This will be called after any animations are performed to transition from one
 * focus state to the other.
 * @param hasFocus Whether the URL field has gained focus.
 */
public void finishUrlFocusChange(boolean hasFocus) {
    final WindowDelegate windowDelegate = getWindowDelegate();
    if (!hasFocus) {
        // Remove the selection from the url text.  The ending selection position
        // will determine the scroll position when the url field is restored.  If
        // we do not clear this, it will scroll to the end of the text when you
        // enter/exit the tab stack.
        // We set the selection to 0 instead of removing the selection to avoid a crash that
        // happens if you clear the selection instead.
        //
        // Triggering the bug happens by:
        // 1.) Selecting some portion of the URL (where the two selection handles
        //     appear)
        // 2.) Trigger a text change in the URL bar (i.e. by triggering a new URL load
        //     by a command line intent)
        // 3.) Simultaneously moving one of the selection handles left and right.  This will
        //     occasionally throw an AssertionError on the bounds of the selection.
        Selection.setSelection(mUrlBar.getText(), 0);

        // The animation rendering may not yet be 100% complete and hiding the keyboard makes
        // the animation quite choppy.
        postDelayed(new Runnable() {
            @Override
            public void run() {
                UiUtils.hideKeyboard(mUrlBar);
            }
        }, KEYBOARD_HIDE_DELAY_MS);
        // Convert the keyboard back to resize mode (delay the change for an arbitrary amount
        // of time in hopes the keyboard will be completely hidden before making this change).
        if (mKeyboardResizeModeTask == null
                && windowDelegate.getWindowSoftInputMode()
                        != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) {
            mKeyboardResizeModeTask = new Runnable() {
                @Override
                public void run() {
                    windowDelegate.setWindowSoftInputMode(
                            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
                    mKeyboardResizeModeTask = null;
                }
            };
            postDelayed(mKeyboardResizeModeTask, KEYBOARD_MODE_CHANGE_DELAY_MS);
        }
        if (!hasVisibleViewsAfterUrlBarWhenUnfocused()) {
            mUrlActionsContainer.setVisibility(GONE);
        }
    } else {
        if (mKeyboardResizeModeTask != null) {
            removeCallbacks(mKeyboardResizeModeTask);
            mKeyboardResizeModeTask = null;
        }
        if (windowDelegate.getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) {
            windowDelegate.setWindowSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        }
        UiUtils.showKeyboard(mUrlBar);
        // As the position of the navigation icon has changed, ensure the suggestions are
        // updated to reflect the new position.
        if (getSuggestionList() != null && getSuggestionList().isShown()) {
            getSuggestionList().invalidateSuggestionViews();
        }
    }
    setUrlFocusChangeInProgress(false);

    NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
    if (hasFocus && ntp != null && ntp.isLocationBarShownInNTP()) {
        fadeInOmniboxResultsContainerBackground();
    }
}
 
Example 12
Source File: LocationBarLayout.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    UiUtils.showKeyboard(mUrlBar);
}
 
Example 13
Source File: LocationBarPhone.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Handles any actions to be performed after all other actions triggered by the URL focus
 * change.  This will be called after any animations are performed to transition from one
 * focus state to the other.
 * @param hasFocus Whether the URL field has gained focus.
 */
public void finishUrlFocusChange(boolean hasFocus) {
    final WindowDelegate windowDelegate = getWindowDelegate();
    if (!hasFocus) {
        // Remove the selection from the url text.  The ending selection position
        // will determine the scroll position when the url field is restored.  If
        // we do not clear this, it will scroll to the end of the text when you
        // enter/exit the tab stack.
        // We set the selection to 0 instead of removing the selection to avoid a crash that
        // happens if you clear the selection instead.
        //
        // Triggering the bug happens by:
        // 1.) Selecting some portion of the URL (where the two selection handles
        //     appear)
        // 2.) Trigger a text change in the URL bar (i.e. by triggering a new URL load
        //     by a command line intent)
        // 3.) Simultaneously moving one of the selection handles left and right.  This will
        //     occasionally throw an AssertionError on the bounds of the selection.
        Selection.setSelection(mUrlBar.getText(), 0);

        // The animation rendering may not yet be 100% complete and hiding the keyboard makes
        // the animation quite choppy.
        postDelayed(new Runnable() {
            @Override
            public void run() {
                UiUtils.hideKeyboard(mUrlBar);
            }
        }, KEYBOARD_HIDE_DELAY_MS);
        // Convert the keyboard back to resize mode (delay the change for an arbitrary amount
        // of time in hopes the keyboard will be completely hidden before making this change).
        if (mKeyboardResizeModeTask == null
                && windowDelegate.getWindowSoftInputMode()
                        != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) {
            mKeyboardResizeModeTask = new Runnable() {
                @Override
                public void run() {
                    windowDelegate.setWindowSoftInputMode(
                            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
                    mKeyboardResizeModeTask = null;
                }
            };
            postDelayed(mKeyboardResizeModeTask, KEYBOARD_MODE_CHANGE_DELAY_MS);
        }
        mUrlActionsContainer.setVisibility(GONE);
    } else {
        if (mKeyboardResizeModeTask != null) {
            removeCallbacks(mKeyboardResizeModeTask);
            mKeyboardResizeModeTask = null;
        }
        if (windowDelegate.getWindowSoftInputMode()
                != WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) {
            windowDelegate.setWindowSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        }
        UiUtils.showKeyboard(mUrlBar);
        // As the position of the navigation icon has changed, ensure the suggestions are
        // updated to reflect the new position.
        if (getSuggestionList() != null && getSuggestionList().isShown()) {
            getSuggestionList().invalidateSuggestionViews();
        }
    }
    setUrlFocusChangeInProgress(false);

    NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
    if (hasFocus && ntp != null && ntp.isLocationBarShownInNTP()) {
        fadeInOmniboxResultsContainerBackground();
    }
}
 
Example 14
Source File: LocationBarLayout.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    UiUtils.showKeyboard(mUrlBar);
}
 
Example 15
Source File: LocationBarPhone.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Handles any actions to be performed after all other actions triggered by the URL focus
 * change.  This will be called after any animations are performed to transition from one
 * focus state to the other.
 * @param hasFocus Whether the URL field has gained focus.
 */
public void finishUrlFocusChange(boolean hasFocus) {
    if (!hasFocus) {
        // Remove the selection from the url text.  The ending selection position
        // will determine the scroll position when the url field is restored.  If
        // we do not clear this, it will scroll to the end of the text when you
        // enter/exit the tab stack.
        // We set the selection to 0 instead of removing the selection to avoid a crash that
        // happens if you clear the selection instead.
        //
        // Triggering the bug happens by:
        // 1.) Selecting some portion of the URL (where the two selection handles
        //     appear)
        // 2.) Trigger a text change in the URL bar (i.e. by triggering a new URL load
        //     by a command line intent)
        // 3.) Simultaneously moving one of the selection handles left and right.  This will
        //     occasionally throw an AssertionError on the bounds of the selection.
        if (!mUrlBar.scrollToTLD()) {
            Selection.setSelection(mUrlBar.getText(), 0);
        }

        // The animation rendering may not yet be 100% complete and hiding the keyboard makes
        // the animation quite choppy.
        postDelayed(new Runnable() {
            @Override
            public void run() {
                UiUtils.hideKeyboard(mUrlBar);
            }
        }, KEYBOARD_HIDE_DELAY_MS);
        // Convert the keyboard back to resize mode (delay the change for an arbitrary amount
        // of time in hopes the keyboard will be completely hidden before making this change).
        // If Chrome Home is enabled, it will handle its own mode changes.
        if (mBottomSheet == null) {
            setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE, true);
        }
        mUrlActionsContainer.setVisibility(GONE);
    } else {
        // If Chrome Home is enabled, it will handle its own mode changes.
        if (mBottomSheet == null) {
            setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN, false);
        }
        UiUtils.showKeyboard(mUrlBar);
        // As the position of the navigation icon has changed, ensure the suggestions are
        // updated to reflect the new position.
        if (getSuggestionList() != null && getSuggestionList().isShown()) {
            getSuggestionList().invalidateSuggestionViews();
        }
    }
    setUrlFocusChangeInProgress(false);

    NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
    if (hasFocus && ntp != null && ntp.isLocationBarShownInNTP() && mBottomSheet == null) {
        if (mFadingView == null) initFadingOverlayView();
        mFadingView.showFadingOverlay();
    }
}