aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java22
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java1
-rw-r--r--native/src/binary_format.h14
-rw-r--r--native/src/unigram_dictionary.h6
-rw-r--r--tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java8
6 files changed, 36 insertions, 17 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index d9d28f186..3540577ca 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -205,16 +205,21 @@ public class Keyboard {
return mShiftState.isShiftLocked();
}
+ private void setShiftKeyGraphics(boolean newShiftState) {
+ if (mShiftState.isShiftLocked()) {
+ return;
+ }
+ for (final Key key : mShiftKeys) {
+ final int attrId = newShiftState
+ ? R.styleable.Keyboard_iconShiftKeyShifted
+ : R.styleable.Keyboard_iconShiftKey;
+ key.setIcon(mIconsSet.getIconByAttrId(attrId));
+ }
+ }
+
// TODO: Remove this method.
void setShifted(boolean newShiftState) {
- if (!mShiftState.isShiftLocked()) {
- for (final Key key : mShiftKeys) {
- final int attrId = newShiftState
- ? R.styleable.Keyboard_iconShiftKeyShifted
- : R.styleable.Keyboard_iconShiftKey;
- key.setIcon(mIconsSet.getIconByAttrId(attrId));
- }
- }
+ setShiftKeyGraphics(newShiftState);
mShiftState.setShifted(newShiftState);
}
@@ -225,6 +230,7 @@ public class Keyboard {
// TODO: Remove this method
void setAutomaticTemporaryUpperCase() {
+ setShiftKeyGraphics(true);
mShiftState.setAutomaticTemporaryUpperCase();
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index e839fe7a3..fa073b671 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -134,6 +134,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
if (mainKeyboardId.isPhoneKeyboard()) {
mState.onToggleAlphabetAndSymbols();
}
+ updateShiftState();
}
public void saveKeyboardState() {
@@ -164,7 +165,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mKeyboardView.updateSpacebar(0.0f,
mSubtypeSwitcher.needsToDisplayLanguage(keyboard.mId.mLocale));
mKeyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
- updateShiftState();
final boolean localeChanged = (oldKeyboard == null)
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index a174fd98f..abc220e34 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -944,6 +944,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
public void invalidateAllKeys() {
mDirtyRect.union(0, 0, getWidth(), getHeight());
mBufferNeedsUpdate = true;
+ mInvalidatedKey = null;
invalidate();
}
diff --git a/native/src/binary_format.h b/native/src/binary_format.h
index 6f65088db..cbaccb295 100644
--- a/native/src/binary_format.h
+++ b/native/src/binary_format.h
@@ -145,15 +145,15 @@ inline int BinaryFormat::skipFrequency(const uint8_t flags, const int pos) {
inline int BinaryFormat::skipAllAttributes(const uint8_t* const dict, const uint8_t flags,
const int pos) {
- // This function skips all attributes. The format makes provision for future extension
- // with other attributes (notably shortcuts) but for the time being, bigrams are the
- // only attributes that may be found in a character group, so we only look at bigrams
- // in this version.
+ // This function skips all attributes: shortcuts and bigrams.
+ int newPos = pos;
+ if (UnigramDictionary::FLAG_HAS_SHORTCUT_TARGETS & flags) {
+ newPos = skipAttributes(dict, newPos);
+ }
if (UnigramDictionary::FLAG_HAS_BIGRAMS & flags) {
- return skipAttributes(dict, pos);
- } else {
- return pos;
+ newPos = skipAttributes(dict, newPos);
}
+ return newPos;
}
inline int BinaryFormat::skipChildrenPosAndAttributes(const uint8_t* const dict,
diff --git a/native/src/unigram_dictionary.h b/native/src/unigram_dictionary.h
index 54f0054c1..afe92e5b9 100644
--- a/native/src/unigram_dictionary.h
+++ b/native/src/unigram_dictionary.h
@@ -44,8 +44,14 @@ public:
// Flag for terminal groups
static const int FLAG_IS_TERMINAL = 0x10;
+ // Flag for shortcut targets presence
+ static const int FLAG_HAS_SHORTCUT_TARGETS = 0x08;
// Flag for bigram presence
static const int FLAG_HAS_BIGRAMS = 0x04;
+ // Flag for shortcut-only words. Some words are shortcut-only, which means they match when
+ // the user types them but they don't pop in the suggestion strip, only the words they are
+ // shortcuts for do.
+ static const int FLAG_IS_SHORTCUT_ONLY = 0x02;
// Attribute (bigram/shortcut) related flags:
// Flag for presence of more attributes
diff --git a/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java b/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java
index 35a7b51d6..1535eb0b8 100644
--- a/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java
+++ b/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java
@@ -123,6 +123,12 @@ public class XmlDictInputOutput {
private final static String BIGRAM_W2_ATTRIBUTE = "w2";
private final static String BIGRAM_FREQ_ATTRIBUTE = "p";
+ // In this version of the XML file, the bigram frequency is given as an int 0..XML_MAX
+ private final static int XML_MAX = 256;
+ // In memory and in the binary dictionary the bigram frequency is 0..MEMORY_MAX
+ private final static int MEMORY_MAX = 16;
+ private final static int XML_TO_MEMORY_RATIO = XML_MAX / MEMORY_MAX;
+
String mW1;
final HashMap<String, ArrayList<WeightedString>> mBigramsMap;
@@ -138,7 +144,7 @@ public class XmlDictInputOutput {
} else if (BIGRAM_W2_TAG.equals(localName)) {
String w2 = attrs.getValue(uri, BIGRAM_W2_ATTRIBUTE);
int freq = Integer.parseInt(attrs.getValue(uri, BIGRAM_FREQ_ATTRIBUTE));
- WeightedString bigram = new WeightedString(w2, freq / 8);
+ WeightedString bigram = new WeightedString(w2, freq / XML_TO_MEMORY_RATIO);
ArrayList<WeightedString> bigramList = mBigramsMap.get(mW1);
if (null == bigramList) bigramList = new ArrayList<WeightedString>();
bigramList.add(bigram);