当前位置: 首页>>代码示例>>Java>>正文


Java TextUtils.CAP_MODE_CHARACTERS属性代码示例

本文整理汇总了Java中android.text.TextUtils.CAP_MODE_CHARACTERS属性的典型用法代码示例。如果您正苦于以下问题:Java TextUtils.CAP_MODE_CHARACTERS属性的具体用法?Java TextUtils.CAP_MODE_CHARACTERS怎么用?Java TextUtils.CAP_MODE_CHARACTERS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.text.TextUtils的用法示例。


在下文中一共展示了TextUtils.CAP_MODE_CHARACTERS属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: flagsToString

/**
 * Convert capitalize mode flags into human readable text.
 *
 * @param capsFlags The modes flags to be converted. It may be any combination of
 * {@link TextUtils#CAP_MODE_CHARACTERS}, {@link TextUtils#CAP_MODE_WORDS}, and
 * {@link TextUtils#CAP_MODE_SENTENCES}.
 * @return the text that describe the <code>capsMode</code>.
 */
public static String flagsToString(final int capsFlags) {
    final int capsFlagsMask = TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS
            | TextUtils.CAP_MODE_SENTENCES;
    if ((capsFlags & ~capsFlagsMask) != 0) {
        return "unknown<0x" + Integer.toHexString(capsFlags) + ">";
    }
    final ArrayList<String> builder = new ArrayList<>();
    if ((capsFlags & android.text.TextUtils.CAP_MODE_CHARACTERS) != 0) {
        builder.add("characters");
    }
    if ((capsFlags & android.text.TextUtils.CAP_MODE_WORDS) != 0) {
        builder.add("words");
    }
    if ((capsFlags & android.text.TextUtils.CAP_MODE_SENTENCES) != 0) {
        builder.add("sentences");
    }
    return builder.isEmpty() ? "none" : TextUtils.join("|", builder);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:26,代码来源:CapsModeUtils.java

示例2: flagsToString

/**
 * Convert capitalize mode flags into human readable text.
 *
 * @param capsFlags The modes flags to be converted. It may be any combination of
 * {@link TextUtils#CAP_MODE_CHARACTERS}, {@link TextUtils#CAP_MODE_WORDS}, and
 * {@link TextUtils#CAP_MODE_SENTENCES}.
 * @return the text that describe the <code>capsMode</code>.
 */
public static String flagsToString(final int capsFlags) {
    final int capsFlagsMask = TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS
            | TextUtils.CAP_MODE_SENTENCES;
    if ((capsFlags & ~capsFlagsMask) != 0) {
        return "unknown<0x" + Integer.toHexString(capsFlags) + ">";
    }
    final ArrayList<String> builder = new ArrayList<>();
    if ((capsFlags & TextUtils.CAP_MODE_CHARACTERS) != 0) {
        builder.add("characters");
    }
    if ((capsFlags & TextUtils.CAP_MODE_WORDS) != 0) {
        builder.add("words");
    }
    if ((capsFlags & TextUtils.CAP_MODE_SENTENCES) != 0) {
        builder.add("sentences");
    }
    return builder.isEmpty() ? "none" : TextUtils.join("|", builder);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:26,代码来源:CapsModeUtils.java

示例3: getActualCapsMode

/**
 * Factor in auto-caps and manual caps and compute the current caps mode.
 * @param settingsValues the current settings values.
 * @param keyboardShiftMode the current shift mode of the keyboard. See
 *   KeyboardSwitcher#getKeyboardShiftMode() for possible values.
 * @return the actual caps mode the keyboard is in right now.
 */
private int getActualCapsMode(final SettingsValues settingsValues,
        final int keyboardShiftMode) {
    if (keyboardShiftMode != CAPS_MODE_AUTO_SHIFTED) {
        return keyboardShiftMode;
    }
    final int auto = getCurrentAutoCapsState(settingsValues);
    if (0 != (auto & TextUtils.CAP_MODE_CHARACTERS)) {
        return CAPS_MODE_AUTO_SHIFT_LOCKED;
    }
    if (0 != auto) {
        return CAPS_MODE_AUTO_SHIFTED;
    }
    return CAPS_MODE_OFF;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:21,代码来源:InputLogic.java

示例4: getCursorCapsMode

/**
 * Gets the caps modes we should be in after this specific string.
 *
 * This returns a bit set of TextUtils#CAP_MODE_*, masked by the inputType argument.
 * This method also supports faking an additional space after the string passed in argument,
 * to support cases where a space will be added automatically, like in phantom space
 * state for example.
 * Note that for English, we are using American typography rules (which are not specific to
 * American English, it's just the most common set of rules for English).
 *
 * @param inputType a mask of the caps modes to test for.
 * @param spacingAndPunctuations the values of the settings to use for locale and separators.
 * @return the caps modes that should be on as a set of bits
 */
public int getCursorCapsMode(final int inputType, final SpacingAndPunctuations spacingAndPunctuations) {
    mIC = mParent.getCurrentInputConnection();
    if (!isConnected()) {
        return Constants.TextUtils.CAP_MODE_OFF;
    }
    if (!TextUtils.isEmpty(mComposingText)) {
        // We have some composing text - we should be in MODE_CHARACTERS only.
        return TextUtils.CAP_MODE_CHARACTERS & inputType;
    }
    // TODO: this will generally work, but there may be cases where the buffer contains SOME
    // information but not enough to determine the caps mode accurately. This may happen after
    // heavy pressing of delete, for example DEFAULT_TEXT_CACHE_SIZE - 5 times or so.
    // getCapsMode should be updated to be able to return a "not enough info" result so that
    // we can get more context only when needed.
    if (TextUtils.isEmpty(mCommittedTextBeforeComposingText) && 0 != mExpectedSelStart) {
        if (!reloadTextCache()) {
            Log.w(TAG, "Unable to connect to the editor. "
                    + "Setting caps mode without knowing text.");
        }
    }
    // This never calls InputConnection#getCapsMode - in fact, it's a static method that
    // never blocks or initiates IPC.
    // TODO: don't call #toString() here. Instead, all accesses to
    // mCommittedTextBeforeComposingText should be done on the main thread.
    return CapsModeUtils.getCapsMode(mCommittedTextBeforeComposingText.toString(), inputType,
            spacingAndPunctuations);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:41,代码来源:RichInputConnection.java

示例5: onPressKey

public void onPressKey(final int code, final boolean isSinglePointer, final int autoCapsFlags,
        final int recapitalizeMode) {
    if (DEBUG_EVENT) {
        Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code)
                + " single=" + isSinglePointer
                + " " + stateToString(autoCapsFlags, recapitalizeMode));
    }
    if (code != Constants.CODE_SHIFT) {
        // Because the double tap shift key timer is to detect two consecutive shift key press,
        // it should be canceled when a non-shift key is pressed.
        mSwitchActions.cancelDoubleTapShiftKeyTimer();
    }
    if (code == Constants.CODE_SHIFT) {
        onPressShift();
    } else if (code == Constants.CODE_CAPSLOCK) {
        // Nothing to do here. See {@link #onReleaseKey(int,boolean)}.
    } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
        onPressSymbol(autoCapsFlags, recapitalizeMode);
    } else {
        mShiftKeyState.onOtherKeyPressed();
        mSymbolKeyState.onOtherKeyPressed();
        // It is required to reset the auto caps state when all of the following conditions
        // are met:
        // 1) two or more fingers are in action
        // 2) in alphabet layout
        // 3) not in all characters caps mode
        // As for #3, please note that it's required to check even when the auto caps mode is
        // off because, for example, we may be in the #1 state within the manual temporary
        // shifted mode.
        if (!isSinglePointer && mIsAlphabetMode
                && autoCapsFlags != TextUtils.CAP_MODE_CHARACTERS) {
            final boolean needsToResetAutoCaps = mAlphabetShiftState.isAutomaticShifted()
                    || (mAlphabetShiftState.isManualShifted() && mShiftKeyState.isReleasing());
            if (needsToResetAutoCaps) {
                mSwitchActions.setAlphabetKeyboard();
            }
        }
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:39,代码来源:KeyboardState.java

示例6: getActualCapsMode

/**
 * Factor in auto-caps and manual caps and compute the current caps mode.
 * @param settingsValues the current settings values.
 * @param keyboardShiftMode the current shift mode of the keyboard. See
 *   KeyboardSwitcher#getKeyboardShiftMode() for possible values.
 * @return the actual caps mode the keyboard is in right now.
 */
private int getActualCapsMode(final SettingsValues settingsValues,
        final int keyboardShiftMode) {
    if (keyboardShiftMode != WordComposer.CAPS_MODE_AUTO_SHIFTED) {
        return keyboardShiftMode;
    }
    final int auto = getCurrentAutoCapsState(settingsValues);
    if (0 != (auto & TextUtils.CAP_MODE_CHARACTERS)) {
        return WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED;
    }
    if (0 != auto) {
        return WordComposer.CAPS_MODE_AUTO_SHIFTED;
    }
    return WordComposer.CAPS_MODE_OFF;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:21,代码来源:InputLogic.java

示例7: getCursorCapsMode

/**
 * Gets the caps modes we should be in after this specific string.
 *
 * This returns a bit set of TextUtils#CAP_MODE_*, masked by the inputType argument.
 * This method also supports faking an additional space after the string passed in argument,
 * to support cases where a space will be added automatically, like in phantom space
 * state for example.
 * Note that for English, we are using American typography rules (which are not specific to
 * American English, it's just the most common set of rules for English).
 *
 * @param inputType a mask of the caps modes to test for.
 * @param spacingAndPunctuations the values of the settings to use for locale and separators.
 * @param hasSpaceBefore if we should consider there should be a space after the string.
 * @return the caps modes that should be on as a set of bits
 */
public int getCursorCapsMode(final int inputType,
        final SpacingAndPunctuations spacingAndPunctuations, final boolean hasSpaceBefore) {
    mIC = mParent.getCurrentInputConnection();
    if (!isConnected()) {
        return Constants.TextUtils.CAP_MODE_OFF;
    }
    if (!TextUtils.isEmpty(mComposingText)) {
        if (hasSpaceBefore) {
            // If we have some composing text and a space before, then we should have
            // MODE_CHARACTERS and MODE_WORDS on.
            return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS) & inputType;
        }
        // We have some composing text - we should be in MODE_CHARACTERS only.
        return TextUtils.CAP_MODE_CHARACTERS & inputType;
    }
    // TODO: this will generally work, but there may be cases where the buffer contains SOME
    // information but not enough to determine the caps mode accurately. This may happen after
    // heavy pressing of delete, for example DEFAULT_TEXT_CACHE_SIZE - 5 times or so.
    // getCapsMode should be updated to be able to return a "not enough info" result so that
    // we can get more context only when needed.
    if (TextUtils.isEmpty(mCommittedTextBeforeComposingText) && 0 != mExpectedSelStart) {
        if (!reloadTextCache()) {
            Log.w(TAG, "Unable to connect to the editor. "
                    + "Setting caps mode without knowing text.");
        }
    }
    // This never calls InputConnection#getCapsMode - in fact, it's a static method that
    // never blocks or initiates IPC.
    // TODO: don't call #toString() here. Instead, all accesses to
    // mCommittedTextBeforeComposingText should be done on the main thread.
    return CapsModeUtils.getCapsMode(mCommittedTextBeforeComposingText.toString(), inputType,
            spacingAndPunctuations, hasSpaceBefore);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:48,代码来源:RichInputConnection.java


注:本文中的android.text.TextUtils.CAP_MODE_CHARACTERS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。