Search in sources :

Example 21 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project android_frameworks_base by ParanoidAndroid.

the class TextServicesManagerService method getCurrentSpellCheckerSubtype.

// TODO: Respect allowImplicitlySelectedSubtype
// TODO: Save SpellCheckerSubtype by supported languages by looking at "locale".
@Override
public SpellCheckerSubtype getCurrentSpellCheckerSubtype(String locale, boolean allowImplicitlySelectedSubtype) {
    // TODO: Make this work even for non-current users?
    if (!calledFromValidUser()) {
        return null;
    }
    synchronized (mSpellCheckerMap) {
        final String subtypeHashCodeStr = mSettings.getSelectedSpellCheckerSubtype();
        if (DBG) {
            Slog.w(TAG, "getCurrentSpellCheckerSubtype: " + subtypeHashCodeStr);
        }
        final SpellCheckerInfo sci = getCurrentSpellChecker(null);
        if (sci == null || sci.getSubtypeCount() == 0) {
            if (DBG) {
                Slog.w(TAG, "Subtype not found.");
            }
            return null;
        }
        final int hashCode;
        if (!TextUtils.isEmpty(subtypeHashCodeStr)) {
            hashCode = Integer.valueOf(subtypeHashCodeStr);
        } else {
            hashCode = 0;
        }
        if (hashCode == 0 && !allowImplicitlySelectedSubtype) {
            return null;
        }
        String candidateLocale = null;
        if (hashCode == 0) {
            // Spell checker language settings == "auto"
            final InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
            if (imm != null) {
                final InputMethodSubtype currentInputMethodSubtype = imm.getCurrentInputMethodSubtype();
                if (currentInputMethodSubtype != null) {
                    final String localeString = currentInputMethodSubtype.getLocale();
                    if (!TextUtils.isEmpty(localeString)) {
                        // 1. Use keyboard locale if available in the spell checker
                        candidateLocale = localeString;
                    }
                }
            }
            if (candidateLocale == null) {
                // 2. Use System locale if available in the spell checker
                candidateLocale = mContext.getResources().getConfiguration().locale.toString();
            }
        }
        SpellCheckerSubtype candidate = null;
        for (int i = 0; i < sci.getSubtypeCount(); ++i) {
            final SpellCheckerSubtype scs = sci.getSubtypeAt(i);
            if (hashCode == 0) {
                final String scsLocale = scs.getLocale();
                if (candidateLocale.equals(scsLocale)) {
                    return scs;
                } else if (candidate == null) {
                    if (candidateLocale.length() >= 2 && scsLocale.length() >= 2 && candidateLocale.startsWith(scsLocale)) {
                        // Fall back to the applicable language
                        candidate = scs;
                    }
                }
            } else if (scs.hashCode() == hashCode) {
                if (DBG) {
                    Slog.w(TAG, "Return subtype " + scs.hashCode() + ", input= " + locale + ", " + scs.getLocale());
                }
                // 3. Use the user specified spell check language
                return scs;
            }
        }
        // spell check languages
        return candidate;
    }
}
Also used : SpellCheckerSubtype(android.view.textservice.SpellCheckerSubtype) InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) InputMethodManager(android.view.inputmethod.InputMethodManager) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 22 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project android_frameworks_base by ParanoidAndroid.

the class ButtonActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final ButtonActivity instance = this;
    final Button myButton = new Button(this);
    myButton.setClickable(true);
    myButton.setText("Keyboard UP!");
    myButton.setId(BUTTON_ID);
    myButton.setFocusableInTouchMode(true);
    myButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            InputMethodManager imm = InputMethodManager.getInstance();
            if (mKeyboardIsActive) {
                imm.hideSoftInputFromInputMethod(v.getWindowToken(), 0);
                myButton.setText("Keyboard UP!");
            } else {
                myButton.requestFocusFromTouch();
                imm.showSoftInput(v, 0);
                myButton.setText("Keyboard DOWN!");
            }
            mKeyboardIsActive = !mKeyboardIsActive;
        }
    });
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(myButton);
    setContentView(layout);
    mRootView = layout;
}
Also used : Button(android.widget.Button) InputMethodManager(android.view.inputmethod.InputMethodManager) TextView(android.widget.TextView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 23 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project HoloEverywhere by Prototik.

the class SearchView method setImeVisibility.

private void setImeVisibility(final boolean visible) {
    if (visible) {
        post(mShowImeRunnable);
    } else {
        removeCallbacks(mShowImeRunnable);
        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(getWindowToken(), 0);
        }
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 24 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project HoloEverywhere by Prototik.

the class AutoCompleteTextView method dismissDropDown.

public void dismissDropDown() {
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.displayCompletions(this, null);
    }
    mPopup.dismiss();
    mPopupCanBeUpdated = false;
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 25 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project HoloEverywhere by Prototik.

the class AutoCompleteTextView method buildImeCompletions.

private void buildImeCompletions() {
    final ListAdapter adapter = mAdapter;
    if (adapter != null) {
        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            final int count = Math.min(adapter.getCount(), 20);
            CompletionInfo[] completions = new CompletionInfo[count];
            int realCount = 0;
            for (int i = 0; i < count; i++) {
                if (adapter.isEnabled(i)) {
                    Object item = adapter.getItem(i);
                    long id = adapter.getItemId(i);
                    completions[realCount] = new CompletionInfo(id, realCount, convertSelectionToString(item));
                    realCount++;
                }
            }
            if (realCount != count) {
                CompletionInfo[] tmp = new CompletionInfo[realCount];
                System.arraycopy(completions, 0, tmp, 0, realCount);
                completions = tmp;
            }
            imm.displayCompletions(this, completions);
        }
    }
}
Also used : CompletionInfo(android.view.inputmethod.CompletionInfo) InputMethodManager(android.view.inputmethod.InputMethodManager) ListAdapter(android.widget.ListAdapter) SuppressLint(android.annotation.SuppressLint)

Aggregations

InputMethodManager (android.view.inputmethod.InputMethodManager)601 View (android.view.View)113 TextView (android.widget.TextView)61 Paint (android.graphics.Paint)43 Spannable (android.text.Spannable)34 Editable (android.text.Editable)32 EditText (android.widget.EditText)30 Intent (android.content.Intent)29 ImageView (android.widget.ImageView)29 RemoteException (android.os.RemoteException)23 TextPaint (android.text.TextPaint)21 KeyEvent (android.view.KeyEvent)20 Point (android.graphics.Point)18 InputMethodInfo (android.view.inputmethod.InputMethodInfo)18 AdapterView (android.widget.AdapterView)17 Button (android.widget.Button)17 RemoteView (android.widget.RemoteViews.RemoteView)16 Resources (android.content.res.Resources)15 ListView (android.widget.ListView)15 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)14