Example usage for android.view.inputmethod InputMethodManager SHOW_FORCED

List of usage examples for android.view.inputmethod InputMethodManager SHOW_FORCED

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager SHOW_FORCED.

Prototype

int SHOW_FORCED

To view the source code for android.view.inputmethod InputMethodManager SHOW_FORCED.

Click Source Link

Document

Flag for #showSoftInput to indicate that the user has forced the input method open (such as by long-pressing menu) so it should not be closed until they explicitly do so.

Usage

From source file:org.appcelerator.titanium.util.TiUIHelper.java

/**
 * Shows/hides the soft keyboard.//from  w  w w. j a  v a 2 s. com
 * @param view the current focused view.
 * @param show whether to show soft keyboard.
 */
public static void showSoftKeyboard(final View view, final boolean show) {
    if (view == null)
        return;
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Activity.INPUT_METHOD_SERVICE);

    if (imm != null) {
        boolean useForce = (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT || Build.VERSION.SDK_INT >= 8)
                ? true
                : false;
        String model = TiPlatformHelper.getInstance().getModel();
        if (model != null && model.toLowerCase().startsWith("droid")) {
            useForce = true;
        }
        if (show) {
            imm.showSoftInput(view,
                    useForce ? InputMethodManager.SHOW_FORCED : InputMethodManager.SHOW_IMPLICIT);
        } else {
            imm.hideSoftInputFromWindow(view.getWindowToken(),
                    useForce ? 0 : InputMethodManager.HIDE_IMPLICIT_ONLY);
        }
    }
}

From source file:jackpal.androidterm.Term.java

private void doToggleSoftKeyboard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

}

From source file:jackpal.androidterm.Term.java

private void doShowSoftKeyboard() {
    if (getCurrentEmulatorView() == null)
        return;/*from   w  w  w  .j  a  va 2 s  . c  o  m*/
    Activity activity = this;
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(getCurrentEmulatorView(), InputMethodManager.SHOW_FORCED);
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

private void hideEaseButtons() {
    switchVisibility(mEase1Layout, View.GONE);
    switchVisibility(mEase2Layout, View.GONE);
    switchVisibility(mEase3Layout, View.GONE);
    switchVisibility(mEase4Layout, View.GONE);

    if (mFlipCardLayout.getVisibility() != View.VISIBLE) {
        switchVisibility(mFlipCardLayout, View.VISIBLE);
        mFlipCardLayout.requestFocus();//from   w  w w .  j a v  a 2  s  .c om
    } else if (typeAnswer()) {
        mAnswerField.requestFocus();

        // Show soft keyboard
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(mAnswerField, InputMethodManager.SHOW_FORCED);
    }
}

From source file:com.ichi2.anki2.Reviewer.java

private void displayCardQuestion() {
    // show timer, if activated in the deck's preferences
    initTimer();/*from ww w. java2s .com*/

    sDisplayAnswer = false;

    if (mButtonHeight == 0 && mRelativeButtonSize != 100) {
        mButtonHeight = mFlipCard.getHeight() * mRelativeButtonSize / 100;
        mFlipCard.setHeight(mButtonHeight);
        mEase1.setHeight(mButtonHeight);
        mEase2.setHeight(mButtonHeight);
        mEase3.setHeight(mButtonHeight);
        mEase4.setHeight(mButtonHeight);
    }

    setInterface();

    String question = mCurrentCard.getQuestion(mCurrentSimpleInterface);
    question = typeAnsQuestionFilter(question);

    if (mPrefFixArabic) {
        question = ArabicUtilities.reshapeSentence(question, true);
    }

    Log.i(AnkiDroidApp.TAG, "question: '" + question + "'");

    String displayString = "";

    if (mCurrentSimpleInterface) {
        mCardContent = convertToSimple(question);
        if (mCardContent.length() == 0) {
            SpannableString hint = new SpannableString(
                    getResources().getString(R.string.simple_interface_hint, R.string.card_details_question));
            hint.setSpan(new StyleSpan(Typeface.ITALIC), 0, mCardContent.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mCardContent = hint;
        }
    } else {
        // If the user wants to write the answer
        if (typeAnswer()) {
            mAnswerField.setVisibility(View.VISIBLE);

            // Show soft keyboard
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputMethodManager.showSoftInput(mAnswerField, InputMethodManager.SHOW_FORCED);
        }

        displayString = enrichWithQADiv(question, false);

        if (mSpeakText) {
            // ReadText.setLanguageInformation(Model.getModel(DeckManager.getMainDeck(),
            // mCurrentCard.getCardModelId(), false).getId(), mCurrentCard.getCardModelId());
        }

        if (mPrefRecord) {
            Recorder.reset();
            // check for auto record
            try {
                if (mSched.getCol().getDecks().confForDid(mCurrentCard.getDid()).getBoolean("autoRecord")) {
                    Recorder.startRecording();
                }
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }

    }

    updateCard(displayString);
    hideEaseButtons();

    // If the user want to show answer automatically
    if (mPrefUseTimer) {
        mTimeoutHandler.removeCallbacks(mShowAnswerTask);
        mTimeoutHandler.postDelayed(mShowAnswerTask, mWaitAnswerSecond * 1000);
    }
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

private void displayCardQuestion() {
    // show timer, if activated in the deck's preferences
    initTimer();/*  ww w .j a va2  s.c o  m*/

    sDisplayAnswer = false;

    if (mButtonHeight == 0 && mRelativeButtonSize != 100) {
        mButtonHeight = mFlipCard.getHeight() * mRelativeButtonSize / 100;
        mFlipCard.setHeight(mButtonHeight);
        mEase1.setHeight(mButtonHeight);
        mEase2.setHeight(mButtonHeight);
        mEase3.setHeight(mButtonHeight);
        mEase4.setHeight(mButtonHeight);
    }

    setInterface();

    String question = mCurrentCard.getQuestion(mCurrentSimpleInterface);
    question = typeAnsQuestionFilter(question);

    if (mPrefFixArabic) {
        question = ArabicUtilities.reshapeSentence(question, true);
    }

    // Log.i(AnkiDroidApp.TAG, "question: '" + question + "'");

    String displayString = "";

    if (mCurrentSimpleInterface) {
        mCardContent = convertToSimple(question);
        if (mCardContent.length() == 0) {
            SpannableString hint = new SpannableString(
                    getResources().getString(R.string.simple_interface_hint, R.string.card_details_question));
            hint.setSpan(new StyleSpan(Typeface.ITALIC), 0, mCardContent.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            mCardContent = hint;
        }
    } else {
        // If the user wants to write the answer
        if (typeAnswer()) {
            mAnswerField.setVisibility(View.VISIBLE);

            // Show soft keyboard
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputMethodManager.showSoftInput(mAnswerField, InputMethodManager.SHOW_FORCED);
        }

        displayString = enrichWithQADiv(question, false);

        if (mSpeakText) {
            // ReadText.setLanguageInformation(Model.getModel(DeckManager.getMainDeck(),
            // mCurrentCard.getCardModelId(), false).getId(), mCurrentCard.getCardModelId());
        }
    }

    updateCard(displayString);
    hideEaseButtons();

    // If the user want to show answer automatically
    if (mPrefUseTimer) {
        mTimeoutHandler.removeCallbacks(mShowAnswerTask);
        mTimeoutHandler.postDelayed(mShowAnswerTask, mWaitAnswerSecond * 1000);
    }
}