List of usage examples for android.content Context TEXT_SERVICES_MANAGER_SERVICE
String TEXT_SERVICES_MANAGER_SERVICE
To view the source code for android.content Context TEXT_SERVICES_MANAGER_SERVICE.
Click Source Link
From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java
/** * This is the main point where we do our initialization of the input method * to begin operating on an application. At this point we have been * bound to the client, and are now receiving all of the detailed information * about the target of our edits.//from w w w.ja va2 s . com * * Set up edit field behaviour and disable logging if pass/email/url * Bind to spell-checking service */ @Override public void onStartInput(EditorInfo attribute, boolean restarting) { super.onStartInput(attribute, restarting); //get connection to editor field ic = getCurrentInputConnection(); //create a temporary keyboard to obtain the necessary options mCurKeyboard = new LatinKeyboard(this, R.xml.qwerty); keyModel = new KeyGraph(mCurKeyboard); /*display the coordinates of all keys List<Key> keys = mCurKeyboard.getKeys(); for (int x=0; x<keys.size(); x++) { System.out.println(keys.get(x).label+"*" +keys.get(x).x+"*" +keys.get(x).y+"*" +keys.get(x).width+"*" +keys.get(x).height); } */ // Reset our state. We want to do this even if restarting, because // the underlying state of the text editor could have changed in any way. mComposing.setLength(0); captureData = true; //updateCandidates(); if (!restarting) { // Clear shift states. mMetaState = 0; } mPredictionOn = false; mCompletionOn = false; mCompletions = null; // We are now going to initialize our state based on the type of // text being edited. switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) { case EditorInfo.TYPE_CLASS_NUMBER: case EditorInfo.TYPE_CLASS_DATETIME: // Numbers and dates default to the symbols keyboard, with // no extra features. //mCurKeyboard = mSymbolsKeyboard; startingKeyboard = KeyboardViews.SYMBOLS; break; case EditorInfo.TYPE_CLASS_PHONE: // Phones will also default to the symbols keyboard, though // often you will want to have a dedicated phone keyboard. //mCurKeyboard = mSymbolsKeyboard; startingKeyboard = KeyboardViews.SYMBOLS; break; case EditorInfo.TYPE_CLASS_TEXT: // This is general text editing. We will default to the // normal alphabetic keyboard, and assume that we should // be doing predictive text (showing candidates as the // user types). //mCurKeyboard = mQwertyKeyboard; startingKeyboard = KeyboardViews.QWERTY_EN; mPredictionOn = true; // We now look for a few special variations of text that will // modify our behavior. int variation = attribute.inputType & EditorInfo.TYPE_MASK_VARIATION; //do not log data from passwords, email addresses, URL fields if (variation == EditorInfo.TYPE_TEXT_VARIATION_PASSWORD || variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD || variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS || variation == EditorInfo.TYPE_TEXT_VARIATION_URI) { // Do not log data captureData = false; Log.i("OnStartInput", "DANGER FIELD - DO NOT CAPTURE"); } if (variation == EditorInfo.TYPE_TEXT_VARIATION_PASSWORD || variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { // Do not display predictions / what the user is typing // when they are entering a password. mPredictionOn = false; } if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS || variation == EditorInfo.TYPE_TEXT_VARIATION_URI || variation == EditorInfo.TYPE_TEXT_VARIATION_FILTER) { // Our predictions are not useful for e-mail addresses // or URIs. mPredictionOn = false; } if ((attribute.inputType & EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) { // If this is an auto-complete text view, then our predictions // will not be shown and instead we will allow the editor // to supply their own. We only show the editor's // candidates when in fullscreen mode, otherwise relying // own it displaying its own UI. mPredictionOn = false; mCompletionOn = isFullscreenMode(); } // We also want to look at the current state of the editor // to decide whether our alphabetic keyboard should start out // shifted. updateShiftKeyState(attribute); break; default: // For all unknown input types, default to the alphabetic // keyboard with no special features. //mCurKeyboard = mQwertyKeyboard; startingKeyboard = KeyboardViews.QWERTY_EN; updateShiftKeyState(attribute); } // Update the label on the enter key, depending on what the application // says it will do. if (mInputView != null) { //Log.i("onStartInput","Setting existing keyboard"); ((LatinKeyboard) mInputView.getKeyboard()).setImeOptions(getResources(), attribute.imeOptions); } else { //Log.i("onStartInput","Setting temp keyboard"); mCurKeyboard.imeOptions = attribute.imeOptions; //mCurKeyboard.shifted=attribute.initialCapsMode; } //bind to the spell checking service tsm = (TextServicesManager) getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE); //Log.i("OnStartInput", "ID:"+attribute.fieldId+" "+attribute.fieldName); }