diff options
22 files changed, 105 insertions, 127 deletions
diff --git a/java/res/values-hi/strings-talkback-descriptions.xml b/java/res/values-hi/strings-talkback-descriptions.xml index a1468da51..df9511905 100644 --- a/java/res/values-hi/strings-talkback-descriptions.xml +++ b/java/res/values-hi/strings-talkback-descriptions.xml @@ -20,25 +20,25 @@ <resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="spoken_use_headphones" msgid="4313642710742229868">"ज़ोर से बोली जाने वाली पासवर्ड कुंजियां सुनने के लिए हैडसेट प्लग करें."</string> + <string name="spoken_use_headphones" msgid="4313642710742229868">"जोर से बोली जाने वाली पासवर्ड कुंजियां सुनने के लिए हैडसेट प्लग करें."</string> <string name="spoken_current_text_is" msgid="4240549866156675799">"वर्तमान पाठ %s है"</string> <string name="spoken_no_text_entered" msgid="1711276837961785646">"कोई पाठ नहीं डाला गया"</string> <string name="spoken_auto_correct" msgid="8989324692167993804">"<xliff:g id="KEY_NAME">%1$s</xliff:g> <xliff:g id="ORIGINAL_WORD">%2$s</xliff:g> को सुधार कर <xliff:g id="CORRECTED_WORD">%3$s</xliff:g> करता है"</string> <string name="spoken_auto_correct_obscured" msgid="7769449372355268412">"<xliff:g id="KEY_NAME">%1$s</xliff:g> स्वत: सुधार करता है"</string> <string name="spoken_description_unknown" msgid="2382510329910793539">"कुंजी कोड %d"</string> - <string name="spoken_description_shift" msgid="7209798151676638728">"Shift"</string> + <string name="spoken_description_shift" msgid="7209798151676638728">"शिफ़्ट"</string> <string name="spoken_description_shift_shifted" msgid="1609924271343916689">"शिफ़्ट चालू (अक्षम करने के लिए टैप करें)"</string> <string name="spoken_description_caps_lock" msgid="5020582161133170892">"कैप्स लॉक चालू (अक्षम करने के लिए टैप करें)"</string> - <string name="spoken_description_delete" msgid="3878902286264983302">"Delete"</string> + <string name="spoken_description_delete" msgid="3878902286264983302">"डिलीट"</string> <string name="spoken_description_to_symbol" msgid="8244903740201126590">"प्रतीक"</string> <string name="spoken_description_to_alpha" msgid="4081215210530031950">"अक्षर"</string> <string name="spoken_description_to_numeric" msgid="4560261331530795682">"संख्याएं"</string> <string name="spoken_description_settings" msgid="7281251004003143204">"सेटिंग"</string> - <string name="spoken_description_tab" msgid="8210782459446866716">"Tab"</string> + <string name="spoken_description_tab" msgid="8210782459446866716">"टैब"</string> <string name="spoken_description_space" msgid="5908716896642059145">"स्पेस"</string> <string name="spoken_description_mic" msgid="6153138783813452464">"ध्वनि इनपुट"</string> <string name="spoken_description_emoji" msgid="7990051553008088470">"ईमोजी"</string> - <string name="spoken_description_return" msgid="3183692287397645708">"Return"</string> + <string name="spoken_description_return" msgid="3183692287397645708">"रिटर्न"</string> <string name="spoken_description_search" msgid="5099937658231911288">"खोजें"</string> <string name="spoken_description_dot" msgid="5644176501632325560">"डॉट"</string> <string name="spoken_description_language_switch" msgid="6818666779313544553">"भाषा स्विच करें"</string> diff --git a/java/res/values-hy-rAM/strings-talkback-descriptions.xml b/java/res/values-hy-rAM/strings-talkback-descriptions.xml index d8f7d272d..e5b1ce6d9 100644 --- a/java/res/values-hy-rAM/strings-talkback-descriptions.xml +++ b/java/res/values-hy-rAM/strings-talkback-descriptions.xml @@ -23,7 +23,7 @@ <string name="spoken_use_headphones" msgid="4313642710742229868">"Միացրեք ականջակալը՝ բարձրաձայն արտասանվող գաղտնաբառը լսելու համար:"</string> <string name="spoken_current_text_is" msgid="4240549866156675799">"Տվյալ տեքստը %s է"</string> <string name="spoken_no_text_entered" msgid="1711276837961785646">"Տեքստ չի մուտքագրվել"</string> - <string name="spoken_auto_correct" msgid="8989324692167993804">"<xliff:g id="KEY_NAME">%1$s</xliff:g>-ը շտկում է <xliff:g id="ORIGINAL_WORD">%2$s</xliff:g>-ը և դարձնում <xliff:g id="CORRECTED_WORD">%3$s</xliff:g>"</string> + <string name="spoken_auto_correct" msgid="8989324692167993804">"<xliff:g id="KEY_NAME">%1$s</xliff:g>-ը շտկում է <xliff:g id="ORIGINAL_WORD">%2$s</xliff:g>-ը՝ դարձնելով <xliff:g id="CORRECTED_WORD">%3$s</xliff:g>"</string> <string name="spoken_auto_correct_obscured" msgid="7769449372355268412">"<xliff:g id="KEY_NAME">%1$s</xliff:g> ստեղնը ինքնաշտկում է կատարում"</string> <string name="spoken_description_unknown" msgid="2382510329910793539">"Բանալու կոդը՝ %d"</string> <string name="spoken_description_shift" msgid="7209798151676638728">"Shift"</string> @@ -34,8 +34,8 @@ <string name="spoken_description_to_alpha" msgid="4081215210530031950">"Տառեր"</string> <string name="spoken_description_to_numeric" msgid="4560261331530795682">"Թվեր"</string> <string name="spoken_description_settings" msgid="7281251004003143204">"Կարգավորումներ"</string> - <string name="spoken_description_tab" msgid="8210782459446866716">"Թաբ"</string> - <string name="spoken_description_space" msgid="5908716896642059145">"Բացակ"</string> + <string name="spoken_description_tab" msgid="8210782459446866716">"Tab"</string> + <string name="spoken_description_space" msgid="5908716896642059145">"Բացատ"</string> <string name="spoken_description_mic" msgid="6153138783813452464">"Ձայնային մուտքագրում"</string> <string name="spoken_description_emoji" msgid="7990051553008088470">"Զմայլիկներ"</string> <string name="spoken_description_return" msgid="3183692287397645708">"Վերադառնալ"</string> @@ -59,7 +59,7 @@ <string name="keyboard_mode_im" msgid="3812086215529493501">"նամակագրություն"</string> <string name="keyboard_mode_number" msgid="5395042245837996809">"թվեր"</string> <string name="keyboard_mode_phone" msgid="2486230278064523665">"հեռախոսահամար"</string> - <string name="keyboard_mode_text" msgid="9138789594969187494">"տեքստային հաղորդագրություն"</string> + <string name="keyboard_mode_text" msgid="9138789594969187494">"տեքստ"</string> <string name="keyboard_mode_time" msgid="8558297845514402675">"ժամանակ"</string> <string name="keyboard_mode_url" msgid="8072011652949962550">"URL"</string> <string name="spoken_descrption_emoji_category_recents" msgid="4185344945205590692">"Վերջինները"</string> diff --git a/java/res/values-zu/strings-talkback-descriptions.xml b/java/res/values-zu/strings-talkback-descriptions.xml index d30ec8b71..e01f7347d 100644 --- a/java/res/values-zu/strings-talkback-descriptions.xml +++ b/java/res/values-zu/strings-talkback-descriptions.xml @@ -26,12 +26,12 @@ <string name="spoken_auto_correct" msgid="8989324692167993804">"I-<xliff:g id="KEY_NAME">%1$s</xliff:g> ilungisa i-<xliff:g id="ORIGINAL_WORD">%2$s</xliff:g> kube yi-<xliff:g id="CORRECTED_WORD">%3$s</xliff:g>"</string> <string name="spoken_auto_correct_obscured" msgid="7769449372355268412">"I-<xliff:g id="KEY_NAME">%1$s</xliff:g> yenza ukulungisa okuzenzakalelayo"</string> <string name="spoken_description_unknown" msgid="2382510329910793539">"Ikhodi yokhiye %d"</string> - <string name="spoken_description_shift" msgid="7209798151676638728">"I-Shift"</string> + <string name="spoken_description_shift" msgid="7209798151676638728">"U-Shift"</string> <string name="spoken_description_shift_shifted" msgid="1609924271343916689">"U-Shift uvuliwe (thepha ukuwuvimbela)"</string> <string name="spoken_description_caps_lock" msgid="5020582161133170892">"Ofeleba bavuliwe (thepha ukubavimbela)"</string> <string name="spoken_description_delete" msgid="3878902286264983302">"Susa"</string> <string name="spoken_description_to_symbol" msgid="8244903740201126590">"Amasimbuli"</string> - <string name="spoken_description_to_alpha" msgid="4081215210530031950">"Imbhalo"</string> + <string name="spoken_description_to_alpha" msgid="4081215210530031950">"Izinhlamvu"</string> <string name="spoken_description_to_numeric" msgid="4560261331530795682">"Izinombolo"</string> <string name="spoken_description_settings" msgid="7281251004003143204">"Izilungiselelo"</string> <string name="spoken_description_tab" msgid="8210782459446866716">"Ithebhu"</string> @@ -65,7 +65,7 @@ <string name="spoken_descrption_emoji_category_recents" msgid="4185344945205590692">"Okwakamuva"</string> <string name="spoken_descrption_emoji_category_people" msgid="8414196269847492817">"Abantu"</string> <string name="spoken_descrption_emoji_category_objects" msgid="6116297906606195278">"Izinto"</string> - <string name="spoken_descrption_emoji_category_nature" msgid="5018340512472354640">"Awendalo"</string> + <string name="spoken_descrption_emoji_category_nature" msgid="5018340512472354640">"Indalo"</string> <string name="spoken_descrption_emoji_category_places" msgid="1163315840948545317">"Izindawo"</string> <string name="spoken_descrption_emoji_category_symbols" msgid="474680659024880601">"Amasimbuli"</string> <string name="spoken_descrption_emoji_category_emoticons" msgid="456737544787823539">"Izithombe-mzwelo"</string> diff --git a/java/res/values/strings-talkback-descriptions.xml b/java/res/values/strings-talkback-descriptions.xml index 9c1e652b0..4ffca10c8 100644 --- a/java/res/values/strings-talkback-descriptions.xml +++ b/java/res/values/strings-talkback-descriptions.xml @@ -74,11 +74,10 @@ <string name="spoken_description_shiftmode_on">Shift enabled</string> <!-- Spoken feedback after turning "Caps lock" mode on. --> <string name="spoken_description_shiftmode_locked">Caps lock enabled</string> - <!-- Spoken feedback after turning "Shift" mode off. --> - <string name="spoken_description_shiftmode_off">Shift disabled</string> - <!-- Spoken feedback after changing to the symbols keyboard. --> <string name="spoken_description_mode_symbol">Symbols mode</string> + <!-- Spoken feedback after changing to the symbols shift keyboard. --> + <string name="spoken_description_mode_symbol_shift">Symbols shift mode</string> <!-- Spoken feedback after changing to the alphanumeric keyboard. --> <string name="spoken_description_mode_alpha">Letters mode</string> <!-- Spoken feedback after changing to the phone dialer keyboard. --> diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index 322127a12..15f79f3de 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -136,12 +136,19 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp return; } // Announce the language name only when the language is changed. - if (lastKeyboard == null || !lastKeyboard.mId.mSubtype.equals(keyboard.mId.mSubtype)) { + if (lastKeyboard == null || !keyboard.mId.mSubtype.equals(lastKeyboard.mId.mSubtype)) { announceKeyboardLanguage(keyboard); + return; } // Announce the mode only when the mode is changed. - if (lastKeyboardMode != keyboard.mId.mMode) { + if (keyboard.mId.mMode != lastKeyboardMode) { announceKeyboardMode(keyboard); + return; + } + // Announce the keyboard type only when the type is changed. + if (keyboard.mId.mElementId != lastKeyboard.mId.mElementId) { + announceKeyboardType(keyboard, lastKeyboard); + return; } } @@ -174,9 +181,8 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp * @param keyboard The new keyboard. */ private void announceKeyboardMode(final Keyboard keyboard) { - final int mode = keyboard.mId.mMode; final Context context = mView.getContext(); - final int modeTextResId = KEYBOARD_MODE_RES_IDS.get(mode); + final int modeTextResId = KEYBOARD_MODE_RES_IDS.get(keyboard.mId.mMode); if (modeTextResId == 0) { return; } @@ -186,6 +192,50 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp } /** + * Announces which type of keyboard is being displayed. + * + * @param keyboard The new keyboard. + * @param lastKeyboard The last keyboard. + */ + private void announceKeyboardType(final Keyboard keyboard, final Keyboard lastKeyboard) { + final int lastElementId = lastKeyboard.mId.mElementId; + final int resId; + switch (keyboard.mId.mElementId) { + case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: + case KeyboardId.ELEMENT_ALPHABET: + if (lastElementId == KeyboardId.ELEMENT_ALPHABET + || lastElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return; + } + resId = R.string.spoken_description_mode_alpha; + break; + case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED: + resId = R.string.spoken_description_shiftmode_on; + break; + case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED: + case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED: + resId = R.string.spoken_description_shiftmode_locked; + break; + case KeyboardId.ELEMENT_SYMBOLS: + resId = R.string.spoken_description_mode_symbol; + break; + case KeyboardId.ELEMENT_SYMBOLS_SHIFTED: + resId = R.string.spoken_description_mode_symbol_shift; + break; + case KeyboardId.ELEMENT_PHONE: + resId = R.string.spoken_description_mode_phone; + break; + case KeyboardId.ELEMENT_PHONE_SYMBOLS: + resId = R.string.spoken_description_mode_phone_shift; + break; + default: + return; + } + final String text = mView.getContext().getString(resId); + sendWindowStateChanged(text); + } + + /** * Announces that the keyboard has been hidden. */ private void announceKeyboardHidden() { @@ -301,7 +351,7 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp } /** - * Simulates a key press by injecting touch event into the keyboard view. + * Simulates a key press by injecting touch an event into the keyboard view. * This avoids the complexity of trackers and listeners within the keyboard. * * @param key The key to press. @@ -318,7 +368,7 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp } /** - * Simulates a key release by injecting touch event into the keyboard view. + * Simulates a key release by injecting touch an event into the keyboard view. * This avoids the complexity of trackers and listeners within the keyboard. * * @param key The key to release. @@ -383,72 +433,4 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp } return true; } - - /** - * Notifies the user of changes in the keyboard shift state. - */ - public void notifyShiftState() { - if (mView == null || mKeyboard == null) { - return; - } - - final KeyboardId keyboardId = mKeyboard.mId; - final int elementId = keyboardId.mElementId; - final Context context = mView.getContext(); - final CharSequence text; - - switch (elementId) { - case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED: - case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED: - text = context.getText(R.string.spoken_description_shiftmode_locked); - break; - case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: - case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED: - case KeyboardId.ELEMENT_SYMBOLS_SHIFTED: - text = context.getText(R.string.spoken_description_shiftmode_on); - break; - default: - text = context.getText(R.string.spoken_description_shiftmode_off); - } - AccessibilityUtils.getInstance().announceForAccessibility(mView, text); - } - - /** - * Notifies the user of changes in the keyboard symbols state. - */ - public void notifySymbolsState() { - if (mView == null || mKeyboard == null) { - return; - } - - final KeyboardId keyboardId = mKeyboard.mId; - final int elementId = keyboardId.mElementId; - final Context context = mView.getContext(); - final int resId; - - switch (elementId) { - case KeyboardId.ELEMENT_ALPHABET: - case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: - case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED: - case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED: - case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED: - resId = R.string.spoken_description_mode_alpha; - break; - case KeyboardId.ELEMENT_SYMBOLS: - case KeyboardId.ELEMENT_SYMBOLS_SHIFTED: - resId = R.string.spoken_description_mode_symbol; - break; - case KeyboardId.ELEMENT_PHONE: - resId = R.string.spoken_description_mode_phone; - break; - case KeyboardId.ELEMENT_PHONE_SYMBOLS: - resId = R.string.spoken_description_mode_phone_shift; - break; - default: - return; - } - - final String text = context.getString(resId); - AccessibilityUtils.getInstance().announceForAccessibility(mView, text); - } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 0235fde38..0e667bc1c 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -123,7 +123,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { builder.setOptions( mSubtypeSwitcher.isShortcutImeEnabled(), settingsValues.mShowsVoiceInputKey, - mLatinIME.shouldSwitchToOtherInputMethods()); + mLatinIME.shouldShowLanguageSwitchKey()); mKeyboardLayoutSet = builder.build(); mCurrentSettingsValues = settingsValues; try { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f1b1b8db2..78867f153 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1596,18 +1596,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onReleaseKey(final int primaryCode, final boolean withSliding) { mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding, getCurrentAutoCapsState(), getCurrentRecapitalizeState()); - - // If accessibility is on, ensure the user receives keyboard state updates. - if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { - switch (primaryCode) { - case Constants.CODE_SHIFT: - AccessibleKeyboardViewProxy.getInstance().notifyShiftState(); - break; - case Constants.CODE_SWITCH_ALPHA_SYMBOL: - AccessibleKeyboardViewProxy.getInstance().notifySymbolsState(); - break; - } - } } private HardwareEventDecoder getHardwareKeyEventDecoder(final int deviceId) { diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java index 2b0be545e..64cc562c8 100644 --- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java +++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java @@ -410,12 +410,21 @@ public final class RichInputMethodManager { public boolean shouldOfferSwitchingToNextInputMethod(final IBinder binder, boolean defaultValue) { - // Use the default value instead on Jelly Bean MR2 and previous where - // {@link InputMethodManager#shouldOfferSwitchingToNextInputMethod} isn't yet available - // and on KitKat where the API is still just a stub to return true always. - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { + // Use the default value instead on Jelly Bean MR2 and previous, where + // {@link InputMethodManager#shouldOfferSwitchingToNextInputMethod} isn't yet available. + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) { return defaultValue; } + // Use the default value instead on KitKat as well, where + // {@link InputMethodManager#shouldOfferSwitchingToNextInputMethod} is still just a stub to + // return true always. + if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { + // Make sure this is actually KitKat. + // TODO: Consider to remove this check once the *next* version becomes available. + if (Build.VERSION.CODENAME.equals("REL")) { + return defaultValue; + } + } return mImmWrapper.shouldOfferSwitchingToNextInputMethod(binder); } } diff --git a/native/jni/NativeFileList.mk b/native/jni/NativeFileList.mk index 70a6638fb..34c190718 100644 --- a/native/jni/NativeFileList.mk +++ b/native/jni/NativeFileList.mk @@ -56,10 +56,10 @@ LATIN_IME_CORE_SRC_FILES := \ dynamic_pt_reading_helper.cpp \ dynamic_pt_reading_utils.cpp \ dynamic_pt_updating_helper.cpp \ - dynamic_pt_writing_utils.cpp) \ + dynamic_pt_writing_utils.cpp \ + patricia_trie_reading_utils.cpp) \ $(addprefix suggest/policyimpl/dictionary/structure/v2/, \ patricia_trie_policy.cpp \ - patricia_trie_reading_utils.cpp \ ver2_patricia_trie_node_reader.cpp \ ver2_pt_node_array_reader.cpp) \ $(addprefix suggest/policyimpl/dictionary/structure/v4/, \ diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h index 2fe2bd8fa..cd095c91d 100644 --- a/native/jni/src/defines.h +++ b/native/jni/src/defines.h @@ -293,13 +293,6 @@ static inline void prof_out(void) { #define M_PI_F 3.14159265f #define MAX_PERCENTILE 100 -// Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator. -// As such, this is the maximum number of characters will be needed to represent an int as a -// string, including the terminator; this is used as the size of a string buffer large enough to -// hold any value that is intended to fit in an integer, e.g. in the code that reads the header -// of the binary dictionary where a {key,value} string pair scheme is used. -#define LARGEST_INT_DIGIT_COUNT 11 - #define NOT_A_CODE_POINT (-1) #define NOT_A_DISTANCE (-1) #define NOT_A_COORDINATE (-1) diff --git a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp index d20accfbc..5608e27d4 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp @@ -26,6 +26,13 @@ namespace latinime { +// Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator. +// As such, this is the maximum number of characters will be needed to represent an int as a +// string, including the terminator; this is used as the size of a string buffer large enough to +// hold any value that is intended to fit in an integer, e.g. in the code that reads the header +// of the binary dictionary where a {key,value} string pair scheme is used. +const int HeaderReadWriteUtils::LARGEST_INT_DIGIT_COUNT = 11; + const int HeaderReadWriteUtils::MAX_ATTRIBUTE_KEY_LENGTH = 256; const int HeaderReadWriteUtils::MAX_ATTRIBUTE_VALUE_LENGTH = 256; @@ -154,8 +161,8 @@ typedef DictionaryHeaderStructurePolicy::AttributeMap AttributeMap; /* static */ void HeaderReadWriteUtils::setIntAttributeInner(AttributeMap *const headerAttributes, const AttributeMap::key_type *const key, const int value) { AttributeMap::mapped_type valueVector; - char charBuf[LARGEST_INT_DIGIT_COUNT + 1]; - snprintf(charBuf, LARGEST_INT_DIGIT_COUNT + 1, "%d", value); + char charBuf[LARGEST_INT_DIGIT_COUNT]; + snprintf(charBuf, sizeof(charBuf), "%d", value); insertCharactersIntoVector(charBuf, &valueVector); (*headerAttributes)[*key] = valueVector; } diff --git a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h index a6b4c4e14..9b90488fc 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h +++ b/native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h @@ -92,6 +92,7 @@ class HeaderReadWriteUtils { private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeaderReadWriteUtils); + static const int LARGEST_INT_DIGIT_COUNT; static const int MAX_ATTRIBUTE_KEY_LENGTH; static const int MAX_ATTRIBUTE_VALUE_LENGTH; diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.cpp index 2457b49c8..e02dd5550 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.cpp @@ -18,9 +18,9 @@ #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_helper.h" #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_writing_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" #include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_reader.h" #include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" #include "suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.h" namespace latinime { diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.cpp index b4eee5572..e64a13cc4 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" #include "defines.h" #include "suggest/core/policy/dictionary_bigrams_structure_policy.h" diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h index a6090a513..c3f09c3b1 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h @@ -26,7 +26,6 @@ namespace latinime { class DictionaryShortcutsStructurePolicy; class DictionaryBigramsStructurePolicy; -// TODO: Move to pt_common class PatriciaTrieReadingUtils { public: typedef uint8_t NodeFlags; diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h index e4847fcf9..91192fc57 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h @@ -21,7 +21,7 @@ #include "defines.h" #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_utils.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" #include "suggest/policyimpl/dictionary/structure/v4/ver4_dict_constants.h" namespace latinime { diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp index b426dbf28..b3af1f47a 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp @@ -22,7 +22,7 @@ #include "suggest/core/dicnode/dic_node_vector.h" #include "suggest/core/dictionary/binary_dictionary_bigrams_iterator.h" #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_helper.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" #include "suggest/policyimpl/dictionary/utils/probability_utils.h" namespace latinime { diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_patricia_trie_node_reader.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_patricia_trie_node_reader.cpp index 778d7a408..0c8de0df2 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_patricia_trie_node_reader.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_patricia_trie_node_reader.cpp @@ -16,7 +16,7 @@ #include "suggest/policyimpl/dictionary/structure/v2/ver2_patricia_trie_node_reader.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" namespace latinime { diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_pt_node_array_reader.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_pt_node_array_reader.cpp index 125ea31dc..b46617d96 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_pt_node_array_reader.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/ver2_pt_node_array_reader.cpp @@ -16,7 +16,7 @@ #include "suggest/policyimpl/dictionary/structure/v2/ver2_pt_node_array_reader.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" namespace latinime { diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp index f149781f4..67420a252 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp @@ -17,7 +17,7 @@ #include "suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.h" #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_utils.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" #include "suggest/policyimpl/dictionary/structure/v4/content/probability_dict_content.h" #include "suggest/policyimpl/dictionary/structure/v4/content/probability_entry.h" #include "suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_reading_utils.h" diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp index f24c2e1af..38ff42fee 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp @@ -21,7 +21,7 @@ #include "suggest/policyimpl/dictionary/shortcut/ver4_shortcut_list_policy.h" #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_utils.h" #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_writing_utils.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" #include "suggest/policyimpl/dictionary/structure/v4/content/probability_entry.h" #include "suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_node_reader.h" #include "suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.h" diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_pt_node_array_reader.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_pt_node_array_reader.cpp index bbdf40cdd..b014c523d 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_pt_node_array_reader.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_pt_node_array_reader.cpp @@ -17,7 +17,7 @@ #include "suggest/policyimpl/dictionary/structure/v4/ver4_pt_node_array_reader.h" #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_utils.h" -#include "suggest/policyimpl/dictionary/structure/v2/patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/structure/pt_common/patricia_trie_reading_utils.h" #include "suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.h" namespace latinime { |