Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36c56cae authored by Jean Chalard's avatar Jean Chalard Committed by Android (Google) Code Review
Browse files

Merge "Make the sentence separator a resource."

parents 61aae2b4 10581e68
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -26,4 +26,7 @@
    <!-- Symbols that separate words. Adding armenian period and comma. -->
    <!-- Don't remove the enclosing double quotes, they protect whitespace (not just U+0020) -->
    <string name="symbols_word_separators">"&#x0009;&#x0020;\n"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"&#x0589;&#x055D;</string>
    <!-- The sentence separator code point, for capitalization -->
    <!-- U+0589: "։" ARMENIAN FULL STOP   ; 589h = 1417d -->
    <integer name="sentence_separator">1417</integer>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@
    <string name="symbols_word_separators">"&#x0009;&#x0020;\n"()[]{}*&amp;&lt;&gt;+=|.,;:!?/_\"</string>
    <!-- Word connectors -->
    <string name="symbols_word_connectors">\'-</string>
    <!-- The sentence separator code point, for capitalization -->
    <!-- U+002E: "." FULL STOP   ; 2Eh = 46d -->
    <integer name="sentence_separator">46</integer>
    <!-- Whether this language uses spaces between words -->
    <bool name="current_language_has_spaces">true</bool>

+9 −6
Original line number Diff line number Diff line
@@ -1411,14 +1411,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
    // Called from the KeyboardSwitcher which needs to know auto caps state to display
    // the right layout.
    public int getCurrentAutoCapsState() {
        if (!mSettings.getCurrent().mAutoCap) return Constants.TextUtils.CAP_MODE_OFF;
        final SettingsValues currentSettingsValues = mSettings.getCurrent();
        if (!currentSettingsValues.mAutoCap) return Constants.TextUtils.CAP_MODE_OFF;

        final EditorInfo ei = getCurrentInputEditorInfo();
        if (ei == null) return Constants.TextUtils.CAP_MODE_OFF;
        final int inputType = ei.inputType;
        // Warning: this depends on mSpaceState, which may not be the most current value. If
        // mSpaceState gets updated later, whoever called this may need to be told about it.
        return mConnection.getCursorCapsMode(inputType, mSubtypeSwitcher.getCurrentSubtypeLocale(),
        return mConnection.getCursorCapsMode(inputType, currentSettingsValues,
                SPACE_STATE_PHANTOM == mSpaceState);
    }

@@ -1459,9 +1460,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
    }

    private boolean maybeDoubleSpacePeriod() {
        final SettingsValues settingsValues = mSettings.getCurrent();
        if (!settingsValues.mCorrectionEnabled) return false;
        if (!settingsValues.mUseDoubleSpacePeriod) return false;
        final SettingsValues currentSettingsValues = mSettings.getCurrent();
        if (!currentSettingsValues.mCorrectionEnabled) return false;
        if (!currentSettingsValues.mUseDoubleSpacePeriod) return false;
        if (!mHandler.isAcceptingDoubleSpacePeriod()) return false;
        // We only do this when we see two spaces and an accepted code point before the cursor.
        // The code point may be a surrogate pair but the two spaces may not, so we need 4 chars.
@@ -1480,7 +1481,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        if (canBeFollowedByDoubleSpacePeriod(firstCodePoint)) {
            mHandler.cancelDoubleSpacePeriodTimer();
            mConnection.deleteSurroundingText(2, 0);
            final String textToInsert = ". ";
            final String textToInsert = new String(
                    new int[] { currentSettingsValues.mSentenceSeparator, Constants.CODE_SPACE },
                    0, 2);
            mConnection.commitText(textToInsert, 1);
            if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
                ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert,
+4 −4
Original line number Diff line number Diff line
@@ -245,11 +245,11 @@ public final class RichInputConnection {
     * 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 locale what language should be considered.
     * @param settingsValues 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 Locale locale,
    public int getCursorCapsMode(final int inputType, final SettingsValues settingsValues,
            final boolean hasSpaceBefore) {
        mIC = mParent.getCurrentInputConnection();
        if (null == mIC) return Constants.TextUtils.CAP_MODE_OFF;
@@ -277,8 +277,8 @@ public final class RichInputConnection {
        }
        // This never calls InputConnection#getCapsMode - in fact, it's a static method that
        // never blocks or initiates IPC.
        return CapsModeUtils.getCapsMode(mCommittedTextBeforeComposingText, inputType, locale,
                hasSpaceBefore);
        return CapsModeUtils.getCapsMode(mCommittedTextBeforeComposingText, inputType,
                settingsValues, hasSpaceBefore);
    }

    public int getCodePointBeforeCursor() {
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.inputmethod.EditorInfo;

import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.internal.KeySpecParser;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.R;
@@ -57,6 +58,7 @@ public final class SettingsValues {
    public final int[] mWordConnectors;
    public final SuggestedWords mSuggestPuncList;
    public final String mWordSeparators;
    public final int mSentenceSeparator;
    public final CharSequence mHintToSaveText;
    public final boolean mCurrentLanguageHasSpaces;

@@ -120,6 +122,7 @@ public final class SettingsValues {
                R.string.suggested_punctuations));
        mSuggestPuncList = createSuggestPuncList(suggestPuncsSpec);
        mWordSeparators = res.getString(R.string.symbols_word_separators);
        mSentenceSeparator = res.getInteger(R.integer.sentence_separator);
        mHintToSaveText = res.getText(R.string.hint_add_to_dictionary);
        mCurrentLanguageHasSpaces = res.getBoolean(R.bool.current_language_has_spaces);

@@ -187,6 +190,7 @@ public final class SettingsValues {
        Arrays.sort(mSymbolsFollowedBySpace);
        mWordConnectors = new int[] { '\'', '-' };
        Arrays.sort(mWordConnectors);
        mSentenceSeparator = Constants.CODE_PERIOD;
        final String[] suggestPuncsSpec = new String[] { "!", "?", ",", ":", ";" };
        mSuggestPuncList = createSuggestPuncList(suggestPuncsSpec);
        mWordSeparators = "&\t \n()[]{}*&<>+=|.,;:!?/_\"";
Loading