aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/drawable-hdpi/btn_keyboard_key_normal.9.pngbin1134 -> 0 bytes
-rw-r--r--java/res/drawable-hdpi/btn_keyboard_key_normal_off.9.pngbin1243 -> 0 bytes
-rw-r--r--java/res/drawable-hdpi/btn_keyboard_key_normal_on.9.pngbin1307 -> 0 bytes
-rw-r--r--java/res/drawable-hdpi/btn_keyboard_key_pressed.9.pngbin1088 -> 0 bytes
-rw-r--r--java/res/drawable-hdpi/btn_keyboard_key_pressed_off.9.pngbin1233 -> 0 bytes
-rw-r--r--java/res/drawable-hdpi/btn_keyboard_key_pressed_on.9.pngbin1271 -> 0 bytes
-rw-r--r--java/res/drawable-hdpi/ic_subtype_mic_dark.pngbin1005 -> 0 bytes
-rw-r--r--java/res/drawable-mdpi/btn_keyboard_key_normal.9.pngbin991 -> 0 bytes
-rw-r--r--java/res/drawable-mdpi/btn_keyboard_key_normal_off.9.pngbin1083 -> 0 bytes
-rw-r--r--java/res/drawable-mdpi/btn_keyboard_key_normal_on.9.pngbin1151 -> 0 bytes
-rw-r--r--java/res/drawable-mdpi/btn_keyboard_key_pressed.9.pngbin956 -> 0 bytes
-rw-r--r--java/res/drawable-mdpi/btn_keyboard_key_pressed_off.9.pngbin1078 -> 0 bytes
-rw-r--r--java/res/drawable-mdpi/btn_keyboard_key_pressed_on.9.pngbin1119 -> 0 bytes
-rw-r--r--java/res/drawable-mdpi/sym_keyboard_mic_holo_light.pngbin525 -> 0 bytes
-rw-r--r--java/res/drawable-xhdpi/btn_keyboard_key_normal.9.pngbin1172 -> 0 bytes
-rw-r--r--java/res/drawable-xhdpi/btn_keyboard_key_normal_off.9.pngbin1278 -> 0 bytes
-rw-r--r--java/res/drawable-xhdpi/btn_keyboard_key_normal_on.9.pngbin1345 -> 0 bytes
-rw-r--r--java/res/drawable-xhdpi/btn_keyboard_key_pressed.9.pngbin1131 -> 0 bytes
-rw-r--r--java/res/drawable-xhdpi/btn_keyboard_key_pressed_off.9.pngbin1273 -> 0 bytes
-rw-r--r--java/res/drawable-xhdpi/btn_keyboard_key_pressed_on.9.pngbin1312 -> 0 bytes
-rw-r--r--java/res/drawable-xhdpi/ic_subtype_mic_dark.pngbin1259 -> 0 bytes
-rw-r--r--java/res/drawable-xxhdpi/ic_subtype_mic_dark.pngbin1846 -> 0 bytes
-rw-r--r--java/res/values-h1200dp-port/setup-dimens-large-tablet-port.xml1
-rw-r--r--java/res/values-h330dp-land/setup-dimens-large-phone-land.xml1
-rw-r--r--java/res/values-h520dp-land/setup-dimens-small-tablet-land.xml1
-rw-r--r--java/res/values-h540dp-port/setup-dimens-large-phone-port.xml1
-rw-r--r--java/res/values-h720dp-land/setup-dimens-large-tablet-land.xml1
-rw-r--r--java/res/values-h800dp-port/setup-dimens-small-tablet-port.xml1
-rw-r--r--java/res/values-land/config.xml1
-rw-r--r--java/res/values-land/dimens.xml1
-rw-r--r--java/res/values-land/setup-dimens-small-phone-land.xml1
-rw-r--r--java/res/values-port/setup-dimens-small-phone-port.xml1
-rw-r--r--java/res/values-sw540dp-land/config.xml1
-rw-r--r--java/res/values-sw540dp-land/dimens.xml1
-rw-r--r--java/res/values-sw540dp/config-screen-metrics.xml (renamed from java/res/values-hdpi/config.xml)11
-rw-r--r--java/res/values-sw540dp/config.xml4
-rw-r--r--java/res/values-sw540dp/dimens.xml3
-rw-r--r--java/res/values-sw600dp/config-screen-metrics.xml29
-rw-r--r--java/res/values-sw600dp/config.xml1
-rw-r--r--java/res/values-sw768dp-land/config.xml1
-rw-r--r--java/res/values-sw768dp-land/dimens.xml1
-rw-r--r--java/res/values-sw768dp/config-screen-metrics.xml29
-rw-r--r--java/res/values-sw768dp/config.xml10
-rw-r--r--java/res/values-sw768dp/dimens.xml3
-rw-r--r--java/res/values/config-dictionary-pack.xml30
-rw-r--r--java/res/values/config-screen-metrics.xml29
-rw-r--r--java/res/values/config.xml20
-rw-r--r--java/res/values/dimens.xml2
-rw-r--r--java/res/xml/key_symbols_period.xml47
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java66
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java25
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java27
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/DictDecoder.java8
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java10
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java8
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java5
56 files changed, 223 insertions, 158 deletions
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_normal.9.png b/java/res/drawable-hdpi/btn_keyboard_key_normal.9.png
deleted file mode 100644
index 3e25180f0..000000000
--- a/java/res/drawable-hdpi/btn_keyboard_key_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_normal_off.9.png b/java/res/drawable-hdpi/btn_keyboard_key_normal_off.9.png
deleted file mode 100644
index bad360f77..000000000
--- a/java/res/drawable-hdpi/btn_keyboard_key_normal_off.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_normal_on.9.png b/java/res/drawable-hdpi/btn_keyboard_key_normal_on.9.png
deleted file mode 100644
index 49f519860..000000000
--- a/java/res/drawable-hdpi/btn_keyboard_key_normal_on.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_pressed.9.png b/java/res/drawable-hdpi/btn_keyboard_key_pressed.9.png
deleted file mode 100644
index e784eddf8..000000000
--- a/java/res/drawable-hdpi/btn_keyboard_key_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_pressed_off.9.png b/java/res/drawable-hdpi/btn_keyboard_key_pressed_off.9.png
deleted file mode 100644
index a4731cf1a..000000000
--- a/java/res/drawable-hdpi/btn_keyboard_key_pressed_off.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_pressed_on.9.png b/java/res/drawable-hdpi/btn_keyboard_key_pressed_on.9.png
deleted file mode 100644
index 03e163c9c..000000000
--- a/java/res/drawable-hdpi/btn_keyboard_key_pressed_on.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-hdpi/ic_subtype_mic_dark.png b/java/res/drawable-hdpi/ic_subtype_mic_dark.png
deleted file mode 100644
index eacbcd255..000000000
--- a/java/res/drawable-hdpi/ic_subtype_mic_dark.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_normal.9.png b/java/res/drawable-mdpi/btn_keyboard_key_normal.9.png
deleted file mode 100644
index 12bc97928..000000000
--- a/java/res/drawable-mdpi/btn_keyboard_key_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_normal_off.9.png b/java/res/drawable-mdpi/btn_keyboard_key_normal_off.9.png
deleted file mode 100644
index 44bd414a1..000000000
--- a/java/res/drawable-mdpi/btn_keyboard_key_normal_off.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_normal_on.9.png b/java/res/drawable-mdpi/btn_keyboard_key_normal_on.9.png
deleted file mode 100644
index 43fdf5b88..000000000
--- a/java/res/drawable-mdpi/btn_keyboard_key_normal_on.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_pressed.9.png b/java/res/drawable-mdpi/btn_keyboard_key_pressed.9.png
deleted file mode 100644
index 1c1f3d711..000000000
--- a/java/res/drawable-mdpi/btn_keyboard_key_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_pressed_off.9.png b/java/res/drawable-mdpi/btn_keyboard_key_pressed_off.9.png
deleted file mode 100644
index dacb675a9..000000000
--- a/java/res/drawable-mdpi/btn_keyboard_key_pressed_off.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_keyboard_key_pressed_on.9.png b/java/res/drawable-mdpi/btn_keyboard_key_pressed_on.9.png
deleted file mode 100644
index 3daa69f31..000000000
--- a/java/res/drawable-mdpi/btn_keyboard_key_pressed_on.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-mdpi/sym_keyboard_mic_holo_light.png b/java/res/drawable-mdpi/sym_keyboard_mic_holo_light.png
deleted file mode 100644
index 84a63dc7f..000000000
--- a/java/res/drawable-mdpi/sym_keyboard_mic_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_normal.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_normal.9.png
deleted file mode 100644
index 026005d6f..000000000
--- a/java/res/drawable-xhdpi/btn_keyboard_key_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_normal_off.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_normal_off.9.png
deleted file mode 100644
index 38c5f244b..000000000
--- a/java/res/drawable-xhdpi/btn_keyboard_key_normal_off.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_normal_on.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_normal_on.9.png
deleted file mode 100644
index f1223e50e..000000000
--- a/java/res/drawable-xhdpi/btn_keyboard_key_normal_on.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_pressed.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_pressed.9.png
deleted file mode 100644
index ec35db54d..000000000
--- a/java/res/drawable-xhdpi/btn_keyboard_key_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_pressed_off.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_pressed_off.9.png
deleted file mode 100644
index bd30464d6..000000000
--- a/java/res/drawable-xhdpi/btn_keyboard_key_pressed_off.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_pressed_on.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_pressed_on.9.png
deleted file mode 100644
index a3ff5d1bb..000000000
--- a/java/res/drawable-xhdpi/btn_keyboard_key_pressed_on.9.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xhdpi/ic_subtype_mic_dark.png b/java/res/drawable-xhdpi/ic_subtype_mic_dark.png
deleted file mode 100644
index 17581ba89..000000000
--- a/java/res/drawable-xhdpi/ic_subtype_mic_dark.png
+++ /dev/null
Binary files differ
diff --git a/java/res/drawable-xxhdpi/ic_subtype_mic_dark.png b/java/res/drawable-xxhdpi/ic_subtype_mic_dark.png
deleted file mode 100644
index 811103a56..000000000
--- a/java/res/drawable-xxhdpi/ic_subtype_mic_dark.png
+++ /dev/null
Binary files differ
diff --git a/java/res/values-h1200dp-port/setup-dimens-large-tablet-port.xml b/java/res/values-h1200dp-port/setup-dimens-large-tablet-port.xml
index bc7928d6a..adc3e35a9 100644
--- a/java/res/values-h1200dp-port/setup-dimens-large-tablet-port.xml
+++ b/java/res/values-h1200dp-port/setup-dimens-large-tablet-port.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">38sp</dimen>
<dimen name="setup_step_bullet_text_size">24sp</dimen>
<dimen name="setup_step_triangle_indicator_height">24dp</dimen>
- <dimen name="setup_step_indicator_height">24dp</dimen>
<dimen name="setup_step_title_text_size">24sp</dimen>
<dimen name="setup_step_instruction_text_size">18sp</dimen>
<dimen name="setup_step_action_text_size">20sp</dimen>
diff --git a/java/res/values-h330dp-land/setup-dimens-large-phone-land.xml b/java/res/values-h330dp-land/setup-dimens-large-phone-land.xml
index aebf6d2f3..1ff43ff9f 100644
--- a/java/res/values-h330dp-land/setup-dimens-large-phone-land.xml
+++ b/java/res/values-h330dp-land/setup-dimens-large-phone-land.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">22sp</dimen>
<dimen name="setup_step_bullet_text_size">22sp</dimen>
<dimen name="setup_step_triangle_indicator_height">24dp</dimen>
- <dimen name="setup_step_indicator_height">24dp</dimen>
<dimen name="setup_step_title_text_size">20sp</dimen>
<dimen name="setup_step_instruction_text_size">16sp</dimen>
<dimen name="setup_step_action_text_size">18sp</dimen>
diff --git a/java/res/values-h520dp-land/setup-dimens-small-tablet-land.xml b/java/res/values-h520dp-land/setup-dimens-small-tablet-land.xml
index aedf79fb2..a0e30cd37 100644
--- a/java/res/values-h520dp-land/setup-dimens-small-tablet-land.xml
+++ b/java/res/values-h520dp-land/setup-dimens-small-tablet-land.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">32sp</dimen>
<dimen name="setup_step_bullet_text_size">24sp</dimen>
<dimen name="setup_step_triangle_indicator_height">24dp</dimen>
- <dimen name="setup_step_indicator_height">24dp</dimen>
<dimen name="setup_step_title_text_size">24sp</dimen>
<dimen name="setup_step_instruction_text_size">18sp</dimen>
<dimen name="setup_step_action_text_size">20sp</dimen>
diff --git a/java/res/values-h540dp-port/setup-dimens-large-phone-port.xml b/java/res/values-h540dp-port/setup-dimens-large-phone-port.xml
index 6d66f46eb..cf2a10a9e 100644
--- a/java/res/values-h540dp-port/setup-dimens-large-phone-port.xml
+++ b/java/res/values-h540dp-port/setup-dimens-large-phone-port.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">26sp</dimen>
<dimen name="setup_step_bullet_text_size">22sp</dimen>
<dimen name="setup_step_triangle_indicator_height">24dp</dimen>
- <dimen name="setup_step_indicator_height">24dp</dimen>
<dimen name="setup_step_title_text_size">20sp</dimen>
<dimen name="setup_step_instruction_text_size">16sp</dimen>
<dimen name="setup_step_action_text_size">18sp</dimen>
diff --git a/java/res/values-h720dp-land/setup-dimens-large-tablet-land.xml b/java/res/values-h720dp-land/setup-dimens-large-tablet-land.xml
index e22b741fb..a782ef8f4 100644
--- a/java/res/values-h720dp-land/setup-dimens-large-tablet-land.xml
+++ b/java/res/values-h720dp-land/setup-dimens-large-tablet-land.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">38sp</dimen>
<dimen name="setup_step_bullet_text_size">24sp</dimen>
<dimen name="setup_step_triangle_indicator_height">24dp</dimen>
- <dimen name="setup_step_indicator_height">24dp</dimen>
<dimen name="setup_step_title_text_size">24sp</dimen>
<dimen name="setup_step_instruction_text_size">18sp</dimen>
<dimen name="setup_step_action_text_size">20sp</dimen>
diff --git a/java/res/values-h800dp-port/setup-dimens-small-tablet-port.xml b/java/res/values-h800dp-port/setup-dimens-small-tablet-port.xml
index 86cf3a04a..9ac0f115f 100644
--- a/java/res/values-h800dp-port/setup-dimens-small-tablet-port.xml
+++ b/java/res/values-h800dp-port/setup-dimens-small-tablet-port.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">36sp</dimen>
<dimen name="setup_step_bullet_text_size">24sp</dimen>
<dimen name="setup_step_triangle_indicator_height">24dp</dimen>
- <dimen name="setup_step_indicator_height">24dp</dimen>
<dimen name="setup_step_title_text_size">24sp</dimen>
<dimen name="setup_step_instruction_text_size">18sp</dimen>
<dimen name="setup_step_action_text_size">20sp</dimen>
diff --git a/java/res/values-land/config.xml b/java/res/values-land/config.xml
index 7d93cc2ff..8cf7d95af 100644
--- a/java/res/values-land/config.xml
+++ b/java/res/values-land/config.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configuration values for Small Phone Landscape. -->
<resources>
<bool name="config_use_fullscreen_mode">true</bool>
</resources>
diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml
index c97e68f11..c2b360a42 100644
--- a/java/res/values-land/dimens.xml
+++ b/java/res/values-land/dimens.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configurable dimensions for Small Phone Landscape. -->
<resources>
<!-- Preferable keyboard height in absolute scale: 1.100in -->
<!-- This keyboardHeight value should match with keyboard-heights.xml -->
diff --git a/java/res/values-land/setup-dimens-small-phone-land.xml b/java/res/values-land/setup-dimens-small-phone-land.xml
index 088e6562a..de93eee08 100644
--- a/java/res/values-land/setup-dimens-small-phone-land.xml
+++ b/java/res/values-land/setup-dimens-small-phone-land.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">18sp</dimen>
<dimen name="setup_step_bullet_text_size">18sp</dimen>
<dimen name="setup_step_triangle_indicator_height">18dp</dimen>
- <dimen name="setup_step_indicator_height">18dp</dimen>
<dimen name="setup_step_title_text_size">18sp</dimen>
<dimen name="setup_step_instruction_text_size">14sp</dimen>
<dimen name="setup_step_action_text_size">16sp</dimen>
diff --git a/java/res/values-port/setup-dimens-small-phone-port.xml b/java/res/values-port/setup-dimens-small-phone-port.xml
index 8ac72ea7c..cf2751f1b 100644
--- a/java/res/values-port/setup-dimens-small-phone-port.xml
+++ b/java/res/values-port/setup-dimens-small-phone-port.xml
@@ -20,7 +20,6 @@
<dimen name="setup_welcome_description_text_size">20sp</dimen>
<dimen name="setup_step_bullet_text_size">18sp</dimen>
<dimen name="setup_step_triangle_indicator_height">18dp</dimen>
- <dimen name="setup_step_indicator_height">18dp</dimen>
<dimen name="setup_step_title_text_size">18sp</dimen>
<dimen name="setup_step_instruction_text_size">14sp</dimen>
<dimen name="setup_step_action_text_size">16sp</dimen>
diff --git a/java/res/values-sw540dp-land/config.xml b/java/res/values-sw540dp-land/config.xml
index b3cd7278d..796f14838 100644
--- a/java/res/values-sw540dp-land/config.xml
+++ b/java/res/values-sw540dp-land/config.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configuration values for Large Phone and Small Tablet Landscape. -->
<resources>
<bool name="config_use_fullscreen_mode">false</bool>
</resources>
diff --git a/java/res/values-sw540dp-land/dimens.xml b/java/res/values-sw540dp-land/dimens.xml
index 002493798..35b2009b2 100644
--- a/java/res/values-sw540dp-land/dimens.xml
+++ b/java/res/values-sw540dp-land/dimens.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configurable dimensions for Large Phone and Small Tablet Landscape. -->
<resources>
<!-- Preferable keyboard height in absolute scale: 45.0mm -->
<!-- This keyboardHeight value should match with keyboard-heights.xml -->
diff --git a/java/res/values-hdpi/config.xml b/java/res/values-sw540dp/config-screen-metrics.xml
index 4cf3562fe..1205aaa1e 100644
--- a/java/res/values-hdpi/config.xml
+++ b/java/res/values-sw540dp/config-screen-metrics.xml
@@ -2,7 +2,7 @@
<!--
/*
**
-** Copyright 2011, The Android Open Source Project
+** Copyright 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.
@@ -20,11 +20,10 @@
<resources>
<!-- Screen metrics for logging.
- 0 = "mdpi phone screen"
- 1 = "hdpi phone screen"
- 2 = "mdpi 11 inch tablet screen"
- 3 = "xhdpi phone screen?"
- 4 = ?
+ 0 = "small phone screen"
+ 1 = "large phone screen"
+ 2 = "large tablet screen"
+ 3 = "small tablet screen"
-->
<integer name="log_screen_metrics">1</integer>
</resources>
diff --git a/java/res/values-sw540dp/config.xml b/java/res/values-sw540dp/config.xml
index b1e578366..6ef53b611 100644
--- a/java/res/values-sw540dp/config.xml
+++ b/java/res/values-sw540dp/config.xml
@@ -18,14 +18,12 @@
*/
-->
+<!-- Configuration values for Large Phone and Small Tablet Portrait. -->
<resources>
<bool name="config_enable_show_option_of_key_preview_popup">false</bool>
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_key_preview_popup">false</bool>
<bool name="config_default_sound_enabled">true</bool>
- <bool name="config_auto_correction_spacebar_led_enabled">false</bool>
- <!-- The language is never displayed if == 0, always displayed if < 0 -->
- <integer name="config_delay_before_fadeout_language_on_spacebar">1200</integer>
<integer name="config_max_more_keys_column">5</integer>
<!--
Configuration for MainKeyboardView
diff --git a/java/res/values-sw540dp/dimens.xml b/java/res/values-sw540dp/dimens.xml
index 801b7acb5..79e923a33 100644
--- a/java/res/values-sw540dp/dimens.xml
+++ b/java/res/values-sw540dp/dimens.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configurable dimensions for Large Phone and Small Tablet Portrait. -->
<resources>
<!-- Preferable keyboard height in absolute scale: 48.0mm -->
<!-- This keyboardHeight value should match with keyboard-heights.xml -->
@@ -80,8 +81,6 @@
<dimen name="suggestion_text_size">22dp</dimen>
<dimen name="more_suggestions_hint_text_size">33dp</dimen>
- <!-- Gesture trail parameters -->
- <dimen name="gesture_trail_width">2.5dp</dimen>
<!-- Gesture floating preview text parameters -->
<dimen name="gesture_floating_preview_text_size">28dp</dimen>
<dimen name="gesture_floating_preview_text_offset">87dp</dimen>
diff --git a/java/res/values-sw600dp/config-screen-metrics.xml b/java/res/values-sw600dp/config-screen-metrics.xml
new file mode 100644
index 000000000..e939c068f
--- /dev/null
+++ b/java/res/values-sw600dp/config-screen-metrics.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<resources>
+ <!-- Screen metrics for logging.
+ 0 = "small phone screen"
+ 1 = "large phone screen"
+ 2 = "large tablet screen"
+ 3 = "small tablet screen"
+ -->
+ <integer name="log_screen_metrics">3</integer>
+</resources>
diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml
index e72e4941e..c2419b639 100644
--- a/java/res/values-sw600dp/config.xml
+++ b/java/res/values-sw600dp/config.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configuration values for Small Tablet Portrait. -->
<resources>
<bool name="config_enable_show_voice_key_option">false</bool>
</resources>
diff --git a/java/res/values-sw768dp-land/config.xml b/java/res/values-sw768dp-land/config.xml
index b3cd7278d..7490e52ce 100644
--- a/java/res/values-sw768dp-land/config.xml
+++ b/java/res/values-sw768dp-land/config.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configuration values for Large Tablet Landscape. -->
<resources>
<bool name="config_use_fullscreen_mode">false</bool>
</resources>
diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml
index 653f5e7d5..47c9b15b5 100644
--- a/java/res/values-sw768dp-land/dimens.xml
+++ b/java/res/values-sw768dp-land/dimens.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configurable dimensions for Large Tablet Landscape. -->
<resources>
<!-- Preferable keyboard height in absolute scale: 58.0mm -->
<!-- This keyboardHeight value should match with keyboard-heights.xml -->
diff --git a/java/res/values-sw768dp/config-screen-metrics.xml b/java/res/values-sw768dp/config-screen-metrics.xml
new file mode 100644
index 000000000..c555cbb9f
--- /dev/null
+++ b/java/res/values-sw768dp/config-screen-metrics.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<resources>
+ <!-- Screen metrics for logging.
+ 0 = "small phone screen"
+ 1 = "large phone screen"
+ 2 = "large tablet screen"
+ 3 = "small tablet screen"
+ -->
+ <integer name="log_screen_metrics">2</integer>
+</resources>
diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml
index a3f5de95b..c11ee809a 100644
--- a/java/res/values-sw768dp/config.xml
+++ b/java/res/values-sw768dp/config.xml
@@ -18,13 +18,13 @@
*/
-->
+<!-- Configuration values for Large Tablet Portrait. -->
<resources>
<bool name="config_enable_show_voice_key_option">false</bool>
<bool name="config_enable_show_option_of_key_preview_popup">false</bool>
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_key_preview_popup">false</bool>
<bool name="config_default_sound_enabled">true</bool>
- <bool name="config_auto_correction_spacebar_led_enabled">false</bool>
<integer name="config_max_more_keys_column">5</integer>
<!--
Configuration for MainKeyboardView
@@ -33,12 +33,4 @@
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
false -->
<bool name="config_show_more_keys_keyboard_at_touched_point">true</bool>
- <!-- Screen metrics for logging.
- 0 = "mdpi phone screen"
- 1 = "hdpi phone screen"
- 2 = "mdpi 11 inch tablet screen"
- 3 = "xhdpi phone screen?"
- 4 = ?
- -->
- <integer name="log_screen_metrics">2</integer>
</resources>
diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml
index 4671aa28b..211a89081 100644
--- a/java/res/values-sw768dp/dimens.xml
+++ b/java/res/values-sw768dp/dimens.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configurable dimensions for Large Tablet Portrait. -->
<resources>
<!-- Preferable keyboard height in absolute scale: 48.0mm -->
<!-- This keyboardHeight value should match with keyboard-heights.xml -->
@@ -80,8 +81,6 @@
<dimen name="suggestion_text_size">22dp</dimen>
<dimen name="more_suggestions_hint_text_size">33dp</dimen>
- <!-- Gesture trail parameters -->
- <dimen name="gesture_trail_width">2.5dp</dimen>
<!-- Gesture floating preview text parameters -->
<dimen name="gesture_floating_preview_text_size">26dp</dimen>
<dimen name="gesture_floating_preview_text_offset">86dp</dimen>
diff --git a/java/res/values/config-dictionary-pack.xml b/java/res/values/config-dictionary-pack.xml
new file mode 100644
index 000000000..d076af452
--- /dev/null
+++ b/java/res/values/config-dictionary-pack.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<!-- Configuration values for Dictionary pack. -->
+<resources>
+ <!-- Settings for the dictionary pack -->
+ <bool name="allow_over_metered">false</bool>
+ <bool name="allow_over_roaming">false</bool>
+ <bool name="dict_downloads_visible_in_download_UI">false</bool>
+ <bool name="metadata_downloads_visible_in_download_UI">false</bool>
+ <bool name="display_notification_for_auto_update">false</bool>
+ <bool name="display_notification_for_user_requested_update">false</bool>
+</resources>
diff --git a/java/res/values/config-screen-metrics.xml b/java/res/values/config-screen-metrics.xml
new file mode 100644
index 000000000..7b9870602
--- /dev/null
+++ b/java/res/values/config-screen-metrics.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<resources>
+ <!-- Screen metrics for logging.
+ 0 = "small phone screen"
+ 1 = "large phone screen"
+ 2 = "large tablet screen"
+ 3 = "small tablet screen"
+ -->
+ <integer name="log_screen_metrics">0</integer>
+</resources>
diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index 669a6612c..e1b1c1616 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -18,12 +18,11 @@
*/
-->
+<!-- Configuration values for Small Phone Portrait. -->
<resources>
<bool name="config_use_fullscreen_mode">false</bool>
<bool name="config_enable_show_voice_key_option">true</bool>
<bool name="config_enable_show_option_of_key_preview_popup">true</bool>
- <!-- TODO: Disable the following configuration for production. -->
- <bool name="config_enable_usability_study_mode_option">true</bool>
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_key_preview_popup">true</bool>
<!-- Default value for next word prediction: after entering a word and a space only, should we look
@@ -119,21 +118,4 @@
<!-- Threshold of the normalized score of the best suggestion for the spell checker to declare
a word to be "recommended" -->
<string name="spellchecker_recommended_threshold_value" translatable="false">0.11</string>
- <!-- Screen metrics for logging.
- 0 = "mdpi phone screen"
- 1 = "hdpi phone screen"
- 2 = "mdpi 11 inch tablet screen"
- 3 = "xhdpi phone screen?"
- 4 = ?
- -->
- <integer name="log_screen_metrics">0</integer>
-
- <!-- Settings for the dictionary pack -->
- <bool name="allow_over_metered">false</bool>
- <bool name="allow_over_roaming">false</bool>
- <bool name="dict_downloads_visible_in_download_UI">false</bool>
- <bool name="metadata_downloads_visible_in_download_UI">false</bool>
- <bool name="display_notification_for_auto_update">false</bool>
- <bool name="display_notification_for_user_requested_update">false</bool>
-
</resources>
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 4588b10eb..02b1380a3 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -18,6 +18,7 @@
*/
-->
+<!-- Configurable dimensions for Small Phone Portrait. -->
<resources>
<!-- Preferable keyboard height in absolute scale: 1.285in -->
<!-- This keyboardHeight value should match with keyboard-heights.xml -->
@@ -80,7 +81,6 @@
<dimen name="more_suggestions_row_height">40dp</dimen>
<dimen name="more_suggestions_bottom_gap">6dp</dimen>
<dimen name="more_suggestions_modal_tolerance">32.0dp</dimen>
- <dimen name="more_suggestions_slide_allowance">16.0dp</dimen>
<integer name="max_more_suggestions_row">6</integer>
<fraction name="min_more_suggestions_width">90%</fraction>
<fraction name="more_suggestions_info_ratio">18%</fraction>
diff --git a/java/res/xml/key_symbols_period.xml b/java/res/xml/key_symbols_period.xml
deleted file mode 100644
index 6efc9dee3..000000000
--- a/java/res/xml/key_symbols_period.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 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.
-*/
--->
-
-<merge
- xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
- <!-- U+2105: "℅" CARE OF
- U+2122: "™" TRADE MARK SIGN
- U+00AE: "®" REGISTERED SIGN
- U+00A9: "©" COPYRIGHT SIGN
- U+00A7: "§" SECTION SIGN
- U+00B6: "¶" PILCROW SIGN
- U+002C: "," COMMA
- U+2022: "•" BULLET -->
- <!-- U+00B0: "°" DEGREE SIGN
- U+2032: "′" PRIME
- U+2033: "″" DOUBLE PRIME
- U+2191: "↑" UPWARDS ARROW
- U+2193: "↓" DOWNWARDS ARROW
- U+2190: "←" LEFTWARDS ARROW
- U+2192: "→" RIGHTWARDS ARROW
- U+2026: "…" HORIZONTAL ELLIPSIS -->
- <!-- U+0394: "Δ" GREEK CAPITAL LETTER DELTA
- U+03A0: "Π" GREEK CAPITAL LETTER PI
- U+03C0: "π" GREEK SMALL LETTER PI -->
- <Key
- latin:keyLabel="."
- latin:keyLabelFlags="hasPopupHint"
- latin:moreKeys="!fixedColumnOrder!8,&#x2105;,&#x2122;,&#x00AE;,&#x00A9;,&#x00A7;,&#x00B6;,\\,,&#x2022;,&#x00B0;,&#x2032;,&#x2033;,&#x2191;,&#x2193;,&#x2190;,&#x2192;,&#x2026;,!text/more_keys_for_bullet,&#x0394;,&#x03A0;,&#x03C0;" />
-</merge>
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index ad5aedf71..39fb0b5be 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -195,7 +195,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
private KeyboardActionListener mListener = KeyboardActionListener.EMPTY_LISTENER;
private Keyboard mKeyboard;
- private int mPhantonSuddenMoveThreshold;
+ private int mPhantomSuddenMoveThreshold;
private final BogusMoveEventDetector mBogusMoveEventDetector = new BogusMoveEventDetector();
private boolean mIsDetectingGesture = false; // per PointerTracker.
@@ -446,8 +446,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i);
tracker.setKeyDetectorInner(keyDetector);
- // Mark that keyboard layout has been changed.
- tracker.mKeyboardLayoutHasBeenChanged = true;
}
final Keyboard keyboard = keyDetector.getKeyboard();
sGestureHandlingEnabledByInputField = !keyboard.mId.passwordInput();
@@ -458,7 +456,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
final int trackersSize = sTrackers.size();
for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i);
- tracker.setReleasedKeyGraphics(tracker.mCurrentKey);
+ tracker.setReleasedKeyGraphics(tracker.getKey());
}
}
@@ -466,10 +464,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
final int trackersSize = sTrackers.size();
for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i);
- if (tracker.isShowingMoreKeysPanel()) {
- tracker.mMoreKeysPanel.dismissMoreKeysPanel();
- tracker.mMoreKeysPanel = null;
- }
+ tracker.dismissMoreKeysPanel();
}
}
@@ -604,6 +599,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
}
mKeyDetector = keyDetector;
mKeyboard = keyDetector.getKeyboard();
+ // Mark that keyboard layout has been changed.
+ mKeyboardLayoutHasBeenChanged = true;
final int keyWidth = mKeyboard.mMostCommonKeyWidth;
final int keyHeight = mKeyboard.mMostCommonKeyHeight;
mGestureStrokeWithPreviewPoints.setKeyboardGeometry(keyWidth, mKeyboard.mOccupiedHeight);
@@ -614,7 +611,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
}
// Keep {@link #mCurrentKey} that comes from previous keyboard.
}
- mPhantonSuddenMoveThreshold = (int)(keyWidth * PHANTOM_SUDDEN_MOVE_THRESHOLD);
+ mPhantomSuddenMoveThreshold = (int)(keyWidth * PHANTOM_SUDDEN_MOVE_THRESHOLD);
mBogusMoveEventDetector.setKeyboardGeometry(keyWidth, keyHeight);
}
@@ -958,6 +955,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
return (mMoreKeysPanel != null);
}
+ private void dismissMoreKeysPanel() {
+ if (isShowingMoreKeysPanel()) {
+ mMoreKeysPanel.dismissMoreKeysPanel();
+ mMoreKeysPanel = null;
+ }
+ }
+
private void onDownEventInternal(final int x, final int y, final long eventTime) {
Key key = onDownKey(x, y, eventTime);
// Key selection by dragging finger is allowed when 1) key selection by dragging finger is
@@ -1134,7 +1138,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
// successive up and down events.
// TODO: Should find a way to balance gesture detection and this hack.
else if (sNeedsPhantomSuddenMoveEventHack
- && getDistance(x, y, lastX, lastY) >= mPhantonSuddenMoveThreshold) {
+ && getDistance(x, y, lastX, lastY) >= mPhantomSuddenMoveThreshold) {
processPhantomSuddenMoveHack(key, x, y, eventTime, oldKey, lastX, lastY);
}
// HACK: On some devices, quick successive proximate touches may be reported as a bogus
@@ -1382,28 +1386,28 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
if (key == null) return;
if (!key.isLongPressEnabled()) return;
// Caveat: Please note that isLongPressEnabled() can be true even if the current key
- // doesn't have its more keys. (e.g. spacebar, globe key)
+ // doesn't have its more keys. (e.g. spacebar, globe key) If we are in the dragging finger
+ // mode, we will disable long press timer of such key.
// We always need to start the long press timer if the key has its more keys regardless of
// whether or not we are in the dragging finger mode.
if (mIsInDraggingFinger && key.getMoreKeys() == null) return;
- final int delay;
- switch (key.getCode()) {
- case Constants.CODE_SHIFT:
- delay = sParams.mLongPressShiftLockTimeout;
- break;
- default:
- final int longpressTimeout = Settings.getInstance().getCurrent().mKeyLongpressTimeout;
- if (mIsInSlidingKeyInput) {
- // We use longer timeout for sliding finger input started from the modifier key.
- delay = longpressTimeout * MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT;
- } else {
- delay = longpressTimeout;
- }
- break;
- }
+
+ final int delay = getLongPressTimeout(key.getCode());
mTimerProxy.startLongPressTimer(this, delay);
}
+ private int getLongPressTimeout(final int code) {
+ if (code == Constants.CODE_SHIFT) {
+ return sParams.mLongPressShiftLockTimeout;
+ }
+ final int longpressTimeout = Settings.getInstance().getCurrent().mKeyLongpressTimeout;
+ if (mIsInSlidingKeyInput) {
+ // We use longer timeout for sliding finger input started from the modifier key.
+ return longpressTimeout * MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT;
+ }
+ return longpressTimeout;
+ }
+
private void detectAndSendKey(final Key key, final int x, final int y, final long eventTime) {
if (key == null) {
callListenerOnCancelInput();
@@ -1422,7 +1426,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
// Don't start key repeat when we are in the dragging finger mode.
if (mIsInDraggingFinger) return;
final int startRepeatCount = 1;
- mTimerProxy.startKeyRepeatTimer(this, startRepeatCount, sParams.mKeyRepeatStartTimeout);
+ startKeyRepeatTimer(startRepeatCount);
}
public void onKeyRepeat(final int code, final int repeatCount) {
@@ -1434,11 +1438,17 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
mCurrentRepeatingKeyCode = code;
mIsDetectingGesture = false;
final int nextRepeatCount = repeatCount + 1;
- mTimerProxy.startKeyRepeatTimer(this, nextRepeatCount, sParams.mKeyRepeatInterval);
+ startKeyRepeatTimer(nextRepeatCount);
callListenerOnPressAndCheckKeyboardLayoutChange(key, repeatCount);
callListenerOnCodeInput(key, code, mKeyX, mKeyY, SystemClock.uptimeMillis());
}
+ private void startKeyRepeatTimer(final int repeatCount) {
+ final int delay =
+ (repeatCount == 1) ? sParams.mKeyRepeatStartTimeout : sParams.mKeyRepeatInterval;
+ mTimerProxy.startKeyRepeatTimer(this, repeatCount, delay);
+ }
+
private void printTouchEvent(final String title, final int x, final int y,
final long eventTime) {
final Key key = mKeyDetector.detectHitKey(x, y);
diff --git a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
index fda97dafc..b75fc37d9 100644
--- a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
+++ b/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
@@ -32,6 +32,10 @@ import java.util.TreeMap;
* A base class of the binary dictionary decoder.
*/
public abstract class AbstractDictDecoder implements DictDecoder {
+ private static final int SUCCESS = 0;
+ private static final int ERROR_CANNOT_READ = 1;
+ private static final int ERROR_WRONG_FORMAT = 2;
+
protected FileHeader readHeader(final DictBuffer dictBuffer)
throws IOException, UnsupportedFormatException {
if (dictBuffer == null) {
@@ -204,4 +208,25 @@ public abstract class AbstractDictDecoder implements DictDecoder {
return readLength;
}
}
+
+ /**
+ * Check whether the header contains the expected information. This is a no-error method,
+ * that will return an error code and never throw a checked exception.
+ * @return an error code, either ERROR_* or SUCCESS.
+ */
+ private int checkHeader() {
+ try {
+ readHeader();
+ } catch (IOException e) {
+ return ERROR_CANNOT_READ;
+ } catch (UnsupportedFormatException e) {
+ return ERROR_WRONG_FORMAT;
+ }
+ return SUCCESS;
+ }
+
+ @Override
+ public boolean hasValidRawBinaryDictionary() {
+ return checkHeader() == SUCCESS;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
index 8a8ceaa8c..17c609fbe 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
@@ -24,12 +24,9 @@ import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
@@ -639,32 +636,10 @@ public final class BinaryDictDecoderUtils {
/**
* Basic test to find out whether the file is a binary dictionary or not.
*
- * Concretely this only tests the magic number.
- *
* @param file The file to test.
* @return true if it's a binary dictionary, false otherwise
*/
public static boolean isBinaryDictionary(final File file) {
- FileInputStream inStream = null;
- try {
- inStream = new FileInputStream(file);
- final ByteBuffer buffer = inStream.getChannel().map(
- FileChannel.MapMode.READ_ONLY, 0, file.length());
- final int version = getFormatVersion(new ByteBufferDictBuffer(buffer));
- return (version >= FormatSpec.MINIMUM_SUPPORTED_VERSION
- && version <= FormatSpec.MAXIMUM_SUPPORTED_VERSION);
- } catch (FileNotFoundException e) {
- return false;
- } catch (IOException e) {
- return false;
- } finally {
- if (inStream != null) {
- try {
- inStream.close();
- } catch (IOException e) {
- // do nothing
- }
- }
- }
+ return FormatSpec.getDictDecoder(file).hasValidRawBinaryDictionary();
}
}
diff --git a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java
index 91543986d..b4838f00f 100644
--- a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java
+++ b/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java
@@ -128,7 +128,8 @@ public interface DictDecoder {
* Opens the dictionary file and makes DictBuffer.
*/
@UsedForTesting
- public void openDictBuffer() throws FileNotFoundException, IOException;
+ public void openDictBuffer() throws FileNotFoundException, IOException,
+ UnsupportedFormatException;
@UsedForTesting
public boolean isDictBufferOpen();
@@ -229,4 +230,9 @@ public interface DictDecoder {
}
public void skipPtNode(final FormatOptions formatOptions);
+
+ /**
+ * @return whether this decoder has a valid binary dictionary that it can decode.
+ */
+ public boolean hasValidRawBinaryDictionary();
}
diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java
index f0fed3fda..8833c35aa 100644
--- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java
+++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java
@@ -103,7 +103,7 @@ public class Ver4DictDecoder extends AbstractDictDecoder {
mDictBuffer = mFrequencyBuffer = null;
}
- protected File getFile(final int fileType) {
+ protected File getFile(final int fileType) throws UnsupportedFormatException {
if (fileType == FILETYPE_TRIE) {
return new File(mDictDirectory,
mDictDirectory.getName() + FormatSpec.TRIE_FILE_EXTENSION);
@@ -122,12 +122,16 @@ public class Ver4DictDecoder extends AbstractDictDecoder {
mDictDirectory.getName() + FormatSpec.SHORTCUT_FILE_EXTENSION
+ FormatSpec.SHORTCUT_CONTENT_ID);
} else {
- throw new RuntimeException("Unsupported kind of file : " + fileType);
+ throw new UnsupportedFormatException("Unsupported kind of file : " + fileType);
}
}
@Override
- public void openDictBuffer() throws FileNotFoundException, IOException {
+ public void openDictBuffer() throws FileNotFoundException, IOException,
+ UnsupportedFormatException {
+ if (!mDictDirectory.isDirectory()) {
+ throw new UnsupportedFormatException("Format 4 dictionary needs a directory");
+ }
mDictBuffer = mBufferFactory.getDictionaryBuffer(getFile(FILETYPE_TRIE));
mFrequencyBuffer = mBufferFactory.getDictionaryBuffer(getFile(FILETYPE_FREQUENCY));
mTerminalAddressTableBuffer = mBufferFactory.getDictionaryBuffer(
diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java
index 65860ee72..883709f83 100644
--- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java
+++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java
@@ -45,7 +45,8 @@ public class Ver4DictUpdater extends Ver4DictDecoder implements DictUpdater {
private final File mFrequencyFile;
@UsedForTesting
- public Ver4DictUpdater(final File dictDirectory, final int factoryType) {
+ public Ver4DictUpdater(final File dictDirectory, final int factoryType)
+ throws UnsupportedFormatException {
// DictUpdater must have an updatable DictBuffer.
super(dictDirectory, ((factoryType & MASK_DICTBUFFER) == USE_BYTEARRAY)
? USE_BYTEARRAY : USE_WRITABLE_BYTEBUFFER);
@@ -664,7 +665,8 @@ public class Ver4DictUpdater extends Ver4DictDecoder implements DictUpdater {
frequencyStream.close();
}
- private void insertTerminalPosition(final int posOfTerminal) throws IOException {
+ private void insertTerminalPosition(final int posOfTerminal) throws IOException,
+ UnsupportedFormatException {
final OutputStream terminalPosStream = new FileOutputStream(
getFile(FILETYPE_TERMINAL_ADDRESS_TABLE), true /* append */);
BinaryDictEncoderUtils.writeUIntToStream(terminalPosStream, posOfTerminal,
@@ -702,7 +704,7 @@ public class Ver4DictUpdater extends Ver4DictDecoder implements DictUpdater {
updater.insertShortcuts(terminalId, shortcuts);
}
- private void openBuffersAndStream() throws IOException {
+ private void openBuffersAndStream() throws IOException, UnsupportedFormatException {
openDictBuffer();
mDictStream = new FileOutputStream(getFile(FILETYPE_TRIE), true /* append */);
}
diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
index 8b948831e..5edac232c 100644
--- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
+++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
@@ -28,6 +28,7 @@ import com.android.inputmethod.latin.ExpandableBinaryDictionary;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.makedict.DictDecoder;
import com.android.inputmethod.latin.makedict.FormatSpec;
+import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils;
@@ -222,6 +223,8 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
UserHistoryDictIOUtils.readDictionaryBinary(dictDecoder, listener);
} catch (IOException e) {
Log.d(TAG, "IOException on opening a bytebuffer", e);
+ } catch (UnsupportedFormatException e) {
+ Log.d(TAG, "Unsupported format, can't read the dictionary", e);
} finally {
if (PROFILE_SAVE_RESTORE) {
final long diff = System.currentTimeMillis() - now;
@@ -291,6 +294,8 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB
UserHistoryDictIOUtils.readDictionaryBinary(dictDecoder, listener);
} catch (IOException e) {
Log.d(TAG, "IOException on opening a bytebuffer", e);
+ } catch (UnsupportedFormatException e) {
+ Log.d(TAG, "Unsupported format, can't read the dictionary", e);
}
}