Loading java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java +28 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.settings.SpacingAndPunctuations; import java.util.ArrayList; import java.util.Locale; public final class CapsModeUtils { Loading Loading @@ -326,4 +327,31 @@ public final class CapsModeUtils { // Here we arrived at the start of the line. This should behave exactly like whitespace. return (START == state || LETTER == state) ? noCaps : caps; } /** * 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); } } java/src/com/android/inputmethod/latin/utils/RecapitalizeStatus.java +11 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,17 @@ public class RecapitalizeStatus { } } public static String modeToString(final int recapitalizeMode) { switch (recapitalizeMode) { case NOT_A_RECAPITALIZE_MODE: return "undefined"; case CAPS_MODE_ORIGINAL_MIXED_CASE: return "mixedCase"; case CAPS_MODE_ALL_LOWER: return "allLower"; case CAPS_MODE_FIRST_WORD_UPPER: return "firstWordUpper"; case CAPS_MODE_ALL_UPPER: return "allUpper"; default: return "unknown<" + recapitalizeMode + ">"; } } /** * We store the location of the cursor and the string that was there before the recapitalize * action was done, and the location of the cursor and the string that was there after. Loading Loading
java/src/com/android/inputmethod/latin/utils/CapsModeUtils.java +28 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.common.StringUtils; import com.android.inputmethod.latin.settings.SpacingAndPunctuations; import java.util.ArrayList; import java.util.Locale; public final class CapsModeUtils { Loading Loading @@ -326,4 +327,31 @@ public final class CapsModeUtils { // Here we arrived at the start of the line. This should behave exactly like whitespace. return (START == state || LETTER == state) ? noCaps : caps; } /** * 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); } }
java/src/com/android/inputmethod/latin/utils/RecapitalizeStatus.java +11 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,17 @@ public class RecapitalizeStatus { } } public static String modeToString(final int recapitalizeMode) { switch (recapitalizeMode) { case NOT_A_RECAPITALIZE_MODE: return "undefined"; case CAPS_MODE_ORIGINAL_MIXED_CASE: return "mixedCase"; case CAPS_MODE_ALL_LOWER: return "allLower"; case CAPS_MODE_FIRST_WORD_UPPER: return "firstWordUpper"; case CAPS_MODE_ALL_UPPER: return "allUpper"; default: return "unknown<" + recapitalizeMode + ">"; } } /** * We store the location of the cursor and the string that was there before the recapitalize * action was done, and the location of the cursor and the string that was there after. Loading