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

Commit 62d45ec9 authored by c_yunong's avatar c_yunong Committed by Linux Build Service Account
Browse files

LatinIME: Customize features for regional package.

Add new feature to support:
- Customize auto correction type of input method LatinIME.
- Make the button in the lower right corner of the keyboard to be
  Enter button.

By default they are not enabled, they could be enabled in the
operator data package overlay if needed.

Change-Id: I7198bf600eab499de44c73bf4b1e6a761a82410b
CRs-Fixed: 1043367
parent 5e0dedaf
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<resources>
    <!--
         enable auto correction by setting auto_correction to true.
         Customize the default auto correction mode, 0-off, 1-modest, 2-aggeressive, 3-very aggeressive,
         default value is 1.
    -->
    <bool name="lower_right_corner_is_enter">false</bool>
    <string name="auto_correction_threshold_mode_default_index">@string/auto_correction_threshold_mode_index_modest</string>
</resources>
+9 −0
Original line number Diff line number Diff line
@@ -254,6 +254,15 @@
                latin:styleName="enterKeyStyle"
                latin:parentStyle="emojiKeyStyle" />
        </case>
        <!-- Make the button in the lower right corner of the keyboard to be Enter
             button. -->
        <case
            latin:mode="lowerRightCornerIsEnterKey"
        >
            <key-style
                latin:styleName="enterKeyStyle"
                latin:parentStyle="defaultEnterKeyStyle" />
        </case>
        <case
            latin:imeAction="actionGo"
        >
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public final class KeyboardId {
    public static final int MODE_DATE = 6;
    public static final int MODE_TIME = 7;
    public static final int MODE_DATETIME = 8;
    public static final int MODE_LOWER_RIGHT_CORNER_ENTER = 9;

    public static final int ELEMENT_ALPHABET = 0;
    public static final int ELEMENT_ALPHABET_MANUAL_SHIFTED = 1;
@@ -260,6 +261,7 @@ public final class KeyboardId {
        case MODE_DATE: return "date";
        case MODE_TIME: return "time";
        case MODE_DATETIME: return "datetime";
        case MODE_LOWER_RIGHT_CORNER_ENTER: return "lowerRightCornerIsEnterKey";
        default: return null;
        }
    }
+5 −1
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public final class KeyboardLayoutSet {
    private final Context mContext;
    @Nonnull
    private final Params mParams;
    private static boolean mLowerRightCornerIsEnterKey = false;

    // How many layouts we forcibly keep in cache. This only includes ALPHABET (default) and
    // ALPHABET_AUTOMATIC_SHIFTED layouts - other layouts may stay in memory in the map of
@@ -269,6 +270,8 @@ public final class KeyboardLayoutSet {
            mResources = context.getResources();
            final Params params = mParams;

            mLowerRightCornerIsEnterKey = mResources.getBoolean(
                    R.bool.lower_right_corner_is_enter);
            final EditorInfo editorInfo = (ei != null) ? ei : EMPTY_EDITOR_INFO;
            params.mMode = getKeyboardMode(editorInfo);
            // TODO: Consolidate those with {@link InputAttributes}.
@@ -494,7 +497,8 @@ public final class KeyboardLayoutSet {
                } else if (variation == InputType.TYPE_TEXT_VARIATION_URI) {
                    return KeyboardId.MODE_URL;
                } else if (variation == InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
                    return KeyboardId.MODE_IM;
                    return (mLowerRightCornerIsEnterKey ?
                            KeyboardId.MODE_LOWER_RIGHT_CORNER_ENTER : KeyboardId.MODE_IM);
                } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
                    return KeyboardId.MODE_TEXT;
                } else {
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ public class SettingsValues {
        mBlockPotentiallyOffensive = Settings.readBlockPotentiallyOffensive(prefs, res);
        mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(prefs, res);
        final String autoCorrectionThresholdRawValue = mAutoCorrectEnabled
                ? res.getString(R.string.auto_correction_threshold_mode_index_modest)
                ? res.getString(R.string.auto_correction_threshold_mode_default_index)
                : res.getString(R.string.auto_correction_threshold_mode_index_off);
        mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
        mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);