Example usage for android.text InputType TYPE_TEXT_FLAG_CAP_CHARACTERS

List of usage examples for android.text InputType TYPE_TEXT_FLAG_CAP_CHARACTERS

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_FLAG_CAP_CHARACTERS.

Prototype

int TYPE_TEXT_FLAG_CAP_CHARACTERS

To view the source code for android.text InputType TYPE_TEXT_FLAG_CAP_CHARACTERS.

Click Source Link

Document

Flag for #TYPE_CLASS_TEXT : capitalize all characters.

Usage

From source file:com.mobiletin.inputmethod.indic.LatinIME.java

@SuppressWarnings("deprecation")
private void onStartInputViewInternal(final EditorInfo editorInfo, final boolean restarting) {
    super.onStartInputView(editorInfo, restarting);

    mRichImm.clearSubtypeCaches();/*from   w ww  .  j  a  v  a  2 s . c  o m*/
    final KeyboardSwitcher switcher = mKeyboardSwitcher;
    switcher.updateKeyboardTheme();
    final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
    // If we are starting input in a different text field from before, we'll have to reload
    // settings, so currentSettingsValues can't be final.
    SettingsValues currentSettingsValues = mSettings.getCurrent();

    if (editorInfo == null) {
        Log.e(TAG, "Null EditorInfo in onStartInputView()");
        if (DebugFlags.DEBUG_ENABLED) {
            throw new NullPointerException("Null EditorInfo in onStartInputView()");
        }
        return;
    }
    if (DEBUG) {
        Log.d(TAG, "onStartInputView: editorInfo:" + String.format("inputType=0x%08x imeOptions=0x%08x",
                editorInfo.inputType, editorInfo.imeOptions));
        Log.d(TAG, "All caps = " + ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0)
                + ", sentence caps = " + ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0)
                + ", word caps = " + ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_WORDS) != 0));
    }
    Log.e(TAG,
            "Starting input. Cursor position = " + editorInfo.initialSelStart + "," + editorInfo.initialSelEnd);
    // TODO: Consolidate these checks with {@link InputAttributes}.
    if (InputAttributes.inPrivateImeOptions(null, NO_MICROPHONE_COMPAT, editorInfo)) {
        Log.w(TAG, "Deprecated private IME option specified: " + editorInfo.privateImeOptions);
        Log.w(TAG, "Use " + getPackageName() + "." + NO_MICROPHONE + " instead");
    }
    if (InputAttributes.inPrivateImeOptions(getPackageName(), FORCE_ASCII, editorInfo)) {
        Log.w(TAG, "Deprecated private IME option specified: " + editorInfo.privateImeOptions);
        Log.w(TAG, "Use EditorInfo.IME_FLAG_FORCE_ASCII flag instead");
    }

    // In landscape mode, this method gets called without the input view being created.
    if (mainKeyboardView == null) {
        return;
    }

    // Forward this event to the accessibility utilities, if enabled.
    final AccessibilityUtils accessUtils = AccessibilityUtils.getInstance();
    if (accessUtils.isTouchExplorationEnabled()) {
        accessUtils.onStartInputViewInternal(mainKeyboardView, editorInfo, restarting);
    }

    final boolean inputTypeChanged = !currentSettingsValues.isSameInputType(editorInfo);
    final boolean isDifferentTextField = !restarting || inputTypeChanged;
    if (isDifferentTextField) {
        mSubtypeSwitcher.updateParametersOnStartInputView();
    }

    // The EditorInfo might have a flag that affects fullscreen mode.
    // Note: This call should be done by InputMethodService?
    updateFullscreenMode();

    // ALERT: settings have not been reloaded and there is a chance they may be stale.
    // In the practice, if it is, we should have gotten onConfigurationChanged so it should
    // be fine, but this is horribly confusing and must be fixed AS SOON AS POSSIBLE.

    // In some cases the input connection has not been reset yet and we can't access it. In
    // this case we will need to call loadKeyboard() later, when it's accessible, so that we
    // can go into the correct mode, so we need to do some housekeeping here.
    final boolean needToCallLoadKeyboardLater;
    final Suggest suggest = mInputLogic.mSuggest;

    if (!currentSettingsValues.mHasHardwareKeyboard) {
        // The app calling setText() has the effect of clearing the composing
        // span, so we should reset our state unconditionally, even if restarting is true.
        // We also tell the input logic about the combining rules for the current subtype, so
        // it can adjust its combiners if needed.
        mInputLogic.startInput(mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype(),
                currentSettingsValues);

        // Note: the following does a round-trip IPC on the main thread: be careful
        final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
        if (null != currentLocale && !currentLocale.equals(suggest.getLocale())) {
            // TODO: Do this automatically.
            resetSuggest();
        }

        // TODO[IL]: Can the following be moved to InputLogic#startInput?
        if (!mInputLogic.mConnection.resetCachesUponCursorMoveAndReturnSuccess(editorInfo.initialSelStart,
                editorInfo.initialSelEnd, false /* shouldFinishComposition */)) {
            // Sometimes, while rotating, for some reason the framework tells the app we are not
            // connected to it and that means we can't refresh the cache. In this case, schedule
            // a refresh later.
            // We try resetting the caches up to 5 times before giving up.
            mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */);
            // mLastSelection{Start,End} are reset later in this method, no need to do it here
            needToCallLoadKeyboardLater = true;
        } else {
            // When rotating, initialSelStart and initialSelEnd sometimes are lying. Make a best
            // effort to work around this bug.
            mInputLogic.mConnection.tryFixLyingCursorPosition();
            mHandler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
                    true /* shouldDelay */);
            needToCallLoadKeyboardLater = false;
        }
    } else {
        // If we have a hardware keyboard we don't need to call loadKeyboard later anyway.
        needToCallLoadKeyboardLater = false;
    }

    if (isDifferentTextField || !currentSettingsValues.hasSameOrientation(getResources().getConfiguration())) {
        loadSettings();
    }
    if (isDifferentTextField) {
        mainKeyboardView.closing();
        currentSettingsValues = mSettings.getCurrent();

        if (currentSettingsValues.mAutoCorrectionEnabledPerUserSettings) {
            suggest.setAutoCorrectionThreshold(currentSettingsValues.mAutoCorrectionThreshold);
        }

        switcher.loadKeyboard(editorInfo, currentSettingsValues, getCurrentAutoCapsState(),
                getCurrentRecapitalizeState());
        if (needToCallLoadKeyboardLater) {
            // If we need to call loadKeyboard again later, we need to save its state now. The
            // later call will be done in #retryResetCaches.
            switcher.saveKeyboardState();
        }
    } else if (restarting) {
        // TODO: Come up with a more comprehensive way to reset the keyboard layout when
        // a keyboard layout set doesn't get reloaded in this method.
        switcher.resetKeyboardStateToAlphabet(getCurrentAutoCapsState(), getCurrentRecapitalizeState());
        // In apps like Talk, we come here when the text is sent and the field gets emptied and
        // we need to re-evaluate the shift state, but not the whole layout which would be
        // disruptive.
        // Space state must be updated before calling updateShiftState
        switcher.requestUpdatingShiftState(getCurrentAutoCapsState(), getCurrentRecapitalizeState());
    }
    // This will set the punctuation suggestions if next word suggestion is off;
    // otherwise it will clear the suggestion strip.
    setNeutralSuggestionStrip();

    mHandler.cancelUpdateSuggestionStrip();

    mainKeyboardView.setMainDictionaryAvailability(mDictionaryFacilitator.hasInitializedMainDictionary());
    mainKeyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn,
            currentSettingsValues.mKeyPreviewPopupDismissDelay);
    mainKeyboardView.setSlidingKeyInputPreviewEnabled(currentSettingsValues.mSlidingKeyInputPreviewEnabled);
    mainKeyboardView.setGestureHandlingEnabledByUser(currentSettingsValues.mGestureInputEnabled,
            currentSettingsValues.mGestureTrailEnabled,
            currentSettingsValues.mGestureFloatingPreviewTextEnabled);

    // Contextual dictionary should be updated for the current application.
    mContextualDictionaryUpdater.onStartInputView(editorInfo.packageName);
    if (TRACE)
        Debug.startMethodTracing("/data/trace/latinime");
}