1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.inputmethod.latin; 18 19 public final class Constants { 20 public static final class Color { 21 /** 22 * The alpha value for fully opaque. 23 */ 24 public final static int ALPHA_OPAQUE = 255; 25 } 26 27 public static final class ImeOption { 28 /** 29 * The private IME option used to indicate that no microphone should be shown for a given 30 * text field. For instance, this is specified by the search dialog when the dialog is 31 * already showing a voice search button. 32 * 33 * @deprecated Use {@link ImeOption#NO_MICROPHONE} with package name prefixed. 34 */ 35 @SuppressWarnings("dep-ann") 36 public static final String NO_MICROPHONE_COMPAT = "nm"; 37 38 /** 39 * The private IME option used to indicate that no microphone should be shown for a given 40 * text field. For instance, this is specified by the search dialog when the dialog is 41 * already showing a voice search button. 42 */ 43 public static final String NO_MICROPHONE = "noMicrophoneKey"; 44 45 /** 46 * The private IME option used to indicate that no settings key should be shown for a given 47 * text field. 48 */ 49 public static final String NO_SETTINGS_KEY = "noSettingsKey"; 50 51 /** 52 * The private IME option used to indicate that the given text field needs ASCII code points 53 * input. 54 * 55 * @deprecated Use EditorInfo#IME_FLAG_FORCE_ASCII. 56 */ 57 @SuppressWarnings("dep-ann") 58 public static final String FORCE_ASCII = "forceAscii"; 59 60 private ImeOption() { 61 // This utility class is not publicly instantiable. 62 } 63 } 64 65 public static final class Subtype { 66 /** 67 * The subtype mode used to indicate that the subtype is a keyboard. 68 */ 69 public static final String KEYBOARD_MODE = "keyboard"; 70 71 public static final class ExtraValue { 72 /** 73 * The subtype extra value used to indicate that the subtype keyboard layout is capable 74 * for typing ASCII characters. 75 */ 76 public static final String ASCII_CAPABLE = "AsciiCapable"; 77 78 /** 79 * The subtype extra value used to indicate that the subtype keyboard layout is capable 80 * for typing EMOJI characters. 81 */ 82 public static final String EMOJI_CAPABLE = "EmojiCapable"; 83 /** 84 * The subtype extra value used to indicate that the subtype require network connection 85 * to work. 86 */ 87 public static final String REQ_NETWORK_CONNECTIVITY = "requireNetworkConnectivity"; 88 89 /** 90 * The subtype extra value used to indicate that the subtype display name contains "%s" 91 * for replacement mark and it should be replaced by this extra value. 92 * This extra value is supported on JellyBean and later. 93 */ 94 public static final String UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME = 95 "UntranslatableReplacementStringInSubtypeName"; 96 97 /** 98 * The subtype extra value used to indicate that the subtype keyboard layout set name. 99 * This extra value is private to LatinIME. 100 */ 101 public static final String KEYBOARD_LAYOUT_SET = "KeyboardLayoutSet"; 102 103 /** 104 * The subtype extra value used to indicate that the subtype is additional subtype 105 * that the user defined. This extra value is private to LatinIME. 106 */ 107 public static final String IS_ADDITIONAL_SUBTYPE = "isAdditionalSubtype"; 108 109 private ExtraValue() { 110 // This utility class is not publicly instantiable. 111 } 112 } 113 114 private Subtype() { 115 // This utility class is not publicly instantiable. 116 } 117 } 118 119 public static final class TextUtils { 120 /** 121 * Capitalization mode for {@link android.text.TextUtils#getCapsMode}: don't capitalize 122 * characters. This value may be used with 123 * {@link android.text.TextUtils#CAP_MODE_CHARACTERS}, 124 * {@link android.text.TextUtils#CAP_MODE_WORDS}, and 125 * {@link android.text.TextUtils#CAP_MODE_SENTENCES}. 126 */ 127 public static final int CAP_MODE_OFF = 0; 128 129 private TextUtils() { 130 // This utility class is not publicly instantiable. 131 } 132 } 133 134 public static final int NOT_A_CODE = -1; 135 136 public static final int NOT_A_COORDINATE = -1; 137 public static final int SUGGESTION_STRIP_COORDINATE = -2; 138 public static final int SPELL_CHECKER_COORDINATE = -3; 139 public static final int EXTERNAL_KEYBOARD_COORDINATE = -4; 140 141 // A hint on how many characters to cache from the TextView. A good value of this is given by 142 // how many characters we need to be able to almost always find the caps mode. 143 public static final int EDITOR_CONTENTS_CACHE_SIZE = 1024; 144 145 // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h 146 public static final int DICTIONARY_MAX_WORD_LENGTH = 48; 147 148 public static boolean isValidCoordinate(final int coordinate) { 149 // Detect {@link NOT_A_COORDINATE}, {@link SUGGESTION_STRIP_COORDINATE}, 150 // and {@link SPELL_CHECKER_COORDINATE}. 151 return coordinate >= 0; 152 } 153 154 /** 155 * Custom request code used in 156 * {@link com.android.inputmethod.keyboard.KeyboardActionListener#onCustomRequest(int)}. 157 */ 158 // The code to show input method picker. 159 public static final int CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER = 1; 160 161 /** 162 * Some common keys code. Must be positive. 163 */ 164 public static final int CODE_ENTER = '\n'; 165 public static final int CODE_TAB = '\t'; 166 public static final int CODE_SPACE = ' '; 167 public static final int CODE_PERIOD = '.'; 168 public static final int CODE_ARMENIAN_PERIOD = 0x0589; 169 public static final int CODE_DASH = '-'; 170 public static final int CODE_SINGLE_QUOTE = '\''; 171 public static final int CODE_DOUBLE_QUOTE = '"'; 172 public static final int CODE_QUESTION_MARK = '?'; 173 public static final int CODE_EXCLAMATION_MARK = '!'; 174 public static final int CODE_SLASH = '/'; 175 public static final int CODE_COMMERCIAL_AT = '@'; 176 public static final int CODE_PLUS = '+'; 177 public static final int CODE_PERCENT = '%'; 178 public static final int CODE_CLOSING_PARENTHESIS = ')'; 179 public static final int CODE_CLOSING_SQUARE_BRACKET = ']'; 180 public static final int CODE_CLOSING_CURLY_BRACKET = '}'; 181 public static final int CODE_CLOSING_ANGLE_BRACKET = '>'; 182 183 /** 184 * Special keys code. Must be negative. 185 * These should be aligned with {@link KeyboardCodesSet#ID_TO_NAME}, 186 * {@link KeyboardCodesSet#DEFAULT}, and {@link KeyboardCodesSet#RTL}. 187 */ 188 public static final int CODE_SHIFT = -1; 189 public static final int CODE_CAPSLOCK = -2; 190 public static final int CODE_SWITCH_ALPHA_SYMBOL = -3; 191 public static final int CODE_OUTPUT_TEXT = -4; 192 public static final int CODE_DELETE = -5; 193 public static final int CODE_SETTINGS = -6; 194 public static final int CODE_SHORTCUT = -7; 195 public static final int CODE_ACTION_NEXT = -8; 196 public static final int CODE_ACTION_PREVIOUS = -9; 197 public static final int CODE_LANGUAGE_SWITCH = -10; 198 public static final int CODE_EMOJI = -11; 199 public static final int CODE_SHIFT_ENTER = -12; 200 // Code value representing the code is not specified. 201 public static final int CODE_UNSPECIFIED = -13; 202 203 public static boolean isLetterCode(final int code) { 204 return code >= CODE_SPACE; 205 } 206 207 public static String printableCode(final int code) { 208 switch (code) { 209 case CODE_SHIFT: return "shift"; 210 case CODE_CAPSLOCK: return "capslock"; 211 case CODE_SWITCH_ALPHA_SYMBOL: return "symbol"; 212 case CODE_OUTPUT_TEXT: return "text"; 213 case CODE_DELETE: return "delete"; 214 case CODE_SETTINGS: return "settings"; 215 case CODE_SHORTCUT: return "shortcut"; 216 case CODE_ACTION_NEXT: return "actionNext"; 217 case CODE_ACTION_PREVIOUS: return "actionPrevious"; 218 case CODE_LANGUAGE_SWITCH: return "languageSwitch"; 219 case CODE_EMOJI: return "emoji"; 220 case CODE_SHIFT_ENTER: return "shiftEnter"; 221 case CODE_UNSPECIFIED: return "unspec"; 222 case CODE_TAB: return "tab"; 223 case CODE_ENTER: return "enter"; 224 default: 225 if (code < CODE_SPACE) return String.format("'\\u%02x'", code); 226 if (code < 0x100) return String.format("'%c'", code); 227 return String.format("'\\u%04x'", code); 228 } 229 } 230 231 public static final int MAX_INT_BIT_COUNT = 32; 232 233 private Constants() { 234 // This utility class is not publicly instantiable. 235 } 236 237 } 238