diff options
Diffstat (limited to 'java')
19 files changed, 122 insertions, 19 deletions
diff --git a/java/res/drawable-hdpi/sym_keyboard_settings_holo_dark.png b/java/res/drawable-hdpi/sym_keyboard_settings_holo_dark.png Binary files differindex c76008ab3..5af09ad8c 100644 --- a/java/res/drawable-hdpi/sym_keyboard_settings_holo_dark.png +++ b/java/res/drawable-hdpi/sym_keyboard_settings_holo_dark.png diff --git a/java/res/drawable-mdpi/sym_keyboard_settings_holo_dark.png b/java/res/drawable-mdpi/sym_keyboard_settings_holo_dark.png Binary files differindex a76a976c5..36c8c9623 100644 --- a/java/res/drawable-mdpi/sym_keyboard_settings_holo_dark.png +++ b/java/res/drawable-mdpi/sym_keyboard_settings_holo_dark.png diff --git a/java/res/drawable-xhdpi/sym_keyboard_settings_holo_dark.png b/java/res/drawable-xhdpi/sym_keyboard_settings_holo_dark.png Binary files differindex 05eaffe2e..99ee97dbf 100644 --- a/java/res/drawable-xhdpi/sym_keyboard_settings_holo_dark.png +++ b/java/res/drawable-xhdpi/sym_keyboard_settings_holo_dark.png diff --git a/java/res/drawable-xxhdpi/sym_keyboard_settings_holo_dark.png b/java/res/drawable-xxhdpi/sym_keyboard_settings_holo_dark.png Binary files differindex e4358463b..7041bb6ce 100644 --- a/java/res/drawable-xxhdpi/sym_keyboard_settings_holo_dark.png +++ b/java/res/drawable-xxhdpi/sym_keyboard_settings_holo_dark.png diff --git a/java/res/values-sw600dp-land/dimens.xml b/java/res/values-sw600dp-land/dimens.xml index d067265e3..d79e8ca35 100644 --- a/java/res/values-sw600dp-land/dimens.xml +++ b/java/res/values-sw600dp-land/dimens.xml @@ -66,7 +66,7 @@ <!-- Emoji keyboard --> <fraction name="emoji_keyboard_key_width">10%p</fraction> <fraction name="emoji_keyboard_row_height">33%p</fraction> - <fraction name="emoji_keyboard_key_letter_size">85%p</fraction> + <fraction name="emoji_keyboard_key_letter_size">70%p</fraction> <integer name="emoji_keyboard_max_key_count">30</integer> </resources> diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml index 591355d3c..b2f4ae043 100644 --- a/java/res/values-sw600dp/dimens.xml +++ b/java/res/values-sw600dp/dimens.xml @@ -92,7 +92,7 @@ <!-- Emoji keyboard --> <fraction name="emoji_keyboard_key_width">12.5%p</fraction> <fraction name="emoji_keyboard_row_height">33%p</fraction> - <fraction name="emoji_keyboard_key_letter_size">76%p</fraction> + <fraction name="emoji_keyboard_key_letter_size">60%p</fraction> <integer name="emoji_keyboard_max_key_count">24</integer> </resources> diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml index 664630b4f..ce315b0fc 100644 --- a/java/res/values-sw768dp-land/dimens.xml +++ b/java/res/values-sw768dp-land/dimens.xml @@ -67,7 +67,7 @@ <!-- Emoji keyboard --> <fraction name="emoji_keyboard_key_width">7.69%p</fraction> <fraction name="emoji_keyboard_row_height">33%p</fraction> - <fraction name="emoji_keyboard_key_letter_size">68%p</fraction> + <fraction name="emoji_keyboard_key_letter_size">60%p</fraction> <integer name="emoji_keyboard_max_key_count">39</integer> </resources> diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml index 1fd933abf..c90da7fed 100644 --- a/java/res/values-sw768dp/dimens.xml +++ b/java/res/values-sw768dp/dimens.xml @@ -92,7 +92,7 @@ <!-- Emoji keyboard --> <fraction name="emoji_keyboard_key_width">10%p</fraction> <fraction name="emoji_keyboard_row_height">33%p</fraction> - <fraction name="emoji_keyboard_key_letter_size">76%p</fraction> + <fraction name="emoji_keyboard_key_letter_size">68%p</fraction> <integer name="emoji_keyboard_max_key_count">30</integer> </resources> diff --git a/java/res/values-v19/emoji-categories.xml b/java/res/values-v19/emoji-categories.xml index 0d5aa1aa1..51aad6ede 100644 --- a/java/res/values-v19/emoji-categories.xml +++ b/java/res/values-v19/emoji-categories.xml @@ -214,7 +214,7 @@ <item>fe835|0038,20e3|99</item> <!-- TODO: fix support min sdk version (99) --> <item>fe836|0039,20e3|99</item> <!-- TODO: fix support min sdk version (99) --> <item>fe837|0030,20e3|99</item> <!-- TODO: fix support min sdk version (99) --> - <item>1f51f</item> + <item>1f51f||99</item> <!-- TODO: fix support min sdk version (99) --> <item>fe82c|0023,20e3|99</item> <!-- TODO: fix support min sdk version (99) --> <item>1f51d</item> <item>1f519</item> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 465d52cec..66b9b7082 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -103,7 +103,7 @@ --> <string-array name="auto_correction_threshold_values" translatable="false"> <!-- Off, When auto correction setting is Off, this value is not used. --> - <item></item> + <item>floatMaxValue</item> <!-- Modest : Suggestion whose normalized score is greater than this value will be subject to auto-correction. --> <item>0.185</item> diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 2d626dbcf..18cb262e2 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -118,7 +118,7 @@ <!-- Emoji keyboard --> <fraction name="emoji_keyboard_key_width">14.2857%p</fraction> <fraction name="emoji_keyboard_row_height">33%p</fraction> - <fraction name="emoji_keyboard_key_letter_size">81%p</fraction> + <fraction name="emoji_keyboard_key_letter_size">68%p</fraction> <integer name="emoji_keyboard_max_key_count">21</integer> <dimen name="emoji_category_page_id_height">3dp</dimen> diff --git a/java/src/com/android/inputmethod/keyboard/EmojiKeyboardView.java b/java/src/com/android/inputmethod/keyboard/EmojiKeyboardView.java index eb48d01f6..db7c845bc 100644 --- a/java/src/com/android/inputmethod/keyboard/EmojiKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/EmojiKeyboardView.java @@ -580,10 +580,18 @@ public final class EmojiKeyboardView extends LinearLayout implements OnTabChange } private void setCurrentCategoryId(final int categoryId, final boolean force) { - if (mEmojiCategory.getCurrentCategoryId() == categoryId && !force) { + final int oldCategoryId = mEmojiCategory.getCurrentCategoryId(); + if (oldCategoryId == categoryId && !force) { return; } + if (oldCategoryId == CATEGORY_ID_RECENTS) { + // Needs to save pending updates for recent keys when we get out of the recents + // category because we don't want to move the recent emojis around while the user + // is in the recents category. + mEmojiKeyboardAdapter.flushPendingRecentKeys(); + } + mEmojiCategory.setCurrentCategoryId(categoryId); final int newTabId = mEmojiCategory.getTabIdFromCategoryId(categoryId); final int newCategoryPageId = mEmojiCategory.getPageIdFromCategoryId(categoryId); @@ -612,8 +620,18 @@ public final class EmojiKeyboardView extends LinearLayout implements OnTabChange mRecentsKeyboard = mEmojiCategory.getKeyboard(CATEGORY_ID_RECENTS, 0); } + public void flushPendingRecentKeys() { + mRecentsKeyboard.flushPendingRecentKeys(); + final KeyboardView recentKeyboardView = + mActiveKeyboardView.get(mEmojiCategory.getRecentTabId()); + if (recentKeyboardView != null) { + recentKeyboardView.invalidateAllKeys(); + } + } + public void addRecentKey(final Key key) { if (mEmojiCategory.isInRecentTab()) { + mRecentsKeyboard.addPendingKey(key); return; } mRecentsKeyboard.addKeyFirst(key); diff --git a/java/src/com/android/inputmethod/keyboard/EmojiLayoutParams.java b/java/src/com/android/inputmethod/keyboard/EmojiLayoutParams.java index 71790b7d6..ceb44e79f 100644 --- a/java/src/com/android/inputmethod/keyboard/EmojiLayoutParams.java +++ b/java/src/com/android/inputmethod/keyboard/EmojiLayoutParams.java @@ -56,7 +56,7 @@ public class EmojiLayoutParams { - (mKeyVerticalGap - mBottomPadding) / 2; mEmojiPagerHeight = defaultKeyboardHeight - mEmojiActionBarHeight - mEmojiCategoryPageIdViewHeight; - mEmojiPagerBottomMargin = mKeyVerticalGap / 2; + mEmojiPagerBottomMargin = 0; mEmojiKeyboardHeight = mEmojiPagerHeight - mEmojiPagerBottomMargin - 1; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java b/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java index 0dd71e2ec..587f95a39 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java @@ -39,6 +39,7 @@ public class DynamicGridKeyboard extends Keyboard { private static final String TAG = DynamicGridKeyboard.class.getSimpleName(); private static final int TEMPLATE_KEY_CODE_0 = 0x30; private static final int TEMPLATE_KEY_CODE_1 = 0x31; + private final Object mLock = new Object(); private final SharedPreferences mPrefs; private final int mLeftPadding; @@ -48,6 +49,7 @@ public class DynamicGridKeyboard extends Keyboard { private final int mMaxKeyCount; private final boolean mIsRecents; private final ArrayDeque<GridKey> mGridKeys = CollectionUtils.newArrayDeque(); + private final ArrayDeque<Key> mPendingKeys = CollectionUtils.newArrayDeque(); private Key[] mCachedGridKeys; @@ -74,6 +76,21 @@ public class DynamicGridKeyboard extends Keyboard { throw new RuntimeException("Can't find template key: code=" + code); } + public void addPendingKey(final Key usedKey) { + synchronized (mLock) { + mPendingKeys.addLast(usedKey); + } + } + + public void flushPendingRecentKeys() { + synchronized (mLock) { + while (!mPendingKeys.isEmpty()) { + addKey(mPendingKeys.pollFirst(), true); + } + saveRecentKeys(); + } + } + public void addKeyFirst(final Key usedKey) { addKey(usedKey, true); if (mIsRecents) { @@ -89,7 +106,7 @@ public class DynamicGridKeyboard extends Keyboard { if (usedKey == null) { return; } - synchronized (mGridKeys) { + synchronized (mLock) { mCachedGridKeys = null; final GridKey key = new GridKey(usedKey); while (mGridKeys.remove(key)) { @@ -167,7 +184,7 @@ public class DynamicGridKeyboard extends Keyboard { @Override public Key[] getKeys() { - synchronized (mGridKeys) { + synchronized (mLock) { if (mCachedGridKeys != null) { return mCachedGridKeys; } diff --git a/java/src/com/android/inputmethod/latin/makedict/DictUpdater.java b/java/src/com/android/inputmethod/latin/makedict/DictUpdater.java index 709ea3310..c4f7ec91f 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DictUpdater.java +++ b/java/src/com/android/inputmethod/latin/makedict/DictUpdater.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin.makedict; +import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; import java.io.IOException; @@ -24,6 +25,7 @@ import java.util.ArrayList; /** * An interface of a binary dictionary updater. */ +@UsedForTesting public interface DictUpdater extends DictDecoder { /** @@ -31,6 +33,7 @@ public interface DictUpdater extends DictDecoder { * * @param word the word to be deleted. */ + @UsedForTesting public void deleteWord(final String word) throws IOException, UnsupportedFormatException; /** @@ -43,6 +46,7 @@ public interface DictUpdater extends DictDecoder { * @param isBlackListEntry whether this should be a blacklist entry. */ // TODO: Support batch insertion. + @UsedForTesting public void insertWord(final String word, final int frequency, final ArrayList<WeightedString> bigramStrings, final ArrayList<WeightedString> shortcuts, final boolean isNotAWord, diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver3DictUpdater.java b/java/src/com/android/inputmethod/latin/makedict/Ver3DictUpdater.java index fa7ae310a..07adda625 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver3DictUpdater.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver3DictUpdater.java @@ -57,7 +57,7 @@ public class Ver3DictUpdater extends Ver3DictDecoder implements DictUpdater { public void deleteWord(final String word) throws IOException, UnsupportedFormatException { if (mOutStream == null) openStreamAndBuffer(); mDictBuffer.position(0); - super.readHeader(); + readHeader(); final int wordPos = getTerminalPosition(word); if (wordPos != FormatSpec.NOT_VALID_WORD) { mDictBuffer.position(wordPos); diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java index bab24e301..53729075f 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java @@ -48,7 +48,7 @@ public class Ver4DictDecoder extends AbstractDictDecoder { private final File mDictDirectory; private final DictionaryBufferFactory mBufferFactory; - private DictBuffer mDictBuffer; + protected DictBuffer mDictBuffer; private DictBuffer mFrequencyBuffer; private DictBuffer mTerminalAddressTableBuffer; private DictBuffer mBigramBuffer; diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java new file mode 100644 index 000000000..3d8f186ba --- /dev/null +++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.makedict; + +import com.android.inputmethod.annotations.UsedForTesting; +import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +/** + * An implementation of DictUpdater for version 4 binary dictionary. + */ +@UsedForTesting +public class Ver4DictUpdater extends Ver4DictDecoder implements DictUpdater { + + @UsedForTesting + public Ver4DictUpdater(final File dictDirectory, final int factoryType) { + // DictUpdater must have an updatable DictBuffer. + super(dictDirectory, ((factoryType & MASK_DICTBUFFER) == USE_BYTEARRAY) + ? USE_BYTEARRAY : USE_WRITABLE_BYTEBUFFER); + } + + @Override + public void deleteWord(final String word) throws IOException, UnsupportedFormatException { + if (mDictBuffer == null) openDictBuffer(); + readHeader(); + final int wordPos = getTerminalPosition(word); + if (wordPos != FormatSpec.NOT_VALID_WORD) { + mDictBuffer.position(wordPos); + final int flags = PtNodeReader.readPtNodeOptionFlags(mDictBuffer); + mDictBuffer.position(wordPos); + mDictBuffer.put((byte) DynamicBinaryDictIOUtils.markAsDeleted(flags)); + } + } + + @Override + public void insertWord(final String word, final int frequency, + final ArrayList<WeightedString> bigramStrings, final ArrayList<WeightedString> shortcuts, + final boolean isNotAWord, final boolean isBlackListEntry) + throws IOException, UnsupportedFormatException { + // TODO: Implement this method. + } +} diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java index ee322e91b..2abcdc7fa 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java @@ -45,8 +45,9 @@ import java.util.Locale; */ public final class SettingsValues { private static final String TAG = SettingsValues.class.getSimpleName(); - // "floatNegativeInfinity" is a special marker string for Float.NEGATIVE_INFINITE - // currently used for auto-correction + // "floatMaxValue" and "floatNegativeInfinity" are special marker strings for + // Float.NEGATIVE_INFINITE and Float.MAX_VALUE. Currently used for auto-correction settings. + private static final String FLOAT_MAX_VALUE_MARKER_STRING = "floatMaxValue"; private static final String FLOAT_NEGATIVE_INFINITY_MARKER_STRING = "floatNegativeInfinity"; // From resources: @@ -343,24 +344,28 @@ public final class SettingsValues { final String[] autoCorrectionThresholdValues = res.getStringArray( R.array.auto_correction_threshold_values); // When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off. - float autoCorrectionThreshold = Float.MAX_VALUE; + final float autoCorrectionThreshold; try { final int arrayIndex = Integer.valueOf(currentAutoCorrectionSetting); if (arrayIndex >= 0 && arrayIndex < autoCorrectionThresholdValues.length) { final String val = autoCorrectionThresholdValues[arrayIndex]; - if (FLOAT_NEGATIVE_INFINITY_MARKER_STRING.equals(val)) { + if (FLOAT_MAX_VALUE_MARKER_STRING.equals(val)) { + autoCorrectionThreshold = Float.MAX_VALUE; + } else if (FLOAT_NEGATIVE_INFINITY_MARKER_STRING.equals(val)) { autoCorrectionThreshold = Float.NEGATIVE_INFINITY; } else { autoCorrectionThreshold = Float.parseFloat(val); } + } else { + autoCorrectionThreshold = Float.MAX_VALUE; } - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { // Whenever the threshold settings are correct, never come here. - autoCorrectionThreshold = Float.MAX_VALUE; Log.w(TAG, "Cannot load auto correction threshold setting." + " currentAutoCorrectionSetting: " + currentAutoCorrectionSetting + ", autoCorrectionThresholdValues: " + Arrays.toString(autoCorrectionThresholdValues), e); + return Float.MAX_VALUE; } return autoCorrectionThreshold; } |