diff options
Diffstat (limited to 'java')
24 files changed, 235 insertions, 371 deletions
diff --git a/java/res/values-land/config.xml b/java/res/values-land/config.xml index b6ef4a7ad..ade7d002c 100644 --- a/java/res/values-land/config.xml +++ b/java/res/values-land/config.xml @@ -26,50 +26,49 @@ <!-- This config_default_keyboard_height value should match with keyboard-heights.xml --> <dimen name="config_default_keyboard_height">176.0dp</dimen> <fraction name="config_min_keyboard_height">45%p</fraction> + <!-- key_height + key_bottom_gap = config_more_keys_keyboard_key_height --> <dimen name="config_more_keys_keyboard_key_height">44.8dp</dimen> + <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> + <!-- config_more_keys_keyboard_key_height x 1.2 --> + <dimen name="config_more_keys_keyboard_slide_allowance">53.76dp</dimen> <fraction name="config_keyboard_top_padding_gb">1.818%p</fraction> <fraction name="config_keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="config_key_vertical_gap_gb">5.941%p</fraction> <fraction name="config_key_horizontal_gap_gb">0.997%p</fraction> + <!-- config_more_keys_keyboard_key_height x -1.0 --> + <dimen name="config_more_keys_keyboard_vertical_correction_gb">-44.8dp</dimen> + <dimen name="config_key_preview_offset_gb">0.0dp</dimen> <fraction name="config_keyboard_top_padding_holo">2.727%p</fraction> <fraction name="config_keyboard_bottom_padding_holo">0.0%p</fraction> <fraction name="config_key_vertical_gap_holo">5.368%p</fraction> <fraction name="config_key_horizontal_gap_holo">1.020%p</fraction> + <!-- config_more_keys_keyboard_key_height x -0.5 --> + <dimen name="config_more_keys_keyboard_vertical_correction_holo">-22.4dp</dimen> + <dimen name="config_key_preview_offset_holo">1.6dp</dimen> - <!-- left or right padding of label alignment --> - <dimen name="config_key_label_horizontal_padding">8dp</dimen> - + <fraction name="config_key_preview_text_ratio">90%</fraction> <fraction name="config_key_letter_ratio">65%</fraction> <fraction name="config_key_large_letter_ratio">74%</fraction> <fraction name="config_key_label_ratio">40%</fraction> <fraction name="config_key_hint_letter_ratio">30%</fraction> <fraction name="config_key_hint_label_ratio">52%</fraction> <fraction name="config_key_shifted_letter_hint_ratio">40%</fraction> - <fraction name="config_key_preview_text_ratio">90%</fraction> <fraction name="config_language_on_spacebar_text_ratio">40.000%</fraction> - <dimen name="config_key_preview_offset_gb">0.0dp</dimen> + <!-- left or right padding of label alignment --> + <dimen name="config_key_label_horizontal_padding">8dp</dimen> <!-- For 5-row keyboard --> <fraction name="config_key_vertical_gap_5row">3.20%p</fraction> <fraction name="config_key_letter_ratio_5row">78%</fraction> <fraction name="config_key_shifted_letter_hint_ratio_5row">48%</fraction> - <dimen name="config_key_preview_offset_holo">1.6dp</dimen> - <!-- config_more_keys_keyboard_key_height x -0.5 --> - <dimen name="config_more_keys_keyboard_vertical_correction_holo">-22.4dp</dimen> - <dimen name="config_suggestions_strip_height">36dp</dimen> <dimen name="config_more_suggestions_row_height">36dp</dimen> <integer name="config_max_more_suggestions_row">2</integer> <fraction name="config_min_more_suggestions_width">60%</fraction> - <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> - <!-- config_more_keys_keyboard_key_height x 1.2 --> - <dimen name="config_more_keys_keyboard_slide_allowance">53.76dp</dimen> - <!-- config_more_keys_keyboard_key_height x -1.0 --> - <dimen name="config_more_keys_keyboard_vertical_correction_gb">-44.8dp</dimen> <!-- Gesture floating preview text parameters --> <dimen name="config_gesture_floating_preview_text_size">23dp</dimen> diff --git a/java/res/values-sw540dp-land/config.xml b/java/res/values-sw540dp-land/config.xml index 55dcd5145..f4785e721 100644 --- a/java/res/values-sw540dp-land/config.xml +++ b/java/res/values-sw540dp-land/config.xml @@ -27,6 +27,8 @@ <dimen name="config_default_keyboard_height">283.5dp</dimen> <fraction name="config_min_keyboard_height">45%p</fraction> + <dimen name="config_more_keys_keyboard_key_height">81.9dp</dimen> + <fraction name="config_keyboard_top_padding_gb">2.444%p</fraction> <fraction name="config_keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="config_key_vertical_gap_gb">5.200%p</fraction> @@ -37,11 +39,6 @@ <fraction name="config_key_vertical_gap_holo">4.5%p</fraction> <fraction name="config_key_horizontal_gap_holo">0.9%p</fraction> - <dimen name="config_more_keys_keyboard_key_height">81.9dp</dimen> - - <!-- left or right padding of label alignment --> - <dimen name="config_key_label_horizontal_padding">18dp</dimen> - <fraction name="config_key_letter_ratio">50%</fraction> <fraction name="config_key_large_letter_ratio">48%</fraction> <fraction name="config_key_label_ratio">32%</fraction> @@ -49,6 +46,8 @@ <fraction name="config_key_hint_label_ratio">34%</fraction> <fraction name="config_key_shifted_letter_hint_ratio">29%</fraction> <fraction name="config_language_on_spacebar_text_ratio">30.0%</fraction> + <!-- left or right padding of label alignment --> + <dimen name="config_key_label_horizontal_padding">18dp</dimen> <dimen name="config_key_shifted_letter_hint_padding">4dp</dimen> <!-- For 5-row keyboard --> diff --git a/java/res/values-sw540dp/config-per-form-factor.xml b/java/res/values-sw540dp/config-per-form-factor.xml new file mode 100644 index 000000000..7f898e017 --- /dev/null +++ b/java/res/values-sw540dp/config-per-form-factor.xml @@ -0,0 +1,32 @@ +<?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 Large Phone. --> +<resources> + <bool name="config_enable_show_key_preview_popup_option">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_enable_show_voice_key_option">true</bool> + <bool name="config_key_selection_by_dragging_finger">false</bool> + <!-- 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">false</bool> +</resources> diff --git a/java/res/values-sw540dp/config.xml b/java/res/values-sw540dp/config.xml index 09fe7d3bf..8637d6bab 100644 --- a/java/res/values-sw540dp/config.xml +++ b/java/res/values-sw540dp/config.xml @@ -20,16 +20,7 @@ <!-- Configuration values for Large Phone and Small Tablet Portrait. --> <resources> - <bool name="config_enable_show_key_preview_popup_option">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> - <dimen name="config_key_hysteresis_distance">40.0dp</dimen> - <bool name="config_key_selection_by_dragging_finger">false</bool> - <!-- 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">false</bool> <!-- Preferable keyboard height in absolute scale: 48.0mm --> <!-- This config_default_keyboard_height value should match with keyboard-heights.xml --> @@ -38,29 +29,29 @@ <fraction name="config_min_keyboard_height">-35.0%p</fraction> <dimen name="config_more_keys_keyboard_key_height">63.0dp</dimen> + <dimen name="config_more_keys_keyboard_key_horizontal_padding">6dp</dimen> + <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> + <!-- config_more_keys_keyboard_key_height x 1.2 --> + <dimen name="config_more_keys_keyboard_slide_allowance">98.3dp</dimen> <fraction name="config_keyboard_top_padding_gb">2.291%p</fraction> <fraction name="config_keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="config_key_vertical_gap_gb">4.625%p</fraction> <fraction name="config_key_horizontal_gap_gb">2.113%p</fraction> + <!-- config_more_keys_keyboard_key_height x -1.0 --> + <dimen name="config_more_keys_keyboard_vertical_correction_gb">-81.9dp</dimen> + <dimen name="config_key_preview_offset_gb">16.0dp</dimen> <fraction name="config_keyboard_top_padding_holo">2.335%p</fraction> <fraction name="config_keyboard_bottom_padding_holo">4.0%p</fraction> <fraction name="config_key_vertical_gap_holo">4.5%p</fraction> <fraction name="config_key_horizontal_gap_holo">1.565%p</fraction> + <!-- config_more_keys_keyboard_key_height x -0.5 --> + <dimen name="config_more_keys_keyboard_vertical_correction_holo">-31.5dp</dimen> + <dimen name="config_key_preview_offset_holo">8.0dp</dimen> - <dimen name="config_more_keys_keyboard_key_horizontal_padding">6dp</dimen> - <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> - <!-- config_more_keys_keyboard_key_height x 1.2 --> - <dimen name="config_more_keys_keyboard_slide_allowance">98.3dp</dimen> - <!-- config_more_keys_keyboard_key_height x -1.0 --> - <dimen name="config_more_keys_keyboard_vertical_correction_gb">-81.9dp</dimen> - - <!-- left or right padding of label alignment --> - <dimen name="config_key_label_horizontal_padding">6dp</dimen> - <dimen name="config_key_hint_letter_padding">3dp</dimen> - <dimen name="config_key_shifted_letter_hint_padding">3dp</dimen> - + <dimen name="config_key_preview_height">94.5dp</dimen> + <fraction name="config_key_preview_text_ratio">50%</fraction> <fraction name="config_key_letter_ratio">42%</fraction> <fraction name="config_key_large_letter_ratio">45%</fraction> <fraction name="config_key_label_ratio">25%</fraction> @@ -68,20 +59,17 @@ <fraction name="config_key_hint_letter_ratio">23%</fraction> <fraction name="config_key_hint_label_ratio">28%</fraction> <fraction name="config_key_shifted_letter_hint_ratio">22%</fraction> - <fraction name="config_key_preview_text_ratio">50%</fraction> <fraction name="config_language_on_spacebar_text_ratio">28.0%</fraction> - <dimen name="config_key_preview_height">94.5dp</dimen> - <dimen name="config_key_preview_offset_gb">16.0dp</dimen> + <!-- left or right padding of label alignment --> + <dimen name="config_key_label_horizontal_padding">6dp</dimen> + <dimen name="config_key_hint_letter_padding">3dp</dimen> + <dimen name="config_key_shifted_letter_hint_padding">3dp</dimen> <!-- For 5-row keyboard --> <fraction name="config_key_vertical_gap_5row">3.20%p</fraction> <fraction name="config_key_letter_ratio_5row">52%</fraction> <fraction name="config_key_shifted_letter_hint_ratio_5row">27%</fraction> - <dimen name="config_key_preview_offset_holo">8.0dp</dimen> - <!-- config_more_keys_keyboard_key_height x -0.5 --> - <dimen name="config_more_keys_keyboard_vertical_correction_holo">-31.5dp</dimen> - <dimen name="config_suggestions_strip_height">44dp</dimen> <dimen name="config_more_suggestions_row_height">44dp</dimen> <integer name="config_max_more_suggestions_row">6</integer> diff --git a/java/res/values-sw600dp/config-per-form-factor.xml b/java/res/values-sw600dp/config-per-form-factor.xml new file mode 100644 index 000000000..1c7e677a9 --- /dev/null +++ b/java/res/values-sw600dp/config-per-form-factor.xml @@ -0,0 +1,32 @@ +<?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 Small Tablet. --> +<resources> + <bool name="config_enable_show_key_preview_popup_option">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_enable_show_voice_key_option">false</bool> + <bool name="config_key_selection_by_dragging_finger">false</bool> + <!-- 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">false</bool> +</resources> diff --git a/java/res/values-sw768dp-land/config.xml b/java/res/values-sw768dp-land/config.xml index b27d4c057..b97872f54 100644 --- a/java/res/values-sw768dp-land/config.xml +++ b/java/res/values-sw768dp-land/config.xml @@ -36,12 +36,11 @@ <fraction name="config_keyboard_bottom_padding_holo">0.0%p</fraction> <fraction name="config_key_vertical_gap_holo">3.690%p</fraction> <fraction name="config_key_horizontal_gap_holo">1.030%p</fraction> + <dimen name="config_key_preview_offset_holo">8.0dp</dimen> <dimen name="config_more_keys_keyboard_key_height">81.9dp</dimen> - <!-- left or right padding of label alignment --> - <dimen name="config_key_label_horizontal_padding">18dp</dimen> - + <dimen name="config_key_preview_height">107.1dp</dimen> <fraction name="config_key_letter_ratio">43%</fraction> <fraction name="config_key_large_letter_ratio">42%</fraction> <fraction name="config_key_label_ratio">28%</fraction> @@ -49,15 +48,14 @@ <fraction name="config_key_hint_label_ratio">28%</fraction> <fraction name="config_key_shifted_letter_hint_ratio">24%</fraction> <fraction name="config_language_on_spacebar_text_ratio">24.00%</fraction> - <dimen name="config_key_preview_height">107.1dp</dimen> + <!-- left or right padding of label alignment --> + <dimen name="config_key_label_horizontal_padding">18dp</dimen> <!-- For 5-row keyboard --> <fraction name="config_key_vertical_gap_5row">2.65%p</fraction> <fraction name="config_key_letter_ratio_5row">53%</fraction> <fraction name="config_key_shifted_letter_hint_ratio_5row">30%</fraction> - <dimen name="config_key_preview_offset_holo">8.0dp</dimen> - <dimen name="config_suggestions_strip_horizontal_padding">252.0dp</dimen> <fraction name="config_min_more_suggestions_width">50%</fraction> diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw768dp/config-per-form-factor.xml index c2419b639..136f41567 100644 --- a/java/res/values-sw600dp/config.xml +++ b/java/res/values-sw768dp/config-per-form-factor.xml @@ -18,7 +18,15 @@ */ --> -<!-- Configuration values for Small Tablet Portrait. --> +<!-- Configuration values for Large Tablet. --> <resources> + <bool name="config_enable_show_key_preview_popup_option">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_enable_show_voice_key_option">false</bool> + <bool name="config_key_selection_by_dragging_finger">false</bool> + <!-- 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> </resources> diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml index b63b509d5..33286c686 100644 --- a/java/res/values-sw768dp/config.xml +++ b/java/res/values-sw768dp/config.xml @@ -20,17 +20,6 @@ <!-- Configuration values for Large Tablet Portrait. --> <resources> - <bool name="config_enable_show_voice_key_option">false</bool> - <bool name="config_enable_show_key_preview_popup_option">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_key_selection_by_dragging_finger">false</bool> - <!-- 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> - <!-- Preferable keyboard height in absolute scale: 48.0mm --> <!-- This config_default_keyboard_height value should match with keyboard-heights.xml --> <dimen name="config_default_keyboard_height">302.4dp</dimen> @@ -41,26 +30,26 @@ <fraction name="config_keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="config_key_vertical_gap_gb">4.687%p</fraction> <fraction name="config_key_horizontal_gap_gb">1.272%p</fraction> + <!-- config_more_keys_keyboard_key_height x -1.0 --> + <dimen name="config_more_keys_keyboard_vertical_correction_gb">-81.9dp</dimen> + <dimen name="config_key_preview_offset_gb">16.0dp</dimen> <fraction name="config_keyboard_top_padding_holo">2.335%p</fraction> <fraction name="config_keyboard_bottom_padding_holo">0.0%p</fraction> <fraction name="config_key_vertical_gap_holo">3.312%p</fraction> <fraction name="config_key_horizontal_gap_holo">1.066%p</fraction> + <!-- config_more_keys_keyboard_key_height x -0.5 --> + <dimen name="config_more_keys_keyboard_vertical_correction_holo">-31.5dp</dimen> + <dimen name="config_key_preview_offset_holo">8.0dp</dimen> <dimen name="config_more_keys_keyboard_key_height">63.0dp</dimen> - <dimen name="config_more_keys_keyboard_key_horizontal_padding">12dp</dimen> <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> <!-- config_more_keys_keyboard_key_height x 1.2 --> <dimen name="config_more_keys_keyboard_slide_allowance">98.3dp</dimen> - <!-- config_more_keys_keyboard_key_height x -1.0 --> - <dimen name="config_more_keys_keyboard_vertical_correction_gb">-81.9dp</dimen> - - <!-- left or right padding of label alignment --> - <dimen name="config_key_label_horizontal_padding">6dp</dimen> - <dimen name="config_key_hint_letter_padding">3dp</dimen> - <dimen name="config_key_shifted_letter_hint_padding">3dp</dimen> + <dimen name="config_key_preview_height">94.5dp</dimen> + <fraction name="config_key_preview_text_ratio">50%</fraction> <fraction name="config_key_letter_ratio">40%</fraction> <fraction name="config_key_large_letter_ratio">42%</fraction> <fraction name="config_key_label_ratio">28%</fraction> @@ -68,20 +57,17 @@ <fraction name="config_key_hint_letter_ratio">23%</fraction> <fraction name="config_key_hint_label_ratio">28%</fraction> <fraction name="config_key_shifted_letter_hint_ratio">26%</fraction> - <fraction name="config_key_preview_text_ratio">50%</fraction> <fraction name="config_language_on_spacebar_text_ratio">29.03%</fraction> - <dimen name="config_key_preview_height">94.5dp</dimen> - <dimen name="config_key_preview_offset_gb">16.0dp</dimen> + <!-- left or right padding of label alignment --> + <dimen name="config_key_label_horizontal_padding">6dp</dimen> + <dimen name="config_key_hint_letter_padding">3dp</dimen> + <dimen name="config_key_shifted_letter_hint_padding">3dp</dimen> <!-- For 5-row keyboard --> <fraction name="config_key_vertical_gap_5row">2.95%p</fraction> <fraction name="config_key_letter_ratio_5row">51%</fraction> <fraction name="config_key_shifted_letter_hint_ratio_5row">33%</fraction> - <dimen name="config_key_preview_offset_holo">8.0dp</dimen> - <!-- config_more_keys_keyboard_key_height x -0.5 --> - <dimen name="config_more_keys_keyboard_vertical_correction_holo">-31.5dp</dimen> - <dimen name="config_suggestions_strip_height">44dp</dimen> <dimen name="config_more_suggestions_row_height">44dp</dimen> <integer name="config_max_more_suggestions_row">6</integer> diff --git a/java/res/values/config-per-form-factor.xml b/java/res/values/config-per-form-factor.xml new file mode 100644 index 000000000..67fc75134 --- /dev/null +++ b/java/res/values/config-per-form-factor.xml @@ -0,0 +1,32 @@ +<?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 Small Phone. --> +<resources> + <bool name="config_enable_show_key_preview_popup_option">true</bool> + <!-- Whether or not Popup on key press is enabled by default --> + <bool name="config_default_key_preview_popup">true</bool> + <bool name="config_default_sound_enabled">false</bool> + <bool name="config_enable_show_voice_key_option">true</bool> + <bool name="config_key_selection_by_dragging_finger">true</bool> + <!-- 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">false</bool> +</resources> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 698efa923..e64b4b192 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -21,17 +21,8 @@ <!-- 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_key_preview_popup_option">true</bool> - <!-- Whether or not Popup on key press is enabled by default --> - <bool name="config_default_key_preview_popup">true</bool> - <bool name="config_default_sound_enabled">false</bool> <dimen name="config_key_hysteresis_distance">8.0dp</dimen> - <bool name="config_key_selection_by_dragging_finger">true</bool> - <!-- 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">false</bool> <!-- Preferable keyboard height in absolute scale: 1.285in --> <!-- This config_default_keyboard_height value should match with keyboard-heights.xml --> @@ -40,25 +31,29 @@ <fraction name="config_min_keyboard_height">-61.8%p</fraction> <dimen name="config_more_keys_keyboard_key_height">52.8dp</dimen> - + <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> + <!-- config_more_keys_keyboard_key_height x 1.2 --> + <dimen name="config_more_keys_keyboard_slide_allowance">63.36dp</dimen> <dimen name="config_more_keys_keyboard_key_horizontal_padding">8dp</dimen> <fraction name="config_keyboard_top_padding_gb">1.556%p</fraction> <fraction name="config_keyboard_bottom_padding_gb">4.669%p</fraction> <fraction name="config_key_vertical_gap_gb">6.495%p</fraction> <fraction name="config_key_horizontal_gap_gb">1.971%p</fraction> + <!-- config_more_keys_keyboard_key_height x -1.0 --> + <dimen name="config_more_keys_keyboard_vertical_correction_gb">-52.8dp</dimen> + <dimen name="config_key_preview_offset_gb">-8.0dp</dimen> <fraction name="config_keyboard_top_padding_holo">2.335%p</fraction> <fraction name="config_keyboard_bottom_padding_holo">4.669%p</fraction> <fraction name="config_key_vertical_gap_holo">6.127%p</fraction> <fraction name="config_key_horizontal_gap_holo">1.739%p</fraction> + <!-- config_more_keys_keyboard_key_height x -0.5 --> + <dimen name="config_more_keys_keyboard_vertical_correction_holo">-26.4dp</dimen> + <dimen name="config_key_preview_offset_holo">8.0dp</dimen> - <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> - <!-- config_more_keys_keyboard_key_height x 1.2 --> - <dimen name="config_more_keys_keyboard_slide_allowance">63.36dp</dimen> - <!-- config_more_keys_keyboard_key_height x -1.0 --> - <dimen name="config_more_keys_keyboard_vertical_correction_gb">-52.8dp</dimen> - + <dimen name="config_key_preview_height">80dp</dimen> + <fraction name="config_key_preview_text_ratio">82%</fraction> <fraction name="config_key_letter_ratio">55%</fraction> <fraction name="config_key_large_letter_ratio">65%</fraction> <fraction name="config_key_label_ratio">34%</fraction> @@ -66,11 +61,7 @@ <fraction name="config_key_hint_letter_ratio">25%</fraction> <fraction name="config_key_hint_label_ratio">44%</fraction> <fraction name="config_key_shifted_letter_hint_ratio">35%</fraction> - <fraction name="config_key_preview_text_ratio">82%</fraction> <fraction name="config_language_on_spacebar_text_ratio">33.735%</fraction> - <dimen name="config_key_preview_height">80dp</dimen> - <dimen name="config_key_preview_offset_gb">-8.0dp</dimen> - <dimen name="config_key_label_horizontal_padding">4dp</dimen> <dimen name="config_key_hint_letter_padding">1dp</dimen> <dimen name="config_key_shifted_letter_hint_padding">2dp</dimen> @@ -80,10 +71,6 @@ <fraction name="config_key_letter_ratio_5row">64%</fraction> <fraction name="config_key_shifted_letter_hint_ratio_5row">41%</fraction> - <dimen name="config_key_preview_offset_holo">8.0dp</dimen> - <!-- config_more_keys_keyboard_key_height x -0.5 --> - <dimen name="config_more_keys_keyboard_vertical_correction_holo">-26.4dp</dimen> - <dimen name="config_suggestions_strip_height">40dp</dimen> <dimen name="config_more_suggestions_row_height">40dp</dimen> <integer name="config_max_more_suggestions_row">6</integer> diff --git a/java/src/com/android/inputmethod/latin/DictionaryWriter.java b/java/src/com/android/inputmethod/latin/DictionaryWriter.java index f960c5343..89ef96d7f 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryWriter.java +++ b/java/src/com/android/inputmethod/latin/DictionaryWriter.java @@ -18,8 +18,6 @@ package com.android.inputmethod.latin; import android.content.Context; -import com.android.inputmethod.keyboard.ProximityInfo; -import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; @@ -52,7 +50,7 @@ public class DictionaryWriter extends AbstractDictionaryWriter { public void clear() { final HashMap<String, String> attributes = CollectionUtils.newHashMap(); mFusionDictionary = new FusionDictionary(new PtNodeArray(), - new FusionDictionary.DictionaryOptions(attributes, false, false)); + new FusionDictionary.DictionaryOptions(attributes)); } /** diff --git a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java index bbbb8e461..f8fa68f45 100644 --- a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java @@ -58,12 +58,9 @@ public abstract class AbstractDictDecoder implements DictDecoder { headerSize); final FileHeader header = new FileHeader(headerSize, - new FusionDictionary.DictionaryOptions(attributes, - 0 != (optionsFlags & FormatSpec.GERMAN_UMLAUT_PROCESSING_FLAG), - 0 != (optionsFlags & FormatSpec.FRENCH_LIGATURE_PROCESSING_FLAG)), - new FormatOptions(version, - 0 != (optionsFlags & FormatSpec.SUPPORTS_DYNAMIC_UPDATE), - 0 != (optionsFlags & FormatSpec.CONTAINS_TIMESTAMP_FLAG))); + new FusionDictionary.DictionaryOptions(attributes), + new FormatOptions(version, + 0 != (optionsFlags & FormatSpec.CONTAINS_TIMESTAMP_FLAG))); return header; } diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java index 83ee7d685..7f0aa777f 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java @@ -330,7 +330,7 @@ public final class BinaryDictDecoderUtils { static int readChildrenAddress(final DictBuffer dictBuffer, final int optionFlags, final FormatOptions options) { - if (options.mSupportsDynamicUpdate) { + if (options.supportsDynamicUpdate()) { final int address = dictBuffer.readUnsignedInt24(); if (address == 0) return FormatSpec.NO_CHILDREN_ADDRESS; if ((address & FormatSpec.MSB24) != 0) { @@ -540,11 +540,11 @@ public final class BinaryDictDecoderUtils { } // reach the end of the array. - if (options.mSupportsDynamicUpdate) { + if (options.supportsDynamicUpdate()) { final boolean hasValidForwardLink = dictDecoder.readAndFollowForwardLink(); if (!hasValidForwardLink) break; } - } while (options.mSupportsDynamicUpdate && dictDecoder.hasNextPtNodeArray()); + } while (options.supportsDynamicUpdate() && dictDecoder.hasNextPtNodeArray()); final PtNodeArray nodeArray = new PtNodeArray(nodeArrayContents); nodeArray.mCachedAddressBeforeUpdate = nodeArrayOriginPos; diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java index c0dad3db2..8ba0797de 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java @@ -20,7 +20,6 @@ import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.CharEncodin import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; -import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; @@ -161,7 +160,7 @@ public class BinaryDictEncoderUtils { node.mCachedSize = nodeSize; size += nodeSize; } - if (options.mSupportsDynamicUpdate) { + if (options.supportsDynamicUpdate()) { size += FormatSpec.FORWARD_LINK_ADDRESS_SIZE; } ptNodeArray.mCachedSize = size; @@ -398,7 +397,7 @@ public class BinaryDictEncoderUtils { nodeSize += FormatSpec.PTNODE_FREQUENCY_SIZE; } } - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { nodeSize += FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE; } else if (null != ptNode.mChildren) { nodeSize += getByteSize(getOffsetToTargetNodeArrayDuringUpdate(ptNodeArray, @@ -418,7 +417,7 @@ public class BinaryDictEncoderUtils { ptNode.mCachedSize = nodeSize; size += nodeSize; } - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { size += FormatSpec.FORWARD_LINK_ADDRESS_SIZE; } if (ptNodeArray.mCachedSize != size) { @@ -534,7 +533,7 @@ public class BinaryDictEncoderUtils { if (passes > MAX_PASSES) throw new RuntimeException("Too many passes - probably a bug"); } while (changesDone); - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { computeParentAddresses(flatNodes); } final PtNodeArray lastPtNodeArray = flatNodes.get(flatNodes.size() - 1); @@ -643,7 +642,7 @@ public class BinaryDictEncoderUtils { byte flags = 0; if (hasMultipleChars) flags |= FormatSpec.FLAG_HAS_MULTIPLE_CHARS; if (isTerminal) flags |= FormatSpec.FLAG_IS_TERMINAL; - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { flags |= FormatSpec.FLAG_IS_NOT_MOVED; } else if (true) { switch (childrenAddressSize) { @@ -755,16 +754,11 @@ public class BinaryDictEncoderUtils { } /** - * Makes the 2-byte value for options flags. + * Makes the 2-byte value for options flags. Unused at the moment, and always 0. */ - private static final int makeOptionsValue(final FusionDictionary dictionary, - final FormatOptions formatOptions) { - final DictionaryOptions options = dictionary.mOptions; - final boolean hasBigrams = dictionary.hasBigrams(); - return (options.mFrenchLigatureProcessing ? FormatSpec.FRENCH_LIGATURE_PROCESSING_FLAG : 0) - + (options.mGermanUmlautProcessing ? FormatSpec.GERMAN_UMLAUT_PROCESSING_FLAG : 0) - + (hasBigrams ? FormatSpec.CONTAINS_BIGRAMS_FLAG : 0) - + (formatOptions.mSupportsDynamicUpdate ? FormatSpec.SUPPORTS_DYNAMIC_UPDATE : 0); + private static final int makeOptionsValue(final FormatOptions formatOptions) { + // TODO: why doesn't this handle CONTAINS_TIMESTAMP_FLAG? + return 0; } /** @@ -852,7 +846,7 @@ public class BinaryDictEncoderUtils { } dictEncoder.writePtNode(ptNode, parentPosition, formatOptions, dict); } - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { dictEncoder.writeForwardLinkAddress(FormatSpec.NO_FORWARD_LINK_ADDRESS); } if (dictEncoder.getPosition() != ptNodeArray.mCachedAddressAfterUpdate @@ -953,7 +947,7 @@ public class BinaryDictEncoderUtils { headerBuffer.write((byte) (0xFF & version)); // Options flags - final int options = makeOptionsValue(dict, formatOptions); + final int options = makeOptionsValue(formatOptions); headerBuffer.write((byte) (0xFF & (options >> 8))); headerBuffer.write((byte) (0xFF & options)); final int headerSizeOffset = headerBuffer.size(); diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index 86ebf5844..640d778bb 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -112,7 +112,7 @@ public final class BinaryDictIOUtils { } if (p.mPosition == p.mNumOfPtNode) { - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { final boolean hasValidForwardLinkAddress = dictDecoder.readAndFollowForwardLink(); if (hasValidForwardLinkAddress && dictDecoder.hasNextPtNodeArray()) { @@ -228,7 +228,7 @@ public final class BinaryDictIOUtils { // a forward link address that we need to consult and possibly resume // search on the next node array in the linked list. if (foundNextPtNode) break; - if (!header.mFormatOptions.mSupportsDynamicUpdate) { + if (!header.mFormatOptions.supportsDynamicUpdate()) { return FormatSpec.NOT_VALID_WORD; } @@ -507,7 +507,7 @@ public final class BinaryDictIOUtils { * Helper method to check whether the node is moved. */ public static boolean isMovedPtNode(final int flags, final FormatOptions options) { - return options.mSupportsDynamicUpdate + return options.supportsDynamicUpdate() && ((flags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) == FormatSpec.FLAG_IS_MOVED); } @@ -516,14 +516,14 @@ public final class BinaryDictIOUtils { */ public static boolean supportsDynamicUpdate(final FormatOptions options) { return options.mVersion >= FormatSpec.FIRST_VERSION_WITH_DYNAMIC_UPDATE - && options.mSupportsDynamicUpdate; + && options.supportsDynamicUpdate(); } /** * Helper method to check whether the node is deleted. */ public static boolean isDeletedPtNode(final int flags, final FormatOptions formatOptions) { - return formatOptions.mSupportsDynamicUpdate + return formatOptions.supportsDynamicUpdate() && ((flags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) == FormatSpec.FLAG_IS_DELETED); } @@ -546,7 +546,7 @@ public final class BinaryDictIOUtils { static int getChildrenAddressSize(final int optionFlags, final FormatOptions formatOptions) { - if (formatOptions.mSupportsDynamicUpdate) return FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE; + if (formatOptions.supportsDynamicUpdate()) return FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE; switch (optionFlags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) { case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE: return 1; diff --git a/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java index 971b4ff9f..ff03190a3 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java @@ -61,7 +61,7 @@ public final class DynamicBinaryDictIOUtils { final DictBuffer dictBuffer = dictUpdater.getDictBuffer(); final int originalPosition = dictBuffer.position(); dictBuffer.position(ptNodeOriginAddress); - if (!formatOptions.mSupportsDynamicUpdate) { + if (!formatOptions.supportsDynamicUpdate()) { throw new RuntimeException("this file format does not support parent addresses"); } final int flags = dictBuffer.readUnsignedByte(); @@ -102,7 +102,7 @@ public final class DynamicBinaryDictIOUtils { } if (!dictUpdater.readAndFollowForwardLink()) break; if (dictUpdater.getPosition() == FormatSpec.NO_FORWARD_LINK_ADDRESS) break; - } while (formatOptions.mSupportsDynamicUpdate); + } while (formatOptions.supportsDynamicUpdate()); dictUpdater.setPosition(originalPosition); } diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java index 846aacf11..20ddba836 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java @@ -40,12 +40,8 @@ public final class FormatSpec { * p | not used 3 bits * t | each unigram and bigram entry has a time stamp? * i | 1 bit, 1 = yes, 0 = no : CONTAINS_TIMESTAMP_FLAG - * o | has bigrams ? 1 bit, 1 = yes, 0 = no : CONTAINS_BIGRAMS_FLAG - * n | FRENCH_LIGATURE_PROCESSING_FLAG - * f | supports dynamic updates ? 1 bit, 1 = yes, 0 = no : SUPPORTS_DYNAMIC_UPDATE - * l | GERMAN_UMLAUT_PROCESSING_FLAG - * a | - * gs + * o | + * nflags * * h | * e | size of the file header, 4bytes @@ -82,45 +78,36 @@ public final class FormatSpec { * s * * f | - * o | IF SUPPORTS_DYNAMIC_UPDATE (defined in the file header) - * r | forward link address, 3byte - * w | 1 byte = bbbbbbbb match - * a | case 1xxxxxxx => -((xxxxxxx << 16) + (next byte << 8) + next byte) - * r | otherwise => (xxxxxxx << 16) + (next byte << 8) + next byte - * d | - * linkaddress + * o | forward link address, 3byte + * r | 1 byte = bbbbbbbb match + * w | case 1xxxxxxx => -((xxxxxxx << 16) + (next byte << 8) + next byte) + * a | otherwise => (xxxxxxx << 16) + (next byte << 8) + next byte + * r | + * dlinkaddress */ /* Node (FusionDictionary.PtNode) layout is as follows: - * | IF !SUPPORTS_DYNAMIC_UPDATE - * | addressType xx : mask with MASK_CHILDREN_ADDRESS_TYPE - * | 2 bits, 00 = no children : FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS - * f | 01 = 1 byte : FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE - * l | 10 = 2 bytes : FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES - * a | 11 = 3 bytes : FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES - * g | ELSE - * s | is moved ? 2 bits, 11 = no : FLAG_IS_NOT_MOVED - * | This must be the same as FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES - * | 01 = yes : FLAG_IS_MOVED - * | the new address is stored in the same place as the parent address - * | is deleted? 10 = yes : FLAG_IS_DELETED - * | has several chars ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_MULTIPLE_CHARS - * | has a terminal ? 1 bit, 1 = yes, 0 = no : FLAG_IS_TERMINAL - * | has shortcut targets ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_SHORTCUT_TARGETS + * | is moved ? 2 bits, 11 = no : FLAG_IS_NOT_MOVED + * | This must be the same as FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES + * | 01 = yes : FLAG_IS_MOVED + * f | the new address is stored in the same place as the parent address + * l | is deleted? 10 = yes : FLAG_IS_DELETED + * a | has several chars ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_MULTIPLE_CHARS + * g | has a terminal ? 1 bit, 1 = yes, 0 = no : FLAG_IS_TERMINAL + * s | has shortcut targets ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_SHORTCUT_TARGETS * | has bigrams ? 1 bit, 1 = yes, 0 = no : FLAG_HAS_BIGRAMS * | is not a word ? 1 bit, 1 = yes, 0 = no : FLAG_IS_NOT_A_WORD * | is blacklisted ? 1 bit, 1 = yes, 0 = no : FLAG_IS_BLACKLISTED * * p | - * a | IF SUPPORTS_DYNAMIC_UPDATE (defined in the file header) - * r | parent address, 3byte - * e | 1 byte = bbbbbbbb match - * n | case 1xxxxxxx => -((0xxxxxxx << 16) + (next byte << 8) + next byte) - * t | otherwise => (bbbbbbbb << 16) + (next byte << 8) + next byte - * a | This address is relative to the head of the PtNode. - * d | If the node doesn't have a parent, this field is set to 0. + * a | parent address, 3byte + * r | 1 byte = bbbbbbbb match + * e | case 1xxxxxxx => -((0xxxxxxx << 16) + (next byte << 8) + next byte) + * n | otherwise => (bbbbbbbb << 16) + (next byte << 8) + next byte + * t | This address is relative to the head of the PtNode. + * a | If the node doesn't have a parent, this field is set to 0. * d | - * ress + * dress * * c | IF FLAG_HAS_MULTIPLE_CHARS * h | char, char, char, char n * (1 or 3 bytes) : use PtNodeInfo for i/o helpers @@ -134,23 +121,16 @@ public final class FormatSpec { * e | frequency 1 byte * q | * - * c | IF SUPPORTS_DYNAMIC_UPDATE - * h | children address, 3 bytes - * i | 1 byte = bbbbbbbb match - * l | case 1xxxxxxx => -((0xxxxxxx << 16) + (next byte << 8) + next byte) - * d | otherwise => (bbbbbbbb<<16) + (next byte << 8) + next byte - * r | if this node doesn't have children, this field is set to 0. - * e | (see BinaryDictEncoderUtils#writeVariableSignedAddress) - * n | ELSIF 00 = FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS == addressType - * a | // nothing - * d | ELSIF 01 = FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE == addressType - * d | children address, 1 byte - * r | ELSIF 10 = FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES == addressType - * e | children address, 2 bytes - * s | ELSE // 11 = FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES = addressType - * s | children address, 3 bytes - * | END - * | This address is relative to the position of this field. + * c | + * h | children address, 3 bytes + * i | 1 byte = bbbbbbbb match + * l | case 1xxxxxxx => -((0xxxxxxx << 16) + (next byte << 8) + next byte) + * d | otherwise => (bbbbbbbb<<16) + (next byte << 8) + next byte + * r | if this node doesn't have children, this field is set to 0. + * e | (see BinaryDictEncoderUtils#writeVariableSignedAddress) + * n | This address is relative to the position of this field. + * a | + * ddress * * | IF FLAG_IS_TERMINAL && FLAG_HAS_SHORTCUT_TARGETS * | shortcut string list @@ -214,11 +194,7 @@ public final class FormatSpec { static final int MAXIMUM_SUPPORTED_VERSION = VERSION4; // These options need to be the same numeric values as the one in the native reading code. - static final int GERMAN_UMLAUT_PROCESSING_FLAG = 0x1; // TODO: Make the native reading code read this variable. - static final int SUPPORTS_DYNAMIC_UPDATE = 0x2; - static final int FRENCH_LIGATURE_PROCESSING_FLAG = 0x4; - static final int CONTAINS_BIGRAMS_FLAG = 0x8; static final int CONTAINS_TIMESTAMP_FLAG = 0x10; // TODO: Make this value adaptative to content data, store it in the header, and @@ -339,30 +315,23 @@ public final class FormatSpec { */ public static final class FormatOptions { public final int mVersion; - public final boolean mSupportsDynamicUpdate; public final boolean mHasTerminalId; public final boolean mHasTimestamp; - @UsedForTesting - public FormatOptions(final int version) { - this(version, false); - } @UsedForTesting - public FormatOptions(final int version, final boolean supportsDynamicUpdate) { - this(version, supportsDynamicUpdate, false /* hasTimestamp */); + public FormatOptions(final int version) { + this(version, false /* hasTimestamp */); } - public FormatOptions(final int version, final boolean supportsDynamicUpdate, - final boolean hasTimestamp) { + public FormatOptions(final int version, final boolean hasTimestamp) { mVersion = version; - if (version < FIRST_VERSION_WITH_DYNAMIC_UPDATE && supportsDynamicUpdate) { - throw new RuntimeException("Dynamic updates are only supported with versions " - + FIRST_VERSION_WITH_DYNAMIC_UPDATE + " and ulterior."); - } - mSupportsDynamicUpdate = supportsDynamicUpdate; mHasTerminalId = (version >= FIRST_VERSION_WITH_TERMINAL_ID); mHasTimestamp = hasTimestamp; } + + public boolean supportsDynamicUpdate() { + return mVersion >= FIRST_VERSION_WITH_DYNAMIC_UPDATE; + } } /** @@ -374,7 +343,6 @@ public final class FormatSpec { public final FormatOptions mFormatOptions; // Note that these are corresponding definitions in native code in latinime::HeaderPolicy // and latinime::HeaderReadWriteUtils. - public static final String SUPPORTS_DYNAMIC_UPDATE_ATTRIBUTE = "SUPPORTS_DYNAMIC_UPDATE"; public static final String USES_FORGETTING_CURVE_ATTRIBUTE = "USES_FORGETTING_CURVE"; public static final String HAS_HISTORICAL_INFO_ATTRIBUTE = "HAS_HISTORICAL_INFO"; public static final String ATTRIBUTE_VALUE_TRUE = "1"; diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index 3bb218bea..fdf2ae7b5 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java @@ -303,14 +303,9 @@ public final class FusionDictionary implements Iterable<Word> { * Options global to the dictionary. */ public static final class DictionaryOptions { - public final boolean mGermanUmlautProcessing; - public final boolean mFrenchLigatureProcessing; public final HashMap<String, String> mAttributes; - public DictionaryOptions(final HashMap<String, String> attributes, - final boolean germanUmlautProcessing, final boolean frenchLigatureProcessing) { + public DictionaryOptions(final HashMap<String, String> attributes) { mAttributes = attributes; - mGermanUmlautProcessing = germanUmlautProcessing; - mFrenchLigatureProcessing = frenchLigatureProcessing; } @Override public String toString() { // Convenience method @@ -339,14 +334,6 @@ public final class FusionDictionary implements Iterable<Word> { } s.append("\n"); } - if (mGermanUmlautProcessing) { - s.append(indent); - s.append("Needs German umlaut processing\n"); - } - if (mFrenchLigatureProcessing) { - s.append(indent); - s.append("Needs French ligature processing\n"); - } return s.toString(); } } @@ -701,138 +688,6 @@ public final class FusionDictionary implements Iterable<Word> { } /** - * Recursively count the number of nodes in a given branch of the trie. - * - * @param nodeArray the node array to count. - * @return the number of nodes in this branch. - */ - public static int countNodeArrays(final PtNodeArray nodeArray) { - int size = 1; - for (int i = nodeArray.mData.size() - 1; i >= 0; --i) { - PtNode ptNode = nodeArray.mData.get(i); - if (null != ptNode.mChildren) - size += countNodeArrays(ptNode.mChildren); - } - return size; - } - - // Recursively find out whether there are any bigrams. - // This can be pretty expensive especially if there aren't any (we return as soon - // as we find one, so it's much cheaper if there are bigrams) - private static boolean hasBigramsInternal(final PtNodeArray nodeArray) { - if (null == nodeArray) return false; - for (int i = nodeArray.mData.size() - 1; i >= 0; --i) { - PtNode ptNode = nodeArray.mData.get(i); - if (null != ptNode.mBigrams) return true; - if (hasBigramsInternal(ptNode.mChildren)) return true; - } - return false; - } - - /** - * Finds out whether there are any bigrams in this dictionary. - * - * @return true if there is any bigram, false otherwise. - */ - // TODO: this is expensive especially for large dictionaries without any bigram. - // The up side is, this is always accurate and correct and uses no memory. We should - // find a more efficient way of doing this, without compromising too much on memory - // and ease of use. - public boolean hasBigrams() { - return hasBigramsInternal(mRootNodeArray); - } - - // Historically, the tails of the words were going to be merged to save space. - // However, that would prevent the code to search for a specific address in log(n) - // time so this was abandoned. - // The code is still of interest as it does add some compression to any dictionary - // that has no need for attributes. Implementations that does not read attributes should be - // able to read a dictionary with merged tails. - // Also, the following code does support frequencies, as in, it will only merges - // tails that share the same frequency. Though it would result in the above loss of - // performance while searching by address, it is still technically possible to merge - // tails that contain attributes, but this code does not take that into account - it does - // not compare attributes and will merge terminals with different attributes regardless. - public void mergeTails() { - MakedictLog.i("Do not merge tails"); - return; - -// MakedictLog.i("Merging PtNodes. Number of PtNodes : " + countPtNodes(root)); -// MakedictLog.i("Number of PtNodes : " + countPtNodes(root)); -// -// final HashMap<String, ArrayList<PtNodeArray>> repository = -// new HashMap<String, ArrayList<PtNodeArray>>(); -// mergeTailsInner(repository, root); -// -// MakedictLog.i("Number of different pseudohashes : " + repository.size()); -// int size = 0; -// for (ArrayList<PtNodeArray> a : repository.values()) { -// size += a.size(); -// } -// MakedictLog.i("Number of nodes after merge : " + (1 + size)); -// MakedictLog.i("Recursively seen nodes : " + countNodes(root)); - } - - // The following methods are used by the deactivated mergeTails() -// private static boolean isEqual(PtNodeArray a, PtNodeArray b) { -// if (null == a && null == b) return true; -// if (null == a || null == b) return false; -// if (a.data.size() != b.data.size()) return false; -// final int size = a.data.size(); -// for (int i = size - 1; i >= 0; --i) { -// PtNode aPtNode = a.data.get(i); -// PtNode bPtNode = b.data.get(i); -// if (aPtNode.frequency != bPtNode.frequency) return false; -// if (aPtNode.alternates == null && bPtNode.alternates != null) return false; -// if (aPtNode.alternates != null && !aPtNode.equals(bPtNode.alternates)) return false; -// if (!Arrays.equals(aPtNode.chars, bPtNode.chars)) return false; -// if (!isEqual(aPtNode.children, bPtNode.children)) return false; -// } -// return true; -// } - -// static private HashMap<String, ArrayList<PtNodeArray>> mergeTailsInner( -// final HashMap<String, ArrayList<PtNodeArray>> map, final PtNodeArray nodeArray) { -// final ArrayList<PtNode> branches = nodeArray.data; -// final int nodeSize = branches.size(); -// for (int i = 0; i < nodeSize; ++i) { -// PtNode ptNode = branches.get(i); -// if (null != ptNode.children) { -// String pseudoHash = getPseudoHash(ptNode.children); -// ArrayList<PtNodeArray> similarList = map.get(pseudoHash); -// if (null == similarList) { -// similarList = new ArrayList<PtNodeArray>(); -// map.put(pseudoHash, similarList); -// } -// boolean merged = false; -// for (PtNodeArray similar : similarList) { -// if (isEqual(ptNode.children, similar)) { -// ptNode.children = similar; -// merged = true; -// break; -// } -// } -// if (!merged) { -// similarList.add(ptNode.children); -// } -// mergeTailsInner(map, ptNode.children); -// } -// } -// return map; -// } - -// private static String getPseudoHash(final PtNodeArray nodeArray) { -// StringBuilder s = new StringBuilder(); -// for (PtNode ptNode : nodeArray.data) { -// s.append(ptNode.frequency); -// for (int ch : ptNode.chars) { -// s.append(Character.toChars(ch)); -// } -// } -// return s.toString(); -// } - - /** * Iterator to walk through a dictionary. * * This is purely for convenience. diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver3DictEncoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver3DictEncoder.java index 5da34534e..92eb861d6 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver3DictEncoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver3DictEncoder.java @@ -169,7 +169,7 @@ public class Ver3DictEncoder implements DictEncoder { private void writeChildrenPosition(final PtNode ptNode, final FormatOptions formatOptions) { final int childrenPos = BinaryDictEncoderUtils.getChildrenPosition(ptNode, formatOptions); - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { mPosition += BinaryDictEncoderUtils.writeSignedChildrenPosition(mBuffer, mPosition, childrenPos); } else { diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java index 07522b54b..3be62f066 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java @@ -183,14 +183,11 @@ public class Ver4DictDecoder extends AbstractDictDecoder { * An auxiliary class for reading bigrams. */ protected static class BigramContentReader extends SparseTableContentReader { - private final boolean mHasTimestamp; - public BigramContentReader(final String name, final File baseDir, final DictionaryBufferFactory factory, final boolean hasTimestamp) { super(name + FormatSpec.BIGRAM_FILE_EXTENSION, FormatSpec.BIGRAM_ADDRESS_TABLE_BLOCK_SIZE, baseDir, getContentFilenames(name, hasTimestamp), getContentIds(hasTimestamp), factory); - mHasTimestamp = hasTimestamp; } // TODO: Consolidate this method and BigramContentWriter.getContentFilenames. diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java index 1a245b6db..8b80ebe63 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java @@ -365,7 +365,7 @@ public class Ver4DictEncoder implements DictEncoder { private void writeChildrenPosition(PtNode ptNode, FormatOptions formatOptions) { final int childrenPos = BinaryDictEncoderUtils.getChildrenPosition(ptNode, formatOptions); - if (formatOptions.mSupportsDynamicUpdate) { + if (formatOptions.supportsDynamicUpdate()) { mTriePos += BinaryDictEncoderUtils.writeSignedChildrenPosition(mTrieBuf, mTriePos, childrenPos); } else { diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java index 91d9cf345..c46bc36bb 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictUpdater.java @@ -54,8 +54,6 @@ public class Ver4DictUpdater extends Ver4DictDecoder implements DictUpdater { } private static class BigramContentUpdater extends SparseTableContentUpdater { - private final boolean mHasTimestamp; - public BigramContentUpdater(final String name, final File baseDir, final boolean hasTimestamp) { super(name + FormatSpec.BIGRAM_FILE_EXTENSION, @@ -63,7 +61,6 @@ public class Ver4DictUpdater extends Ver4DictDecoder implements DictUpdater { BigramContentReader.getContentFilenames(name, hasTimestamp), BigramContentReader.getContentIds(hasTimestamp), new DictionaryBufferFromWritableByteBufferFactory()); - mHasTimestamp = hasTimestamp; } public void insertBigramEntries(final int terminalId, final int frequency, diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java index 296733fad..9b573b4b8 100644 --- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java +++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java @@ -95,8 +95,6 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB @Override protected Map<String, String> getHeaderAttributeMap() { HashMap<String, String> attributeMap = new HashMap<String, String>(); - attributeMap.put(FormatSpec.FileHeader.SUPPORTS_DYNAMIC_UPDATE_ATTRIBUTE, - FormatSpec.FileHeader.ATTRIBUTE_VALUE_TRUE); attributeMap.put(FormatSpec.FileHeader.USES_FORGETTING_CURVE_ATTRIBUTE, FormatSpec.FileHeader.ATTRIBUTE_VALUE_TRUE); attributeMap.put(FormatSpec.FileHeader.HAS_HISTORICAL_INFO_ATTRIBUTE, diff --git a/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java b/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java index a2c3ed44d..db628fe18 100644 --- a/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java @@ -95,8 +95,7 @@ public final class UserHistoryDictIOUtils { static FusionDictionary constructFusionDictionary(final BigramDictionaryInterface dict, final UserHistoryDictionaryBigramList bigrams, final HashMap<String, String> options) { final FusionDictionary fusionDict = new FusionDictionary(new PtNodeArray(), - new FusionDictionary.DictionaryOptions(options, false, - false)); + new FusionDictionary.DictionaryOptions(options)); int profTotal = 0; for (final String word1 : bigrams.keySet()) { final HashMap<String, Byte> word1Bigrams = bigrams.getBigrams(word1); |