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

Commit cc8c8b99 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Split Utils class to StringUtils, SubtypeUtils, and JniUtils

Change-Id: I09e91675fe7d573dad8c933ad513b21d7e409144
parent 3e2d3858
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ import android.view.inputmethod.InputMethodManager;
import com.android.inputmethod.deprecated.LanguageSwitcherProxy;
import com.android.inputmethod.deprecated.LanguageSwitcherProxy;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.SubtypeUtils;


import java.lang.reflect.Method;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.ArrayList;
@@ -163,7 +163,7 @@ public class InputMethodManagerCompatWrapper {
    private InputMethodInfoCompatWrapper getLatinImeInputMethodInfo() {
    private InputMethodInfoCompatWrapper getLatinImeInputMethodInfo() {
        if (TextUtils.isEmpty(mLatinImePackageName))
        if (TextUtils.isEmpty(mLatinImePackageName))
            return null;
            return null;
        return Utils.getInputMethodInfo(mLatinImePackageName);
        return SubtypeUtils.getInputMethodInfo(mLatinImePackageName);
    }
    }


    private static InputMethodSubtypeCompatWrapper getLastResortSubtype(String mode) {
    private static InputMethodSubtypeCompatWrapper getLastResortSubtype(String mode) {
@@ -260,7 +260,8 @@ public class InputMethodManagerCompatWrapper {


        // The code below are based on {@link InputMethodManager#showInputMethodMenuInternal}.
        // The code below are based on {@link InputMethodManager#showInputMethodMenuInternal}.


        final InputMethodInfoCompatWrapper myImi = Utils.getInputMethodInfo(mLatinImePackageName);
        final InputMethodInfoCompatWrapper myImi = SubtypeUtils.getInputMethodInfo(
                mLatinImePackageName);
        final List<InputMethodSubtypeCompatWrapper> myImsList = getEnabledInputMethodSubtypeList(
        final List<InputMethodSubtypeCompatWrapper> myImsList = getEnabledInputMethodSubtypeList(
                myImi, true);
                myImi, true);
        final InputMethodSubtypeCompatWrapper currentIms = getCurrentInputMethodSubtype();
        final InputMethodSubtypeCompatWrapper currentIms = getCurrentInputMethodSubtype();
+3 −3
Original line number Original line Diff line number Diff line
@@ -61,8 +61,8 @@ import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinIME.UIHandler;
import com.android.inputmethod.latin.LatinIME.UIHandler;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.Utils;


import java.util.ArrayList;
import java.util.ArrayList;
@@ -662,9 +662,9 @@ public class VoiceProxy implements VoiceInput.UiListener {


    private boolean shouldShowVoiceButton(FieldContext fieldContext, EditorInfo editorInfo) {
    private boolean shouldShowVoiceButton(FieldContext fieldContext, EditorInfo editorInfo) {
        @SuppressWarnings("deprecation")
        @SuppressWarnings("deprecation")
        final boolean noMic = Utils.inPrivateImeOptions(null,
        final boolean noMic = StringUtils.inPrivateImeOptions(null,
                LatinIME.IME_OPTION_NO_MICROPHONE_COMPAT, editorInfo)
                LatinIME.IME_OPTION_NO_MICROPHONE_COMPAT, editorInfo)
                || Utils.inPrivateImeOptions(mService.getPackageName(),
                || StringUtils.inPrivateImeOptions(mService.getPackageName(),
                        LatinIME.IME_OPTION_NO_MICROPHONE, editorInfo);
                        LatinIME.IME_OPTION_NO_MICROPHONE, editorInfo);
        return ENABLE_VOICE_BUTTON && fieldCanDoVoice(fieldContext) && !noMic
        return ENABLE_VOICE_BUTTON && fieldCanDoVoice(fieldContext) && !noMic
                && SpeechRecognizer.isRecognitionAvailable(mService);
                && SpeechRecognizer.isRecognitionAvailable(mService);
+12 −12
Original line number Original line Diff line number Diff line
@@ -16,16 +16,6 @@


package com.android.inputmethod.deprecated.languageswitcher;
package com.android.inputmethod.deprecated.languageswitcher;


import com.android.inputmethod.compat.SharedPreferencesCompat;
import com.android.inputmethod.keyboard.KeyboardSet;
import com.android.inputmethod.latin.DictionaryFactory;
import com.android.inputmethod.latin.LocaleUtils;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.Settings;
import com.android.inputmethod.latin.Utils;

import org.xmlpull.v1.XmlPullParserException;

import android.content.SharedPreferences;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.content.res.Resources;
@@ -37,6 +27,16 @@ import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Pair;
import android.util.Pair;


import com.android.inputmethod.compat.SharedPreferencesCompat;
import com.android.inputmethod.keyboard.KeyboardSet;
import com.android.inputmethod.latin.DictionaryFactory;
import com.android.inputmethod.latin.LocaleUtils;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.Settings;
import com.android.inputmethod.latin.StringUtils;

import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.io.IOException;
import java.text.Collator;
import java.text.Collator;
import java.util.ArrayList;
import java.util.ArrayList;
@@ -237,12 +237,12 @@ public class InputLanguageSelection extends PreferenceActivity {


            if (finalSize == 0) {
            if (finalSize == 0) {
                preprocess[finalSize++] =
                preprocess[finalSize++] =
                        new LocaleEntry(Utils.getFullDisplayName(l, false), l);
                        new LocaleEntry(StringUtils.getFullDisplayName(l, false), l);
            } else {
            } else {
                if (s.equals("zz_ZZ")) {
                if (s.equals("zz_ZZ")) {
                    // ignore this locale
                    // ignore this locale
                } else {
                } else {
                    final String displayName = Utils.getFullDisplayName(l, false);
                    final String displayName = StringUtils.getFullDisplayName(l, false);
                    preprocess[finalSize++] = new LocaleEntry(displayName, l);
                    preprocess[finalSize++] = new LocaleEntry(displayName, l);
                }
                }
            }
            }
+5 −5
Original line number Original line Diff line number Diff line
@@ -16,10 +16,6 @@


package com.android.inputmethod.deprecated.voice;
package com.android.inputmethod.deprecated.voice;


import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.Utils;

import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
@@ -39,6 +35,10 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.TextView;


import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeSwitcher;

import java.io.ByteArrayOutputStream;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ByteOrder;
@@ -222,7 +222,7 @@ public class RecognitionView {
                Locale locale = SubtypeSwitcher.getInstance().getInputLocale();
                Locale locale = SubtypeSwitcher.getInstance().getInputLocale();


                mLanguage.setVisibility(View.VISIBLE);
                mLanguage.setVisibility(View.VISIBLE);
                mLanguage.setText(Utils.getFullDisplayName(locale, true));
                mLanguage.setText(StringUtils.getFullDisplayName(locale, true));


                mPopupLayout.setBackgroundDrawable(mListeningBorder);
                mPopupLayout.setBackgroundDrawable(mListeningBorder);
                break;
                break;
+5 −5
Original line number Original line Diff line number Diff line
@@ -30,7 +30,7 @@ import com.android.inputmethod.keyboard.internal.KeyStyles;
import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle;
import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.XmlParseUtils;
import com.android.inputmethod.latin.XmlParseUtils;


import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParser;
@@ -293,7 +293,7 @@ public class Key {
        // Choose the first letter of the label as primary code if not specified.
        // Choose the first letter of the label as primary code if not specified.
        if (code == Keyboard.CODE_UNSPECIFIED && TextUtils.isEmpty(outputText)
        if (code == Keyboard.CODE_UNSPECIFIED && TextUtils.isEmpty(outputText)
                && !TextUtils.isEmpty(mLabel)) {
                && !TextUtils.isEmpty(mLabel)) {
            if (Utils.codePointCount(mLabel) == 1) {
            if (StringUtils.codePointCount(mLabel) == 1) {
                // Use the first letter of the hint label if shiftedLetterActivated flag is
                // Use the first letter of the hint label if shiftedLetterActivated flag is
                // specified.
                // specified.
                if (hasShiftedLetterHint() && isShiftedLetterActivated()
                if (hasShiftedLetterHint() && isShiftedLetterActivated()
@@ -309,7 +309,7 @@ public class Key {
                mCode = Keyboard.CODE_OUTPUT_TEXT;
                mCode = Keyboard.CODE_OUTPUT_TEXT;
            }
            }
        } else if (code == Keyboard.CODE_UNSPECIFIED && outputText != null) {
        } else if (code == Keyboard.CODE_UNSPECIFIED && outputText != null) {
            if (Utils.codePointCount(outputText) == 1) {
            if (StringUtils.codePointCount(outputText) == 1) {
                mCode = outputText.codePointAt(0);
                mCode = outputText.codePointAt(0);
                outputText = null;
                outputText = null;
            } else {
            } else {
@@ -336,7 +336,7 @@ public class Key {
        if (!Keyboard.isLetterCode(code) || preserveCase) return code;
        if (!Keyboard.isLetterCode(code) || preserveCase) return code;
        final String text = new String(new int[] { code } , 0, 1);
        final String text = new String(new int[] { code } , 0, 1);
        final String casedText = adjustCaseOfStringForKeyboardId(text, preserveCase, id);
        final String casedText = adjustCaseOfStringForKeyboardId(text, preserveCase, id);
        return Utils.codePointCount(casedText) == 1
        return StringUtils.codePointCount(casedText) == 1
                ? casedText.codePointAt(0) : Keyboard.CODE_UNSPECIFIED;
                ? casedText.codePointAt(0) : Keyboard.CODE_UNSPECIFIED;
    }
    }


@@ -484,7 +484,7 @@ public class Key {
    }
    }


    public int selectTextSize(int letter, int largeLetter, int label, int hintLabel) {
    public int selectTextSize(int letter, int largeLetter, int label, int hintLabel) {
        if (Utils.codePointCount(mLabel) > 1
        if (StringUtils.codePointCount(mLabel) > 1
                && (mLabelFlags & (LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO
                && (mLabelFlags & (LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO
                        | LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO)) == 0) {
                        | LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO)) == 0) {
            return label;
            return label;
Loading