diff options
295 files changed, 6096 insertions, 5471 deletions
diff --git a/java/res/drawable-hdpi/btn_keyboard_key_fulltrans_normal.9.png b/java/res/drawable-hdpi/btn_keyboard_key_fulltrans_normal.9.png Binary files differdeleted file mode 100644 index 116329016..000000000 --- a/java/res/drawable-hdpi/btn_keyboard_key_fulltrans_normal.9.png +++ /dev/null diff --git a/java/res/drawable-hdpi/btn_keyboard_key_fulltrans_pressed.9.png b/java/res/drawable-hdpi/btn_keyboard_key_fulltrans_pressed.9.png Binary files differdeleted file mode 100644 index 207c90d6c..000000000 --- a/java/res/drawable-hdpi/btn_keyboard_key_fulltrans_pressed.9.png +++ /dev/null diff --git a/java/res/drawable-hdpi/btn_keyboard_key_normal_off_stone.9.png b/java/res/drawable-hdpi/btn_keyboard_key_normal_off_stone.9.png Binary files differdeleted file mode 100644 index cdd6c8b79..000000000 --- a/java/res/drawable-hdpi/btn_keyboard_key_normal_off_stone.9.png +++ /dev/null diff --git a/java/res/drawable-hdpi/btn_keyboard_key_normal_on_stone.9.png b/java/res/drawable-hdpi/btn_keyboard_key_normal_on_stone.9.png Binary files differdeleted file mode 100644 index d8421746a..000000000 --- a/java/res/drawable-hdpi/btn_keyboard_key_normal_on_stone.9.png +++ /dev/null diff --git a/java/res/drawable-hdpi/btn_keyboard_key_normal_stone.9.png b/java/res/drawable-hdpi/btn_keyboard_key_normal_stone.9.png Binary files differdeleted file mode 100644 index 671d4e5d6..000000000 --- a/java/res/drawable-hdpi/btn_keyboard_key_normal_stone.9.png +++ /dev/null diff --git a/java/res/drawable-hdpi/ic_settings_language.png b/java/res/drawable-hdpi/ic_settings_language.png Binary files differdeleted file mode 100644 index f635b2e7a..000000000 --- a/java/res/drawable-hdpi/ic_settings_language.png +++ /dev/null diff --git a/java/res/drawable-hdpi/keyboard_background.9.png b/java/res/drawable-hdpi/keyboard_background.9.png Binary files differdeleted file mode 100644 index d57463fb6..000000000 --- a/java/res/drawable-hdpi/keyboard_background.9.png +++ /dev/null diff --git a/java/res/drawable-hdpi/keyboard_dark_background.9.png b/java/res/drawable-hdpi/keyboard_background_gb.9.png Binary files differindex fa3d449f7..fa3d449f7 100644 --- a/java/res/drawable-hdpi/keyboard_dark_background.9.png +++ b/java/res/drawable-hdpi/keyboard_background_gb.9.png diff --git a/java/res/drawable-hdpi/keyboard_background_holo.9.png b/java/res/drawable-hdpi/keyboard_background_ics.9.png Binary files differindex 73868751c..73868751c 100644 --- a/java/res/drawable-hdpi/keyboard_background_holo.9.png +++ b/java/res/drawable-hdpi/keyboard_background_ics.9.png diff --git a/java/res/drawable-hdpi/keyboard_popup_panel_background.9.png b/java/res/drawable-hdpi/keyboard_popup_panel_background_gb.9.png Binary files differindex baff80950..baff80950 100644 --- a/java/res/drawable-hdpi/keyboard_popup_panel_background.9.png +++ b/java/res/drawable-hdpi/keyboard_popup_panel_background_gb.9.png diff --git a/java/res/drawable-hdpi/keyboard_suggest_strip.9.png b/java/res/drawable-hdpi/keyboard_suggest_strip_gb.9.png Binary files differindex 7cab5a899..7cab5a899 100644 --- a/java/res/drawable-hdpi/keyboard_suggest_strip.9.png +++ b/java/res/drawable-hdpi/keyboard_suggest_strip_gb.9.png diff --git a/java/res/drawable-hdpi/sym_bkeyboard_delete.png b/java/res/drawable-hdpi/sym_bkeyboard_delete.png Binary files differdeleted file mode 100644 index 1d24cc85c..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_delete.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_label_mic.png b/java/res/drawable-hdpi/sym_bkeyboard_label_mic.png Binary files differdeleted file mode 100644 index 25702cf73..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_label_mic.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_mic.png b/java/res/drawable-hdpi/sym_bkeyboard_mic.png Binary files differdeleted file mode 100644 index 512f46080..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_mic.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_return.png b/java/res/drawable-hdpi/sym_bkeyboard_return.png Binary files differdeleted file mode 100644 index 426e1599e..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_return.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_search.png b/java/res/drawable-hdpi/sym_bkeyboard_search.png Binary files differdeleted file mode 100644 index 1b6f884fa..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_search.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_settings.png b/java/res/drawable-hdpi/sym_bkeyboard_settings.png Binary files differdeleted file mode 100644 index 08ba18f28..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_settings.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_shift.png b/java/res/drawable-hdpi/sym_bkeyboard_shift.png Binary files differdeleted file mode 100644 index 5a22dd309..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_shift.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_shift_locked.png b/java/res/drawable-hdpi/sym_bkeyboard_shift_locked.png Binary files differdeleted file mode 100644 index 566449126..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_shift_locked.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_space.png b/java/res/drawable-hdpi/sym_bkeyboard_space.png Binary files differdeleted file mode 100644 index cd0ebe2f4..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_space.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_tab.png b/java/res/drawable-hdpi/sym_bkeyboard_tab.png Binary files differdeleted file mode 100644 index 3466e1271..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_tab.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_bkeyboard_voice_off.png b/java/res/drawable-hdpi/sym_bkeyboard_voice_off.png Binary files differdeleted file mode 100644 index 081a13096..000000000 --- a/java/res/drawable-hdpi/sym_bkeyboard_voice_off.png +++ /dev/null diff --git a/java/res/drawable-hdpi/sym_keyboard_space_led.9.png b/java/res/drawable-hdpi/sym_keyboard_space_led_gb.9.png Binary files differindex c76f64b94..c76f64b94 100644 --- a/java/res/drawable-hdpi/sym_keyboard_space_led.9.png +++ b/java/res/drawable-hdpi/sym_keyboard_space_led_gb.9.png diff --git a/java/res/drawable-mdpi/btn_keyboard_key_fulltrans_normal.9.png b/java/res/drawable-mdpi/btn_keyboard_key_fulltrans_normal.9.png Binary files differdeleted file mode 100644 index 4b1a78cfb..000000000 --- a/java/res/drawable-mdpi/btn_keyboard_key_fulltrans_normal.9.png +++ /dev/null diff --git a/java/res/drawable-mdpi/btn_keyboard_key_fulltrans_pressed.9.png b/java/res/drawable-mdpi/btn_keyboard_key_fulltrans_pressed.9.png Binary files differdeleted file mode 100644 index 697683e29..000000000 --- a/java/res/drawable-mdpi/btn_keyboard_key_fulltrans_pressed.9.png +++ /dev/null diff --git a/java/res/drawable-mdpi/btn_keyboard_key_normal_off_stone.9.png b/java/res/drawable-mdpi/btn_keyboard_key_normal_off_stone.9.png Binary files differdeleted file mode 100644 index cdd6c8b79..000000000 --- a/java/res/drawable-mdpi/btn_keyboard_key_normal_off_stone.9.png +++ /dev/null diff --git a/java/res/drawable-mdpi/btn_keyboard_key_normal_on_stone.9.png b/java/res/drawable-mdpi/btn_keyboard_key_normal_on_stone.9.png Binary files differdeleted file mode 100644 index d8421746a..000000000 --- a/java/res/drawable-mdpi/btn_keyboard_key_normal_on_stone.9.png +++ /dev/null diff --git a/java/res/drawable-mdpi/btn_keyboard_key_normal_stone.9.png b/java/res/drawable-mdpi/btn_keyboard_key_normal_stone.9.png Binary files differdeleted file mode 100644 index 73cf35df0..000000000 --- a/java/res/drawable-mdpi/btn_keyboard_key_normal_stone.9.png +++ /dev/null diff --git a/java/res/drawable-mdpi/ic_settings_language.png b/java/res/drawable-mdpi/ic_settings_language.png Binary files differdeleted file mode 100644 index f8aca679b..000000000 --- a/java/res/drawable-mdpi/ic_settings_language.png +++ /dev/null diff --git a/java/res/drawable-mdpi/keyboard_background.9.png b/java/res/drawable-mdpi/keyboard_background.9.png Binary files differdeleted file mode 100644 index 2bd4b628d..000000000 --- a/java/res/drawable-mdpi/keyboard_background.9.png +++ /dev/null diff --git a/java/res/drawable-mdpi/keyboard_dark_background.9.png b/java/res/drawable-mdpi/keyboard_background_gb.9.png Binary files differindex 4f81704c4..4f81704c4 100644 --- a/java/res/drawable-mdpi/keyboard_dark_background.9.png +++ b/java/res/drawable-mdpi/keyboard_background_gb.9.png diff --git a/java/res/drawable-mdpi/keyboard_background_holo.9.png b/java/res/drawable-mdpi/keyboard_background_ics.9.png Binary files differindex fbe97f7a2..fbe97f7a2 100644 --- a/java/res/drawable-mdpi/keyboard_background_holo.9.png +++ b/java/res/drawable-mdpi/keyboard_background_ics.9.png diff --git a/java/res/drawable-mdpi/keyboard_popup_panel_background.9.png b/java/res/drawable-mdpi/keyboard_popup_panel_background_gb.9.png Binary files differindex 0d9ab97f0..0d9ab97f0 100644 --- a/java/res/drawable-mdpi/keyboard_popup_panel_background.9.png +++ b/java/res/drawable-mdpi/keyboard_popup_panel_background_gb.9.png diff --git a/java/res/drawable-mdpi/keyboard_suggest_strip.9.png b/java/res/drawable-mdpi/keyboard_suggest_strip_gb.9.png Binary files differindex fa6c0feff..fa6c0feff 100644 --- a/java/res/drawable-mdpi/keyboard_suggest_strip.9.png +++ b/java/res/drawable-mdpi/keyboard_suggest_strip_gb.9.png diff --git a/java/res/drawable-mdpi/sym_bkeyboard_delete.png b/java/res/drawable-mdpi/sym_bkeyboard_delete.png Binary files differdeleted file mode 100644 index 1a5ff439e..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_delete.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_label_mic.png b/java/res/drawable-mdpi/sym_bkeyboard_label_mic.png Binary files differdeleted file mode 100644 index 7f0b1355f..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_label_mic.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_mic.png b/java/res/drawable-mdpi/sym_bkeyboard_mic.png Binary files differdeleted file mode 100644 index a6cb1cc01..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_mic.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_return.png b/java/res/drawable-mdpi/sym_bkeyboard_return.png Binary files differdeleted file mode 100644 index e76225d0f..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_return.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_search.png b/java/res/drawable-mdpi/sym_bkeyboard_search.png Binary files differdeleted file mode 100644 index 1f180155d..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_search.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_settings.png b/java/res/drawable-mdpi/sym_bkeyboard_settings.png Binary files differdeleted file mode 100644 index 08ba18f28..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_settings.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_shift.png b/java/res/drawable-mdpi/sym_bkeyboard_shift.png Binary files differdeleted file mode 100644 index c981188dd..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_shift.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_shift_locked.png b/java/res/drawable-mdpi/sym_bkeyboard_shift_locked.png Binary files differdeleted file mode 100644 index b8cebd060..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_shift_locked.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_space.png b/java/res/drawable-mdpi/sym_bkeyboard_space.png Binary files differdeleted file mode 100644 index 4da7ee86e..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_space.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_tab.png b/java/res/drawable-mdpi/sym_bkeyboard_tab.png Binary files differdeleted file mode 100644 index 2cb991cbf..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_tab.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_bkeyboard_voice_off.png b/java/res/drawable-mdpi/sym_bkeyboard_voice_off.png Binary files differdeleted file mode 100644 index 081a13096..000000000 --- a/java/res/drawable-mdpi/sym_bkeyboard_voice_off.png +++ /dev/null diff --git a/java/res/drawable-mdpi/sym_keyboard_space_led.9.png b/java/res/drawable-mdpi/sym_keyboard_space_led_gb.9.png Binary files differindex 1c1ca2cc7..1c1ca2cc7 100644 --- a/java/res/drawable-mdpi/sym_keyboard_space_led.9.png +++ b/java/res/drawable-mdpi/sym_keyboard_space_led_gb.9.png diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_fulltrans_normal.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_fulltrans_normal.9.png Binary files differdeleted file mode 100644 index f7e32f764..000000000 --- a/java/res/drawable-xhdpi/btn_keyboard_key_fulltrans_normal.9.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_fulltrans_pressed.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_fulltrans_pressed.9.png Binary files differdeleted file mode 100644 index df3b5ba2d..000000000 --- a/java/res/drawable-xhdpi/btn_keyboard_key_fulltrans_pressed.9.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_normal_off_stone.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_normal_off_stone.9.png Binary files differdeleted file mode 100644 index dec219304..000000000 --- a/java/res/drawable-xhdpi/btn_keyboard_key_normal_off_stone.9.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_normal_on_stone.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_normal_on_stone.9.png Binary files differdeleted file mode 100644 index 3c77b3ccd..000000000 --- a/java/res/drawable-xhdpi/btn_keyboard_key_normal_on_stone.9.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/btn_keyboard_key_normal_stone.9.png b/java/res/drawable-xhdpi/btn_keyboard_key_normal_stone.9.png Binary files differdeleted file mode 100644 index 5cdfc4201..000000000 --- a/java/res/drawable-xhdpi/btn_keyboard_key_normal_stone.9.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/ic_settings_language.png b/java/res/drawable-xhdpi/ic_settings_language.png Binary files differdeleted file mode 100644 index 2c42db3aa..000000000 --- a/java/res/drawable-xhdpi/ic_settings_language.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/keyboard_background.9.png b/java/res/drawable-xhdpi/keyboard_background.9.png Binary files differdeleted file mode 100644 index 263996322..000000000 --- a/java/res/drawable-xhdpi/keyboard_background.9.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/keyboard_dark_background.9.png b/java/res/drawable-xhdpi/keyboard_background_gb.9.png Binary files differindex 27b7a108c..27b7a108c 100644 --- a/java/res/drawable-xhdpi/keyboard_dark_background.9.png +++ b/java/res/drawable-xhdpi/keyboard_background_gb.9.png diff --git a/java/res/drawable-xhdpi/keyboard_background_holo.9.png b/java/res/drawable-xhdpi/keyboard_background_ics.9.png Binary files differindex f5c9df3e5..f5c9df3e5 100644 --- a/java/res/drawable-xhdpi/keyboard_background_holo.9.png +++ b/java/res/drawable-xhdpi/keyboard_background_ics.9.png diff --git a/java/res/drawable-xhdpi/keyboard_popup_panel_background.9.png b/java/res/drawable-xhdpi/keyboard_popup_panel_background_gb.9.png Binary files differindex 79f7ab00a..79f7ab00a 100644 --- a/java/res/drawable-xhdpi/keyboard_popup_panel_background.9.png +++ b/java/res/drawable-xhdpi/keyboard_popup_panel_background_gb.9.png diff --git a/java/res/drawable-xhdpi/keyboard_suggest_strip.9.png b/java/res/drawable-xhdpi/keyboard_suggest_strip_gb.9.png Binary files differindex 1b568df03..1b568df03 100644 --- a/java/res/drawable-xhdpi/keyboard_suggest_strip.9.png +++ b/java/res/drawable-xhdpi/keyboard_suggest_strip_gb.9.png diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_delete.png b/java/res/drawable-xhdpi/sym_bkeyboard_delete.png Binary files differdeleted file mode 100644 index b84ee76dc..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_delete.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_label_mic.png b/java/res/drawable-xhdpi/sym_bkeyboard_label_mic.png Binary files differdeleted file mode 100644 index 9bd1d65b4..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_label_mic.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_mic.png b/java/res/drawable-xhdpi/sym_bkeyboard_mic.png Binary files differdeleted file mode 100644 index 8c3f11dd4..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_mic.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_return.png b/java/res/drawable-xhdpi/sym_bkeyboard_return.png Binary files differdeleted file mode 100644 index 1632ecd8e..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_return.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_search.png b/java/res/drawable-xhdpi/sym_bkeyboard_search.png Binary files differdeleted file mode 100644 index 69d8b22d1..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_search.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_settings.png b/java/res/drawable-xhdpi/sym_bkeyboard_settings.png Binary files differdeleted file mode 100644 index 050154a3a..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_settings.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_shift.png b/java/res/drawable-xhdpi/sym_bkeyboard_shift.png Binary files differdeleted file mode 100644 index d15d11a50..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_shift.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_shift_locked.png b/java/res/drawable-xhdpi/sym_bkeyboard_shift_locked.png Binary files differdeleted file mode 100644 index 83b287fea..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_shift_locked.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_space.png b/java/res/drawable-xhdpi/sym_bkeyboard_space.png Binary files differdeleted file mode 100644 index 5ca62c7b7..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_space.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_tab.png b/java/res/drawable-xhdpi/sym_bkeyboard_tab.png Binary files differdeleted file mode 100644 index 6ca199755..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_tab.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_bkeyboard_voice_off.png b/java/res/drawable-xhdpi/sym_bkeyboard_voice_off.png Binary files differdeleted file mode 100644 index fc6a4eb59..000000000 --- a/java/res/drawable-xhdpi/sym_bkeyboard_voice_off.png +++ /dev/null diff --git a/java/res/drawable-xhdpi/sym_keyboard_space_led.9.png b/java/res/drawable-xhdpi/sym_keyboard_space_led_gb.9.png Binary files differindex 6525fefab..6525fefab 100644 --- a/java/res/drawable-xhdpi/sym_keyboard_space_led.9.png +++ b/java/res/drawable-xhdpi/sym_keyboard_space_led_gb.9.png diff --git a/java/res/drawable-xxhdpi/keyboard_background_holo.9.png b/java/res/drawable-xxhdpi/keyboard_background_ics.9.png Binary files differindex bcef0f839..bcef0f839 100644 --- a/java/res/drawable-xxhdpi/keyboard_background_holo.9.png +++ b/java/res/drawable-xxhdpi/keyboard_background_ics.9.png diff --git a/java/res/drawable/btn_keyboard_key.xml b/java/res/drawable/btn_keyboard_key.xml deleted file mode 100644 index 112ac2636..000000000 --- a/java/res/drawable/btn_keyboard_key.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 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. ---> - -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <!-- Toggle keys. Use checkable/checked state. --> - <item android:state_checkable="true" android:state_checked="true" - android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_pressed_on" /> - <item android:state_checkable="true" android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_pressed_off" /> - <item android:state_checkable="true" android:state_checked="true" - android:drawable="@drawable/btn_keyboard_key_normal_on" /> - <item android:state_checkable="true" - android:drawable="@drawable/btn_keyboard_key_normal_off" /> - - <!-- Empty background keys. --> - <item android:state_empty="true" - android:drawable="@drawable/transparent" /> - - <!-- Normal keys. --> - <item android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_pressed" /> - <item android:drawable="@drawable/btn_keyboard_key_normal" /> -</selector> diff --git a/java/res/drawable/btn_keyboard_key3.xml b/java/res/drawable/btn_keyboard_key3.xml deleted file mode 100644 index 080b1f326..000000000 --- a/java/res/drawable/btn_keyboard_key3.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 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. ---> - -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <!-- Toggle keys. Use checkable/checked state. --> - <item android:state_checkable="true" android:state_checked="true" - android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_pressed_on" /> - <item android:state_checkable="true" android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" /> - <item android:state_checkable="true" android:state_checked="true" - android:drawable="@drawable/btn_keyboard_key_normal_on" /> - <item android:state_checkable="true" - android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> - - <!-- Empty background keys. --> - <item android:state_empty="true" - android:drawable="@drawable/transparent" /> - - <!-- Normal keys. --> - <item android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" /> - <item android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> -</selector> diff --git a/java/res/drawable/btn_keyboard_key_gingerbread.xml b/java/res/drawable/btn_keyboard_key_gb.xml index 3fc253e85..3fc253e85 100644 --- a/java/res/drawable/btn_keyboard_key_gingerbread.xml +++ b/java/res/drawable/btn_keyboard_key_gb.xml diff --git a/java/res/drawable/btn_keyboard_key_popup.xml b/java/res/drawable/btn_keyboard_key_popup_gb.xml index 9e3670d22..9e3670d22 100644 --- a/java/res/drawable/btn_keyboard_key_popup.xml +++ b/java/res/drawable/btn_keyboard_key_popup_gb.xml diff --git a/java/res/drawable/btn_keyboard_key_stone.xml b/java/res/drawable/btn_keyboard_key_stone.xml deleted file mode 100644 index 70a2ad444..000000000 --- a/java/res/drawable/btn_keyboard_key_stone.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 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. ---> - -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <!-- Functional keys. --> - <item android:state_single="true" android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> - <item android:state_single="true" - android:drawable="@drawable/btn_keyboard_key_normal_stone" /> - - <!-- Action keys. --> - <item android:state_active="true" android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> - <item android:state_active="true" - android:drawable="@drawable/btn_keyboard_key_normal_stone" /> - - <!-- Toggle keys. Use checkable/checked state. --> - <item android:state_checkable="true" android:state_checked="true" - android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_normal_on_stone" /> - <item android:state_checkable="true" android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_normal_off_stone" /> - <item android:state_checkable="true" android:state_checked="true" - android:drawable="@drawable/btn_keyboard_key_normal_on_stone" /> - <item android:state_checkable="true" - android:drawable="@drawable/btn_keyboard_key_normal_off_stone" /> - - <!-- Empty background keys. --> - <item android:state_empty="true" - android:drawable="@drawable/transparent" /> - - <!-- Normal keys. --> - <item android:state_pressed="true" - android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> - <item android:drawable="@drawable/btn_keyboard_key_normal_stone" /> -</selector> diff --git a/java/res/drawable/btn_suggestion.xml b/java/res/drawable/btn_suggestion_gb.xml index cde12fe55..cde12fe55 100644 --- a/java/res/drawable/btn_suggestion.xml +++ b/java/res/drawable/btn_suggestion_gb.xml diff --git a/java/res/drawable/keyboard_key_feedback.xml b/java/res/drawable/keyboard_key_feedback_gb.xml index 397e948d8..397e948d8 100644 --- a/java/res/drawable/keyboard_key_feedback.xml +++ b/java/res/drawable/keyboard_key_feedback_gb.xml diff --git a/java/res/layout/hint_add_to_dictionary.xml b/java/res/layout/hint_add_to_dictionary.xml index 73de44fae..63d4001ad 100644 --- a/java/res/layout/hint_add_to_dictionary.xml +++ b/java/res/layout/hint_add_to_dictionary.xml @@ -33,4 +33,4 @@ android:clickable="false" android:singleLine="true" android:ellipsize="none" - style="?attr/suggestionBackgroundStyle" /> + android:background="?attr/suggestionBackground" /> diff --git a/java/res/layout/input_view.xml b/java/res/layout/input_view.xml index 78217b01a..51133b289 100644 --- a/java/res/layout/input_view.xml +++ b/java/res/layout/input_view.xml @@ -34,6 +34,7 @@ android:layout_height="@dimen/suggestions_strip_height" android:paddingRight="@dimen/suggestions_strip_padding" android:paddingLeft="@dimen/suggestions_strip_padding" + android:background="?attr/suggestionStripBackground" style="?attr/suggestionStripViewStyle" /> <!-- To ensure that key preview popup is correctly placed when the current system locale is one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. --> diff --git a/java/res/layout/key_preview.xml b/java/res/layout/key_preview_gb.xml index 2fcd0c4dd..2f2a321a3 100644 --- a/java/res/layout/key_preview.xml +++ b/java/res/layout/key_preview_gb.xml @@ -21,7 +21,7 @@ <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@drawable/keyboard_key_feedback" + android:background="@drawable/keyboard_key_feedback_gb" android:minWidth="32dp" android:gravity="center" /> diff --git a/java/res/layout/more_keys_keyboard.xml b/java/res/layout/more_keys_keyboard.xml index 6b2464b99..cab3abcd9 100644 --- a/java/res/layout/more_keys_keyboard.xml +++ b/java/res/layout/more_keys_keyboard.xml @@ -17,17 +17,17 @@ ** limitations under the License. */ --> + <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - style="?attr/moreKeysKeyboardPanelStyle" - > + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:background="?attr/moreKeysKeyboardBackground" +> <com.android.inputmethod.keyboard.MoreKeysKeyboardView - xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - android:id="@+id/more_keys_keyboard_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - /> + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + android:id="@+id/more_keys_keyboard_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> </LinearLayout> diff --git a/java/res/layout/more_suggestions.xml b/java/res/layout/more_suggestions.xml index b41bb8aa4..0ec0ed1b3 100644 --- a/java/res/layout/more_suggestions.xml +++ b/java/res/layout/more_suggestions.xml @@ -17,21 +17,21 @@ ** limitations under the License. */ --> + <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:background="?attr/moreKeysKeyboardBackground" +> + <com.android.inputmethod.latin.suggestions.MoreSuggestionsView + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + android:id="@+id/more_suggestions_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="horizontal" - style="?attr/moreKeysKeyboardPanelStyle" - > - <com.android.inputmethod.latin.suggestions.MoreSuggestionsView - xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - android:id="@+id/more_suggestions_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - latin:keyLetterSize="@dimen/suggestion_text_size" - latin:keyLabelSize="@dimen/suggestion_text_size" - latin:keyHintLetterRatio="@fraction/more_suggestions_info_ratio" - latin:keyHintLetterColor="@android:color/white" - /> + latin:keyLetterSize="@dimen/suggestion_text_size" + latin:keyLabelSize="@dimen/suggestion_text_size" + latin:keyHintLetterRatio="@fraction/more_suggestions_info_ratio" + latin:keyHintLetterColor="@android:color/white" /> </LinearLayout> diff --git a/java/res/layout/suggestion_info.xml b/java/res/layout/suggestion_info.xml index a4ad6df25..8b0ee3484 100644 --- a/java/res/layout/suggestion_info.xml +++ b/java/res/layout/suggestion_info.xml @@ -24,4 +24,4 @@ android:layout_height="wrap_content" android:textSize="6dp" android:textColor="@android:color/white" - style="?attr/suggestionBackgroundStyle" /> + android:background="?attr/suggestionBackground" /> diff --git a/java/res/layout/suggestion_word.xml b/java/res/layout/suggestion_word.xml index fa00e041e..e32e6952b 100644 --- a/java/res/layout/suggestion_word.xml +++ b/java/res/layout/suggestion_word.xml @@ -36,4 +36,4 @@ android:clickable="false" android:singleLine="true" android:ellipsize="none" - style="?attr/suggestionBackgroundStyle" /> + android:background="?attr/suggestionBackground" /> diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index c78c25f86..c954e60da 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -26,14 +26,8 @@ <!-- key_height + key_bottom_gap = popup_key_height --> <dimen name="popup_key_height">44.8dp</dimen> - <fraction name="keyboard_top_padding">1.818%p</fraction> - <fraction name="keyboard_bottom_padding">0.0%p</fraction> - <fraction name="key_bottom_gap">4.330%p</fraction> - <fraction name="key_horizontal_gap">0.405%p</fraction> - - <fraction name="key_bottom_gap_stone">5.010%p</fraction> - <fraction name="key_horizontal_gap_stone">1.159%p</fraction> - + <fraction name="keyboard_top_padding_gb">1.818%p</fraction> + <fraction name="keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="key_bottom_gap_gb">5.941%p</fraction> <fraction name="key_horizontal_gap_gb">0.997%p</fraction> @@ -53,7 +47,7 @@ <fraction name="key_uppercase_letter_ratio">40%</fraction> <fraction name="key_preview_text_ratio">90%</fraction> <fraction name="spacebar_text_ratio">40.000%</fraction> - <dimen name="key_preview_offset">0.0dp</dimen> + <dimen name="key_preview_offset_gb">0.0dp</dimen> <!-- For 5-row keyboard --> <fraction name="key_bottom_gap_5row">3.20%p</fraction> @@ -72,11 +66,14 @@ <!-- popup_key_height x 1.2 --> <dimen name="more_keys_keyboard_slide_allowance">53.76dp</dimen> <!-- popup_key_height x -1.0 --> - <dimen name="more_keys_keyboard_vertical_correction">-44.8dp</dimen> + <dimen name="more_keys_keyboard_vertical_correction_gb">-44.8dp</dimen> <!-- Gesture floating preview text parameters --> <dimen name="gesture_floating_preview_text_size">23dp</dimen> <dimen name="gesture_floating_preview_text_offset">54dp</dimen> <dimen name="gesture_floating_preview_horizontal_padding">23dp</dimen> <dimen name="gesture_floating_preview_vertical_padding">15dp</dimen> + + <!-- Emoji keyboard --> + <fraction name="emoji_keyboard_key_width">8.3333%p</fraction> </resources> diff --git a/java/res/values-sw600dp-land/dimens.xml b/java/res/values-sw600dp-land/dimens.xml index 51c710fa4..cda462f29 100644 --- a/java/res/values-sw600dp-land/dimens.xml +++ b/java/res/values-sw600dp-land/dimens.xml @@ -24,20 +24,15 @@ <dimen name="keyboardHeight">283.5dp</dimen> <fraction name="minKeyboardHeight">45%p</fraction> - <fraction name="keyboard_top_padding">2.444%p</fraction> - <fraction name="keyboard_bottom_padding">0.0%p</fraction> - <fraction name="key_bottom_gap">4.911%p</fraction> - <fraction name="key_horizontal_gap">1.284%p</fraction> - - <fraction name="key_bottom_gap_stone">4.355%p</fraction> - <fraction name="key_horizontal_gap_stone">1.505%p</fraction> - + <fraction name="keyboard_top_padding_gb">2.444%p</fraction> + <fraction name="keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="key_bottom_gap_gb">5.200%p</fraction> <fraction name="key_horizontal_gap_gb">1.447%p</fraction> + <fraction name="keyboard_top_padding_ics">2.727%p</fraction> + <fraction name="keyboard_bottom_padding_ics">0.0%p</fraction> <fraction name="key_bottom_gap_ics">4.5%p</fraction> <fraction name="key_horizontal_gap_ics">0.9%p</fraction> - <fraction name="keyboard_bottom_padding_ics">0.0%p</fraction> <dimen name="popup_key_height">81.9dp</dimen> diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml index 826565168..93862a767 100644 --- a/java/res/values-sw600dp/config.xml +++ b/java/res/values-sw600dp/config.xml @@ -28,8 +28,6 @@ <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> - <!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. --> - <string name="config_default_keyboard_theme_index" translatable="false">5</string> <integer name="config_max_more_keys_column">5</integer> <!-- Configuration for MainKeyboardView diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml index 75b476c64..7dfd0b162 100644 --- a/java/res/values-sw600dp/dimens.xml +++ b/java/res/values-sw600dp/dimens.xml @@ -27,27 +27,22 @@ <dimen name="popup_key_height">63.0dp</dimen> - <fraction name="keyboard_top_padding">2.291%p</fraction> - <fraction name="keyboard_bottom_padding">0.0%p</fraction> - <fraction name="key_bottom_gap">3.750%p</fraction> - <fraction name="key_horizontal_gap">1.857%p</fraction> - - <fraction name="key_bottom_gap_stone">3.75%p</fraction> - <fraction name="key_horizontal_gap_stone">1.602%p</fraction> - + <fraction name="keyboard_top_padding_gb">2.291%p</fraction> + <fraction name="keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="key_bottom_gap_gb">4.625%p</fraction> <fraction name="key_horizontal_gap_gb">2.113%p</fraction> + <fraction name="keyboard_top_padding_ics">2.335%p</fraction> + <fraction name="keyboard_bottom_padding_ics">4.0%p</fraction> <fraction name="key_bottom_gap_ics">4.5%p</fraction> <fraction name="key_horizontal_gap_ics">1.565%p</fraction> - <fraction name="keyboard_bottom_padding_ics">4.0%p</fraction> <dimen name="more_keys_keyboard_key_horizontal_padding">6dp</dimen> <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> <!-- popup_key_height x 1.2 --> <dimen name="more_keys_keyboard_slide_allowance">98.3dp</dimen> <!-- popup_key_height x -1.0 --> - <dimen name="more_keys_keyboard_vertical_correction">-81.9dp</dimen> + <dimen name="more_keys_keyboard_vertical_correction_gb">-81.9dp</dimen> <!-- left or right padding of label alignment --> <dimen name="key_label_horizontal_padding">6dp</dimen> @@ -64,7 +59,7 @@ <fraction name="key_preview_text_ratio">50%</fraction> <fraction name="spacebar_text_ratio">28.0%</fraction> <dimen name="key_preview_height">94.5dp</dimen> - <dimen name="key_preview_offset">16.0dp</dimen> + <dimen name="key_preview_offset_gb">16.0dp</dimen> <!-- For 5-row keyboard --> <fraction name="key_bottom_gap_5row">3.20%p</fraction> diff --git a/java/res/values-sw600dp/touch-position-correction.xml b/java/res/values-sw600dp/touch-position-correction.xml index f77d3ae83..df07c1295 100644 --- a/java/res/values-sw600dp/touch-position-correction.xml +++ b/java/res/values-sw600dp/touch-position-correction.xml @@ -37,7 +37,7 @@ </string-array> <string-array - name="touch_position_correction_data_gingerbread" + name="touch_position_correction_data_gb" translatable="false" > <!-- The default touch position data (See com.android.inputmethod.keyboard.ProximityInfo) @@ -48,7 +48,7 @@ </string-array> <string-array - name="touch_position_correction_data_ice_cream_sandwich" + name="touch_position_correction_data_ics" translatable="false" > <!-- The default touch position data (See com.android.inputmethod.keyboard.ProximityInfo) diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml index f4a57ffb0..0a7048060 100644 --- a/java/res/values-sw768dp-land/dimens.xml +++ b/java/res/values-sw768dp-land/dimens.xml @@ -24,15 +24,8 @@ <dimen name="keyboardHeight">365.4dp</dimen> <fraction name="minKeyboardHeight">45%p</fraction> - <fraction name="keyboard_top_padding">1.896%p</fraction> - <fraction name="keyboard_bottom_padding">0.0%p</fraction> - - <fraction name="key_bottom_gap">4.103%p</fraction> - <fraction name="key_horizontal_gap">1.034%p</fraction> - - <fraction name="key_bottom_gap_stone">3.379%p</fraction> - <fraction name="key_horizontal_gap_stone">1.062%p</fraction> - + <fraction name="keyboard_top_padding_gb">1.896%p</fraction> + <fraction name="keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="key_bottom_gap_gb">3.896%p</fraction> <fraction name="key_horizontal_gap_gb">1.195%p</fraction> diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml index 97f11cb04..e1c07d6f8 100644 --- a/java/res/values-sw768dp/config.xml +++ b/java/res/values-sw768dp/config.xml @@ -26,8 +26,6 @@ <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> - <!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. --> - <string name="config_default_keyboard_theme_index" translatable="false">5</string> <integer name="config_max_more_keys_column">5</integer> <!-- Configuration for MainKeyboardView diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml index 91251f5a4..877e83b59 100644 --- a/java/res/values-sw768dp/dimens.xml +++ b/java/res/values-sw768dp/dimens.xml @@ -25,18 +25,12 @@ <fraction name="maxKeyboardHeight">46%p</fraction> <fraction name="minKeyboardHeight">-35.0%p</fraction> - <fraction name="keyboard_top_padding">2.291%p</fraction> - <fraction name="keyboard_bottom_padding">0.0%p</fraction> - - <fraction name="key_bottom_gap">4.270%p</fraction> - <fraction name="key_horizontal_gap">1.551%p</fraction> - - <fraction name="key_bottom_gap_stone">3.75%p</fraction> - <fraction name="key_horizontal_gap_stone">1.059%p</fraction> - + <fraction name="keyboard_top_padding_gb">2.291%p</fraction> + <fraction name="keyboard_bottom_padding_gb">0.0%p</fraction> <fraction name="key_bottom_gap_gb">4.687%p</fraction> <fraction name="key_horizontal_gap_gb">1.272%p</fraction> + <fraction name="keyboard_top_padding_ics">2.335%p</fraction> <fraction name="keyboard_bottom_padding_ics">0.0%p</fraction> <fraction name="key_bottom_gap_ics">3.312%p</fraction> <fraction name="key_horizontal_gap_ics">1.066%p</fraction> @@ -48,7 +42,7 @@ <!-- popup_key_height x 1.2 --> <dimen name="more_keys_keyboard_slide_allowance">98.3dp</dimen> <!-- popup_key_height x -1.0 --> - <dimen name="more_keys_keyboard_vertical_correction">-81.9dp</dimen> + <dimen name="more_keys_keyboard_vertical_correction_gb">-81.9dp</dimen> <!-- left or right padding of label alignment --> <dimen name="key_label_horizontal_padding">6dp</dimen> @@ -65,7 +59,7 @@ <fraction name="key_preview_text_ratio">50%</fraction> <fraction name="spacebar_text_ratio">29.03%</fraction> <dimen name="key_preview_height">94.5dp</dimen> - <dimen name="key_preview_offset">16.0dp</dimen> + <dimen name="key_preview_offset_gb">16.0dp</dimen> <!-- For 5-row keyboard --> <fraction name="key_bottom_gap_5row">2.95%p</fraction> diff --git a/java/res/values-v18/emoji-categories.xml b/java/res/values-v18/emoji-categories.xml new file mode 100644 index 000000000..17a2053d2 --- /dev/null +++ b/java/res/values-v18/emoji-categories.xml @@ -0,0 +1,922 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2013 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- Note: This emoji code point list is valid on JB-MR2 (API == 18). + There is another emoji code point list for KLP and later under res/xml/values-v19. --> +<resources> + <!-- Dummy codeArrays for recents emoji keyboard. + Do not remove these keys, because they are used as a template. --> + <array + name="emoji_recents" + format="string" + > + <item>52</item> + <item>45</item> + <item>43</item> + <item>45</item> + <item>4E</item> + <item>54</item> + </array> + <array + name="emoji_nature" + format="string" + > + <!-- <item>1f415</item> --> + <item>1f436</item> + <item>1f429</item> + <!-- <item>1f408</item> --> + <item>1f431</item> + <!-- <item>1f400</item> --> + <!-- <item>1f401</item> --> + <item>1f42d</item> + <item>1f439</item> + <item>1f422</item> + <!-- <item>1f407</item> --> + <item>1f430</item> + <!-- <item>1f413</item> --> + <item>1f414</item> + <item>1f423</item> + <item>1f424</item> + <item>1f425</item> + <item>1f426</item> + <!-- <item>1f40f</item> --> + <item>1f411</item> + <!-- <item>1f410</item> --> + <item>1f43a</item> + <!-- <item>1f403</item> --> + <!-- <item>1f402</item> --> + <!-- <item>1f404</item> --> + <item>1f42e</item> + <item>1f434</item> + <item>1f417</item> + <!-- <item>1f416</item> --> + <item>1f437</item> + <item>1f43d</item> + <item>1f438</item> + <item>1f40d</item> + <item>1f43c</item> + <item>1f427</item> + <item>1f418</item> + <item>1f428</item> + <item>1f412</item> + <item>1f435</item> + <!-- <item>1f406</item> --> + <item>1f42f</item> + <item>1f43b</item> + <item>1f42b</item> + <!-- <item>1f42a</item> --> + <!-- <item>1f40a</item> --> + <item>1f433</item> + <!-- <item>1f40b</item> --> + <item>1f41f</item> + <item>1f420</item> + <item>1f421</item> + <item>1f419</item> + <item>1f41a</item> + <item>1f42c</item> + <item>1f40c</item> + <item>1f41b</item> + <item>1f41c</item> + <item>1f41d</item> + <item>1f41e</item> + <item>1f432</item> + <!-- <item>1f409</item> --> + <item>1f43e</item> + <item>1f378</item> + <item>1f37a</item> + <item>1f37b</item> + <item>1f377</item> + <item>1f379</item> + <item>1f376</item> + <!-- <item>2615</item> --> + <item>1f375</item> + <!-- <item>1f37c</item> --> + <item>1f374</item> + <item>1f368</item> + <item>1f367</item> + <item>1f366</item> + <item>1f369</item> + <item>1f370</item> + <item>1f36a</item> + <item>1f36b</item> + <item>1f36c</item> + <item>1f36d</item> + <item>1f36e</item> + <item>1f36f</item> + <item>1f373</item> + <item>1f354</item> + <item>1f35f</item> + <item>1f35d</item> + <item>1f355</item> + <item>1f356</item> + <item>1f357</item> + <item>1f364</item> + <item>1f363</item> + <item>1f371</item> + <item>1f35e</item> + <item>1f35c</item> + <item>1f359</item> + <item>1f35a</item> + <item>1f35b</item> + <item>1f372</item> + <item>1f365</item> + <item>1f362</item> + <item>1f361</item> + <item>1f358</item> + <item>1f360</item> + <item>1f34c</item> + <item>1f34e</item> + <item>1f34f</item> + <item>1f34a</item> + <!-- <item>1f34b</item> --> + <item>1f344</item> + <item>1f345</item> + <item>1f346</item> + <item>1f347</item> + <item>1f348</item> + <item>1f349</item> + <!-- <item>1f350</item> --> + <item>1f351</item> + <item>1f352</item> + <item>1f353</item> + <item>1f34d</item> + <item>1f330</item> + <item>1f331</item> + <!-- <item>1f332</item> --> + <!-- <item>1f333</item> --> + <item>1f334</item> + <item>1f335</item> + <item>1f337</item> + <item>1f338</item> + <item>1f339</item> + <item>1f340</item> + <item>1f341</item> + <item>1f342</item> + <item>1f343</item> + <item>1f33a</item> + <item>1f33b</item> + <item>1f33c</item> + <item>1f33d</item> + <item>1f33e</item> + <item>1f33f</item> + <item>2600</item> + <item>1f308</item> + <item>26c5</item> + <item>2601</item> + <item>1f301</item> + <item>1f302</item> + <!-- <item>2614</item> --> + <item>1f4a7</item> + <item>26a1</item> + <item>1f300</item> + <item>2744</item> + <item>26c4</item> + <item>1f319</item> + <!-- <item>1f31e</item> --> + <!-- <item>1f31d</item> --> + <!-- <item>1f31a</item> --> + <item>1f31b</item> + <!-- <item>1f31c</item> --> + <item>1f311</item> + <!-- <item>1f312</item> --> + <item>1f313</item> + <item>1f314</item> + <item>1f315</item> + <!-- <item>1f316</item> --> + <!-- <item>1f317</item> --> + <!-- <item>1f318</item> --> + <item>1f391</item> + <item>1f304</item> + <item>1f305</item> + <item>1f307</item> + <item>1f306</item> + <item>1f303</item> + <item>1f30c</item> + <item>1f309</item> + <item>1f30a</item> + <item>1f30b</item> + <!-- <item>1f30e</item> --> + <item>1f30f</item> + <!-- <item>1f30d</item> --> + <!-- <item>1f310</item> --> + </array> + <array + name="emoji_symbols" + format="string" + > + <!-- <item>fe82e|0031,20e3</item> --> + <!-- <item>fe82f|0032,20e3</item> --> + <!-- <item>fe830|0033,20e3</item> --> + <!-- <item>fe831|0034,20e3</item> --> + <!-- <item>fe832|0035,20e3</item> --> + <!-- <item>fe833|0036,20e3</item> --> + <!-- <item>fe834|0037,20e3</item> --> + <!-- <item>fe835|0038,20e3</item> --> + <!-- <item>fe836|0039,20e3</item> --> + <!-- <item>fe837|0030,20e3</item> --> + <!-- <item>1f51f</item> --> + <!-- <item>fe82c|0023,20e3</item> --> + <item>1f51d</item> + <item>1f519</item> + <item>1f51b</item> + <item>1f51c</item> + <item>1f51a</item> + <item>23f3</item> + <item>231b</item> + <item>23f0</item> + <item>2648</item> + <item>2649</item> + <item>264a</item> + <item>264b</item> + <item>264c</item> + <item>264d</item> + <item>264e</item> + <item>264f</item> + <item>2650</item> + <item>2651</item> + <item>2652</item> + <item>2653</item> + <item>26ce</item> + <item>1f531</item> + <item>1f52f</item> + <item>1f6bb</item> + <!-- <item>1f6ae</item> --> + <!-- <item>1f6af</item> --> + <!-- <item>1f6b0</item> --> + <!-- <item>1f6b1</item> --> + <item>1f170</item> + <item>1f171</item> + <item>1f18e</item> + <item>1f17e</item> + <item>1f4ae</item> + <item>1f4af</item> + <item>1f520</item> + <item>1f521</item> + <item>1f522</item> + <item>1f523</item> + <item>1f524</item> + <item>27bf</item> + <item>1f4f6</item> + <item>1f4f3</item> + <item>1f4f4</item> + <!-- <item>1f4f5</item> --> + <item>1f6b9</item> + <item>1f6ba</item> + <item>1f6bc</item> + <item>267f</item> + <item>267b</item> + <item>1f6ad</item> + <item>1f6a9</item> + <item>26a0</item> + <item>1f201</item> + <item>1f51e</item> + <item>26d4</item> + <item>1f192</item> + <item>1f197</item> + <item>1f195</item> + <item>1f198</item> + <item>1f199</item> + <item>1f193</item> + <item>1f196</item> + <item>1f19a</item> + <item>1f232</item> + <item>1f233</item> + <item>1f234</item> + <item>1f235</item> + <item>1f236</item> + <item>1f237</item> + <item>1f238</item> + <item>1f239</item> + <item>1f202</item> + <item>1f23a</item> + <item>1f250</item> + <item>1f251</item> + <item>3299</item> + <item>00ae</item> + <item>00a9</item> + <item>2122</item> + <item>1f21a</item> + <item>1f22f</item> + <item>3297</item> + <item>2b55</item> + <item>274c</item> + <item>274e</item> + <item>2139</item> + <item>1f6ab</item> + <item>2705</item> + <item>2714</item> + <item>1f517</item> + <item>2734</item> + <item>2733</item> + <item>2795</item> + <item>2796</item> + <item>2716</item> + <item>2797</item> + <item>1f4a0</item> + <item>1f4a1</item> + <item>1f4a4</item> + <item>1f4a2</item> + <item>1f525</item> + <item>1f4a5</item> + <item>1f4a8</item> + <item>1f4a6</item> + <item>1f4ab</item> + <item>1f55b</item> + <!-- <item>1f567</item> --> + <item>1f550</item> + <!-- <item>1f55c</item> --> + <item>1f551</item> + <!-- <item>1f55d</item> --> + <item>1f552</item> + <!-- <item>1f55e</item> --> + <item>1f553</item> + <!-- <item>1f55f</item> --> + <item>1f554</item> + <!-- <item>1f560</item> --> + <item>1f555</item> + <!-- <item>1f561</item> --> + <item>1f556</item> + <!-- <item>1f562</item> --> + <item>1f557</item> + <!-- <item>1f563</item> --> + <item>1f558</item> + <!-- <item>1f564</item> --> + <item>1f559</item> + <!-- <item>1f565</item> --> + <item>1f55a</item> + <!-- <item>1f566</item> --> + <item>2195</item> + <item>2b06</item> + <item>2197</item> + <item>27a1</item> + <item>2198</item> + <item>2b07</item> + <item>2199</item> + <item>2b05</item> + <item>2196</item> + <item>2194</item> + <item>2934</item> + <item>2935</item> + <item>23ea</item> + <item>23eb</item> + <item>23ec</item> + <item>23e9</item> + <item>25c0</item> + <item>25b6</item> + <item>1f53d</item> + <item>1f53c</item> + <item>2747</item> + <item>2728</item> + <item>1f534</item> + <item>1f535</item> + <item>26aa</item> + <item>26ab</item> + <item>1f533</item> + <item>1f532</item> + <item>2b50</item> + <item>1f31f</item> + <item>1f320</item> + <item>25ab</item> + <item>25aa</item> + <item>25fd</item> + <item>25fe</item> + <item>25fb</item> + <item>25fc</item> + <item>2b1c</item> + <item>2b1b</item> + <item>1f538</item> + <item>1f539</item> + <item>1f536</item> + <item>1f537</item> + <item>1f53a</item> + <item>1f53b</item> + <item>2754</item> + <item>2753</item> + <item>2755</item> + <item>2757</item> + <item>203c</item> + <item>2049</item> + <item>3030</item> + <item>27b0</item> + <item>2660</item> + <item>2665</item> + <item>2663</item> + <item>2666</item> + <item>1f194</item> + <item>1f511</item> + <item>21a9</item> + <item>1f191</item> + <item>1f50d</item> + <item>1f512</item> + <item>1f513</item> + <item>21aa</item> + <item>1f510</item> + <!-- <item>2611</item> --> + <item>1f518</item> + <item>1f50e</item> + <item>1f516</item> + <item>1f50f</item> + <item>1f503</item> + <!-- <item>1f500</item> --> + <!-- <item>1f501</item> --> + <!-- <item>1f502</item> --> + <!-- <item>1f504</item> --> + <item>1f4e7</item> + <!-- <item>1f505</item> --> + <!-- <item>1f506</item> --> + <!-- <item>1f507</item> --> + <!-- <item>1f508</item> --> + <!-- <item>1f509</item> --> + <item>1f50a</item> + </array> + <array + name="emoji_faces" + format="string" + > + <item>263a</item> + <item>1f60a</item> + <!-- <item>1f600</item> --> + <item>1f601</item> + <item>1f602</item> + <item>1f603</item> + <item>1f604</item> + <item>1f605</item> + <item>1f606</item> + <!-- <item>1f607</item> --> + <!-- <item>1f608</item> --> + <item>1f609</item> + <!-- <item>1f62f</item> --> + <!-- <item>1f610</item> --> + <!-- <item>1f611</item> --> + <!-- <item>1f615</item> --> + <item>1f620</item> + <!-- <item>1f62c</item> --> + <item>1f621</item> + <item>1f622</item> + <!-- <item>1f634</item> --> + <!-- <item>1f62e</item> --> + <item>1f623</item> + <item>1f624</item> + <item>1f625</item> + <!-- <item>1f626</item> --> + <!-- <item>1f627</item> --> + <item>1f628</item> + <item>1f629</item> + <item>1f630</item> + <!-- <item>1f61f</item> --> + <item>1f631</item> + <item>1f632</item> + <item>1f633</item> + <item>1f635</item> + <!-- <item>1f636</item> --> + <item>1f637</item> + <item>1f61e</item> + <item>1f612</item> + <item>1f60d</item> + <!-- <item>1f61b</item> --> + <item>1f61c</item> + <item>1f61d</item> + <item>1f60b</item> + <!-- <item>1f617</item> --> + <!-- <item>1f619</item> --> + <item>1f618</item> + <item>1f61a</item> + <!-- <item>1f60e</item> --> + <item>1f62d</item> + <item>1f60c</item> + <item>1f616</item> + <item>1f614</item> + <item>1f62a</item> + <item>1f60f</item> + <item>1f613</item> + <item>1f62b</item> + <item>1f64b</item> + <item>1f64c</item> + <item>1f64d</item> + <item>1f645</item> + <item>1f646</item> + <item>1f647</item> + <item>1f64e</item> + <item>1f64f</item> + <item>1f63a</item> + <item>1f63c</item> + <item>1f638</item> + <item>1f639</item> + <item>1f63b</item> + <item>1f63d</item> + <item>1f63f</item> + <item>1f63e</item> + <item>1f640</item> + <item>1f648</item> + <item>1f649</item> + <item>1f64a</item> + <item>1f4a9</item> + <item>1f476</item> + <item>1f466</item> + <item>1f467</item> + <item>1f468</item> + <item>1f469</item> + <item>1f474</item> + <item>1f475</item> + <item>1f48f</item> + <item>1f491</item> + <item>1f46a</item> + <item>1f46b</item> + <!-- <item>1f46c</item> --> + <!-- <item>1f46d</item> --> + <item>1f464</item> + <!-- <item>1f465</item> --> + <item>1f46e</item> + <item>1f477</item> + <item>1f481</item> + <item>1f482</item> + <item>1f46f</item> + <item>1f470</item> + <item>1f478</item> + <item>1f385</item> + <item>1f47c</item> + <!-- <item>1f471</item> --> + <!-- <item>1f472</item> --> + <!-- <item>1f473</item> --> + <item>1f483</item> + <item>1f486</item> + <item>1f487</item> + <item>1f485</item> + <item>1f47b</item> + <item>1f479</item> + <item>1f47a</item> + <item>1f47d</item> + <item>1f47e</item> + <item>1f47f</item> + <item>1f480</item> + <item>1f4aa</item> + <item>1f440</item> + <item>1f442</item> + <item>1f443</item> + <item>1f463</item> + <item>1f444</item> + <item>1f445</item> + <item>1f48b</item> + <item>2764</item> + <item>1f499</item> + <item>1f49a</item> + <item>1f49b</item> + <item>1f49c</item> + <item>1f493</item> + <item>1f494</item> + <item>1f495</item> + <item>1f496</item> + <item>1f497</item> + <item>1f498</item> + <item>1f49d</item> + <item>1f49e</item> + <item>1f49f</item> + <item>1f44d</item> + <item>1f44e</item> + <item>1f44c</item> + <item>270a</item> + <item>270c</item> + <item>270b</item> + <item>1f44a</item> + <!-- <item>261d</item> --> + <item>1f446</item> + <item>1f447</item> + <item>1f448</item> + <item>1f449</item> + <item>1f44b</item> + <item>1f44f</item> + <!-- <item>1f450</item> --> + </array> + <array + name="emoji_objects" + format="string" + > + <item>1f530</item> + <item>1f484</item> + <item>1f45e</item> + <item>1f45f</item> + <item>1f451</item> + <item>1f452</item> + <item>1f3a9</item> + <item>1f393</item> + <item>1f453</item> + <item>231a</item> + <item>1f454</item> + <item>1f455</item> + <item>1f456</item> + <item>1f457</item> + <item>1f458</item> + <item>1f459</item> + <item>1f460</item> + <item>1f461</item> + <item>1f462</item> + <item>1f45a</item> + <item>1f45c</item> + <item>1f4bc</item> + <item>1f392</item> + <item>1f45d</item> + <item>1f45b</item> + <item>1f4b0</item> + <item>1f4b3</item> + <item>1f4b2</item> + <item>1f4b5</item> + <item>1f4b4</item> + <!-- <item>1f4b6</item> --> + <!-- <item>1f4b7</item> --> + <item>1f4b8</item> + <item>1f4b1</item> + <item>1f4b9</item> + <item>1f52b</item> + <item>1f52a</item> + <item>1f4a3</item> + <item>1f489</item> + <item>1f48a</item> + <item>1f6ac</item> + <item>1f514</item> + <!-- <item>1f515</item> --> + <item>1f6aa</item> + <!-- <item>1f52c</item> --> + <!-- <item>1f52d</item> --> + <item>1f52e</item> + <item>1f526</item> + <item>1f50b</item> + <item>1f50c</item> + <item>1f4dc</item> + <item>1f4d7</item> + <item>1f4d8</item> + <item>1f4d9</item> + <item>1f4da</item> + <item>1f4d4</item> + <item>1f4d2</item> + <item>1f4d1</item> + <item>1f4d3</item> + <item>1f4d5</item> + <item>1f4d6</item> + <item>1f4f0</item> + <item>1f4db</item> + <item>1f383</item> + <item>1f384</item> + <item>1f380</item> + <item>1f381</item> + <item>1f382</item> + <item>1f388</item> + <item>1f386</item> + <item>1f387</item> + <item>1f389</item> + <item>1f38a</item> + <item>1f38d</item> + <item>1f38f</item> + <item>1f38c</item> + <item>1f390</item> + <item>1f38b</item> + <item>1f38e</item> + <item>1f4f1</item> + <item>1f4f2</item> + <item>1f4df</item> + <item>260e</item> + <item>1f4de</item> + <item>1f4e0</item> + <item>1f4e6</item> + <item>2709</item> + <item>1f4e8</item> + <item>1f4e9</item> + <item>1f4ea</item> + <item>1f4eb</item> + <!-- <item>1f4ed</item> --> + <!-- <item>1f4ec</item> --> + <item>1f4ee</item> + <item>1f4e4</item> + <item>1f4e5</item> + <!-- <item>1f4ef</item> --> + <item>1f4e2</item> + <item>1f4e3</item> + <item>1f4e1</item> + <item>1f4ac</item> + <!-- <item>1f4ad</item> --> + <item>2712</item> + <item>270f</item> + <item>1f4dd</item> + <item>1f4cf</item> + <item>1f4d0</item> + <item>1f4cd</item> + <item>1f4cc</item> + <item>1f4ce</item> + <item>2702</item> + <item>1f4ba</item> + <item>1f4bb</item> + <item>1f4bd</item> + <item>1f4be</item> + <item>1f4bf</item> + <item>1f4c6</item> + <item>1f4c5</item> + <item>1f4c7</item> + <item>1f4cb</item> + <item>1f4c1</item> + <item>1f4c2</item> + <item>1f4c3</item> + <item>1f4c4</item> + <item>1f4ca</item> + <item>1f4c8</item> + <item>1f4c9</item> + <item>26fa</item> + <item>1f3a1</item> + <item>1f3a2</item> + <item>1f3a0</item> + <item>1f3aa</item> + <item>1f3a8</item> + <item>1f3ac</item> + <item>1f3a5</item> + <item>1f4f7</item> + <item>1f4f9</item> + <item>1f3a6</item> + <item>1f3ad</item> + <item>1f3ab</item> + <item>1f3ae</item> + <item>1f3b2</item> + <item>1f3b0</item> + <item>1f0cf</item> + <item>1f3b4</item> + <item>1f004</item> + <item>1f3af</item> + <item>1f4fa</item> + <item>1f4fb</item> + <item>1f4c0</item> + <item>1f4fc</item> + <item>1f3a7</item> + <item>1f3a4</item> + <item>1f3b5</item> + <item>1f3b6</item> + <item>1f3bc</item> + <item>1f3bb</item> + <item>1f3b9</item> + <item>1f3b7</item> + <item>1f3ba</item> + <item>1f3b8</item> + <item>303d</item> + </array> + <array + name="emoji_places" + format="string" + > + <item>1f3e0</item> + <item>1f3e1</item> + <item>1f3e2</item> + <item>1f3e3</item> + <!-- <item>1f3e4</item> --> + <item>1f3e5</item> + <item>1f3e6</item> + <item>1f3e7</item> + <item>1f3e8</item> + <item>1f3e9</item> + <item>1f3ea</item> + <item>1f3eb</item> + <item>26ea</item> + <item>26f2</item> + <item>1f3ec</item> + <item>1f3ef</item> + <item>1f3f0</item> + <item>1f3ed</item> + <item>1f5fb</item> + <item>1f5fc</item> + <item>1f5fd</item> + <item>1f5fe</item> + <item>1f5ff</item> + <item>2693</item> + <item>1f3ee</item> + <item>1f488</item> + <item>1f527</item> + <item>1f528</item> + <item>1f529</item> + <!-- <item>1f6bf</item> --> + <!-- <item>1f6c1</item> --> + <item>1f6c0</item> + <item>1f6bd</item> + <item>1f6be</item> + <item>1f3bd</item> + <item>1f3a3</item> + <item>1f3b1</item> + <item>1f3b3</item> + <item>26be</item> + <item>26f3</item> + <item>1f3be</item> + <item>26bd</item> + <item>1f3bf</item> + <item>1f3c0</item> + <item>1f3c1</item> + <item>1f3c2</item> + <item>1f3c3</item> + <item>1f3c4</item> + <item>1f3c6</item> + <!-- <item>1f3c7</item> --> + <item>1f40e</item> + <item>1f3c8</item> + <!-- <item>1f3c9</item> --> + <item>1f3ca</item> + <!-- <item>1f682</item> --> + <item>1f683</item> + <item>1f684</item> + <item>1f685</item> + <!-- <item>1f686</item> --> + <item>1f687</item> + <item>24c2</item> + <!-- <item>1f688</item> --> + <!-- <item>1f68a</item> --> + <!-- <item>1f68b</item> --> + <item>1f68c</item> + <!-- <item>1f68d</item> --> + <!-- <item>1f68e</item> --> + <item>1f68f</item> + <!-- <item>1f690</item> --> + <item>1f691</item> + <item>1f692</item> + <item>1f693</item> + <!-- <item>1f694</item> --> + <item>1f695</item> + <!-- <item>1f696</item> --> + <item>1f697</item> + <!-- <item>1f698</item> --> + <item>1f699</item> + <!-- <item>1f69a</item> --> + <!-- <item>1f69b</item> --> + <!-- <item>1f69c</item> --> + <!-- <item>1f69d</item> --> + <!-- <item>1f69e</item> --> + <!-- <item>1f69f</item> --> + <!-- <item>1f6a0</item> --> + <!-- <item>1f6a1</item> --> + <item>1f6a2</item> + <!-- <item>1f6a3</item> --> + <!-- <item>1f681</item> --> + <item>2708</item> + <!-- <item>1f6c2</item> --> + <!-- <item>1f6c3</item> --> + <!-- <item>1f6c4</item> --> + <!-- <item>1f6c5</item> --> + <item>26f5</item> + <item>1f6b2</item> + <!-- <item>1f6b3</item> --> + <!-- <item>1f6b4</item> --> + <!-- <item>1f6b5</item> --> + <!-- <item>1f6b7</item> --> + <!-- <item>1f6b8</item> --> + <item>1f689</item> + <item>1f680</item> + <item>1f6a4</item> + <item>1f6b6</item> + <item>26fd</item> + <item>1f17f</item> + <item>1f6a5</item> + <!-- <item>1f6a6</item> --> + <item>1f6a7</item> + <item>1f6a8</item> + <item>2668</item> + <item>1f48c</item> + <item>1f48d</item> + <item>1f48e</item> + <item>1f490</item> + <item>1f492</item> + <item>fe4e5|1f1ef,1f1f5</item> + <item>fe4e6|1f1fa,1f1f8</item> + <item>fe4e7|1f1eb,1f1f7</item> + <item>fe4e8|1f1e9,1f1ea</item> + <item>fe4e9|1f1ee,1f1f9</item> + <item>fe4ea|1f1ec,1f1e7</item> + <item>fe4eb|1f1ea,1f1f8</item> + <item>fe4ec|1f1f7,1f1fa</item> + <item>fe4ed|1f1e8,1f1f3</item> + <item>fe4ee|1f1f0,1f1f7</item> + </array> + <array + name="emoji_emoticons" + format="string" + > + <item>=-O</item> + <item>:-P</item> + <item>;-)</item> + <item>:-(</item> + <item>:-)</item> + <item>:-!</item> + <item>:-$</item> + <item>B-)</item> + <item>:O</item> + <item>:-*</item> + <item>:-D</item> + <item>:\'(</item> + <item>:-\\</item> + <item>O:-)</item> + <item>:-[</item> + </array> +</resources> diff --git a/java/res/values-v19/emoji-categories.xml b/java/res/values-v19/emoji-categories.xml new file mode 100644 index 000000000..a6affc421 --- /dev/null +++ b/java/res/values-v19/emoji-categories.xml @@ -0,0 +1,922 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2013 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- Note: This emoji code point list is valid on KLP and later (API >= 19). + There is another emoji code point list for JB-MR2 under res/xml/values and values-v18.--> +<resources> + <!-- Dummy codeArrays for recents emoji keyboard. + Do not remove these keys, because they are used as a template. --> + <array + name="emoji_recents" + format="string" + > + <item>52</item> + <item>45</item> + <item>43</item> + <item>45</item> + <item>4E</item> + <item>54</item> + </array> + <array + name="emoji_nature" + format="string" + > + <item>1f415</item> + <item>1f436</item> + <item>1f429</item> + <item>1f408</item> + <item>1f431</item> + <item>1f400</item> + <item>1f401</item> + <item>1f42d</item> + <item>1f439</item> + <item>1f422</item> + <item>1f407</item> + <item>1f430</item> + <item>1f413</item> + <item>1f414</item> + <item>1f423</item> + <item>1f424</item> + <item>1f425</item> + <item>1f426</item> + <item>1f40f</item> + <item>1f411</item> + <item>1f410</item> + <item>1f43a</item> + <item>1f403</item> + <item>1f402</item> + <item>1f404</item> + <item>1f42e</item> + <item>1f434</item> + <item>1f417</item> + <item>1f416</item> + <item>1f437</item> + <item>1f43d</item> + <item>1f438</item> + <item>1f40d</item> + <item>1f43c</item> + <item>1f427</item> + <item>1f418</item> + <item>1f428</item> + <item>1f412</item> + <item>1f435</item> + <item>1f406</item> + <item>1f42f</item> + <item>1f43b</item> + <item>1f42b</item> + <item>1f42a</item> + <item>1f40a</item> + <item>1f433</item> + <item>1f40b</item> + <item>1f41f</item> + <item>1f420</item> + <item>1f421</item> + <item>1f419</item> + <item>1f41a</item> + <item>1f42c</item> + <item>1f40c</item> + <item>1f41b</item> + <item>1f41c</item> + <item>1f41d</item> + <item>1f41e</item> + <item>1f432</item> + <item>1f409</item> + <item>1f43e</item> + <item>1f378</item> + <item>1f37a</item> + <item>1f37b</item> + <item>1f377</item> + <item>1f379</item> + <item>1f376</item> + <item>2615</item> + <item>1f375</item> + <item>1f37c</item> + <item>1f374</item> + <item>1f368</item> + <item>1f367</item> + <item>1f366</item> + <item>1f369</item> + <item>1f370</item> + <item>1f36a</item> + <item>1f36b</item> + <item>1f36c</item> + <item>1f36d</item> + <item>1f36e</item> + <item>1f36f</item> + <item>1f373</item> + <item>1f354</item> + <item>1f35f</item> + <item>1f35d</item> + <item>1f355</item> + <item>1f356</item> + <item>1f357</item> + <item>1f364</item> + <item>1f363</item> + <item>1f371</item> + <item>1f35e</item> + <item>1f35c</item> + <item>1f359</item> + <item>1f35a</item> + <item>1f35b</item> + <item>1f372</item> + <item>1f365</item> + <item>1f362</item> + <item>1f361</item> + <item>1f358</item> + <item>1f360</item> + <item>1f34c</item> + <item>1f34e</item> + <item>1f34f</item> + <item>1f34a</item> + <item>1f34b</item> + <item>1f344</item> + <item>1f345</item> + <item>1f346</item> + <item>1f347</item> + <item>1f348</item> + <item>1f349</item> + <item>1f350</item> + <item>1f351</item> + <item>1f352</item> + <item>1f353</item> + <item>1f34d</item> + <item>1f330</item> + <item>1f331</item> + <item>1f332</item> + <item>1f333</item> + <item>1f334</item> + <item>1f335</item> + <item>1f337</item> + <item>1f338</item> + <item>1f339</item> + <item>1f340</item> + <item>1f341</item> + <item>1f342</item> + <item>1f343</item> + <item>1f33a</item> + <item>1f33b</item> + <item>1f33c</item> + <item>1f33d</item> + <item>1f33e</item> + <item>1f33f</item> + <item>2600</item> + <item>1f308</item> + <item>26c5</item> + <item>2601</item> + <item>1f301</item> + <item>1f302</item> + <item>2614</item> + <item>1f4a7</item> + <item>26a1</item> + <item>1f300</item> + <item>2744</item> + <item>26c4</item> + <item>1f319</item> + <item>1f31e</item> + <item>1f31d</item> + <item>1f31a</item> + <item>1f31b</item> + <item>1f31c</item> + <item>1f311</item> + <item>1f312</item> + <item>1f313</item> + <item>1f314</item> + <item>1f315</item> + <item>1f316</item> + <item>1f317</item> + <item>1f318</item> + <item>1f391</item> + <item>1f304</item> + <item>1f305</item> + <item>1f307</item> + <item>1f306</item> + <item>1f303</item> + <item>1f30c</item> + <item>1f309</item> + <item>1f30a</item> + <item>1f30b</item> + <item>1f30e</item> + <item>1f30f</item> + <item>1f30d</item> + <item>1f310</item> + </array> + <array + name="emoji_symbols" + format="string" + > + <item>fe82e|0031,20e3</item> + <item>fe82f|0032,20e3</item> + <item>fe830|0033,20e3</item> + <item>fe831|0034,20e3</item> + <item>fe832|0035,20e3</item> + <item>fe833|0036,20e3</item> + <item>fe834|0037,20e3</item> + <item>fe835|0038,20e3</item> + <item>fe836|0039,20e3</item> + <item>fe837|0030,20e3</item> + <item>1f51f</item> + <item>fe82c|0023,20e3</item> + <item>1f51d</item> + <item>1f519</item> + <item>1f51b</item> + <item>1f51c</item> + <item>1f51a</item> + <item>23f3</item> + <item>231b</item> + <item>23f0</item> + <item>2648</item> + <item>2649</item> + <item>264a</item> + <item>264b</item> + <item>264c</item> + <item>264d</item> + <item>264e</item> + <item>264f</item> + <item>2650</item> + <item>2651</item> + <item>2652</item> + <item>2653</item> + <item>26ce</item> + <item>1f531</item> + <item>1f52f</item> + <item>1f6bb</item> + <item>1f6ae</item> + <item>1f6af</item> + <item>1f6b0</item> + <item>1f6b1</item> + <item>1f170</item> + <item>1f171</item> + <item>1f18e</item> + <item>1f17e</item> + <item>1f4ae</item> + <item>1f4af</item> + <item>1f520</item> + <item>1f521</item> + <item>1f522</item> + <item>1f523</item> + <item>1f524</item> + <item>27bf</item> + <item>1f4f6</item> + <item>1f4f3</item> + <item>1f4f4</item> + <item>1f4f5</item> + <item>1f6b9</item> + <item>1f6ba</item> + <item>1f6bc</item> + <item>267f</item> + <item>267b</item> + <item>1f6ad</item> + <item>1f6a9</item> + <item>26a0</item> + <item>1f201</item> + <item>1f51e</item> + <item>26d4</item> + <item>1f192</item> + <item>1f197</item> + <item>1f195</item> + <item>1f198</item> + <item>1f199</item> + <item>1f193</item> + <item>1f196</item> + <item>1f19a</item> + <item>1f232</item> + <item>1f233</item> + <item>1f234</item> + <item>1f235</item> + <item>1f236</item> + <item>1f237</item> + <item>1f238</item> + <item>1f239</item> + <item>1f202</item> + <item>1f23a</item> + <item>1f250</item> + <item>1f251</item> + <item>3299</item> + <item>00ae</item> + <item>00a9</item> + <item>2122</item> + <item>1f21a</item> + <item>1f22f</item> + <item>3297</item> + <item>2b55</item> + <item>274c</item> + <item>274e</item> + <item>2139</item> + <item>1f6ab</item> + <item>2705</item> + <item>2714</item> + <item>1f517</item> + <item>2734</item> + <item>2733</item> + <item>2795</item> + <item>2796</item> + <item>2716</item> + <item>2797</item> + <item>1f4a0</item> + <item>1f4a1</item> + <item>1f4a4</item> + <item>1f4a2</item> + <item>1f525</item> + <item>1f4a5</item> + <item>1f4a8</item> + <item>1f4a6</item> + <item>1f4ab</item> + <item>1f55b</item> + <item>1f567</item> + <item>1f550</item> + <item>1f55c</item> + <item>1f551</item> + <item>1f55d</item> + <item>1f552</item> + <item>1f55e</item> + <item>1f553</item> + <item>1f55f</item> + <item>1f554</item> + <item>1f560</item> + <item>1f555</item> + <item>1f561</item> + <item>1f556</item> + <item>1f562</item> + <item>1f557</item> + <item>1f563</item> + <item>1f558</item> + <item>1f564</item> + <item>1f559</item> + <item>1f565</item> + <item>1f55a</item> + <item>1f566</item> + <item>2195</item> + <item>2b06</item> + <item>2197</item> + <item>27a1</item> + <item>2198</item> + <item>2b07</item> + <item>2199</item> + <item>2b05</item> + <item>2196</item> + <item>2194</item> + <item>2934</item> + <item>2935</item> + <item>23ea</item> + <item>23eb</item> + <item>23ec</item> + <item>23e9</item> + <item>25c0</item> + <item>25b6</item> + <item>1f53d</item> + <item>1f53c</item> + <item>2747</item> + <item>2728</item> + <item>1f534</item> + <item>1f535</item> + <item>26aa</item> + <item>26ab</item> + <item>1f533</item> + <item>1f532</item> + <item>2b50</item> + <item>1f31f</item> + <item>1f320</item> + <item>25ab</item> + <item>25aa</item> + <item>25fd</item> + <item>25fe</item> + <item>25fb</item> + <item>25fc</item> + <item>2b1c</item> + <item>2b1b</item> + <item>1f538</item> + <item>1f539</item> + <item>1f536</item> + <item>1f537</item> + <item>1f53a</item> + <item>1f53b</item> + <item>2754</item> + <item>2753</item> + <item>2755</item> + <item>2757</item> + <item>203c</item> + <item>2049</item> + <item>3030</item> + <item>27b0</item> + <item>2660</item> + <item>2665</item> + <item>2663</item> + <item>2666</item> + <item>1f194</item> + <item>1f511</item> + <item>21a9</item> + <item>1f191</item> + <item>1f50d</item> + <item>1f512</item> + <item>1f513</item> + <item>21aa</item> + <item>1f510</item> + <item>2611</item> + <item>1f518</item> + <item>1f50e</item> + <item>1f516</item> + <item>1f50f</item> + <item>1f503</item> + <item>1f500</item> + <item>1f501</item> + <item>1f502</item> + <item>1f504</item> + <item>1f4e7</item> + <item>1f505</item> + <item>1f506</item> + <item>1f507</item> + <item>1f508</item> + <item>1f509</item> + <item>1f50a</item> + </array> + <array + name="emoji_faces" + format="string" + > + <item>263a</item> + <item>1f60a</item> + <item>1f600</item> + <item>1f601</item> + <item>1f602</item> + <item>1f603</item> + <item>1f604</item> + <item>1f605</item> + <item>1f606</item> + <item>1f607</item> + <item>1f608</item> + <item>1f609</item> + <item>1f62f</item> + <item>1f610</item> + <item>1f611</item> + <item>1f615</item> + <item>1f620</item> + <item>1f62c</item> + <item>1f621</item> + <item>1f622</item> + <item>1f634</item> + <item>1f62e</item> + <item>1f623</item> + <item>1f624</item> + <item>1f625</item> + <item>1f626</item> + <item>1f627</item> + <item>1f628</item> + <item>1f629</item> + <item>1f630</item> + <item>1f61f</item> + <item>1f631</item> + <item>1f632</item> + <item>1f633</item> + <item>1f635</item> + <item>1f636</item> + <item>1f637</item> + <item>1f61e</item> + <item>1f612</item> + <item>1f60d</item> + <item>1f61b</item> + <item>1f61c</item> + <item>1f61d</item> + <item>1f60b</item> + <item>1f617</item> + <item>1f619</item> + <item>1f618</item> + <item>1f61a</item> + <item>1f60e</item> + <item>1f62d</item> + <item>1f60c</item> + <item>1f616</item> + <item>1f614</item> + <item>1f62a</item> + <item>1f60f</item> + <item>1f613</item> + <item>1f62b</item> + <item>1f64b</item> + <item>1f64c</item> + <item>1f64d</item> + <item>1f645</item> + <item>1f646</item> + <item>1f647</item> + <item>1f64e</item> + <item>1f64f</item> + <item>1f63a</item> + <item>1f63c</item> + <item>1f638</item> + <item>1f639</item> + <item>1f63b</item> + <item>1f63d</item> + <item>1f63f</item> + <item>1f63e</item> + <item>1f640</item> + <item>1f648</item> + <item>1f649</item> + <item>1f64a</item> + <item>1f4a9</item> + <item>1f476</item> + <item>1f466</item> + <item>1f467</item> + <item>1f468</item> + <item>1f469</item> + <item>1f474</item> + <item>1f475</item> + <item>1f48f</item> + <item>1f491</item> + <item>1f46a</item> + <item>1f46b</item> + <item>1f46c</item> + <item>1f46d</item> + <item>1f464</item> + <item>1f465</item> + <item>1f46e</item> + <item>1f477</item> + <item>1f481</item> + <item>1f482</item> + <item>1f46f</item> + <item>1f470</item> + <item>1f478</item> + <item>1f385</item> + <item>1f47c</item> + <item>1f471</item> + <item>1f472</item> + <item>1f473</item> + <item>1f483</item> + <item>1f486</item> + <item>1f487</item> + <item>1f485</item> + <item>1f47b</item> + <item>1f479</item> + <item>1f47a</item> + <item>1f47d</item> + <item>1f47e</item> + <item>1f47f</item> + <item>1f480</item> + <item>1f4aa</item> + <item>1f440</item> + <item>1f442</item> + <item>1f443</item> + <item>1f463</item> + <item>1f444</item> + <item>1f445</item> + <item>1f48b</item> + <item>2764</item> + <item>1f499</item> + <item>1f49a</item> + <item>1f49b</item> + <item>1f49c</item> + <item>1f493</item> + <item>1f494</item> + <item>1f495</item> + <item>1f496</item> + <item>1f497</item> + <item>1f498</item> + <item>1f49d</item> + <item>1f49e</item> + <item>1f49f</item> + <item>1f44d</item> + <item>1f44e</item> + <item>1f44c</item> + <item>270a</item> + <item>270c</item> + <item>270b</item> + <item>1f44a</item> + <item>261d</item> + <item>1f446</item> + <item>1f447</item> + <item>1f448</item> + <item>1f449</item> + <item>1f44b</item> + <item>1f44f</item> + <item>1f450</item> + </array> + <array + name="emoji_objects" + format="string" + > + <item>1f530</item> + <item>1f484</item> + <item>1f45e</item> + <item>1f45f</item> + <item>1f451</item> + <item>1f452</item> + <item>1f3a9</item> + <item>1f393</item> + <item>1f453</item> + <item>231a</item> + <item>1f454</item> + <item>1f455</item> + <item>1f456</item> + <item>1f457</item> + <item>1f458</item> + <item>1f459</item> + <item>1f460</item> + <item>1f461</item> + <item>1f462</item> + <item>1f45a</item> + <item>1f45c</item> + <item>1f4bc</item> + <item>1f392</item> + <item>1f45d</item> + <item>1f45b</item> + <item>1f4b0</item> + <item>1f4b3</item> + <item>1f4b2</item> + <item>1f4b5</item> + <item>1f4b4</item> + <item>1f4b6</item> + <item>1f4b7</item> + <item>1f4b8</item> + <item>1f4b1</item> + <item>1f4b9</item> + <item>1f52b</item> + <item>1f52a</item> + <item>1f4a3</item> + <item>1f489</item> + <item>1f48a</item> + <item>1f6ac</item> + <item>1f514</item> + <item>1f515</item> + <item>1f6aa</item> + <item>1f52c</item> + <item>1f52d</item> + <item>1f52e</item> + <item>1f526</item> + <item>1f50b</item> + <item>1f50c</item> + <item>1f4dc</item> + <item>1f4d7</item> + <item>1f4d8</item> + <item>1f4d9</item> + <item>1f4da</item> + <item>1f4d4</item> + <item>1f4d2</item> + <item>1f4d1</item> + <item>1f4d3</item> + <item>1f4d5</item> + <item>1f4d6</item> + <item>1f4f0</item> + <item>1f4db</item> + <item>1f383</item> + <item>1f384</item> + <item>1f380</item> + <item>1f381</item> + <item>1f382</item> + <item>1f388</item> + <item>1f386</item> + <item>1f387</item> + <item>1f389</item> + <item>1f38a</item> + <item>1f38d</item> + <item>1f38f</item> + <item>1f38c</item> + <item>1f390</item> + <item>1f38b</item> + <item>1f38e</item> + <item>1f4f1</item> + <item>1f4f2</item> + <item>1f4df</item> + <item>260e</item> + <item>1f4de</item> + <item>1f4e0</item> + <item>1f4e6</item> + <item>2709</item> + <item>1f4e8</item> + <item>1f4e9</item> + <item>1f4ea</item> + <item>1f4eb</item> + <item>1f4ed</item> + <item>1f4ec</item> + <item>1f4ee</item> + <item>1f4e4</item> + <item>1f4e5</item> + <item>1f4ef</item> + <item>1f4e2</item> + <item>1f4e3</item> + <item>1f4e1</item> + <item>1f4ac</item> + <item>1f4ad</item> + <item>2712</item> + <item>270f</item> + <item>1f4dd</item> + <item>1f4cf</item> + <item>1f4d0</item> + <item>1f4cd</item> + <item>1f4cc</item> + <item>1f4ce</item> + <item>2702</item> + <item>1f4ba</item> + <item>1f4bb</item> + <item>1f4bd</item> + <item>1f4be</item> + <item>1f4bf</item> + <item>1f4c6</item> + <item>1f4c5</item> + <item>1f4c7</item> + <item>1f4cb</item> + <item>1f4c1</item> + <item>1f4c2</item> + <item>1f4c3</item> + <item>1f4c4</item> + <item>1f4ca</item> + <item>1f4c8</item> + <item>1f4c9</item> + <item>26fa</item> + <item>1f3a1</item> + <item>1f3a2</item> + <item>1f3a0</item> + <item>1f3aa</item> + <item>1f3a8</item> + <item>1f3ac</item> + <item>1f3a5</item> + <item>1f4f7</item> + <item>1f4f9</item> + <item>1f3a6</item> + <item>1f3ad</item> + <item>1f3ab</item> + <item>1f3ae</item> + <item>1f3b2</item> + <item>1f3b0</item> + <item>1f0cf</item> + <item>1f3b4</item> + <item>1f004</item> + <item>1f3af</item> + <item>1f4fa</item> + <item>1f4fb</item> + <item>1f4c0</item> + <item>1f4fc</item> + <item>1f3a7</item> + <item>1f3a4</item> + <item>1f3b5</item> + <item>1f3b6</item> + <item>1f3bc</item> + <item>1f3bb</item> + <item>1f3b9</item> + <item>1f3b7</item> + <item>1f3ba</item> + <item>1f3b8</item> + <item>303d</item> + </array> + <array + name="emoji_places" + format="string" + > + <item>1f3e0</item> + <item>1f3e1</item> + <item>1f3e2</item> + <item>1f3e3</item> + <item>1f3e4</item> + <item>1f3e5</item> + <item>1f3e6</item> + <item>1f3e7</item> + <item>1f3e8</item> + <item>1f3e9</item> + <item>1f3ea</item> + <item>1f3eb</item> + <item>26ea</item> + <item>26f2</item> + <item>1f3ec</item> + <item>1f3ef</item> + <item>1f3f0</item> + <item>1f3ed</item> + <item>1f5fb</item> + <item>1f5fc</item> + <item>1f5fd</item> + <item>1f5fe</item> + <item>1f5ff</item> + <item>2693</item> + <item>1f3ee</item> + <item>1f488</item> + <item>1f527</item> + <item>1f528</item> + <item>1f529</item> + <item>1f6bf</item> + <item>1f6c1</item> + <item>1f6c0</item> + <item>1f6bd</item> + <item>1f6be</item> + <item>1f3bd</item> + <item>1f3a3</item> + <item>1f3b1</item> + <item>1f3b3</item> + <item>26be</item> + <item>26f3</item> + <item>1f3be</item> + <item>26bd</item> + <item>1f3bf</item> + <item>1f3c0</item> + <item>1f3c1</item> + <item>1f3c2</item> + <item>1f3c3</item> + <item>1f3c4</item> + <item>1f3c6</item> + <item>1f3c7</item> + <item>1f40e</item> + <item>1f3c8</item> + <item>1f3c9</item> + <item>1f3ca</item> + <item>1f682</item> + <item>1f683</item> + <item>1f684</item> + <item>1f685</item> + <item>1f686</item> + <item>1f687</item> + <item>24c2</item> + <item>1f688</item> + <item>1f68a</item> + <item>1f68b</item> + <item>1f68c</item> + <item>1f68d</item> + <item>1f68e</item> + <item>1f68f</item> + <item>1f690</item> + <item>1f691</item> + <item>1f692</item> + <item>1f693</item> + <item>1f694</item> + <item>1f695</item> + <item>1f696</item> + <item>1f697</item> + <item>1f698</item> + <item>1f699</item> + <item>1f69a</item> + <item>1f69b</item> + <item>1f69c</item> + <item>1f69d</item> + <item>1f69e</item> + <item>1f69f</item> + <item>1f6a0</item> + <item>1f6a1</item> + <item>1f6a2</item> + <item>1f6a3</item> + <item>1f681</item> + <item>2708</item> + <item>1f6c2</item> + <item>1f6c3</item> + <item>1f6c4</item> + <item>1f6c5</item> + <item>26f5</item> + <item>1f6b2</item> + <item>1f6b3</item> + <item>1f6b4</item> + <item>1f6b5</item> + <item>1f6b7</item> + <item>1f6b8</item> + <item>1f689</item> + <item>1f680</item> + <item>1f6a4</item> + <item>1f6b6</item> + <item>26fd</item> + <item>1f17f</item> + <item>1f6a5</item> + <item>1f6a6</item> + <item>1f6a7</item> + <item>1f6a8</item> + <item>2668</item> + <item>1f48c</item> + <item>1f48d</item> + <item>1f48e</item> + <item>1f490</item> + <item>1f492</item> + <item>fe4e5|1f1ef,1f1f5</item> + <item>fe4e6|1f1fa,1f1f8</item> + <item>fe4e7|1f1eb,1f1f7</item> + <item>fe4e8|1f1e9,1f1ea</item> + <item>fe4e9|1f1ee,1f1f9</item> + <item>fe4ea|1f1ec,1f1e7</item> + <item>fe4eb|1f1ea,1f1f8</item> + <item>fe4ec|1f1f7,1f1fa</item> + <item>fe4ed|1f1e8,1f1f3</item> + <item>fe4ee|1f1f0,1f1f7</item> + </array> + <array + name="emoji_emoticons" + format="string" + > + <item>=-O</item> + <item>:-P</item> + <item>;-)</item> + <item>:-(</item> + <item>:-)</item> + <item>:-!</item> + <item>:-$</item> + <item>B-)</item> + <item>:O</item> + <item>:-*</item> + <item>:-D</item> + <item>:\'(</item> + <item>:-\\</item> + <item>O:-)</item> + <item>:-[</item> + </array> +</resources> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 5c59f5f68..159a64adc 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -1,17 +1,21 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 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. +<!-- +/* +** +** Copyright 2010, 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> @@ -26,11 +30,12 @@ <attr name="moreKeysKeyboardStyle" format="reference" /> <!-- MoreKeysKeyboardView style --> <attr name="moreKeysKeyboardViewStyle" format="reference" /> - <attr name="moreKeysKeyboardPanelStyle" format="reference" /> <!-- Suggestions strip style --> <attr name="suggestionStripViewStyle" format="reference" /> - <attr name="moreSuggestionsViewStyle" format="reference" /> - <attr name="suggestionBackgroundStyle" format="reference" /> + <!-- Styled attributes for android:background --> + <attr name="moreKeysKeyboardBackground" format="reference" /> + <attr name="suggestionStripBackground" format="reference" /> + <attr name="suggestionBackground" format="reference" /> </declare-styleable> <declare-styleable name="KeyboardView"> @@ -169,10 +174,6 @@ <attr name="colorTypedWord" format="color" /> <attr name="colorAutoCorrect" format="color" /> <attr name="colorSuggested" format="color" /> - <attr name="alphaValidTypedWord" format="fraction" /> - <attr name="alphaTypedWord" format="fraction" /> - <attr name="alphaAutoCorrect" format="fraction" /> - <attr name="alphaSuggested" format="fraction" /> <attr name="alphaObsoleted" format="fraction" /> <attr name="suggestionsCountInStrip" format="integer" /> <attr name="centerSuggestionPercentile" format="fraction" /> @@ -219,6 +220,11 @@ <attr name="iconEmojiKey" format="reference" /> </declare-styleable> + <declare-styleable name="Keyboard_GridRows"> + <attr name="codesArray" format="reference" /> + <attr name="textsArray" format="reference" /> + </declare-styleable> + <declare-styleable name="Keyboard_Key"> <!-- The unicode value that this key outputs. Code value represented in hexadecimal prefixed with "0x" or code value reference using @@ -374,10 +380,16 @@ <enum name="alphabetShiftLocked" value="3" /> <enum name="alphabetShiftLockShifted" value="4" /> <enum name="symbols" value="5" /> - <enum name="symbolsShifted" value="6" /> <enum name="phone" value="7" /> <enum name="phoneSymbols" value="8" /> <enum name="number" value="9" /> + <enum name="emojiRecents" value="10" /> + <enum name="emojiCategory1" value="11" /> + <enum name="emojiCategory2" value="12" /> + <enum name="emojiCategory3" value="13" /> + <enum name="emojiCategory4" value="14" /> + <enum name="emojiCategory5" value="15" /> + <enum name="emojiCategory6" value="16" /> </attr> <!-- This should be aligned with KeyboardId.MODE_* --> <attr name="mode" format="enum|string"> @@ -429,10 +441,16 @@ <enum name="alphabetShiftLocked" value="3" /> <enum name="alphabetShiftLockShifted" value="4" /> <enum name="symbols" value="5" /> - <enum name="symbolsShifted" value="6" /> <enum name="phone" value="7" /> <enum name="phoneSymbols" value="8" /> <enum name="number" value="9" /> + <enum name="emojiRecents" value="10" /> + <enum name="emojiCategory1" value="11" /> + <enum name="emojiCategory2" value="12" /> + <enum name="emojiCategory3" value="13" /> + <enum name="emojiCategory4" value="14" /> + <enum name="emojiCategory5" value="15" /> + <enum name="emojiCategory6" value="16" /> </attr> <attr name="elementKeyboard" format="reference"/> <!-- Enable proximity characters correction. Disabled by default. --> diff --git a/java/res/values/colors.xml b/java/res/values/colors.xml index daa167c8a..ea762f977 100644 --- a/java/res/values/colors.xml +++ b/java/res/values/colors.xml @@ -1,47 +1,43 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 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. +<!-- +/* +** +** Copyright 2012, 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 xmlns:android="http://schemas.android.com/apk/res/android"> - <!-- Color resources for default, and Gingerbread theme. --> - <color name="highlight_color_default">#FFFCAE00</color> - <color name="highlight_translucent_color_default">#99FCAE00</color> - <color name="key_text_color_default">@android:color/white</color> - <color name="key_text_shadow_color_default">#BB000000</color> - <color name="key_text_inactivated_color_default">@android:color/white</color> - <color name="key_hint_letter_color_default">#80000000</color> - <color name="key_hint_label_color_default">#E0E0E4E5</color> - <color name="key_shifted_letter_hint_inactivated_color_default">#66E0E4E5</color> - <color name="key_shifted_letter_hint_activated_color_default">#CCE0E4E5</color> - <color name="spacebar_text_color_default">#FFC0C0C0</color> - <color name="spacebar_text_shadow_color_default">#80000000</color> - <color name="typed_word_color_default">@android:color/white</color> - <color name="gesture_floating_preview_color_default">#C0000000</color> - <!-- Color resources for Stone theme. --> - <color name="key_text_color_stone">@android:color/black</color> - <color name="key_text_shadow_color_stone">@android:color/white</color> - <color name="key_text_inactivated_color_stone">#FF808080</color> - <color name="key_hint_letter_color_stone">#80000000</color> - <color name="key_hint_label_color_stone">#E0000000</color> - <color name="key_shifted_letter_hint_inactivated_color_stone">#66000000</color> - <color name="key_shifted_letter_hint_activated_color_stone">#CC000000</color> - <color name="spacebar_text_color_stone">@android:color/black</color> - <color name="spacebar_text_shadow_color_stone">#D0FFFFFF</color> + <!-- Color resources for Gingerbread theme. --> + <color name="highlight_color_gb">#FFFCAE00</color> + <color name="typed_word_color_gb">@android:color/white</color> + <color name="highlight_translucent_color_gb">#99FCAE00</color> + <color name="key_text_color_gb">@android:color/white</color> + <color name="key_text_shadow_color_gb">#BB000000</color> + <color name="key_text_inactivated_color_gb">#66E0E4E5</color> + <color name="key_hint_letter_color_gb">#80000000</color> + <color name="key_hint_label_color_gb">#E0E0E4E5</color> + <color name="key_shifted_letter_hint_inactivated_color_gb">#66E0E4E5</color> + <color name="key_shifted_letter_hint_activated_color_gb">#CCE0E4E5</color> + <color name="spacebar_text_color_gb">#FFC0C0C0</color> + <color name="spacebar_text_shadow_color_gb">#80000000</color> + <color name="gesture_floating_preview_color_gb">#C0000000</color> <!-- Color resources for IceCreamSandwich theme. --> <!-- android:color/holo_blue_light value is #FF33B5E5 --> - <color name="highlight_color_ics">@android:color/holo_blue_light</color> + <color name="highlight_color_ics">#FF33B5E5</color> + <color name="typed_word_color_ics">#D833B5E5</color> + <color name="suggested_word_color_ics">#B233B5E5</color> <color name="highlight_translucent_color_ics">#9933B5E5</color> <color name="key_text_color_ics">@android:color/white</color> <color name="key_text_shadow_color_ics">@android:color/transparent</color> @@ -52,7 +48,7 @@ <color name="key_shifted_letter_hint_activated_color_ics">@android:color/white</color> <color name="spacebar_text_color_ics">#FFC0C0C0</color> <color name="spacebar_text_shadow_color_ics">#80000000</color> - <color name="typed_word_color_ics">@color/highlight_color_ics</color> + <color name="gesture_floating_preview_color_ics">#C0000000</color> <!-- Color resources for setup wizard and tutorial --> <color name="setup_background">#FFEBEBEB</color> <color name="setup_text_dark">#FF707070</color> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index d3a21f2aa..465d52cec 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -42,7 +42,7 @@ <integer name="config_keyboard_grid_height">16</integer> <integer name="config_double_space_period_timeout">1100</integer> <!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. --> - <string name="config_default_keyboard_theme_index" translatable="false">5</string> + <string name="config_default_keyboard_theme_index" translatable="false">0</string> <integer name="config_max_more_keys_column">5</integer> <!-- diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 98ae76cb1..599af124c 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -29,18 +29,11 @@ <dimen name="more_keys_keyboard_key_horizontal_padding">8dp</dimen> - <fraction name="keyboard_top_padding">1.556%p</fraction> - <fraction name="keyboard_bottom_padding">4.669%p</fraction> <fraction name="keyboard_left_padding">0%p</fraction> <fraction name="keyboard_right_padding">0%p</fraction> - <fraction name="key_bottom_gap">6.250%p</fraction> - <fraction name="key_horizontal_gap">1.352%p</fraction> - - <fraction name="keyboard_top_padding_stone">1.556%p</fraction> - <fraction name="keyboard_bottom_padding_stone">0.778%p</fraction> - <fraction name="key_bottom_gap_stone">7.506%p</fraction> - <fraction name="key_horizontal_gap_stone">1.739%p</fraction> + <fraction name="keyboard_top_padding_gb">1.556%p</fraction> + <fraction name="keyboard_bottom_padding_gb">4.669%p</fraction> <fraction name="key_bottom_gap_gb">6.495%p</fraction> <fraction name="key_horizontal_gap_gb">1.971%p</fraction> @@ -48,13 +41,12 @@ <fraction name="keyboard_bottom_padding_ics">4.669%p</fraction> <fraction name="key_bottom_gap_ics">6.127%p</fraction> <fraction name="key_horizontal_gap_ics">1.739%p</fraction> - <dimen name="more_keys_keyboard_horizontal_edges_padding_ics">4dp</dimen> <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> <!-- popup_key_height x 1.2 --> <dimen name="more_keys_keyboard_slide_allowance">63.36dp</dimen> <!-- popup_key_height x -1.0 --> - <dimen name="more_keys_keyboard_vertical_correction">-52.8dp</dimen> + <dimen name="more_keys_keyboard_vertical_correction_gb">-52.8dp</dimen> <dimen name="keyboard_vertical_correction">0.0dp</dimen> <fraction name="key_letter_ratio">55%</fraction> @@ -67,7 +59,7 @@ <fraction name="key_preview_text_ratio">82%</fraction> <fraction name="spacebar_text_ratio">33.735%</fraction> <dimen name="key_preview_height">80dp</dimen> - <dimen name="key_preview_offset">-8.0dp</dimen> + <dimen name="key_preview_offset_gb">-8.0dp</dimen> <dimen name="key_label_horizontal_padding">4dp</dimen> <dimen name="key_hint_letter_padding">1dp</dimen> @@ -123,6 +115,9 @@ <dimen name="gesture_floating_preview_vertical_padding">16dp</dimen> <dimen name="gesture_floating_preview_round_radius">3dp</dimen> + <!-- Emoji keyboard --> + <fraction name="emoji_keyboard_key_width">14.2857%p</fraction> + <!-- Inset used in Accessibility mode to avoid accidental key presses when a finger slides off the screen. --> <dimen name="accessibility_edge_slop">8dp</dimen> diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 8983536af..52ebe161c 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -98,29 +98,17 @@ <string name="prefs_force_non_distinct_multitouch">Force non-distinct multitouch</string> <!-- Keyboard theme names --> - <string name="layout_basic">Basic</string> - <string name="layout_high_contrast">Basic (High Contrast)</string> - <string name="layout_stone_bold">Stone (bold)</string> - <string name="layout_stone_normal">Stone (normal)</string> <string name="layout_gingerbread">Gingerbread</string> <string name="layout_ics">IceCreamSandwich</string> <!-- For keyboard theme switcher dialog --> <string-array name="keyboard_layout_modes"> - <item>@string/layout_basic</item> - <item>@string/layout_high_contrast</item> - <item>@string/layout_stone_normal</item> - <item>@string/layout_stone_bold</item> - <item>@string/layout_gingerbread</item> <item>@string/layout_ics</item> + <item>@string/layout_gingerbread</item> </string-array> <string-array name="keyboard_layout_modes_values"> <item>0</item> <item>1</item> - <item>2</item> - <item>3</item> - <item>4</item> - <item>5</item> </string-array> <!-- Subtype locale display name exceptions. diff --git a/java/res/values/emoji-categories.xml b/java/res/values/emoji-categories.xml new file mode 100644 index 000000000..99d7b2389 --- /dev/null +++ b/java/res/values/emoji-categories.xml @@ -0,0 +1,83 @@ +<?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. +*/ +--> + +<!-- Note: This emoji code point list is valid prior to JB-MR2 (API < 18). + There is another emoji code point list for JB-MR2 and KLP and later under + res/xml/values-v1[89].--> +<resources> + <!-- Dummy codeArrays for recents emoji keyboard. + Do not remove these keys, because they are used as a template. --> + <array + name="emoji_recents" + format="string" + > + <item>52</item> + <item>45</item> + <item>43</item> + <item>45</item> + <item>4E</item> + <item>54</item> + </array> + <array + name="emoji_nature" + format="string" + > + </array> + <array + name="emoji_symbols" + format="string" + > + </array> + <array + name="emoji_faces" + format="string" + > + </array> + <array + name="emoji_objects" + format="string" + > + </array> + <array + name="emoji_places" + format="string" + > + </array> + <array + name="emoji_emoticons" + format="string" + > + <item>=-O</item> + <item>:-P</item> + <item>;-)</item> + <item>:-(</item> + <item>:-)</item> + <item>:-!</item> + <item>:-$</item> + <item>B-)</item> + <item>:O</item> + <item>:-*</item> + <item>:-D</item> + <item>:\'(</item> + <item>:-\\</item> + <item>O:-)</item> + <item>:-[</item> + </array> +</resources> diff --git a/java/res/values/keyboard-icons-black.xml b/java/res/values/keyboard-icons-black.xml deleted file mode 100644 index c1b1b6573..000000000 --- a/java/res/values/keyboard-icons-black.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardIcons.Black"> - <!-- Keyboard icons --> - <!-- TODO: The following holo icon for phone (drawable-hdpi and drawable-xhdpi) are too - ambiguous. - sym_bkeyboard_voice_off - --> - <item name="iconShiftKey">@drawable/sym_bkeyboard_shift</item> - <item name="iconDeleteKey">@drawable/sym_bkeyboard_delete</item> - <item name="iconSettingsKey">@drawable/sym_bkeyboard_settings</item> - <item name="iconSpaceKey">@drawable/sym_bkeyboard_space</item> - <item name="iconEnterKey">@drawable/sym_bkeyboard_return</item> - <item name="iconSearchKey">@drawable/sym_bkeyboard_search</item> - <item name="iconTabKey">@drawable/sym_bkeyboard_tab</item> - <item name="iconShortcutKey">@drawable/sym_bkeyboard_mic</item> - <item name="iconShortcutForLabel">@drawable/sym_bkeyboard_label_mic</item> - <item name="iconSpaceKeyForNumberLayout">@drawable/sym_bkeyboard_space</item> - <item name="iconShiftKeyShifted">@drawable/sym_bkeyboard_shift_locked</item> - <item name="iconShortcutKeyDisabled">@drawable/sym_bkeyboard_voice_off</item> - <item name="iconTabKeyPreview">@drawable/sym_keyboard_feedback_tab</item> - <!-- TODO: Needs dedicated black theme globe icon --> - <item name="iconLanguageSwitchKey">@drawable/sym_keyboard_language_switch</item> - <!-- TODO: Needs dedicated black theme ZWNJ and ZWJ icons --> - <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> - <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> - <item name="iconEmojiKey">@drawable/ic_emoji_light</item> - </style> -</resources> diff --git a/java/res/values/keyboard-icons-ics.xml b/java/res/values/keyboard-icons-ics.xml deleted file mode 100644 index 5ada27ae8..000000000 --- a/java/res/values/keyboard-icons-ics.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardIcons.IceCreamSandwich"> - <!-- Keyboard icons --> - <!-- TODO: The following holo icon for phone (drawable-hdpi and drawable-xhdpi) are missing. - sym_keyboard_123_mic_holo - --> - <item name="iconShiftKey">@drawable/sym_keyboard_shift_holo</item> - <item name="iconDeleteKey">@drawable/sym_keyboard_delete_holo</item> - <item name="iconSettingsKey">@drawable/sym_keyboard_settings_holo</item> - <item name="iconSpaceKey">@null</item> - <item name="iconEnterKey">@drawable/sym_keyboard_return_holo</item> - <item name="iconSearchKey">@drawable/sym_keyboard_search_holo</item> - <item name="iconTabKey">@drawable/sym_keyboard_tab_holo</item> - <item name="iconShortcutKey">@drawable/sym_keyboard_voice_holo</item> - <item name="iconShortcutForLabel">@drawable/sym_keyboard_label_mic_holo</item> - <item name="iconSpaceKeyForNumberLayout">@drawable/sym_keyboard_space_holo</item> - <item name="iconShiftKeyShifted">@drawable/sym_keyboard_shift_locked_holo</item> - <item name="iconShortcutKeyDisabled">@drawable/sym_keyboard_voice_off_holo</item> - <item name="iconTabKeyPreview">@drawable/sym_keyboard_feedback_tab</item> - <item name="iconLanguageSwitchKey">@drawable/sym_keyboard_language_switch</item> - <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> - <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> - <item name="iconEmojiKey">@drawable/ic_emoji_light</item> - </style> -</resources> diff --git a/java/res/values/keyboard-icons-white.xml b/java/res/values/keyboard-icons-white.xml deleted file mode 100644 index 7c6de42fa..000000000 --- a/java/res/values/keyboard-icons-white.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardIcons"> - <!-- Keyboard icons --> - <item name="iconShiftKey">@drawable/sym_keyboard_shift</item> - <item name="iconDeleteKey">@drawable/sym_keyboard_delete</item> - <item name="iconSettingsKey">@drawable/sym_keyboard_settings</item> - <item name="iconSpaceKey">@drawable/sym_keyboard_space</item> - <item name="iconEnterKey">@drawable/sym_keyboard_return</item>ZZ - <item name="iconSearchKey">@drawable/sym_keyboard_search</item> - <item name="iconTabKey">@drawable/sym_keyboard_tab</item> - <item name="iconShortcutKey">@drawable/sym_keyboard_mic</item> - <item name="iconShortcutForLabel">@drawable/sym_keyboard_label_mic</item> - <item name="iconSpaceKeyForNumberLayout">@drawable/sym_keyboard_space</item> - <item name="iconShiftKeyShifted">@drawable/sym_keyboard_shift_locked</item> - <!-- TODO: Needs non-holo disabled shortcut icon drawable --> - <item name="iconShortcutKeyDisabled">@drawable/sym_keyboard_voice_off_holo</item> - <item name="iconTabKeyPreview">@drawable/sym_keyboard_feedback_tab</item> - <item name="iconLanguageSwitchKey">@drawable/sym_keyboard_language_switch</item> - <!-- TODO: Needs dedicated black theme ZWNJ and ZWJ icons --> - <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> - <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> - <item name="iconEmojiKey">@drawable/ic_emoji_dark</item> - </style> -</resources> diff --git a/java/res/values/setup-styles.xml b/java/res/values/setup-styles.xml index 1ffe8ca46..c968b2fc6 100644 --- a/java/res/values/setup-styles.xml +++ b/java/res/values/setup-styles.xml @@ -1,17 +1,21 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2013 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +<!-- +/* +** +** 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 xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml deleted file mode 100644 index 37c6a9553..000000000 --- a/java/res/values/styles.xml +++ /dev/null @@ -1,415 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 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 xmlns:android="http://schemas.android.com/apk/res/android"> - <!-- Theme "Basic" --> - <style name="Keyboard"> - <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> - <item name="themeId">0</item> - <item name="touchPositionCorrectionData">@array/touch_position_correction_data_default</item> - <item name="rowHeight">25%p</item> - <item name="moreKeysTemplate">@xml/kbd_more_keys_keyboard_template</item> - <item name="keyboardTopPadding">@fraction/keyboard_top_padding</item> - <item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding</item> - <item name="keyboardLeftPadding">@fraction/keyboard_left_padding</item> - <item name="keyboardRightPadding">@fraction/keyboard_right_padding</item> - <item name="horizontalGap">@fraction/key_horizontal_gap</item> - <item name="verticalGap">@fraction/key_bottom_gap</item> - <item name="maxMoreKeysColumn">@integer/config_max_more_keys_column</item> - </style> - <style name="KeyboardView"> - <item name="android:background">@drawable/keyboard_background</item> - <item name="keyBackground">@drawable/btn_keyboard_key</item> - <item name="keyLetterSize">@fraction/key_letter_ratio</item> - <item name="keyLargeLetterRatio">@fraction/key_large_letter_ratio</item> - <item name="keyLabelSize">@fraction/key_label_ratio</item> - <item name="keyLargeLabelRatio">@fraction/key_large_label_ratio</item> - <item name="keyHintLetterRatio">@fraction/key_hint_letter_ratio</item> - <item name="keyHintLabelRatio">@fraction/key_hint_label_ratio</item> - <item name="keyShiftedLetterHintRatio">@fraction/key_uppercase_letter_ratio</item> - <item name="keyTypeface">normal</item> - <item name="keyTextColor">@color/key_text_color_default</item> - <item name="keyTextInactivatedColor">@color/key_text_color_default</item> - <item name="keyHintLetterColor">@color/key_hint_letter_color_default</item> - <item name="keyHintLabelColor">@color/key_hint_label_color_default</item> - <item name="keyShiftedLetterHintInactivatedColor">@color/key_shifted_letter_hint_inactivated_color_default</item> - <item name="keyShiftedLetterHintActivatedColor">@color/key_shifted_letter_hint_activated_color_default</item> - <item name="keyLabelHorizontalPadding">@dimen/key_label_horizontal_padding</item> - <item name="keyHintLetterPadding">@dimen/key_hint_letter_padding</item> - <item name="keyPopupHintLetterPadding">@dimen/key_popup_hint_letter_padding</item> - <item name="keyShiftedLetterHintPadding">@dimen/key_uppercase_letter_padding</item> - <item name="keyPreviewTextColor">@color/key_text_color_default</item> - <item name="keyPreviewTextRatio">@fraction/key_preview_text_ratio</item> - <item name="verticalCorrection">@dimen/keyboard_vertical_correction</item> - <item name="keyTextShadowColor">@color/key_text_shadow_color_default</item> - <item name="keyTextShadowRadius">2.75</item> - <item name="backgroundDimAlpha">128</item> - <item name="gestureFloatingPreviewTextSize">@dimen/gesture_floating_preview_text_size</item> - <item name="gestureFloatingPreviewTextColor">@color/highlight_color_default</item> - <item name="gestureFloatingPreviewTextOffset">@dimen/gesture_floating_preview_text_offset</item> - <item name="gestureFloatingPreviewColor">@color/gesture_floating_preview_color_default</item> - <item name="gestureFloatingPreviewHorizontalPadding">@dimen/gesture_floating_preview_horizontal_padding</item> - <item name="gestureFloatingPreviewVerticalPadding">@dimen/gesture_floating_preview_vertical_padding</item> - <item name="gestureFloatingPreviewRoundRadius">@dimen/gesture_floating_preview_round_radius</item> - <item name="gestureTrailMinSamplingDistance">@dimen/gesture_trail_min_sampling_distance</item> - <item name="gestureTrailMaxInterpolationAngularThreshold">@integer/gesture_trail_max_interpolation_angular_threshold</item> - <item name="gestureTrailMaxInterpolationDistanceThreshold">@dimen/gesture_trail_max_interpolation_distance_threshold</item> - <item name="gestureTrailMaxInterpolationSegments">@integer/gesture_trail_max_interpolation_segments</item> - <item name="gestureTrailFadeoutStartDelay">@integer/config_gesture_trail_fadeout_start_delay</item> - <item name="gestureTrailFadeoutDuration">@integer/config_gesture_trail_fadeout_duration</item> - <item name="gestureTrailUpdateInterval">@integer/config_gesture_trail_update_interval</item> - <item name="gestureTrailColor">@color/highlight_color_default</item> - <item name="gestureTrailStartWidth">@dimen/gesture_trail_start_width</item> - <item name="gestureTrailEndWidth">@dimen/gesture_trail_end_width</item> - <item name="gestureTrailBodyRatio">@integer/gesture_trail_body_ratio</item> - <item name="gestureTrailShadowRatio">@integer/gesture_trail_shadow_ratio</item> - <!-- Common attributes of MainKeyboardView --> - <item name="keyHysteresisDistance">@dimen/config_key_hysteresis_distance</item> - <item name="keyHysteresisDistanceForSlidingModifier">@dimen/config_key_hysteresis_distance_for_sliding_modifier</item> - <item name="touchNoiseThresholdTime">@integer/config_touch_noise_threshold_time</item> - <item name="touchNoiseThresholdDistance">@dimen/config_touch_noise_threshold_distance</item> - <item name="slidingKeyInputEnable">@bool/config_sliding_key_input_enabled</item> - <item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_default</item> - <item name="slidingKeyInputPreviewWidth">@dimen/config_sliding_key_input_preview_width</item> - <item name="slidingKeyInputPreviewBodyRatio">@integer/config_sliding_key_input_preview_body_ratio</item> - <item name="slidingKeyInputPreviewShadowRatio">@integer/config_sliding_key_input_preview_shadow_ratio</item> - <item name="keyRepeatStartTimeout">@integer/config_key_repeat_start_timeout</item> - <item name="keyRepeatInterval">@integer/config_key_repeat_interval</item> - <item name="longPressShiftLockTimeout">@integer/config_longpress_shift_lock_timeout</item> - <item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item> - <item name="keyPreviewLayout">@layout/key_preview</item> - <item name="keyPreviewOffset">@dimen/key_preview_offset</item> - <item name="keyPreviewHeight">@dimen/key_preview_height</item> - <item name="keyPreviewLingerTimeout">@integer/config_key_preview_linger_timeout</item> - <item name="moreKeysKeyboardLayout">@layout/more_keys_keyboard</item> - <item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item> - <item name="languageOnSpacebarFinalAlpha">@integer/config_language_on_spacebar_final_alpha</item> - <item name="languageOnSpacebarFadeoutAnimator">@anim/language_on_spacebar_fadeout</item> - <!-- Remove animations for now because it could drain a non-negligible amount of battery while typing. - <item name="altCodeKeyWhileTypingFadeoutAnimator">@anim/alt_code_key_while_typing_fadeout</item> - <item name="altCodeKeyWhileTypingFadeinAnimator">@anim/alt_code_key_while_typing_fadein</item> - --> - <!-- Common attributes of MainKeyboardView for gesture typing detection and recognition --> - <item name="gestureFloatingPreviewTextLingerTimeout">@integer/config_gesture_floating_preview_text_linger_timeout</item> - <item name="gestureStaticTimeThresholdAfterFastTyping">@integer/config_gesture_static_time_threshold_after_fast_typing</item> - <item name="gestureDetectFastMoveSpeedThreshold">@fraction/config_gesture_detect_fast_move_speed_threshold</item> - <item name="gestureDynamicThresholdDecayDuration">@integer/config_gesture_dynamic_threshold_decay_duration</item> - <item name="gestureDynamicTimeThresholdFrom">@integer/config_gesture_dynamic_time_threshold_from</item> - <item name="gestureDynamicTimeThresholdTo">@integer/config_gesture_dynamic_time_threshold_to</item> - <item name="gestureDynamicDistanceThresholdFrom">@fraction/config_gesture_dynamic_distance_threshold_from</item> - <item name="gestureDynamicDistanceThresholdTo">@fraction/config_gesture_dynamic_distance_threshold_to</item> - <item name="gestureSamplingMinimumDistance">@fraction/config_gesture_sampling_minimum_distance</item> - <item name="gestureRecognitionMinimumTime">@integer/config_gesture_recognition_minimum_time</item> - <item name="gestureRecognitionUpdateTime">@integer/config_gesture_recognition_update_time</item> - <item name="gestureRecognitionSpeedThreshold">@fraction/config_gesture_recognition_speed_threshold</item> - <item name="suppressKeyPreviewAfterBatchInputDuration">@integer/config_suppress_key_preview_after_batch_input_duration</item> - </style> - <style - name="MainKeyboardView" - parent="KeyboardView"> - <item name="autoCorrectionSpacebarLedEnabled">true</item> - <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item> - <item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item> - <item name="spacebarTextColor">@color/spacebar_text_color_default</item> - <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_default</item> - </style> - <style - name="MoreKeysKeyboard" - parent="Keyboard" - > - <item name="keyboardTopPadding">0%p</item> - <item name="keyboardBottomPadding">0%p</item> - <item name="horizontalGap">0%p</item> - <item name="touchPositionCorrectionData">@null</item> - </style> - <style - name="MoreKeysKeyboardView" - parent="KeyboardView" - > - <item name="keyBackground">@drawable/btn_keyboard_key_popup</item> - <item name="verticalCorrection">@dimen/more_keys_keyboard_vertical_correction</item> - </style> - <style name="MoreKeysKeyboardPanelStyle"> - <item name="android:background">@drawable/keyboard_popup_panel_background</item> - </style> - <style - name="SuggestionStripViewStyle" - > - <item name="android:background">@drawable/keyboard_suggest_strip</item> - <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> - <item name="colorValidTypedWord">@color/highlight_color_default</item> - <item name="colorTypedWord">@color/typed_word_color_default</item> - <item name="colorAutoCorrect">@color/highlight_color_default</item> - <item name="colorSuggested">@color/highlight_color_default</item> - <item name="alphaObsoleted">50%</item> - <item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item> - <item name="centerSuggestionPercentile">@fraction/center_suggestion_percentile</item> - <item name="maxMoreSuggestionsRow">@integer/max_more_suggestions_row</item> - <item name="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item> - </style> - <style - name="MoreSuggestionsViewStyle" - parent="MoreKeysKeyboardView" - > - </style> - <style name="SuggestionBackgroundStyle"> - <item name="android:background">@drawable/btn_suggestion</item> - </style> - <!-- Theme "Basic high contrast" --> - <style - name="Keyboard.HighContrast" - parent="Keyboard" - > - <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> - <item name="themeId">1</item> - </style> - <style - name="KeyboardView.HighContrast" - parent="KeyboardView" - > - <item name="android:background">@android:color/black</item> - <item name="keyBackground">@drawable/btn_keyboard_key3</item> - </style> - <style - name="MainKeyboardView.HighContrast" - parent="KeyboardView.HighContrast" - > - <item name="autoCorrectionSpacebarLedEnabled">true</item> - <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item> - <item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item> - <item name="spacebarTextColor">@color/spacebar_text_color_default</item> - <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_default</item> - </style> - <!-- Theme "Stone" --> - <style - name="Keyboard.Stone" - parent="Keyboard" - > - <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> - <item name="themeId">6</item> - <item name="keyboardTopPadding">@fraction/keyboard_top_padding_stone</item> - <item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_stone</item> - <item name="horizontalGap">@fraction/key_horizontal_gap_stone</item> - <item name="verticalGap">@fraction/key_bottom_gap_stone</item> - </style> - <style - name="KeyboardView.Stone" - parent="KeyboardView" - > - <item name="keyBackground">@drawable/btn_keyboard_key_stone</item> - <item name="keyTextColor">@color/key_text_color_stone</item> - <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_stone</item> - <item name="keyHintLetterColor">@color/key_hint_letter_color_stone</item> - <item name="keyHintLabelColor">@color/key_hint_label_color_stone</item> - <item name="keyShiftedLetterHintInactivatedColor">@color/key_shifted_letter_hint_inactivated_color_stone</item> - <item name="keyShiftedLetterHintActivatedColor">@color/key_shifted_letter_hint_activated_color_stone</item> - <item name="keyTextShadowColor">@color/key_text_shadow_color_stone</item> - </style> - <style - name="MainKeyboardView.Stone" - parent="KeyboardView.Stone" - > - <item name="autoCorrectionSpacebarLedEnabled">true</item> - <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item> - <item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item> - <item name="spacebarTextColor">@color/spacebar_text_color_stone</item> - <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_stone</item> - </style> - <style - name="MoreKeysKeyboard.Stone" - parent="Keyboard.Stone" - > - <item name="keyboardTopPadding">0%p</item> - <item name="keyboardBottomPadding">0%p</item> - <item name="horizontalGap">0%p</item> - <item name="touchPositionCorrectionData">@null</item> - </style> - <style - name="MoreKeysKeyboardView.Stone" - parent="MoreKeysKeyboardView" - > - <item name="keyBackground">@drawable/btn_keyboard_key_stone</item> - <item name="keyTextColor">@color/key_text_color_stone</item> - <item name="keyTextShadowColor">@color/key_text_shadow_color_stone</item> - </style> - <!-- Theme "Stone bold" --> - <style - name="Keyboard.Stone.Bold" - parent="Keyboard.Stone" - > - <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> - <item name="themeId">7</item> - </style> - <style - name="KeyboardView.Stone.Bold" - parent="KeyboardView.Stone" - > - <item name="keyTypeface">bold</item> - </style> - <style - name="MainKeyboardView.Stone.Bold" - parent="KeyboardView.Stone.Bold" - > - <item name="autoCorrectionSpacebarLedEnabled">true</item> - <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item> - <item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item> - <item name="spacebarTextColor">@color/spacebar_text_color_stone</item> - <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_stone</item> - </style> - <!-- Theme "Gingerbread" --> - <style - name="Keyboard.Gingerbread" - parent="Keyboard" - > - <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> - <item name="themeId">8</item> - <item name="touchPositionCorrectionData">@array/touch_position_correction_data_gingerbread</item> - <item name="horizontalGap">@fraction/key_horizontal_gap_gb</item> - <item name="verticalGap">@fraction/key_bottom_gap_gb</item> - </style> - <style - name="KeyboardView.Gingerbread" - parent="KeyboardView" - > - <item name="android:background">@drawable/keyboard_dark_background</item> - <item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item> - <item name="keyTypeface">bold</item> - </style> - <style - name="MainKeyboardView.Gingerbread" - parent="KeyboardView.Gingerbread" - > - <item name="autoCorrectionSpacebarLedEnabled">true</item> - <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item> - <item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item> - <item name="spacebarTextColor">@color/spacebar_text_color_default</item> - <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_default</item> - </style> - <style - name="MoreKeysKeyboard.Gingerbread" - parent="Keyboard.Gingerbread" - > - <item name="keyboardTopPadding">0%p</item> - <item name="keyboardBottomPadding">0%p</item> - <item name="horizontalGap">0%p</item> - <item name="touchPositionCorrectionData">@null</item> - </style> - <style - name="MoreKeysKeyboardView.Gingerbread" - parent="MoreKeysKeyboardView" - > - <item name="android:background">@null</item> - </style> - <!-- Theme "IceCreamSandwich" --> - <style - name="Keyboard.IceCreamSandwich" - parent="Keyboard" - > - <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> - <item name="themeId">5</item> - <item name="keyboardTopPadding">@fraction/keyboard_top_padding_ics</item> - <item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_ics</item> - <item name="horizontalGap">@fraction/key_horizontal_gap_ics</item> - <item name="verticalGap">@fraction/key_bottom_gap_ics</item> - <item name="touchPositionCorrectionData">@array/touch_position_correction_data_ice_cream_sandwich</item> - </style> - <style - name="KeyboardView.IceCreamSandwich" - parent="KeyboardView" - > - <item name="android:background">@drawable/keyboard_background_holo</item> - <item name="keyBackground">@drawable/btn_keyboard_key_ics</item> - <item name="keyTypeface">bold</item> - <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_ics</item> - <item name="keyHintLetterColor">@color/key_hint_letter_color_ics</item> - <item name="keyHintLabelColor">@color/key_hint_label_color_ics</item> - <item name="keyShiftedLetterHintInactivatedColor">@color/key_shifted_letter_hint_inactivated_color_ics</item> - <item name="keyShiftedLetterHintActivatedColor">@color/key_shifted_letter_hint_activated_color_ics</item> - <item name="keyPreviewLayout">@layout/key_preview_ics</item> - <item name="keyPreviewTextColor">@color/key_text_color_ics</item> - <item name="keyPreviewOffset">@dimen/key_preview_offset_ics</item> - <item name="keyTextShadowColor">@color/key_text_shadow_color_ics</item> - <item name="keyTextShadowRadius">0.0</item> - <item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_ics</item> - <item name="gestureFloatingPreviewTextColor">@color/highlight_color_ics</item> - <item name="gestureTrailColor">@color/highlight_color_ics</item> - </style> - <style - name="MainKeyboardView.IceCreamSandwich" - parent="KeyboardView.IceCreamSandwich" - > - <item name="autoCorrectionSpacebarLedEnabled">false</item> - <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item> - <item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item> - <item name="spacebarTextColor">@color/spacebar_text_color_ics</item> - <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_ics</item> - </style> - <style - name="MoreKeysKeyboard.IceCreamSandwich" - parent="Keyboard.IceCreamSandwich" - > - <item name="keyboardTopPadding">0%p</item> - <item name="keyboardBottomPadding">0%p</item> - <item name="horizontalGap">0%p</item> - <item name="touchPositionCorrectionData">@null</item> - </style> - <style - name="MoreKeysKeyboardView.IceCreamSandwich" - parent="MoreKeysKeyboardView" - > - <item name="android:background">@null</item> - <item name="keyBackground">@drawable/btn_keyboard_key_popup_ics</item> - <item name="verticalCorrection">@dimen/more_keys_keyboard_vertical_correction_ics</item> - </style> - <style name="MoreKeysKeyboardPanelStyle.IceCreamSandwich"> - <item name="android:background">@drawable/keyboard_popup_panel_background_holo</item> - </style> - <style - name="SuggestionStripViewStyle.IceCreamSandwich" - > - <item name="android:background">@drawable/keyboard_suggest_strip_holo</item> - <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> - <item name="colorValidTypedWord">@color/highlight_color_ics</item> - <item name="colorTypedWord">@color/highlight_color_ics</item> - <item name="colorAutoCorrect">@color/highlight_color_ics</item> - <item name="colorSuggested">@color/highlight_color_ics</item> - <item name="alphaValidTypedWord">85%</item> - <item name="alphaTypedWord">85%</item> - <item name="alphaSuggested">70%</item> - <item name="alphaObsoleted">70%</item> - <item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item> - <item name="centerSuggestionPercentile">@fraction/center_suggestion_percentile</item> - <item name="maxMoreSuggestionsRow">@integer/max_more_suggestions_row</item> - <item name="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item> - </style> - <style - name="MoreSuggestionsViewStyle.IceCreamSandwich" - parent="MoreKeysKeyboardView.IceCreamSandwich" - > - </style> - <style name="SuggestionBackgroundStyle.IceCreamSandwich"> - <item name="android:background">@drawable/btn_suggestion_ics</item> - </style> - <style - name="SuggestionPreviewBackgroundStyle.IceCreamSandwich" - parent="MoreKeysKeyboardPanelStyle.IceCreamSandwich" - > - </style> - <style name="MoreKeysKeyboardAnimation"> - <item name="android:windowEnterAnimation">@anim/more_keys_keyboard_fadein</item> - <item name="android:windowExitAnimation">@anim/more_keys_keyboard_fadeout</item> - </style> -</resources> diff --git a/java/res/values/themes-basic-highcontrast.xml b/java/res/values/themes-basic-highcontrast.xml deleted file mode 100644 index e81d47386..000000000 --- a/java/res/values/themes-basic-highcontrast.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardTheme.HighContrast" parent="KeyboardIcons"> - <item name="keyboardStyle">@style/Keyboard.HighContrast</item> - <item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item> - <item name="mainKeyboardViewStyle">@style/MainKeyboardView.HighContrast</item> - <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> - <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> - <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> - <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> - <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> - </style> -</resources> diff --git a/java/res/values/themes-basic.xml b/java/res/values/themes-basic.xml deleted file mode 100644 index c44f0f614..000000000 --- a/java/res/values/themes-basic.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardTheme" parent="KeyboardIcons"> - <item name="keyboardStyle">@style/Keyboard</item> - <item name="keyboardViewStyle">@style/KeyboardView</item> - <item name="mainKeyboardViewStyle">@style/MainKeyboardView</item> - <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> - <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> - <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> - <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> - <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> - </style> -</resources> diff --git a/java/res/values/themes-common.xml b/java/res/values/themes-common.xml new file mode 100644 index 000000000..c9334ce5f --- /dev/null +++ b/java/res/values/themes-common.xml @@ -0,0 +1,114 @@ +<?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 xmlns:android="http://schemas.android.com/apk/res/android"> + <style name="KeyboardIcons" /> + <!-- Default theme values --> + <style name="Keyboard"> + <item name="touchPositionCorrectionData">@array/touch_position_correction_data_default</item> + <item name="rowHeight">25%p</item> + <item name="moreKeysTemplate">@xml/kbd_more_keys_keyboard_template</item> + <item name="keyboardLeftPadding">@fraction/keyboard_left_padding</item> + <item name="keyboardRightPadding">@fraction/keyboard_right_padding</item> + <item name="maxMoreKeysColumn">@integer/config_max_more_keys_column</item> + </style> + <style name="KeyboardView"> + <item name="keyLetterSize">@fraction/key_letter_ratio</item> + <item name="keyLargeLetterRatio">@fraction/key_large_letter_ratio</item> + <item name="keyLabelSize">@fraction/key_label_ratio</item> + <item name="keyLargeLabelRatio">@fraction/key_large_label_ratio</item> + <item name="keyHintLetterRatio">@fraction/key_hint_letter_ratio</item> + <item name="keyHintLabelRatio">@fraction/key_hint_label_ratio</item> + <item name="keyShiftedLetterHintRatio">@fraction/key_uppercase_letter_ratio</item> + <item name="keyTypeface">normal</item> + <item name="keyLabelHorizontalPadding">@dimen/key_label_horizontal_padding</item> + <item name="keyHintLetterPadding">@dimen/key_hint_letter_padding</item> + <item name="keyPopupHintLetterPadding">@dimen/key_popup_hint_letter_padding</item> + <item name="keyShiftedLetterHintPadding">@dimen/key_uppercase_letter_padding</item> + <item name="keyPreviewTextRatio">@fraction/key_preview_text_ratio</item> + <item name="verticalCorrection">@dimen/keyboard_vertical_correction</item> + <item name="backgroundDimAlpha">128</item> + <item name="gestureFloatingPreviewTextSize">@dimen/gesture_floating_preview_text_size</item> + <item name="gestureFloatingPreviewTextOffset">@dimen/gesture_floating_preview_text_offset</item> + <item name="gestureFloatingPreviewHorizontalPadding">@dimen/gesture_floating_preview_horizontal_padding</item> + <item name="gestureFloatingPreviewVerticalPadding">@dimen/gesture_floating_preview_vertical_padding</item> + <item name="gestureFloatingPreviewRoundRadius">@dimen/gesture_floating_preview_round_radius</item> + <item name="gestureTrailMinSamplingDistance">@dimen/gesture_trail_min_sampling_distance</item> + <item name="gestureTrailMaxInterpolationAngularThreshold">@integer/gesture_trail_max_interpolation_angular_threshold</item> + <item name="gestureTrailMaxInterpolationDistanceThreshold">@dimen/gesture_trail_max_interpolation_distance_threshold</item> + <item name="gestureTrailMaxInterpolationSegments">@integer/gesture_trail_max_interpolation_segments</item> + <item name="gestureTrailFadeoutStartDelay">@integer/config_gesture_trail_fadeout_start_delay</item> + <item name="gestureTrailFadeoutDuration">@integer/config_gesture_trail_fadeout_duration</item> + <item name="gestureTrailUpdateInterval">@integer/config_gesture_trail_update_interval</item> + <item name="gestureTrailStartWidth">@dimen/gesture_trail_start_width</item> + <item name="gestureTrailEndWidth">@dimen/gesture_trail_end_width</item> + <item name="gestureTrailBodyRatio">@integer/gesture_trail_body_ratio</item> + <item name="gestureTrailShadowRatio">@integer/gesture_trail_shadow_ratio</item> + <!-- Common attributes of MainKeyboardView --> + <item name="keyHysteresisDistance">@dimen/config_key_hysteresis_distance</item> + <item name="keyHysteresisDistanceForSlidingModifier">@dimen/config_key_hysteresis_distance_for_sliding_modifier</item> + <item name="touchNoiseThresholdTime">@integer/config_touch_noise_threshold_time</item> + <item name="touchNoiseThresholdDistance">@dimen/config_touch_noise_threshold_distance</item> + <item name="slidingKeyInputEnable">@bool/config_sliding_key_input_enabled</item> + <item name="slidingKeyInputPreviewWidth">@dimen/config_sliding_key_input_preview_width</item> + <item name="slidingKeyInputPreviewBodyRatio">@integer/config_sliding_key_input_preview_body_ratio</item> + <item name="slidingKeyInputPreviewShadowRatio">@integer/config_sliding_key_input_preview_shadow_ratio</item> + <item name="keyRepeatStartTimeout">@integer/config_key_repeat_start_timeout</item> + <item name="keyRepeatInterval">@integer/config_key_repeat_interval</item> + <item name="longPressShiftLockTimeout">@integer/config_longpress_shift_lock_timeout</item> + <item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item> + <item name="keyPreviewHeight">@dimen/key_preview_height</item> + <item name="keyPreviewLingerTimeout">@integer/config_key_preview_linger_timeout</item> + <item name="moreKeysKeyboardLayout">@layout/more_keys_keyboard</item> + <item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item> + <item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item> + <item name="languageOnSpacebarFinalAlpha">@integer/config_language_on_spacebar_final_alpha</item> + <item name="languageOnSpacebarFadeoutAnimator">@anim/language_on_spacebar_fadeout</item> + <!-- Remove animations for now because it could drain a non-negligible amount of battery while typing. + <item name="altCodeKeyWhileTypingFadeoutAnimator">@anim/alt_code_key_while_typing_fadeout</item> + <item name="altCodeKeyWhileTypingFadeinAnimator">@anim/alt_code_key_while_typing_fadein</item> + --> + <!-- Common attributes of MainKeyboardView for gesture typing detection and recognition --> + <item name="gestureFloatingPreviewTextLingerTimeout">@integer/config_gesture_floating_preview_text_linger_timeout</item> + <item name="gestureStaticTimeThresholdAfterFastTyping">@integer/config_gesture_static_time_threshold_after_fast_typing</item> + <item name="gestureDetectFastMoveSpeedThreshold">@fraction/config_gesture_detect_fast_move_speed_threshold</item> + <item name="gestureDynamicThresholdDecayDuration">@integer/config_gesture_dynamic_threshold_decay_duration</item> + <item name="gestureDynamicTimeThresholdFrom">@integer/config_gesture_dynamic_time_threshold_from</item> + <item name="gestureDynamicTimeThresholdTo">@integer/config_gesture_dynamic_time_threshold_to</item> + <item name="gestureDynamicDistanceThresholdFrom">@fraction/config_gesture_dynamic_distance_threshold_from</item> + <item name="gestureDynamicDistanceThresholdTo">@fraction/config_gesture_dynamic_distance_threshold_to</item> + <item name="gestureSamplingMinimumDistance">@fraction/config_gesture_sampling_minimum_distance</item> + <item name="gestureRecognitionMinimumTime">@integer/config_gesture_recognition_minimum_time</item> + <item name="gestureRecognitionUpdateTime">@integer/config_gesture_recognition_update_time</item> + <item name="gestureRecognitionSpeedThreshold">@fraction/config_gesture_recognition_speed_threshold</item> + <item name="suppressKeyPreviewAfterBatchInputDuration">@integer/config_suppress_key_preview_after_batch_input_duration</item> + </style> + <style name="MainKeyboardView" /> + <style name="MoreKeysKeyboard" /> + <style name="MoreKeysKeyboardView" /> + <style + name="SuggestionStripView" + > + <item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item> + <item name="centerSuggestionPercentile">@fraction/center_suggestion_percentile</item> + <item name="maxMoreSuggestionsRow">@integer/max_more_suggestions_row</item> + <item name="minMoreSuggestionsWidth">@fraction/min_more_suggestions_width</item> + </style> +</resources> diff --git a/java/res/values/themes-gb.xml b/java/res/values/themes-gb.xml new file mode 100644 index 000000000..b430eeafd --- /dev/null +++ b/java/res/values/themes-gb.xml @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2011, 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> + <style name="KeyboardTheme.GB" parent="KeyboardIcons.GB"> + <item name="keyboardStyle">@style/Keyboard.GB</item> + <item name="keyboardViewStyle">@style/KeyboardView.GB</item> + <item name="mainKeyboardViewStyle">@style/MainKeyboardView.GB</item> + <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.GB</item> + <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.GB</item> + <item name="suggestionStripViewStyle">@style/SuggestionStripView.GB</item> + <item name="moreKeysKeyboardBackground">@drawable/keyboard_popup_panel_background_gb</item> + <item name="suggestionStripBackground">@drawable/keyboard_suggest_strip_gb</item> + <item name="suggestionBackground">@drawable/btn_suggestion_gb</item> + </style> + <style name="KeyboardIcons.GB"> + <!-- Keyboard icons --> + <item name="iconShiftKey">@drawable/sym_keyboard_shift</item> + <item name="iconDeleteKey">@drawable/sym_keyboard_delete</item> + <item name="iconSettingsKey">@drawable/sym_keyboard_settings</item> + <item name="iconSpaceKey">@drawable/sym_keyboard_space</item> + <item name="iconEnterKey">@drawable/sym_keyboard_return</item> + <item name="iconSearchKey">@drawable/sym_keyboard_search</item> + <item name="iconTabKey">@drawable/sym_keyboard_tab</item> + <item name="iconShortcutKey">@drawable/sym_keyboard_mic</item> + <item name="iconShortcutForLabel">@drawable/sym_keyboard_label_mic</item> + <item name="iconSpaceKeyForNumberLayout">@drawable/sym_keyboard_space</item> + <item name="iconShiftKeyShifted">@drawable/sym_keyboard_shift_locked</item> + <!-- TODO: Needs non-holo disabled shortcut icon drawable --> + <item name="iconShortcutKeyDisabled">@drawable/sym_keyboard_voice_off_holo</item> + <item name="iconTabKeyPreview">@drawable/sym_keyboard_feedback_tab</item> + <item name="iconLanguageSwitchKey">@drawable/sym_keyboard_language_switch</item> + <!-- TODO: Needs dedicated black theme ZWNJ and ZWJ icons --> + <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> + <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> + <item name="iconEmojiKey">@drawable/ic_emoji_dark</item> + </style> + <style + name="Keyboard.GB" + parent="Keyboard" + > + <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> + <item name="themeId">1</item> + <item name="touchPositionCorrectionData">@array/touch_position_correction_data_gb</item> + <item name="keyboardTopPadding">@fraction/keyboard_top_padding_gb</item> + <item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_gb</item> + <item name="horizontalGap">@fraction/key_horizontal_gap_gb</item> + <item name="verticalGap">@fraction/key_bottom_gap_gb</item> + </style> + <style + name="KeyboardView.GB" + parent="KeyboardView" + > + <item name="android:background">@drawable/keyboard_background_gb</item> + <item name="keyBackground">@drawable/btn_keyboard_key_gb</item> + <item name="keyTypeface">bold</item> + <item name="keyTextColor">@color/key_text_color_gb</item> + <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_gb</item> + <item name="keyHintLetterColor">@color/key_hint_letter_color_gb</item> + <item name="keyHintLabelColor">@color/key_hint_label_color_gb</item> + <item name="keyShiftedLetterHintInactivatedColor">@color/key_shifted_letter_hint_inactivated_color_gb</item> + <item name="keyShiftedLetterHintActivatedColor">@color/key_shifted_letter_hint_activated_color_gb</item> + <item name="keyPreviewTextColor">@color/key_text_color_gb</item> + <item name="keyTextShadowColor">@color/key_text_shadow_color_gb</item> + <item name="keyTextShadowRadius">2.75</item> + </style> + <style + name="MainKeyboardView.GB" + parent="KeyboardView.GB" + > + <item name="keyPreviewLayout">@layout/key_preview_gb</item> + <item name="keyPreviewOffset">@dimen/key_preview_offset_gb</item> + <item name="gestureFloatingPreviewTextColor">@color/highlight_color_gb</item> + <item name="gestureFloatingPreviewColor">@color/gesture_floating_preview_color_gb</item> + <item name="gestureTrailColor">@color/highlight_color_gb</item> + <item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_gb</item> + <item name="autoCorrectionSpacebarLedEnabled">true</item> + <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_gb</item> + <item name="spacebarTextColor">@color/spacebar_text_color_gb</item> + <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_gb</item> + </style> + <style + name="MoreKeysKeyboard.GB" + parent="Keyboard.GB" + > + <item name="keyboardTopPadding">0%p</item> + <item name="keyboardBottomPadding">0%p</item> + <item name="horizontalGap">0%p</item> + <item name="touchPositionCorrectionData">@null</item> + </style> + <style + name="MoreKeysKeyboardView.GB" + parent="KeyboardView.GB" + > + <item name="android:background">@null</item> + <item name="keyBackground">@drawable/btn_keyboard_key_popup_gb</item> + <item name="keyTypeface">normal</item> + <item name="verticalCorrection">@dimen/more_keys_keyboard_vertical_correction_gb</item> + </style> + <style + name="SuggestionStripView.GB" + parent="SuggestionStripView" + > + <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> + <item name="colorValidTypedWord">@color/highlight_color_gb</item> + <item name="colorTypedWord">@color/typed_word_color_gb</item> + <item name="colorAutoCorrect">@color/highlight_color_gb</item> + <item name="colorSuggested">@color/highlight_color_gb</item> + <item name="alphaObsoleted">50%</item> + </style> +</resources> diff --git a/java/res/values/themes-gingerbread.xml b/java/res/values/themes-gingerbread.xml deleted file mode 100644 index 129afdf5b..000000000 --- a/java/res/values/themes-gingerbread.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardTheme.Gingerbread" parent="KeyboardIcons"> - <item name="keyboardStyle">@style/Keyboard.Gingerbread</item> - <item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item> - <item name="mainKeyboardViewStyle">@style/MainKeyboardView.Gingerbread</item> - <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Gingerbread</item> - <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Gingerbread</item> - <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> - <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> - <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> - </style> -</resources> diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml index 1264831f3..5ca0665ad 100644 --- a/java/res/values/themes-ics.xml +++ b/java/res/values/themes-ics.xml @@ -1,29 +1,133 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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. +<!-- +/* +** +** Copyright 2011, 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> - <style name="KeyboardTheme.IceCreamSandwich" parent="KeyboardIcons.IceCreamSandwich"> - <item name="keyboardStyle">@style/Keyboard.IceCreamSandwich</item> - <item name="keyboardViewStyle">@style/KeyboardView.IceCreamSandwich</item> - <item name="mainKeyboardViewStyle">@style/MainKeyboardView.IceCreamSandwich</item> - <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.IceCreamSandwich</item> - <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.IceCreamSandwich</item> - <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle.IceCreamSandwich</item> - <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle.IceCreamSandwich</item> - <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle.IceCreamSandwich</item> - <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item> + <style name="KeyboardTheme.ICS" parent="KeyboardIcons.ICS"> + <item name="keyboardStyle">@style/Keyboard.ICS</item> + <item name="keyboardViewStyle">@style/KeyboardView.ICS</item> + <item name="mainKeyboardViewStyle">@style/MainKeyboardView.ICS</item> + <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.ICS</item> + <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.ICS</item> + <item name="suggestionStripViewStyle">@style/SuggestionStripView.ICS</item> + <item name="moreKeysKeyboardBackground">@drawable/keyboard_popup_panel_background_holo</item> + <item name="suggestionStripBackground">@drawable/keyboard_suggest_strip_holo</item> + <item name="suggestionBackground">@drawable/btn_suggestion_ics</item> + </style> + <style name="KeyboardIcons.ICS"> + <!-- Keyboard icons --> + <!-- TODO: The following holo icon for phone (drawable-hdpi and drawable-xhdpi) are missing. + sym_keyboard_123_mic_holo + --> + <item name="iconShiftKey">@drawable/sym_keyboard_shift_holo</item> + <item name="iconDeleteKey">@drawable/sym_keyboard_delete_holo</item> + <item name="iconSettingsKey">@drawable/sym_keyboard_settings_holo</item> + <item name="iconSpaceKey">@null</item> + <item name="iconEnterKey">@drawable/sym_keyboard_return_holo</item> + <item name="iconSearchKey">@drawable/sym_keyboard_search_holo</item> + <item name="iconTabKey">@drawable/sym_keyboard_tab_holo</item> + <item name="iconShortcutKey">@drawable/sym_keyboard_voice_holo</item> + <item name="iconShortcutForLabel">@drawable/sym_keyboard_label_mic_holo</item> + <item name="iconSpaceKeyForNumberLayout">@drawable/sym_keyboard_space_holo</item> + <item name="iconShiftKeyShifted">@drawable/sym_keyboard_shift_locked_holo</item> + <item name="iconShortcutKeyDisabled">@drawable/sym_keyboard_voice_off_holo</item> + <item name="iconTabKeyPreview">@drawable/sym_keyboard_feedback_tab</item> + <item name="iconLanguageSwitchKey">@drawable/sym_keyboard_language_switch</item> + <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> + <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> + <item name="iconEmojiKey">@drawable/ic_emoji_light</item> + </style> + <style + name="Keyboard.ICS" + parent="Keyboard" + > + <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> + <item name="themeId">0</item> + <item name="keyboardTopPadding">@fraction/keyboard_top_padding_ics</item> + <item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_ics</item> + <item name="horizontalGap">@fraction/key_horizontal_gap_ics</item> + <item name="verticalGap">@fraction/key_bottom_gap_ics</item> + <item name="touchPositionCorrectionData">@array/touch_position_correction_data_ics</item> + </style> + <style + name="KeyboardView.ICS" + parent="KeyboardView" + > + <item name="android:background">@drawable/keyboard_background_ics</item> + <item name="keyBackground">@drawable/btn_keyboard_key_ics</item> + <item name="keyTypeface">bold</item> + <item name="keyTextColor">@color/key_text_color_ics</item> + <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_ics</item> + <item name="keyHintLetterColor">@color/key_hint_letter_color_ics</item> + <item name="keyHintLabelColor">@color/key_hint_label_color_ics</item> + <item name="keyShiftedLetterHintInactivatedColor">@color/key_shifted_letter_hint_inactivated_color_ics</item> + <item name="keyShiftedLetterHintActivatedColor">@color/key_shifted_letter_hint_activated_color_ics</item> + <item name="keyPreviewTextColor">@color/key_text_color_ics</item> + <item name="keyTextShadowColor">@color/key_text_shadow_color_ics</item> + <item name="keyTextShadowRadius">0.0</item> + </style> + <style + name="MainKeyboardView.ICS" + parent="KeyboardView.ICS" + > + <item name="keyPreviewLayout">@layout/key_preview_ics</item> + <item name="keyPreviewOffset">@dimen/key_preview_offset_ics</item> + <item name="gestureFloatingPreviewTextColor">@color/highlight_color_ics</item> + <item name="gestureFloatingPreviewColor">@color/gesture_floating_preview_color_ics</item> + <item name="gestureTrailColor">@color/highlight_color_ics</item> + <item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_ics</item> + <item name="autoCorrectionSpacebarLedEnabled">false</item> + <item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item> + <item name="spacebarTextColor">@color/spacebar_text_color_ics</item> + <item name="spacebarTextShadowColor">@color/spacebar_text_shadow_color_ics</item> + </style> + <style + name="MoreKeysKeyboard.ICS" + parent="Keyboard.ICS" + > + <item name="keyboardTopPadding">0%p</item> + <item name="keyboardBottomPadding">0%p</item> + <item name="horizontalGap">0%p</item> + <item name="touchPositionCorrectionData">@null</item> + </style> + <style + name="MoreKeysKeyboardView.ICS" + parent="KeyboardView.ICS" + > + <item name="android:background">@null</item> + <item name="keyBackground">@drawable/btn_keyboard_key_popup_ics</item> + <item name="keyTypeface">normal</item> + <item name="verticalCorrection">@dimen/more_keys_keyboard_vertical_correction_ics</item> + </style> + <style + name="SuggestionStripView.ICS" + parent="SuggestionStripView" + > + <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> + <item name="colorValidTypedWord">@color/typed_word_color_ics</item> + <item name="colorTypedWord">@color/typed_word_color_ics</item> + <item name="colorAutoCorrect">@color/highlight_color_ics</item> + <item name="colorSuggested">@color/suggested_word_color_ics</item> + <item name="alphaObsoleted">70%</item> + </style> + <style name="MoreKeysKeyboardAnimation"> + <item name="android:windowEnterAnimation">@anim/more_keys_keyboard_fadein</item> + <item name="android:windowExitAnimation">@anim/more_keys_keyboard_fadeout</item> </style> </resources> diff --git a/java/res/values/themes-stone-bold.xml b/java/res/values/themes-stone-bold.xml deleted file mode 100644 index 196f3ef9f..000000000 --- a/java/res/values/themes-stone-bold.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardTheme.Stone.Bold" parent="KeyboardIcons.Black"> - <item name="keyboardStyle">@style/Keyboard.Stone.Bold</item> - <item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item> - <item name="mainKeyboardViewStyle">@style/MainKeyboardView.Stone.Bold</item> - <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> - <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> - <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> - <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> - <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> - </style> -</resources> diff --git a/java/res/values/themes-stone.xml b/java/res/values/themes-stone.xml deleted file mode 100644 index d0d35c28d..000000000 --- a/java/res/values/themes-stone.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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> - <style name="KeyboardTheme.Stone" parent="KeyboardIcons.Black"> - <item name="keyboardStyle">@style/Keyboard.Stone</item> - <item name="keyboardViewStyle">@style/KeyboardView.Stone</item> - <item name="mainKeyboardViewStyle">@style/MainKeyboardView.Stone</item> - <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> - <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> - <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> - <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> - <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> - </style> -</resources> diff --git a/java/res/values/touch-position-correction.xml b/java/res/values/touch-position-correction.xml index 7df86f467..9df517b32 100644 --- a/java/res/values/touch-position-correction.xml +++ b/java/res/values/touch-position-correction.xml @@ -37,7 +37,7 @@ </string-array> <string-array - name="touch_position_correction_data_gingerbread" + name="touch_position_correction_data_gb" translatable="false" > <!-- First row --> @@ -57,7 +57,7 @@ </string-array> <string-array - name="touch_position_correction_data_ice_cream_sandwich" + name="touch_position_correction_data_ics" translatable="false" > <!-- First row --> diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml index f407ba346..fc9342b91 100644 --- a/java/res/xml-sw600dp/key_styles_common.xml +++ b/java/res/xml-sw600dp/key_styles_common.xml @@ -178,16 +178,6 @@ latin:keyLabel="!text/label_to_alpha_key" latin:parentStyle="baseForLayoutSwitchKeyStyle" /> <key-style - latin:styleName="toMoreSymbolKeyStyle" - latin:code="!code/key_shift" - latin:keyLabel="!text/label_to_more_symbol_for_tablet_key" - latin:parentStyle="baseForLayoutSwitchKeyStyle" /> - <key-style - latin:styleName="backFromMoreSymbolKeyStyle" - latin:code="!code/key_shift" - latin:keyLabel="!text/label_to_symbol_key" - latin:parentStyle="baseForLayoutSwitchKeyStyle" /> - <key-style latin:styleName="comKeyStyle" latin:keyLabel="!text/keylabel_for_popular_domain" latin:keyLabelFlags="autoXScale|fontNormal|hasPopupHint|preserveCase" diff --git a/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml b/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml index 0a27ca70c..324e025ed 100644 --- a/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml +++ b/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml @@ -23,36 +23,32 @@ > <switch> <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" > <Key latin:keyLabel="[" - latin:moreKeys="{" /> - <Key - latin:keyLabel="]" - latin:moreKeys="}" /> - <!-- U+00A6: "¦" BROKEN BAR --> - <Key - latin:keyLabel="\\" - latin:moreKeys="\\|,¦" /> - </case> - <default> - <Key - latin:keyLabel="[" latin:keyHintLabel="{" - latin:moreKeys="{" + latin:additionalMoreKeys="{" latin:keyStyle="hasShiftedLetterHintStyle" /> <Key latin:keyLabel="]" latin:keyHintLabel="}" - latin:moreKeys="}" + latin:additionalMoreKeys="}" latin:keyStyle="hasShiftedLetterHintStyle" /> - <!-- U+00A6: "¦" BROKEN BAR --> <Key latin:keyLabel="\\" latin:keyHintLabel="|" - latin:moreKeys="\\|,¦" + latin:additionalMoreKeys="\\|" latin:keyStyle="hasShiftedLetterHintStyle" /> + </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> + <default> + <Key + latin:keyLabel="{" /> + <Key + latin:keyLabel="}" /> + <Key + latin:keyLabel="|" /> </default> </switch> -</merge> +</merge>
\ No newline at end of file diff --git a/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml b/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml index 0e3013afe..254b5e571 100644 --- a/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml +++ b/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml @@ -23,26 +23,27 @@ > <switch> <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" > <Key latin:keyLabel=";" - latin:moreKeys=":" /> + latin:keyHintLabel=":" + latin:additionalMoreKeys=":" + latin:keyStyle="hasShiftedLetterHintStyle" /> <Key latin:keyLabel="\'" - latin:moreKeys="!fixedColumnOrder!3,!text/double_quotes,!text/single_quotes" /> + latin:keyHintLabel=""" + latin:additionalMoreKeys=""" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,%,!text/single_quotes" /> </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> <default> <Key - latin:keyLabel=";" - latin:keyHintLabel=":" - latin:moreKeys=":" - latin:keyStyle="hasShiftedLetterHintStyle" /> + latin:keyLabel=":" /> <Key - latin:keyLabel="\'" - latin:keyHintLabel=""" - latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,",!text/single_quotes" - latin:keyStyle="hasShiftedLetterHintStyle" /> + latin:keyLabel=""" + latin:moreKeys="!fixedColumnOrder!3,!text/double_quotes,!text/single_quotes" /> </default> </switch> </merge> diff --git a/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml b/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml index ee5271abe..774ff8d05 100644 --- a/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml +++ b/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml @@ -23,28 +23,26 @@ > <switch> <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" > - <!-- U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK - U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - U+2264: "≤" LESS-THAN OR EQUAL TO - U+2265: "≥" GREATER-THAN EQUAL TO - U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK --> - <Key + <Key latin:keyLabel="," + latin:keyHintLabel="<" latin:additionalMoreKeys="<" - latin:moreKeys="!fixedColumnOrder!4,‹,⁤,«" /> + latin:keyStyle="hasShiftedLetterHintStyle" /> <Key latin:keyLabel="." + latin:keyHintLabel=">" latin:additionalMoreKeys=">" - latin:moreKeys="!fixedColumnOrder!4,›,⁥,»" /> - <!-- U+00BF: "¿" INVERTED QUESTION MARK --> + latin:keyStyle="hasShiftedLetterHintStyle" /> <Key latin:keyLabel="/" + latin:keyHintLabel="\?" latin:additionalMoreKeys="\?" - latin:moreKeys="¿" /> + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_question" /> </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> <default> <!-- U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK @@ -53,24 +51,14 @@ U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK --> <Key - latin:keyLabel="," - latin:keyHintLabel="<" - latin:additionalMoreKeys="<" - latin:moreKeys="!fixedColumnOrder!4,‹,≤,«" - latin:keyStyle="hasShiftedLetterHintStyle" /> + latin:keyLabel="<" + latin:moreKeys="!fixedColumnOrder!3,‹,≤,«" /> <Key - latin:keyLabel="." - latin:keyHintLabel=">" - latin:additionalMoreKeys=">" - latin:moreKeys="!fixedColumnOrder!4,›,≥,»" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <!-- U+00BF: "¿" INVERTED QUESTION MARK --> + latin:keyLabel=">" + latin:moreKeys="!fixedColumnOrder!3,›,≥,»" /> <Key - latin:keyLabel="/" - latin:keyHintLabel="\?" - latin:additionalMoreKeys="\?" - latin:moreKeys="¿" - latin:keyStyle="hasShiftedLetterHintStyle" /> + latin:keyLabel="\?" + latin:moreKeys="!text/more_keys_for_symbols_question" /> </default> </switch> </merge> diff --git a/java/res/xml-sw600dp/row_pcqwerty5.xml b/java/res/xml-sw600dp/row_pcqwerty5.xml index 3c4a46660..a79d2a87f 100644 --- a/java/res/xml-sw600dp/row_pcqwerty5.xml +++ b/java/res/xml-sw600dp/row_pcqwerty5.xml @@ -38,9 +38,23 @@ latin:keyStyle="spaceKeyStyle" latin:keyXPos="25.5%p" latin:keyWidth="49.0%p" /> - <include - latin:keyXPos="-9.0%p" - latin:keyWidth="fillRight" - latin:keyboardLayout="@xml/key_shortcut" /> + <switch> + <case + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" + > + <include + latin:keyXPos="-9.0%p" + latin:keyWidth="9.0%p" + latin:keyboardLayout="@xml/key_shortcut" /> + </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> + <default> + <include + latin:keyXPos="-9.0%p" + latin:keyWidth="9.0%p" + latin:backgroundType="functional" + latin:keyboardLayout="@xml/key_symbols_period" /> + </default> + </switch> </Row> </merge> diff --git a/java/res/xml-sw600dp/row_symbols4.xml b/java/res/xml-sw600dp/row_symbols4.xml index f138d8ef4..26ce1ebf4 100644 --- a/java/res/xml-sw600dp/row_symbols4.xml +++ b/java/res/xml-sw600dp/row_symbols4.xml @@ -28,21 +28,13 @@ <Key latin:keyStyle="toAlphaKeyStyle" latin:keyWidth="10.0%p" /> - <Key - latin:keyLabel="/" /> - <include - latin:keyboardLayout="@xml/key_f1" /> <include latin:keyXPos="28.0%p" latin:keyboardLayout="@xml/key_space" latin:backgroundType="normal" /> - <Key - latin:keyLabel=""" - latin:moreKeys="!text/more_keys_for_tablet_double_quote" /> - <Key - latin:keyLabel="_" /> - <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> - <Spacer - latin:keyWidth="fillRight" /> + <Spacer /> + <Spacer /> + <include + latin:keyboardLayout="@xml/key_f2" /> </Row> </merge> diff --git a/java/res/xml-sw600dp/row_symbols_shift4.xml b/java/res/xml-sw600dp/row_symbols_shift4.xml deleted file mode 100644 index 29befa92a..000000000 --- a/java/res/xml-sw600dp/row_symbols_shift4.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Row - latin:keyWidth="9.0%p" - latin:backgroundType="functional" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyWidth="10.0%p" /> - <!-- Here is empty space. --> - <include - latin:keyXPos="28.0%p" - latin:keyboardLayout="@xml/key_space" - latin:backgroundType="normal" /> - <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> - <Spacer - latin:keyWidth="fillRight" /> - </Row> -</merge> diff --git a/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml b/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml index b11bbba1b..254d3fdba 100644 --- a/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml +++ b/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml @@ -21,93 +21,87 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <switch> - <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" - > - <include - latin:keyboardLayout="@xml/keys_pcqwerty_symbols1" /> - </case> - <!-- keyboardLayoutSetElement="alphabet*" --> - <default> - <!-- U+00AC: "¬" NOT SIGN --> - <Key - latin:keyLabel="`" - latin:keyHintLabel="~" - latin:additionalMoreKeys="~" - latin:moreKeys="¬" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <!-- U+00A1: "¡" NVERTED EXCLAMATION MARK --> - <Key - latin:keyLabel="1" - latin:keyHintLabel="!" - latin:additionalMoreKeys="!" - latin:moreKeys="¡,!text/more_keys_for_symbols_1" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="2" - latin:keyHintLabel="\@" - latin:additionalMoreKeys="\@" - latin:moreKeys="!text/more_keys_for_symbols_2" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="3" - latin:keyHintLabel="\#" - latin:additionalMoreKeys="\#" - latin:moreKeys="!text/more_keys_for_symbols_3" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="4" - latin:keyHintLabel="$" - latin:additionalMoreKeys="$" - latin:moreKeys="!text/more_keys_for_symbols_4" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="5" - latin:keyHintLabel="%" - latin:additionalMoreKeys="\\%" - latin:moreKeys="!text/more_keys_for_symbols_5" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="6" - latin:keyHintLabel="^" - latin:additionalMoreKeys="^" - latin:moreKeys="!text/more_keys_for_symbols_6" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="7" - latin:keyHintLabel="&" - latin:additionalMoreKeys="&" - latin:moreKeys="!text/more_keys_for_symbols_7" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="8" - latin:keyHintLabel="*" - latin:additionalMoreKeys="*" - latin:moreKeys="!text/more_keys_for_symbols_8" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="9" - latin:keyHintLabel="(" - latin:additionalMoreKeys="(" - latin:moreKeys="!text/more_keys_for_symbols_9" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="0" - latin:keyHintLabel=")" - latin:additionalMoreKeys=")" - latin:moreKeys="!text/more_keys_for_symbols_0" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="-" - latin:keyHintLabel="_" - latin:moreKeys="_" - latin:keyStyle="hasShiftedLetterHintStyle" /> - <Key - latin:keyLabel="=" - latin:keyHintLabel="+" - latin:moreKeys="+" - latin:keyStyle="hasShiftedLetterHintStyle" /> - </default> - </switch> + <Key + latin:keyLabel="`" + latin:keyHintLabel="~" + latin:additionalMoreKeys="~" + latin:keyStyle="hasShiftedLetterHintStyle" /> + <Key + latin:keyLabel="1" + latin:keyHintLabel="!" + latin:additionalMoreKeys="!" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_exclamation,!text/more_keys_for_symbols_1" /> + <Key + latin:keyLabel="2" + latin:keyHintLabel="\@" + latin:additionalMoreKeys="\@" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_2" /> + <Key + latin:keyLabel="3" + latin:keyHintLabel="\#" + latin:additionalMoreKeys="\#" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_3" /> + <Key + latin:keyLabel="4" + latin:keyHintLabel="$" + latin:additionalMoreKeys="$" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_4" /> + <Key + latin:keyLabel="5" + latin:keyHintLabel="%" + latin:additionalMoreKeys="\\%" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_5" /> + <Key + latin:keyLabel="6" + latin:keyHintLabel="^" + latin:additionalMoreKeys="^" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_6" /> + <Key + latin:keyLabel="7" + latin:keyHintLabel="&" + latin:additionalMoreKeys="&" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_7" /> + <Key + latin:keyLabel="8" + latin:keyHintLabel="*" + latin:additionalMoreKeys="*" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_8" /> + <Key + latin:keyLabel="9" + latin:keyHintLabel="(" + latin:additionalMoreKeys="(" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_9" /> + <Key + latin:keyLabel="0" + latin:keyHintLabel=")" + latin:additionalMoreKeys=")" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="!text/more_keys_for_symbols_0" /> + <!-- U+2013: "–" EN DASH + U+2014: "—" EM DASH + U+00B7: "·" MIDDLE DOT --> + <Key + latin:keyLabel="-" + latin:keyHintLabel="_" + latin:additionalMoreKeys="_" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="–,—,·" /> + <!-- U+221E: "∞" INFINITY + U+2260: "≠" NOT EQUAL TO + U+2248: "≈" ALMOST EQUAL TO --> + <Key + latin:keyLabel="=" + latin:keyHintLabel="+" + latin:additionalMoreKeys="+" + latin:keyStyle="hasShiftedLetterHintStyle" + latin:moreKeys="∞,≠,≈" /> </merge> diff --git a/java/res/xml-sw600dp/rowkeys_symbols2.xml b/java/res/xml-sw600dp/rowkeys_symbols2.xml deleted file mode 100644 index 14abb42f9..000000000 --- a/java/res/xml-sw600dp/rowkeys_symbols2.xml +++ /dev/null @@ -1,75 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <switch> - <case - latin:languageCode="fa" - > - <!-- U+066C: "٬" ARABIC THOUSANDS SEPARATOR --> - <Key - latin:keyLabel="٬" - latin:keyHintLabel="&" - latin:keyLabelFlags="hasPopupHint|hasShiftedLetterHint" - latin:moreKeys="&" /> - </case> - <default> - <Key - latin:keyLabel="\#" /> - </default> - </switch> - <Key - latin:keyStyle="currencyKeyStyle" /> - <Key - latin:keyLabel="!text/keylabel_for_symbols_percent" - latin:moreKeys="!text/more_keys_for_symbols_percent" /> - <switch> - <case - latin:languageCode="fa" - > - <!-- U+066B: "٫" ARABIC DECIMAL SEPARATOR --> - <Key - latin:keyLabel="٫" - latin:keyHintLabel="\#" - latin:keyLabelFlags="hasPopupHint|hasShiftedLetterHint" - latin:moreKeys="\#" /> - </case> - <default> - <Key - latin:keyLabel="&" /> - </default> - </switch> - <Key - latin:keyLabel="*" - latin:moreKeys="!text/more_keys_for_star" /> - <!-- U+2013: "–" EN DASH - U+2014: "—" EM DASH - U+00B7: "·" MIDDLE DOT --> - <Key - latin:keyLabel="-" - latin:moreKeys="_,–,—,·" /> - <Key - latin:keyLabel="+" - latin:moreKeys="!text/more_keys_for_plus" /> - <include - latin:keyboardLayout="@xml/keys_parentheses" /> -</merge> diff --git a/java/res/xml-sw600dp/rowkeys_symbols3.xml b/java/res/xml-sw600dp/rowkeys_symbols3.xml deleted file mode 100644 index 30fba3812..000000000 --- a/java/res/xml-sw600dp/rowkeys_symbols3.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <include - latin:keyboardLayout="@xml/keys_less_greater" /> - <!-- U+2260: "≠" NOT EQUAL TO - U+2248: "≈" ALMOST EQUAL TO --> - <Key - latin:keyLabel="=" - latin:moreKeys="≠,≈" /> - <switch> - <case - latin:mode="url" - > - <Key - latin:keyLabel="\'" /> - </case> - <default> - <Key - latin:keyLabel=":" /> - </default> - </switch> - <Key - latin:keyLabel="!text/keylabel_for_symbols_semicolon" - latin:moreKeys="!text/more_keys_for_symbols_semicolon" /> - <Key - latin:keyLabel="!text/keylabel_for_comma" - latin:moreKeys="!text/more_keys_for_comma" /> - <Key - latin:keyLabel="." /> - <Key - latin:keyLabel="!" - latin:moreKeys="!text/more_keys_for_symbols_exclamation" /> - <Key - latin:keyLabel="!text/keylabel_for_symbols_question" - latin:moreKeys="!text/more_keys_for_symbols_question" /> -</merge> diff --git a/java/res/xml-sw600dp/rowkeys_symbols_shift1.xml b/java/res/xml-sw600dp/rowkeys_symbols_shift1.xml deleted file mode 100644 index 3549fdda4..000000000 --- a/java/res/xml-sw600dp/rowkeys_symbols_shift1.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Key - latin:keyLabel="~" /> - <Key - latin:keyLabel="`" /> - <Key - latin:keyLabel="|" /> - <!-- U+2022: "•" BULLET --> - <Key - latin:keyLabel="•" - latin:moreKeys="!text/more_keys_for_bullet" /> - <!-- U+221A: "√" SQUARE ROOT --> - <Key - latin:keyLabel="√" /> - <!-- U+03C0: "π" GREEK SMALL LETTER PI - U+03A0: "Π" GREEK CAPITAL LETTER PI --> - <Key - latin:keyLabel="π" - latin:moreKeys="Π" /> - <!-- U+00F7: "÷" DIVISION SIGN --> - <Key - latin:keyLabel="÷" /> - <!-- U+00D7: "×" MULTIPLICATION SIGN --> - <Key - latin:keyLabel="×" /> - <!-- U+00A7: "§" SECTION SIGN - U+00B6: "¶" PILCROW SIGN --> - <Key - latin:keyLabel="§" - latin:moreKeys="¶" /> - <!-- U+0394: "Δ" GREEK CAPITAL LETTER DELTA --> - <Key - latin:keyLabel="Δ" /> -</merge> diff --git a/java/res/xml-sw600dp/rowkeys_symbols_shift2.xml b/java/res/xml-sw600dp/rowkeys_symbols_shift2.xml deleted file mode 100644 index 2048b7335..000000000 --- a/java/res/xml-sw600dp/rowkeys_symbols_shift2.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Key - latin:keyStyle="moreCurrency1KeyStyle" /> - <Key - latin:keyStyle="moreCurrency2KeyStyle" /> - <Key - latin:keyStyle="moreCurrency3KeyStyle" /> - <Key - latin:keyStyle="moreCurrency4KeyStyle" /> - <!-- U+2191: "↑" UPWARDS ARROW - U+2193: "↓" DOWNWARDS ARROW - U+2190: "←" LEFTWARDS ARROW - U+2192: "→" RIGHTWARDS ARROW --> - <Key - latin:keyLabel="^" - latin:moreKeys="↑,↓,←,→" /> - <!-- U+00B0: "°" DEGREE SIGN - U+2032: "′" PRIME - U+2033: "″" DOUBLE PRIME --> - <Key - latin:keyLabel="°" - latin:moreKeys="′,″" /> - <!-- U+00B1: "±" PLUS-MINUS SIGN - U+221E: "∞" INFINITY --> - <Key - latin:keyLabel="±" - latin:moreKeys="∞" /> - <include - latin:keyboardLayout="@xml/keys_curly_brackets" /> -</merge> diff --git a/java/res/xml-sw600dp/rowkeys_symbols_shift3.xml b/java/res/xml-sw600dp/rowkeys_symbols_shift3.xml deleted file mode 100644 index 8bd865639..000000000 --- a/java/res/xml-sw600dp/rowkeys_symbols_shift3.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Key - latin:keyLabel="\\" /> - <!-- U+00A9: "©" COPYRIGHT SIGN --> - <Key - latin:keyLabel="©" /> - <!-- U+00AE: "®" REGISTERED SIGN --> - <Key - latin:keyLabel="®" /> - <!-- U+2122: "™" TRADE MARK SIGN --> - <Key - latin:keyLabel="™" /> - <!-- U+2105: "℅" CARE OF --> - <Key - latin:keyLabel="℅" /> - <include - latin:keyboardLayout="@xml/keys_square_brackets" /> - <!-- U+00A1: "¡" INVERTED EXCLAMATION MARK --> - <Key - latin:keyLabel="¡" /> - <!-- U+00BF: "¿" INVERTED QUESTION MARK --> - <Key - latin:keyLabel="¿" /> -</merge> diff --git a/java/res/xml-sw600dp/rows_10_10_7_symbols.xml b/java/res/xml-sw600dp/rows_10_10_7_symbols.xml deleted file mode 100644 index 0e4710c37..000000000 --- a/java/res/xml-sw600dp/rows_10_10_7_symbols.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="9.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols1" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="9.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols2" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="9.0%p" - > - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="10.0%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols3" /> - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <include - latin:keyboardLayout="@xml/row_symbols4" /> -</merge> diff --git a/java/res/xml-sw600dp/rows_10_10_7_symbols_shift.xml b/java/res/xml-sw600dp/rows_10_10_7_symbols_shift.xml deleted file mode 100644 index 3d3b59f22..000000000 --- a/java/res/xml-sw600dp/rows_10_10_7_symbols_shift.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="9.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift1" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="9.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift2" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="9.0%p" - > - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="10.0%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift3" /> - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <include - latin:keyboardLayout="@xml/row_symbols_shift4" /> -</merge> diff --git a/java/res/xml-sw600dp/rows_pcqwerty.xml b/java/res/xml-sw600dp/rows_pcqwerty.xml index fa6080a19..8714815ef 100644 --- a/java/res/xml-sw600dp/rows_pcqwerty.xml +++ b/java/res/xml-sw600dp/rows_pcqwerty.xml @@ -26,8 +26,19 @@ <Row latin:keyWidth="7.0%p" > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> + <switch> + <case + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" + > + <include + latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> + </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> + <default> + <include + latin:keyboardLayout="@xml/rowkeys_pcqwerty1_shift" /> + </default> + </switch> <Key latin:keyStyle="deleteKeyStyle" latin:keyWidth="fillRight" /> @@ -44,9 +55,7 @@ <Row latin:keyWidth="7.0%p" > - <Key - latin:keyStyle="toSymbolKeyStyle" - latin:keyLabel="!text/label_to_symbol_key_pcqwerty" + <Spacer latin:keyWidth="12.0%p" /> <include latin:keyboardLayout="@xml/rowkeys_pcqwerty3" /> diff --git a/java/res/xml-sw600dp/rows_pcqwerty_symbols.xml b/java/res/xml-sw600dp/rows_pcqwerty_symbols.xml deleted file mode 100644 index 5e1aa6382..000000000 --- a/java/res/xml-sw600dp/rows_pcqwerty_symbols.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="7.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="7.0%p" - > - <Key - latin:keyStyle="tabKeyStyle" - latin:keyWidth="9.0%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty2" /> - </Row> - <Row - latin:keyWidth="7.0%p" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyWidth="12.0%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty3" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="7.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty4" - latin:keyXPos="15.0%p" /> - </Row> - <include - latin:keyboardLayout="@xml/row_pcqwerty5" /> -</merge> diff --git a/java/res/xml-sw600dp/rows_symbols.xml b/java/res/xml-sw600dp/rows_symbols.xml index 3d0593dab..dee79e64f 100644 --- a/java/res/xml-sw600dp/rows_symbols.xml +++ b/java/res/xml-sw600dp/rows_symbols.xml @@ -23,8 +23,6 @@ > <include latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> <Row latin:keyWidth="9.0%p" > @@ -38,23 +36,22 @@ latin:keyWidth="9.0%p" > <include - latin:keyboardLayout="@xml/rowkeys_symbols2" - latin:keyXPos="4.5%p" /> + latin:keyboardLayout="@xml/rowkeys_symbols2" /> <Key latin:keyStyle="enterKeyStyle" latin:keyWidth="fillRight" /> </Row> - <Row + <Row latin:keyWidth="9.0%p" > - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="10.0%p" /> <include + latin:keyXPos="1.0%p" latin:keyboardLayout="@xml/rowkeys_symbols3" /> <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="fillRight" /> + latin:keyLabel="," /> + <include + latin:keyboardLayout="@xml/key_symbols_period" + latin:backgroundType="normal" /> </Row> <include latin:keyboardLayout="@xml/row_symbols4" /> diff --git a/java/res/xml-sw600dp/rows_symbols_shift.xml b/java/res/xml-sw600dp/rows_symbols_shift.xml deleted file mode 100644 index 0050c0c15..000000000 --- a/java/res/xml-sw600dp/rows_symbols_shift.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2011, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="9.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift1" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="9.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift2" - latin:keyXPos="4.5%p" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="9.0%p" - > - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="10.0%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift3" /> - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <include - latin:keyboardLayout="@xml/row_symbols_shift4" /> -</merge> diff --git a/java/res/xml-sw600dp/kbd_10_10_7_symbols.xml b/java/res/xml-sw768dp/kbd_10_10_7_symbols.xml index dd545b5ef..dd545b5ef 100644 --- a/java/res/xml-sw600dp/kbd_10_10_7_symbols.xml +++ b/java/res/xml-sw768dp/kbd_10_10_7_symbols.xml diff --git a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml b/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml deleted file mode 100644 index 135222b22..000000000 --- a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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. -*/ ---> - -<Keyboard - xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:rowHeight="20%p" - latin:verticalGap="@fraction/key_bottom_gap_5row" - latin:keyLetterSize="@fraction/key_letter_ratio_5row" - latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row" - latin:touchPositionCorrectionData="@array/touch_position_correction_data_default" -> - <include - latin:keyboardLayout="@xml/rows_thai_symbols_shift" /> -</Keyboard> diff --git a/java/res/xml-sw768dp/key_styles_common.xml b/java/res/xml-sw768dp/key_styles_common.xml index 7c0a82a71..538930948 100644 --- a/java/res/xml-sw768dp/key_styles_common.xml +++ b/java/res/xml-sw768dp/key_styles_common.xml @@ -168,16 +168,6 @@ latin:keyLabel="!text/label_to_alpha_key" latin:parentStyle="baseForLayoutSwitchKeyStyle" /> <key-style - latin:styleName="toMoreSymbolKeyStyle" - latin:code="!code/key_shift" - latin:keyLabel="!text/label_to_more_symbol_for_tablet_key" - latin:parentStyle="baseForLayoutSwitchKeyStyle" /> - <key-style - latin:styleName="backFromMoreSymbolKeyStyle" - latin:code="!code/key_shift" - latin:keyLabel="!text/label_to_symbol_key" - latin:parentStyle="baseForLayoutSwitchKeyStyle" /> - <key-style latin:styleName="comKeyStyle" latin:keyLabel="!text/keylabel_for_popular_domain" latin:keyLabelFlags="fontNormal|hasPopupHint|preserveCase" diff --git a/java/res/xml-sw768dp/row_pcqwerty5.xml b/java/res/xml-sw768dp/row_pcqwerty5.xml index e27ec878b..6bfd6463a 100644 --- a/java/res/xml-sw768dp/row_pcqwerty5.xml +++ b/java/res/xml-sw768dp/row_pcqwerty5.xml @@ -24,36 +24,34 @@ <Row latin:keyWidth="8.047%p" > - <include - latin:keyboardLayout="@xml/key_settings" /> <switch> <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" + latin:languageSwitchKeyEnabled="true" > - <Spacer - latin:keyXPos="15.0%p" - latin:keyWidth="10.5%p" /> + <Key + latin:keyStyle="languageSwitchKeyStyle" + latin:backgroundType="functional" /> </case> + </switch> + <Key + latin:keyStyle="spaceKeyStyle" + latin:keyXPos="25.5%p" + latin:keyWidth="49.0%p" /> + <switch> <case - latin:mode="email|url" + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" > - <Key - latin:keyStyle="comKeyStyle" - latin:keyXPos="15.0%p" - latin:keyWidth="10.5%p" /> + <include + latin:keyXPos="-8.047%p" + latin:keyboardLayout="@xml/key_shortcut" /> </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> <default> - <Spacer - latin:keyXPos="15.0%p" - latin:keyWidth="10.5%p" /> + <include + latin:keyXPos="-8.047%p" + latin:backgroundType="functional" + latin:keyboardLayout="@xml/key_symbols_period" /> </default> </switch> - <Key - latin:keyStyle="spaceKeyStyle" - latin:keyWidth="49.0%p" /> - <include - latin:keyXPos="-8.047%p" - latin:keyWidth="fillRight" - latin:keyboardLayout="@xml/key_shortcut" /> </Row> </merge> diff --git a/java/res/xml-sw768dp/row_symbols4.xml b/java/res/xml-sw768dp/row_symbols4.xml index b801a12a7..49340b8ae 100644 --- a/java/res/xml-sw768dp/row_symbols4.xml +++ b/java/res/xml-sw768dp/row_symbols4.xml @@ -28,21 +28,13 @@ <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> <Spacer latin:keyWidth="13.829%p" /> - <Key - latin:keyLabel="/" /> - <include - latin:keyboardLayout="@xml/key_f1" /> <include latin:keyXPos="29.923%p" latin:keyboardLayout="@xml/key_space" latin:backgroundType="normal" /> - <Key - latin:keyLabel=""" - latin:moreKeys="!text/more_keys_for_tablet_double_quote" /> - <Key - latin:keyLabel="_" /> - <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> - <Spacer - latin:keyWidth="fillRight" /> + <Spacer /> + <Spacer /> + <include + latin:keyboardLayout="@xml/key_f2" /> </Row> </merge> diff --git a/java/res/xml-sw768dp/row_symbols_shift4.xml b/java/res/xml-sw768dp/row_symbols_shift4.xml deleted file mode 100644 index f71864bc3..000000000 --- a/java/res/xml-sw768dp/row_symbols_shift4.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Row - latin:keyWidth="8.047%p" - latin:backgroundType="functional" - > - <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> - <Spacer - latin:keyWidth="29.923%p" /> - <include - latin:keyboardLayout="@xml/key_space" - latin:backgroundType="normal" /> - <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> - <Spacer - latin:keyWidth="fillRight" /> - </Row> -</merge> diff --git a/java/res/xml-sw768dp/rows_10_10_7_symbols.xml b/java/res/xml-sw768dp/rows_10_10_7_symbols.xml index d9b0d2383..967b90359 100644 --- a/java/res/xml-sw768dp/rows_10_10_7_symbols.xml +++ b/java/res/xml-sw768dp/rows_10_10_7_symbols.xml @@ -23,8 +23,6 @@ > <include latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> <Row latin:keyWidth="8.282%p" > @@ -54,15 +52,14 @@ <Row latin:keyWidth="8.047%p" > - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="13.829%p" /> <include + latin:keyXPos="5.782%p" latin:keyboardLayout="@xml/rowkeys_symbols3" /> <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyXPos="-13.750%p" - latin:keyWidth="fillRight" /> + latin:keyLabel="," /> + <include + latin:keyboardLayout="@xml/key_symbols_period" + latin:backgroundType="normal" /> </Row> <include latin:keyboardLayout="@xml/row_symbols4" /> diff --git a/java/res/xml-sw768dp/rows_10_10_7_symbols_shift.xml b/java/res/xml-sw768dp/rows_10_10_7_symbols_shift.xml deleted file mode 100644 index a317dbf84..000000000 --- a/java/res/xml-sw768dp/rows_10_10_7_symbols_shift.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="8.282%p" - > - <Key - latin:keyStyle="tabKeyStyle" - latin:keyLabelFlags="alignLeft" - latin:keyWidth="7.969%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift1" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="8.125%p" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyLabelFlags="alignLeft" - latin:keyWidth="10.167%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift2" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="8.047%p" - > - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="13.829%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift3" /> - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyXPos="-13.750%p" - latin:keyWidth="fillRight" /> - </Row> - <include - latin:keyboardLayout="@xml/row_symbols_shift4" /> -</merge> diff --git a/java/res/xml-sw768dp/rows_pcqwerty.xml b/java/res/xml-sw768dp/rows_pcqwerty.xml index a8447288f..5f721a224 100644 --- a/java/res/xml-sw768dp/rows_pcqwerty.xml +++ b/java/res/xml-sw768dp/rows_pcqwerty.xml @@ -26,8 +26,19 @@ <Row latin:keyWidth="7.0%p" > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> + <switch> + <case + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" + > + <include + latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> + </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> + <default> + <include + latin:keyboardLayout="@xml/rowkeys_pcqwerty1_shift" /> + </default> + </switch> <Key latin:keyStyle="deleteKeyStyle" latin:keyWidth="fillRight" /> @@ -44,9 +55,7 @@ <Row latin:keyWidth="7.0%p" > - <Key - latin:keyStyle="toSymbolKeyStyle" - latin:keyLabel="!text/label_to_symbol_key_pcqwerty" + <Spacer latin:keyWidth="12.0%p" /> <include latin:keyboardLayout="@xml/rowkeys_pcqwerty3" /> diff --git a/java/res/xml-sw768dp/rows_pcqwerty_symbols.xml b/java/res/xml-sw768dp/rows_pcqwerty_symbols.xml deleted file mode 100644 index 956da97fb..000000000 --- a/java/res/xml-sw768dp/rows_pcqwerty_symbols.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2011, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="7.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="7.0%p" - > - <Key - latin:keyStyle="tabKeyStyle" - latin:keyWidth="9.0%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty2" /> - </Row> - <Row - latin:keyWidth="7.0%p" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyWidth="12.0%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty3" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="7.0%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty4" - latin:keyXPos="15.0%p" /> - </Row> - <include - latin:keyboardLayout="@xml/row_pcqwerty5" /> -</merge> diff --git a/java/res/xml-sw768dp/rows_symbols.xml b/java/res/xml-sw768dp/rows_symbols.xml index efd77352b..57944cb8e 100644 --- a/java/res/xml-sw768dp/rows_symbols.xml +++ b/java/res/xml-sw768dp/rows_symbols.xml @@ -23,8 +23,6 @@ > <include latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> <Row latin:keyWidth="8.282%p" > @@ -54,14 +52,14 @@ <Row latin:keyWidth="8.047%p" > - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="13.829%p" /> <include + latin:keyXPos="5.782%p" latin:keyboardLayout="@xml/rowkeys_symbols3" /> <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="fillRight" /> + latin:keyLabel="," /> + <include + latin:keyboardLayout="@xml/key_symbols_period" + latin:backgroundType="normal" /> </Row> <include latin:keyboardLayout="@xml/row_symbols4" /> diff --git a/java/res/xml-sw768dp/rows_symbols_shift.xml b/java/res/xml-sw768dp/rows_symbols_shift.xml deleted file mode 100644 index fd1b93d51..000000000 --- a/java/res/xml-sw768dp/rows_symbols_shift.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2011, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="8.282%p" - > - <Key - latin:keyStyle="tabKeyStyle" - latin:keyLabelFlags="alignLeft" - latin:keyWidth="7.969%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift1" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="8.125%p" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyLabelFlags="alignLeft" - latin:keyWidth="11.172%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift2" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="8.047%p" - > - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="13.829%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift3" /> - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <include - latin:keyboardLayout="@xml/row_symbols_shift4" /> -</merge> diff --git a/java/res/xml-sw768dp/rows_thai_symbols.xml b/java/res/xml-sw768dp/rows_thai_symbols.xml index 528514182..15fb4e177 100644 --- a/java/res/xml-sw768dp/rows_thai_symbols.xml +++ b/java/res/xml-sw768dp/rows_thai_symbols.xml @@ -23,8 +23,6 @@ > <include latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> <Row latin:keyWidth="8.282%p" > @@ -61,15 +59,14 @@ <Row latin:keyWidth="8.047%p" > - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="13.829%p" /> <include + latin:keyXPos="5.782%p" latin:keyboardLayout="@xml/rowkeys_symbols3" /> <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyXPos="-13.750%p" - latin:keyWidth="fillRight" /> + latin:keyLabel="," /> + <include + latin:keyboardLayout="@xml/key_symbols_period" + latin:backgroundType="normal" /> </Row> <include latin:keyboardLayout="@xml/row_symbols4" /> diff --git a/java/res/xml-sw768dp/rows_thai_symbols_shift.xml b/java/res/xml-sw768dp/rows_thai_symbols_shift.xml deleted file mode 100644 index 9d2694b86..000000000 --- a/java/res/xml-sw768dp/rows_thai_symbols_shift.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="8.282%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_thai_digits" - latin:keyXPos="7.969%p" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="8.282%p" - > - <Key - latin:keyStyle="tabKeyStyle" - latin:keyLabelFlags="alignLeft" - latin:keyWidth="7.969%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift1" /> - </Row> - <Row - latin:keyWidth="8.125%p" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyLabelFlags="alignLeft" - latin:keyWidth="11.172%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift2" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> - <Row - latin:keyWidth="8.047%p" - > - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="13.829%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift3" /> - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyXPos="-13.750%p" - latin:keyWidth="fillRight" /> - </Row> - <include - latin:keyboardLayout="@xml/row_symbols_shift4" /> -</merge> diff --git a/java/res/xml/kbd_thai_symbols_shift.xml b/java/res/xml/kbd_emoji_category1.xml index a2d67caf4..92b0c3fbf 100644 --- a/java/res/xml/kbd_thai_symbols_shift.xml +++ b/java/res/xml/kbd_emoji_category1.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2012, 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,8 +20,11 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:touchPositionCorrectionData="@array/touch_position_correction_data_default" + latin:keyWidth="@fraction/emoji_keyboard_key_width" + latin:keyLetterSize="90%p" > - <include - latin:keyboardLayout="@xml/rows_symbols_shift" /> + <GridRows + latin:codesArray="@array/emoji_faces" + latin:keyLabelFlags="fontNormal" + latin:backgroundType="empty" /> </Keyboard> diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_emoji_category2.xml index 932ec017e..17d36c52f 100644 --- a/java/res/xml/kbd_symbols_shift.xml +++ b/java/res/xml/kbd_emoji_category2.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2008, 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,8 +20,11 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:touchPositionCorrectionData="@array/touch_position_correction_data_default" + latin:keyWidth="@fraction/emoji_keyboard_key_width" + latin:keyLetterSize="90%p" > - <include - latin:keyboardLayout="@xml/rows_symbols_shift" /> + <GridRows + latin:codesArray="@array/emoji_objects" + latin:keyLabelFlags="fontNormal" + latin:backgroundType="empty" /> </Keyboard> diff --git a/java/res/xml-sw600dp/kbd_10_10_7_symbols_shift.xml b/java/res/xml/kbd_emoji_category3.xml index c36f0097e..9000a3a11 100644 --- a/java/res/xml-sw600dp/kbd_10_10_7_symbols_shift.xml +++ b/java/res/xml/kbd_emoji_category3.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2012, 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,8 +20,11 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:touchPositionCorrectionData="@array/touch_position_correction_data_default" + latin:keyWidth="@fraction/emoji_keyboard_key_width" + latin:keyLetterSize="90%p" > - <include - latin:keyboardLayout="@xml/rows_10_10_7_symbols_shift" /> + <GridRows + latin:codesArray="@array/emoji_nature" + latin:keyLabelFlags="fontNormal" + latin:backgroundType="empty" /> </Keyboard> diff --git a/java/res/xml/kbd_10_10_7_symbols_shift.xml b/java/res/xml/kbd_emoji_category4.xml index a2d67caf4..e79e124e7 100644 --- a/java/res/xml/kbd_10_10_7_symbols_shift.xml +++ b/java/res/xml/kbd_emoji_category4.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2012, 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,8 +20,11 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:touchPositionCorrectionData="@array/touch_position_correction_data_default" + latin:keyWidth="@fraction/emoji_keyboard_key_width" + latin:keyLetterSize="90%p" > - <include - latin:keyboardLayout="@xml/rows_symbols_shift" /> + <GridRows + latin:codesArray="@array/emoji_places" + latin:keyLabelFlags="fontNormal" + latin:backgroundType="empty" /> </Keyboard> diff --git a/java/res/xml/kbd_emoji_category5.xml b/java/res/xml/kbd_emoji_category5.xml new file mode 100644 index 000000000..07b3d908c --- /dev/null +++ b/java/res/xml/kbd_emoji_category5.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. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:keyWidth="@fraction/emoji_keyboard_key_width" + latin:keyLetterSize="90%p" +> + <GridRows + latin:codesArray="@array/emoji_symbols" + latin:keyLabelFlags="fontNormal" + latin:backgroundType="empty" /> +</Keyboard> diff --git a/java/res/xml/kbd_emoji_category6.xml b/java/res/xml/kbd_emoji_category6.xml new file mode 100644 index 000000000..a07966b07 --- /dev/null +++ b/java/res/xml/kbd_emoji_category6.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. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:keyWidth="@fraction/emoji_keyboard_key_width" + latin:keyLetterSize="90%p" +> + <GridRows + latin:textsArray="@array/emoji_emoticons" + latin:keyLabelFlags="fontNormal" + latin:backgroundType="empty" /> +</Keyboard> diff --git a/java/res/xml/kbd_emoji_recents.xml b/java/res/xml/kbd_emoji_recents.xml new file mode 100644 index 000000000..8b4fa958c --- /dev/null +++ b/java/res/xml/kbd_emoji_recents.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. +*/ +--> + +<Keyboard + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" + latin:keyWidth="@fraction/emoji_keyboard_key_width" + latin:keyLetterSize="90%p" +> + <GridRows + latin:codesArray="@array/emoji_recents" + latin:keyLabelFlags="fontNormal" + latin:backgroundType="empty" /> +</Keyboard> diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_pcqwerty_symbols.xml deleted file mode 100644 index bfb39e8aa..000000000 --- a/java/res/xml/kbd_pcqwerty_symbols.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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. -*/ ---> - -<Keyboard - xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:rowHeight="20%p" - latin:verticalGap="@fraction/key_bottom_gap_5row" - latin:keyLetterSize="@fraction/key_letter_ratio_5row" - latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row" - latin:touchPositionCorrectionData="@array/touch_position_correction_data_default" -> - <include - latin:keyboardLayout="@xml/rows_pcqwerty_symbols" /> -</Keyboard> diff --git a/java/res/xml/key_styles_currency.xml b/java/res/xml/key_currency.xml index 76fe0e6b0..2e4f828ce 100644 --- a/java/res/xml/key_styles_currency.xml +++ b/java/res/xml/key_currency.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. @@ -18,6 +18,7 @@ */ --> +<!-- TODO: Move these definitions to text resources and remove key_currency.xml. --> <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > @@ -26,7 +27,7 @@ latin:passwordInput="true" > <include - latin:keyboardLayout="@xml/key_styles_currency_dollar" /> + latin:keyboardLayout="@xml/key_dollar" /> </case> <!-- Countries using Euro currency, 23 countries as of November 2012. 1. Andorra (ca_AD, ca_ES) @@ -56,7 +57,7 @@ latin:countryCode="AD|AT|BE|CY|EE|FI|FR|DE|GR|IE|IT|XK|LU|MT|MO|ME|NL|PT|SM|SK|SI|ES|VA" > <include - latin:keyboardLayout="@xml/key_styles_currency_euro" /> + latin:keyboardLayout="@xml/key_euro" /> </case> <!-- Note: Some subtype locale may not have country code, and it it supposed to indicate the country where the language originally/mainly spoken. --> @@ -80,7 +81,7 @@ latin:localeCode="da|de|es|el|fi|fr|it|nl|sk|sl|sv|tr" > <include - latin:keyboardLayout="@xml/key_styles_currency_euro" /> + latin:keyboardLayout="@xml/key_euro" /> </case> <!-- ca: Catalan (Andorra, Spain) et: Estonian (Estonia) @@ -90,7 +91,7 @@ latin:languageCode="ca|et|lb|mt" > <include - latin:keyboardLayout="@xml/key_styles_currency_euro" /> + latin:keyboardLayout="@xml/key_euro" /> </case> <!-- fa: Persian (Rial and Afgahni) hi: Hindi (Indian Rupee) @@ -104,26 +105,9 @@ <case latin:languageCode="fa|hi|iw|mn|th|uk|vi" > - <!-- U+00A3: "£" POUND SIGN - U+20AC: "€" EURO SIGN - U+00A2: "¢" CENT SIGN --> - <key-style - latin:styleName="currencyKeyStyle" - latin:keyLabel="!text/keylabel_for_currency_generic" - latin:moreKeys="!text/more_keys_for_currency_generic" /> - <key-style - latin:styleName="moreCurrency1KeyStyle" - latin:keyLabel="£" /> - <key-style - latin:styleName="moreCurrency2KeyStyle" - latin:keyLabel="€" /> - <key-style - latin:styleName="moreCurrency3KeyStyle" - latin:keyLabel="$" - latin:moreKeys="¢" /> - <key-style - latin:styleName="moreCurrency4KeyStyle" - latin:keyLabel="¢" /> + <Key + latin:keyLabel="!text/keylabel_for_currency" + latin:moreKeys="!text/more_keys_for_currency" /> </case> <!-- GB: United Kingdom (Pound) --> <case @@ -134,28 +118,14 @@ U+00A5: "¥" YEN SIGN U+00A2: "¢" CENT SIGN U+20B1: "₱" PESO SIGN --> - <key-style - latin:styleName="currencyKeyStyle" + <Key latin:keyLabel="£" latin:moreKeys="¢,$,€,¥,₱" /> - <key-style - latin:styleName="moreCurrency1KeyStyle" - latin:keyLabel="€" /> - <key-style - latin:styleName="moreCurrency2KeyStyle" - latin:keyLabel="¥" /> - <key-style - latin:styleName="moreCurrency3KeyStyle" - latin:keyLabel="$" - latin:moreKeys="¢" /> - <key-style - latin:styleName="moreCurrency4KeyStyle" - latin:keyLabel="¢" /> </case> <!-- ar: Arabic (Dollar and Rial) --> <default> <include - latin:keyboardLayout="@xml/key_styles_currency_dollar" /> + latin:keyboardLayout="@xml/key_dollar" /> </default> </switch> </merge> diff --git a/java/res/xml/key_styles_currency_dollar.xml b/java/res/xml/key_dollar.xml index 674a3966d..118c7a291 100644 --- a/java/res/xml/key_styles_currency_dollar.xml +++ b/java/res/xml/key_dollar.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. @@ -23,20 +23,7 @@ U+00A2: "¢" CENT SIGN U+20AC: "€" EURO SIGN U+00A5: "¥" YEN SIGN --> - <key-style - latin:styleName="currencyKeyStyle" + <Key latin:keyLabel="$" latin:moreKeys="!text/more_keys_for_currency_dollar" /> - <key-style - latin:styleName="moreCurrency1KeyStyle" - latin:keyLabel="£" /> - <key-style - latin:styleName="moreCurrency2KeyStyle" - latin:keyLabel="¢" /> - <key-style - latin:styleName="moreCurrency3KeyStyle" - latin:keyLabel="€" /> - <key-style - latin:styleName="moreCurrency4KeyStyle" - latin:keyLabel="¥" /> </merge> diff --git a/java/res/xml/key_styles_currency_euro.xml b/java/res/xml/key_euro.xml index c1b5e0384..820ced97c 100644 --- a/java/res/xml/key_styles_currency_euro.xml +++ b/java/res/xml/key_euro.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. @@ -24,21 +24,7 @@ U+00A3: "£" POUND SIGN U+00A5: "¥" YEN SIGN U+20B1: "₱" PESO SIGN --> - <key-style - latin:styleName="currencyKeyStyle" + <Key latin:keyLabel="€" latin:moreKeys="¢,£,$,¥,₱" /> - <key-style - latin:styleName="moreCurrency1KeyStyle" - latin:keyLabel="£" /> - <key-style - latin:styleName="moreCurrency2KeyStyle" - latin:keyLabel="¥" /> - <key-style - latin:styleName="moreCurrency3KeyStyle" - latin:keyLabel="$" - latin:moreKeys="¢" /> - <key-style - latin:styleName="moreCurrency4KeyStyle" - latin:keyLabel="¢" /> </merge> diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml index 355455e3b..dabe1e7eb 100644 --- a/java/res/xml/key_styles_common.xml +++ b/java/res/xml/key_styles_common.xml @@ -179,15 +179,6 @@ latin:keyLabel="!text/label_to_alpha_key" latin:parentStyle="baseForLayoutSwitchKeyStyle" /> <key-style - latin:styleName="toMoreSymbolKeyStyle" - latin:code="!code/key_shift" - latin:keyLabel="!text/label_to_more_symbol_key" - latin:parentStyle="baseForLayoutSwitchKeyStyle" /> - <key-style - latin:styleName="backFromMoreSymbolKeyStyle" - latin:code="!code/key_shift" - latin:parentStyle="baseForToSymbolKeyStyle" /> - <key-style latin:styleName="punctuationKeyStyle" latin:keyLabel="." latin:keyLabelFlags="hasPopupHint" diff --git a/java/res/xml/key_symbols_period.xml b/java/res/xml/key_symbols_period.xml new file mode 100644 index 000000000..6efc9dee3 --- /dev/null +++ b/java/res/xml/key_symbols_period.xml @@ -0,0 +1,47 @@ +<?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,℅,™,®,©,§,¶,\\,,•,°,′,″,↑,↓,←,→,…,!text/more_keys_for_bullet,Δ,Π,π" /> +</merge> diff --git a/java/res/xml/keyboard_layout_set_arabic.xml b/java/res/xml/keyboard_layout_set_arabic.xml index 10e95bd30..9eb11dc5e 100644 --- a/java/res/xml/keyboard_layout_set_arabic.xml +++ b/java/res/xml/keyboard_layout_set_arabic.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_azerty.xml b/java/res/xml/keyboard_layout_set_azerty.xml index 4d144edbc..03d8ce72b 100644 --- a/java/res/xml/keyboard_layout_set_azerty.xml +++ b/java/res/xml/keyboard_layout_set_azerty.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_10_10_7_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_10_10_7_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_bulgarian.xml b/java/res/xml/keyboard_layout_set_bulgarian.xml index c6fdff9a2..0b92af8e4 100644 --- a/java/res/xml/keyboard_layout_set_bulgarian.xml +++ b/java/res/xml/keyboard_layout_set_bulgarian.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_bulgarian_bds.xml b/java/res/xml/keyboard_layout_set_bulgarian_bds.xml index a36b3bd52..d185a85b4 100644 --- a/java/res/xml/keyboard_layout_set_bulgarian_bds.xml +++ b/java/res/xml/keyboard_layout_set_bulgarian_bds.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_colemak.xml b/java/res/xml/keyboard_layout_set_colemak.xml index c18f13225..fd4254291 100644 --- a/java/res/xml/keyboard_layout_set_colemak.xml +++ b/java/res/xml/keyboard_layout_set_colemak.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_10_10_7_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_10_10_7_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_dvorak.xml b/java/res/xml/keyboard_layout_set_dvorak.xml index eb8e0c539..851a27117 100644 --- a/java/res/xml/keyboard_layout_set_dvorak.xml +++ b/java/res/xml/keyboard_layout_set_dvorak.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_10_10_7_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_10_10_7_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_east_slavic.xml b/java/res/xml/keyboard_layout_set_east_slavic.xml index 8d66faf8f..9dc284668 100644 --- a/java/res/xml/keyboard_layout_set_east_slavic.xml +++ b/java/res/xml/keyboard_layout_set_east_slavic.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_emoji.xml b/java/res/xml/keyboard_layout_set_emoji.xml new file mode 100644 index 000000000..98e6b6b5c --- /dev/null +++ b/java/res/xml/keyboard_layout_set_emoji.xml @@ -0,0 +1,44 @@ +<?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. +*/ +--> + +<KeyboardLayoutSet + xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Element + latin:elementName="emojiRecents" + latin:elementKeyboard="@xml/kbd_emoji_recents" /> + <Element + latin:elementName="emojiCategory1" + latin:elementKeyboard="@xml/kbd_emoji_category1" /> + <Element + latin:elementName="emojiCategory2" + latin:elementKeyboard="@xml/kbd_emoji_category2" /> + <Element + latin:elementName="emojiCategory3" + latin:elementKeyboard="@xml/kbd_emoji_category3" /> + <Element + latin:elementName="emojiCategory4" + latin:elementKeyboard="@xml/kbd_emoji_category4" /> + <Element + latin:elementName="emojiCategory5" + latin:elementKeyboard="@xml/kbd_emoji_category5" /> + <Element + latin:elementName="emojiCategory6" + latin:elementKeyboard="@xml/kbd_emoji_category6" /> +</KeyboardLayoutSet> diff --git a/java/res/xml/keyboard_layout_set_farsi.xml b/java/res/xml/keyboard_layout_set_farsi.xml index b9a91e3a8..ef29e1ae8 100644 --- a/java/res/xml/keyboard_layout_set_farsi.xml +++ b/java/res/xml/keyboard_layout_set_farsi.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_georgian.xml b/java/res/xml/keyboard_layout_set_georgian.xml index 36d091653..181c99713 100644 --- a/java/res/xml/keyboard_layout_set_georgian.xml +++ b/java/res/xml/keyboard_layout_set_georgian.xml @@ -44,9 +44,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_greek.xml b/java/res/xml/keyboard_layout_set_greek.xml index b376e4fe3..2e4a28692 100644 --- a/java/res/xml/keyboard_layout_set_greek.xml +++ b/java/res/xml/keyboard_layout_set_greek.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_hebrew.xml b/java/res/xml/keyboard_layout_set_hebrew.xml index 212816dfe..c8ac31c7e 100644 --- a/java/res/xml/keyboard_layout_set_hebrew.xml +++ b/java/res/xml/keyboard_layout_set_hebrew.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_10_10_7_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_10_10_7_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_hindi.xml b/java/res/xml/keyboard_layout_set_hindi.xml index e850c7ebc..1bd3d72fb 100644 --- a/java/res/xml/keyboard_layout_set_hindi.xml +++ b/java/res/xml/keyboard_layout_set_hindi.xml @@ -44,9 +44,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_mongolian.xml b/java/res/xml/keyboard_layout_set_mongolian.xml index 2d364f682..bbf3c0945 100644 --- a/java/res/xml/keyboard_layout_set_mongolian.xml +++ b/java/res/xml/keyboard_layout_set_mongolian.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_nordic.xml b/java/res/xml/keyboard_layout_set_nordic.xml index 1f00f440e..ce6fc635b 100644 --- a/java/res/xml/keyboard_layout_set_nordic.xml +++ b/java/res/xml/keyboard_layout_set_nordic.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_pcqwerty.xml b/java/res/xml/keyboard_layout_set_pcqwerty.xml index 9367ed00c..67fbd9159 100644 --- a/java/res/xml/keyboard_layout_set_pcqwerty.xml +++ b/java/res/xml/keyboard_layout_set_pcqwerty.xml @@ -25,12 +25,6 @@ latin:elementKeyboard="@xml/kbd_pcqwerty" latin:enableProximityCharsCorrection="true" /> <Element - latin:elementName="symbols" - latin:elementKeyboard="@xml/kbd_pcqwerty_symbols" /> - <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_pcqwerty_symbols" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_qwerty.xml b/java/res/xml/keyboard_layout_set_qwerty.xml index 821517081..98b3582d4 100644 --- a/java/res/xml/keyboard_layout_set_qwerty.xml +++ b/java/res/xml/keyboard_layout_set_qwerty.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_qwertz.xml b/java/res/xml/keyboard_layout_set_qwertz.xml index f9e87a66f..789dcfa62 100644 --- a/java/res/xml/keyboard_layout_set_qwertz.xml +++ b/java/res/xml/keyboard_layout_set_qwertz.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_south_slavic.xml b/java/res/xml/keyboard_layout_set_south_slavic.xml index 36666b91b..eaeaa1c4b 100644 --- a/java/res/xml/keyboard_layout_set_south_slavic.xml +++ b/java/res/xml/keyboard_layout_set_south_slavic.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_spanish.xml b/java/res/xml/keyboard_layout_set_spanish.xml index 57cef5234..500e23a10 100644 --- a/java/res/xml/keyboard_layout_set_spanish.xml +++ b/java/res/xml/keyboard_layout_set_spanish.xml @@ -28,9 +28,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_10_10_7_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_10_10_7_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keyboard_layout_set_thai.xml b/java/res/xml/keyboard_layout_set_thai.xml index 94713e3d4..146b413d2 100644 --- a/java/res/xml/keyboard_layout_set_thai.xml +++ b/java/res/xml/keyboard_layout_set_thai.xml @@ -44,9 +44,6 @@ latin:elementName="symbols" latin:elementKeyboard="@xml/kbd_thai_symbols" /> <Element - latin:elementName="symbolsShifted" - latin:elementKeyboard="@xml/kbd_thai_symbols_shift" /> - <Element latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element diff --git a/java/res/xml/keys_parentheses.xml b/java/res/xml/keys_parentheses.xml deleted file mode 100644 index 25e89c930..000000000 --- a/java/res/xml/keys_parentheses.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Key - latin:keyLabel="(" - latin:code="!code/key_left_parenthesis" - latin:moreKeys="!text/more_keys_for_left_parenthesis" /> - <Key - latin:keyLabel=")" - latin:code="!code/key_right_parenthesis" - latin:moreKeys="!text/more_keys_for_right_parenthesis" /> -</merge> diff --git a/java/res/xml/keys_pcqwerty2_right3.xml b/java/res/xml/keys_pcqwerty2_right3.xml index 2065e6b46..6f86477da 100644 --- a/java/res/xml/keys_pcqwerty2_right3.xml +++ b/java/res/xml/keys_pcqwerty2_right3.xml @@ -27,25 +27,22 @@ > <Key latin:keyLabel="[" - latin:moreKeys="{" /> + latin:additionalMoreKeys="{" /> <Key latin:keyLabel="]" - latin:moreKeys="}" /> - <!-- U+00A6: "¦" BROKEN BAR --> + latin:additionalMoreKeys="}" /> <Key latin:keyLabel="\\" - latin:moreKeys="\\|,¦" /> + latin:additionalMoreKeys="\\|" /> </case> - <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols*" --> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> <default> <Key latin:keyLabel="{" /> <Key latin:keyLabel="}" /> - <!-- U+00A6: "¦" BROKEN BAR --> <Key - latin:keyLabel="|" - latin:moreKeys="¦" /> + latin:keyLabel="|" /> </default> </switch> </merge> diff --git a/java/res/xml/keys_pcqwerty3_right2.xml b/java/res/xml/keys_pcqwerty3_right2.xml index aa150afb3..8da145b20 100644 --- a/java/res/xml/keys_pcqwerty3_right2.xml +++ b/java/res/xml/keys_pcqwerty3_right2.xml @@ -27,12 +27,13 @@ > <Key latin:keyLabel=";" - latin:moreKeys=":" /> + latin:additionalMoreKeys=":" /> <Key latin:keyLabel="\'" - latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,",!text/single_quotes" /> + latin:additionalMoreKeys=""" + latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,%,!text/single_quotes" /> </case> - <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols*" --> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> <default> <Key latin:keyLabel=":" /> diff --git a/java/res/xml/keys_pcqwerty4_right3.xml b/java/res/xml/keys_pcqwerty4_right3.xml index 7795b3d8b..e6084cb45 100644 --- a/java/res/xml/keys_pcqwerty4_right3.xml +++ b/java/res/xml/keys_pcqwerty4_right3.xml @@ -27,16 +27,16 @@ > <Key latin:keyLabel="," - latin:moreKeys="<" /> + latin:additionalMoreKeys="<" /> <Key latin:keyLabel="." - latin:moreKeys=">" /> - <!-- U+00BF: "¿" INVERTED QUESTION MARK --> + latin:additionalMoreKeys=">" /> <Key latin:keyLabel="/" - latin:moreKeys="\?,¿" /> + latin:additionalMoreKeys="\?" + latin:moreKeys="!text/more_keys_for_symbols_question" /> </case> - <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols*" --> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> <default> <!-- U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK @@ -50,10 +50,9 @@ <Key latin:keyLabel=">" latin:moreKeys="!fixedColumnOrder!3,›,≥,»" /> - <!-- U+00BF: "¿" INVERTED QUESTION MARK --> <Key latin:keyLabel="\?" - latin:moreKeys="¿" /> + latin:moreKeys="!text/more_keys_for_symbols_question" /> </default> </switch> </merge> diff --git a/java/res/xml/keys_pcqwerty_symbols2.xml b/java/res/xml/keys_pcqwerty_symbols2.xml deleted file mode 100644 index d0ea984e8..000000000 --- a/java/res/xml/keys_pcqwerty_symbols2.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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+2022: "•" BULLET --> - <Key - latin:keyLabel="•" - latin:moreKeys="!text/more_keys_for_bullet" /> - <!-- U+00B1: "±" PLUS-MINUS SIGN --> - <Key - latin:keyLabel="±" /> - <!-- U+00AC: "¬" NOT SIGN --> - <Key - latin:keyLabel="¬" /> - <!-- U+00A6: "¦" BROKEN BAR --> - <Key - latin:keyLabel="¦" /> - <!-- U+221A: "√" SQUARE ROOT --> - <Key - latin:keyLabel="√" /> - <!-- U+03C0: "π" GREEK SMALL LETTER PI - U+03A0: "Π" GREEK CAPITAL LETTER PI --> - <Key - latin:keyLabel="π" - latin:moreKeys="Π" /> - <!-- U+03CC: "σ" GREEK SMALL LETTER SIGMA - U+03A3: "Σ" GREEK CAPITAL LETTER SIGMA --> - <Key - latin:keyLabel="σ" - latin:moreKeys="Σ" /> - <!-- U+00B5: "µ" MICRO SIGN --> - <Key - latin:keyLabel="µ" /> - <!-- U+00F7: "÷" DIVISION SIGN --> - <Key - latin:keyLabel="÷" /> - <!-- U+00D7: "×" MULTIPLICATION SIGN --> - <Key - latin:keyLabel="×" /> -</merge> diff --git a/java/res/xml/keys_pcqwerty_symbols3.xml b/java/res/xml/keys_pcqwerty_symbols3.xml deleted file mode 100644 index 35279deaf..000000000 --- a/java/res/xml/keys_pcqwerty_symbols3.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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+00A3: "£" POUND SIGN; --> - <Key - latin:keyLabel="£" /> - <!-- U+00A2: "¢" CENT SIGN --> - <Key - latin:keyLabel="¢" /> - <!-- U+20AC: "€" EURO SIGN --> - <Key - latin:keyLabel="€" /> - <!-- U+00A5: "¥" YEN SIGN --> - <Key - latin:keyLabel="¥" /> - <!-- U+00A4: "¤" CURRENCY SIGN --> - <Key - latin:keyLabel="¤" /> - <!-- U+00B0: "°" DEGREE SIGN - U+2032: "′" PRIME - U+2033: "″" DOUBLE PRIME --> - <Key - latin:keyLabel="°" - latin:moreKeys="′,″" /> - <!-- U+2260: "≠" NOT EQUAL TO --> - <Key - latin:keyLabel="≠" /> - <!-- U+2248: "≈" ALMOST EQUAL TO --> - <Key - latin:keyLabel="≈" /> - <!-- U+221E: "∞" INFINITY --> - <Key - latin:keyLabel="∞" /> -</merge> diff --git a/java/res/xml/keys_pcqwerty_symbols4.xml b/java/res/xml/keys_pcqwerty_symbols4.xml deleted file mode 100644 index 3c628f0e0..000000000 --- a/java/res/xml/keys_pcqwerty_symbols4.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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+2122: "™" TRADE MARK SIGN --> - <Key - latin:keyLabel="™" /> - <!-- U+00AE: "®" REGISTERED SIGN --> - <Key - latin:keyLabel="®" /> - <!-- U+00A9: "©" COPYRIGHT SIGN --> - <Key - latin:keyLabel="©" /> - <!-- U+00B6: "¶" PILCROW SIGN --> - <Key - latin:keyLabel="¶" /> - <!-- U+00A7: "§" SECTION SIGN --> - <Key - latin:keyLabel="§" /> - <!-- U+2191: "↑" UPWARDS ARROW - U+2193: "↓" DOWNWARDS ARROW - U+2190: "←" LEFTWARDS ARROW - U+2192: "→" RIGHTWARDS ARROW --> - <Key - latin:keyLabel="↑" - latin:moreKeys="↓" /> - <Key - latin:keyLabel="←" - latin:moreKeys="→" /> -</merge> diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 52d715a7a..2c3ac57ed 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -24,7 +24,7 @@ keyboard_locale: script_name/keyboard_layout_set af: Afrikaans/qwerty ar: Arabic/arabic - (az: Azerbaijani/qwerty) # disabled temporarily. waiting for strnig resources. + az: Azerbaijani/qwerty be: Belarusian/east_slavic bg: Bulgarian/bulgarian bg: Bulgarian/bulgarian_bds @@ -117,7 +117,6 @@ android:imeSubtypeMode="keyboard" android:imeSubtypeExtraValue="SupportTouchPositionCorrection" /> - <!-- <subtype android:icon="@drawable/ic_subtype_keyboard" android:label="@string/subtype_generic" android:subtypeId="0x70b0f974" @@ -125,7 +124,6 @@ android:imeSubtypeMode="keyboard" android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable" /> - --> <subtype android:icon="@drawable/ic_subtype_keyboard" android:label="@string/subtype_generic" android:subtypeId="0x1dc3a859" diff --git a/java/res/xml/row_pcqwerty5.xml b/java/res/xml/row_pcqwerty5.xml index a8940af6e..0e618059e 100644 --- a/java/res/xml/row_pcqwerty5.xml +++ b/java/res/xml/row_pcqwerty5.xml @@ -24,36 +24,23 @@ <Row latin:keyWidth="7.692%p" > - <switch> - <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyWidth="11.538%p" /> - </case> - <!-- keyboardLayoutSetElement="alphabet*" --> - <default> - <Key - latin:keyStyle="toSymbolKeyStyle" - latin:keyIcon="!icon/undefined" - latin:keyLabel="!text/label_to_symbol_key_pcqwerty" - latin:keyWidth="11.538%p" /> - </default> - </switch> + <Spacer + latin:keyWidth="11.538%p" /> <switch> <case latin:shortcutKeyEnabled="true" > <Key - latin:keyStyle="shortcutKeyStyle" /> - </case> + latin:keyStyle="shortcutKeyStyle" + latin:keyWidth="11.538%p" /> + </case> <case latin:clobberSettingsKey="false" > <Key - latin:keyStyle="settingsKeyStyle" /> - </case> + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="11.538%p" /> + </case> </switch> <switch> <case @@ -61,21 +48,33 @@ > <Key latin:keyStyle="languageSwitchKeyStyle" - latin:keyXPos="19.230%p" /> + latin:keyWidth="11.538%p" /> <Key latin:keyStyle="spaceKeyStyle" - latin:keyWidth="53.844%p" /> - </case> + latin:keyWidth="42.310%p" /> + </case> <!-- languageSwitchKeyEnabled="false" --> <default> <Key latin:keyStyle="spaceKeyStyle" - latin:keyXPos="19.230%p" - latin:keyWidth="61.536%p" /> + latin:keyWidth="53.848%p" /> </default> </switch> <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> + latin:keyStyle="defaultEnterKeyStyle" + latin:keyWidth="15.384%p" /> + <switch> + <case + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" + > + <Spacer /> + </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> + <default> + <include + latin:keyboardLayout="@xml/key_symbols_period" + latin:backgroundType="functional" /> + </default> + </switch> </Row> </merge> diff --git a/java/res/xml/row_symbols4.xml b/java/res/xml/row_symbols4.xml index 150ad486c..5c15da6a5 100644 --- a/java/res/xml/row_symbols4.xml +++ b/java/res/xml/row_symbols4.xml @@ -46,8 +46,9 @@ <include latin:keyXPos="25%p" latin:keyboardLayout="@xml/key_space" /> - <Key - latin:keyStyle="punctuationKeyStyle" /> + <include + latin:keyboardLayout="@xml/key_symbols_period" + latin:backgroundType="functional" /> <Key latin:keyStyle="enterKeyStyle" latin:keyWidth="fillRight" /> diff --git a/java/res/xml/row_symbols_shift4.xml b/java/res/xml/row_symbols_shift4.xml deleted file mode 100644 index 99a685c45..000000000 --- a/java/res/xml/row_symbols_shift4.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Row - latin:keyWidth="10%p" - > - <Key - latin:keyStyle="toAlphaKeyStyle" - latin:keyWidth="15%p" /> - <!-- U+201A: "‚" SINGLE LOW-9 QUOTATION MARK - U+201E: "„" DOUBLE LOW-9 QUOTATION MARK --> - <Key - latin:keyLabel="„" - latin:moreKeys="‚" - latin:backgroundType="functional" /> - <include - latin:keyXPos="25%p" - latin:keyboardLayout="@xml/key_space" /> - <!-- U+2026: "…" HORIZONTAL ELLIPSIS --> - <Key - latin:keyLabel="…" - latin:backgroundType="functional" /> - <Key - latin:keyStyle="enterKeyStyle" - latin:keyWidth="fillRight" /> - </Row> -</merge> diff --git a/java/res/xml/rowkeys_pcqwerty1.xml b/java/res/xml/rowkeys_pcqwerty1.xml index b2d1d374b..de548d0ba 100644 --- a/java/res/xml/rowkeys_pcqwerty1.xml +++ b/java/res/xml/rowkeys_pcqwerty1.xml @@ -21,67 +21,61 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <switch> - <case - latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" - > - <!-- U+00AC: "¬" NOT SIGN --> - <Key - latin:keyLabel="`" - latin:moreKeys="~" - latin:additionalMoreKeys="¬" /> - <!-- U+00A1: "¡" NVERTED EXCLAMATION MARK --> - <Key - latin:keyLabel="1" - latin:additionalMoreKeys="!" - latin:moreKeys="¡,!text/more_keys_for_symbols_1" /> - <Key - latin:keyLabel="2" - latin:additionalMoreKeys="\@" - latin:moreKeys="!text/more_keys_for_symbols_2" /> - <Key - latin:keyLabel="3" - latin:additionalMoreKeys="\#" - latin:moreKeys="!text/more_keys_for_symbols_3" /> - <Key - latin:keyLabel="4" - latin:additionalMoreKeys="$" - latin:moreKeys="!text/more_keys_for_symbols_4" /> - <Key - latin:keyLabel="5" - latin:additionalMoreKeys="\\%" - latin:moreKeys="!text/more_keys_for_symbols_5" /> - <Key - latin:keyLabel="6" - latin:additionalMoreKeys="^" - latin:moreKeys="!text/more_keys_for_symbols_6" /> - <Key - latin:keyLabel="7" - latin:additionalMoreKeys="&" - latin:moreKeys="!text/more_keys_for_symbols_7" /> - <Key - latin:keyLabel="8" - latin:additionalMoreKeys="*,%" - latin:moreKeys="!text/more_keys_for_symbols_8" /> - <Key - latin:keyLabel="9" - latin:additionalMoreKeys="(" - latin:moreKeys="!text/more_keys_for_symbols_9" /> - <Key - latin:keyLabel="0" - latin:additionalMoreKeys=")" - latin:moreKeys="!text/more_keys_for_symbols_0" /> - <Key - latin:keyLabel="-" - latin:moreKeys="_" /> - <Key - latin:keyLabel="=" - latin:moreKeys="+" /> - </case> - <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols*" --> - <default> - <include - latin:keyboardLayout="@xml/keys_pcqwerty_symbols1" /> - </default> - </switch> + <Key + latin:keyLabel="`" + latin:additionalMoreKeys="~" /> + <Key + latin:keyLabel="1" + latin:additionalMoreKeys="!,!text/more_keys_for_symbols_exclamation" + latin:moreKeys="!text/more_keys_for_symbols_1" /> + <Key + latin:keyLabel="2" + latin:additionalMoreKeys="\@" + latin:moreKeys="!text/more_keys_for_symbols_2" /> + <Key + latin:keyLabel="3" + latin:additionalMoreKeys="\#" + latin:moreKeys="!text/more_keys_for_symbols_3" /> + <Key + latin:keyLabel="4" + latin:additionalMoreKeys="$" + latin:moreKeys="!text/more_keys_for_symbols_4" /> + <Key + latin:keyLabel="5" + latin:additionalMoreKeys="\\%" + latin:moreKeys="!text/more_keys_for_symbols_5" /> + <Key + latin:keyLabel="6" + latin:additionalMoreKeys="^" + latin:moreKeys="!text/more_keys_for_symbols_6" /> + <Key + latin:keyLabel="7" + latin:additionalMoreKeys="&" + latin:moreKeys="!text/more_keys_for_symbols_7" /> + <Key + latin:keyLabel="8" + latin:additionalMoreKeys="*" + latin:moreKeys="!text/more_keys_for_symbols_8" /> + <Key + latin:keyLabel="9" + latin:additionalMoreKeys="(" + latin:moreKeys="!text/more_keys_for_symbols_9" /> + <Key + latin:keyLabel="0" + latin:additionalMoreKeys=")" + latin:moreKeys="!text/more_keys_for_symbols_0" /> + <!-- U+2013: "–" EN DASH + U+2014: "—" EM DASH + U+00B7: "·" MIDDLE DOT --> + <Key + latin:keyLabel="-" + latin:additionalMoreKeys="_" + latin:moreKeys="–,—,·" /> + <!-- U+221E: "∞" INFINITY + U+2260: "≠" NOT EQUAL TO + U+2248: "≈" ALMOST EQUAL TO --> + <Key + latin:keyLabel="=" + latin:additionalMoreKeys="+" + latin:moreKeys="!fixedColumnOrder!4,∞,≠,≈,%" /> </merge> diff --git a/java/res/xml/keys_pcqwerty_symbols1.xml b/java/res/xml/rowkeys_pcqwerty1_shift.xml index 2364e1087..bc39f944e 100644 --- a/java/res/xml/keys_pcqwerty_symbols1.xml +++ b/java/res/xml/rowkeys_pcqwerty1_shift.xml @@ -21,37 +21,40 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <!-- U+00AC: "¬" NOT SIGN --> <Key - latin:keyLabel="~" - latin:moreKeys="¬" /> - <!-- U+00A1: "¡" NVERTED EXCLAMATION MARK --> + latin:keyLabel="~" /> <Key latin:keyLabel="!" - latin:moreKeys="¡" /> + latin:additionalMoreKeys="!text/more_keys_for_symbols_exclamation" /> <Key latin:keyLabel="\@" /> <Key latin:keyLabel="\#" /> <Key - latin:keyLabel="$" /> - <!-- U+2030: "‰" PER MILLE SIGN --> + latin:keyLabel="$" + latin:additionalMoreKeys="!text/more_keys_for_currency_dollar" /> <Key latin:keyLabel="%" - latin:moreKeys="‰" /> + latin:additionalMoreKeys="!text/more_keys_for_symbols_percent" /> <Key latin:keyLabel="^" /> <Key latin:keyLabel="&" /> <Key latin:keyLabel="*" - latin:moreKeys="!text/more_keys_for_star" /> + latin:additionalMoreKeys="!text/more_keys_for_star" /> <Key latin:keyLabel="(" /> <Key latin:keyLabel=")" /> <Key latin:keyLabel="_" /> - <Key - latin:keyLabel="+" /> + <!-- U+00B1: "±" PLUS-MINUS SIGN + U+00D7: "×" MULTIPLICATION SIGN + U+00F7: "÷" DIVISION SIGN + U+221A: "√" SQUARE ROOT --> + <Key + latin:keyLabel="+" + latin:additionalMoreKeys="!text/more_keys_for_plus" + latin:moreKeys="±,×,÷,√" /> </merge> diff --git a/java/res/xml/rowkeys_pcqwerty2.xml b/java/res/xml/rowkeys_pcqwerty2.xml index cedf47559..8db704d71 100644 --- a/java/res/xml/rowkeys_pcqwerty2.xml +++ b/java/res/xml/rowkeys_pcqwerty2.xml @@ -21,21 +21,11 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <switch> - <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" - > - <include - latin:keyboardLayout="@xml/keys_pcqwerty_symbols2" /> - </case> - <default> - <!-- The keys on this PC layout row2 consist of the letters of QWERTY layout row1 and - some symbols keys. --> - <include - latin:keyboardLayout="@xml/rowkeys_qwerty1" - latin:keyLabelFlags="disableAdditionalMoreKeys|disableKeyHintLabel" /> - </default> - </switch> + <!-- The keys on this PC layout row2 consist of the letters of QWERTY layout row1 and + some symbols keys. --> + <include + latin:keyboardLayout="@xml/rowkeys_qwerty1" + latin:keyLabelFlags="disableAdditionalMoreKeys|disableKeyHintLabel" /> <include latin:keyboardLayout="@xml/keys_pcqwerty2_right3" /> </merge> diff --git a/java/res/xml/rowkeys_pcqwerty3.xml b/java/res/xml/rowkeys_pcqwerty3.xml index 5044e5feb..ad122d30c 100644 --- a/java/res/xml/rowkeys_pcqwerty3.xml +++ b/java/res/xml/rowkeys_pcqwerty3.xml @@ -21,20 +21,10 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <switch> - <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" - > - <include - latin:keyboardLayout="@xml/keys_pcqwerty_symbols3" /> - </case> - <default> - <!-- The keys on this PC layout row3 consist of the letters of QWERTY layout row2 and - some symbols keys. --> - <include - latin:keyboardLayout="@xml/rowkeys_qwerty2" /> - </default> - </switch> + <!-- The keys on this PC layout row3 consist of the letters of QWERTY layout row2 and + some symbols keys. --> + <include + latin:keyboardLayout="@xml/rowkeys_qwerty2" /> <include latin:keyboardLayout="@xml/keys_pcqwerty3_right2" /> </merge> diff --git a/java/res/xml/rowkeys_pcqwerty4.xml b/java/res/xml/rowkeys_pcqwerty4.xml index 4071e8c09..b558f4142 100644 --- a/java/res/xml/rowkeys_pcqwerty4.xml +++ b/java/res/xml/rowkeys_pcqwerty4.xml @@ -21,20 +21,10 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <switch> - <case - latin:keyboardLayoutSetElement="symbols|symbolsShifted" - > - <include - latin:keyboardLayout="@xml/keys_pcqwerty_symbols4" /> - </case> - <default> - <!-- The keys on this PC layout row4 consist of the letters of QWERTY layout row3 and - some symbols keys. --> - <include - latin:keyboardLayout="@xml/rowkeys_qwerty3" /> - </default> - </switch> + <!-- The keys on this PC layout row4 consist of the letters of QWERTY layout row3 and + some symbols keys. --> + <include + latin:keyboardLayout="@xml/rowkeys_qwerty3" /> <include latin:keyboardLayout="@xml/keys_pcqwerty4_right3" /> </merge> diff --git a/java/res/xml/rowkeys_symbols2.xml b/java/res/xml/rowkeys_symbols2.xml index 3e27f1579..9d629f1c8 100644 --- a/java/res/xml/rowkeys_symbols2.xml +++ b/java/res/xml/rowkeys_symbols2.xml @@ -43,8 +43,12 @@ latin:keyLabel="\#" /> </default> </switch> - <Key - latin:keyStyle="currencyKeyStyle" /> + <!-- TODO: Remove key_currency.xml and uncomment the following definition. --> +<!-- <Key --> +<!-- latin:keyLabel="!text/keylabel_for_currency" --> +<!-- latin:moreKeys="!text/more_keys_for_currency" /> --> + <include + latin:keyboardLayout="@xml/key_currency" /> <Key latin:keyLabel="!text/keylabel_for_symbols_percent" latin:moreKeys="!text/more_keys_for_symbols_percent" /> @@ -53,15 +57,27 @@ <Key latin:keyLabel="*" latin:moreKeys="!text/more_keys_for_star" /> - <!-- U+2013: "–" EN DASH - U+2014: "—" EM DASH - U+00B7: "·" MIDDLE DOT --> + <!-- U+00B1: "±" PLUS-MINUS SIGN + U+00D7: "×" MULTIPLICATION SIGN + U+00F7: "÷" DIVISION SIGN + U+221A: "√" SQUARE ROOT --> + <Key + latin:keyLabel="+" + latin:moreKeys="!text/more_keys_for_plus,±,×,÷,√" /> + <!-- U+221E: "∞" INFINITY + U+2264: "≤" LESS-THAN OR EQUAL TO + U+2265: "≥" GREATER-THAN EQUAL TO + U+2260: "≠" NOT EQUAL TO + U+2248: "≈" ALMOST EQUAL TO --> <Key - latin:keyLabel="-" - latin:moreKeys="_,–,—,·" /> + latin:keyLabel="=" + latin:moreKeys="!fixedColumnOrder!5,∞,≤,≥,≠,≈" /> <Key - latin:keyLabel="+" - latin:moreKeys="!text/more_keys_for_plus" /> - <include - latin:keyboardLayout="@xml/keys_parentheses" /> + latin:keyLabel="(" + latin:code="!code/key_left_parenthesis" + latin:moreKeys="!text/more_keys_for_left_parenthesis" /> + <Key + latin:keyLabel=")" + latin:code="!code/key_right_parenthesis" + latin:moreKeys="!text/more_keys_for_right_parenthesis" /> </merge> diff --git a/java/res/xml/rowkeys_symbols3.xml b/java/res/xml/rowkeys_symbols3.xml index 7722ca9ae..9e9dfd8bd 100644 --- a/java/res/xml/rowkeys_symbols3.xml +++ b/java/res/xml/rowkeys_symbols3.xml @@ -24,6 +24,9 @@ <Key latin:keyLabel="!" latin:moreKeys="!text/more_keys_for_symbols_exclamation" /> + <Key + latin:keyLabel="!text/keylabel_for_symbols_question" + latin:moreKeys="!text/more_keys_for_symbols_question" /> <switch> <case latin:languageCode="fa" @@ -33,11 +36,11 @@ <Key latin:keyLabel="«" latin:code="0x00BB" - latin:moreKeys="!text/more_keys_for_double_quote" /> + latin:moreKeys="!fixedColumnOrder!6,!text/more_keys_for_double_quote,"" /> <Key latin:keyLabel="»" latin:code="0x00AB" - latin:moreKeys="!text/more_keys_for_single_quote" /> + latin:moreKeys="!fixedColumnOrder!6,!text/more_keys_for_single_quote,\'" /> </case> <default> <Key @@ -48,14 +51,18 @@ latin:moreKeys="!text/more_keys_for_single_quote" /> </default> </switch> + <!-- U+2013: "–" EN DASH + U+2014: "—" EM DASH + U+00B7: "·" MIDDLE DOT --> + <Key + latin:keyLabel="-" + latin:moreKeys="_,~,–,—,·" /> <Key latin:keyLabel=":" /> <Key latin:keyLabel="!text/keylabel_for_symbols_semicolon" latin:moreKeys="!text/more_keys_for_symbols_semicolon" /> <Key - latin:keyLabel="/" /> - <Key - latin:keyLabel="!text/keylabel_for_symbols_question" - latin:moreKeys="!text/more_keys_for_symbols_question" /> + latin:keyLabel="/" + latin:moreKeys="\\|,\\\\,^" /> </merge> diff --git a/java/res/xml/rowkeys_symbols_shift1.xml b/java/res/xml/rowkeys_symbols_shift1.xml deleted file mode 100644 index fea8ae337..000000000 --- a/java/res/xml/rowkeys_symbols_shift1.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Key - latin:keyLabel="~" /> - <Key - latin:keyLabel="`" /> - <Key - latin:keyLabel="|" /> - <!-- U+2022: "•" BULLET --> - <Key - latin:keyLabel="•" - latin:moreKeys="!text/more_keys_for_bullet" /> - <!-- U+221A: "√" SQUARE ROOT --> - <Key - latin:keyLabel="√" /> - <!-- U+03C0: "π" GREEK SMALL LETTER PI - U+03A0: "Π" GREEK CAPITAL LETTER PI --> - <Key - latin:keyLabel="π" - latin:moreKeys="Π" /> - <!-- U+00F7: "÷" DIVISION SIGN --> - <Key - latin:keyLabel="÷" /> - <!-- U+00D7: "×" MULTIPLICATION SIGN --> - <Key - latin:keyLabel="×" /> - <include - latin:keyboardLayout="@xml/keys_curly_brackets" /> -</merge> diff --git a/java/res/xml/rowkeys_symbols_shift2.xml b/java/res/xml/rowkeys_symbols_shift2.xml deleted file mode 100644 index 3fd8aacb6..000000000 --- a/java/res/xml/rowkeys_symbols_shift2.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <Key - latin:keyStyle="nonSpecialBackgroundTabKeyStyle" /> - <Key - latin:keyStyle="moreCurrency1KeyStyle" /> - <Key - latin:keyStyle="moreCurrency2KeyStyle" /> - <Key - latin:keyStyle="moreCurrency3KeyStyle" /> - <!-- U+00B0: "°" DEGREE SIGN - U+2032: "′" PRIME - U+2033: "″" DOUBLE PRIME --> - <Key - latin:keyLabel="°" - latin:moreKeys="′,″" /> - <!-- U+2191: "↑" UPWARDS ARROW - U+2193: "↓" DOWNWARDS ARROW - U+2190: "←" LEFTWARDS ARROW - U+2192: "→" RIGHTWARDS ARROW --> - <Key - latin:keyLabel="^" - latin:moreKeys="↑,↓,←,→" /> - <Key - latin:keyLabel="_" /> - <!-- U+2260: "≠" NOT EQUAL TO - U+2248: "≈" ALMOST EQUAL TO - U+221E: "∞" INFINITY --> - <Key - latin:keyLabel="=" - latin:moreKeys="≠,≈,∞" /> - <include - latin:keyboardLayout="@xml/keys_square_brackets" /> -</merge> diff --git a/java/res/xml/rowkeys_symbols_shift3.xml b/java/res/xml/rowkeys_symbols_shift3.xml deleted file mode 100644 index a35af218f..000000000 --- a/java/res/xml/rowkeys_symbols_shift3.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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+2122: "™" TRADE MARK SIGN --> - <Key - latin:keyLabel="™" /> - <!-- U+00AE: "®" REGISTERED SIGN --> - <Key - latin:keyLabel="®" /> - <!-- U+00A9: "©" COPYRIGHT SIGN --> - <Key - latin:keyLabel="©" /> - <!-- U+00B6: "¶" PILCROW SIGN - U+00A7: "§" SECTION SIGN --> - <Key - latin:keyLabel="¶" - latin:moreKeys="§" /> - <Key - latin:keyLabel="\\" /> - <include - latin:keyboardLayout="@xml/keys_less_greater" /> -</merge> diff --git a/java/res/xml/rows_pcqwerty.xml b/java/res/xml/rows_pcqwerty.xml index a5ed74518..884698963 100644 --- a/java/res/xml/rows_pcqwerty.xml +++ b/java/res/xml/rows_pcqwerty.xml @@ -26,8 +26,19 @@ <Row latin:keyWidth="7.692%p" > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> + <switch> + <case + latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted" + > + <include + latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> + </case> + <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" --> + <default> + <include + latin:keyboardLayout="@xml/rowkeys_pcqwerty1_shift" /> + </default> + </switch> </Row> <Row latin:keyWidth="7.692%p" diff --git a/java/res/xml/rows_pcqwerty_symbols.xml b/java/res/xml/rows_pcqwerty_symbols.xml deleted file mode 100644 index 107a4ad1f..000000000 --- a/java/res/xml/rows_pcqwerty_symbols.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2012, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="7.692%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty1" /> - </Row> - <Row - latin:keyWidth="7.692%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty2" /> - </Row> - <Row - latin:keyWidth="7.692%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty3" - latin:keyXPos="3.846%p" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" - latin:visualInsetsLeft="1%p" /> - </Row> - <Row - latin:keyWidth="7.692%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_pcqwerty4" - latin:keyXPos="11.538%p" /> - </Row> - <include - latin:keyboardLayout="@xml/row_pcqwerty5" /> -</merge> diff --git a/java/res/xml/rows_symbols.xml b/java/res/xml/rows_symbols.xml index bd1a57e75..27010cbd6 100644 --- a/java/res/xml/rows_symbols.xml +++ b/java/res/xml/rows_symbols.xml @@ -23,8 +23,6 @@ > <include latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> <Row latin:keyWidth="10%p" > @@ -40,11 +38,8 @@ <Row latin:keyWidth="10%p" > - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="15%p" - latin:visualInsetsRight="1%p" /> <include + latin:keyXPos="5%p" latin:keyboardLayout="@xml/rowkeys_symbols3" /> <Key latin:keyStyle="deleteKeyStyle" diff --git a/java/res/xml/rows_symbols_shift.xml b/java/res/xml/rows_symbols_shift.xml deleted file mode 100644 index 9c03d90b5..000000000 --- a/java/res/xml/rows_symbols_shift.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 2008, 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" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_currency" /> - <Row - latin:keyWidth="10%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift1" /> - </Row> - <Row - latin:keyWidth="10%p" - > - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift2" /> - </Row> - <Row - latin:keyWidth="10%p" - > - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="15%p" - latin:visualInsetsRight="1%p" /> - <include - latin:keyboardLayout="@xml/rowkeys_symbols_shift3" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyWidth="fillRight" - latin:visualInsetsLeft="1%p" /> - </Row> - <include - latin:keyboardLayout="@xml/row_symbols_shift4" /> -</merge> diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java index 8ce126330..7639432aa 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java @@ -157,7 +157,7 @@ public final class AccessibilityEntityProvider extends AccessibilityNodeProvider // Add the virtual children of the root View. final Keyboard keyboard = mKeyboardView.getKeyboard(); - final Key[] keys = keyboard.mKeys; + final Key[] keys = keyboard.getKeys(); for (Key key : keys) { final int childVirtualViewId = generateVirtualViewIdForKey(key); rootInfo.addChild(mKeyboardView, childVirtualViewId); @@ -300,7 +300,7 @@ public final class AccessibilityEntityProvider extends AccessibilityNodeProvider } mVirtualViewIdToKey.clear(); - final Key[] keys = keyboard.mKeys; + final Key[] keys = keyboard.getKeys(); for (Key key : keys) { final int virtualViewId = generateVirtualViewIdForKey(key); mVirtualViewIdToKey.put(virtualViewId, key); diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index 73896dfd3..b3bb767af 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -357,7 +357,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp break; case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED: - case KeyboardId.ELEMENT_SYMBOLS_SHIFTED: text = context.getText(R.string.spoken_description_shiftmode_on); break; default: @@ -389,7 +388,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp resId = R.string.spoken_description_mode_alpha; break; case KeyboardId.ELEMENT_SYMBOLS: - case KeyboardId.ELEMENT_SYMBOLS_SHIFTED: resId = R.string.spoken_description_mode_symbol; break; case KeyboardId.ELEMENT_PHONE: diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 58624a2e6..085ca93d5 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -156,7 +156,6 @@ public final class KeyCodeDescriptionMapper { resId = R.string.spoken_description_to_symbol; break; case KeyboardId.ELEMENT_SYMBOLS: - case KeyboardId.ELEMENT_SYMBOLS_SHIFTED: resId = R.string.spoken_description_to_alpha; break; case KeyboardId.ELEMENT_PHONE: @@ -191,7 +190,6 @@ public final class KeyCodeDescriptionMapper { break; case KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED: - case KeyboardId.ELEMENT_SYMBOLS_SHIFTED: resId = R.string.spoken_description_shift_shifted; break; default: diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index c40ddeabe..23f037fbd 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -51,6 +51,11 @@ public class Keyboard { /** Total width of the keyboard, including the padding and keys */ public final int mOccupiedWidth; + /** Base height of the keyboard, used to calculate rows' height */ + public final int mBaseHeight; + /** Base width of the keyboard, used to calculate keys' width */ + public final int mBaseWidth; + /** The padding above the keyboard */ public final int mTopPadding; /** Default gap between rows */ @@ -69,7 +74,7 @@ public class Keyboard { public final int mMaxMoreKeysKeyboardColumn; /** Array of keys and icons in this keyboard */ - public final Key[] mKeys; + private final Key[] mKeys; public final Key[] mShiftKeys; public final Key[] mAltCodeKeysWhileTyping; public final KeyboardIconsSet mIconsSet; @@ -84,6 +89,8 @@ public class Keyboard { mThemeId = params.mThemeId; mOccupiedHeight = params.mOccupiedHeight; mOccupiedWidth = params.mOccupiedWidth; + mBaseHeight = params.mBaseHeight; + mBaseWidth = params.mBaseWidth; mMostCommonKeyHeight = params.mMostCommonKeyHeight; mMostCommonKeyWidth = params.mMostCommonKeyWidth; mMoreKeysTemplate = params.mMoreKeysTemplate; @@ -104,6 +111,30 @@ public class Keyboard { mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled; } + protected Keyboard(final Keyboard keyboard) { + mId = keyboard.mId; + mThemeId = keyboard.mThemeId; + mOccupiedHeight = keyboard.mOccupiedHeight; + mOccupiedWidth = keyboard.mOccupiedWidth; + mBaseHeight = keyboard.mBaseHeight; + mBaseWidth = keyboard.mBaseWidth; + mMostCommonKeyHeight = keyboard.mMostCommonKeyHeight; + mMostCommonKeyWidth = keyboard.mMostCommonKeyWidth; + mMoreKeysTemplate = keyboard.mMoreKeysTemplate; + mMaxMoreKeysKeyboardColumn = keyboard.mMaxMoreKeysKeyboardColumn; + mKeyVisualAttributes = keyboard.mKeyVisualAttributes; + mTopPadding = keyboard.mTopPadding; + mVerticalGap = keyboard.mVerticalGap; + + mKeys = keyboard.mKeys; + mShiftKeys = keyboard.mShiftKeys; + mAltCodeKeysWhileTyping = keyboard.mAltCodeKeysWhileTyping; + mIconsSet = keyboard.mIconsSet; + + mProximityInfo = keyboard.mProximityInfo; + mProximityCharsCorrectionEnabled = keyboard.mProximityCharsCorrectionEnabled; + } + public boolean hasProximityCharsCorrection(final int code) { if (!mProximityCharsCorrectionEnabled) { return false; @@ -120,6 +151,10 @@ public class Keyboard { return mProximityInfo; } + public Key[] getKeys() { + return mKeys; + } + public Key getKey(final int code) { if (code == Constants.CODE_UNSPECIFIED) { return null; @@ -130,7 +165,7 @@ public class Keyboard { return mKeyCache.valueAt(index); } - for (final Key key : mKeys) { + for (final Key key : getKeys()) { if (key.getCode() == code) { mKeyCache.put(code, key); return key; @@ -146,7 +181,7 @@ public class Keyboard { return true; } - for (final Key key : mKeys) { + for (final Key key : getKeys()) { if (key == aKey) { mKeyCache.put(key.getCode(), key); return true; diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 1dc3c6a4c..53748bb58 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -50,10 +50,16 @@ public final class KeyboardId { public static final int ELEMENT_ALPHABET_SHIFT_LOCKED = 3; public static final int ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED = 4; public static final int ELEMENT_SYMBOLS = 5; - public static final int ELEMENT_SYMBOLS_SHIFTED = 6; public static final int ELEMENT_PHONE = 7; public static final int ELEMENT_PHONE_SYMBOLS = 8; public static final int ELEMENT_NUMBER = 9; + public static final int ELEMENT_EMOJI_RECENTS = 10; + public static final int ELEMENT_EMOJI_CATEGORY1 = 11; + public static final int ELEMENT_EMOJI_CATEGORY2 = 12; + public static final int ELEMENT_EMOJI_CATEGORY3 = 13; + public static final int ELEMENT_EMOJI_CATEGORY4 = 14; + public static final int ELEMENT_EMOJI_CATEGORY5 = 15; + public static final int ELEMENT_EMOJI_CATEGORY6 = 16; public final InputMethodSubtype mSubtype; public final Locale mLocale; @@ -213,10 +219,16 @@ public final class KeyboardId { case ELEMENT_ALPHABET_SHIFT_LOCKED: return "alphabetShiftLocked"; case ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED: return "alphabetShiftLockShifted"; case ELEMENT_SYMBOLS: return "symbols"; - case ELEMENT_SYMBOLS_SHIFTED: return "symbolsShifted"; case ELEMENT_PHONE: return "phone"; case ELEMENT_PHONE_SYMBOLS: return "phoneSymbols"; case ELEMENT_NUMBER: return "number"; + case ELEMENT_EMOJI_RECENTS: return "emojiRecents"; + case ELEMENT_EMOJI_CATEGORY1: return "emojiCategory1"; + case ELEMENT_EMOJI_CATEGORY2: return "emojiCategory2"; + case ELEMENT_EMOJI_CATEGORY3: return "emojiCategory3"; + case ELEMENT_EMOJI_CATEGORY4: return "emojiCategory4"; + case ELEMENT_EMOJI_CATEGORY5: return "emojiCategory5"; + case ELEMENT_EMOJI_CATEGORY6: return "emojiCategory6"; default: return null; } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 1ea0f8b96..098c8b3df 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -58,12 +58,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { } private static final KeyboardTheme[] KEYBOARD_THEMES = { - new KeyboardTheme(0, R.style.KeyboardTheme), - new KeyboardTheme(1, R.style.KeyboardTheme_HighContrast), - new KeyboardTheme(6, R.style.KeyboardTheme_Stone), - new KeyboardTheme(7, R.style.KeyboardTheme_Stone_Bold), - new KeyboardTheme(8, R.style.KeyboardTheme_Gingerbread), - new KeyboardTheme(5, R.style.KeyboardTheme_IceCreamSandwich), + new KeyboardTheme(0, R.style.KeyboardTheme_ICS), + new KeyboardTheme(1, R.style.KeyboardTheme_GB), }; private SubtypeSwitcher mSubtypeSwitcher; @@ -121,8 +117,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { } catch (NumberFormatException e) { // Format error, keyboard theme is default to 0. } - Log.w(TAG, "Illegal keyboard theme in preference: " + themeIndex + ", default to 0"); - return KEYBOARD_THEMES[0]; + Log.w(TAG, "Illegal keyboard theme in preference: " + themeIndex + ", default to " + + defaultIndex); + return KEYBOARD_THEMES[Integer.valueOf(defaultIndex)]; } private void setContextThemeWrapper(final Context context, final KeyboardTheme keyboardTheme) { @@ -258,12 +255,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { // Implements {@link KeyboardState.SwitchActions}. @Override - public void setSymbolsShiftedKeyboard() { - setKeyboard(mKeyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_SYMBOLS_SHIFTED)); - } - - // Implements {@link KeyboardState.SwitchActions}. - @Override public void requestUpdatingShiftState() { mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState(), mLatinIME.getCurrentRecapitalizeState()); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index d049a861e..0ef6802ca 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -285,7 +285,7 @@ public class KeyboardView extends View { // TODO: Confirm if it's really required to draw all keys when hardware acceleration is on. if (drawAllKeys || isHardwareAccelerated) { // Draw all keys. - for (final Key key : mKeyboard.mKeys) { + for (final Key key : mKeyboard.getKeys()) { onDrawKey(key, canvas, paint); } } else { diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java index a2001cb8f..6b76e2461 100644 --- a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java +++ b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java @@ -39,7 +39,7 @@ public final class MoreKeysDetector extends KeyDetector { Key nearestKey = null; int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare; - for (final Key key : getKeyboard().mKeys) { + for (final Key key : getKeyboard().getKeys()) { final int dist = key.squaredDistanceToEdge(touchX, touchY); if (dist < nearestDist) { nearestKey = key; diff --git a/java/src/com/android/inputmethod/keyboard/internal/CodesArrayParser.java b/java/src/com/android/inputmethod/keyboard/internal/CodesArrayParser.java new file mode 100644 index 000000000..c10fdbace --- /dev/null +++ b/java/src/com/android/inputmethod/keyboard/internal/CodesArrayParser.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.internal; + +import com.android.inputmethod.latin.Constants; + +/** + * The string parser of codesArray specification for <GridRows />. The attribute codesArray is an + * array of string. + * Each element of the array defines a key label by specifying a code point as a hexadecimal string. + * A key label may consist of multiple code points separated by comma. + * Each element of the array optionally can have an output text definition after vertical bar + * marker. An output text may consist of multiple code points separated by comma. + * The format of the codesArray element should be: + * <pre> + * codePointInHex[,codePoint2InHex]*(|outputTextCodePointInHex[,outputTextCodePoint2InHex]*)? + * </pre> + */ +// TODO: Write unit tests for this class. +public final class CodesArrayParser { + // Constants for parsing. + private static final char COMMA = ','; + private static final char VERTICAL_BAR = '|'; + private static final String COMMA_STRING = ","; + private static final int BASE_HEX = 16; + + private CodesArrayParser() { + // This utility class is not publicly instantiable. + } + + private static String getLabelSpec(final String codesArraySpec) { + final int pos = codesArraySpec.indexOf(VERTICAL_BAR); + return (pos < 0) ? codesArraySpec : codesArraySpec.substring(0, pos); + } + + public static String parseLabel(final String codesArraySpec) { + final String labelSpec = getLabelSpec(codesArraySpec); + final StringBuilder sb = new StringBuilder(); + for (final String codeInHex : labelSpec.split(COMMA_STRING)) { + final int codePoint = Integer.parseInt(codeInHex, BASE_HEX); + sb.appendCodePoint(codePoint); + } + return sb.toString(); + } + + private static String getCodeSpec(final String codesArraySpec) { + final int pos = codesArraySpec.indexOf(VERTICAL_BAR); + return (pos < 0) ? codesArraySpec : codesArraySpec.substring(pos + 1); + } + + public static int parseCode(final String codesArraySpec) { + final String codeSpec = getCodeSpec(codesArraySpec); + if (codeSpec.indexOf(COMMA) < 0) { + return Integer.parseInt(codeSpec, BASE_HEX); + } + return Constants.CODE_OUTPUT_TEXT; + } + + public static String parseOutputText(final String codesArraySpec) { + final String codeSpec = getCodeSpec(codesArraySpec); + if (codeSpec.indexOf(COMMA) < 0) { + return null; + } + final StringBuilder sb = new StringBuilder(); + for (final String codeInHex : codeSpec.split(COMMA_STRING)) { + final int codePoint = Integer.parseInt(codeInHex, BASE_HEX); + sb.appendCodePoint(codePoint); + } + return sb.toString(); + } +} diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java index 3f0773e15..8c70389ba 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java @@ -29,6 +29,7 @@ import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardId; +import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.RunInLocale; @@ -113,6 +114,7 @@ import java.util.Locale; * </pre> */ +// TODO: Write unit tests for this class. public class KeyboardBuilder<KP extends KeyboardParams> { private static final String BUILDER_TAG = "Keyboard.Builder"; private static final boolean DEBUG = false; @@ -120,6 +122,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> { // Keyboard XML Tags private static final String TAG_KEYBOARD = "Keyboard"; private static final String TAG_ROW = "Row"; + private static final String TAG_GRID_ROWS = "GridRows"; private static final String TAG_KEY = "Key"; private static final String TAG_SPACER = "Spacer"; private static final String TAG_INCLUDE = "include"; @@ -312,6 +315,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> { startRow(row); } parseRowContent(parser, row, skip); + } else if (TAG_GRID_ROWS.equals(tag)) { + if (DEBUG) startTag("<%s>%s", TAG_GRID_ROWS, skip ? " skipped" : ""); + parseGridRows(parser, skip); } else if (TAG_INCLUDE.equals(tag)) { parseIncludeKeyboardContent(parser, skip); } else if (TAG_SWITCH.equals(tag)) { @@ -389,6 +395,73 @@ public class KeyboardBuilder<KP extends KeyboardParams> { } } + private void parseGridRows(final XmlPullParser parser, final boolean skip) + throws XmlPullParserException, IOException { + if (skip) { + XmlParseUtils.checkEndTag(TAG_GRID_ROWS, parser); + if (DEBUG) { + startEndTag("<%s /> skipped", TAG_GRID_ROWS); + } + return; + } + final KeyboardRow gridRows = new KeyboardRow(mResources, mParams, parser, mCurrentY); + final TypedArray gridRowAttr = mResources.obtainAttributes( + Xml.asAttributeSet(parser), R.styleable.Keyboard_GridRows); + final int codesArrayId = gridRowAttr.getResourceId( + R.styleable.Keyboard_GridRows_codesArray, 0); + final int textsArrayId = gridRowAttr.getResourceId( + R.styleable.Keyboard_GridRows_textsArray, 0); + gridRowAttr.recycle(); + if (codesArrayId == 0 && textsArrayId == 0) { + throw new XmlParseUtils.ParseException( + "Missing codesArray or textsArray attributes", parser); + } + if (codesArrayId != 0 && textsArrayId != 0) { + throw new XmlParseUtils.ParseException( + "Both codesArray and textsArray attributes specifed", parser); + } + final String[] array = mResources.getStringArray( + codesArrayId != 0 ? codesArrayId : textsArrayId); + final int counts = array.length; + final float keyWidth = gridRows.getKeyWidth(null, 0.0f); + final int numColumns = (int)(mParams.mOccupiedWidth / keyWidth); + for (int index = 0; index < counts; index += numColumns) { + final KeyboardRow row = new KeyboardRow(mResources, mParams, parser, mCurrentY); + startRow(row); + for (int c = 0; c < numColumns; c++) { + final int i = index + c; + if (i >= counts) { + break; + } + final String label; + final int code; + final String outputText; + if (codesArrayId != 0) { + final String codeArraySpec = array[i]; + label = CodesArrayParser.parseLabel(codeArraySpec); + code = CodesArrayParser.parseCode(codeArraySpec); + outputText = CodesArrayParser.parseOutputText(codeArraySpec); + } else { + final String textArraySpec = array[i]; + // TODO: Utilize KeySpecParser or write more generic TextsArrayParser. + label = textArraySpec; + code = Constants.CODE_OUTPUT_TEXT; + outputText = textArraySpec + (char)Constants.CODE_SPACE; + } + final int x = (int)row.getKeyX(null); + final int y = row.getKeyY(); + final Key key = new Key(mParams, label, null /* hintLabel */, 0 /* iconId */, + code, outputText, x, y, (int)keyWidth, (int)row.getRowHeight(), + row.getDefaultKeyLabelFlags(), row.getDefaultBackgroundType()); + endKey(key); + row.advanceXPos(keyWidth); + } + endRow(row); + } + + XmlParseUtils.checkEndTag(TAG_GRID_ROWS, parser); + } + private void parseKey(final XmlPullParser parser, final KeyboardRow row, final boolean skip) throws XmlPullParserException, IOException { if (skip) { @@ -744,7 +817,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> { } private void endKeyboard() { - // nothing to do here. + // {@link #parseGridRows(XmlPullParser,boolean)} may populate keyboard rows higher than + // previously expected. + final int actualHeight = mCurrentY - mParams.mVerticalGap + mParams.mBottomPadding; + mParams.mOccupiedHeight = Math.max(mParams.mOccupiedHeight, actualHeight); } private void addEdgeSpace(final float width, final KeyboardRow row) { diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 164910dd4..0b10a1d1a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -46,7 +46,6 @@ public final class KeyboardState { public void setAlphabetShiftLockedKeyboard(); public void setAlphabetShiftLockShiftedKeyboard(); public void setSymbolsKeyboard(); - public void setSymbolsShiftedKeyboard(); /** * Request to call back {@link KeyboardState#onUpdateShiftState(int, int)}. @@ -64,21 +63,17 @@ public final class KeyboardState { private ModifierKeyState mSymbolKeyState = new ModifierKeyState("Symbol"); // TODO: Merge {@link #mSwitchState}, {@link #mIsAlphabetMode}, {@link #mAlphabetShiftState}, - // {@link #mIsSymbolShifted}, {@link #mPrevMainKeyboardWasShiftLocked}, and - // {@link #mPrevSymbolsKeyboardWasShifted} into single state variable. + // {@link #mPrevMainKeyboardWasShiftLocked} into single state variable. private static final int SWITCH_STATE_ALPHA = 0; private static final int SWITCH_STATE_SYMBOL_BEGIN = 1; private static final int SWITCH_STATE_SYMBOL = 2; private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 3; - private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 4; private static final int SWITCH_STATE_MOMENTARY_ALPHA_SHIFT = 5; private int mSwitchState = SWITCH_STATE_ALPHA; private boolean mIsAlphabetMode; private AlphabetShiftState mAlphabetShiftState = new AlphabetShiftState(); - private boolean mIsSymbolShifted; private boolean mPrevMainKeyboardWasShiftLocked; - private boolean mPrevSymbolsKeyboardWasShifted; private int mRecapitalizeMode; // For handling double tap. @@ -100,7 +95,7 @@ public final class KeyboardState { if (mIsAlphabetShiftLocked) return "ALPHABET_SHIFT_LOCKED"; return "ALPHABET_" + shiftModeToString(mShiftMode); } else { - return "SYMBOLS_" + shiftModeToString(mShiftMode); + return "SYMBOLS"; } } } @@ -117,7 +112,6 @@ public final class KeyboardState { // Reset alphabet shift state. mAlphabetShiftState.setShiftLocked(false); mPrevMainKeyboardWasShiftLocked = false; - mPrevSymbolsKeyboardWasShifted = false; mShiftKeyState.onRelease(); mSymbolKeyState.onRelease(); onRestoreKeyboardState(); @@ -137,7 +131,6 @@ public final class KeyboardState { : (mAlphabetShiftState.isShiftedOrShiftLocked() ? MANUAL_SHIFT : UNSHIFT); } else { state.mIsAlphabetShiftLocked = mPrevMainKeyboardWasShiftLocked; - state.mShiftMode = mIsSymbolShifted ? MANUAL_SHIFT : UNSHIFT; } state.mIsValid = true; if (DEBUG_EVENT) { @@ -153,11 +146,7 @@ public final class KeyboardState { if (!state.mIsValid || state.mIsAlphabetMode) { setAlphabetKeyboard(); } else { - if (state.mShiftMode == MANUAL_SHIFT) { - setSymbolsShiftedKeyboard(); - } else { - setSymbolsKeyboard(); - } + setSymbolsKeyboard(); } if (!state.mIsValid) return; @@ -233,14 +222,8 @@ public final class KeyboardState { } if (mIsAlphabetMode) { mPrevMainKeyboardWasShiftLocked = mAlphabetShiftState.isShiftLocked(); - if (mPrevSymbolsKeyboardWasShifted) { - setSymbolsShiftedKeyboard(); - } else { - setSymbolsKeyboard(); - } - mPrevSymbolsKeyboardWasShifted = false; + setSymbolsKeyboard(); } else { - mPrevSymbolsKeyboardWasShifted = mIsSymbolShifted; setAlphabetKeyboard(); if (mPrevMainKeyboardWasShiftLocked) { setShiftLocked(true); @@ -257,7 +240,6 @@ public final class KeyboardState { } if (mIsAlphabetMode) return; - mPrevSymbolsKeyboardWasShifted = mIsSymbolShifted; setAlphabetKeyboard(); if (mPrevMainKeyboardWasShiftLocked) { setShiftLocked(true); @@ -265,14 +247,6 @@ public final class KeyboardState { mPrevMainKeyboardWasShiftLocked = false; } - private void toggleShiftInSymbols() { - if (mIsSymbolShifted) { - setSymbolsKeyboard(); - } else { - setSymbolsShiftedKeyboard(); - } - } - private void setAlphabetKeyboard() { if (DEBUG_ACTION) { Log.d(TAG, "setAlphabetKeyboard"); @@ -280,7 +254,6 @@ public final class KeyboardState { mSwitchActions.setAlphabetKeyboard(); mIsAlphabetMode = true; - mIsSymbolShifted = false; mRecapitalizeMode = RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE; mSwitchState = SWITCH_STATE_ALPHA; mSwitchActions.requestUpdatingShiftState(); @@ -292,19 +265,6 @@ public final class KeyboardState { } mSwitchActions.setSymbolsKeyboard(); mIsAlphabetMode = false; - mIsSymbolShifted = false; - // Reset alphabet shift state. - mAlphabetShiftState.setShiftLocked(false); - mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; - } - - private void setSymbolsShiftedKeyboard() { - if (DEBUG_ACTION) { - Log.d(TAG, "setSymbolsShiftedKeyboard"); - } - mSwitchActions.setSymbolsShiftedKeyboard(); - mIsAlphabetMode = false; - mIsSymbolShifted = true; // Reset alphabet shift state. mAlphabetShiftState.setShiftLocked(false); mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; @@ -357,7 +317,7 @@ public final class KeyboardState { } else if (code == Constants.CODE_CAPSLOCK) { setShiftLocked(!mAlphabetShiftState.isShiftLocked()); } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { - onReleaseSymbol(withSliding); + onReleaseSymbol(); } } @@ -367,16 +327,11 @@ public final class KeyboardState { mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL; } - private void onReleaseSymbol(final boolean withSliding) { + private void onReleaseSymbol() { if (mSymbolKeyState.isChording()) { // Switch back to the previous keyboard mode if the user chords the mode change key and // another key, then releases the mode change key. toggleAlphabetAndSymbols(); - } else if (!withSliding) { - // If the mode change key is being released without sliding, we should forget the - // previous symbols keyboard shift state and simply switch back to symbols layout - // (never symbols shifted) next time the mode gets changed to symbols layout. - mPrevSymbolsKeyboardWasShifted = false; } mSymbolKeyState.onRelease(); } @@ -442,47 +397,43 @@ public final class KeyboardState { if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) { return; } - if (mIsAlphabetMode) { - mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapShiftKeyTimeout(); - if (!mIsInDoubleTapShiftKey) { - // This is first tap. - mSwitchActions.startDoubleTapShiftKeyTimer(); - } - if (mIsInDoubleTapShiftKey) { - if (mAlphabetShiftState.isManualShifted() || mIsInAlphabetUnshiftedFromShifted) { - // Shift key has been double tapped while in manual shifted or automatic - // shifted state. - setShiftLocked(true); - } else { - // Shift key has been double tapped while in normal state. This is the second - // tap to disable shift locked state, so just ignore this. - } + if (!mIsAlphabetMode) { + // There is no shift key on symbols keyboard. + return; + } + mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapShiftKeyTimeout(); + if (!mIsInDoubleTapShiftKey) { + // This is first tap. + mSwitchActions.startDoubleTapShiftKeyTimer(); + } + if (mIsInDoubleTapShiftKey) { + if (mAlphabetShiftState.isManualShifted() || mIsInAlphabetUnshiftedFromShifted) { + // Shift key has been double tapped while in manual shifted or automatic + // shifted state. + setShiftLocked(true); } else { - if (mAlphabetShiftState.isShiftLocked()) { - // Shift key is pressed while shift locked state, we will treat this state as - // shift lock shifted state and mark as if shift key pressed while normal state. - setShifted(SHIFT_LOCK_SHIFTED); - mShiftKeyState.onPress(); - } else if (mAlphabetShiftState.isAutomaticShifted()) { - // Shift key is pressed while automatic shifted, we have to move to manual - // shifted. - setShifted(MANUAL_SHIFT); - mShiftKeyState.onPress(); - } else if (mAlphabetShiftState.isShiftedOrShiftLocked()) { - // In manual shifted state, we just record shift key has been pressing while - // shifted state. - mShiftKeyState.onPressOnShifted(); - } else { - // In base layout, chording or manual shifted mode is started. - setShifted(MANUAL_SHIFT); - mShiftKeyState.onPress(); - } + // Shift key has been double tapped while in normal state. This is the second + // tap to disable shift locked state, so just ignore this. } } else { - // In symbol mode, just toggle symbol and symbol more keyboard. - toggleShiftInSymbols(); - mSwitchState = SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE; - mShiftKeyState.onPress(); + if (mAlphabetShiftState.isShiftLocked()) { + // Shift key is pressed while shift locked state, we will treat this state as + // shift lock shifted state and mark as if shift key pressed while normal state. + setShifted(SHIFT_LOCK_SHIFTED); + mShiftKeyState.onPress(); + } else if (mAlphabetShiftState.isAutomaticShifted()) { + // Shift key is pressed while automatic shifted, we have to move to manual shifted. + setShifted(MANUAL_SHIFT); + mShiftKeyState.onPress(); + } else if (mAlphabetShiftState.isShiftedOrShiftLocked()) { + // In manual shifted state, we just record shift key has been pressing while + // shifted state. + mShiftKeyState.onPressOnShifted(); + } else { + // In base layout, chording or manual shifted mode is started. + setShifted(MANUAL_SHIFT); + mShiftKeyState.onPress(); + } } } @@ -537,11 +488,7 @@ public final class KeyboardState { mIsInAlphabetUnshiftedFromShifted = true; } } else { - // In symbol mode, switch back to the previous keyboard mode if the user chords the - // shift key and another key, then releases the shift key. - if (mShiftKeyState.isChording()) { - toggleShiftInSymbols(); - } + // There is no shift key on symbols keyboard. } mShiftKeyState.onRelease(); } @@ -555,9 +502,6 @@ public final class KeyboardState { case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: toggleAlphabetAndSymbols(); break; - case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: - toggleShiftInSymbols(); - break; case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: setAlphabetKeyboard(); break; @@ -585,12 +529,6 @@ public final class KeyboardState { } } break; - case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: - if (code == Constants.CODE_SHIFT) { - // Detected only the shift key has been pressed on symbol layout, and then released. - mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; - } - break; case SWITCH_STATE_SYMBOL_BEGIN: if (!isSpaceCharacter(code) && (Constants.isLetterCode(code) || code == Constants.CODE_OUTPUT_TEXT)) { @@ -602,7 +540,6 @@ public final class KeyboardState { // characters followed by a space/enter. if (isSpaceCharacter(code)) { toggleAlphabetAndSymbols(); - mPrevSymbolsKeyboardWasShifted = false; } break; } @@ -628,7 +565,6 @@ public final class KeyboardState { case SWITCH_STATE_SYMBOL_BEGIN: return "SYMBOL-BEGIN"; case SWITCH_STATE_SYMBOL: return "SYMBOL"; case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: return "MOMENTARY-ALPHA-SYMBOL"; - case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: return "MOMENTARY-SYMBOL-MORE"; case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: return "MOMENTARY-ALPHA_SHIFT"; default: return null; } @@ -636,8 +572,7 @@ public final class KeyboardState { @Override public String toString() { - return "[keyboard=" + (mIsAlphabetMode ? mAlphabetShiftState.toString() - : (mIsSymbolShifted ? "SYMBOLS_SHIFTED" : "SYMBOLS")) + return "[keyboard=" + (mIsAlphabetMode ? mAlphabetShiftState.toString() : "SYMBOLS") + " shift=" + mShiftKeyState + " symbol=" + mSymbolKeyState + " switch=" + switchStateToString(mSwitchState) + "]"; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java index bb49f4758..c6d652c0e 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java @@ -153,8 +153,8 @@ public final class KeyboardTextsSet { /* 48 */ "single_angle_quotes", /* 49 */ "double_angle_quotes", /* 50 */ "more_keys_for_currency_dollar", - /* 51 */ "keylabel_for_currency_generic", - /* 52 */ "more_keys_for_currency_generic", + /* 51 */ "keylabel_for_currency", + /* 52 */ "more_keys_for_currency", /* 53 */ "more_keys_for_punctuation", /* 54 */ "more_keys_for_star", /* 55 */ "more_keys_for_bullet", @@ -226,32 +226,29 @@ public final class KeyboardTextsSet { /* 121 */ "shortcut_as_more_key", /* 122 */ "action_next_as_more_key", /* 123 */ "action_previous_as_more_key", - /* 124 */ "label_to_more_symbol_key", - /* 125 */ "label_to_more_symbol_for_tablet_key", - /* 126 */ "label_tab_key", - /* 127 */ "label_to_phone_numeric_key", - /* 128 */ "label_to_phone_symbols_key", - /* 129 */ "label_time_am", - /* 130 */ "label_time_pm", - /* 131 */ "label_to_symbol_key_pcqwerty", - /* 132 */ "keylabel_for_popular_domain", - /* 133 */ "more_keys_for_popular_domain", - /* 134 */ "more_keys_for_smiley", - /* 135 */ "single_laqm_raqm", - /* 136 */ "single_laqm_raqm_rtl", - /* 137 */ "single_raqm_laqm", - /* 138 */ "double_laqm_raqm", - /* 139 */ "double_laqm_raqm_rtl", - /* 140 */ "double_raqm_laqm", - /* 141 */ "single_lqm_rqm", - /* 142 */ "single_9qm_lqm", - /* 143 */ "single_9qm_rqm", - /* 144 */ "double_lqm_rqm", - /* 145 */ "double_9qm_lqm", - /* 146 */ "double_9qm_rqm", - /* 147 */ "more_keys_for_single_quote", - /* 148 */ "more_keys_for_double_quote", - /* 149 */ "more_keys_for_tablet_double_quote", + /* 124 */ "label_tab_key", + /* 125 */ "label_to_phone_numeric_key", + /* 126 */ "label_to_phone_symbols_key", + /* 127 */ "label_time_am", + /* 128 */ "label_time_pm", + /* 129 */ "keylabel_for_popular_domain", + /* 130 */ "more_keys_for_popular_domain", + /* 131 */ "more_keys_for_smiley", + /* 132 */ "single_laqm_raqm", + /* 133 */ "single_laqm_raqm_rtl", + /* 134 */ "single_raqm_laqm", + /* 135 */ "double_laqm_raqm", + /* 136 */ "double_laqm_raqm_rtl", + /* 137 */ "double_raqm_laqm", + /* 138 */ "single_lqm_rqm", + /* 139 */ "single_9qm_lqm", + /* 140 */ "single_9qm_rqm", + /* 141 */ "double_lqm_rqm", + /* 142 */ "double_9qm_lqm", + /* 143 */ "double_9qm_rqm", + /* 144 */ "more_keys_for_single_quote", + /* 145 */ "more_keys_for_double_quote", + /* 146 */ "more_keys_for_tablet_double_quote", }; private static final String EMPTY = ""; @@ -289,8 +286,7 @@ public final class KeyboardTextsSet { // U+2666: "♦" BLACK DIAMOND SUIT // U+2663: "♣" BLACK CLUB SUIT /* 55 */ "\u266A,\u2665,\u2660,\u2666,\u2663", - // U+00B1: "±" PLUS-MINUS SIGN - /* 56 */ "\u00B1", + /* 56 */ EMPTY, // The all letters need to be mirrored are found at // http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt /* 57 */ "!fixedColumnOrder!3,<,{,[", @@ -380,28 +376,22 @@ public final class KeyboardTextsSet { /* 121 */ "!icon/shortcut_key|!code/key_shortcut", /* 122 */ "!hasLabels!,!text/label_next_key|!code/key_action_next", /* 123 */ "!hasLabels!,!text/label_previous_key|!code/key_action_previous", - // Label for "switch to more symbol" modifier key. Must be short to fit on key! - /* 124 */ "= \\ <", - // Label for "switch to more symbol" modifier key on tablets. Must be short to fit on key! - /* 125 */ "~ \\ {", // Label for "Tab" key. Must be short to fit on key! - /* 126 */ "Tab", + /* 124 */ "Tab", // Label for "switch to phone numeric" key. Must be short to fit on key! - /* 127 */ "123", + /* 125 */ "123", // Label for "switch to phone symbols" key. Must be short to fit on key! // U+FF0A: "*" FULLWIDTH ASTERISK // U+FF03: "#" FULLWIDTH NUMBER SIGN - /* 128 */ "\uFF0A\uFF03", + /* 126 */ "\uFF0A\uFF03", // Key label for "ante meridiem" - /* 129 */ "AM", + /* 127 */ "AM", // Key label for "post meridiem" - /* 130 */ "PM", - // Label for "switch to symbols" key on PC QWERTY layout - /* 131 */ "Sym", - /* 132 */ ".com", + /* 128 */ "PM", + /* 129 */ ".com", // popular web domains for the locale - most popular, displayed on the keyboard - /* 133 */ "!hasLabels!,.net,.org,.gov,.edu", - /* 134 */ "!fixedColumnOrder!5,!hasLabels!,=-O|=-O ,:-P|:-P ,;-)|;-) ,:-(|:-( ,:-)|:-) ,:-!|:-! ,:-$|:-$ ,B-)|B-) ,:O|:O ,:-*|:-* ,:-D|:-D ,:\'(|:\'( ,:-\\\\|:-\\\\ ,O:-)|O:-) ,:-[|:-[ ", + /* 130 */ "!hasLabels!,.net,.org,.gov,.edu", + /* 131 */ "!fixedColumnOrder!5,!hasLabels!,=-O|=-O ,:-P|:-P ,;-)|;-) ,:-(|:-( ,:-)|:-) ,:-!|:-! ,:-$|:-$ ,B-)|B-) ,:O|:O ,:-*|:-* ,:-D|:-D ,:\'(|:\'( ,:-\\\\|:-\\\\ ,O:-)|O:-) ,:-[|:-[ ", // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK @@ -423,24 +413,24 @@ public final class KeyboardTextsSet { // The following each quotation mark pair consist of // <opening quotation mark>, <closing quotation mark> // and is named after (single|double)_<opening quotation mark>_<closing quotation mark>. - /* 135 */ "\u2039,\u203A", - /* 136 */ "\u2039|\u203A,\u203A|\u2039", - /* 137 */ "\u203A,\u2039", - /* 138 */ "\u00AB,\u00BB", - /* 139 */ "\u00AB|\u00BB,\u00BB|\u00AB", - /* 140 */ "\u00BB,\u00AB", + /* 132 */ "\u2039,\u203A", + /* 133 */ "\u2039|\u203A,\u203A|\u2039", + /* 134 */ "\u203A,\u2039", + /* 135 */ "\u00AB,\u00BB", + /* 136 */ "\u00AB|\u00BB,\u00BB|\u00AB", + /* 137 */ "\u00BB,\u00AB", // The following each quotation mark triplet consists of // <another quotation mark>, <opening quotation mark>, <closing quotation mark> // and is named after (single|double)_<opening quotation mark>_<closing quotation mark>. - /* 141 */ "\u201A,\u2018,\u2019", - /* 142 */ "\u2019,\u201A,\u2018", - /* 143 */ "\u2018,\u201A,\u2019", - /* 144 */ "\u201E,\u201C,\u201D", - /* 145 */ "\u201D,\u201E,\u201C", - /* 146 */ "\u201C,\u201E,\u201D", - /* 147 */ "!fixedColumnOrder!5,!text/single_quotes,!text/single_angle_quotes", - /* 148 */ "!fixedColumnOrder!5,!text/double_quotes,!text/double_angle_quotes", - /* 149 */ "!fixedColumnOrder!6,!text/double_quotes,!text/single_quotes,!text/double_angle_quotes,!text/single_angle_quotes", + /* 138 */ "\u201A,\u2018,\u2019", + /* 139 */ "\u2019,\u201A,\u2018", + /* 140 */ "\u2018,\u201A,\u2019", + /* 141 */ "\u201E,\u201C,\u201D", + /* 142 */ "\u201D,\u201E,\u201C", + /* 143 */ "\u201C,\u201E,\u201D", + /* 144 */ "!fixedColumnOrder!5,!text/single_quotes,!text/single_angle_quotes", + /* 145 */ "!fixedColumnOrder!5,!text/double_quotes,!text/double_angle_quotes", + /* 146 */ "!fixedColumnOrder!6,!text/double_quotes,!text/single_quotes,!text/double_angle_quotes,!text/single_angle_quotes", }; /* Language af: Afrikaans */ @@ -1402,9 +1392,10 @@ public final class KeyboardTextsSet { /* 47 */ null, /* 48 */ "!text/single_laqm_raqm_rtl", /* 49 */ "!text/double_laqm_raqm_rtl", - /* 50~ */ - null, null, null, - /* ~52 */ + /* 50 */ null, + // U+FDFC: "﷼" RIAL SIGN + /* 51 */ "\uFDFC", + /* 52 */ null, // U+061F: "؟" ARABIC QUESTION MARK // U+060C: "،" ARABIC COMMA // U+061B: "؛" ARABIC SEMICOLON @@ -1899,16 +1890,16 @@ public final class KeyboardTextsSet { /* 47 */ "\u201C,\u201D,\u201E", /* 48 */ "!text/single_laqm_raqm_rtl", /* 49 */ "!text/double_laqm_raqm_rtl", - /* 50~ */ - null, null, null, - /* ~52 */ + /* 50 */ null, + // U+20AA: "₪" NEW SHEQEL SIGN + /* 51 */ "\u20AA", + /* 52 */ null, /* 53 */ "!fixedColumnOrder!8,\",\',#,-,:,!,\\,,?,@,&,\\%,+,;,/,(|),)|(", // U+2605: "★" BLACK STAR /* 54 */ "\u2605", /* 55 */ null, - // U+00B1: "±" PLUS-MINUS SIGN // U+FB29: "﬩" HEBREW LETTER ALTERNATIVE PLUS SIGN - /* 56 */ "\u00B1,\uFB29", + /* 56 */ "\uFB29", // The all letters need to be mirrored are found at // http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt /* 57 */ "!fixedColumnOrder!3,<|>,{|},[|]", diff --git a/java/src/com/android/inputmethod/keyboard/internal/ScrollKeyboardView.java b/java/src/com/android/inputmethod/keyboard/internal/ScrollKeyboardView.java new file mode 100644 index 000000000..2628f59a8 --- /dev/null +++ b/java/src/com/android/inputmethod/keyboard/internal/ScrollKeyboardView.java @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.internal; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.widget.ScrollView; +import android.widget.Scroller; + +import com.android.inputmethod.keyboard.Key; +import com.android.inputmethod.keyboard.KeyDetector; +import com.android.inputmethod.keyboard.Keyboard; +import com.android.inputmethod.keyboard.KeyboardView; +import com.android.inputmethod.latin.R; + +/** + * This is an extended {@link KeyboardView} class that hosts a scroll keyboard. + * Multi-touch unsupported. No {@link PointerTracker}s. No gesture support. + */ +public final class ScrollKeyboardView extends KeyboardView implements + ScrollViewWithNotifier.ScrollListener, GestureDetector.OnGestureListener { + private static final boolean PAGINATION = false; + + public interface OnKeyClickListener { + public void onKeyClick(Key key); + } + + private static final OnKeyClickListener EMPTY_LISTENER = new OnKeyClickListener() { + @Override + public void onKeyClick(final Key key) {} + }; + + private OnKeyClickListener mListener = EMPTY_LISTENER; + private final KeyDetector mKeyDetector = new KeyDetector(0.0f /*keyHysteresisDistance */); + private final GestureDetector mGestureDetector; + + private final Scroller mScroller; + private ScrollViewWithNotifier mScrollView; + + public ScrollKeyboardView(final Context context, final AttributeSet attrs) { + this(context, attrs, R.attr.keyboardViewStyle); + } + + public ScrollKeyboardView(final Context context, final AttributeSet attrs, final int defStyle) { + super(context, attrs, defStyle); + mGestureDetector = new GestureDetector(context, this); + mGestureDetector.setIsLongpressEnabled(false /* isLongpressEnabled */); + mScroller = new Scroller(context); + } + + public void setScrollView(final ScrollViewWithNotifier scrollView) { + mScrollView = scrollView; + scrollView.setScrollListener(this); + } + + private final Runnable mScrollTask = new Runnable() { + @Override + public void run() { + final Scroller scroller = mScroller; + final ScrollView scrollView = mScrollView; + scroller.computeScrollOffset(); + scrollView.scrollTo(0, scroller.getCurrY()); + if (!scroller.isFinished()) { + scrollView.post(this); + } + } + }; + + // {@link ScrollViewWithNotified#ScrollListener} methods. + @Override + public void notifyScrollChanged(final int scrollX, final int scrollY, final int oldX, + final int oldY) { + if (PAGINATION) { + mScroller.forceFinished(true /* finished */); + mScrollView.removeCallbacks(mScrollTask); + final int currentTop = mScrollView.getScrollY(); + final int pageHeight = getKeyboard().mBaseHeight; + final int lastPageNo = currentTop / pageHeight; + final int lastPageTop = lastPageNo * pageHeight; + final int nextPageNo = lastPageNo + 1; + final int nextPageTop = Math.min(nextPageNo * pageHeight, getHeight() - pageHeight); + final int scrollTo = (currentTop - lastPageTop) < (nextPageTop - currentTop) + ? lastPageTop : nextPageTop; + final int deltaY = scrollTo - currentTop; + mScroller.startScroll(0, currentTop, 0, deltaY, 300); + mScrollView.post(mScrollTask); + } + } + + @Override + public void notifyOverScrolled(final int scrollX, final int scrollY, final boolean clampedX, + final boolean clampedY) { + releaseCurrentKey(); + } + + public void setOnKeyClickListener(final OnKeyClickListener listener) { + mListener = listener; + } + + /** + * {@inheritDoc} + */ + @Override + public void setKeyboard(final Keyboard keyboard) { + super.setKeyboard(keyboard); + mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean onTouchEvent(final MotionEvent e) { + if (mGestureDetector.onTouchEvent(e)) { + return true; + } + final Key key = getKey(e); + if (key != null && key != mCurrentKey) { + releaseCurrentKey(); + } + return true; + } + + // {@link GestureDetector#OnGestureListener} methods. + private Key mCurrentKey; + + private Key getKey(final MotionEvent e) { + final int index = e.getActionIndex(); + final int x = (int)e.getX(index); + final int y = (int)e.getY(index); + return mKeyDetector.detectHitKey(x, y); + } + + public void releaseCurrentKey() { + final Key currentKey = mCurrentKey; + if (currentKey == null) { + return; + } + currentKey.onReleased(); + invalidateKey(currentKey); + mCurrentKey = null; + } + + @Override + public boolean onDown(final MotionEvent e) { + final Key key = getKey(e); + releaseCurrentKey(); + mCurrentKey = key; + if (key == null) { + return false; + } + // TODO: May call {@link KeyboardActionListener#onPressKey(int,int,boolean)}. + key.onPressed(); + invalidateKey(key); + return false; + } + + @Override + public void onShowPress(final MotionEvent e) { + // User feedback is done at {@link #onDown(MotionEvent)}. + } + + @Override + public boolean onSingleTapUp(final MotionEvent e) { + final Key key = getKey(e); + releaseCurrentKey(); + if (key == null) { + return false; + } + // TODO: May call {@link KeyboardActionListener#onReleaseKey(int,boolean)}. + key.onReleased(); + invalidateKey(key); + mListener.onKeyClick(key); + return true; + } + + @Override + public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX, + final float distanceY) { + releaseCurrentKey(); + return false; + } + + @Override + public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX, + final float velocityY) { + releaseCurrentKey(); + return false; + } + + @Override + public void onLongPress(final MotionEvent e) { + // Long press detection of {@link #mGestureDetector} is disabled and not used. + } +} diff --git a/java/src/com/android/inputmethod/keyboard/internal/ScrollViewWithNotifier.java b/java/src/com/android/inputmethod/keyboard/internal/ScrollViewWithNotifier.java new file mode 100644 index 000000000..d1ccdc7b5 --- /dev/null +++ b/java/src/com/android/inputmethod/keyboard/internal/ScrollViewWithNotifier.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.internal; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ScrollView; + +/** + * This is an extended {@link ScrollView} that can notify + * {@link ScrollView#onScrollChanged(int,int,int,int} and + * {@link ScrollView#onOverScrolled(int,int,int,int)} to a content view. + */ +public class ScrollViewWithNotifier extends ScrollView { + private ScrollListener mScrollListener = EMPTY_LISTER; + + public interface ScrollListener { + public void notifyScrollChanged(int scrollX, int scrollY, int oldX, int oldY); + public void notifyOverScrolled(int scrollX, int scrollY, boolean clampedX, + boolean clampedY); + } + + private static final ScrollListener EMPTY_LISTER = new ScrollListener() { + @Override + public void notifyScrollChanged(int scrollX, int scrollY, int oldX, int oldY) {} + @Override + public void notifyOverScrolled(int scrollX, int scrollY, boolean clampedX, + boolean clampedY) {} + }; + + public ScrollViewWithNotifier(final Context context, final AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onScrollChanged(final int scrollX, final int scrollY, final int oldX, + final int oldY) { + super.onScrollChanged(scrollX, scrollY, oldX, oldY); + mScrollListener.notifyScrollChanged(scrollX, scrollY, oldX, oldY); + } + + @Override + protected void onOverScrolled(final int scrollX, final int scrollY, final boolean clampedX, + final boolean clampedY) { + super.onOverScrolled(scrollX, scrollY, clampedX, clampedY); + mScrollListener.notifyOverScrolled(scrollX, scrollY, clampedX, clampedY); + } + + public void setScrollListener(final ScrollListener listener) { + mScrollListener = listener; + } +} diff --git a/java/src/com/android/inputmethod/latin/AbstractDictionaryWriter.java b/java/src/com/android/inputmethod/latin/AbstractDictionaryWriter.java index 269b3a299..55df263fe 100644 --- a/java/src/com/android/inputmethod/latin/AbstractDictionaryWriter.java +++ b/java/src/com/android/inputmethod/latin/AbstractDictionaryWriter.java @@ -19,10 +19,11 @@ package com.android.inputmethod.latin; import android.content.Context; import android.util.Log; +import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; +import com.android.inputmethod.latin.makedict.Ver3DictEncoder; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; // TODO: Quit extending Dictionary after implementing dynamic binary dictionary. @@ -49,32 +50,21 @@ abstract public class AbstractDictionaryWriter extends Dictionary { abstract public void removeBigramWords(final String word0, final String word1); - abstract protected void writeBinaryDictionary(final FileOutputStream out) + abstract protected void writeDictionary(final DictEncoder dictEncoder) throws IOException, UnsupportedFormatException; public void write(final String fileName) { final String tempFileName = fileName + ".temp"; final File file = new File(mContext.getFilesDir(), fileName); final File tempFile = new File(mContext.getFilesDir(), tempFileName); - FileOutputStream out = null; try { - out = new FileOutputStream(tempFile); - writeBinaryDictionary(out); - out.flush(); - out.close(); + final DictEncoder dictEncoder = new Ver3DictEncoder(file); + writeDictionary(dictEncoder); tempFile.renameTo(file); } catch (IOException e) { Log.e(TAG, "IO exception while writing file", e); } catch (UnsupportedFormatException e) { Log.e(TAG, "Unsupported format", e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - // ignore - } - } } } } diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java index 8f6b848bb..2b6d983c0 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java @@ -229,8 +229,6 @@ final public class BinaryDictionaryGetter { try { // Read the version of the file final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(f); - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); final FileHeader header = dictDecoder.readHeader(); final String version = header.mDictionaryOptions.mAttributes.get(VERSION_KEY); diff --git a/java/src/com/android/inputmethod/latin/DictionaryWriter.java b/java/src/com/android/inputmethod/latin/DictionaryWriter.java index 1ececd5c1..a97e053d0 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryWriter.java +++ b/java/src/com/android/inputmethod/latin/DictionaryWriter.java @@ -20,7 +20,7 @@ import android.content.Context; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; -import com.android.inputmethod.latin.makedict.BinaryDictEncoder; +import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; @@ -28,7 +28,6 @@ import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import com.android.inputmethod.latin.utils.CollectionUtils; -import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -85,9 +84,9 @@ public class DictionaryWriter extends AbstractDictionaryWriter { } @Override - protected void writeBinaryDictionary(final FileOutputStream out) + protected void writeDictionary(final DictEncoder dictEncoder) throws IOException, UnsupportedFormatException { - BinaryDictEncoder.writeDictionaryBinary(out, mFusionDictionary, FORMAT_OPTIONS); + dictEncoder.writeDictionary(mFusionDictionary, FORMAT_OPTIONS); } @Override diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 37256770a..939c2a03b 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -23,11 +23,13 @@ import android.util.Log; import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; +import com.android.inputmethod.latin.personalization.DynamicPersonalizationDictionaryWriter; import com.android.inputmethod.latin.utils.CollectionUtils; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.ReentrantReadWriteLock; /** @@ -91,6 +93,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { /* A extension for a binary dictionary file. */ public static final String DICT_FILE_EXTENSION = ".dict"; + private final AtomicReference<AsyncWriteBinaryDictionaryTask> mWaitingTask = + new AtomicReference<AsyncWriteBinaryDictionaryTask>(); + /** * Abstract method for loading the unigrams and bigrams of a given dictionary in a background * thread. @@ -118,10 +123,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } private static AbstractDictionaryWriter getDictionaryWriter(final Context context, - final String dictType, final boolean isUpdatable) { - if (isUpdatable) { - // TODO: Employ dynamically updatable DictionaryWriter. - return new DictionaryWriter(context, dictType); + final String dictType, final boolean isDynamicPersonalizationDictionary) { + if (isDynamicPersonalizationDictionary) { + return new DynamicPersonalizationDictionaryWriter(context, dictType); } else { return new DictionaryWriter(context, dictType); } @@ -145,6 +149,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { mIsUpdatable = isUpdatable; mBinaryDictionary = null; mSharedDictionaryController = getSharedDictionaryController(filename); + // Currently, only dynamic personalization dictionary is updatable. mDictionaryWriter = getDictionaryWriter(context, dictType, isUpdatable); } @@ -179,6 +184,15 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } } + protected void clear() { + mLocalDictionaryController.writeLock().lock(); + try { + mDictionaryWriter.clear(); + } finally { + mLocalDictionaryController.writeLock().unlock(); + } + } + /** * Adds a word unigram to the dictionary. Used for loading a dictionary. */ @@ -266,7 +280,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { final ArrayList<SuggestedWordInfo> inMemDictSuggestion = mDictionaryWriter.getSuggestions(composer, prevWord, proximityInfo, blockOffensiveWords); - if (mBinaryDictionary != null) { + // TODO: Remove checking mIsUpdatable and use native suggestion. + if (mBinaryDictionary != null && !mIsUpdatable) { final ArrayList<SuggestedWordInfo> binarySuggestion = mBinaryDictionary.getSuggestions(composer, prevWord, proximityInfo, blockOffensiveWords); @@ -275,7 +290,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } else if (binarySuggestion == null) { return inMemDictSuggestion; } else { - binarySuggestion.addAll(binarySuggestion); + binarySuggestion.addAll(inMemDictSuggestion); return binarySuggestion; } } else { @@ -401,7 +416,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { /** * Reloads the dictionary if required. Reload will occur asynchronously in a separate thread. */ - void asyncReloadDictionaryIfRequired() { + public void asyncReloadDictionaryIfRequired() { if (!isReloadRequired()) return; if (DEBUG) { Log.d(TAG, "Starting AsyncReloadDictionaryTask: " + mFilename); @@ -412,7 +427,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { /** * Reloads the dictionary if required. */ - protected final void syncReloadDictionaryIfRequired() { + public final void syncReloadDictionaryIfRequired() { if (!isReloadRequired()) return; syncReloadDictionaryInternal(); } @@ -492,6 +507,68 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } /** + * Load the dictionary to memory. + */ + protected void asyncLoadDictionaryToMemory() { + new AsyncLoadDictionaryToMemoryTask().start(); + } + + /** + * Thread class for asynchronously loading dictionary to memory. + */ + private class AsyncLoadDictionaryToMemoryTask extends Thread { + @Override + public void run() { + mLocalDictionaryController.writeLock().lock(); + try { + mSharedDictionaryController.readLock().lock(); + try { + loadDictionaryAsync(); + } finally { + mSharedDictionaryController.readLock().unlock(); + } + } finally { + mLocalDictionaryController.writeLock().unlock(); + } + } + } + + /** + * Generate binary dictionary using DictionaryWriter. + */ + protected void asyncWriteBinaryDictionary() { + final AsyncWriteBinaryDictionaryTask newTask = new AsyncWriteBinaryDictionaryTask(); + newTask.start(); + final AsyncWriteBinaryDictionaryTask oldTask = mWaitingTask.getAndSet(newTask); + if (oldTask != null) { + oldTask.interrupt(); + } + } + + /** + * Thread class for asynchronously writing the binary dictionary. + */ + private class AsyncWriteBinaryDictionaryTask extends Thread { + @Override + public void run() { + mSharedDictionaryController.writeLock().lock(); + try { + mLocalDictionaryController.writeLock().lock(); + try { + if (isInterrupted()) { + return; + } + writeBinaryDictionary(); + } finally { + mLocalDictionaryController.writeLock().unlock(); + } + } finally { + mSharedDictionaryController.writeLock().unlock(); + } + } + } + + /** * Lock for controlling access to a given binary dictionary and for tracking whether the * dictionary is out of date. Can be shared across multiple dictionary instances that access the * same filename. diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java index 516b8426c..f5fa5d0d7 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -16,10 +16,10 @@ package com.android.inputmethod.latin; -import android.content.Context; import android.text.TextUtils; import android.util.Log; +import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.utils.CollectionUtils; @@ -29,9 +29,10 @@ import java.util.ArrayList; import java.util.LinkedList; /** - * Base class for an in-memory dictionary that can grow dynamically and can + * Class for an in-memory dictionary that can grow dynamically and can * be searched for suggestions and valid words. */ +// TODO: Remove after binary dictionary supports dynamic update. public class ExpandableDictionary extends Dictionary { private static final String TAG = ExpandableDictionary.class.getSimpleName(); /** @@ -39,23 +40,11 @@ public class ExpandableDictionary extends Dictionary { */ private static final int FULL_WORD_SCORE_MULTIPLIER = 2; - // Bigram frequency is a fixed point number with 1 meaning 1.2 and 255 meaning 1.8. - protected static final int BIGRAM_MAX_FREQUENCY = 255; - - private Context mContext; private char[] mWordBuilder = new char[Constants.DICTIONARY_MAX_WORD_LENGTH]; private int mMaxDepth; private int mInputLength; - private boolean mRequiresReload; - - private boolean mUpdatingDictionary; - - // Use this lock before touching mUpdatingDictionary & mRequiresDownload - private Object mUpdatingLock = new Object(); - private static final class Node { - Node() {} char mCode; int mFrequency; boolean mTerminal; @@ -157,46 +146,12 @@ public class ExpandableDictionary extends Dictionary { private int[][] mCodes; - public ExpandableDictionary(final Context context, final String dictType) { + public ExpandableDictionary(final String dictType) { super(dictType); - mContext = context; clearDictionary(); mCodes = new int[Constants.DICTIONARY_MAX_WORD_LENGTH][]; } - public void loadDictionary() { - synchronized (mUpdatingLock) { - startDictionaryLoadingTaskLocked(); - } - } - - public void startDictionaryLoadingTaskLocked() { - if (!mUpdatingDictionary) { - mUpdatingDictionary = true; - mRequiresReload = false; - new LoadDictionaryTask().start(); - } - } - - public void setRequiresReload(final boolean reload) { - synchronized (mUpdatingLock) { - mRequiresReload = reload; - } - } - - public boolean getRequiresReload() { - return mRequiresReload; - } - - /** Override to load your dictionary here, on a background thread. */ - public void loadDictionaryAsync() { - // empty base implementation - } - - public Context getContext() { - return mContext; - } - public int getMaxWordLength() { return Constants.DICTIONARY_MAX_WORD_LENGTH; } @@ -231,7 +186,7 @@ public class ExpandableDictionary extends Dictionary { childNode.mShortcutOnly = isShortcutOnly; children.add(childNode); } - if (wordLength == depth + 1 && shortcutTarget != null) { + if (wordLength == depth + 1) { // Terminate this word childNode.mTerminal = true; if (isShortcutOnly) { @@ -256,7 +211,6 @@ public class ExpandableDictionary extends Dictionary { public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, final boolean blockOffensiveWords) { - if (reloadDictionaryIfRequired()) return null; if (composer.size() > 1) { if (composer.size() >= Constants.DICTIONARY_MAX_WORD_LENGTH) { return null; @@ -272,17 +226,7 @@ public class ExpandableDictionary extends Dictionary { } } - // This reloads the dictionary if required, and returns whether it's currently updating its - // contents or not. - private boolean reloadDictionaryIfRequired() { - synchronized (mUpdatingLock) { - // If we need to update, start off a background task - if (mRequiresReload) startDictionaryLoadingTaskLocked(); - return mUpdatingDictionary; - } - } - - protected ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer codes, + private ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer codes, final String prevWordForBigrams, final ProximityInfo proximityInfo) { final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList(); mInputLength = codes.size(); @@ -312,11 +256,6 @@ public class ExpandableDictionary extends Dictionary { @Override public synchronized boolean isValidWord(final String word) { - synchronized (mUpdatingLock) { - // If we need to update, start off a background task - if (mRequiresReload) startDictionaryLoadingTaskLocked(); - if (mUpdatingDictionary) return false; - } final Node node = searchNode(mRoots, word, 0, word.length()); // If node is null, we didn't find the word, so it's not valid. // If node.mShortcutOnly is true, then it exists as a shortcut but not as a word, @@ -326,7 +265,7 @@ public class ExpandableDictionary extends Dictionary { return (node == null) ? false : !node.mShortcutOnly; } - protected boolean removeBigram(final String word1, final String word2) { + public boolean removeBigram(final String word1, final String word2) { // Refer to addOrSetBigram() about word1.toLowerCase() final Node firstWord = searchWord(mRoots, word1.toLowerCase(), 0, null); final Node secondWord = searchWord(mRoots, word2, 0, null); @@ -351,13 +290,14 @@ public class ExpandableDictionary extends Dictionary { /** * Returns the word's frequency or -1 if not found */ - protected int getWordFrequency(final String word) { + @UsedForTesting + public int getWordFrequency(final String word) { // Case-sensitive search final Node node = searchNode(mRoots, word, 0, word.length()); return (node == null) ? -1 : node.mFrequency; } - protected NextWord getBigramWord(final String word1, final String word2) { + public NextWord getBigramWord(final String word1, final String word2) { // Refer to addOrSetBigram() about word1.toLowerCase() final Node firstWord = searchWord(mRoots, word1.toLowerCase(), 0, null); final Node secondWord = searchWord(mRoots, word2, 0, null); @@ -440,7 +380,7 @@ public class ExpandableDictionary extends Dictionary { * @param suggestions the list in which to add suggestions */ // TODO: Share this routine with the native code for BinaryDictionary - protected void getWordsRec(final NodeArray roots, final WordComposer codes, final char[] word, + private void getWordsRec(final NodeArray roots, final WordComposer codes, final char[] word, final int depth, final boolean completion, final int snr, final int inputIndex, final int skipPos, final ArrayList<SuggestedWordInfo> suggestions) { final int count = roots.mLength; @@ -698,21 +638,10 @@ public class ExpandableDictionary extends Dictionary { return null; } - protected void clearDictionary() { + public void clearDictionary() { mRoots = new NodeArray(); } - private final class LoadDictionaryTask extends Thread { - LoadDictionaryTask() {} - @Override - public void run() { - loadDictionaryAsync(); - synchronized (mUpdatingLock) { - mUpdatingDictionary = false; - } - } - } - private static char toLowerCase(final char c) { char baseChar = c; if (c < BASE_CHARS.length) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 816c6daa4..85001c30c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -73,8 +73,9 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.MainKeyboardView; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.define.ProductionFlag; -import com.android.inputmethod.latin.personalization.PersonalizationDictionaryHelper; +import com.android.inputmethod.latin.personalization.PersonalizationDictionary; import com.android.inputmethod.latin.personalization.PersonalizationDictionarySessionRegister; +import com.android.inputmethod.latin.personalization.PersonalizationHelper; import com.android.inputmethod.latin.personalization.PersonalizationPredictionDictionary; import com.android.inputmethod.latin.personalization.UserHistoryPredictionDictionary; import com.android.inputmethod.latin.settings.Settings; @@ -173,6 +174,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private UserBinaryDictionary mUserDictionary; private UserHistoryPredictionDictionary mUserHistoryPredictionDictionary; private PersonalizationPredictionDictionary mPersonalizationPredictionDictionary; + private PersonalizationDictionary mPersonalizationDictionary; private boolean mIsUserDictionaryAvailable; private LastComposedWord mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD; @@ -564,10 +566,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - mUserHistoryPredictionDictionary = PersonalizationDictionaryHelper + mUserHistoryPredictionDictionary = PersonalizationHelper .getUserHistoryPredictionDictionary(this, localeStr, prefs); newSuggest.setUserHistoryPredictionDictionary(mUserHistoryPredictionDictionary); - mPersonalizationPredictionDictionary = PersonalizationDictionaryHelper + mPersonalizationDictionary = PersonalizationHelper + .getPersonalizationDictionary(this, localeStr, prefs); + newSuggest.setPersonalizationDictionary(mPersonalizationDictionary); + mPersonalizationPredictionDictionary = PersonalizationHelper .getPersonalizationPredictionDictionary(this, localeStr, prefs); newSuggest.setPersonalizationPredictionDictionary(mPersonalizationPredictionDictionary); @@ -639,6 +644,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ResearchLogger.getInstance().onDestroy(); } unregisterReceiver(mDictionaryPackInstallReceiver); + PersonalizationDictionarySessionRegister.onDestroy(this); LatinImeLogger.commit(); LatinImeLogger.onDestroy(); super.onDestroy(); @@ -2051,10 +2057,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen (!mConnection.isCursorTouchingWord(currentSettings) || !currentSettings.mCurrentLanguageHasSpaces)) { // Reset entirely the composing state anyway, then start composing a new word unless - // the character is a single quote. The idea here is, single quote is not a - // separator and it should be treated as a normal character, except in the first - // position where it should not start composing a word. - isComposingWord = (Constants.CODE_SINGLE_QUOTE != primaryCode); + // the character is a single quote or a dash. The idea here is, single quote and dash + // are not separators and they should be treated as normal characters, except in the + // first position where they should not start composing a word. + isComposingWord = (Constants.CODE_SINGLE_QUOTE != primaryCode + && Constants.CODE_DASH != primaryCode); // Here we don't need to reset the last composed word. It will be reset // when we commit this one, if we ever do; if on the other hand we backspace // it entirely and resume suggestions on the previous word, we'd like to still diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 35920f8cb..a031bb3be 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -169,7 +169,6 @@ public final class RichInputConnection { if (DEBUG_BATCH_NESTING) checkBatchEdit(); if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); mCommittedTextBeforeComposingText.append(mComposingText); - mExpectedCursorPosition += mComposingText.length(); mComposingText.setLength(0); if (null != mIC) { mIC.finishComposingText(); diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 8766e0fc1..c8a151a6c 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -24,6 +24,7 @@ import android.util.Log; import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; +import com.android.inputmethod.latin.personalization.PersonalizationDictionary; import com.android.inputmethod.latin.personalization.PersonalizationPredictionDictionary; import com.android.inputmethod.latin.personalization.UserHistoryPredictionDictionary; import com.android.inputmethod.latin.settings.Settings; @@ -200,6 +201,12 @@ public final class Suggest { personalizationPredictionDictionary); } + public void setPersonalizationDictionary( + final PersonalizationDictionary personalizationDictionary) { + addOrReplaceDictionaryInternal(Dictionary.TYPE_PERSONALIZATION, + personalizationDictionary); + } + public void setAutoCorrectionThreshold(float threshold) { mAutoCorrectionThreshold = threshold; } diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java index 995f061f3..ceb8fa81f 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java @@ -19,7 +19,7 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; @@ -31,7 +31,6 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.util.ArrayList; -import java.util.Arrays; import java.util.Map; import java.util.TreeMap; @@ -42,6 +41,7 @@ import java.util.TreeMap; * * TODO: Remove calls from classes except Ver3DictDecoder * TODO: Move this file to makedict/internal. + * TODO: Rename this class to DictDecoderUtils. */ public final class BinaryDictDecoderUtils { @@ -214,7 +214,7 @@ public final class BinaryDictDecoderUtils { buffer[index++] = (byte)(0xFF & codePoint); } } - buffer[index++] = FormatSpec.GROUP_CHARACTERS_TERMINATOR; + buffer[index++] = FormatSpec.PTNODE_CHARACTERS_TERMINATOR; return index - origin; } @@ -238,7 +238,7 @@ public final class BinaryDictDecoderUtils { buffer.write((byte) (0xFF & codePoint)); } } - buffer.write(FormatSpec.GROUP_CHARACTERS_TERMINATOR); + buffer.write(FormatSpec.PTNODE_CHARACTERS_TERMINATOR); } /** @@ -265,7 +265,7 @@ public final class BinaryDictDecoderUtils { static int readChar(final DictBuffer dictBuffer) { int character = dictBuffer.readUnsignedByte(); if (!fitsOnOneByte(character)) { - if (FormatSpec.GROUP_CHARACTERS_TERMINATOR == character) { + if (FormatSpec.PTNODE_CHARACTERS_TERMINATOR == character) { return FormatSpec.INVALID_CHARACTER; } character <<= 16; @@ -278,6 +278,12 @@ public final class BinaryDictDecoderUtils { // Input methods: Read a binary dictionary to memory. // readDictionaryBinary is the public entry point for them. + static int readSInt24(final DictBuffer dictBuffer) { + final int retval = dictBuffer.readUnsignedInt24(); + final int sign = ((retval & FormatSpec.MSB24) != 0) ? -1 : 1; + return sign * (retval & FormatSpec.SINT24_MAX); + } + static int readChildrenAddress(final DictBuffer dictBuffer, final int optionFlags, final FormatOptions options) { if (options.mSupportsDynamicUpdate) { @@ -290,14 +296,14 @@ public final class BinaryDictDecoderUtils { } } int address; - switch (optionFlags & FormatSpec.MASK_GROUP_ADDRESS_TYPE) { - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE: + switch (optionFlags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) { + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE: return dictBuffer.readUnsignedByte(); - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES: + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES: return dictBuffer.readUnsignedShort(); - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES: + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES: return dictBuffer.readUnsignedInt24(); - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_NOADDRESS: + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS: default: return FormatSpec.NO_CHILDREN_ADDRESS; } @@ -314,199 +320,103 @@ public final class BinaryDictDecoderUtils { } } - private static final int[] CHARACTER_BUFFER = new int[FormatSpec.MAX_WORD_LENGTH]; - public static CharGroupInfo readCharGroup(final DictBuffer dictBuffer, - final int originalGroupAddress, final FormatOptions options) { - int addressPointer = originalGroupAddress; - final int flags = dictBuffer.readUnsignedByte(); - ++addressPointer; - - final int parentAddress = readParentAddress(dictBuffer, options); - if (BinaryDictIOUtils.supportsDynamicUpdate(options)) { - addressPointer += 3; - } - - final int characters[]; - if (0 != (flags & FormatSpec.FLAG_HAS_MULTIPLE_CHARS)) { - int index = 0; - int character = CharEncoding.readChar(dictBuffer); - addressPointer += CharEncoding.getCharSize(character); - while (-1 != character) { - // FusionDictionary is making sure that the length of the word is smaller than - // MAX_WORD_LENGTH. - // So we'll never write past the end of CHARACTER_BUFFER. - CHARACTER_BUFFER[index++] = character; - character = CharEncoding.readChar(dictBuffer); - addressPointer += CharEncoding.getCharSize(character); - } - characters = Arrays.copyOfRange(CHARACTER_BUFFER, 0, index); - } else { - final int character = CharEncoding.readChar(dictBuffer); - addressPointer += CharEncoding.getCharSize(character); - characters = new int[] { character }; - } - final int frequency; - if (0 != (FormatSpec.FLAG_IS_TERMINAL & flags)) { - ++addressPointer; - frequency = dictBuffer.readUnsignedByte(); - } else { - frequency = CharGroup.NOT_A_TERMINAL; - } - int childrenAddress = readChildrenAddress(dictBuffer, flags, options); - if (childrenAddress != FormatSpec.NO_CHILDREN_ADDRESS) { - childrenAddress += addressPointer; - } - addressPointer += BinaryDictIOUtils.getChildrenAddressSize(flags, options); - ArrayList<WeightedString> shortcutTargets = null; - if (0 != (flags & FormatSpec.FLAG_HAS_SHORTCUT_TARGETS)) { - final int pointerBefore = dictBuffer.position(); - shortcutTargets = new ArrayList<WeightedString>(); - dictBuffer.readUnsignedShort(); // Skip the size - while (true) { - final int targetFlags = dictBuffer.readUnsignedByte(); - final String word = CharEncoding.readString(dictBuffer); - shortcutTargets.add(new WeightedString(word, - targetFlags & FormatSpec.FLAG_ATTRIBUTE_FREQUENCY)); - if (0 == (targetFlags & FormatSpec.FLAG_ATTRIBUTE_HAS_NEXT)) break; - } - addressPointer += dictBuffer.position() - pointerBefore; - } - ArrayList<PendingAttribute> bigrams = null; - if (0 != (flags & FormatSpec.FLAG_HAS_BIGRAMS)) { - bigrams = new ArrayList<PendingAttribute>(); - int bigramCount = 0; - while (bigramCount++ < FormatSpec.MAX_BIGRAMS_IN_A_GROUP) { - final int bigramFlags = dictBuffer.readUnsignedByte(); - ++addressPointer; - final int sign = 0 == (bigramFlags & FormatSpec.FLAG_ATTRIBUTE_OFFSET_NEGATIVE) - ? 1 : -1; - int bigramAddress = addressPointer; - switch (bigramFlags & FormatSpec.MASK_ATTRIBUTE_ADDRESS_TYPE) { - case FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE: - bigramAddress += sign * dictBuffer.readUnsignedByte(); - addressPointer += 1; - break; - case FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_TWOBYTES: - bigramAddress += sign * dictBuffer.readUnsignedShort(); - addressPointer += 2; - break; - case FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_THREEBYTES: - final int offset = (dictBuffer.readUnsignedByte() << 16) - + dictBuffer.readUnsignedShort(); - bigramAddress += sign * offset; - addressPointer += 3; - break; - default: - throw new RuntimeException("Has bigrams with no address"); - } - bigrams.add(new PendingAttribute(bigramFlags & FormatSpec.FLAG_ATTRIBUTE_FREQUENCY, - bigramAddress)); - if (0 == (bigramFlags & FormatSpec.FLAG_ATTRIBUTE_HAS_NEXT)) break; - } - if (bigramCount >= FormatSpec.MAX_BIGRAMS_IN_A_GROUP) { - MakedictLog.d("too many bigrams in a group."); - } - } - return new CharGroupInfo(originalGroupAddress, addressPointer, flags, characters, frequency, - parentAddress, childrenAddress, shortcutTargets, bigrams); - } - /** - * Reads and returns the char group count out of a buffer and forwards the pointer. + * Reads and returns the PtNode count out of a buffer and forwards the pointer. */ - public static int readCharGroupCount(final DictBuffer dictBuffer) { + /* package */ static int readPtNodeCount(final DictBuffer dictBuffer) { final int msb = dictBuffer.readUnsignedByte(); - if (FormatSpec.MAX_CHARGROUPS_FOR_ONE_BYTE_CHARGROUP_COUNT >= msb) { + if (FormatSpec.MAX_PTNODES_FOR_ONE_BYTE_PTNODE_COUNT >= msb) { return msb; } else { - return ((FormatSpec.MAX_CHARGROUPS_FOR_ONE_BYTE_CHARGROUP_COUNT & msb) << 8) + return ((FormatSpec.MAX_PTNODES_FOR_ONE_BYTE_PTNODE_COUNT & msb) << 8) + dictBuffer.readUnsignedByte(); } } /** - * Finds, as a string, the word at the address passed as an argument. + * Finds, as a string, the word at the position passed as an argument. * - * @param dictBuffer the buffer to read from. + * @param dictDecoder the dict decoder. * @param headerSize the size of the header. - * @param address the address to seek. + * @param pos the position to seek. * @param formatOptions file format options. * @return the word with its frequency, as a weighted string. */ - /* package for tests */ static WeightedString getWordAtAddress( - final DictBuffer dictBuffer, final int headerSize, final int address, + /* package for tests */ static WeightedString getWordAtPosition( + final Ver3DictDecoder dictDecoder, final int headerSize, final int pos, final FormatOptions formatOptions) { + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); final WeightedString result; - final int originalPointer = dictBuffer.position(); - dictBuffer.position(address); + final int originalPos = dictBuffer.position(); + dictBuffer.position(pos); if (BinaryDictIOUtils.supportsDynamicUpdate(formatOptions)) { - result = getWordAtAddressWithParentAddress(dictBuffer, headerSize, address, - formatOptions); + result = getWordAtPositionWithParentAddress(dictDecoder, pos, formatOptions); } else { - result = getWordAtAddressWithoutParentAddress(dictBuffer, headerSize, address, + result = getWordAtPositionWithoutParentAddress(dictDecoder, headerSize, pos, formatOptions); } - dictBuffer.position(originalPointer); + dictBuffer.position(originalPos); return result; } @SuppressWarnings("unused") - private static WeightedString getWordAtAddressWithParentAddress( - final DictBuffer dictBuffer, final int headerSize, final int address, - final FormatOptions options) { - int currentAddress = address; + private static WeightedString getWordAtPositionWithParentAddress( + final Ver3DictDecoder dictDecoder, final int pos, final FormatOptions options) { + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); + int currentPos = pos; int frequency = Integer.MIN_VALUE; final StringBuilder builder = new StringBuilder(); // the length of the path from the root to the leaf is limited by MAX_WORD_LENGTH for (int count = 0; count < FormatSpec.MAX_WORD_LENGTH; ++count) { - CharGroupInfo currentInfo; + PtNodeInfo currentInfo; int loopCounter = 0; do { - dictBuffer.position(currentAddress + headerSize); - currentInfo = readCharGroup(dictBuffer, currentAddress, options); - if (BinaryDictIOUtils.isMovedGroup(currentInfo.mFlags, options)) { - currentAddress = currentInfo.mParentAddress + currentInfo.mOriginalAddress; + dictBuffer.position(currentPos); + currentInfo = dictDecoder.readPtNode(currentPos, options); + if (BinaryDictIOUtils.isMovedPtNode(currentInfo.mFlags, options)) { + currentPos = currentInfo.mParentAddress + currentInfo.mOriginalAddress; } if (DBG && loopCounter++ > MAX_JUMPS) { MakedictLog.d("Too many jumps - probably a bug"); } - } while (BinaryDictIOUtils.isMovedGroup(currentInfo.mFlags, options)); + } while (BinaryDictIOUtils.isMovedPtNode(currentInfo.mFlags, options)); if (Integer.MIN_VALUE == frequency) frequency = currentInfo.mFrequency; builder.insert(0, new String(currentInfo.mCharacters, 0, currentInfo.mCharacters.length)); if (currentInfo.mParentAddress == FormatSpec.NO_PARENT_ADDRESS) break; - currentAddress = currentInfo.mParentAddress + currentInfo.mOriginalAddress; + currentPos = currentInfo.mParentAddress + currentInfo.mOriginalAddress; } return new WeightedString(builder.toString(), frequency); } - private static WeightedString getWordAtAddressWithoutParentAddress( - final DictBuffer dictBuffer, final int headerSize, final int address, + private static WeightedString getWordAtPositionWithoutParentAddress( + final Ver3DictDecoder dictDecoder, final int headerSize, final int pos, final FormatOptions options) { + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); dictBuffer.position(headerSize); - final int count = readCharGroupCount(dictBuffer); - int groupOffset = BinaryDictIOUtils.getGroupCountSize(count); + final int count = readPtNodeCount(dictBuffer); + int groupPos = headerSize + BinaryDictIOUtils.getPtNodeCountSize(count); final StringBuilder builder = new StringBuilder(); WeightedString result = null; - CharGroupInfo last = null; + PtNodeInfo last = null; for (int i = count - 1; i >= 0; --i) { - CharGroupInfo info = readCharGroup(dictBuffer, groupOffset, options); - groupOffset = info.mEndAddress; - if (info.mOriginalAddress == address) { + PtNodeInfo info = dictDecoder.readPtNode(groupPos, options); + groupPos = info.mEndAddress; + if (info.mOriginalAddress == pos) { builder.append(new String(info.mCharacters, 0, info.mCharacters.length)); result = new WeightedString(builder.toString(), info.mFrequency); break; // and return } if (BinaryDictIOUtils.hasChildrenAddress(info.mChildrenAddress)) { - if (info.mChildrenAddress > address) { + if (info.mChildrenAddress > pos) { if (null == last) continue; builder.append(new String(last.mCharacters, 0, last.mCharacters.length)); - dictBuffer.position(last.mChildrenAddress + headerSize); - i = readCharGroupCount(dictBuffer); - groupOffset = last.mChildrenAddress + BinaryDictIOUtils.getGroupCountSize(i); + dictBuffer.position(last.mChildrenAddress); + i = readPtNodeCount(dictBuffer); + groupPos = last.mChildrenAddress + BinaryDictIOUtils.getPtNodeCountSize(i); last = null; continue; } @@ -514,9 +424,9 @@ public final class BinaryDictDecoderUtils { } if (0 == i && BinaryDictIOUtils.hasChildrenAddress(last.mChildrenAddress)) { builder.append(new String(last.mCharacters, 0, last.mCharacters.length)); - dictBuffer.position(last.mChildrenAddress + headerSize); - i = readCharGroupCount(dictBuffer); - groupOffset = last.mChildrenAddress + BinaryDictIOUtils.getGroupCountSize(i); + dictBuffer.position(last.mChildrenAddress); + i = readPtNodeCount(dictBuffer); + groupPos = last.mChildrenAddress + BinaryDictIOUtils.getPtNodeCountSize(i); last = null; continue; } @@ -532,34 +442,35 @@ public final class BinaryDictDecoderUtils { * This will recursively read other node arrays into the structure, populating the reverse * maps on the fly and using them to keep track of already read nodes. * - * @param dictBuffer the buffer, correctly positioned at the start of a node array. + * @param dictDecoder the dict decoder, correctly positioned at the start of a node array. * @param headerSize the size, in bytes, of the file header. * @param reverseNodeArrayMap a mapping from addresses to already read node arrays. - * @param reverseGroupMap a mapping from addresses to already read character groups. + * @param reversePtNodeMap a mapping from addresses to already read PtNodes. * @param options file format options. * @return the read node array with all his children already read. */ - private static PtNodeArray readNodeArray(final DictBuffer dictBuffer, + private static PtNodeArray readNodeArray(final Ver3DictDecoder dictDecoder, final int headerSize, final Map<Integer, PtNodeArray> reverseNodeArrayMap, - final Map<Integer, CharGroup> reverseGroupMap, final FormatOptions options) + final Map<Integer, PtNode> reversePtNodeMap, final FormatOptions options) throws IOException { - final ArrayList<CharGroup> nodeArrayContents = new ArrayList<CharGroup>(); - final int nodeArrayOrigin = dictBuffer.position() - headerSize; + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); + final ArrayList<PtNode> nodeArrayContents = new ArrayList<PtNode>(); + final int nodeArrayOriginPos = dictBuffer.position(); do { // Scan the linked-list node. - final int nodeArrayHeadPosition = dictBuffer.position() - headerSize; - final int count = readCharGroupCount(dictBuffer); - int groupOffset = nodeArrayHeadPosition + BinaryDictIOUtils.getGroupCountSize(count); - for (int i = count; i > 0; --i) { // Scan the array of CharGroup. - CharGroupInfo info = readCharGroup(dictBuffer, groupOffset, options); - if (BinaryDictIOUtils.isMovedGroup(info.mFlags, options)) continue; + final int nodeArrayHeadPos = dictBuffer.position(); + final int count = readPtNodeCount(dictBuffer); + int groupOffsetPos = nodeArrayHeadPos + BinaryDictIOUtils.getPtNodeCountSize(count); + for (int i = count; i > 0; --i) { // Scan the array of PtNode. + PtNodeInfo info = dictDecoder.readPtNode(groupOffsetPos, options); + if (BinaryDictIOUtils.isMovedPtNode(info.mFlags, options)) continue; ArrayList<WeightedString> shortcutTargets = info.mShortcutTargets; ArrayList<WeightedString> bigrams = null; if (null != info.mBigrams) { bigrams = new ArrayList<WeightedString>(); for (PendingAttribute bigram : info.mBigrams) { - final WeightedString word = getWordAtAddress( - dictBuffer, headerSize, bigram.mAddress, options); + final WeightedString word = getWordAtPosition(dictDecoder, headerSize, + bigram.mAddress, options); final int reconstructedFrequency = BinaryDictIOUtils.reconstructBigramFrequency(word.mFrequency, bigram.mFrequency); @@ -570,24 +481,24 @@ public final class BinaryDictDecoderUtils { PtNodeArray children = reverseNodeArrayMap.get(info.mChildrenAddress); if (null == children) { final int currentPosition = dictBuffer.position(); - dictBuffer.position(info.mChildrenAddress + headerSize); - children = readNodeArray(dictBuffer, headerSize, reverseNodeArrayMap, - reverseGroupMap, options); + dictBuffer.position(info.mChildrenAddress); + children = readNodeArray(dictDecoder, headerSize, reverseNodeArrayMap, + reversePtNodeMap, options); dictBuffer.position(currentPosition); } nodeArrayContents.add( - new CharGroup(info.mCharacters, shortcutTargets, bigrams, + new PtNode(info.mCharacters, shortcutTargets, bigrams, info.mFrequency, 0 != (info.mFlags & FormatSpec.FLAG_IS_NOT_A_WORD), 0 != (info.mFlags & FormatSpec.FLAG_IS_BLACKLISTED), children)); } else { nodeArrayContents.add( - new CharGroup(info.mCharacters, shortcutTargets, bigrams, + new PtNode(info.mCharacters, shortcutTargets, bigrams, info.mFrequency, 0 != (info.mFlags & FormatSpec.FLAG_IS_NOT_A_WORD), 0 != (info.mFlags & FormatSpec.FLAG_IS_BLACKLISTED))); } - groupOffset = info.mEndAddress; + groupOffsetPos = info.mEndAddress; } // reach the end of the array. @@ -603,8 +514,8 @@ public final class BinaryDictDecoderUtils { dictBuffer.position() != FormatSpec.NO_FORWARD_LINK_ADDRESS); final PtNodeArray nodeArray = new PtNodeArray(nodeArrayContents); - nodeArray.mCachedAddressBeforeUpdate = nodeArrayOrigin; - nodeArray.mCachedAddressAfterUpdate = nodeArrayOrigin; + nodeArray.mCachedAddressBeforeUpdate = nodeArrayOriginPos; + nodeArray.mCachedAddressAfterUpdate = nodeArrayOriginPos; reverseNodeArrayMap.put(nodeArray.mCachedAddressAfterUpdate, nodeArray); return nodeArray; } @@ -649,24 +560,15 @@ public final class BinaryDictDecoderUtils { * @return the created (or merged) dictionary. */ @UsedForTesting - public static FusionDictionary readDictionaryBinary(final Ver3DictDecoder dictDecoder, - final FusionDictionary dict) throws FileNotFoundException, IOException, - UnsupportedFormatException { - - // if the buffer has not been opened, open the buffer with bytebuffer. - if (dictDecoder.getDictBuffer() == null) dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); - if (dictDecoder.getDictBuffer() == null) { - MakedictLog.e("Cannot open the buffer"); - } - + /* package */ static FusionDictionary readDictionaryBinary(final Ver3DictDecoder dictDecoder, + final FusionDictionary dict) throws IOException, UnsupportedFormatException { // Read header final FileHeader fileHeader = dictDecoder.readHeader(); Map<Integer, PtNodeArray> reverseNodeArrayMapping = new TreeMap<Integer, PtNodeArray>(); - Map<Integer, CharGroup> reverseGroupMapping = new TreeMap<Integer, CharGroup>(); - final PtNodeArray root = readNodeArray(dictDecoder.getDictBuffer(), fileHeader.mHeaderSize, - reverseNodeArrayMapping, reverseGroupMapping, fileHeader.mFormatOptions); + Map<Integer, PtNode> reversePtNodeMapping = new TreeMap<Integer, PtNode>(); + final PtNodeArray root = readNodeArray(dictDecoder, fileHeader.mHeaderSize, + reverseNodeArrayMapping, reversePtNodeMapping, fileHeader.mFormatOptions); FusionDictionary newDict = new FusionDictionary(root, fileHeader.mDictionaryOptions); if (null != dict) { diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoder.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java index ff11cde39..79f5ad8bd 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java @@ -18,7 +18,7 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.CharEncoding; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +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; @@ -33,12 +33,14 @@ import java.util.Iterator; * Encodes binary files for a FusionDictionary. * * All the methods in this class are static. + * + * TODO: Rename this class to DictEncoderUtils. */ -public class BinaryDictEncoder { +public class BinaryDictEncoderUtils { private static final boolean DBG = MakedictLog.DBG; - private BinaryDictEncoder() { + private BinaryDictEncoderUtils() { // This utility class is not publicly instantiable. } @@ -58,46 +60,46 @@ public class BinaryDictEncoder { * @param characters the character array * @return the size of the char array, including the terminator if any */ - static int getGroupCharactersSize(final int[] characters) { + static int getPtNodeCharactersSize(final int[] characters) { int size = CharEncoding.getCharArraySize(characters); - if (characters.length > 1) size += FormatSpec.GROUP_TERMINATOR_SIZE; + if (characters.length > 1) size += FormatSpec.PTNODE_TERMINATOR_SIZE; return size; } /** - * Compute the binary size of the character array in a group + * Compute the binary size of the character array in a PtNode * * If only one character, this is the size of this character. If many, it's the sum of their * sizes + 1 byte for the terminator. * - * @param group the group + * @param ptNode the PtNode * @return the size of the char array, including the terminator if any */ - private static int getGroupCharactersSize(final CharGroup group) { - return getGroupCharactersSize(group.mChars); + private static int getPtNodeCharactersSize(final PtNode ptNode) { + return getPtNodeCharactersSize(ptNode.mChars); } /** - * Compute the binary size of the group count for a node array. + * Compute the binary size of the PtNode count for a node array. * @param nodeArray the nodeArray - * @return the size of the group count, either 1 or 2 bytes. + * @return the size of the PtNode count, either 1 or 2 bytes. */ - private static int getGroupCountSize(final PtNodeArray nodeArray) { - return BinaryDictIOUtils.getGroupCountSize(nodeArray.mData.size()); + private static int getPtNodeCountSize(final PtNodeArray nodeArray) { + return BinaryDictIOUtils.getPtNodeCountSize(nodeArray.mData.size()); } /** * Compute the size of a shortcut in bytes. */ private static int getShortcutSize(final WeightedString shortcut) { - int size = FormatSpec.GROUP_ATTRIBUTE_FLAGS_SIZE; + int size = FormatSpec.PTNODE_ATTRIBUTE_FLAGS_SIZE; final String word = shortcut.mWord; final int length = word.length(); for (int i = 0; i < length; i = word.offsetByCodePoints(i, 1)) { final int codePoint = word.codePointAt(i); size += CharEncoding.getCharSize(codePoint); } - size += FormatSpec.GROUP_TERMINATOR_SIZE; + size += FormatSpec.PTNODE_TERMINATOR_SIZE; return size; } @@ -108,8 +110,8 @@ public class BinaryDictEncoder { * like address lists do. */ static int getShortcutListSize(final ArrayList<WeightedString> shortcutList) { - if (null == shortcutList) return 0; - int size = FormatSpec.GROUP_SHORTCUT_LIST_SIZE_SIZE; + if (null == shortcutList || shortcutList.isEmpty()) return 0; + int size = FormatSpec.PTNODE_SHORTCUT_LIST_SIZE_SIZE; for (final WeightedString shortcut : shortcutList) { size += getShortcutSize(shortcut); } @@ -117,60 +119,60 @@ public class BinaryDictEncoder { } /** - * Compute the maximum size of a CharGroup, assuming 3-byte addresses for everything. + * Compute the maximum size of a PtNode, assuming 3-byte addresses for everything. * - * @param group the CharGroup to compute the size of. + * @param ptNode the PtNode to compute the size of. * @param options file format options. - * @return the maximum size of the group. + * @return the maximum size of the PtNode. */ - private static int getCharGroupMaximumSize(final CharGroup group, final FormatOptions options) { - int size = getGroupHeaderSize(group, options); + private static int getPtNodeMaximumSize(final PtNode ptNode, final FormatOptions options) { + int size = getNodeHeaderSize(ptNode, options); // If terminal, one byte for the frequency - if (group.isTerminal()) size += FormatSpec.GROUP_FREQUENCY_SIZE; - size += FormatSpec.GROUP_MAX_ADDRESS_SIZE; // For children address - size += getShortcutListSize(group.mShortcutTargets); - if (null != group.mBigrams) { - size += (FormatSpec.GROUP_ATTRIBUTE_FLAGS_SIZE - + FormatSpec.GROUP_ATTRIBUTE_MAX_ADDRESS_SIZE) - * group.mBigrams.size(); + if (ptNode.isTerminal()) size += FormatSpec.PTNODE_FREQUENCY_SIZE; + size += FormatSpec.PTNODE_MAX_ADDRESS_SIZE; // For children address + size += getShortcutListSize(ptNode.mShortcutTargets); + if (null != ptNode.mBigrams) { + size += (FormatSpec.PTNODE_ATTRIBUTE_FLAGS_SIZE + + FormatSpec.PTNODE_ATTRIBUTE_MAX_ADDRESS_SIZE) + * ptNode.mBigrams.size(); } return size; } /** - * Compute the maximum size of each node of a node array, assuming 3-byte addresses for + * Compute the maximum size of each PtNode of a PtNode array, assuming 3-byte addresses for * everything, and caches it in the `mCachedSize' member of the nodes; deduce the size of * the containing node array, and cache it it its 'mCachedSize' member. * - * @param nodeArray the node array to compute the maximum size of. + * @param ptNodeArray the node array to compute the maximum size of. * @param options file format options. */ - private static void calculateNodeArrayMaximumSize(final PtNodeArray nodeArray, + private static void calculatePtNodeArrayMaximumSize(final PtNodeArray ptNodeArray, final FormatOptions options) { - int size = getGroupCountSize(nodeArray); - for (CharGroup g : nodeArray.mData) { - final int groupSize = getCharGroupMaximumSize(g, options); - g.mCachedSize = groupSize; - size += groupSize; + int size = getPtNodeCountSize(ptNodeArray); + for (PtNode node : ptNodeArray.mData) { + final int nodeSize = getPtNodeMaximumSize(node, options); + node.mCachedSize = nodeSize; + size += nodeSize; } if (options.mSupportsDynamicUpdate) { size += FormatSpec.FORWARD_LINK_ADDRESS_SIZE; } - nodeArray.mCachedSize = size; + ptNodeArray.mCachedSize = size; } /** - * Compute the size of the header (flag + [parent address] + characters size) of a CharGroup. + * Compute the size of the header (flag + [parent address] + characters size) of a PtNode. * - * @param group the group of which to compute the size of the header + * @param ptNode the PtNode of which to compute the size of the header * @param options file format options. */ - private static int getGroupHeaderSize(final CharGroup group, final FormatOptions options) { + private static int getNodeHeaderSize(final PtNode ptNode, final FormatOptions options) { if (BinaryDictIOUtils.supportsDynamicUpdate(options)) { - return FormatSpec.GROUP_FLAGS_SIZE + FormatSpec.PARENT_ADDRESS_SIZE - + getGroupCharactersSize(group); + return FormatSpec.PTNODE_FLAGS_SIZE + FormatSpec.PARENT_ADDRESS_SIZE + + getPtNodeCharactersSize(ptNode); } else { - return FormatSpec.GROUP_FLAGS_SIZE + getGroupCharactersSize(group); + return FormatSpec.PTNODE_FLAGS_SIZE + getPtNodeCharactersSize(ptNode); } } @@ -203,14 +205,14 @@ public class BinaryDictEncoder { // cache performance and dictionary size. /* package for tests */ static ArrayList<PtNodeArray> flattenTree( final PtNodeArray rootNodeArray) { - final int treeSize = FusionDictionary.countCharGroups(rootNodeArray); + final int treeSize = FusionDictionary.countPtNodes(rootNodeArray); MakedictLog.i("Counted nodes : " + treeSize); final ArrayList<PtNodeArray> flatTree = new ArrayList<PtNodeArray>(treeSize); return flattenTreeInner(flatTree, rootNodeArray); } private static ArrayList<PtNodeArray> flattenTreeInner(final ArrayList<PtNodeArray> list, - final PtNodeArray nodeArray) { + final PtNodeArray ptNodeArray) { // Removing the node is necessary if the tails are merged, because we would then // add the same node several times when we only want it once. A number of places in // the code also depends on any node being only once in the list. @@ -228,11 +230,11 @@ public class BinaryDictEncoder { // this simple list.remove operation O(n*n) overall. On Android this overhead is very // high. // For future reference, the code to remove duplicate is a simple : list.remove(node); - list.add(nodeArray); - final ArrayList<CharGroup> branches = nodeArray.mData; + list.add(ptNodeArray); + final ArrayList<PtNode> branches = ptNodeArray.mData; final int nodeSize = branches.size(); - for (CharGroup group : branches) { - if (null != group.mChildren) flattenTreeInner(list, group.mChildren); + for (PtNode ptNode : branches) { + if (null != ptNode.mChildren) flattenTreeInner(list, ptNode.mChildren); } return list; } @@ -248,7 +250,7 @@ public class BinaryDictEncoder { * from the new position in the current node array to the new position in the target node * array. * - * @param currentNodeArray node array containing the CharGroup where the offset will be written + * @param currentNodeArray node array containing the PtNode where the offset will be written * @param offsetFromStartOfCurrentNodeArray offset, in bytes, from the start of currentNodeArray * @param targetNodeArray the target node array to get the offset to * @return the offset to the target node array @@ -269,20 +271,20 @@ public class BinaryDictEncoder { } /** - * Get the offset from a position inside a current node array to a target CharGroup, during + * Get the offset from a position inside a current node array to a target PtNode, during * update. * - * @param currentNodeArray node array containing the CharGroup where the offset will be written + * @param currentNodeArray node array containing the PtNode where the offset will be written * @param offsetFromStartOfCurrentNodeArray offset, in bytes, from the start of currentNodeArray - * @param targetCharGroup the target CharGroup to get the offset to - * @return the offset to the target CharGroup + * @param targetPtNode the target PtNode to get the offset to + * @return the offset to the target PtNode */ // TODO: is there any way to factorize this method with the one above? - private static int getOffsetToTargetCharGroupDuringUpdate(final PtNodeArray currentNodeArray, - final int offsetFromStartOfCurrentNodeArray, final CharGroup targetCharGroup) { + private static int getOffsetToTargetPtNodeDuringUpdate(final PtNodeArray currentNodeArray, + final int offsetFromStartOfCurrentNodeArray, final PtNode targetPtNode) { final int oldOffsetBasePoint = currentNodeArray.mCachedAddressBeforeUpdate + offsetFromStartOfCurrentNodeArray; - final boolean isTargetBeforeCurrent = (targetCharGroup.mCachedAddressBeforeUpdate + final boolean isTargetBeforeCurrent = (targetPtNode.mCachedAddressBeforeUpdate < oldOffsetBasePoint); // If the target is before the current node array, then its address has already been // updated. We can use the AfterUpdate member, and compare it to our own member after @@ -292,9 +294,9 @@ public class BinaryDictEncoder { if (isTargetBeforeCurrent) { final int newOffsetBasePoint = currentNodeArray.mCachedAddressAfterUpdate + offsetFromStartOfCurrentNodeArray; - return targetCharGroup.mCachedAddressAfterUpdate - newOffsetBasePoint; + return targetPtNode.mCachedAddressAfterUpdate - newOffsetBasePoint; } else { - return targetCharGroup.mCachedAddressBeforeUpdate - oldOffsetBasePoint; + return targetPtNode.mCachedAddressBeforeUpdate - oldOffsetBasePoint; } } @@ -308,49 +310,45 @@ public class BinaryDictEncoder { * contents (as in, any of the addresses stored in the cache fields) have changed with * respect to their previous value. * - * @param nodeArray the node array to compute the size of. + * @param ptNodeArray the node array to compute the size of. * @param dict the dictionary in which the word/attributes are to be found. * @param formatOptions file format options. * @return false if none of the cached addresses inside the node array changed, true otherwise. */ - private static boolean computeActualNodeArraySize(final PtNodeArray nodeArray, + private static boolean computeActualPtNodeArraySize(final PtNodeArray ptNodeArray, final FusionDictionary dict, final FormatOptions formatOptions) { boolean changed = false; - int size = getGroupCountSize(nodeArray); - for (CharGroup group : nodeArray.mData) { - group.mCachedAddressAfterUpdate = nodeArray.mCachedAddressAfterUpdate + size; - if (group.mCachedAddressAfterUpdate != group.mCachedAddressBeforeUpdate) { + int size = getPtNodeCountSize(ptNodeArray); + for (PtNode ptNode : ptNodeArray.mData) { + ptNode.mCachedAddressAfterUpdate = ptNodeArray.mCachedAddressAfterUpdate + size; + if (ptNode.mCachedAddressAfterUpdate != ptNode.mCachedAddressBeforeUpdate) { changed = true; } - int groupSize = getGroupHeaderSize(group, formatOptions); - if (group.isTerminal()) groupSize += FormatSpec.GROUP_FREQUENCY_SIZE; - if (null == group.mChildren && formatOptions.mSupportsDynamicUpdate) { - groupSize += FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE; - } else if (null != group.mChildren) { - if (formatOptions.mSupportsDynamicUpdate) { - groupSize += FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE; - } else { - groupSize += getByteSize(getOffsetToTargetNodeArrayDuringUpdate(nodeArray, - groupSize + size, group.mChildren)); - } + int nodeSize = getNodeHeaderSize(ptNode, formatOptions); + if (ptNode.isTerminal()) nodeSize += FormatSpec.PTNODE_FREQUENCY_SIZE; + if (formatOptions.mSupportsDynamicUpdate) { + nodeSize += FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE; + } else if (null != ptNode.mChildren) { + nodeSize += getByteSize(getOffsetToTargetNodeArrayDuringUpdate(ptNodeArray, + nodeSize + size, ptNode.mChildren)); } - groupSize += getShortcutListSize(group.mShortcutTargets); - if (null != group.mBigrams) { - for (WeightedString bigram : group.mBigrams) { - final int offset = getOffsetToTargetCharGroupDuringUpdate(nodeArray, - groupSize + size + FormatSpec.GROUP_FLAGS_SIZE, + nodeSize += getShortcutListSize(ptNode.mShortcutTargets); + if (null != ptNode.mBigrams) { + for (WeightedString bigram : ptNode.mBigrams) { + final int offset = getOffsetToTargetPtNodeDuringUpdate(ptNodeArray, + nodeSize + size + FormatSpec.PTNODE_FLAGS_SIZE, FusionDictionary.findWordInTree(dict.mRootNodeArray, bigram.mWord)); - groupSize += getByteSize(offset) + FormatSpec.GROUP_FLAGS_SIZE; + nodeSize += getByteSize(offset) + FormatSpec.PTNODE_FLAGS_SIZE; } } - group.mCachedSize = groupSize; - size += groupSize; + ptNode.mCachedSize = nodeSize; + size += nodeSize; } if (formatOptions.mSupportsDynamicUpdate) { size += FormatSpec.FORWARD_LINK_ADDRESS_SIZE; } - if (nodeArray.mCachedSize != size) { - nodeArray.mCachedSize = size; + if (ptNodeArray.mCachedSize != size) { + ptNodeArray.mCachedSize = size; changed = true; } return changed; @@ -363,19 +361,19 @@ public class BinaryDictEncoder { * @param formatOptions file format options. * @return the byte size of the entire stack. */ - private static int initializeNodeArraysCachedAddresses(final ArrayList<PtNodeArray> flatNodes, + private static int initializePtNodeArraysCachedAddresses(final ArrayList<PtNodeArray> flatNodes, final FormatOptions formatOptions) { int nodeArrayOffset = 0; for (final PtNodeArray nodeArray : flatNodes) { nodeArray.mCachedAddressBeforeUpdate = nodeArrayOffset; - int groupCountSize = getGroupCountSize(nodeArray); - int groupOffset = 0; - for (final CharGroup g : nodeArray.mData) { - g.mCachedAddressBeforeUpdate = g.mCachedAddressAfterUpdate = - groupCountSize + nodeArrayOffset + groupOffset; - groupOffset += g.mCachedSize; + int nodeCountSize = getPtNodeCountSize(nodeArray); + int nodeffset = 0; + for (final PtNode ptNode : nodeArray.mData) { + ptNode.mCachedAddressBeforeUpdate = ptNode.mCachedAddressAfterUpdate = + nodeCountSize + nodeArrayOffset + nodeffset; + nodeffset += ptNode.mCachedSize; } - final int nodeSize = groupCountSize + groupOffset + final int nodeSize = nodeCountSize + nodeffset + (formatOptions.mSupportsDynamicUpdate ? FormatSpec.FORWARD_LINK_ADDRESS_SIZE : 0); nodeArrayOffset += nodeArray.mCachedSize; @@ -388,11 +386,11 @@ public class BinaryDictEncoder { * * @param flatNodes the list of node arrays. */ - private static void updateNodeArraysCachedAddresses(final ArrayList<PtNodeArray> flatNodes) { + private static void updatePtNodeArraysCachedAddresses(final ArrayList<PtNodeArray> flatNodes) { for (final PtNodeArray nodeArray : flatNodes) { nodeArray.mCachedAddressBeforeUpdate = nodeArray.mCachedAddressAfterUpdate; - for (final CharGroup g : nodeArray.mData) { - g.mCachedAddressBeforeUpdate = g.mCachedAddressAfterUpdate; + for (final PtNode ptNode : nodeArray.mData) { + ptNode.mCachedAddressBeforeUpdate = ptNode.mCachedAddressAfterUpdate; } } } @@ -407,38 +405,38 @@ public class BinaryDictEncoder { */ private static void computeParentAddresses(final ArrayList<PtNodeArray> flatNodes) { for (final PtNodeArray nodeArray : flatNodes) { - for (final CharGroup group : nodeArray.mData) { - if (null != group.mChildren) { + for (final PtNode ptNode : nodeArray.mData) { + if (null != ptNode.mChildren) { // Assign my address to children's parent address // Here BeforeUpdate and AfterUpdate addresses have the same value, so it // does not matter which we use. - group.mChildren.mCachedParentAddress = group.mCachedAddressAfterUpdate - - group.mChildren.mCachedAddressAfterUpdate; + ptNode.mChildren.mCachedParentAddress = ptNode.mCachedAddressAfterUpdate + - ptNode.mChildren.mCachedAddressAfterUpdate; } } } } /** - * Compute the addresses and sizes of an ordered list of node arrays. + * Compute the addresses and sizes of an ordered list of PtNode arrays. * - * This method takes a list of node arrays and will update their cached address and size + * This method takes a list of PtNode arrays and will update their cached address and size * values so that they can be written into a file. It determines the smallest size each of the - * nodes arrays can be given the addresses of its children and attributes, and store that into - * each node. - * The order of the node is given by the order of the array. This method makes no effort + * PtNode arrays can be given the addresses of its children and attributes, and store that into + * each PtNode. + * The order of the PtNode is given by the order of the array. This method makes no effort * to find a good order; it only mechanically computes the size this order results in. * * @param dict the dictionary - * @param flatNodes the ordered list of nodes arrays + * @param flatNodes the ordered list of PtNode arrays * @param formatOptions file format options. * @return the same array it was passed. The nodes have been updated for address and size. */ private static ArrayList<PtNodeArray> computeAddresses(final FusionDictionary dict, final ArrayList<PtNodeArray> flatNodes, final FormatOptions formatOptions) { // First get the worst possible sizes and offsets - for (final PtNodeArray n : flatNodes) calculateNodeArrayMaximumSize(n, formatOptions); - final int offset = initializeNodeArraysCachedAddresses(flatNodes, formatOptions); + for (final PtNodeArray n : flatNodes) calculatePtNodeArrayMaximumSize(n, formatOptions); + final int offset = initializePtNodeArraysCachedAddresses(flatNodes, formatOptions); MakedictLog.i("Compressing the array addresses. Original size : " + offset); MakedictLog.i("(Recursively seen size : " + offset + ")"); @@ -447,19 +445,20 @@ public class BinaryDictEncoder { boolean changesDone = false; do { changesDone = false; - int nodeArrayStartOffset = 0; - for (final PtNodeArray nodeArray : flatNodes) { - nodeArray.mCachedAddressAfterUpdate = nodeArrayStartOffset; - final int oldNodeArraySize = nodeArray.mCachedSize; - final boolean changed = computeActualNodeArraySize(nodeArray, dict, formatOptions); - final int newNodeArraySize = nodeArray.mCachedSize; + int ptNodeArrayStartOffset = 0; + for (final PtNodeArray ptNodeArray : flatNodes) { + ptNodeArray.mCachedAddressAfterUpdate = ptNodeArrayStartOffset; + final int oldNodeArraySize = ptNodeArray.mCachedSize; + final boolean changed = + computeActualPtNodeArraySize(ptNodeArray, dict, formatOptions); + final int newNodeArraySize = ptNodeArray.mCachedSize; if (oldNodeArraySize < newNodeArraySize) { throw new RuntimeException("Increased size ?!"); } - nodeArrayStartOffset += newNodeArraySize; + ptNodeArrayStartOffset += newNodeArraySize; changesDone |= changed; } - updateNodeArraysCachedAddresses(flatNodes); + updatePtNodeArraysCachedAddresses(flatNodes); ++passes; if (passes > MAX_PASSES) throw new RuntimeException("Too many passes - probably a bug"); } while (changesDone); @@ -467,10 +466,10 @@ public class BinaryDictEncoder { if (formatOptions.mSupportsDynamicUpdate) { computeParentAddresses(flatNodes); } - final PtNodeArray lastNodeArray = flatNodes.get(flatNodes.size() - 1); + final PtNodeArray lastPtNodeArray = flatNodes.get(flatNodes.size() - 1); MakedictLog.i("Compression complete in " + passes + " passes."); MakedictLog.i("After address compression : " - + (lastNodeArray.mCachedAddressAfterUpdate + lastNodeArray.mCachedSize)); + + (lastPtNodeArray.mCachedAddressAfterUpdate + lastPtNodeArray.mCachedSize)); return flatNodes; } @@ -478,25 +477,26 @@ public class BinaryDictEncoder { /** * Sanity-checking method. * - * This method checks a list of node arrays for juxtaposition, that is, it will do + * This method checks a list of PtNode arrays for juxtaposition, that is, it will do * nothing if each node array's cached address is actually the previous node array's address * plus the previous node's size. * If this is not the case, it will throw an exception. * * @param arrays the list of node arrays to check */ - private static void checkFlatNodeArrayList(final ArrayList<PtNodeArray> arrays) { + private static void checkFlatPtNodeArrayList(final ArrayList<PtNodeArray> arrays) { int offset = 0; int index = 0; - for (final PtNodeArray nodeArray : arrays) { + for (final PtNodeArray ptNodeArray : arrays) { // BeforeUpdate and AfterUpdate addresses are the same here, so it does not matter // which we use. - if (nodeArray.mCachedAddressAfterUpdate != offset) { + if (ptNodeArray.mCachedAddressAfterUpdate != offset) { throw new RuntimeException("Wrong address for node " + index - + " : expected " + offset + ", got " + nodeArray.mCachedAddressAfterUpdate); + + " : expected " + offset + ", got " + + ptNodeArray.mCachedAddressAfterUpdate); } ++index; - offset += nodeArray.mCachedSize; + offset += ptNodeArray.mCachedSize; } } @@ -552,19 +552,19 @@ public class BinaryDictEncoder { } /** - * Makes the flag value for a char group. + * Makes the flag value for a PtNode. * - * @param hasMultipleChars whether the group has multiple chars. - * @param isTerminal whether the group is terminal. + * @param hasMultipleChars whether the PtNode has multiple chars. + * @param isTerminal whether the PtNode is terminal. * @param childrenAddressSize the size of a children address. - * @param hasShortcuts whether the group has shortcuts. - * @param hasBigrams whether the group has bigrams. - * @param isNotAWord whether the group is not a word. - * @param isBlackListEntry whether the group is a blacklist entry. + * @param hasShortcuts whether the PtNode has shortcuts. + * @param hasBigrams whether the PtNode has bigrams. + * @param isNotAWord whether the PtNode is not a word. + * @param isBlackListEntry whether the PtNode is a blacklist entry. * @param formatOptions file format options. * @return the flags */ - static int makeCharGroupFlags(final boolean hasMultipleChars, final boolean isTerminal, + static int makePtNodeFlags(final boolean hasMultipleChars, final boolean isTerminal, final int childrenAddressSize, final boolean hasShortcuts, final boolean hasBigrams, final boolean isNotAWord, final boolean isBlackListEntry, final FormatOptions formatOptions) { @@ -576,16 +576,16 @@ public class BinaryDictEncoder { } else if (true) { switch (childrenAddressSize) { case 1: - flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE; + flags |= FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE; break; case 2: - flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES; + flags |= FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES; break; case 3: - flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES; + flags |= FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES; break; case 0: - flags |= FormatSpec.FLAG_GROUP_ADDRESS_TYPE_NOADDRESS; + flags |= FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS; break; default: throw new RuntimeException("Node with a strange address"); @@ -598,11 +598,12 @@ public class BinaryDictEncoder { return flags; } - private static byte makeCharGroupFlags(final CharGroup group, final int groupAddress, + private static byte makePtNodeFlags(final PtNode node, final int ptNodeAddress, final int childrenOffset, final FormatOptions formatOptions) { - return (byte) makeCharGroupFlags(group.mChars.length > 1, group.mFrequency >= 0, - getByteSize(childrenOffset), group.mShortcutTargets != null, group.mBigrams != null, - group.mIsNotAWord, group.mIsBlacklistEntry, formatOptions); + return (byte) makePtNodeFlags(node.mChars.length > 1, node.mFrequency >= 0, + getByteSize(childrenOffset), + node.mShortcutTargets != null && !node.mShortcutTargets.isEmpty(), + node.mBigrams != null, node.mIsNotAWord, node.mIsBlacklistEntry, formatOptions); } /** @@ -617,17 +618,17 @@ public class BinaryDictEncoder { */ private static final int makeBigramFlags(final boolean more, final int offset, int bigramFrequency, final int unigramFrequency, final String word) { - int bigramFlags = (more ? FormatSpec.FLAG_ATTRIBUTE_HAS_NEXT : 0) - + (offset < 0 ? FormatSpec.FLAG_ATTRIBUTE_OFFSET_NEGATIVE : 0); + int bigramFlags = (more ? FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT : 0) + + (offset < 0 ? FormatSpec.FLAG_BIGRAM_ATTR_OFFSET_NEGATIVE : 0); switch (getByteSize(offset)) { case 1: - bigramFlags |= FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE; + bigramFlags |= FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE; break; case 2: - bigramFlags |= FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_TWOBYTES; + bigramFlags |= FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES; break; case 3: - bigramFlags |= FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_THREEBYTES; + bigramFlags |= FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES; break; default: throw new RuntimeException("Strange offset size"); @@ -672,7 +673,7 @@ public class BinaryDictEncoder { // small over-estimation that we get in this case. TODO: actually remove this bigram // if discretizedFrequency < 0. final int finalBigramFrequency = discretizedFrequency > 0 ? discretizedFrequency : 0; - bigramFlags += finalBigramFrequency & FormatSpec.FLAG_ATTRIBUTE_FREQUENCY; + bigramFlags += finalBigramFrequency & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY; return bigramFlags; } @@ -697,8 +698,8 @@ public class BinaryDictEncoder { * @return the flags */ static final int makeShortcutFlags(final boolean more, final int frequency) { - return (more ? FormatSpec.FLAG_ATTRIBUTE_HAS_NEXT : 0) - + (frequency & FormatSpec.FLAG_ATTRIBUTE_FREQUENCY); + return (more ? FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT : 0) + + (frequency & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY); } private static final int writeParentAddress(final byte[] buffer, final int index, @@ -721,68 +722,69 @@ public class BinaryDictEncoder { } /** - * Write a node array to memory. The node array is expected to have its final position cached. + * Write a PtNodeArray to memory. The PtNodeArray is expected to have its final position cached. * * @param dict the dictionary the node array is a part of (for relative offsets). * @param buffer the memory buffer to write to. - * @param nodeArray the node array to write. + * @param ptNodeArray the node array to write. * @param formatOptions file format options. * @return the address of the END of the node. */ @SuppressWarnings("unused") private static int writePlacedNode(final FusionDictionary dict, byte[] buffer, - final PtNodeArray nodeArray, final FormatOptions formatOptions) { - // TODO: Make the code in common with BinaryDictIOUtils#writeCharGroup - int index = nodeArray.mCachedAddressAfterUpdate; + final PtNodeArray ptNodeArray, final FormatOptions formatOptions) { + // TODO: Make the code in common with BinaryDictIOUtils#writePtNode + int index = ptNodeArray.mCachedAddressAfterUpdate; - final int groupCount = nodeArray.mData.size(); - final int countSize = getGroupCountSize(nodeArray); - final int parentAddress = nodeArray.mCachedParentAddress; + final int ptNodeCount = ptNodeArray.mData.size(); + final int countSize = getPtNodeCountSize(ptNodeArray); + final int parentAddress = ptNodeArray.mCachedParentAddress; if (1 == countSize) { - buffer[index++] = (byte)groupCount; + buffer[index++] = (byte)ptNodeCount; } else if (2 == countSize) { // We need to signal 2-byte size by setting the top bit of the MSB to 1, so // we | 0x80 to do this. - buffer[index++] = (byte)((groupCount >> 8) | 0x80); - buffer[index++] = (byte)(groupCount & 0xFF); + buffer[index++] = (byte)((ptNodeCount >> 8) | 0x80); + buffer[index++] = (byte)(ptNodeCount & 0xFF); } else { throw new RuntimeException("Strange size from getGroupCountSize : " + countSize); } - int groupAddress = index; - for (int i = 0; i < groupCount; ++i) { - final CharGroup group = nodeArray.mData.get(i); - if (index != group.mCachedAddressAfterUpdate) { + int ptNodeAddress = index; + for (int i = 0; i < ptNodeCount; ++i) { + final PtNode ptNode = ptNodeArray.mData.get(i); + if (index != ptNode.mCachedAddressAfterUpdate) { throw new RuntimeException("Bug: write index is not the same as the cached address " - + "of the group : " + index + " <> " + group.mCachedAddressAfterUpdate); + + "of the node : " + index + " <> " + ptNode.mCachedAddressAfterUpdate); } - groupAddress += getGroupHeaderSize(group, formatOptions); + ptNodeAddress += getNodeHeaderSize(ptNode, formatOptions); // Sanity checks. - if (DBG && group.mFrequency > FormatSpec.MAX_TERMINAL_FREQUENCY) { + if (DBG && ptNode.mFrequency > FormatSpec.MAX_TERMINAL_FREQUENCY) { throw new RuntimeException("A node has a frequency > " + FormatSpec.MAX_TERMINAL_FREQUENCY - + " : " + group.mFrequency); + + " : " + ptNode.mFrequency); } - if (group.mFrequency >= 0) groupAddress += FormatSpec.GROUP_FREQUENCY_SIZE; - final int childrenOffset = null == group.mChildren + if (ptNode.mFrequency >= 0) ptNodeAddress += FormatSpec.PTNODE_FREQUENCY_SIZE; + final int childrenOffset = null == ptNode.mChildren ? FormatSpec.NO_CHILDREN_ADDRESS - : group.mChildren.mCachedAddressAfterUpdate - groupAddress; + : ptNode.mChildren.mCachedAddressAfterUpdate - ptNodeAddress; buffer[index++] = - makeCharGroupFlags(group, groupAddress, childrenOffset, formatOptions); + makePtNodeFlags(ptNode, ptNodeAddress, childrenOffset, formatOptions); if (parentAddress == FormatSpec.NO_PARENT_ADDRESS) { index = writeParentAddress(buffer, index, parentAddress, formatOptions); } else { index = writeParentAddress(buffer, index, parentAddress - + (nodeArray.mCachedAddressAfterUpdate - group.mCachedAddressAfterUpdate), + + (ptNodeArray.mCachedAddressAfterUpdate + - ptNode.mCachedAddressAfterUpdate), formatOptions); } - index = CharEncoding.writeCharArray(group.mChars, buffer, index); - if (group.hasSeveralChars()) { - buffer[index++] = FormatSpec.GROUP_CHARACTERS_TERMINATOR; + index = CharEncoding.writeCharArray(ptNode.mChars, buffer, index); + if (ptNode.hasSeveralChars()) { + buffer[index++] = FormatSpec.PTNODE_CHARACTERS_TERMINATOR; } - if (group.mFrequency >= 0) { - buffer[index++] = (byte) group.mFrequency; + if (ptNode.mFrequency >= 0) { + buffer[index++] = (byte) ptNode.mFrequency; } final int shift; @@ -792,23 +794,24 @@ public class BinaryDictEncoder { shift = writeVariableAddress(buffer, index, childrenOffset); } index += shift; - groupAddress += shift; + ptNodeAddress += shift; // Write shortcuts - if (null != group.mShortcutTargets) { + if (null != ptNode.mShortcutTargets && !ptNode.mShortcutTargets.isEmpty()) { final int indexOfShortcutByteSize = index; - index += FormatSpec.GROUP_SHORTCUT_LIST_SIZE_SIZE; - groupAddress += FormatSpec.GROUP_SHORTCUT_LIST_SIZE_SIZE; - final Iterator<WeightedString> shortcutIterator = group.mShortcutTargets.iterator(); + index += FormatSpec.PTNODE_SHORTCUT_LIST_SIZE_SIZE; + ptNodeAddress += FormatSpec.PTNODE_SHORTCUT_LIST_SIZE_SIZE; + final Iterator<WeightedString> shortcutIterator = + ptNode.mShortcutTargets.iterator(); while (shortcutIterator.hasNext()) { final WeightedString target = shortcutIterator.next(); - ++groupAddress; + ++ptNodeAddress; int shortcutFlags = makeShortcutFlags(shortcutIterator.hasNext(), target.mFrequency); buffer[index++] = (byte)shortcutFlags; final int shortcutShift = CharEncoding.writeString(buffer, index, target.mWord); index += shortcutShift; - groupAddress += shortcutShift; + ptNodeAddress += shortcutShift; } final int shortcutByteSize = index - indexOfShortcutByteSize; if (shortcutByteSize > 0xFFFF) { @@ -818,22 +821,22 @@ public class BinaryDictEncoder { buffer[indexOfShortcutByteSize + 1] = (byte)(shortcutByteSize & 0xFF); } // Write bigrams - if (null != group.mBigrams) { - final Iterator<WeightedString> bigramIterator = group.mBigrams.iterator(); + if (null != ptNode.mBigrams) { + final Iterator<WeightedString> bigramIterator = ptNode.mBigrams.iterator(); while (bigramIterator.hasNext()) { final WeightedString bigram = bigramIterator.next(); - final CharGroup target = + final PtNode target = FusionDictionary.findWordInTree(dict.mRootNodeArray, bigram.mWord); final int addressOfBigram = target.mCachedAddressAfterUpdate; final int unigramFrequencyForThisWord = target.mFrequency; - ++groupAddress; - final int offset = addressOfBigram - groupAddress; + ++ptNodeAddress; + final int offset = addressOfBigram - ptNodeAddress; int bigramFlags = makeBigramFlags(bigramIterator.hasNext(), offset, bigram.mFrequency, unigramFrequencyForThisWord, bigram.mWord); buffer[index++] = (byte)bigramFlags; final int bigramShift = writeVariableAddress(buffer, index, Math.abs(offset)); index += bigramShift; - groupAddress += bigramShift; + ptNodeAddress += bigramShift; } } @@ -843,64 +846,64 @@ public class BinaryDictEncoder { = FormatSpec.NO_FORWARD_LINK_ADDRESS; index += FormatSpec.FORWARD_LINK_ADDRESS_SIZE; } - if (index != nodeArray.mCachedAddressAfterUpdate + nodeArray.mCachedSize) { + if (index != ptNodeArray.mCachedAddressAfterUpdate + ptNodeArray.mCachedSize) { throw new RuntimeException( - "Not the same size : written " + (index - nodeArray.mCachedAddressAfterUpdate) - + " bytes from a node that should have " + nodeArray.mCachedSize + " bytes"); + "Not the same size : written " + (index - ptNodeArray.mCachedAddressAfterUpdate) + + " bytes from a node that should have " + ptNodeArray.mCachedSize + " bytes"); } return index; } /** - * Dumps a collection of useful statistics about a list of node arrays. + * Dumps a collection of useful statistics about a list of PtNode arrays. * * This prints purely informative stuff, like the total estimated file size, the - * number of node arrays, of character groups, the repartition of each address size, etc + * number of PtNode arrays, of PtNodes, the repartition of each address size, etc * - * @param nodeArrays the list of node arrays. + * @param ptNodeArrays the list of PtNode arrays. */ - private static void showStatistics(ArrayList<PtNodeArray> nodeArrays) { + private static void showStatistics(ArrayList<PtNodeArray> ptNodeArrays) { int firstTerminalAddress = Integer.MAX_VALUE; int lastTerminalAddress = Integer.MIN_VALUE; int size = 0; - int charGroups = 0; - int maxGroups = 0; + int ptNodes = 0; + int maxNodes = 0; int maxRuns = 0; - for (final PtNodeArray nodeArray : nodeArrays) { - if (maxGroups < nodeArray.mData.size()) maxGroups = nodeArray.mData.size(); - for (final CharGroup cg : nodeArray.mData) { - ++charGroups; - if (cg.mChars.length > maxRuns) maxRuns = cg.mChars.length; - if (cg.mFrequency >= 0) { - if (nodeArray.mCachedAddressAfterUpdate < firstTerminalAddress) - firstTerminalAddress = nodeArray.mCachedAddressAfterUpdate; - if (nodeArray.mCachedAddressAfterUpdate > lastTerminalAddress) - lastTerminalAddress = nodeArray.mCachedAddressAfterUpdate; + for (final PtNodeArray ptNodeArray : ptNodeArrays) { + if (maxNodes < ptNodeArray.mData.size()) maxNodes = ptNodeArray.mData.size(); + for (final PtNode ptNode : ptNodeArray.mData) { + ++ptNodes; + if (ptNode.mChars.length > maxRuns) maxRuns = ptNode.mChars.length; + if (ptNode.mFrequency >= 0) { + if (ptNodeArray.mCachedAddressAfterUpdate < firstTerminalAddress) + firstTerminalAddress = ptNodeArray.mCachedAddressAfterUpdate; + if (ptNodeArray.mCachedAddressAfterUpdate > lastTerminalAddress) + lastTerminalAddress = ptNodeArray.mCachedAddressAfterUpdate; } } - if (nodeArray.mCachedAddressAfterUpdate + nodeArray.mCachedSize > size) { - size = nodeArray.mCachedAddressAfterUpdate + nodeArray.mCachedSize; + if (ptNodeArray.mCachedAddressAfterUpdate + ptNodeArray.mCachedSize > size) { + size = ptNodeArray.mCachedAddressAfterUpdate + ptNodeArray.mCachedSize; } } - final int[] groupCounts = new int[maxGroups + 1]; + final int[] ptNodeCounts = new int[maxNodes + 1]; final int[] runCounts = new int[maxRuns + 1]; - for (final PtNodeArray nodeArray : nodeArrays) { - ++groupCounts[nodeArray.mData.size()]; - for (final CharGroup cg : nodeArray.mData) { - ++runCounts[cg.mChars.length]; + for (final PtNodeArray ptNodeArray : ptNodeArrays) { + ++ptNodeCounts[ptNodeArray.mData.size()]; + for (final PtNode ptNode : ptNodeArray.mData) { + ++runCounts[ptNode.mChars.length]; } } MakedictLog.i("Statistics:\n" + " total file size " + size + "\n" - + " " + nodeArrays.size() + " node arrays\n" - + " " + charGroups + " groups (" + ((float)charGroups / nodeArrays.size()) - + " groups per node)\n" + + " " + ptNodeArrays.size() + " node arrays\n" + + " " + ptNodes + " PtNodes (" + ((float)ptNodes / ptNodeArrays.size()) + + " PtNodes per node)\n" + " first terminal at " + firstTerminalAddress + "\n" + " last terminal at " + lastTerminalAddress + "\n" - + " Group stats : max = " + maxGroups); - for (int i = 0; i < groupCounts.length; ++i) { - MakedictLog.i(" " + i + " : " + groupCounts[i]); + + " PtNode stats : max = " + maxNodes); + for (int i = 0; i < ptNodeCounts.length; ++i) { + MakedictLog.i(" " + i + " : " + ptNodeCounts[i]); } MakedictLog.i(" Character run stats : max = " + maxRuns); for (int i = 0; i < runCounts.length; ++i) { @@ -911,19 +914,17 @@ public class BinaryDictEncoder { /** * Dumps a FusionDictionary to a file. * - * This is the public entry point to write a dictionary to a file. - * * @param destination the stream to write the binary data to. * @param dict the dictionary to write. * @param formatOptions file format options. */ - public static void writeDictionaryBinary(final OutputStream destination, + /* package */ static void writeDictionaryBinary(final OutputStream destination, final FusionDictionary dict, final FormatOptions formatOptions) throws IOException, UnsupportedFormatException { // Addresses are limited to 3 bytes, but since addresses can be relative to each node // array, the structure itself is not limited to 16MB. However, if it is over 16MB deciding - // the order of the node arrays becomes a quite complicated problem, because though the + // the order of the PtNode arrays becomes a quite complicated problem, because though the // dictionary itself does not have a size limit, each node array must still be within 16MB // of all its children and parents. As long as this is ensured, the dictionary file may // grow to any size. @@ -981,8 +982,8 @@ public class BinaryDictEncoder { MakedictLog.i("Computing addresses..."); computeAddresses(dict, flatNodes, formatOptions); - MakedictLog.i("Checking array..."); - if (DBG) checkFlatNodeArrayList(flatNodes); + MakedictLog.i("Checking PtNode array..."); + if (DBG) checkFlatPtNodeArrayList(flatNodes); // Create a buffer that matches the final dictionary size. final PtNodeArray lastNodeArray = flatNodes.get(flatNodes.size() - 1); diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index 0fa2cf428..106f02519 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -22,7 +22,7 @@ import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.CharEncodin import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; import com.android.inputmethod.latin.utils.ByteArrayDictBuffer; @@ -44,17 +44,17 @@ public final class BinaryDictIOUtils { } private static final class Position { - public static final int NOT_READ_GROUPCOUNT = -1; + public static final int NOT_READ_PTNODE_COUNT = -1; public int mAddress; - public int mNumOfCharGroup; + public int mNumOfPtNode; public int mPosition; public int mLength; public Position(int address, int length) { mAddress = address; mLength = length; - mNumOfCharGroup = NOT_READ_GROUPCOUNT; + mNumOfPtNode = NOT_READ_PTNODE_COUNT; } } @@ -62,10 +62,11 @@ public final class BinaryDictIOUtils { * Retrieves all node arrays without recursive call. */ private static void readUnigramsAndBigramsBinaryInner( - final DictBuffer dictBuffer, final int headerSize, + final Ver3DictDecoder dictDecoder, final int headerSize, final Map<Integer, String> words, final Map<Integer, Integer> frequencies, final Map<Integer, ArrayList<PendingAttribute>> bigrams, final FormatOptions formatOptions) { + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); int[] pushedChars = new int[FormatSpec.MAX_WORD_LENGTH + 1]; Stack<Position> stack = new Stack<Position>(); @@ -78,46 +79,45 @@ public final class BinaryDictIOUtils { Position p = stack.peek(); if (DBG) { - MakedictLog.d("read: address=" + p.mAddress + ", numOfCharGroup=" + - p.mNumOfCharGroup + ", position=" + p.mPosition + ", length=" + p.mLength); + MakedictLog.d("read: address=" + p.mAddress + ", numOfPtNode=" + + p.mNumOfPtNode + ", position=" + p.mPosition + ", length=" + p.mLength); } if (dictBuffer.position() != p.mAddress) dictBuffer.position(p.mAddress); if (index != p.mLength) index = p.mLength; - if (p.mNumOfCharGroup == Position.NOT_READ_GROUPCOUNT) { - p.mNumOfCharGroup = BinaryDictDecoderUtils.readCharGroupCount(dictBuffer); - p.mAddress += getGroupCountSize(p.mNumOfCharGroup); + if (p.mNumOfPtNode == Position.NOT_READ_PTNODE_COUNT) { + p.mNumOfPtNode = BinaryDictDecoderUtils.readPtNodeCount(dictBuffer); + p.mAddress += getPtNodeCountSize(p.mNumOfPtNode); p.mPosition = 0; } - if (p.mNumOfCharGroup == 0) { + if (p.mNumOfPtNode == 0) { stack.pop(); continue; } - CharGroupInfo info = BinaryDictDecoderUtils.readCharGroup(dictBuffer, - p.mAddress - headerSize, formatOptions); + PtNodeInfo info = dictDecoder.readPtNode(p.mAddress, formatOptions); for (int i = 0; i < info.mCharacters.length; ++i) { pushedChars[index++] = info.mCharacters[i]; } p.mPosition++; - final boolean isMovedGroup = isMovedGroup(info.mFlags, + final boolean isMovedPtNode = isMovedPtNode(info.mFlags, formatOptions); - final boolean isDeletedGroup = isDeletedGroup(info.mFlags, + final boolean isDeletedPtNode = isDeletedPtNode(info.mFlags, formatOptions); - if (!isMovedGroup && !isDeletedGroup - && info.mFrequency != FusionDictionary.CharGroup.NOT_A_TERMINAL) {// found word + if (!isMovedPtNode && !isDeletedPtNode + && info.mFrequency != FusionDictionary.PtNode.NOT_A_TERMINAL) {// found word words.put(info.mOriginalAddress, new String(pushedChars, 0, index)); frequencies.put(info.mOriginalAddress, info.mFrequency); if (info.mBigrams != null) bigrams.put(info.mOriginalAddress, info.mBigrams); } - if (p.mPosition == p.mNumOfCharGroup) { + if (p.mPosition == p.mNumOfPtNode) { if (formatOptions.mSupportsDynamicUpdate) { final int forwardLinkAddress = dictBuffer.readUnsignedInt24(); if (forwardLinkAddress != FormatSpec.NO_FORWARD_LINK_ADDRESS) { // The node array has a forward link. - p.mNumOfCharGroup = Position.NOT_READ_GROUPCOUNT; + p.mNumOfPtNode = Position.NOT_READ_PTNODE_COUNT; p.mAddress = forwardLinkAddress; } else { stack.pop(); @@ -126,12 +126,12 @@ public final class BinaryDictIOUtils { stack.pop(); } } else { - // The node array has more groups. + // The Ptnode array has more PtNodes. p.mAddress = dictBuffer.position(); } - if (!isMovedGroup && hasChildrenAddress(info.mChildrenAddress)) { - Position childrenPos = new Position(info.mChildrenAddress + headerSize, index); + if (!isMovedPtNode && hasChildrenAddress(info.mChildrenAddress)) { + final Position childrenPos = new Position(info.mChildrenAddress, index); stack.push(childrenPos); } } @@ -148,18 +148,18 @@ public final class BinaryDictIOUtils { * @throws IOException if the file can't be read. * @throws UnsupportedFormatException if the format of the file is not recognized. */ - public static void readUnigramsAndBigramsBinary(final Ver3DictDecoder dictDecoder, + /* package */ static void readUnigramsAndBigramsBinary(final Ver3DictDecoder dictDecoder, final Map<Integer, String> words, final Map<Integer, Integer> frequencies, final Map<Integer, ArrayList<PendingAttribute>> bigrams) throws IOException, UnsupportedFormatException { // Read header final FileHeader header = dictDecoder.readHeader(); - readUnigramsAndBigramsBinaryInner(dictDecoder.getDictBuffer(), header.mHeaderSize, words, + readUnigramsAndBigramsBinaryInner(dictDecoder, header.mHeaderSize, words, frequencies, bigrams, header.mFormatOptions); } /** - * Gets the address of the last CharGroup of the exact matching word in the dictionary. + * Gets the address of the last PtNode of the exact matching word in the dictionary. * If no match is found, returns NOT_VALID_WORD. * * @param dictDecoder the dict decoder. @@ -169,7 +169,7 @@ public final class BinaryDictIOUtils { * @throws UnsupportedFormatException if the format of the file is not recognized. */ @UsedForTesting - public static int getTerminalPosition(final Ver3DictDecoder dictDecoder, + /* package */ static int getTerminalPosition(final Ver3DictDecoder dictDecoder, final String word) throws IOException, UnsupportedFormatException { final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); if (word == null) return FormatSpec.NOT_VALID_WORD; @@ -182,17 +182,17 @@ public final class BinaryDictIOUtils { if (wordPos >= wordLen) return FormatSpec.NOT_VALID_WORD; do { - final int charGroupCount = BinaryDictDecoderUtils.readCharGroupCount(dictBuffer); - boolean foundNextCharGroup = false; - for (int i = 0; i < charGroupCount; ++i) { - final int charGroupPos = dictBuffer.position(); - final CharGroupInfo currentInfo = BinaryDictDecoderUtils.readCharGroup( - dictBuffer, dictBuffer.position(), header.mFormatOptions); - final boolean isMovedGroup = isMovedGroup(currentInfo.mFlags, + final int ptNodeCount = BinaryDictDecoderUtils.readPtNodeCount(dictBuffer); + boolean foundNextPtNode = false; + for (int i = 0; i < ptNodeCount; ++i) { + final int ptNodePos = dictBuffer.position(); + final PtNodeInfo currentInfo = dictDecoder.readPtNode(ptNodePos, + header.mFormatOptions); + final boolean isMovedNode = isMovedPtNode(currentInfo.mFlags, header.mFormatOptions); - final boolean isDeletedGroup = isDeletedGroup(currentInfo.mFlags, + final boolean isDeletedNode = isDeletedPtNode(currentInfo.mFlags, header.mFormatOptions); - if (isMovedGroup) continue; + if (isMovedNode) continue; boolean same = true; for (int p = 0, j = word.offsetByCodePoints(0, wordPos); p < currentInfo.mCharacters.length; @@ -205,30 +205,30 @@ public final class BinaryDictIOUtils { } if (same) { - // found the group matches the word. + // found the PtNode matches the word. if (wordPos + currentInfo.mCharacters.length == wordLen) { - if (currentInfo.mFrequency == CharGroup.NOT_A_TERMINAL - || isDeletedGroup) { + if (currentInfo.mFrequency == PtNode.NOT_A_TERMINAL + || isDeletedNode) { return FormatSpec.NOT_VALID_WORD; } else { - return charGroupPos; + return ptNodePos; } } wordPos += currentInfo.mCharacters.length; if (currentInfo.mChildrenAddress == FormatSpec.NO_CHILDREN_ADDRESS) { return FormatSpec.NOT_VALID_WORD; } - foundNextCharGroup = true; + foundNextPtNode = true; dictBuffer.position(currentInfo.mChildrenAddress); break; } } - // If we found the next char group, it is under the file pointer. + // If we found the next PtNode, it is under the file pointer. // But if not, we are at the end of this node array so we expect to have // a forward link address that we need to consult and possibly resume // search on the next node array in the linked list. - if (foundNextCharGroup) break; + if (foundNextPtNode) break; if (!header.mFormatOptions.mSupportsDynamicUpdate) { return FormatSpec.NOT_VALID_WORD; } @@ -272,7 +272,7 @@ public final class BinaryDictIOUtils { */ private static int writeVariableAddress(final OutputStream destination, final int value) throws IOException { - switch (BinaryDictEncoder.getByteSize(value)) { + switch (BinaryDictEncoderUtils.getByteSize(value)) { case 1: destination.write((byte)value); break; @@ -286,11 +286,10 @@ public final class BinaryDictIOUtils { destination.write((byte)(0xFF & value)); break; } - return BinaryDictEncoder.getByteSize(value); + return BinaryDictEncoderUtils.getByteSize(value); } - static void skipCharGroup(final DictBuffer dictBuffer, - final FormatOptions formatOptions) { + static void skipPtNode(final DictBuffer dictBuffer, final FormatOptions formatOptions) { final int flags = dictBuffer.readUnsignedByte(); BinaryDictDecoderUtils.readParentAddress(dictBuffer, formatOptions); skipString(dictBuffer, (flags & FormatSpec.FLAG_HAS_MULTIPLE_CHARS) != 0); @@ -299,27 +298,27 @@ public final class BinaryDictIOUtils { if ((flags & FormatSpec.FLAG_HAS_SHORTCUT_TARGETS) != 0) { final int shortcutsSize = dictBuffer.readUnsignedShort(); dictBuffer.position(dictBuffer.position() + shortcutsSize - - FormatSpec.GROUP_SHORTCUT_LIST_SIZE_SIZE); + - FormatSpec.PTNODE_SHORTCUT_LIST_SIZE_SIZE); } if ((flags & FormatSpec.FLAG_HAS_BIGRAMS) != 0) { int bigramCount = 0; - while (bigramCount++ < FormatSpec.MAX_BIGRAMS_IN_A_GROUP) { + while (bigramCount++ < FormatSpec.MAX_BIGRAMS_IN_A_PTNODE) { final int bigramFlags = dictBuffer.readUnsignedByte(); - switch (bigramFlags & FormatSpec.MASK_ATTRIBUTE_ADDRESS_TYPE) { - case FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE: + switch (bigramFlags & FormatSpec.MASK_BIGRAM_ATTR_ADDRESS_TYPE) { + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE: dictBuffer.readUnsignedByte(); break; - case FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_TWOBYTES: + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES: dictBuffer.readUnsignedShort(); break; - case FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_THREEBYTES: + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES: dictBuffer.readUnsignedInt24(); break; } - if ((bigramFlags & FormatSpec.FLAG_ATTRIBUTE_HAS_NEXT) == 0) break; + if ((bigramFlags & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT) == 0) break; } - if (bigramCount >= FormatSpec.MAX_BIGRAMS_IN_A_GROUP) { - throw new RuntimeException("Too many bigrams in a group."); + if (bigramCount >= FormatSpec.MAX_BIGRAMS_IN_A_PTNODE) { + throw new RuntimeException("Too many bigrams in a PtNode."); } } } @@ -360,24 +359,24 @@ public final class BinaryDictIOUtils { size += 3; } } - destination.write((byte)FormatSpec.GROUP_CHARACTERS_TERMINATOR); - size += FormatSpec.GROUP_TERMINATOR_SIZE; + destination.write((byte)FormatSpec.PTNODE_CHARACTERS_TERMINATOR); + size += FormatSpec.PTNODE_TERMINATOR_SIZE; return size; } /** - * Write a char group to an output stream from a CharGroupInfo. - * A char group is an in-memory representation of a node in the patricia trie. - * A char group info is a container for low-level information about how the - * char group is stored in the binary format. + * Write a PtNode to an output stream from a PtNodeInfo. + * A PtNode is an in-memory representation of a node in the patricia trie. + * A PtNode info is a container for low-level information about how the + * PtNode is stored in the binary format. * * @param destination the stream to write. - * @param info the char group info to be written. + * @param info the PtNode info to be written. * @return the size written, in bytes. */ - public static int writeCharGroup(final OutputStream destination, final CharGroupInfo info) + private static int writePtNode(final OutputStream destination, final PtNodeInfo info) throws IOException { - int size = FormatSpec.GROUP_FLAGS_SIZE; + int size = FormatSpec.PTNODE_FLAGS_SIZE; destination.write((byte)info.mFlags); final int parentOffset = info.mParentAddress == FormatSpec.NO_PARENT_ADDRESS ? FormatSpec.NO_PARENT_ADDRESS : info.mParentAddress - info.mOriginalAddress; @@ -392,7 +391,7 @@ public final class BinaryDictIOUtils { } } if (info.mCharacters.length > 1) { - destination.write((byte)FormatSpec.GROUP_CHARACTERS_TERMINATOR); + destination.write((byte)FormatSpec.PTNODE_CHARACTERS_TERMINATOR); size++; } @@ -402,7 +401,7 @@ public final class BinaryDictIOUtils { } if (DBG) { - MakedictLog.d("writeCharGroup origin=" + info.mOriginalAddress + ", size=" + size + MakedictLog.d("writePtNode origin=" + info.mOriginalAddress + ", size=" + size + ", child=" + info.mChildrenAddress + ", characters =" + new String(info.mCharacters, 0, info.mCharacters.length)); } @@ -413,14 +412,14 @@ public final class BinaryDictIOUtils { if (info.mShortcutTargets != null && info.mShortcutTargets.size() > 0) { final int shortcutListSize = - BinaryDictEncoder.getShortcutListSize(info.mShortcutTargets); + BinaryDictEncoderUtils.getShortcutListSize(info.mShortcutTargets); destination.write((byte)(shortcutListSize >> 8)); destination.write((byte)(shortcutListSize & 0xFF)); size += 2; final Iterator<WeightedString> shortcutIterator = info.mShortcutTargets.iterator(); while (shortcutIterator.hasNext()) { final WeightedString target = shortcutIterator.next(); - destination.write((byte)BinaryDictEncoder.makeShortcutFlags( + destination.write((byte)BinaryDictEncoderUtils.makeShortcutFlags( shortcutIterator.hasNext(), target.mFrequency)); size++; size += writeString(destination, target.mWord); @@ -429,28 +428,28 @@ public final class BinaryDictIOUtils { if (info.mBigrams != null) { // TODO: Consolidate this code with the code that computes the size of the bigram list - // in BinaryDictEncoder#computeActualNodeArraySize + // in BinaryDictEncoderUtils#computeActualNodeArraySize for (int i = 0; i < info.mBigrams.size(); ++i) { final int bigramFrequency = info.mBigrams.get(i).mFrequency; int bigramFlags = (i < info.mBigrams.size() - 1) - ? FormatSpec.FLAG_ATTRIBUTE_HAS_NEXT : 0; + ? FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT : 0; size++; final int bigramOffset = info.mBigrams.get(i).mAddress - (info.mOriginalAddress + size); - bigramFlags |= (bigramOffset < 0) ? FormatSpec.FLAG_ATTRIBUTE_OFFSET_NEGATIVE : 0; - switch (BinaryDictEncoder.getByteSize(bigramOffset)) { + bigramFlags |= (bigramOffset < 0) ? FormatSpec.FLAG_BIGRAM_ATTR_OFFSET_NEGATIVE : 0; + switch (BinaryDictEncoderUtils.getByteSize(bigramOffset)) { case 1: - bigramFlags |= FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE; + bigramFlags |= FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE; break; case 2: - bigramFlags |= FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_TWOBYTES; + bigramFlags |= FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES; break; case 3: - bigramFlags |= FormatSpec.FLAG_ATTRIBUTE_ADDRESS_TYPE_THREEBYTES; + bigramFlags |= FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES; break; } - bigramFlags |= bigramFrequency & FormatSpec.FLAG_ATTRIBUTE_FREQUENCY; + bigramFlags |= bigramFrequency & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY; destination.write((byte)bigramFlags); size += writeVariableAddress(destination, Math.abs(bigramOffset)); } @@ -459,22 +458,22 @@ public final class BinaryDictIOUtils { } /** - * Compute the size of the char group. + * Compute the size of the PtNode. */ - static int computeGroupSize(final CharGroupInfo info, final FormatOptions formatOptions) { - int size = FormatSpec.GROUP_FLAGS_SIZE + FormatSpec.PARENT_ADDRESS_SIZE - + BinaryDictEncoder.getGroupCharactersSize(info.mCharacters) + static int computePtNodeSize(final PtNodeInfo info, final FormatOptions formatOptions) { + int size = FormatSpec.PTNODE_FLAGS_SIZE + FormatSpec.PARENT_ADDRESS_SIZE + + BinaryDictEncoderUtils.getPtNodeCharactersSize(info.mCharacters) + getChildrenAddressSize(info.mFlags, formatOptions); if ((info.mFlags & FormatSpec.FLAG_IS_TERMINAL) != 0) { - size += FormatSpec.GROUP_FREQUENCY_SIZE; + size += FormatSpec.PTNODE_FREQUENCY_SIZE; } if (info.mShortcutTargets != null && !info.mShortcutTargets.isEmpty()) { - size += BinaryDictEncoder.getShortcutListSize(info.mShortcutTargets); + size += BinaryDictEncoderUtils.getShortcutListSize(info.mShortcutTargets); } if (info.mBigrams != null) { for (final PendingAttribute attr : info.mBigrams) { - size += FormatSpec.GROUP_FLAGS_SIZE; - size += BinaryDictEncoder.getByteSize(attr.mAddress); + size += FormatSpec.PTNODE_FLAGS_SIZE; + size += BinaryDictEncoderUtils.getByteSize(attr.mAddress); } } return size; @@ -484,14 +483,14 @@ public final class BinaryDictIOUtils { * Write a node array to the stream. * * @param destination the stream to write. - * @param infos an array of CharGroupInfo to be written. + * @param infos an array of PtNodeInfo to be written. * @return the size written, in bytes. * @throws IOException */ - static int writeNodes(final OutputStream destination, final CharGroupInfo[] infos) + static int writeNodes(final OutputStream destination, final PtNodeInfo[] infos) throws IOException { - int size = getGroupCountSize(infos.length); - switch (getGroupCountSize(infos.length)) { + int size = getPtNodeCountSize(infos.length); + switch (getPtNodeCountSize(infos.length)) { case 1: destination.write((byte)infos.length); break; @@ -500,37 +499,13 @@ public final class BinaryDictIOUtils { destination.write((byte)(infos.length & 0xFF)); break; default: - throw new RuntimeException("Invalid group count size."); + throw new RuntimeException("Invalid node count size."); } - for (final CharGroupInfo info : infos) size += writeCharGroup(destination, info); + for (final PtNodeInfo info : infos) size += writePtNode(destination, info); writeSInt24ToStream(destination, FormatSpec.NO_FORWARD_LINK_ADDRESS); return size + FormatSpec.FORWARD_LINK_ADDRESS_SIZE; } - /** - * Find a word using the Ver3DictDecoder. - * - * @param dictDecoder the dict reader - * @param word the word searched - * @return the found group - * @throws IOException - * @throws UnsupportedFormatException - */ - @UsedForTesting - public static CharGroupInfo findWordByBinaryDictReader(final Ver3DictDecoder dictDecoder, - final String word) throws IOException, UnsupportedFormatException { - int position = getTerminalPosition(dictDecoder, word); - final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); - if (position != FormatSpec.NOT_VALID_WORD) { - dictBuffer.position(0); - final FileHeader header = dictDecoder.readHeader(); - dictBuffer.position(position); - return BinaryDictDecoderUtils.readCharGroup(dictBuffer, position, - header.mFormatOptions); - } - return null; - } - private static final int HEADER_READING_BUFFER_SIZE = 16384; /** * Convenience method to read the header of a binary file. @@ -541,24 +516,26 @@ public final class BinaryDictIOUtils { * @param offset The offset in the file where to start reading the data. * @param length The length of the data file. */ - public static FileHeader getDictionaryFileHeader( + private static FileHeader getDictionaryFileHeader( final File file, final long offset, final long length) throws FileNotFoundException, IOException, UnsupportedFormatException { final byte[] buffer = new byte[HEADER_READING_BUFFER_SIZE]; - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); - dictDecoder.openDictBuffer(new DictDecoder.DictionaryBufferFactory() { - @Override - public DictBuffer getDictionaryBuffer(File file) - throws FileNotFoundException, IOException { - final FileInputStream inStream = new FileInputStream(file); - try { - inStream.read(buffer); - return new ByteArrayDictBuffer(buffer); - } finally { - inStream.close(); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file, + new DictDecoder.DictionaryBufferFactory() { + @Override + public DictBuffer getDictionaryBuffer(File file) + throws FileNotFoundException, IOException { + final FileInputStream inStream = new FileInputStream(file); + try { + inStream.skip(offset); + inStream.read(buffer); + return new ByteArrayDictBuffer(buffer); + } finally { + inStream.close(); + } + } } - } - }); + ); return dictDecoder.readHeader(); } @@ -582,11 +559,11 @@ public final class BinaryDictIOUtils { } /** - * Helper method to check whether the group is moved. + * Helper method to check whether the node is moved. */ - public static boolean isMovedGroup(final int flags, final FormatOptions options) { + public static boolean isMovedPtNode(final int flags, final FormatOptions options) { return options.mSupportsDynamicUpdate - && ((flags & FormatSpec.MASK_GROUP_ADDRESS_TYPE) == FormatSpec.FLAG_IS_MOVED); + && ((flags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) == FormatSpec.FLAG_IS_MOVED); } /** @@ -598,26 +575,26 @@ public final class BinaryDictIOUtils { } /** - * Helper method to check whether the group is deleted. + * Helper method to check whether the node is deleted. */ - public static boolean isDeletedGroup(final int flags, final FormatOptions formatOptions) { + public static boolean isDeletedPtNode(final int flags, final FormatOptions formatOptions) { return formatOptions.mSupportsDynamicUpdate - && ((flags & FormatSpec.MASK_GROUP_ADDRESS_TYPE) == FormatSpec.FLAG_IS_DELETED); + && ((flags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) == FormatSpec.FLAG_IS_DELETED); } /** - * Compute the binary size of the group count - * @param count the group count - * @return the size of the group count, either 1 or 2 bytes. + * Compute the binary size of the node count + * @param count the node count + * @return the size of the node count, either 1 or 2 bytes. */ - public static int getGroupCountSize(final int count) { - if (FormatSpec.MAX_CHARGROUPS_FOR_ONE_BYTE_CHARGROUP_COUNT >= count) { + public static int getPtNodeCountSize(final int count) { + if (FormatSpec.MAX_PTNODES_FOR_ONE_BYTE_PTNODE_COUNT >= count) { return 1; - } else if (FormatSpec.MAX_CHARGROUPS_IN_A_PT_NODE_ARRAY >= count) { + } else if (FormatSpec.MAX_PTNODES_IN_A_PT_NODE_ARRAY >= count) { return 2; } else { throw new RuntimeException("Can't have more than " - + FormatSpec.MAX_CHARGROUPS_IN_A_PT_NODE_ARRAY + " groups in a node (found " + + FormatSpec.MAX_PTNODES_IN_A_PT_NODE_ARRAY + " PtNode in a PtNodeArray (found " + count + ")"); } } @@ -625,14 +602,14 @@ public final class BinaryDictIOUtils { static int getChildrenAddressSize(final int optionFlags, final FormatOptions formatOptions) { if (formatOptions.mSupportsDynamicUpdate) return FormatSpec.SIGNED_CHILDREN_ADDRESS_SIZE; - switch (optionFlags & FormatSpec.MASK_GROUP_ADDRESS_TYPE) { - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_ONEBYTE: + switch (optionFlags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) { + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE: return 1; - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_TWOBYTES: + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES: return 2; - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_THREEBYTES: + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES: return 3; - case FormatSpec.FLAG_GROUP_ADDRESS_TYPE_NOADDRESS: + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS: default: return 0; } diff --git a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java index a63d9d5ba..11a3f0b3a 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/DictDecoder.java @@ -19,6 +19,7 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; +import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.utils.ByteArrayDictBuffer; import java.io.File; @@ -28,6 +29,8 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.util.ArrayList; +import java.util.TreeMap; /** * An interface of binary dictionary decoder. @@ -35,6 +38,62 @@ import java.nio.channels.FileChannel; public interface DictDecoder { public FileHeader readHeader() throws IOException, UnsupportedFormatException; + /** + * Reads PtNode from nodeAddress. + * @param ptNodePos the position of PtNode. + * @param formatOptions the format options. + * @return PtNodeInfo. + */ + public PtNodeInfo readPtNode(final int ptNodePos, final FormatOptions formatOptions); + + /** + * Reads a buffer and returns the memory representation of the dictionary. + * + * This high-level method takes a buffer and reads its contents, populating a + * FusionDictionary structure. The optional dict argument is an existing dictionary to + * which words from the buffer should be added. If it is null, a new dictionary is created. + * + * @param dict an optional dictionary to add words to, or null. + * @return the created (or merged) dictionary. + */ + @UsedForTesting + public FusionDictionary readDictionaryBinary(final FusionDictionary dict) + throws FileNotFoundException, IOException, UnsupportedFormatException; + + /** + * Gets the address of the last PtNode of the exact matching word in the dictionary. + * If no match is found, returns NOT_VALID_WORD. + * + * @param word the word we search for. + * @return the address of the terminal node. + * @throws IOException if the file can't be read. + * @throws UnsupportedFormatException if the format of the file is not recognized. + */ + @UsedForTesting + public int getTerminalPosition(final String word) + throws IOException, UnsupportedFormatException; + + /** + * Reads unigrams and bigrams from the binary file. + * Doesn't store a full memory representation of the dictionary. + * + * @param words the map to store the address as a key and the word as a value. + * @param frequencies the map to store the address as a key and the frequency as a value. + * @param bigrams the map to store the address as a key and the list of address as a value. + * @throws IOException if the file can't be read. + * @throws UnsupportedFormatException if the format of the file is not recognized. + */ + public void readUnigramsAndBigramsBinary(final TreeMap<Integer, String> words, + final TreeMap<Integer, Integer> frequencies, + final TreeMap<Integer, ArrayList<PendingAttribute>> bigrams) + throws IOException, UnsupportedFormatException; + + // Flags for DictionaryBufferFactory. + public static final int USE_READONLY_BYTEBUFFER = 0x01000000; + public static final int USE_BYTEARRAY = 0x02000000; + public static final int USE_WRITABLE_BYTEBUFFER = 0x04000000; + public static final int MASK_DICTBUFFER = 0x0F000000; + public interface DictionaryBufferFactory { public DictBuffer getDictionaryBuffer(final File file) throws FileNotFoundException, IOException; diff --git a/java/src/com/android/inputmethod/latin/makedict/DictEncoder.java b/java/src/com/android/inputmethod/latin/makedict/DictEncoder.java new file mode 100644 index 000000000..89c982e7b --- /dev/null +++ b/java/src/com/android/inputmethod/latin/makedict/DictEncoder.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.makedict; + +import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; + +import java.io.IOException; + +/** + * An interface of binary dictionary encoder. + */ +public interface DictEncoder { + public void writeDictionary(final FusionDictionary dict, final FormatOptions formatOptions) + throws IOException, UnsupportedFormatException; +} diff --git a/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java index 99deaa4f9..bf3d19101 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/DynamicBinaryDictIOUtils.java @@ -43,7 +43,7 @@ public final class DynamicBinaryDictIOUtils { } private static int markAsDeleted(final int flags) { - return (flags & (~FormatSpec.MASK_GROUP_ADDRESS_TYPE)) | FormatSpec.FLAG_IS_DELETED; + return (flags & (~FormatSpec.MASK_CHILDREN_ADDRESS_TYPE)) | FormatSpec.FLAG_IS_DELETED; } /** @@ -60,7 +60,7 @@ public final class DynamicBinaryDictIOUtils { final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); dictBuffer.position(0); final FileHeader header = dictDecoder.readHeader(); - final int wordPosition = BinaryDictIOUtils.getTerminalPosition(dictDecoder, word); + final int wordPosition = dictDecoder.getTerminalPosition(word); if (wordPosition == FormatSpec.NOT_VALID_WORD) return; dictBuffer.position(wordPosition); @@ -70,56 +70,56 @@ public final class DynamicBinaryDictIOUtils { } /** - * Update a parent address in a CharGroup that is referred to by groupOriginAddress. + * Update a parent address in a PtNode that is referred to by ptNodeOriginAddress. * * @param dictBuffer the DictBuffer to write. - * @param groupOriginAddress the address of the group. + * @param ptNodeOriginAddress the address of the PtNode. * @param newParentAddress the absolute address of the parent. * @param formatOptions file format options. */ public static void updateParentAddress(final DictBuffer dictBuffer, - final int groupOriginAddress, final int newParentAddress, + final int ptNodeOriginAddress, final int newParentAddress, final FormatOptions formatOptions) { final int originalPosition = dictBuffer.position(); - dictBuffer.position(groupOriginAddress); + dictBuffer.position(ptNodeOriginAddress); if (!formatOptions.mSupportsDynamicUpdate) { throw new RuntimeException("this file format does not support parent addresses"); } final int flags = dictBuffer.readUnsignedByte(); - if (BinaryDictIOUtils.isMovedGroup(flags, formatOptions)) { - // If the group is moved, the parent address is stored in the destination group. - // We are guaranteed to process the destination group later, so there is no need to + if (BinaryDictIOUtils.isMovedPtNode(flags, formatOptions)) { + // If the node is moved, the parent address is stored in the destination node. + // We are guaranteed to process the destination node later, so there is no need to // update anything here. dictBuffer.position(originalPosition); return; } if (DBG) { - MakedictLog.d("update parent address flags=" + flags + ", " + groupOriginAddress); + MakedictLog.d("update parent address flags=" + flags + ", " + ptNodeOriginAddress); } - final int parentOffset = newParentAddress - groupOriginAddress; + final int parentOffset = newParentAddress - ptNodeOriginAddress; BinaryDictIOUtils.writeSInt24ToBuffer(dictBuffer, parentOffset); dictBuffer.position(originalPosition); } /** - * Update parent addresses in a node array stored at nodeOriginAddress. + * Update parent addresses in a node array stored at ptNodeOriginAddress. * * @param dictBuffer the DictBuffer to be modified. - * @param nodeOriginAddress the address of the node array to update. + * @param ptNodeOriginAddress the address of the node array to update. * @param newParentAddress the address to be written. * @param formatOptions file format options. */ public static void updateParentAddresses(final DictBuffer dictBuffer, - final int nodeOriginAddress, final int newParentAddress, + final int ptNodeOriginAddress, final int newParentAddress, final FormatOptions formatOptions) { final int originalPosition = dictBuffer.position(); - dictBuffer.position(nodeOriginAddress); + dictBuffer.position(ptNodeOriginAddress); do { - final int count = BinaryDictDecoderUtils.readCharGroupCount(dictBuffer); + final int count = BinaryDictDecoderUtils.readPtNodeCount(dictBuffer); for (int i = 0; i < count; ++i) { updateParentAddress(dictBuffer, dictBuffer.position(), newParentAddress, formatOptions); - BinaryDictIOUtils.skipCharGroup(dictBuffer, formatOptions); + BinaryDictIOUtils.skipPtNode(dictBuffer, formatOptions); } final int forwardLinkAddress = dictBuffer.readUnsignedInt24(); dictBuffer.position(forwardLinkAddress); @@ -129,18 +129,18 @@ public final class DynamicBinaryDictIOUtils { } /** - * Update a children address in a CharGroup that is addressed by groupOriginAddress. + * Update a children address in a PtNode that is addressed by ptNodeOriginAddress. * * @param dictBuffer the DictBuffer to write. - * @param groupOriginAddress the address of the group. + * @param ptNodeOriginAddress the address of the PtNode. * @param newChildrenAddress the absolute address of the child. * @param formatOptions file format options. */ public static void updateChildrenAddress(final DictBuffer dictBuffer, - final int groupOriginAddress, final int newChildrenAddress, + final int ptNodeOriginAddress, final int newChildrenAddress, final FormatOptions formatOptions) { final int originalPosition = dictBuffer.position(); - dictBuffer.position(groupOriginAddress); + dictBuffer.position(ptNodeOriginAddress); final int flags = dictBuffer.readUnsignedByte(); final int parentAddress = BinaryDictDecoderUtils.readParentAddress(dictBuffer, formatOptions); @@ -153,21 +153,21 @@ public final class DynamicBinaryDictIOUtils { } /** - * Helper method to move a char group to the tail of the file. + * Helper method to move a PtNode to the tail of the file. */ - private static int moveCharGroup(final OutputStream destination, - final DictBuffer dictBuffer, final CharGroupInfo info, - final int nodeArrayOriginAddress, final int oldGroupAddress, + private static int movePtNode(final OutputStream destination, + final DictBuffer dictBuffer, final PtNodeInfo info, + final int nodeArrayOriginAddress, final int oldNodeAddress, final FormatOptions formatOptions) throws IOException { - updateParentAddress(dictBuffer, oldGroupAddress, dictBuffer.limit() + 1, formatOptions); - dictBuffer.position(oldGroupAddress); + updateParentAddress(dictBuffer, oldNodeAddress, dictBuffer.limit() + 1, formatOptions); + dictBuffer.position(oldNodeAddress); final int currentFlags = dictBuffer.readUnsignedByte(); - dictBuffer.position(oldGroupAddress); + dictBuffer.position(oldNodeAddress); dictBuffer.put((byte)(FormatSpec.FLAG_IS_MOVED | (currentFlags & (~FormatSpec.MASK_MOVE_AND_DELETE_FLAG)))); - int size = FormatSpec.GROUP_FLAGS_SIZE; + int size = FormatSpec.PTNODE_FLAGS_SIZE; updateForwardLink(dictBuffer, nodeArrayOriginAddress, dictBuffer.limit(), formatOptions); - size += BinaryDictIOUtils.writeNodes(destination, new CharGroupInfo[] { info }); + size += BinaryDictIOUtils.writeNodes(destination, new PtNodeInfo[] { info }); return size; } @@ -178,9 +178,9 @@ public final class DynamicBinaryDictIOUtils { dictBuffer.position(nodeArrayOriginAddress); int jumpCount = 0; while (jumpCount++ < MAX_JUMPS) { - final int count = BinaryDictDecoderUtils.readCharGroupCount(dictBuffer); + final int count = BinaryDictDecoderUtils.readPtNodeCount(dictBuffer); for (int i = 0; i < count; ++i) { - BinaryDictIOUtils.skipCharGroup(dictBuffer, formatOptions); + BinaryDictIOUtils.skipPtNode(dictBuffer, formatOptions); } final int forwardLinkAddress = dictBuffer.readUnsignedInt24(); if (forwardLinkAddress == FormatSpec.NO_FORWARD_LINK_ADDRESS) { @@ -196,43 +196,43 @@ public final class DynamicBinaryDictIOUtils { } /** - * Move a group that is referred to by oldGroupOrigin to the tail of the file, and set the - * children address to the byte after the group + * Move a PtNode that is referred to by oldPtNodeOrigin to the tail of the file, and set the + * children address to the byte after the PtNode. * * @param fileEndAddress the address of the tail of the file. - * @param codePoints the characters to put inside the group. + * @param codePoints the characters to put inside the PtNode. * @param length how many code points to read from codePoints. - * @param flags the flags for this group. + * @param flags the flags for this PtNode. * @param frequency the frequency of this terminal. - * @param parentAddress the address of the parent group of this group. - * @param shortcutTargets the shortcut targets for this group. - * @param bigrams the bigrams for this group. + * @param parentAddress the address of the parent PtNode of this PtNode. + * @param shortcutTargets the shortcut targets for this PtNode. + * @param bigrams the bigrams for this PtNode. * @param destination the stream representing the tail of the file. * @param dictBuffer the DictBuffer representing the (constant-size) body of the file. - * @param oldNodeArrayOrigin the origin of the old node array this group was a part of. - * @param oldGroupOrigin the old origin where this group used to be stored. + * @param oldPtNodeArrayOrigin the origin of the old PtNode array this PtNode was a part of. + * @param oldPtNodeOrigin the old origin where this PtNode used to be stored. * @param formatOptions format options for this dictionary. * @return the size written, in bytes. * @throws IOException if the file can't be accessed */ - private static int moveGroup(final int fileEndAddress, final int[] codePoints, + private static int movePtNode(final int fileEndAddress, final int[] codePoints, final int length, final int flags, final int frequency, final int parentAddress, final ArrayList<WeightedString> shortcutTargets, final ArrayList<PendingAttribute> bigrams, final OutputStream destination, - final DictBuffer dictBuffer, final int oldNodeArrayOrigin, - final int oldGroupOrigin, final FormatOptions formatOptions) throws IOException { + final DictBuffer dictBuffer, final int oldPtNodeArrayOrigin, + final int oldPtNodeOrigin, final FormatOptions formatOptions) throws IOException { int size = 0; - final int newGroupOrigin = fileEndAddress + 1; + final int newPtNodeOrigin = fileEndAddress + 1; final int[] writtenCharacters = Arrays.copyOfRange(codePoints, 0, length); - final CharGroupInfo tmpInfo = new CharGroupInfo(newGroupOrigin, -1 /* endAddress */, + final PtNodeInfo tmpInfo = new PtNodeInfo(newPtNodeOrigin, -1 /* endAddress */, flags, writtenCharacters, frequency, parentAddress, FormatSpec.NO_CHILDREN_ADDRESS, shortcutTargets, bigrams); - size = BinaryDictIOUtils.computeGroupSize(tmpInfo, formatOptions); - final CharGroupInfo newInfo = new CharGroupInfo(newGroupOrigin, newGroupOrigin + size, + size = BinaryDictIOUtils.computePtNodeSize(tmpInfo, formatOptions); + final PtNodeInfo newInfo = new PtNodeInfo(newPtNodeOrigin, newPtNodeOrigin + size, flags, writtenCharacters, frequency, parentAddress, fileEndAddress + 1 + size + FormatSpec.FORWARD_LINK_ADDRESS_SIZE, shortcutTargets, bigrams); - moveCharGroup(destination, dictBuffer, newInfo, oldNodeArrayOrigin, oldGroupOrigin, + movePtNode(destination, dictBuffer, newInfo, oldPtNodeArrayOrigin, oldPtNodeOrigin, formatOptions); return 1 + size + FormatSpec.FORWARD_LINK_ADDRESS_SIZE; } @@ -263,7 +263,7 @@ public final class DynamicBinaryDictIOUtils { final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); if (bigramStrings != null) { for (final WeightedString bigram : bigramStrings) { - int position = BinaryDictIOUtils.getTerminalPosition(dictDecoder, bigram.mWord); + int position = dictDecoder.getTerminalPosition(bigram.mWord); if (position == FormatSpec.NOT_VALID_WORD) { // TODO: figure out what is the correct thing to do here. } else { @@ -288,16 +288,16 @@ public final class DynamicBinaryDictIOUtils { if (wordPos >= wordLen) break; nodeOriginAddress = dictBuffer.position(); int nodeParentAddress = -1; - final int charGroupCount = BinaryDictDecoderUtils.readCharGroupCount(dictBuffer); - boolean foundNextGroup = false; + final int ptNodeCount = BinaryDictDecoderUtils.readPtNodeCount(dictBuffer); + boolean foundNextNode = false; - for (int i = 0; i < charGroupCount; ++i) { + for (int i = 0; i < ptNodeCount; ++i) { address = dictBuffer.position(); - final CharGroupInfo currentInfo = BinaryDictDecoderUtils.readCharGroup(dictBuffer, - dictBuffer.position(), fileHeader.mFormatOptions); - final boolean isMovedGroup = BinaryDictIOUtils.isMovedGroup(currentInfo.mFlags, + final PtNodeInfo currentInfo = dictDecoder.readPtNode(address, fileHeader.mFormatOptions); - if (isMovedGroup) continue; + final boolean isMovedNode = BinaryDictIOUtils.isMovedPtNode(currentInfo.mFlags, + fileHeader.mFormatOptions); + if (isMovedNode) continue; nodeParentAddress = (currentInfo.mParentAddress == FormatSpec.NO_PARENT_ADDRESS) ? FormatSpec.NO_PARENT_ADDRESS : currentInfo.mParentAddress + address; boolean matched = true; @@ -314,10 +314,10 @@ public final class DynamicBinaryDictIOUtils { * abc - d - ef */ final int newNodeAddress = dictBuffer.limit(); - final int flags = BinaryDictEncoder.makeCharGroupFlags(p > 1, + final int flags = BinaryDictEncoderUtils.makePtNodeFlags(p > 1, isTerminal, 0, hasShortcuts, hasBigrams, false /* isNotAWord */, false /* isBlackListEntry */, fileHeader.mFormatOptions); - int written = moveGroup(newNodeAddress, currentInfo.mCharacters, p, flags, + int written = movePtNode(newNodeAddress, currentInfo.mCharacters, p, flags, frequency, nodeParentAddress, shortcuts, bigrams, destination, dictBuffer, nodeOriginAddress, address, fileHeader.mFormatOptions); @@ -327,12 +327,12 @@ public final class DynamicBinaryDictIOUtils { updateParentAddresses(dictBuffer, currentInfo.mChildrenAddress, newNodeAddress + written + 1, fileHeader.mFormatOptions); } - final CharGroupInfo newInfo2 = new CharGroupInfo( + final PtNodeInfo newInfo2 = new PtNodeInfo( newNodeAddress + written + 1, -1 /* endAddress */, currentInfo.mFlags, characters2, currentInfo.mFrequency, newNodeAddress + 1, currentInfo.mChildrenAddress, currentInfo.mShortcutTargets, currentInfo.mBigrams); - BinaryDictIOUtils.writeNodes(destination, new CharGroupInfo[] { newInfo2 }); + BinaryDictIOUtils.writeNodes(destination, new PtNodeInfo[] { newInfo2 }); return; } else if (codePoints[wordPos + p] != currentInfo.mCharacters[p]) { if (p > 0) { @@ -353,12 +353,12 @@ public final class DynamicBinaryDictIOUtils { final int childrenAddress = currentInfo.mChildrenAddress; // move prefix - final int prefixFlags = BinaryDictEncoder.makeCharGroupFlags(p > 1, + final int prefixFlags = BinaryDictEncoderUtils.makePtNodeFlags(p > 1, false /* isTerminal */, 0 /* childrenAddressSize*/, false /* hasShortcut */, false /* hasBigrams */, false /* isNotAWord */, false /* isBlackListEntry */, fileHeader.mFormatOptions); - int written = moveGroup(newNodeAddress, currentInfo.mCharacters, p, + int written = movePtNode(newNodeAddress, currentInfo.mCharacters, p, prefixFlags, -1 /* frequency */, nodeParentAddress, null, null, destination, dictBuffer, nodeOriginAddress, address, fileHeader.mFormatOptions); @@ -369,7 +369,7 @@ public final class DynamicBinaryDictIOUtils { updateParentAddresses(dictBuffer, currentInfo.mChildrenAddress, newNodeAddress + written + 1, fileHeader.mFormatOptions); } - final int suffixFlags = BinaryDictEncoder.makeCharGroupFlags( + final int suffixFlags = BinaryDictEncoderUtils.makePtNodeFlags( suffixCharacters.length > 1, (currentInfo.mFlags & FormatSpec.FLAG_IS_TERMINAL) != 0, 0 /* childrenAddressSize */, @@ -377,26 +377,26 @@ public final class DynamicBinaryDictIOUtils { != 0, (currentInfo.mFlags & FormatSpec.FLAG_HAS_BIGRAMS) != 0, isNotAWord, isBlackListEntry, fileHeader.mFormatOptions); - final CharGroupInfo suffixInfo = new CharGroupInfo( + final PtNodeInfo suffixInfo = new PtNodeInfo( newNodeAddress + written + 1, -1 /* endAddress */, suffixFlags, suffixCharacters, currentInfo.mFrequency, newNodeAddress + 1, currentInfo.mChildrenAddress, currentInfo.mShortcutTargets, currentInfo.mBigrams); - written += BinaryDictIOUtils.computeGroupSize(suffixInfo, + written += BinaryDictIOUtils.computePtNodeSize(suffixInfo, fileHeader.mFormatOptions) + 1; final int[] newCharacters = Arrays.copyOfRange(codePoints, wordPos + p, codePoints.length); - final int flags = BinaryDictEncoder.makeCharGroupFlags( + final int flags = BinaryDictEncoderUtils.makePtNodeFlags( newCharacters.length > 1, isTerminal, 0 /* childrenAddressSize */, hasShortcuts, hasBigrams, isNotAWord, isBlackListEntry, fileHeader.mFormatOptions); - final CharGroupInfo newInfo = new CharGroupInfo( + final PtNodeInfo newInfo = new PtNodeInfo( newNodeAddress + written, -1 /* endAddress */, flags, newCharacters, frequency, newNodeAddress + 1, FormatSpec.NO_CHILDREN_ADDRESS, shortcuts, bigrams); BinaryDictIOUtils.writeNodes(destination, - new CharGroupInfo[] { suffixInfo, newInfo }); + new PtNodeInfo[] { suffixInfo, newInfo }); return; } matched = false; @@ -407,17 +407,17 @@ public final class DynamicBinaryDictIOUtils { if (matched) { if (wordPos + currentInfo.mCharacters.length == wordLen) { // the word exists in the dictionary. - // only update group. + // only update the PtNode. final int newNodeAddress = dictBuffer.limit(); final boolean hasMultipleChars = currentInfo.mCharacters.length > 1; - final int flags = BinaryDictEncoder.makeCharGroupFlags(hasMultipleChars, + final int flags = BinaryDictEncoderUtils.makePtNodeFlags(hasMultipleChars, isTerminal, 0 /* childrenAddressSize */, hasShortcuts, hasBigrams, isNotAWord, isBlackListEntry, fileHeader.mFormatOptions); - final CharGroupInfo newInfo = new CharGroupInfo(newNodeAddress + 1, + final PtNodeInfo newInfo = new PtNodeInfo(newNodeAddress + 1, -1 /* endAddress */, flags, currentInfo.mCharacters, frequency, nodeParentAddress, currentInfo.mChildrenAddress, shortcuts, bigrams); - moveCharGroup(destination, dictBuffer, newInfo, nodeOriginAddress, address, + movePtNode(destination, dictBuffer, newInfo, nodeOriginAddress, address, fileHeader.mFormatOptions); return; } @@ -425,7 +425,7 @@ public final class DynamicBinaryDictIOUtils { if (currentInfo.mChildrenAddress == FormatSpec.NO_CHILDREN_ADDRESS) { /* * found the prefix of the word. - * make new node and link to the node from this group. + * make new PtNode and link to the PtNode from this PtNode. * * before * ab - cd @@ -435,28 +435,28 @@ public final class DynamicBinaryDictIOUtils { * after * ab - cd - e */ - final int newNodeAddress = dictBuffer.limit(); - updateChildrenAddress(dictBuffer, address, newNodeAddress, + final int newNodeArrayAddress = dictBuffer.limit(); + updateChildrenAddress(dictBuffer, address, newNodeArrayAddress, fileHeader.mFormatOptions); - final int newGroupAddress = newNodeAddress + 1; + final int newNodeAddress = newNodeArrayAddress + 1; final boolean hasMultipleChars = (wordLen - wordPos) > 1; - final int flags = BinaryDictEncoder.makeCharGroupFlags(hasMultipleChars, + final int flags = BinaryDictEncoderUtils.makePtNodeFlags(hasMultipleChars, isTerminal, 0 /* childrenAddressSize */, hasShortcuts, hasBigrams, isNotAWord, isBlackListEntry, fileHeader.mFormatOptions); final int[] characters = Arrays.copyOfRange(codePoints, wordPos, wordLen); - final CharGroupInfo newInfo = new CharGroupInfo(newGroupAddress, -1, flags, + final PtNodeInfo newInfo = new PtNodeInfo(newNodeAddress, -1, flags, characters, frequency, address, FormatSpec.NO_CHILDREN_ADDRESS, shortcuts, bigrams); - BinaryDictIOUtils.writeNodes(destination, new CharGroupInfo[] { newInfo }); + BinaryDictIOUtils.writeNodes(destination, new PtNodeInfo[] { newInfo }); return; } dictBuffer.position(currentInfo.mChildrenAddress); - foundNextGroup = true; + foundNextNode = true; break; } } - if (foundNextGroup) continue; + if (foundNextNode) continue; // reached the end of the array. final int linkAddressPosition = dictBuffer.position(); @@ -485,13 +485,13 @@ public final class DynamicBinaryDictIOUtils { BinaryDictIOUtils.writeSInt24ToBuffer(dictBuffer, newNodeAddress); final int[] characters = Arrays.copyOfRange(codePoints, wordPos, wordLen); - final int flags = BinaryDictEncoder.makeCharGroupFlags(characters.length > 1, + final int flags = BinaryDictEncoderUtils.makePtNodeFlags(characters.length > 1, isTerminal, 0 /* childrenAddressSize */, hasShortcuts, hasBigrams, isNotAWord, isBlackListEntry, fileHeader.mFormatOptions); - final CharGroupInfo newInfo = new CharGroupInfo(newNodeAddress + 1, + final PtNodeInfo newInfo = new PtNodeInfo(newNodeAddress + 1, -1 /* endAddress */, flags, characters, frequency, nodeParentAddress, FormatSpec.NO_CHILDREN_ADDRESS, shortcuts, bigrams); - BinaryDictIOUtils.writeNodes(destination, new CharGroupInfo[]{ newInfo }); + BinaryDictIOUtils.writeNodes(destination, new PtNodeInfo[]{ newInfo }); return; } else { depth--; diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java index 5e331219c..b8ef57696 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java @@ -62,19 +62,19 @@ public final class FormatSpec { /* * Node array (FusionDictionary.PtNodeArray) layout is as follows: * - * g | - * r | the number of groups, 1 or 2 bytes. - * o | 1 byte = bbbbbbbb match - * u | case 1xxxxxxx => xxxxxxx << 8 + next byte - * p | otherwise => bbbbbbbb - * c | - * ount + * n | + * o | the number of PtNodes, 1 or 2 bytes. + * d | 1 byte = bbbbbbbb match + * e | case 1xxxxxxx => xxxxxxx << 8 + next byte + * c | otherwise => bbbbbbbb + * o | + * unt * - * g | - * r | sequence of groups, - * o | the layout of each group is described below. - * u | - * ps + * n | + * o | sequence of PtNodes, + * d | the layout of each PtNode is described below. + * e | + * s * * f | * o | IF SUPPORTS_DYNAMIC_UPDATE (defined in the file header) @@ -86,19 +86,19 @@ public final class FormatSpec { * linkaddress */ - /* Node (FusionDictionary.CharGroup) layout is as follows: + /* Node (FusionDictionary.PtNode) layout is as follows: * | IF !SUPPORTS_DYNAMIC_UPDATE - * | addressType xx : mask with MASK_GROUP_ADDRESS_TYPE - * | 2 bits, 00 = no children : FLAG_GROUP_ADDRESS_TYPE_NOADDRESS - * f | 01 = 1 byte : FLAG_GROUP_ADDRESS_TYPE_ONEBYTE - * l | 10 = 2 bytes : FLAG_GROUP_ADDRESS_TYPE_TWOBYTES - * a | 11 = 3 bytes : FLAG_GROUP_ADDRESS_TYPE_THREEBYTES + * | 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_GROUP_ADDRESS_TYPE_THREEBYTES - * | 01 = yes : FLAG_IS_MOVED + * 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 + * | 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 @@ -116,7 +116,7 @@ public final class FormatSpec { * ddress * * c | IF FLAG_HAS_MULTIPLE_CHARS - * h | char, char, char, char n * (1 or 3 bytes) : use CharGroupInfo for i/o helpers + * h | char, char, char, char n * (1 or 3 bytes) : use PtNodeInfo for i/o helpers * a | end 1 byte, = 0 * r | ELSE * s | char 1 or 3 bytes @@ -127,17 +127,22 @@ public final class FormatSpec { * e | frequency 1 byte * q | * - * c | IF 00 = FLAG_GROUP_ADDRESS_TYPE_NOADDRESS = addressType - * h | // nothing - * i | ELSIF 01 = FLAG_GROUP_ADDRESS_TYPE_ONEBYTE == addressType - * l | children address, 1 byte - * d | ELSIF 10 = FLAG_GROUP_ADDRESS_TYPE_TWOBYTES == addressType - * r | children address, 2 bytes - * e | ELSE // 11 = FLAG_GROUP_ADDRESS_TYPE_THREEBYTES = addressType - * n | children address, 3 bytes - * A | END - * d - * dress + * 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 | ELSIF 00 = FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS == addressType + * e | // nothing + * n | ELSIF 01 = FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE == addressType + * A | children address, 1 byte + * d | ELSIF 10 = FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES == addressType + * d | children address, 2 bytes + * r | ELSE // 11 = FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES = addressType + * e | children address, 3 bytes + * s | END + * s + * ress * * | IF FLAG_IS_TERMINAL && FLAG_HAS_SHORTCUT_TARGETS * | shortcut string list @@ -156,33 +161,33 @@ public final class FormatSpec { * characters which should never happen anyway (and still work, but take 3 bytes). * * bigram address list is: - * <flags> = | hasNext = 1 bit, 1 = yes, 0 = no : FLAG_ATTRIBUTE_HAS_NEXT - * | addressSign = 1 bit, : FLAG_ATTRIBUTE_OFFSET_NEGATIVE + * <flags> = | hasNext = 1 bit, 1 = yes, 0 = no : FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT + * | addressSign = 1 bit, : FLAG_BIGRAM_ATTR_OFFSET_NEGATIVE * | 1 = must take -address, 0 = must take +address - * | xx : mask with MASK_ATTRIBUTE_ADDRESS_TYPE - * | addressFormat = 2 bits, 00 = unused : FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE - * | 01 = 1 byte : FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE - * | 10 = 2 bytes : FLAG_ATTRIBUTE_ADDRESS_TYPE_TWOBYTES - * | 11 = 3 bytes : FLAG_ATTRIBUTE_ADDRESS_TYPE_THREEBYTES - * | 4 bits : frequency : mask with FLAG_ATTRIBUTE_FREQUENCY - * <address> | IF (01 == FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE == addressFormat) + * | xx : mask with MASK_BIGRAM_ATTR_ADDRESS_TYPE + * | addressFormat = 2 bits, 00 = unused : FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE + * | 01 = 1 byte : FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE + * | 10 = 2 bytes : FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES + * | 11 = 3 bytes : FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES + * | 4 bits : frequency : mask with FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY + * <address> | IF (01 == FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE == addressFormat) * | read 1 byte, add top 4 bits - * | ELSIF (10 == FLAG_ATTRIBUTE_ADDRESS_TYPE_TWOBYTES == addressFormat) + * | ELSIF (10 == FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES == addressFormat) * | read 2 bytes, add top 4 bits - * | ELSE // 11 == FLAG_ATTRIBUTE_ADDRESS_TYPE_THREEBYTES == addressFormat + * | ELSE // 11 == FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES == addressFormat * | read 3 bytes, add top 4 bits * | END - * | if (FLAG_ATTRIBUTE_OFFSET_NEGATIVE) then address = -address - * if (FLAG_ATTRIBUTE_HAS_NEXT) goto bigram_and_shortcut_address_list_is + * | if (FLAG_BIGRAM_ATTR_OFFSET_NEGATIVE) then address = -address + * if (FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT) goto bigram_and_shortcut_address_list_is * * shortcut string list is: - * <byte size> = GROUP_SHORTCUT_LIST_SIZE_SIZE bytes, big-endian: size of the list, in bytes. - * <flags> = | hasNext = 1 bit, 1 = yes, 0 = no : FLAG_ATTRIBUTE_HAS_NEXT + * <byte size> = PTNODE_SHORTCUT_LIST_SIZE_SIZE bytes, big-endian: size of the list, in bytes. + * <flags> = | hasNext = 1 bit, 1 = yes, 0 = no : FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT * | reserved = 3 bits, must be 0 - * | 4 bits : frequency : mask with FLAG_ATTRIBUTE_FREQUENCY + * | 4 bits : frequency : mask with FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY * <shortcut> = | string of characters at the char format described above, with the terminator * | used to signal the end of the string. - * if (FLAG_ATTRIBUTE_HAS_NEXT goto flags + * if (FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT goto flags */ public static final int MAGIC_NUMBER = 0x9BC13AFE; @@ -206,11 +211,11 @@ public final class FormatSpec { static final int FORWARD_LINK_ADDRESS_SIZE = 3; // These flags are used only in the static dictionary. - static final int MASK_GROUP_ADDRESS_TYPE = 0xC0; - static final int FLAG_GROUP_ADDRESS_TYPE_NOADDRESS = 0x00; - static final int FLAG_GROUP_ADDRESS_TYPE_ONEBYTE = 0x40; - static final int FLAG_GROUP_ADDRESS_TYPE_TWOBYTES = 0x80; - static final int FLAG_GROUP_ADDRESS_TYPE_THREEBYTES = 0xC0; + static final int MASK_CHILDREN_ADDRESS_TYPE = 0xC0; + static final int FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS = 0x00; + static final int FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE = 0x40; + static final int FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES = 0x80; + static final int FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES = 0xC0; static final int FLAG_HAS_MULTIPLE_CHARS = 0x20; @@ -227,32 +232,32 @@ public final class FormatSpec { static final int FLAG_IS_NOT_MOVED = 0x80 | FIXED_BIT_OF_DYNAMIC_UPDATE_MOVE; static final int FLAG_IS_DELETED = 0x80; - static final int FLAG_ATTRIBUTE_HAS_NEXT = 0x80; - static final int FLAG_ATTRIBUTE_OFFSET_NEGATIVE = 0x40; - static final int MASK_ATTRIBUTE_ADDRESS_TYPE = 0x30; - static final int FLAG_ATTRIBUTE_ADDRESS_TYPE_ONEBYTE = 0x10; - static final int FLAG_ATTRIBUTE_ADDRESS_TYPE_TWOBYTES = 0x20; - static final int FLAG_ATTRIBUTE_ADDRESS_TYPE_THREEBYTES = 0x30; - static final int FLAG_ATTRIBUTE_FREQUENCY = 0x0F; + static final int FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT = 0x80; + static final int FLAG_BIGRAM_ATTR_OFFSET_NEGATIVE = 0x40; + static final int MASK_BIGRAM_ATTR_ADDRESS_TYPE = 0x30; + static final int FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE = 0x10; + static final int FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES = 0x20; + static final int FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES = 0x30; + static final int FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY = 0x0F; - static final int GROUP_CHARACTERS_TERMINATOR = 0x1F; + static final int PTNODE_CHARACTERS_TERMINATOR = 0x1F; - static final int GROUP_TERMINATOR_SIZE = 1; - static final int GROUP_FLAGS_SIZE = 1; - static final int GROUP_FREQUENCY_SIZE = 1; - static final int GROUP_MAX_ADDRESS_SIZE = 3; - static final int GROUP_ATTRIBUTE_FLAGS_SIZE = 1; - static final int GROUP_ATTRIBUTE_MAX_ADDRESS_SIZE = 3; - static final int GROUP_SHORTCUT_LIST_SIZE_SIZE = 2; + static final int PTNODE_TERMINATOR_SIZE = 1; + static final int PTNODE_FLAGS_SIZE = 1; + static final int PTNODE_FREQUENCY_SIZE = 1; + static final int PTNODE_MAX_ADDRESS_SIZE = 3; + static final int PTNODE_ATTRIBUTE_FLAGS_SIZE = 1; + static final int PTNODE_ATTRIBUTE_MAX_ADDRESS_SIZE = 3; + static final int PTNODE_SHORTCUT_LIST_SIZE_SIZE = 2; static final int NO_CHILDREN_ADDRESS = Integer.MIN_VALUE; static final int NO_PARENT_ADDRESS = 0; static final int NO_FORWARD_LINK_ADDRESS = 0; static final int INVALID_CHARACTER = -1; - static final int MAX_CHARGROUPS_FOR_ONE_BYTE_CHARGROUP_COUNT = 0x7F; // 127 - static final int MAX_CHARGROUPS_IN_A_PT_NODE_ARRAY = 0x7FFF; // 32767 - static final int MAX_BIGRAMS_IN_A_GROUP = 10000; + static final int MAX_PTNODES_FOR_ONE_BYTE_PTNODE_COUNT = 0x7F; // 127 + static final int MAX_PTNODES_IN_A_PT_NODE_ARRAY = 0x7FFF; // 32767 + static final int MAX_BIGRAMS_IN_A_PTNODE = 10000; static final int MAX_TERMINAL_FREQUENCY = 255; static final int MAX_BIGRAM_FREQUENCY = 15; diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index fce1c5cdd..3e685a3d7 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java @@ -37,15 +37,15 @@ public final class FusionDictionary implements Iterable<Word> { private static int CHARACTER_NOT_FOUND_INDEX = -1; /** - * A node array of the dictionary, containing several CharGroups. + * A node array of the dictionary, containing several PtNodes. * - * A PtNodeArray is but an ordered array of CharGroups, which essentially contain all the + * A PtNodeArray is but an ordered array of PtNodes, which essentially contain all the * real information. * This class also contains fields to cache size and address, to help with binary * generation. */ public static final class PtNodeArray { - ArrayList<CharGroup> mData; + ArrayList<PtNode> mData; // To help with binary generation int mCachedSize = Integer.MIN_VALUE; // mCachedAddressBefore/AfterUpdate are helpers for binary dictionary generation. They @@ -58,9 +58,9 @@ public final class FusionDictionary implements Iterable<Word> { int mCachedParentAddress = 0; public PtNodeArray() { - mData = new ArrayList<CharGroup>(); + mData = new ArrayList<PtNode>(); } - public PtNodeArray(ArrayList<CharGroup> data) { + public PtNodeArray(ArrayList<PtNode> data) { mData = data; } } @@ -93,18 +93,19 @@ public final class FusionDictionary implements Iterable<Word> { } /** - * A group of characters, with a frequency, shortcut targets, bigrams, and children. + * PtNode is a group of characters, with a frequency, shortcut targets, bigrams, and children + * (Pt means Patricia Trie). * - * This is the central class of the in-memory representation. A CharGroup is what can + * This is the central class of the in-memory representation. A PtNode is what can * be seen as a traditional "trie node", except it can hold several characters at the - * same time. A CharGroup essentially represents one or several characters in the middle + * same time. A PtNode essentially represents one or several characters in the middle * of the trie tree; as such, it can be a terminal, and it can have children. - * In this in-memory representation, whether the CharGroup is a terminal or not is represented + * In this in-memory representation, whether the PtNode is a terminal or not is represented * in the frequency, where NOT_A_TERMINAL (= -1) means this is not a terminal and any other * value is the frequency of this terminal. A terminal may have non-null shortcuts and/or * bigrams, but a non-terminal may not. Moreover, children, if present, are null. */ - public static final class CharGroup { + public static final class PtNode { public static final int NOT_A_TERMINAL = -1; final int mChars[]; ArrayList<WeightedString> mShortcutTargets; @@ -119,11 +120,11 @@ public final class FusionDictionary implements Iterable<Word> { // same time. Updating will update the AfterUpdate value, and the code will move them // to BeforeUpdate before the next update pass. // The update process does not need two versions of mCachedSize. - int mCachedSize; // The size, in bytes, of this char group. - int mCachedAddressBeforeUpdate; // The address of this char group (before update) - int mCachedAddressAfterUpdate; // The address of this char group (after update) + int mCachedSize; // The size, in bytes, of this PtNode. + int mCachedAddressBeforeUpdate; // The address of this PtNode (before update) + int mCachedAddressAfterUpdate; // The address of this PtNode (after update) - public CharGroup(final int[] chars, final ArrayList<WeightedString> shortcutTargets, + public PtNode(final int[] chars, final ArrayList<WeightedString> shortcutTargets, final ArrayList<WeightedString> bigrams, final int frequency, final boolean isNotAWord, final boolean isBlacklistEntry) { mChars = chars; @@ -135,7 +136,7 @@ public final class FusionDictionary implements Iterable<Word> { mIsBlacklistEntry = isBlacklistEntry; } - public CharGroup(final int[] chars, final ArrayList<WeightedString> shortcutTargets, + public PtNode(final int[] chars, final ArrayList<WeightedString> shortcutTargets, final ArrayList<WeightedString> bigrams, final int frequency, final boolean isNotAWord, final boolean isBlacklistEntry, final PtNodeArray children) { @@ -148,7 +149,7 @@ public final class FusionDictionary implements Iterable<Word> { mIsBlacklistEntry = isBlacklistEntry; } - public void addChild(CharGroup n) { + public void addChild(PtNode n) { if (null == mChildren) { mChildren = new PtNodeArray(); } @@ -245,7 +246,7 @@ public final class FusionDictionary implements Iterable<Word> { } /** - * Updates the CharGroup with the given properties. Adds the shortcut and bigram lists to + * Updates the PtNode with the given properties. Adds the shortcut and bigram lists to * the existing ones if any. Note: unigram, bigram, and shortcut frequencies are only * updated if they are higher than the existing ones. */ @@ -407,13 +408,13 @@ public final class FusionDictionary implements Iterable<Word> { } /** - * Sanity check for a node array. + * Sanity check for a PtNode array. * - * This method checks that all CharGroups in a node array are ordered as expected. + * This method checks that all PtNodes in a node array are ordered as expected. * If they are, nothing happens. If they aren't, an exception is thrown. */ - private void checkStack(PtNodeArray nodeArray) { - ArrayList<CharGroup> stack = nodeArray.mData; + private void checkStack(PtNodeArray ptNodeArray) { + ArrayList<PtNode> stack = ptNodeArray.mData; int lastValue = -1; for (int i = 0; i < stack.size(); ++i) { int currentValue = stack.get(i).mChars[0]; @@ -432,18 +433,18 @@ public final class FusionDictionary implements Iterable<Word> { * @param frequency the bigram frequency */ public void setBigram(final String word1, final String word2, final int frequency) { - CharGroup charGroup = findWordInTree(mRootNodeArray, word1); - if (charGroup != null) { - final CharGroup charGroup2 = findWordInTree(mRootNodeArray, word2); - if (charGroup2 == null) { + PtNode ptNode = findWordInTree(mRootNodeArray, word1); + if (ptNode != null) { + final PtNode ptNode2 = findWordInTree(mRootNodeArray, word2); + if (ptNode2 == null) { add(getCodePoints(word2), 0, null, false /* isNotAWord */, false /* isBlacklistEntry */); - // The chargroup for the first word may have moved by the above insertion, + // The PtNode for the first word may have moved by the above insertion, // if word1 and word2 share a common stem that happens not to have been - // a cutting point until now. In this case, we need to refresh charGroup. - charGroup = findWordInTree(mRootNodeArray, word1); + // a cutting point until now. In this case, we need to refresh ptNode. + ptNode = findWordInTree(mRootNodeArray, word1); } - charGroup.addBigram(word2, frequency); + ptNode.addBigram(word2, frequency); } else { throw new RuntimeException("First word of bigram not found"); } @@ -473,84 +474,83 @@ public final class FusionDictionary implements Iterable<Word> { PtNodeArray currentNodeArray = mRootNodeArray; int charIndex = 0; - CharGroup currentGroup = null; + PtNode currentPtNode = null; int differentCharIndex = 0; // Set by the loop to the index of the char that differs int nodeIndex = findIndexOfChar(mRootNodeArray, word[charIndex]); while (CHARACTER_NOT_FOUND_INDEX != nodeIndex) { - currentGroup = currentNodeArray.mData.get(nodeIndex); - differentCharIndex = compareCharArrays(currentGroup.mChars, word, charIndex); + currentPtNode = currentNodeArray.mData.get(nodeIndex); + differentCharIndex = compareCharArrays(currentPtNode.mChars, word, charIndex); if (ARRAYS_ARE_EQUAL != differentCharIndex - && differentCharIndex < currentGroup.mChars.length) break; - if (null == currentGroup.mChildren) break; - charIndex += currentGroup.mChars.length; + && differentCharIndex < currentPtNode.mChars.length) break; + if (null == currentPtNode.mChildren) break; + charIndex += currentPtNode.mChars.length; if (charIndex >= word.length) break; - currentNodeArray = currentGroup.mChildren; + currentNodeArray = currentPtNode.mChildren; nodeIndex = findIndexOfChar(currentNodeArray, word[charIndex]); } if (CHARACTER_NOT_FOUND_INDEX == nodeIndex) { // No node at this point to accept the word. Create one. final int insertionIndex = findInsertionIndex(currentNodeArray, word[charIndex]); - final CharGroup newGroup = new CharGroup( - Arrays.copyOfRange(word, charIndex, word.length), + final PtNode newPtNode = new PtNode(Arrays.copyOfRange(word, charIndex, word.length), shortcutTargets, null /* bigrams */, frequency, isNotAWord, isBlacklistEntry); - currentNodeArray.mData.add(insertionIndex, newGroup); + currentNodeArray.mData.add(insertionIndex, newPtNode); if (DBG) checkStack(currentNodeArray); } else { // There is a word with a common prefix. - if (differentCharIndex == currentGroup.mChars.length) { + if (differentCharIndex == currentPtNode.mChars.length) { if (charIndex + differentCharIndex >= word.length) { // The new word is a prefix of an existing word, but the node on which it - // should end already exists as is. Since the old CharGroup was not a terminal, + // should end already exists as is. Since the old PtNode was not a terminal, // make it one by filling in its frequency and other attributes - currentGroup.update(frequency, shortcutTargets, null, isNotAWord, + currentPtNode.update(frequency, shortcutTargets, null, isNotAWord, isBlacklistEntry); } else { // The new word matches the full old word and extends past it. // We only have to create a new node and add it to the end of this. - final CharGroup newNode = new CharGroup( + final PtNode newNode = new PtNode( Arrays.copyOfRange(word, charIndex + differentCharIndex, word.length), shortcutTargets, null /* bigrams */, frequency, isNotAWord, isBlacklistEntry); - currentGroup.mChildren = new PtNodeArray(); - currentGroup.mChildren.mData.add(newNode); + currentPtNode.mChildren = new PtNodeArray(); + currentPtNode.mChildren.mData.add(newNode); } } else { if (0 == differentCharIndex) { // Exact same word. Update the frequency if higher. This will also add the // new shortcuts to the existing shortcut list if it already exists. - currentGroup.update(frequency, shortcutTargets, null, - currentGroup.mIsNotAWord && isNotAWord, - currentGroup.mIsBlacklistEntry || isBlacklistEntry); + currentPtNode.update(frequency, shortcutTargets, null, + currentPtNode.mIsNotAWord && isNotAWord, + currentPtNode.mIsBlacklistEntry || isBlacklistEntry); } else { // Partial prefix match only. We have to replace the current node with a node // containing the current prefix and create two new ones for the tails. PtNodeArray newChildren = new PtNodeArray(); - final CharGroup newOldWord = new CharGroup( - Arrays.copyOfRange(currentGroup.mChars, differentCharIndex, - currentGroup.mChars.length), currentGroup.mShortcutTargets, - currentGroup.mBigrams, currentGroup.mFrequency, - currentGroup.mIsNotAWord, currentGroup.mIsBlacklistEntry, - currentGroup.mChildren); + final PtNode newOldWord = new PtNode( + Arrays.copyOfRange(currentPtNode.mChars, differentCharIndex, + currentPtNode.mChars.length), currentPtNode.mShortcutTargets, + currentPtNode.mBigrams, currentPtNode.mFrequency, + currentPtNode.mIsNotAWord, currentPtNode.mIsBlacklistEntry, + currentPtNode.mChildren); newChildren.mData.add(newOldWord); - final CharGroup newParent; + final PtNode newParent; if (charIndex + differentCharIndex >= word.length) { - newParent = new CharGroup( - Arrays.copyOfRange(currentGroup.mChars, 0, differentCharIndex), + newParent = new PtNode( + Arrays.copyOfRange(currentPtNode.mChars, 0, differentCharIndex), shortcutTargets, null /* bigrams */, frequency, isNotAWord, isBlacklistEntry, newChildren); } else { - newParent = new CharGroup( - Arrays.copyOfRange(currentGroup.mChars, 0, differentCharIndex), + newParent = new PtNode( + Arrays.copyOfRange(currentPtNode.mChars, 0, differentCharIndex), null /* shortcutTargets */, null /* bigrams */, -1, false /* isNotAWord */, false /* isBlacklistEntry */, newChildren); - final CharGroup newWord = new CharGroup(Arrays.copyOfRange(word, + final PtNode newWord = new PtNode(Arrays.copyOfRange(word, charIndex + differentCharIndex, word.length), shortcutTargets, null /* bigrams */, frequency, isNotAWord, isBlacklistEntry); final int addIndex = word[charIndex + differentCharIndex] - > currentGroup.mChars[differentCharIndex] ? 1 : 0; + > currentPtNode.mChars[differentCharIndex] ? 1 : 0; newChildren.mData.add(addIndex, newWord); } currentNodeArray.mData.set(nodeIndex, newParent); @@ -589,29 +589,29 @@ public final class FusionDictionary implements Iterable<Word> { } /** - * Helper class that compares and sorts two chargroups according to their + * Helper class that compares and sorts two PtNodes according to their * first element only. I repeat: ONLY the first element is considered, the rest * is ignored. * This comparator imposes orderings that are inconsistent with equals. */ - static private final class CharGroupComparator implements java.util.Comparator<CharGroup> { + static private final class PtNodeComparator implements java.util.Comparator<PtNode> { @Override - public int compare(CharGroup c1, CharGroup c2) { - if (c1.mChars[0] == c2.mChars[0]) return 0; - return c1.mChars[0] < c2.mChars[0] ? -1 : 1; + public int compare(PtNode p1, PtNode p2) { + if (p1.mChars[0] == p2.mChars[0]) return 0; + return p1.mChars[0] < p2.mChars[0] ? -1 : 1; } } - final static private CharGroupComparator CHARGROUP_COMPARATOR = new CharGroupComparator(); + final static private PtNodeComparator PTNODE_COMPARATOR = new PtNodeComparator(); /** * Finds the insertion index of a character within a node array. */ private static int findInsertionIndex(final PtNodeArray nodeArray, int character) { - final ArrayList<CharGroup> data = nodeArray.mData; - final CharGroup reference = new CharGroup(new int[] { character }, + final ArrayList<PtNode> data = nodeArray.mData; + final PtNode reference = new PtNode(new int[] { character }, null /* shortcutTargets */, null /* bigrams */, 0, false /* isNotAWord */, false /* isBlacklistEntry */); - int result = Collections.binarySearch(data, reference, CHARGROUP_COMPARATOR); + int result = Collections.binarySearch(data, reference, PTNODE_COMPARATOR); return result >= 0 ? result : -result - 1; } @@ -633,35 +633,37 @@ public final class FusionDictionary implements Iterable<Word> { * Helper method to find a word in a given branch. */ @SuppressWarnings("unused") - public static CharGroup findWordInTree(PtNodeArray nodeArray, final String string) { + public static PtNode findWordInTree(PtNodeArray nodeArray, final String string) { int index = 0; final StringBuilder checker = DBG ? new StringBuilder() : null; final int[] codePoints = getCodePoints(string); - CharGroup currentGroup; + PtNode currentPtNode; do { int indexOfGroup = findIndexOfChar(nodeArray, codePoints[index]); if (CHARACTER_NOT_FOUND_INDEX == indexOfGroup) return null; - currentGroup = nodeArray.mData.get(indexOfGroup); + currentPtNode = nodeArray.mData.get(indexOfGroup); - if (codePoints.length - index < currentGroup.mChars.length) return null; + if (codePoints.length - index < currentPtNode.mChars.length) return null; int newIndex = index; - while (newIndex < codePoints.length && newIndex - index < currentGroup.mChars.length) { - if (currentGroup.mChars[newIndex - index] != codePoints[newIndex]) return null; + while (newIndex < codePoints.length && newIndex - index < currentPtNode.mChars.length) { + if (currentPtNode.mChars[newIndex - index] != codePoints[newIndex]) return null; newIndex++; } index = newIndex; - if (DBG) checker.append(new String(currentGroup.mChars, 0, currentGroup.mChars.length)); + if (DBG) { + checker.append(new String(currentPtNode.mChars, 0, currentPtNode.mChars.length)); + } if (index < codePoints.length) { - nodeArray = currentGroup.mChildren; + nodeArray = currentPtNode.mChildren; } } while (null != nodeArray && index < codePoints.length); if (index < codePoints.length) return null; - if (!currentGroup.isTerminal()) return null; + if (!currentPtNode.isTerminal()) return null; if (DBG && !string.equals(checker.toString())) return null; - return currentGroup; + return currentPtNode; } /** @@ -675,18 +677,18 @@ public final class FusionDictionary implements Iterable<Word> { } /** - * Recursively count the number of character groups in a given branch of the trie. + * Recursively count the number of PtNodes in a given branch of the trie. * * @param nodeArray the parent node. - * @return the number of char groups in all the branch under this node. + * @return the number of PtNodes in all the branch under this node. */ - public static int countCharGroups(final PtNodeArray nodeArray) { + public static int countPtNodes(final PtNodeArray nodeArray) { final int nodeSize = nodeArray.mData.size(); int size = nodeSize; for (int i = nodeSize - 1; i >= 0; --i) { - CharGroup group = nodeArray.mData.get(i); - if (null != group.mChildren) - size += countCharGroups(group.mChildren); + PtNode ptNode = nodeArray.mData.get(i); + if (null != ptNode.mChildren) + size += countPtNodes(ptNode.mChildren); } return size; } @@ -700,9 +702,9 @@ public final class FusionDictionary implements Iterable<Word> { public static int countNodeArrays(final PtNodeArray nodeArray) { int size = 1; for (int i = nodeArray.mData.size() - 1; i >= 0; --i) { - CharGroup group = nodeArray.mData.get(i); - if (null != group.mChildren) - size += countNodeArrays(group.mChildren); + PtNode ptNode = nodeArray.mData.get(i); + if (null != ptNode.mChildren) + size += countNodeArrays(ptNode.mChildren); } return size; } @@ -713,9 +715,9 @@ public final class FusionDictionary implements Iterable<Word> { private static boolean hasBigramsInternal(final PtNodeArray nodeArray) { if (null == nodeArray) return false; for (int i = nodeArray.mData.size() - 1; i >= 0; --i) { - CharGroup group = nodeArray.mData.get(i); - if (null != group.mBigrams) return true; - if (hasBigramsInternal(group.mChildren)) return true; + PtNode ptNode = nodeArray.mData.get(i); + if (null != ptNode.mBigrams) return true; + if (hasBigramsInternal(ptNode.mChildren)) return true; } return false; } @@ -748,8 +750,8 @@ public final class FusionDictionary implements Iterable<Word> { MakedictLog.i("Do not merge tails"); return; -// MakedictLog.i("Merging nodes. Number of nodes : " + countNodes(root)); -// MakedictLog.i("Number of groups : " + countCharGroups(root)); +// 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>>(); @@ -771,25 +773,25 @@ public final class FusionDictionary implements Iterable<Word> { // if (a.data.size() != b.data.size()) return false; // final int size = a.data.size(); // for (int i = size - 1; i >= 0; --i) { -// CharGroup aGroup = a.data.get(i); -// CharGroup bGroup = b.data.get(i); -// if (aGroup.frequency != bGroup.frequency) return false; -// if (aGroup.alternates == null && bGroup.alternates != null) return false; -// if (aGroup.alternates != null && !aGroup.equals(bGroup.alternates)) return false; -// if (!Arrays.equals(aGroup.chars, bGroup.chars)) return false; -// if (!isEqual(aGroup.children, bGroup.children)) return false; +// 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<CharGroup> branches = nodeArray.data; +// final ArrayList<PtNode> branches = nodeArray.data; // final int nodeSize = branches.size(); // for (int i = 0; i < nodeSize; ++i) { -// CharGroup group = branches.get(i); -// if (null != group.children) { -// String pseudoHash = getPseudoHash(group.children); +// 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>(); @@ -797,16 +799,16 @@ public final class FusionDictionary implements Iterable<Word> { // } // boolean merged = false; // for (PtNodeArray similar : similarList) { -// if (isEqual(group.children, similar)) { -// group.children = similar; +// if (isEqual(ptNode.children, similar)) { +// ptNode.children = similar; // merged = true; // break; // } // } // if (!merged) { -// similarList.add(group.children); +// similarList.add(ptNode.children); // } -// mergeTailsInner(map, group.children); +// mergeTailsInner(map, ptNode.children); // } // } // return map; @@ -814,9 +816,9 @@ public final class FusionDictionary implements Iterable<Word> { // private static String getPseudoHash(final PtNodeArray nodeArray) { // StringBuilder s = new StringBuilder(); -// for (CharGroup g : nodeArray.data) { -// s.append(g.frequency); -// for (int ch : g.chars) { +// for (PtNode ptNode : nodeArray.data) { +// s.append(ptNode.frequency); +// for (int ch : ptNode.chars) { // s.append(Character.toChars(ch)); // } // } @@ -830,20 +832,20 @@ public final class FusionDictionary implements Iterable<Word> { */ public static final class DictionaryIterator implements Iterator<Word> { private static final class Position { - public Iterator<CharGroup> pos; + public Iterator<PtNode> pos; public int length; - public Position(ArrayList<CharGroup> groups) { - pos = groups.iterator(); + public Position(ArrayList<PtNode> ptNodes) { + pos = ptNodes.iterator(); length = 0; } } final StringBuilder mCurrentString; final LinkedList<Position> mPositions; - public DictionaryIterator(ArrayList<CharGroup> root) { + public DictionaryIterator(ArrayList<PtNode> ptRoot) { mCurrentString = new StringBuilder(); mPositions = new LinkedList<Position>(); - final Position rootPos = new Position(root); + final Position rootPos = new Position(ptRoot); mPositions.add(rootPos); } @@ -864,20 +866,20 @@ public final class FusionDictionary implements Iterable<Word> { do { if (currentPos.pos.hasNext()) { - final CharGroup currentGroup = currentPos.pos.next(); + final PtNode currentPtNode = currentPos.pos.next(); currentPos.length = mCurrentString.length(); - for (int i : currentGroup.mChars) { + for (int i : currentPtNode.mChars) { mCurrentString.append(Character.toChars(i)); } - if (null != currentGroup.mChildren) { - currentPos = new Position(currentGroup.mChildren.mData); + if (null != currentPtNode.mChildren) { + currentPos = new Position(currentPtNode.mChildren.mData); currentPos.length = mCurrentString.length(); mPositions.addLast(currentPos); } - if (currentGroup.mFrequency >= 0) { - return new Word(mCurrentString.toString(), currentGroup.mFrequency, - currentGroup.mShortcutTargets, currentGroup.mBigrams, - currentGroup.mIsNotAWord, currentGroup.mIsBlacklistEntry); + if (currentPtNode.mFrequency >= 0) { + return new Word(mCurrentString.toString(), currentPtNode.mFrequency, + currentPtNode.mShortcutTargets, currentPtNode.mBigrams, + currentPtNode.mIsNotAWord, currentPtNode.mIsBlacklistEntry); } } else { mPositions.removeLast(); diff --git a/java/src/com/android/inputmethod/latin/makedict/CharGroupInfo.java b/java/src/com/android/inputmethod/latin/makedict/PtNodeInfo.java index b3617443e..188de7a0f 100644 --- a/java/src/com/android/inputmethod/latin/makedict/CharGroupInfo.java +++ b/java/src/com/android/inputmethod/latin/makedict/PtNodeInfo.java @@ -21,9 +21,9 @@ import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; import java.util.ArrayList; /** - * Raw char group info straight out of a file. This will contain numbers for addresses. + * Raw PtNode info straight out of a file. This will contain numbers for addresses. */ -public final class CharGroupInfo { +public final class PtNodeInfo { public final int mOriginalAddress; public final int mEndAddress; @@ -35,7 +35,7 @@ public final class CharGroupInfo { public final ArrayList<WeightedString> mShortcutTargets; public final ArrayList<PendingAttribute> mBigrams; - public CharGroupInfo(final int originalAddress, final int endAddress, final int flags, + public PtNodeInfo(final int originalAddress, final int endAddress, final int flags, final int[] characters, final int frequency, final int parentAddress, final int childrenAddress, final ArrayList<WeightedString> shortcutTargets, final ArrayList<PendingAttribute> bigrams) { diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java index 7a9323c2f..1a5023ef6 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver3DictDecoder.java @@ -21,18 +21,26 @@ import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.CharEncodin import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; +import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; +import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; import com.android.inputmethod.latin.utils.JniUtils; +import android.util.Log; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.TreeMap; /** * An implementation of DictDecoder for version 3 binary dictionary. */ @UsedForTesting public class Ver3DictDecoder implements DictDecoder { + private static final String TAG = Ver3DictDecoder.class.getSimpleName(); static { JniUtils.loadNativeLibrary(); @@ -70,32 +78,145 @@ public class Ver3DictDecoder implements DictDecoder { } } + private final static class PtNodeReader { + protected static int readPtNodeOptionFlags(final DictBuffer dictBuffer) { + return dictBuffer.readUnsignedByte(); + } + + protected static int readParentAddress(final DictBuffer dictBuffer, + final FormatOptions formatOptions) { + if (BinaryDictIOUtils.supportsDynamicUpdate(formatOptions)) { + return BinaryDictDecoderUtils.readSInt24(dictBuffer); + } else { + return FormatSpec.NO_PARENT_ADDRESS; + } + } + + protected static int readFrequency(final DictBuffer dictBuffer) { + return dictBuffer.readUnsignedByte(); + } + + protected static int readChildrenAddress(final DictBuffer dictBuffer, final int optionFlags, + final FormatOptions formatOptions) { + if (BinaryDictIOUtils.supportsDynamicUpdate(formatOptions)) { + final int address = BinaryDictDecoderUtils.readSInt24(dictBuffer); + if (address == 0) return FormatSpec.NO_CHILDREN_ADDRESS; + return address; + } else { + switch (optionFlags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) { + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE: + return dictBuffer.readUnsignedByte(); + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_TWOBYTES: + return dictBuffer.readUnsignedShort(); + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_THREEBYTES: + return dictBuffer.readUnsignedInt24(); + case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_NOADDRESS: + default: + return FormatSpec.NO_CHILDREN_ADDRESS; + } + } + } + + // Reads shortcuts and returns the read length. + protected static int readShortcut(final DictBuffer dictBuffer, + final ArrayList<WeightedString> shortcutTargets) { + final int pointerBefore = dictBuffer.position(); + dictBuffer.readUnsignedShort(); // skip the size + while (true) { + final int targetFlags = dictBuffer.readUnsignedByte(); + final String word = CharEncoding.readString(dictBuffer); + shortcutTargets.add(new WeightedString(word, + targetFlags & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY)); + if (0 == (targetFlags & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT)) break; + } + return dictBuffer.position() - pointerBefore; + } + + protected static int readBigrams(final DictBuffer dictBuffer, + final ArrayList<PendingAttribute> bigrams, final int baseAddress) { + int readLength = 0; + int bigramCount = 0; + while (bigramCount++ < FormatSpec.MAX_BIGRAMS_IN_A_PTNODE) { + final int bigramFlags = dictBuffer.readUnsignedByte(); + ++readLength; + final int sign = 0 == (bigramFlags & FormatSpec.FLAG_BIGRAM_ATTR_OFFSET_NEGATIVE) + ? 1 : -1; + int bigramAddress = baseAddress + readLength; + switch (bigramFlags & FormatSpec.MASK_BIGRAM_ATTR_ADDRESS_TYPE) { + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_ONEBYTE: + bigramAddress += sign * dictBuffer.readUnsignedByte(); + readLength += 1; + break; + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_TWOBYTES: + bigramAddress += sign * dictBuffer.readUnsignedShort(); + readLength += 2; + break; + case FormatSpec.FLAG_BIGRAM_ATTR_ADDRESS_TYPE_THREEBYTES: + final int offset = (dictBuffer.readUnsignedByte() << 16) + + dictBuffer.readUnsignedShort(); + bigramAddress += sign * offset; + readLength += 3; + break; + default: + throw new RuntimeException("Has bigrams with no address"); + } + bigrams.add(new PendingAttribute( + bigramFlags & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY, + bigramAddress)); + if (0 == (bigramFlags & FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT)) break; + } + return readLength; + } + } + private final File mDictionaryBinaryFile; + private final DictionaryBufferFactory mBufferFactory; private DictBuffer mDictBuffer; public Ver3DictDecoder(final File file) { + this(file, USE_READONLY_BYTEBUFFER); + } + + public Ver3DictDecoder(final File file, final int factoryFlag) { mDictionaryBinaryFile = file; mDictBuffer = null; + + if ((factoryFlag & MASK_DICTBUFFER) == USE_READONLY_BYTEBUFFER) { + mBufferFactory = new DictionaryBufferFromReadOnlyByteBufferFactory(); + } else if ((factoryFlag & MASK_DICTBUFFER) == USE_BYTEARRAY) { + mBufferFactory = new DictionaryBufferFromByteArrayFactory(); + } else if ((factoryFlag & MASK_DICTBUFFER) == USE_WRITABLE_BYTEBUFFER) { + mBufferFactory = new DictionaryBufferFromWritableByteBufferFactory(); + } else { + mBufferFactory = new DictionaryBufferFromReadOnlyByteBufferFactory(); + } } - public void openDictBuffer(final DictDecoder.DictionaryBufferFactory factory) - throws FileNotFoundException, IOException { - mDictBuffer = factory.getDictionaryBuffer(mDictionaryBinaryFile); + public Ver3DictDecoder(final File file, final DictionaryBufferFactory factory) { + mDictionaryBinaryFile = file; + mBufferFactory = factory; + } + + public void openDictBuffer() throws FileNotFoundException, IOException { + mDictBuffer = mBufferFactory.getDictionaryBuffer(mDictionaryBinaryFile); } - public DictBuffer getDictBuffer() { + /* package */ DictBuffer getDictBuffer() { return mDictBuffer; } @UsedForTesting - public DictBuffer openAndGetDictBuffer(final DictDecoder.DictionaryBufferFactory factory) - throws FileNotFoundException, IOException { - openDictBuffer(factory); + /* package */ DictBuffer openAndGetDictBuffer() throws FileNotFoundException, IOException { + openDictBuffer(); return getDictBuffer(); } @Override public FileHeader readHeader() throws IOException, UnsupportedFormatException { + if (mDictBuffer == null) { + openDictBuffer(); + } + final int version = HeaderReader.readVersion(mDictBuffer); final int optionsFlags = HeaderReader.readOptionFlags(mDictBuffer); @@ -116,4 +237,114 @@ public class Ver3DictDecoder implements DictDecoder { 0 != (optionsFlags & FormatSpec.SUPPORTS_DYNAMIC_UPDATE))); return header; } + + // TODO: Make this buffer multi thread safe. + private final int[] mCharacterBuffer = new int[FormatSpec.MAX_WORD_LENGTH]; + @Override + public PtNodeInfo readPtNode(final int ptNodePos, final FormatOptions options) { + int addressPointer = ptNodePos; + final int flags = PtNodeReader.readPtNodeOptionFlags(mDictBuffer); + ++addressPointer; + + final int parentAddress = PtNodeReader.readParentAddress(mDictBuffer, options); + if (BinaryDictIOUtils.supportsDynamicUpdate(options)) { + addressPointer += 3; + } + + final int characters[]; + if (0 != (flags & FormatSpec.FLAG_HAS_MULTIPLE_CHARS)) { + int index = 0; + int character = CharEncoding.readChar(mDictBuffer); + addressPointer += CharEncoding.getCharSize(character); + while (-1 != character) { + // FusionDictionary is making sure that the length of the word is smaller than + // MAX_WORD_LENGTH. + // So we'll never write past the end of mCharacterBuffer. + mCharacterBuffer[index++] = character; + character = CharEncoding.readChar(mDictBuffer); + addressPointer += CharEncoding.getCharSize(character); + } + characters = Arrays.copyOfRange(mCharacterBuffer, 0, index); + } else { + final int character = CharEncoding.readChar(mDictBuffer); + addressPointer += CharEncoding.getCharSize(character); + characters = new int[] { character }; + } + final int frequency; + if (0 != (FormatSpec.FLAG_IS_TERMINAL & flags)) { + ++addressPointer; + frequency = PtNodeReader.readFrequency(mDictBuffer); + } else { + frequency = PtNode.NOT_A_TERMINAL; + } + int childrenAddress = PtNodeReader.readChildrenAddress(mDictBuffer, flags, options); + if (childrenAddress != FormatSpec.NO_CHILDREN_ADDRESS) { + childrenAddress += addressPointer; + } + addressPointer += BinaryDictIOUtils.getChildrenAddressSize(flags, options); + final ArrayList<WeightedString> shortcutTargets; + if (0 != (flags & FormatSpec.FLAG_HAS_SHORTCUT_TARGETS)) { + // readShortcut will add shortcuts to shortcutTargets. + shortcutTargets = new ArrayList<WeightedString>(); + addressPointer += PtNodeReader.readShortcut(mDictBuffer, shortcutTargets); + } else { + shortcutTargets = null; + } + + final ArrayList<PendingAttribute> bigrams; + if (0 != (flags & FormatSpec.FLAG_HAS_BIGRAMS)) { + bigrams = new ArrayList<PendingAttribute>(); + addressPointer += PtNodeReader.readBigrams(mDictBuffer, bigrams, addressPointer); + if (bigrams.size() >= FormatSpec.MAX_BIGRAMS_IN_A_PTNODE) { + MakedictLog.d("too many bigrams in a PtNode."); + } + } else { + bigrams = null; + } + return new PtNodeInfo(ptNodePos, addressPointer, flags, characters, frequency, + parentAddress, childrenAddress, shortcutTargets, bigrams); + } + + @Override + public FusionDictionary readDictionaryBinary(final FusionDictionary dict) + throws FileNotFoundException, IOException, UnsupportedFormatException { + if (mDictBuffer == null) { + openDictBuffer(); + } + try { + return BinaryDictDecoderUtils.readDictionaryBinary(this, dict); + } catch (IOException e) { + Log.e(TAG, "The dictionary " + mDictionaryBinaryFile.getName() + " is broken.", e); + if (!mDictionaryBinaryFile.delete()) { + Log.e(TAG, "Failed to delete the broken dictionary."); + } + throw e; + } catch (UnsupportedFormatException e) { + Log.e(TAG, "The dictionary " + mDictionaryBinaryFile.getName() + " is broken.", e); + if (!mDictionaryBinaryFile.delete()) { + Log.e(TAG, "Failed to delete the broken dictionary."); + } + throw e; + } + } + + @Override + public int getTerminalPosition(String word) throws IOException, UnsupportedFormatException { + if (mDictBuffer == null) { + openDictBuffer(); + } + return BinaryDictIOUtils.getTerminalPosition(this, word); + } + + @Override + public void readUnigramsAndBigramsBinary(final TreeMap<Integer, String> words, + final TreeMap<Integer, Integer> frequencies, + final TreeMap<Integer, ArrayList<PendingAttribute>> bigrams) + throws IOException, UnsupportedFormatException { + if (mDictBuffer == null) { + openDictBuffer(); + } + BinaryDictIOUtils.readUnigramsAndBigramsBinary(this, words, frequencies, bigrams); + } + } diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver3DictEncoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver3DictEncoder.java new file mode 100644 index 000000000..e81fd4514 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/makedict/Ver3DictEncoder.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.makedict; + +import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * An implementation of DictEncoder for version 3 binary dictionary. + */ +public class Ver3DictEncoder implements DictEncoder { + + private final File mDictFile; + private OutputStream mOutStream; + + public Ver3DictEncoder(final File dictFile) { + mDictFile = dictFile; + mOutStream = null; + } + + // This constructor is used only by BinaryDictOffdeviceUtilsTests. + // If you want to use this in the production code, you should consider keeping consistency of + // the interface of Ver3DictDecoder by using factory. + public Ver3DictEncoder(final OutputStream outStream) { + mDictFile = null; + mOutStream = outStream; + } + + private void openStream() throws FileNotFoundException { + mOutStream = new FileOutputStream(mDictFile); + } + + private void close() throws IOException { + if (mOutStream != null) { + mOutStream.close(); + mOutStream = null; + } + } + + @Override + public void writeDictionary(FusionDictionary dict, FormatOptions formatOptions) + throws IOException, UnsupportedFormatException { + if (mOutStream == null) { + openStream(); + } + BinaryDictEncoderUtils.writeDictionaryBinary(mOutStream, dict, formatOptions); + close(); + } +} diff --git a/java/src/com/android/inputmethod/latin/personalization/DynamicPersonalizationDictionaryWriter.java b/java/src/com/android/inputmethod/latin/personalization/DynamicPersonalizationDictionaryWriter.java new file mode 100644 index 000000000..7f4f5e74a --- /dev/null +++ b/java/src/com/android/inputmethod/latin/personalization/DynamicPersonalizationDictionaryWriter.java @@ -0,0 +1,159 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.personalization; + +import android.content.Context; + +import com.android.inputmethod.keyboard.ProximityInfo; +import com.android.inputmethod.latin.AbstractDictionaryWriter; +import com.android.inputmethod.latin.ExpandableDictionary; +import com.android.inputmethod.latin.WordComposer; +import com.android.inputmethod.latin.ExpandableDictionary.NextWord; +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.UnsupportedFormatException; +import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils; +import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface; +import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils; +import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils.ForgettingCurveParams; + +import java.io.IOException; +import java.util.ArrayList; + +// Currently this class is used to implement dynamic prodiction dictionary. +// TODO: Move to native code. +public class DynamicPersonalizationDictionaryWriter extends AbstractDictionaryWriter { + private static final String TAG = DynamicPersonalizationDictionaryWriter.class.getSimpleName(); + /** Maximum number of pairs. Pruning will start when databases goes above this number. */ + public static final int MAX_HISTORY_BIGRAMS = 10000; + + /** Any pair being typed or picked */ + private static final int FREQUENCY_FOR_TYPED = 2; + + private static final int BINARY_DICT_VERSION = 3; + private static final FormatSpec.FormatOptions FORMAT_OPTIONS = + new FormatSpec.FormatOptions(BINARY_DICT_VERSION, true /* supportsDynamicUpdate */); + + private final UserHistoryDictionaryBigramList mBigramList = + new UserHistoryDictionaryBigramList(); + private final ExpandableDictionary mExpandableDictionary; + + public DynamicPersonalizationDictionaryWriter(final Context context, final String dictType) { + super(context, dictType); + mExpandableDictionary = new ExpandableDictionary(dictType); + } + + @Override + public void clear() { + mBigramList.evictAll(); + mExpandableDictionary.clearDictionary(); + } + + /** + * Adds a word unigram to the fusion dictionary. Call updateBinaryDictionary when all changes + * are done to update the binary dictionary. + */ + @Override + public void addUnigramWord(final String word, final String shortcutTarget, final int frequency, + final boolean isNotAWord) { + mExpandableDictionary.addWord(word, shortcutTarget, frequency); + mBigramList.addBigram(null, word, (byte)frequency); + } + + @Override + public void addBigramWords(final String word0, final String word1, final int frequency, + final boolean isValid, final long lastModifiedTime) { + if (lastModifiedTime > 0) { + mExpandableDictionary.setBigramAndGetFrequency(word0, word1, + new ForgettingCurveParams(frequency, System.currentTimeMillis(), + lastModifiedTime)); + mBigramList.addBigram(word0, word1, (byte)frequency); + } else { + mExpandableDictionary.setBigramAndGetFrequency(word0, word1, + new ForgettingCurveParams(isValid)); + mBigramList.addBigram(word0, word1, (byte)frequency); + } + } + + @Override + public void removeBigramWords(final String word0, final String word1) { + if (mBigramList.removeBigram(word0, word1)) { + mExpandableDictionary.removeBigram(word0, word1); + } + } + + @Override + protected void writeDictionary(final DictEncoder dictEncoder) + throws IOException, UnsupportedFormatException { + UserHistoryDictIOUtils.writeDictionary(dictEncoder, + new FrequencyProvider(mBigramList, mExpandableDictionary), mBigramList, + FORMAT_OPTIONS); + } + + private static class FrequencyProvider implements BigramDictionaryInterface { + final private UserHistoryDictionaryBigramList mBigramList; + final private ExpandableDictionary mExpandableDictionary; + + public FrequencyProvider(final UserHistoryDictionaryBigramList bigramList, + final ExpandableDictionary expandableDictionary) { + mBigramList = bigramList; + mExpandableDictionary = expandableDictionary; + } + @Override + public int getFrequency(final String word0, final String word1) { + final int freq; + if (word0 == null) { // unigram + freq = FREQUENCY_FOR_TYPED; + } else { // bigram + final NextWord nw = mExpandableDictionary.getBigramWord(word0, word1); + if (nw != null) { + final ForgettingCurveParams forgettingCurveParams = nw.getFcParams(); + final byte prevFc = mBigramList.getBigrams(word0).get(word1); + final byte fc = forgettingCurveParams.getFc(); + final boolean isValid = forgettingCurveParams.isValid(); + if (prevFc > 0 && prevFc == fc) { + freq = fc & 0xFF; + } else if (UserHistoryForgettingCurveUtils. + needsToSave(fc, isValid, mBigramList.size() <= MAX_HISTORY_BIGRAMS)) { + freq = fc & 0xFF; + } else { + // Delete this entry + freq = -1; + } + } else { + // Delete this entry + freq = -1; + } + } + return freq; + } + } + + @Override + public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, + final String prevWord, final ProximityInfo proximityInfo, + boolean blockOffensiveWords) { + return mExpandableDictionary.getSuggestions(composer, prevWord, proximityInfo, + blockOffensiveWords); + } + + @Override + public boolean isValidWord(final String word) { + return mExpandableDictionary.isValidWord(word); + } +} diff --git a/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java index b565b2f9f..be3a9f2f1 100644 --- a/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java +++ b/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java @@ -18,106 +18,88 @@ package com.android.inputmethod.latin.personalization; import android.content.Context; import android.content.SharedPreferences; -import android.os.AsyncTask; import android.util.Log; import com.android.inputmethod.annotations.UsedForTesting; -import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.Constants; -import com.android.inputmethod.latin.ExpandableDictionary; +import com.android.inputmethod.latin.ExpandableBinaryDictionary; import com.android.inputmethod.latin.LatinImeLogger; -import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; -import com.android.inputmethod.latin.WordComposer; -import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; +import com.android.inputmethod.latin.makedict.DictDecoder; import com.android.inputmethod.latin.makedict.Ver3DictDecoder; import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils; -import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface; import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.OnAddWordListener; -import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils; -import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils.ForgettingCurveParams; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.locks.ReentrantLock; /** * This class is a base class of a dictionary for the personalized prediction language model. */ -public abstract class DynamicPredictionDictionaryBase extends ExpandableDictionary { - +public abstract class DynamicPredictionDictionaryBase extends ExpandableBinaryDictionary { private static final String TAG = DynamicPredictionDictionaryBase.class.getSimpleName(); public static final boolean DBG_SAVE_RESTORE = false; private static final boolean DBG_STRESS_TEST = false; private static final boolean PROFILE_SAVE_RESTORE = LatinImeLogger.sDBG; - private static final FormatOptions VERSION3 = new FormatOptions(3, - true /* supportsDynamicUpdate */); - /** Any pair being typed or picked */ - private static final int FREQUENCY_FOR_TYPED = 2; - - /** Maximum number of pairs. Pruning will start when databases goes above this number. */ - private static final int MAX_HISTORY_BIGRAMS = 10000; + public static final int FREQUENCY_FOR_TYPED = 2; /** Locale for which this user history dictionary is storing words */ private final String mLocale; - private final UserHistoryDictionaryBigramList mBigramList = - new UserHistoryDictionaryBigramList(); - private final ReentrantLock mBigramListLock = new ReentrantLock(); + private final String mFileName; + private final SharedPreferences mPrefs; private final ArrayList<PersonalizationDictionaryUpdateSession> mSessions = CollectionUtils.newArrayList(); - private final AtomicReference<AsyncTask<Void, Void, Void>> mWaitingTask; - // Should always be false except when we use this class for test @UsedForTesting boolean mIsTest = false; /* package */ DynamicPredictionDictionaryBase(final Context context, final String locale, - final SharedPreferences sp, final String dictionaryType) { - super(context, dictionaryType); + final SharedPreferences sp, final String dictionaryType, final String fileName) { + super(context, locale, dictionaryType, true); mLocale = locale; + mFileName = fileName; mPrefs = sp; - mWaitingTask = new AtomicReference<AsyncTask<Void, Void, Void>>(); if (mLocale != null && mLocale.length() > 1) { - loadDictionary(); + asyncLoadDictionaryToMemory(); + asyncReloadDictionaryIfRequired(); } } @Override public void close() { - flushPendingWrites(); - // Don't close the database as locale changes will require it to be reopened anyway - // Also, the database is written to somewhat frequently, so it needs to be kept alive - // throughout the life of the process. - // mOpenHelper.close(); - // Ignore close because we cache PersonalizationPredictionDictionary for each language. - // See getInstance() above. + // Close only binary dictionary to reuse this dictionary. // super.close(); + closeBinaryDictionary(); + // Flush pending writes. + // TODO: Remove after this class become to use a dynamic binary dictionary. + asyncWriteBinaryDictionary(); + Settings.writeLastUserHistoryWriteTime(mPrefs, mLocale); } @Override - protected ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer composer, - final String prevWord, final ProximityInfo proximityInfo) { - // Inhibit suggestions (not predictions) for user history for now. Removing this method - // is enough to use it through the standard ExpandableDictionary way. - return null; + protected boolean hasContentChanged() { + return false; + } + + @Override + protected boolean needsToReloadBeforeWriting() { + return false; } /** * Return whether the passed charsequence is in the dictionary. */ @Override - public synchronized boolean isValidWord(final String word) { - // TODO: figure out what is the correct thing to do here. + public boolean isValidWord(final String word) { + // Words included only in the user history should be treated as not in dictionary words. return false; } @@ -129,74 +111,29 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona * context, as in beginning of a sentence for example. * The second word may not be null (a NullPointerException would be thrown). */ - public int addToPersonalizationPredictionDictionary( - final String word1, final String word2, final boolean isValid) { - if (word2.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH || - (word1 != null && word1.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) { - return -1; + public void addToPersonalizationPredictionDictionary( + final String word0, final String word1, final boolean isValid) { + if (word1.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH || + (word0 != null && word0.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) { + return; } - if (mBigramListLock.tryLock()) { - try { - super.addWord( - word2, null /* the "shortcut" parameter is null */, FREQUENCY_FOR_TYPED); - mBigramList.addBigram(null, word2, (byte)FREQUENCY_FOR_TYPED); - // Do not insert a word as a bigram of itself - if (word2.equals(word1)) { - return 0; - } - final int freq; - if (null == word1) { - freq = FREQUENCY_FOR_TYPED; - } else { - freq = super.setBigramAndGetFrequency( - word1, word2, new ForgettingCurveParams(isValid)); - } - mBigramList.addBigram(word1, word2); - return freq; - } finally { - mBigramListLock.unlock(); - } + addWordDynamically(word1, null /* the "shortcut" parameter is null */, FREQUENCY_FOR_TYPED, + false /* isNotAWord */); + // Do not insert a word as a bigram of itself + if (word1.equals(word0)) { + return; } - return -1; - } - - public boolean cancelAddingUserHistory(final String word1, final String word2) { - if (mBigramListLock.tryLock()) { - try { - if (mBigramList.removeBigram(word1, word2)) { - return super.removeBigram(word1, word2); - } - } finally { - mBigramListLock.unlock(); - } + if (null != word0) { + addBigramDynamically(word0, word1, FREQUENCY_FOR_TYPED, isValid); } - return false; } - /** - * Schedules a background thread to write any pending words to the database. - */ - private void flushPendingWrites() { - // Create a background thread to write the pending entries - final AsyncTask<Void, Void, Void> old = mWaitingTask.getAndSet(new UpdateBinaryTask( - mBigramList, mLocale, this, mPrefs, getContext()).execute()); - if (old != null) { - old.cancel(false); - } + public void cancelAddingUserHistory(final String word0, final String word1) { + removeBigramDynamically(word0, word1); } @Override - public final void loadDictionaryAsync() { - // This must be run on non-main thread - mBigramListLock.lock(); - try { - loadDictionaryAsyncLocked(); - } finally { - mBigramListLock.unlock(); - } - } - - private void loadDictionaryAsyncLocked() { + protected void loadDictionaryAsync() { final int[] profTotalCount = { 0 }; final String locale = getLocale(); if (DBG_STRESS_TEST) { @@ -208,10 +145,8 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona } } final long last = Settings.readLastUserHistoryWriteTime(mPrefs, locale); - final boolean initializing = last == 0; final long now = System.currentTimeMillis(); - final String fileName = getDictionaryFileName(); - final ExpandableDictionary dictionary = this; + final ExpandableBinaryDictionary dictionary = this; final OnAddWordListener listener = new OnAddWordListener() { @Override public void setUnigram(final String word, final String shortcutTarget, @@ -219,33 +154,30 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona if (DBG_SAVE_RESTORE) { Log.d(TAG, "load unigram: " + word + "," + frequency); } - dictionary.addWord(word, shortcutTarget, frequency); + addWord(word, shortcutTarget, frequency, false /* isNotAWord */); ++profTotalCount[0]; - addToBigramListLocked(null, word, (byte)frequency); } @Override - public void setBigram(final String word1, final String word2, final int frequency) { - if (word1.length() < Constants.DICTIONARY_MAX_WORD_LENGTH - && word2.length() < Constants.DICTIONARY_MAX_WORD_LENGTH) { + public void setBigram(final String word0, final String word1, final int frequency) { + if (word0.length() < Constants.DICTIONARY_MAX_WORD_LENGTH + && word1.length() < Constants.DICTIONARY_MAX_WORD_LENGTH) { if (DBG_SAVE_RESTORE) { - Log.d(TAG, "load bigram: " + word1 + "," + word2 + "," + frequency); + Log.d(TAG, "load bigram: " + word0 + "," + word1 + "," + frequency); } ++profTotalCount[0]; - dictionary.setBigramAndGetFrequency( - word1, word2, initializing ? new ForgettingCurveParams(true) - : new ForgettingCurveParams(frequency, now, last)); + addBigram(word0, word1, frequency, last); } - addToBigramListLocked(word1, word2, (byte)frequency); } }; // Load the dictionary from binary file - final Ver3DictDecoder reader = new Ver3DictDecoder( - new File(getContext().getFilesDir(), fileName)); + final File dictFile = new File(mContext.getFilesDir(), mFileName); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(dictFile, + DictDecoder.USE_BYTEARRAY); try { - reader.openDictBuffer(new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory()); - UserHistoryDictIOUtils.readDictionaryBinary(reader, listener); + dictDecoder.openDictBuffer(); + UserHistoryDictIOUtils.readDictionaryBinary(dictDecoder, listener); } catch (FileNotFoundException e) { // This is an expected condition: we don't have a user history dictionary for this // language yet. It will be created sometime later. @@ -260,150 +192,18 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona } } - protected abstract String getDictionaryFileName(); - protected String getLocale() { return mLocale; } - private void addToBigramListLocked(String word0, String word1, byte fcValue) { - mBigramList.addBigram(word0, word1, fcValue); - } - - /** - * Async task to write pending words to the binarydicts. - */ - private static final class UpdateBinaryTask extends AsyncTask<Void, Void, Void> - implements BigramDictionaryInterface { - private final UserHistoryDictionaryBigramList mBigramList; - private final boolean mAddLevel0Bigrams; - private final String mLocale; - private final DynamicPredictionDictionaryBase mDynamicPredictionDictionary; - private final SharedPreferences mPrefs; - private final Context mContext; - - public UpdateBinaryTask(final UserHistoryDictionaryBigramList pendingWrites, - final String locale, final DynamicPredictionDictionaryBase dict, - final SharedPreferences prefs, final Context context) { - mBigramList = pendingWrites; - mLocale = locale; - mDynamicPredictionDictionary = dict; - mPrefs = prefs; - mContext = context; - mAddLevel0Bigrams = mBigramList.size() <= MAX_HISTORY_BIGRAMS; - } - - @Override - protected Void doInBackground(final Void... v) { - if (isCancelled()) return null; - if (mDynamicPredictionDictionary.mIsTest) { - // If mIsTest == true, wait until the lock is released. - mDynamicPredictionDictionary.mBigramListLock.lock(); - try { - doWriteTaskLocked(); - } finally { - mDynamicPredictionDictionary.mBigramListLock.unlock(); - } - } else if (mDynamicPredictionDictionary.mBigramListLock.tryLock()) { - try { - doWriteTaskLocked(); - } finally { - mDynamicPredictionDictionary.mBigramListLock.unlock(); - } - } - return null; - } - - private void doWriteTaskLocked() { - if (isCancelled()) return; - mDynamicPredictionDictionary.mWaitingTask.compareAndSet(this, null); - - if (DBG_STRESS_TEST) { - try { - Log.w(TAG, "Start stress in closing: " + mLocale); - Thread.sleep(15000); - Log.w(TAG, "End stress in closing"); - } catch (InterruptedException e) { - Log.e(TAG, "In stress test", e); - } - } - - final long now = PROFILE_SAVE_RESTORE ? System.currentTimeMillis() : 0; - final String fileName = - mDynamicPredictionDictionary.getDictionaryFileName(); - final File file = new File(mContext.getFilesDir(), fileName); - FileOutputStream out = null; - - try { - out = new FileOutputStream(file); - UserHistoryDictIOUtils.writeDictionaryBinary(out, this, mBigramList, VERSION3); - out.flush(); - out.close(); - } catch (IOException e) { - Log.e(TAG, "IO Exception while writing file", e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - // ignore - } - } - } - - // Save the timestamp after we finish writing the binary dictionary. - Settings.writeLastUserHistoryWriteTime(mPrefs, mLocale); - if (PROFILE_SAVE_RESTORE) { - final long diff = System.currentTimeMillis() - now; - Log.w(TAG, "PROF: Write User HistoryDictionary: " + mLocale + ", " + diff + "ms."); - } - } - - @Override - public int getFrequency(final String word1, final String word2) { - final int freq; - if (word1 == null) { // unigram - freq = FREQUENCY_FOR_TYPED; - final byte prevFc = mBigramList.getBigrams(word1).get(word2); - } else { // bigram - final NextWord nw = - mDynamicPredictionDictionary.getBigramWord(word1, word2); - if (nw != null) { - final ForgettingCurveParams fcp = nw.getFcParams(); - final byte prevFc = mBigramList.getBigrams(word1).get(word2); - final byte fc = fcp.getFc(); - final boolean isValid = fcp.isValid(); - if (prevFc > 0 && prevFc == fc) { - freq = fc & 0xFF; - } else if (UserHistoryForgettingCurveUtils. - needsToSave(fc, isValid, mAddLevel0Bigrams)) { - freq = fc & 0xFF; - } else { - // Delete this entry - freq = -1; - } - } else { - // Delete this entry - freq = -1; - } - } - return freq; - } - } - @UsedForTesting /* package for test */ void forceAddWordForTest( - final String word1, final String word2, final boolean isValid) { - mBigramListLock.lock(); - try { - addToPersonalizationPredictionDictionary(word1, word2, isValid); - } finally { - mBigramListLock.unlock(); - } + final String word0, final String word1, final boolean isValid) { + addToPersonalizationPredictionDictionary(word0, word1, isValid); } public void registerUpdateSession(PersonalizationDictionaryUpdateSession session) { - session.setPredictionDictionary(mLocale, this); + session.setPredictionDictionary(this); mSessions.add(session); session.onDictionaryReady(); } @@ -414,15 +214,8 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona public void clearAndFlushDictionary() { // Clear the node structure on memory - clearDictionary(); - mBigramListLock.lock(); - try { - // Clear the bigram list on memory - mBigramList.evictAll(); - } finally { - mBigramListLock.unlock(); - } + clear(); // Then flush the cleared state of the dictionary on disk. - flushPendingWrites(); + asyncWriteBinaryDictionary(); } } diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java index 275ce2fdc..f257165cb 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java @@ -18,28 +18,32 @@ package com.android.inputmethod.latin.personalization; import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.ExpandableBinaryDictionary; +import com.android.inputmethod.latin.utils.CollectionUtils; import android.content.Context; +import android.content.SharedPreferences; + +import java.util.ArrayList; /** * This class is a dictionary for the personalized language model that uses binary dictionary. */ public class PersonalizationDictionary extends ExpandableBinaryDictionary { private static final String NAME = "personalization"; - - public static void registerUpdateListener(PersonalizationDictionaryUpdateSession listener) { - // TODO: Implement - } + private final ArrayList<PersonalizationDictionaryUpdateSession> mSessions = + CollectionUtils.newArrayList(); /** Locale for which this user history dictionary is storing words */ private final String mLocale; - // Singleton - private PersonalizationDictionary(final Context context, final String locale) { + public PersonalizationDictionary(final Context context, final String locale, + final SharedPreferences prefs) { // TODO: Make isUpdatable true. super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_PERSONALIZATION, false /* isUpdatable */); mLocale = locale; + // TODO: Restore last updated time + loadDictionary(); } @Override @@ -49,15 +53,21 @@ public class PersonalizationDictionary extends ExpandableBinaryDictionary { @Override protected boolean hasContentChanged() { - // TODO: Implement return false; } @Override protected boolean needsToReloadBeforeWriting() { - // TODO: Implement return false; } - // TODO: Implement + public void registerUpdateSession(PersonalizationDictionaryUpdateSession session) { + session.setDictionary(this); + mSessions.add(session); + session.onDictionaryReady(); + } + + public void unRegisterUpdateSession(PersonalizationDictionaryUpdateSession session) { + mSessions.remove(session); + } } diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionarySessionRegister.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionarySessionRegister.java index da59333f5..c1833ff14 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionarySessionRegister.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionarySessionRegister.java @@ -31,4 +31,7 @@ public class PersonalizationDictionarySessionRegister { public static void onRemoveData(Context context, String type) { } + + public static void onDestroy(Context context) { + } } diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java index 77f0cdbfa..ab3de801c 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java @@ -45,22 +45,41 @@ public abstract class PersonalizationDictionaryUpdateSession { } // TODO: Use a dynamic binary dictionary instead + public WeakReference<PersonalizationDictionary> mDictionary; public WeakReference<DynamicPredictionDictionaryBase> mPredictionDictionary; - public String mLocale; + public final String mSystemLocale; + public PersonalizationDictionaryUpdateSession(String locale) { + mSystemLocale = locale; + } public abstract void onDictionaryReady(); public abstract void onDictionaryClosed(Context context); - public void setPredictionDictionary(String locale, DynamicPredictionDictionaryBase dictionary) { + public void setDictionary(PersonalizationDictionary dictionary) { + mDictionary = new WeakReference<PersonalizationDictionary>(dictionary); + } + + public void setPredictionDictionary(DynamicPredictionDictionaryBase dictionary) { mPredictionDictionary = new WeakReference<DynamicPredictionDictionaryBase>(dictionary); - mLocale = locale; + } + + protected PersonalizationDictionary getDictionary() { + return mDictionary == null ? null : mDictionary.get(); } protected DynamicPredictionDictionaryBase getPredictionDictionary() { return mPredictionDictionary == null ? null : mPredictionDictionary.get(); } + private void unsetDictionary() { + final PersonalizationDictionary dictionary = getDictionary(); + if (dictionary == null) { + return; + } + dictionary.unRegisterUpdateSession(this); + } + private void unsetPredictionDictionary() { final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary(); if (dictionary == null) { @@ -78,10 +97,12 @@ public abstract class PersonalizationDictionaryUpdateSession { } public void closeSession(Context context) { + unsetDictionary(); unsetPredictionDictionary(); onDictionaryClosed(context); } + // TODO: Support multi locale to add bigram public void addBigramToPersonalizationDictionary(String word0, String word1, boolean isValid, int frequency) { final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary(); @@ -92,6 +113,7 @@ public abstract class PersonalizationDictionaryUpdateSession { } // Bulk import + // TODO: Support multi locale to add bigram public void addBigramsToPersonalizationDictionary( final ArrayList<PersonalizationLanguageModelParam> lmParams) { final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary(); diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryHelper.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java index b4fd25024..c8deaf90d 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryHelper.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java @@ -26,16 +26,20 @@ import android.util.Log; import java.lang.ref.SoftReference; import java.util.concurrent.ConcurrentHashMap; -public class PersonalizationDictionaryHelper { - private static final String TAG = PersonalizationDictionaryHelper.class.getSimpleName(); +public class PersonalizationHelper { + private static final String TAG = PersonalizationHelper.class.getSimpleName(); private static final boolean DEBUG = false; private static final ConcurrentHashMap<String, SoftReference<UserHistoryPredictionDictionary>> sLangUserHistoryDictCache = CollectionUtils.newConcurrentHashMap(); + private static final ConcurrentHashMap<String, SoftReference<PersonalizationDictionary>> + sLangPersonalizationDictCache = CollectionUtils.newConcurrentHashMap(); + private static final ConcurrentHashMap<String, SoftReference<PersonalizationPredictionDictionary>> - sLangPersonalizationDictCache = CollectionUtils.newConcurrentHashMap(); + sLangPersonalizationPredictionDictCache = + CollectionUtils.newConcurrentHashMap(); public static UserHistoryPredictionDictionary getUserHistoryPredictionDictionary( final Context context, final String locale, final SharedPreferences sp) { @@ -48,6 +52,7 @@ public class PersonalizationDictionaryHelper { if (DEBUG) { Log.w(TAG, "Use cached UserHistoryPredictionDictionary for " + locale); } + dict.asyncReloadDictionaryIfRequired(); return dict; } } @@ -60,20 +65,45 @@ public class PersonalizationDictionaryHelper { } public static void registerPersonalizationDictionaryUpdateSession(final Context context, - final PersonalizationDictionaryUpdateSession session) { - final PersonalizationPredictionDictionary dictionary = - getPersonalizationPredictionDictionary(context, - context.getResources().getConfiguration().locale.toString(), + final PersonalizationDictionaryUpdateSession session, String locale) { + final PersonalizationPredictionDictionary predictionDictionary = + getPersonalizationPredictionDictionary(context, locale, + PreferenceManager.getDefaultSharedPreferences(context)); + predictionDictionary.registerUpdateSession(session); + final PersonalizationDictionary dictionary = + getPersonalizationDictionary(context, locale, PreferenceManager.getDefaultSharedPreferences(context)); dictionary.registerUpdateSession(session); } - public static PersonalizationPredictionDictionary getPersonalizationPredictionDictionary( + public static PersonalizationDictionary getPersonalizationDictionary( final Context context, final String locale, final SharedPreferences sp) { synchronized (sLangPersonalizationDictCache) { if (sLangPersonalizationDictCache.containsKey(locale)) { - final SoftReference<PersonalizationPredictionDictionary> ref = + final SoftReference<PersonalizationDictionary> ref = sLangPersonalizationDictCache.get(locale); + final PersonalizationDictionary dict = ref == null ? null : ref.get(); + if (dict != null) { + if (DEBUG) { + Log.w(TAG, "Use cached PersonalizationDictCache for " + locale); + } + return dict; + } + } + final PersonalizationDictionary dict = + new PersonalizationDictionary(context, locale, sp); + sLangPersonalizationDictCache.put( + locale, new SoftReference<PersonalizationDictionary>(dict)); + return dict; + } + } + + public static PersonalizationPredictionDictionary getPersonalizationPredictionDictionary( + final Context context, final String locale, final SharedPreferences sp) { + synchronized (sLangPersonalizationPredictionDictCache) { + if (sLangPersonalizationPredictionDictCache.containsKey(locale)) { + final SoftReference<PersonalizationPredictionDictionary> ref = + sLangPersonalizationPredictionDictCache.get(locale); final PersonalizationPredictionDictionary dict = ref == null ? null : ref.get(); if (dict != null) { if (DEBUG) { @@ -84,7 +114,7 @@ public class PersonalizationDictionaryHelper { } final PersonalizationPredictionDictionary dict = new PersonalizationPredictionDictionary(context, locale, sp); - sLangPersonalizationDictCache.put( + sLangPersonalizationPredictionDictCache.put( locale, new SoftReference<PersonalizationPredictionDictionary>(dict)); return dict; } diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationPredictionDictionary.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationPredictionDictionary.java index a038d0ab2..e80953c05 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationPredictionDictionary.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationPredictionDictionary.java @@ -27,11 +27,11 @@ public class PersonalizationPredictionDictionary extends DynamicPredictionDictio /* package */ PersonalizationPredictionDictionary(final Context context, final String locale, final SharedPreferences sp) { - super(context, locale, sp, Dictionary.TYPE_PERSONALIZATION_PREDICTION_IN_JAVA); + super(context, locale, sp, Dictionary.TYPE_PERSONALIZATION_PREDICTION_IN_JAVA, + getDictionaryFileName(locale)); } - @Override - protected String getDictionaryFileName() { - return NAME + "." + getLocale() + ExpandableBinaryDictionary.DICT_FILE_EXTENSION; + private static String getDictionaryFileName(final String locale) { + return NAME + "." + locale + ExpandableBinaryDictionary.DICT_FILE_EXTENSION; } } diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryBigramList.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryBigramList.java index 9f289e9ff..6c2c9e26e 100644 --- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryBigramList.java +++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryBigramList.java @@ -45,6 +45,7 @@ public final class UserHistoryDictionaryBigramList { /** * Called when the user typed a word. */ + @UsedForTesting public void addBigram(String word1, String word2) { addBigram(word1, word2, FORGETTING_CURVE_INITIAL_VALUE); } diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryPredictionDictionary.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryPredictionDictionary.java index 76e48c744..b140c919b 100644 --- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryPredictionDictionary.java +++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryPredictionDictionary.java @@ -31,11 +31,10 @@ public class UserHistoryPredictionDictionary extends DynamicPredictionDictionary UserHistoryPredictionDictionary.class.getSimpleName(); /* package */ UserHistoryPredictionDictionary(final Context context, final String locale, final SharedPreferences sp) { - super(context, locale, sp, Dictionary.TYPE_USER_HISTORY); + super(context, locale, sp, Dictionary.TYPE_USER_HISTORY, getDictionaryFileName(locale)); } - @Override - protected String getDictionaryFileName() { - return NAME + "." + getLocale() + ExpandableBinaryDictionary.DICT_FILE_EXTENSION; + private static String getDictionaryFileName(final String locale) { + return NAME + "." + locale + ExpandableBinaryDictionary.DICT_FILE_EXTENSION; } } diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index d585b5c7f..0ebe37782 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -34,7 +34,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView { private static final String TAG = MoreSuggestionsView.class.getSimpleName(); public MoreSuggestionsView(final Context context, final AttributeSet attrs) { - this(context, attrs, R.attr.moreSuggestionsViewStyle); + this(context, attrs, R.attr.moreKeysKeyboardViewStyle); } public MoreSuggestionsView(final Context context, final AttributeSet attrs, diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java index bcf64a8e8..aca249240 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java @@ -122,27 +122,15 @@ final class SuggestionStripLayoutHelper { mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.suggestions_strip_height); final TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripViewStyle); + R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView); mSuggestionStripOption = a.getInt( R.styleable.SuggestionStripView_suggestionStripOption, 0); - final float alphaValidTypedWord = ResourceUtils.getFraction(a, - R.styleable.SuggestionStripView_alphaValidTypedWord, 1.0f); - final float alphaTypedWord = ResourceUtils.getFraction(a, - R.styleable.SuggestionStripView_alphaTypedWord, 1.0f); - final float alphaAutoCorrect = ResourceUtils.getFraction(a, - R.styleable.SuggestionStripView_alphaAutoCorrect, 1.0f); - final float alphaSuggested = ResourceUtils.getFraction(a, - R.styleable.SuggestionStripView_alphaSuggested, 1.0f); mAlphaObsoleted = ResourceUtils.getFraction(a, - R.styleable.SuggestionStripView_alphaSuggested, 1.0f); - mColorValidTypedWord = applyAlpha(a.getColor( - R.styleable.SuggestionStripView_colorValidTypedWord, 0), alphaValidTypedWord); - mColorTypedWord = applyAlpha(a.getColor( - R.styleable.SuggestionStripView_colorTypedWord, 0), alphaTypedWord); - mColorAutoCorrect = applyAlpha(a.getColor( - R.styleable.SuggestionStripView_colorAutoCorrect, 0), alphaAutoCorrect); - mColorSuggested = applyAlpha(a.getColor( - R.styleable.SuggestionStripView_colorSuggested, 0), alphaSuggested); + R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); + mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0); + mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0); + mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0); + mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0); mSuggestionsCountInStrip = a.getInt( R.styleable.SuggestionStripView_suggestionsCountInStrip, DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); diff --git a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java index 34eccd65b..021bf0825 100644 --- a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java @@ -27,10 +27,8 @@ import com.android.inputmethod.latin.BinaryDictionaryGetter; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; -import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.Locale; @@ -281,13 +279,7 @@ public class DictionaryInfoUtils { } public static FileHeader getDictionaryFileHeaderOrNull(final File file) { - try { - return BinaryDictIOUtils.getDictionaryFileHeader(file, 0, file.length()); - } catch (UnsupportedFormatException e) { - return null; - } catch (IOException e) { - return null; - } + return BinaryDictIOUtils.getDictionaryFileHeaderOrNull(file, 0, file.length()); } private static DictionaryInfo createDictionaryInfoFromFileAddress( diff --git a/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java b/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java index 768d68cb3..99788f6f2 100644 --- a/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java @@ -19,8 +19,8 @@ package com.android.inputmethod.latin.utils; import android.util.Log; import com.android.inputmethod.annotations.UsedForTesting; -import com.android.inputmethod.latin.makedict.BinaryDictEncoder; import com.android.inputmethod.latin.makedict.BinaryDictIOUtils; +import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; @@ -30,10 +30,10 @@ import com.android.inputmethod.latin.makedict.Ver3DictDecoder; import com.android.inputmethod.latin.personalization.UserHistoryDictionaryBigramList; import java.io.IOException; -import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; -import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; /** * Reads and writes Binary files for a UserHistoryDictionary. @@ -57,12 +57,12 @@ public final class UserHistoryDictIOUtils { /** * Writes dictionary to file. */ - public static void writeDictionaryBinary(final OutputStream destination, + public static void writeDictionary(final DictEncoder dictEncoder, final BigramDictionaryInterface dict, final UserHistoryDictionaryBigramList bigrams, final FormatOptions formatOptions) { final FusionDictionary fusionDict = constructFusionDictionary(dict, bigrams); try { - BinaryDictEncoder.writeDictionaryBinary(destination, fusionDict, formatOptions); + dictEncoder.writeDictionary(fusionDict, formatOptions); Log.d(TAG, "end writing"); } catch (IOException e) { Log.e(TAG, "IO exception while writing file", e); @@ -120,12 +120,11 @@ public final class UserHistoryDictIOUtils { */ public static void readDictionaryBinary(final Ver3DictDecoder dictDecoder, final OnAddWordListener dict) { - final Map<Integer, String> unigrams = CollectionUtils.newTreeMap(); - final Map<Integer, Integer> frequencies = CollectionUtils.newTreeMap(); - final Map<Integer, ArrayList<PendingAttribute>> bigrams = CollectionUtils.newTreeMap(); + final TreeMap<Integer, String> unigrams = CollectionUtils.newTreeMap(); + final TreeMap<Integer, Integer> frequencies = CollectionUtils.newTreeMap(); + final TreeMap<Integer, ArrayList<PendingAttribute>> bigrams = CollectionUtils.newTreeMap(); try { - BinaryDictIOUtils.readUnigramsAndBigramsBinary(dictDecoder, unigrams, frequencies, - bigrams); + dictDecoder.readUnigramsAndBigramsBinary(unigrams, frequencies, bigrams); } catch (IOException e) { Log.e(TAG, "IO exception while reading file", e); } catch (UnsupportedFormatException e) { @@ -140,10 +139,11 @@ public final class UserHistoryDictIOUtils { * Adds all unigrams and bigrams in maps to OnAddWordListener. */ @UsedForTesting - static void addWordsFromWordMap(final Map<Integer, String> unigrams, - final Map<Integer, Integer> frequencies, - final Map<Integer, ArrayList<PendingAttribute>> bigrams, final OnAddWordListener to) { - for (Map.Entry<Integer, String> entry : unigrams.entrySet()) { + static void addWordsFromWordMap(final TreeMap<Integer, String> unigrams, + final TreeMap<Integer, Integer> frequencies, + final TreeMap<Integer, ArrayList<PendingAttribute>> bigrams, + final OnAddWordListener to) { + for (Entry<Integer, String> entry : unigrams.entrySet()) { final String word1 = entry.getValue(); final int unigramFrequency = frequencies.get(entry.getKey()); to.setUnigram(word1, null, unigramFrequency); diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 3a3408266..da9c61103 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -1427,7 +1427,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang kid.navigateNext(), kid.navigatePrevious(), kid.mClobberSettingsKey, isPasswordView, kid.mShortcutKeyEnabled, kid.mHasShortcutKey, kid.mLanguageSwitchKeyEnabled, kid.isMultiLine(), keyboard.mOccupiedWidth, - keyboard.mOccupiedHeight, keyboard.mKeys); + keyboard.mOccupiedHeight, keyboard.getKeys()); } /** diff --git a/native/jni/Android.mk b/native/jni/Android.mk index a51fe3c03..bf188971e 100644 --- a/native/jni/Android.mk +++ b/native/jni/Android.mk @@ -71,14 +71,16 @@ LATIN_IME_CORE_SRC_FILES := \ header/header_policy.cpp \ header/header_reading_utils.cpp \ shortcut/shortcut_list_reading_utils.cpp \ - utils/byte_array_utils.cpp \ - utils/format_utils.cpp \ dictionary_structure_with_buffer_policy_factory.cpp \ dynamic_patricia_trie_node_reader.cpp \ dynamic_patricia_trie_policy.cpp \ dynamic_patricia_trie_reading_utils.cpp \ patricia_trie_policy.cpp \ patricia_trie_reading_utils.cpp) \ + $(addprefix suggest/policyimpl/dictionary/utils/, \ + byte_array_utils.cpp \ + extendable_buffer.cpp \ + format_utils.cpp) \ suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp \ $(addprefix suggest/policyimpl/typing/, \ scoring_params.cpp \ diff --git a/native/jni/src/suggest/policyimpl/dictionary/bigram/dynamic_bigram_list_policy.h b/native/jni/src/suggest/policyimpl/dictionary/bigram/dynamic_bigram_list_policy.h new file mode 100644 index 000000000..513878e1d --- /dev/null +++ b/native/jni/src/suggest/policyimpl/dictionary/bigram/dynamic_bigram_list_policy.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LATINIME_DYNAMIC_BIGRAM_LIST_POLICY_H +#define LATINIME_DYNAMIC_BIGRAM_LIST_POLICY_H + +#include <stdint.h> + +#include "defines.h" +#include "suggest/core/policy/dictionary_bigrams_structure_policy.h" +#include "suggest/policyimpl/dictionary/bigram/bigram_list_reading_utils.h" +#include "suggest/policyimpl/dictionary/utils/extendable_buffer.h" + +namespace latinime { + +/* + * This is a dynamic version of BigramListPolicy and supports an additional buffer. + */ +class DynamicBigramListPolicy : public DictionaryBigramsStructurePolicy { + public: + DynamicBigramListPolicy(const uint8_t *const bigramsBuf, const int bufSize, + const ExtendableBuffer *const additionalBuffer) + : mDictRoot(bigramsBuf), mBufSize(bufSize), mAdditionalBuffer(additionalBuffer) {} + + ~DynamicBigramListPolicy() {} + + void getNextBigram(int *const outBigramPos, int *const outProbability, bool *const outHasNext, + int *const pos) const { + const bool usesAdditionalBuffer = *pos >= mBufSize; + const uint8_t *const buffer = (usesAdditionalBuffer) ? + mAdditionalBuffer->getBuffer() : mDictRoot; + if (usesAdditionalBuffer) { + *pos -= mBufSize; + } + const BigramListReadingUtils::BigramFlags flags = + BigramListReadingUtils::getFlagsAndForwardPointer(buffer, pos); + *outBigramPos = BigramListReadingUtils::getBigramAddressAndForwardPointer( + buffer, flags, pos); + if (usesAdditionalBuffer) { + *outBigramPos += mBufSize; + } + *outProbability = BigramListReadingUtils::getProbabilityFromFlags(flags); + *outHasNext = BigramListReadingUtils::hasNext(flags); + if (usesAdditionalBuffer) { + *pos += mBufSize; + } + } + + void skipAllBigrams(int *const pos) const { + if (*pos >= mBufSize) { + *pos -= mBufSize; + BigramListReadingUtils::skipExistingBigrams(mAdditionalBuffer->getBuffer(), pos); + *pos += mBufSize; + } else { + BigramListReadingUtils::skipExistingBigrams(mDictRoot, pos); + } + } + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicBigramListPolicy); + + const uint8_t *const mDictRoot; + const int mBufSize; + const ExtendableBuffer *const mAdditionalBuffer; +}; +} // namespace latinime +#endif // LATINIME_DYNAMIC_BIGRAM_LIST_POLICY_H diff --git a/native/jni/src/suggest/policyimpl/dictionary/dictionary_structure_with_buffer_policy_factory.cpp b/native/jni/src/suggest/policyimpl/dictionary/dictionary_structure_with_buffer_policy_factory.cpp index cc5252c43..434858d67 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/dictionary_structure_with_buffer_policy_factory.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/dictionary_structure_with_buffer_policy_factory.cpp @@ -22,7 +22,7 @@ #include "suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.h" #include "suggest/policyimpl/dictionary/patricia_trie_policy.h" #include "suggest/policyimpl/dictionary/utils/format_utils.h" -#include "suggest/policyimpl/dictionary/utils/mmaped_buffer.h" +#include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" namespace latinime { @@ -31,7 +31,7 @@ namespace latinime { const int bufOffset, const int size, const bool isUpdatable) { // Allocated buffer in MmapedBuffer::openBuffer() will be freed in the destructor of // impl classes of DictionaryStructureWithBufferPolicy. - const MmapedBuffer *const mmapedBuffer = MmapedBuffer::openBuffer(path, pathLength, bufOffset, + const MmappedBuffer *const mmapedBuffer = MmappedBuffer::openBuffer(path, pathLength, bufOffset, size, isUpdatable); if (!mmapedBuffer) { return 0; diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp index 77a85c86d..c427ebe2d 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.cpp @@ -19,34 +19,44 @@ #include "suggest/core/policy/dictionary_bigrams_structure_policy.h" #include "suggest/core/policy/dictionary_shortcuts_structure_policy.h" #include "suggest/policyimpl/dictionary/dynamic_patricia_trie_reading_utils.h" +#include "suggest/policyimpl/dictionary/utils/extendable_buffer.h" namespace latinime { void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(const int nodePos, const int maxCodePointCount, int *const outCodePoints) { - int pos = nodePos; - mFlags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(mDictRoot, &pos); + const bool usesAdditionalBuffer = nodePos >= mOriginalDictSize; + const uint8_t *const dictBuf = + usesAdditionalBuffer ? mExtendableBuffer->getBuffer() : mDictRoot; + int pos = (usesAdditionalBuffer) ? nodePos - mOriginalDictSize : nodePos; + mFlags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(dictBuf, &pos); const int parentPos = - DynamicPatriciaTrieReadingUtils::getParentPosAndAdvancePosition(mDictRoot, &pos); + DynamicPatriciaTrieReadingUtils::getParentPosAndAdvancePosition(dictBuf, &pos); mParentPos = (parentPos != 0) ? mNodePos + parentPos : NOT_A_DICT_POS; if (outCodePoints != 0) { mCodePointCount = PatriciaTrieReadingUtils::getCharsAndAdvancePosition( - mDictRoot, mFlags, maxCodePointCount, outCodePoints, &pos); + dictBuf, mFlags, maxCodePointCount, outCodePoints, &pos); } else { mCodePointCount = PatriciaTrieReadingUtils::skipCharacters( - mDictRoot, mFlags, MAX_WORD_LENGTH, &pos); + dictBuf, mFlags, MAX_WORD_LENGTH, &pos); } if (isTerminal()) { - mProbability = PatriciaTrieReadingUtils::readProbabilityAndAdvancePosition(mDictRoot, &pos); + mProbability = PatriciaTrieReadingUtils::readProbabilityAndAdvancePosition(dictBuf, &pos); } else { mProbability = NOT_A_PROBABILITY; } if (hasChildren()) { mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition( - mDictRoot, mFlags, &pos); + dictBuf, mFlags, &pos); + if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) { + mChildrenPos += mOriginalDictSize; + } } else { mChildrenPos = NOT_A_DICT_POS; } + if (usesAdditionalBuffer) { + pos += mOriginalDictSize; + } if (PatriciaTrieReadingUtils::hasShortcutTargets(mFlags)) { mShortcutPos = pos; mShortcutsPolicy->skipAllShortcuts(&pos); diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.h b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.h index e990809e8..2a636289e 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.h +++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_node_reader.h @@ -27,6 +27,7 @@ namespace latinime { class DictionaryBigramsStructurePolicy; class DictionaryShortcutsStructurePolicy; +class ExtendableBuffer; /* * This class is used for helping to read nodes of dynamic patricia trie. This class handles moved @@ -34,12 +35,14 @@ class DictionaryShortcutsStructurePolicy; */ class DynamicPatriciaTrieNodeReader { public: - DynamicPatriciaTrieNodeReader(const uint8_t *const dictRoot, + DynamicPatriciaTrieNodeReader(const uint8_t *const dictRoot, const int originalDictSize, + const ExtendableBuffer *const extendableBuffer, const DictionaryBigramsStructurePolicy *const bigramsPolicy, const DictionaryShortcutsStructurePolicy *const shortcutsPolicy) - : mDictRoot(dictRoot), mBigramsPolicy(bigramsPolicy), + : mDictRoot(dictRoot), mOriginalDictSize(originalDictSize), + mExtendableBuffer(extendableBuffer), mBigramsPolicy(bigramsPolicy), mShortcutsPolicy(shortcutsPolicy), mNodePos(NOT_A_VALID_WORD_POS), mFlags(0), - mParentPos(NOT_A_DICT_POS), mCodePointCount(0), mProbability(NOT_A_PROBABILITY), + mParentPos(NOT_A_DICT_POS), mCodePointCount(0), mProbability(NOT_A_PROBABILITY), mChildrenPos(NOT_A_DICT_POS), mShortcutPos(NOT_A_DICT_POS), mBigramPos(NOT_A_DICT_POS), mSiblingPos(NOT_A_VALID_WORD_POS) {} @@ -123,6 +126,8 @@ class DynamicPatriciaTrieNodeReader { // TODO: Consolidate mDictRoot. const uint8_t *const mDictRoot; + const int mOriginalDictSize; + const ExtendableBuffer *const mExtendableBuffer; const DictionaryBigramsStructurePolicy *const mBigramsPolicy; const DictionaryShortcutsStructurePolicy *const mShortcutsPolicy; int mNodePos; diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp index 3000860a3..b244dd0b5 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp @@ -33,13 +33,13 @@ void DynamicPatriciaTriePolicy::createAndGetAllChildNodes(const DicNode *const d if (!dicNode->hasChildren()) { return; } - DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), - getShortcutsStructurePolicy()); + DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, mOriginalDictSize, &mExtendableBuffer, + getBigramsStructurePolicy(), getShortcutsStructurePolicy()); int mergedNodeCodePoints[MAX_WORD_LENGTH]; int nextPos = dicNode->getChildrenPos(); int totalChildCount = 0; do { - const int childCount = PatriciaTrieReadingUtils::getGroupCountAndAdvancePosition( + const int childCount = PatriciaTrieReadingUtils::getPtNodeArraySizeAndAdvancePosition( mDictRoot, &nextPos); totalChildCount += childCount; if (childCount <= 0 || totalChildCount > MAX_CHILD_COUNT_TO_AVOID_INFINITE_LOOP) { @@ -79,8 +79,8 @@ int DynamicPatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCoun int mergedNodeCodePoints[maxCodePointCount]; int codePointCount = 0; - DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), - getShortcutsStructurePolicy()); + DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, mOriginalDictSize, &mExtendableBuffer, + getBigramsStructurePolicy(), getShortcutsStructurePolicy()); // First, read terminal node and get its probability. nodeReader.fetchNodeInfoFromBufferAndGetNodeCodePoints(nodePos, maxCodePointCount, mergedNodeCodePoints); @@ -124,14 +124,14 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in int mergedNodeCodePoints[MAX_WORD_LENGTH]; int currentLength = 0; int pos = getRootPosition(); - DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), - getShortcutsStructurePolicy()); - while (currentLength <= length) { + DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, mOriginalDictSize, &mExtendableBuffer, + getBigramsStructurePolicy(), getShortcutsStructurePolicy()); + while (currentLength < length) { // When foundMatchedNode becomes true, currentLength is increased at least once. bool foundMatchedNode = false; int totalChildCount = 0; do { - const int childCount = PatriciaTrieReadingUtils::getGroupCountAndAdvancePosition( + const int childCount = PatriciaTrieReadingUtils::getPtNodeArraySizeAndAdvancePosition( mDictRoot, &pos); totalChildCount += childCount; if (childCount <= 0 || totalChildCount > MAX_CHILD_COUNT_TO_AVOID_INFINITE_LOOP) { @@ -144,13 +144,15 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in for (int i = 0; i < childCount; i++) { nodeReader.fetchNodeInfoFromBufferAndGetNodeCodePoints(pos, MAX_WORD_LENGTH, mergedNodeCodePoints); - if (nodeReader.isDeleted() || nodeReader.getCodePointCount() <= 0) { + const int nodeCodePointCount = nodeReader.getCodePointCount(); + if (nodeReader.isDeleted() || nodeCodePointCount <= 0 + || currentLength + nodeCodePointCount > length) { // Skip deleted or empty node. pos = nodeReader.getSiblingNodePos(); continue; } bool matched = true; - for (int j = 0; j < nodeReader.getCodePointCount(); ++j) { + for (int j = 0; j < nodeCodePointCount; ++j) { if (mergedNodeCodePoints[j] != searchCodePoints[currentLength + j]) { // Different code point is found. matched = false; @@ -158,7 +160,7 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in } } if (matched) { - currentLength += nodeReader.getCodePointCount(); + currentLength += nodeCodePointCount; if (length == currentLength) { // Terminal position is found. return nodeReader.getNodePos(); @@ -177,7 +179,7 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in if (foundMatchedNode) { break; } - // If the matched node is not found in the current node group, try to follow the + // If the matched node is not found in the current PtNode array, try to follow the // forward link. pos = DynamicPatriciaTrieReadingUtils::getForwardLinkPosition( mDictRoot, pos); @@ -196,8 +198,8 @@ int DynamicPatriciaTriePolicy::getUnigramProbability(const int nodePos) const { if (nodePos == NOT_A_VALID_WORD_POS) { return NOT_A_PROBABILITY; } - DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), - getShortcutsStructurePolicy()); + DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, mOriginalDictSize, &mExtendableBuffer, + getBigramsStructurePolicy(), getShortcutsStructurePolicy()); nodeReader.fetchNodeInfoFromBuffer(nodePos); if (nodeReader.isDeleted() || nodeReader.isBlacklisted() || nodeReader.isNotAWord()) { return NOT_A_PROBABILITY; @@ -209,8 +211,8 @@ int DynamicPatriciaTriePolicy::getShortcutPositionOfNode(const int nodePos) cons if (nodePos == NOT_A_VALID_WORD_POS) { return NOT_A_DICT_POS; } - DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), - getShortcutsStructurePolicy()); + DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, mOriginalDictSize, &mExtendableBuffer, + getBigramsStructurePolicy(), getShortcutsStructurePolicy()); nodeReader.fetchNodeInfoFromBuffer(nodePos); if (nodeReader.isDeleted()) { return NOT_A_DICT_POS; @@ -222,8 +224,8 @@ int DynamicPatriciaTriePolicy::getBigramsPositionOfNode(const int nodePos) const if (nodePos == NOT_A_VALID_WORD_POS) { return NOT_A_DICT_POS; } - DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), - getShortcutsStructurePolicy()); + DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, mOriginalDictSize, &mExtendableBuffer, + getBigramsStructurePolicy(), getShortcutsStructurePolicy()); nodeReader.fetchNodeInfoFromBuffer(nodePos); if (nodeReader.isDeleted()) { return NOT_A_DICT_POS; diff --git a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.h b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.h index 708967d7b..73b963212 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.h +++ b/native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.h @@ -21,10 +21,11 @@ #include "defines.h" #include "suggest/core/policy/dictionary_structure_with_buffer_policy.h" -#include "suggest/policyimpl/dictionary/bigram/bigram_list_policy.h" +#include "suggest/policyimpl/dictionary/bigram/dynamic_bigram_list_policy.h" #include "suggest/policyimpl/dictionary/header/header_policy.h" -#include "suggest/policyimpl/dictionary/shortcut/shortcut_list_policy.h" -#include "suggest/policyimpl/dictionary/utils/mmaped_buffer.h" +#include "suggest/policyimpl/dictionary/shortcut/dynamic_shortcut_list_policy.h" +#include "suggest/policyimpl/dictionary/utils/extendable_buffer.h" +#include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" namespace latinime { @@ -33,10 +34,12 @@ class DicNodeVector; class DynamicPatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { public: - DynamicPatriciaTriePolicy(const MmapedBuffer *const buffer) - : mBuffer(buffer), mHeaderPolicy(mBuffer->getBuffer()), + DynamicPatriciaTriePolicy(const MmappedBuffer *const buffer) + : mBuffer(buffer), mExtendableBuffer(), mHeaderPolicy(mBuffer->getBuffer()), mDictRoot(mBuffer->getBuffer() + mHeaderPolicy.getSize()), - mBigramListPolicy(mDictRoot), mShortcutListPolicy(mDictRoot) {} + mOriginalDictSize(mBuffer->getBufferSize() - mHeaderPolicy.getSize()), + mBigramListPolicy(mDictRoot, mOriginalDictSize, &mExtendableBuffer), + mShortcutListPolicy(mDictRoot, mOriginalDictSize, &mExtendableBuffer) {} ~DynamicPatriciaTriePolicy() { delete mBuffer; @@ -86,12 +89,15 @@ class DynamicPatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicPatriciaTriePolicy); static const int MAX_CHILD_COUNT_TO_AVOID_INFINITE_LOOP; - const MmapedBuffer *const mBuffer; + const MmappedBuffer *const mBuffer; + const ExtendableBuffer mExtendableBuffer; const HeaderPolicy mHeaderPolicy; // TODO: Consolidate mDictRoot. + // CAVEAT!: Be careful about array out of bound access with mDictRoot const uint8_t *const mDictRoot; - const BigramListPolicy mBigramListPolicy; - const ShortcutListPolicy mShortcutListPolicy; + const int mOriginalDictSize; + const DynamicBigramListPolicy mBigramListPolicy; + const DynamicShortcutListPolicy mShortcutListPolicy; }; } // namespace latinime #endif // LATINIME_DYNAMIC_PATRICIA_TRIE_POLICY_H diff --git a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.cpp index 15eb0674d..adcf2dbdf 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.cpp @@ -30,7 +30,7 @@ void PatriciaTriePolicy::createAndGetAllChildNodes(const DicNode *const dicNode, return; } int nextPos = dicNode->getChildrenPos(); - const int childCount = PatriciaTrieReadingUtils::getGroupCountAndAdvancePosition( + const int childCount = PatriciaTrieReadingUtils::getPtNodeArraySizeAndAdvancePosition( mDictRoot, &nextPos); for (int i = 0; i < childCount; i++) { nextPos = createAndGetLeavingChildNode(dicNode, nextPos, childDicNodes); @@ -40,15 +40,15 @@ void PatriciaTriePolicy::createAndGetAllChildNodes(const DicNode *const dicNode, // This retrieves code points and the probability of the word by its terminal position. // Due to the fact that words are ordered in the dictionary in a strict breadth-first order, // it is possible to check for this with advantageous complexity. For each node, we search -// for groups with children and compare the children position with the position we look for. +// for PtNodes with children and compare the children position with the position we look for. // When we shoot the position we look for, it means the word we look for is in the children -// of the previous group. The only tricky part is the fact that if we arrive at the end of a -// node with the last group's children position still less than what we are searching for, we -// must descend the last group's children (for example, if the word we are searching for starts -// with a z, it's the last group of the root node, so all children addresses will be smaller +// of the previous PtNode. The only tricky part is the fact that if we arrive at the end of a +// PtNode array with the last PtNode's children position still less than what we are searching for, +// we must descend the last PtNode's children (for example, if the word we are searching for starts +// with a z, it's the last PtNode of the root array, so all children addresses will be smaller // than the position we look for, and we have to descend the z node). /* Parameters : - * nodePos: the byte position of the terminal chargroup of the word we are searching for (this is + * nodePos: the byte position of the terminal PtNode of the word we are searching for (this is * what is stored as the "bigram position" in each bigram) * outCodePoints: an array to write the found word, with MAX_WORD_LENGTH size. * outUnigramProbability: a pointer to an int to write the probability into. @@ -60,18 +60,18 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount( int *const outUnigramProbability) const { int pos = getRootPosition(); int wordPos = 0; - // One iteration of the outer loop iterates through nodes. As stated above, we will only - // traverse nodes that are actually a part of the terminal we are searching, so each time + // One iteration of the outer loop iterates through PtNode arrays. As stated above, we will + // only traverse nodes that are actually a part of the terminal we are searching, so each time // we enter this loop we are one depth level further than last time. // The only reason we count nodes is because we want to reduce the probability of infinite // looping in case there is a bug. Since we know there is an upper bound to the depth we are // supposed to traverse, it does not hurt to count iterations. for (int loopCount = maxCodePointCount; loopCount > 0; --loopCount) { - int lastCandidateGroupPos = 0; - // Let's loop through char groups in this node searching for either the terminal + int lastCandidatePtNodePos = 0; + // Let's loop through PtNodes in this PtNode array searching for either the terminal // or one of its ascendants. - for (int charGroupCount = PatriciaTrieReadingUtils::getGroupCountAndAdvancePosition( - mDictRoot, &pos); charGroupCount > 0; --charGroupCount) { + for (int ptNodeCount = PatriciaTrieReadingUtils::getPtNodeArraySizeAndAdvancePosition( + mDictRoot, &pos); ptNodeCount > 0; --ptNodeCount) { const int startPos = pos; const PatriciaTrieReadingUtils::NodeFlags flags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(mDictRoot, &pos); @@ -98,7 +98,7 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount( &pos); return ++wordPos; } - // We need to skip past this char group, so skip any remaining code points after the + // We need to skip past this PtNode, so skip any remaining code points after the // first and possibly the probability. if (PatriciaTrieReadingUtils::hasMultipleChars(flags)) { PatriciaTrieReadingUtils::skipCharacters(mDictRoot, flags, MAX_WORD_LENGTH, &pos); @@ -106,8 +106,8 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount( if (PatriciaTrieReadingUtils::isTerminal(flags)) { PatriciaTrieReadingUtils::readProbabilityAndAdvancePosition(mDictRoot, &pos); } - // The fact that this group has children is very important. Since we already know - // that this group does not match, if it has no children we know it is irrelevant + // The fact that this PtNode has children is very important. Since we already know + // that this PtNode does not match, if it has no children we know it is irrelevant // to what we are searching for. const bool hasChildren = PatriciaTrieReadingUtils::hasChildrenInFlags(flags); // We will write in `found' whether we have passed the children position we are @@ -122,45 +122,45 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount( ::readChildrenPositionAndAdvancePosition(mDictRoot, flags, ¤tPos); if (childrenPos > nodePos) { // If the children pos is greater than the position, it means the previous - // chargroup, which position is stored in lastCandidateGroupPos, was the right + // PtNode, which position is stored in lastCandidatePtNodePos, was the right // one. found = true; - } else if (1 >= charGroupCount) { - // However if we are on the LAST group of this node, and we have NOT shot the - // position we should descend THIS node. So we trick the lastCandidateGroupPos - // so that we will descend this node, not the previous one. - lastCandidateGroupPos = startPos; + } else if (1 >= ptNodeCount) { + // However if we are on the LAST PtNode of this array, and we have NOT shot the + // position we should descend THIS node. So we trick the lastCandidatePtNodePos + // so that we will descend this PtNode, not the previous one. + lastCandidatePtNodePos = startPos; found = true; } else { // Else, we should continue looking. found = false; } } else { - // Even if we don't have children here, we could still be on the last group of this - // node. If this is the case, we should descend the last group that had children, - // and their position is already in lastCandidateGroup. - found = (1 >= charGroupCount); + // Even if we don't have children here, we could still be on the last PtNode of / + // this array. If this is the case, we should descend the last PtNode that had + // children, and their position is already in lastCandidatePtNodePos. + found = (1 >= ptNodeCount); } if (found) { - // Okay, we found the group we should descend. Its position is in - // the lastCandidateGroupPos variable, so we just re-read it. - if (0 != lastCandidateGroupPos) { + // Okay, we found the PtNode we should descend. Its position is in + // the lastCandidatePtNodePos variable, so we just re-read it. + if (0 != lastCandidatePtNodePos) { const PatriciaTrieReadingUtils::NodeFlags lastFlags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition( - mDictRoot, &lastCandidateGroupPos); + mDictRoot, &lastCandidatePtNodePos); const int lastChar = PatriciaTrieReadingUtils::getCodePointAndAdvancePosition( - mDictRoot, &lastCandidateGroupPos); - // We copy all the characters in this group to the buffer + mDictRoot, &lastCandidatePtNodePos); + // We copy all the characters in this PtNode to the buffer outCodePoints[wordPos] = lastChar; if (PatriciaTrieReadingUtils::hasMultipleChars(lastFlags)) { int nextChar = PatriciaTrieReadingUtils::getCodePointAndAdvancePosition( - mDictRoot, &lastCandidateGroupPos); + mDictRoot, &lastCandidatePtNodePos); int charCount = maxCodePointCount; while (-1 != nextChar && --charCount > 0) { outCodePoints[++wordPos] = nextChar; nextChar = PatriciaTrieReadingUtils::getCodePointAndAdvancePosition( - mDictRoot, &lastCandidateGroupPos); + mDictRoot, &lastCandidatePtNodePos); } } ++wordPos; @@ -168,19 +168,19 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount( // it's there, read pos, and break to resume the search at pos. if (PatriciaTrieReadingUtils::isTerminal(lastFlags)) { PatriciaTrieReadingUtils::readProbabilityAndAdvancePosition(mDictRoot, - &lastCandidateGroupPos); + &lastCandidatePtNodePos); } pos = PatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition( - mDictRoot, lastFlags, &lastCandidateGroupPos); + mDictRoot, lastFlags, &lastCandidatePtNodePos); break; } else { // Here is a little tricky part: we come here if we found out that all children - // addresses in this group are bigger than the address we are searching for. + // addresses in this PtNode are bigger than the address we are searching for. // Should we conclude the word is not in the dictionary? No! It could still be - // one of the remaining chargroups in this node, so we have to keep looking in - // this node until we find it (or we realize it's not there either, in which - // case it's actually not in the dictionary). Pass the end of this group, ready - // to start the next one. + // one of the remaining PtNodes in this array, so we have to keep looking in + // this array until we find it (or we realize it's not there either, in which + // case it's actually not in the dictionary). Pass the end of this PtNode, + // ready to start the next one. if (PatriciaTrieReadingUtils::hasChildrenInFlags(flags)) { PatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition( mDictRoot, flags, &pos); @@ -195,9 +195,9 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount( } else { // If we did not find it, we should record the last children address for the next // iteration. - if (hasChildren) lastCandidateGroupPos = startPos; - // Now skip the end of this group (children pos and the attributes if any) so that - // our pos is after the end of this char group, at the start of the next one. + if (hasChildren) lastCandidatePtNodePos = startPos; + // Now skip the end of this PtNode (children pos and the attributes if any) so that + // our pos is after the end of this PtNode, at the start of the next one. if (PatriciaTrieReadingUtils::hasChildrenInFlags(flags)) { PatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition( mDictRoot, flags, &pos); @@ -212,7 +212,7 @@ int PatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCount( } } - // If we have looked through all the chargroups and found no match, the nodePos is + // If we have looked through all the PtNodes and found no match, the nodePos is // not the position of a terminal in this dictionary. return 0; } @@ -228,24 +228,24 @@ int PatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const inWord, // If we already traversed the tree further than the word is long, there means // there was no match (or we would have found it). if (wordPos >= length) return NOT_A_VALID_WORD_POS; - int charGroupCount = PatriciaTrieReadingUtils::getGroupCountAndAdvancePosition(mDictRoot, + int ptNodeCount = PatriciaTrieReadingUtils::getPtNodeArraySizeAndAdvancePosition(mDictRoot, &pos); const int wChar = forceLowerCaseSearch ? CharUtils::toLowerCase(inWord[wordPos]) : inWord[wordPos]; while (true) { - // If there are no more character groups in this node, it means we could not + // If there are no more PtNodes in this array, it means we could not // find a matching character for this depth, therefore there is no match. - if (0 >= charGroupCount) return NOT_A_VALID_WORD_POS; - const int charGroupPos = pos; + if (0 >= ptNodeCount) return NOT_A_VALID_WORD_POS; + const int ptNodePos = pos; const PatriciaTrieReadingUtils::NodeFlags flags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(mDictRoot, &pos); int character = PatriciaTrieReadingUtils::getCodePointAndAdvancePosition(mDictRoot, &pos); if (character == wChar) { - // This is the correct node. Only one character group may start with the same - // char within a node, so either we found our match in this node, or there is + // This is the correct PtNode. Only one PtNode may start with the same char within + // a PtNode array, so either we found our match in this array, or there is // no match and we can return NOT_A_VALID_WORD_POS. So we will check all the - // characters in this character group indeed does match. + // characters in this PtNode indeed does match. if (PatriciaTrieReadingUtils::hasMultipleChars(flags)) { character = PatriciaTrieReadingUtils::getCodePointAndAdvancePosition(mDictRoot, &pos); @@ -253,7 +253,7 @@ int PatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const inWord, ++wordPos; // If we shoot the length of the word we search for, or if we find a single // character that does not match, as explained above, it means the word is - // not in the dictionary (by virtue of this chargroup being the only one to + // not in the dictionary (by virtue of this PtNode being the only one to // match the word on the first character, but not matching the whole word). if (wordPos >= length) return NOT_A_VALID_WORD_POS; if (inWord[wordPos] != character) return NOT_A_VALID_WORD_POS; @@ -268,7 +268,7 @@ int PatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const inWord, ++wordPos; if (PatriciaTrieReadingUtils::isTerminal(flags)) { if (wordPos == length) { - return charGroupPos; + return ptNodePos; } PatriciaTrieReadingUtils::readProbabilityAndAdvancePosition(mDictRoot, &pos); } @@ -282,7 +282,7 @@ int PatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const inWord, flags, &pos); break; } else { - // This chargroup does not match, so skip the remaining part and go to the next. + // This PtNode does not match, so skip the remaining part and go to the next. if (PatriciaTrieReadingUtils::hasMultipleChars(flags)) { PatriciaTrieReadingUtils::skipCharacters(mDictRoot, flags, MAX_WORD_LENGTH, &pos); @@ -301,7 +301,7 @@ int PatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const inWord, mBigramListPolicy.skipAllBigrams(&pos); } } - --charGroupCount; + --ptNodeCount; } } } diff --git a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.h b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.h index 0d85050f3..d0567fd85 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.h +++ b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_policy.h @@ -24,7 +24,7 @@ #include "suggest/policyimpl/dictionary/bigram/bigram_list_policy.h" #include "suggest/policyimpl/dictionary/header/header_policy.h" #include "suggest/policyimpl/dictionary/shortcut/shortcut_list_policy.h" -#include "suggest/policyimpl/dictionary/utils/mmaped_buffer.h" +#include "suggest/policyimpl/dictionary/utils/mmapped_buffer.h" namespace latinime { @@ -33,7 +33,7 @@ class DicNodeVector; class PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { public: - PatriciaTriePolicy(const MmapedBuffer *const buffer) + PatriciaTriePolicy(const MmappedBuffer *const buffer) : mBuffer(buffer), mHeaderPolicy(mBuffer->getBuffer()), mDictRoot(mBuffer->getBuffer() + mHeaderPolicy.getSize()), mBigramListPolicy(mDictRoot), mShortcutListPolicy(mDictRoot) {} @@ -97,7 +97,7 @@ class PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { private: DISALLOW_IMPLICIT_CONSTRUCTORS(PatriciaTriePolicy); - const MmapedBuffer *const mBuffer; + const MmappedBuffer *const mBuffer; const HeaderPolicy mHeaderPolicy; const uint8_t *const mDictRoot; const BigramListPolicy mBigramListPolicy; diff --git a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.cpp b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.cpp index 003b9435b..576a158bc 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.cpp @@ -23,15 +23,15 @@ namespace latinime { typedef PatriciaTrieReadingUtils PtReadingUtils; -const PtReadingUtils::NodeFlags PtReadingUtils::MASK_GROUP_ADDRESS_TYPE = 0xC0; -const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_GROUP_ADDRESS_TYPE_NOADDRESS = 0x00; -const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_GROUP_ADDRESS_TYPE_ONEBYTE = 0x40; -const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_GROUP_ADDRESS_TYPE_TWOBYTES = 0x80; -const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_GROUP_ADDRESS_TYPE_THREEBYTES = 0xC0; +const PtReadingUtils::NodeFlags PtReadingUtils::MASK_CHILDREN_POSITION_TYPE = 0xC0; +const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_CHILDREN_POSITION_TYPE_NOPOSITION = 0x00; +const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_CHILDREN_POSITION_TYPE_ONEBYTE = 0x40; +const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_CHILDREN_POSITION_TYPE_TWOBYTES = 0x80; +const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_CHILDREN_POSITION_TYPE_THREEBYTES = 0xC0; // Flag for single/multiple char group const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_HAS_MULTIPLE_CHARS = 0x20; -// Flag for terminal groups +// Flag for terminal PtNodes const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_IS_TERMINAL = 0x10; // Flag for shortcut targets presence const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_HAS_SHORTCUT_TARGETS = 0x08; @@ -46,14 +46,14 @@ const PtReadingUtils::NodeFlags PtReadingUtils::FLAG_IS_BLACKLISTED = 0x01; const uint8_t *const buffer, const NodeFlags flags, int *const pos) { const int base = *pos; int offset = 0; - switch (MASK_GROUP_ADDRESS_TYPE & flags) { - case FLAG_GROUP_ADDRESS_TYPE_ONEBYTE: + switch (MASK_CHILDREN_POSITION_TYPE & flags) { + case FLAG_CHILDREN_POSITION_TYPE_ONEBYTE: offset = ByteArrayUtils::readUint8AndAdvancePosition(buffer, pos); break; - case FLAG_GROUP_ADDRESS_TYPE_TWOBYTES: + case FLAG_CHILDREN_POSITION_TYPE_TWOBYTES: offset = ByteArrayUtils::readUint16AndAdvancePosition(buffer, pos); break; - case FLAG_GROUP_ADDRESS_TYPE_THREEBYTES: + case FLAG_CHILDREN_POSITION_TYPE_THREEBYTES: offset = ByteArrayUtils::readUint24AndAdvancePosition(buffer, pos); break; default: diff --git a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.h b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.h index 9f2fc2059..f76c38751 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.h +++ b/native/jni/src/suggest/policyimpl/dictionary/patricia_trie_reading_utils.h @@ -28,7 +28,7 @@ class PatriciaTrieReadingUtils { public: typedef uint8_t NodeFlags; - static AK_FORCE_INLINE int getGroupCountAndAdvancePosition( + static AK_FORCE_INLINE int getPtNodeArraySizeAndAdvancePosition( const uint8_t *const buffer, int *const pos) { const uint8_t firstByte = ByteArrayUtils::readUint8AndAdvancePosition(buffer, pos); if (firstByte < 0x80) { @@ -116,17 +116,17 @@ class PatriciaTrieReadingUtils { } static AK_FORCE_INLINE bool hasChildrenInFlags(const NodeFlags flags) { - return FLAG_GROUP_ADDRESS_TYPE_NOADDRESS != (MASK_GROUP_ADDRESS_TYPE & flags); + return FLAG_CHILDREN_POSITION_TYPE_NOPOSITION != (MASK_CHILDREN_POSITION_TYPE & flags); } private: DISALLOW_IMPLICIT_CONSTRUCTORS(PatriciaTrieReadingUtils); - static const NodeFlags MASK_GROUP_ADDRESS_TYPE; - static const NodeFlags FLAG_GROUP_ADDRESS_TYPE_NOADDRESS; - static const NodeFlags FLAG_GROUP_ADDRESS_TYPE_ONEBYTE; - static const NodeFlags FLAG_GROUP_ADDRESS_TYPE_TWOBYTES; - static const NodeFlags FLAG_GROUP_ADDRESS_TYPE_THREEBYTES; + static const NodeFlags MASK_CHILDREN_POSITION_TYPE; + static const NodeFlags FLAG_CHILDREN_POSITION_TYPE_NOPOSITION; + static const NodeFlags FLAG_CHILDREN_POSITION_TYPE_ONEBYTE; + static const NodeFlags FLAG_CHILDREN_POSITION_TYPE_TWOBYTES; + static const NodeFlags FLAG_CHILDREN_POSITION_TYPE_THREEBYTES; static const NodeFlags FLAG_HAS_MULTIPLE_CHARS; static const NodeFlags FLAG_IS_TERMINAL; diff --git a/native/jni/src/suggest/policyimpl/dictionary/shortcut/dynamic_shortcut_list_policy.h b/native/jni/src/suggest/policyimpl/dictionary/shortcut/dynamic_shortcut_list_policy.h new file mode 100644 index 000000000..fdaf18f7c --- /dev/null +++ b/native/jni/src/suggest/policyimpl/dictionary/shortcut/dynamic_shortcut_list_policy.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LATINIME_DYNAMIC_SHORTCUT_LIST_POLICY_H +#define LATINIME_DYNAMIC_SHORTCUT_LIST_POLICY_H + +#include <stdint.h> + +#include "defines.h" +#include "suggest/core/policy/dictionary_shortcuts_structure_policy.h" +#include "suggest/policyimpl/dictionary/shortcut/shortcut_list_reading_utils.h" +#include "suggest/policyimpl/dictionary/utils/extendable_buffer.h" + +namespace latinime { + +/* + * This is a dynamic version of ShortcutListPolicy and supports an additional buffer. + */ +class DynamicShortcutListPolicy : public DictionaryShortcutsStructurePolicy { + public: + DynamicShortcutListPolicy(const uint8_t *const shortcutBuf, const int bufSize, + const ExtendableBuffer *const additionalBuffer) + : mShortcutsBuf(shortcutBuf), mBufSize(bufSize), mAdditionalBuffer(additionalBuffer) {} + + ~DynamicShortcutListPolicy() {} + + int getStartPos(const int pos) const { + if (pos == NOT_A_DICT_POS) { + return NOT_A_DICT_POS; + } + return pos + ShortcutListReadingUtils::getShortcutListSizeFieldSize(); + } + + void getNextShortcut(const int maxCodePointCount, int *const outCodePoint, + int *const outCodePointCount, bool *const outIsWhitelist, bool *const outHasNext, + int *const pos) const { + const bool usesAdditionalBuffer = *pos >= mBufSize; + const uint8_t *const buffer = usesAdditionalBuffer + ? mAdditionalBuffer->getBuffer() : mShortcutsBuf; + if (usesAdditionalBuffer) { + *pos -= mBufSize; + } + const ShortcutListReadingUtils::ShortcutFlags flags = + ShortcutListReadingUtils::getFlagsAndForwardPointer(buffer, pos); + if (outHasNext) { + *outHasNext = ShortcutListReadingUtils::hasNext(flags); + } + if (outIsWhitelist) { + *outIsWhitelist = ShortcutListReadingUtils::isWhitelist(flags); + } + if (outCodePoint) { + *outCodePointCount = ShortcutListReadingUtils::readShortcutTarget( + buffer, maxCodePointCount, outCodePoint, pos); + } + if (usesAdditionalBuffer) { + *pos += mBufSize; + } + } + + void skipAllShortcuts(int *const pos) const { + if (*pos >= mBufSize) { + *pos -= mBufSize; + const int shortcutListSize = ShortcutListReadingUtils + ::getShortcutListSizeAndForwardPointer(mAdditionalBuffer->getBuffer(), pos); + *pos += mBufSize + shortcutListSize; + } else { + const int shortcutListSize = ShortcutListReadingUtils + ::getShortcutListSizeAndForwardPointer(mShortcutsBuf, pos); + *pos += shortcutListSize; + } + } + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicShortcutListPolicy); + + const uint8_t *const mShortcutsBuf; + const int mBufSize; + const ExtendableBuffer *const mAdditionalBuffer; +}; +} // namespace latinime +#endif // LATINIME_DYNAMIC_SHORTCUT_LIST_POLICY_H diff --git a/native/jni/src/suggest/policyimpl/dictionary/shortcut/shortcut_list_reading_utils.h b/native/jni/src/suggest/policyimpl/dictionary/shortcut/shortcut_list_reading_utils.h index b5bb964d5..5f4f240f5 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/shortcut/shortcut_list_reading_utils.h +++ b/native/jni/src/suggest/policyimpl/dictionary/shortcut/shortcut_list_reading_utils.h @@ -50,6 +50,10 @@ class ShortcutListReadingUtils { - SHORTCUT_LIST_SIZE_FIELD_SIZE; } + static AK_FORCE_INLINE int getShortcutListSizeFieldSize() { + return SHORTCUT_LIST_SIZE_FIELD_SIZE; + } + static AK_FORCE_INLINE void skipShortcuts(const uint8_t *const dictRoot, int *const pos) { const int shortcutListSize = getShortcutListSizeAndForwardPointer(dictRoot, pos); *pos += shortcutListSize; diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/extendable_buffer.cpp b/native/jni/src/suggest/policyimpl/dictionary/utils/extendable_buffer.cpp new file mode 100644 index 000000000..e55cc2410 --- /dev/null +++ b/native/jni/src/suggest/policyimpl/dictionary/utils/extendable_buffer.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "suggest/policyimpl/dictionary/utils/extendable_buffer.h" + +namespace latinime { + +const size_t ExtendableBuffer::INITIAL_BUFFER_SIZE = 16 * 1024; +const size_t ExtendableBuffer::MAX_BUFFER_SIZE = 1024 * 1024; +const size_t ExtendableBuffer::EXTEND_BUFFER_SIZE_STEP = 16 * 1024; + +} diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/extendable_buffer.h b/native/jni/src/suggest/policyimpl/dictionary/utils/extendable_buffer.h new file mode 100644 index 000000000..5c75027d2 --- /dev/null +++ b/native/jni/src/suggest/policyimpl/dictionary/utils/extendable_buffer.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2013, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LATINIME_EXTENDABLE_BUFFER_H +#define LATINIME_EXTENDABLE_BUFFER_H + +#include <cstddef> +#include <stdint.h> +#include <vector> + +#include "defines.h" + +namespace latinime { + +// This is used as a buffer that can be extended for updatable dictionaries. +class ExtendableBuffer { + public: + ExtendableBuffer() : mBuffer(INITIAL_BUFFER_SIZE), mUsedSize(0) {} + + AK_FORCE_INLINE const uint8_t *getBuffer() const { + return &mBuffer[0]; + } + + // Return if the buffer is successfully extended or not. + AK_FORCE_INLINE bool extendBuffer() { + if (mBuffer.size() + EXTEND_BUFFER_SIZE_STEP > MAX_BUFFER_SIZE) { + return false; + } + mBuffer.resize(mBuffer.size() + EXTEND_BUFFER_SIZE_STEP); + return true; + } + + AK_FORCE_INLINE int getAllocatedSize() const { + return mBuffer.size(); + } + + AK_FORCE_INLINE int getUsedSize() const { + return mUsedSize; + } + + AK_FORCE_INLINE void clear() { + mUsedSize = 0; + mBuffer.clear(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ExtendableBuffer); + + static const size_t INITIAL_BUFFER_SIZE; + static const size_t MAX_BUFFER_SIZE; + static const size_t EXTEND_BUFFER_SIZE_STEP; + + std::vector<uint8_t> mBuffer; + int mUsedSize; +}; +} +#endif /* LATINIME_MMAPED_BUFFER_H */ diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/mmaped_buffer.h b/native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.h index 08add03c6..6febd7832 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/utils/mmaped_buffer.h +++ b/native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LATINIME_MMAPED_BUFFER_H -#define LATINIME_MMAPED_BUFFER_H +#ifndef LATINIME_MMAPPED_BUFFER_H +#define LATINIME_MMAPPED_BUFFER_H #include <cerrno> #include <fcntl.h> @@ -27,39 +27,40 @@ namespace latinime { -class MmapedBuffer { +class MmappedBuffer { public: - static MmapedBuffer* openBuffer(const char *const path, const int pathLength, - const int bufOffset, const int size, const bool isUpdatable) { + static MmappedBuffer* openBuffer(const char *const path, const int pathLength, + const int bufferOffset, const int bufferSize, const bool isUpdatable) { const int openMode = isUpdatable ? O_RDWR : O_RDONLY; - const int fd = open(path, openMode); - if (fd < 0) { + const int mmapFd = open(path, openMode); + if (mmapFd < 0) { AKLOGE("DICT: Can't open the source. path=%s errno=%d", path, errno); return 0; } const int pagesize = getpagesize(); - const int offset = bufOffset % pagesize; - int adjOffset = bufOffset - offset; - int adjSize = size + offset; + const int offset = bufferOffset % pagesize; + int alignedOffset = bufferOffset - offset; + int alignedSize = bufferSize + offset; const int protMode = isUpdatable ? PROT_READ | PROT_WRITE : PROT_READ; - void *const mmapedBuffer = mmap(0, adjSize, protMode, MAP_PRIVATE, fd, adjOffset); - if (mmapedBuffer == MAP_FAILED) { + void *const mmappedBuffer = mmap(0, alignedSize, protMode, MAP_PRIVATE, mmapFd, + alignedOffset); + if (mmappedBuffer == MAP_FAILED) { AKLOGE("DICT: Can't mmap dictionary. errno=%d", errno); - close(fd); + close(mmapFd); return 0; } - uint8_t *const buffer = static_cast<uint8_t *>(mmapedBuffer) + offset; + uint8_t *const buffer = static_cast<uint8_t *>(mmappedBuffer) + offset; if (!buffer) { AKLOGE("DICT: buffer is null"); - close(fd); + close(mmapFd); return 0; } - return new MmapedBuffer(buffer, adjSize, fd, offset, isUpdatable); + return new MmappedBuffer(buffer, bufferSize, mmappedBuffer, alignedSize, mmapFd, + isUpdatable); } - ~MmapedBuffer() { - int ret = munmap(static_cast<void *>(mBuffer - mBufferOffset), - mBufferSize + mBufferOffset); + ~MmappedBuffer() { + int ret = munmap(mMmappedBuffer, mAlignedSize); if (ret != 0) { AKLOGE("DICT: Failure in munmap. ret=%d errno=%d", ret, errno); } @@ -82,18 +83,20 @@ class MmapedBuffer { } private: - AK_FORCE_INLINE MmapedBuffer(uint8_t *const buffer, const int bufferSize, const int mmapFd, - const int bufferOffset, const bool isUpdatable) - : mBuffer(buffer), mBufferSize(bufferSize), mMmapFd(mmapFd), - mBufferOffset(bufferOffset), mIsUpdatable(isUpdatable) {} + AK_FORCE_INLINE MmappedBuffer(uint8_t *const buffer, const int bufferSize, + void *const mmappedBuffer, const int alignedSize, const int mmapFd, + const bool isUpdatable) + : mBuffer(buffer), mBufferSize(bufferSize), mMmappedBuffer(mmappedBuffer), + mAlignedSize(alignedSize), mMmapFd(mmapFd), mIsUpdatable(isUpdatable) {} - DISALLOW_IMPLICIT_CONSTRUCTORS(MmapedBuffer); + DISALLOW_IMPLICIT_CONSTRUCTORS(MmappedBuffer); uint8_t *const mBuffer; const int mBufferSize; + void *const mMmappedBuffer; + const int mAlignedSize; const int mMmapFd; - const int mBufferOffset; const bool mIsUpdatable; }; } -#endif /* LATINIME_MMAPED_BUFFER_H */ +#endif /* LATINIME_MMAPPED_BUFFER_H */ diff --git a/native/jni/src/utils/autocorrection_threshold_utils.cpp b/native/jni/src/utils/autocorrection_threshold_utils.cpp index 3406e0f8e..1f8ee0814 100644 --- a/native/jni/src/utils/autocorrection_threshold_utils.cpp +++ b/native/jni/src/utils/autocorrection_threshold_utils.cpp @@ -83,9 +83,12 @@ const int AutocorrectionThresholdUtils::FULL_WORD_MULTIPLIER = 2; return 0.0f; } + if (score <= 0 || distance >= afterLength) { + // normalizedScore must be 0.0f (the minimum value) if the score is less than or equal to 0, + // or if the edit distance is larger than or equal to afterLength. + return 0.0f; + } // add a weight based on edit distance. - // distance <= max(afterLength, beforeLength) == afterLength, - // so, 0 <= distance / afterLength <= 1 const float weight = 1.0f - static_cast<float>(distance) / static_cast<float>(afterLength); // TODO: Revise the following logic thoroughly by referring to... diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java index 9ad81c01d..be1ecf787 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java @@ -30,9 +30,9 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); // Press "?123" key and hold, enter into choring symbols state. - pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + pressKey(CODE_SYMBOL, SYMBOLS); // Press/release symbol letter key. - chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + chordingPressAndReleaseKey('1', SYMBOLS, SYMBOLS); // Release "ABC" key, switch back to alphabet. releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); } @@ -50,9 +50,9 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); // Press "?123" key and hold, enter into choring symbols state. - pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + pressKey(CODE_SYMBOL, SYMBOLS); // Press/release symbol letter key. - chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + chordingPressAndReleaseKey('1', SYMBOLS, SYMBOLS); // Release "123?" key, switch back to alphabet unshifted. releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); } @@ -71,9 +71,9 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); // Press "?123" key and hold, enter into choring symbols state. - pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + pressKey(CODE_SYMBOL, SYMBOLS); // Press/release symbol letter key. - chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + chordingPressAndReleaseKey('1', SYMBOLS, SYMBOLS); // Release "123?" key, switch back to alphabet shift locked. releaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); } @@ -81,21 +81,14 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Chording input in symbols. public void testChordingSymbols() { // Press/release "?123" key, enter symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - - // Press "=\<" key and hold, enter into choring symbols shifted state. - pressKey(CODE_SHIFT, SYMBOLS_SHIFTED); - // Press/release symbol letter key. - chordingPressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Release "=\<" key, switch back to symbols. - releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press "ABC" key and hold, enter into choring alphabet state. pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); // Press/release letter key. chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Release "ABC" key, switch back to symbols. - releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + releaseKey(CODE_SYMBOL, SYMBOLS); // Alphabet shifted -> symbols -> "ABC" key + letter -> symbols // -> alphabet. @@ -104,13 +97,13 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Press/release shift key, enter alphabet shifted. pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press "ABC" key, enter into chording alphabet state. pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); // Enter/release letter key. chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Release "ABC" key, switch back to symbols. - releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + releaseKey(CODE_SYMBOL, SYMBOLS); // Press/release "ABC" key, switch to alphabet (not alphabet shifted). pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); @@ -122,112 +115,13 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press "ABC" key, enter into chording alphabet shift locked. pressKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); // Enter/release letter key. chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); // Release "ABC" key, switch back to symbols. - releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols -> "=\<" key + letter -> symbols -> - // alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press "=\<" key, enter into symbols shifted chording state. - pressKey(CODE_SHIFT, SYMBOLS_SHIFTED); - // Enter/release symbols shift letter key. - chordingPressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Release "=\<" key, switch back to symbols. - releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - } - - // Chording input in symbol shifted. - public void testChordingSymbolsShifted() { - // Press/release "?123" key, enter symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - - // Press "?123" key and hold, enter into chording symbols state. - pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); - // Press/release symbol letter key. - chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Release "=\<" key, switch back to symbols shifted state. - releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED); - - // Press "ABC" key and hold, enter into choring alphabet state. - pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); - // Press/release letter key. - chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Release "ABC" key, switch back to symbols. - releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); - - // Alphabet shifted -> symbols shifted -> "ABC" key + letter -> symbols shifted -> - // alphabet. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Press/release shift key, enter alphabet shifted. - pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press "ABC" key, enter into chording alphabet state. - pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); - // Enter/release letter key. - chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Release "ABC" key, switch back to symbols shifted. - releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet (not alphabet shifted). - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Alphabet shift locked -> symbols shifted -> "ABC" key + letter -> symbols shifted - // -> alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press "ABC" key, enter into chording alphabet shift locked. - pressKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); - // Enter/release letter key. - chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Release "ABC" key, switch back to symbols shifted. - releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols shifted -> "=\<" key + letter -> symbols shifted - // -> alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press "=\<" key, enter into symbols chording state. - pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); - // Enter/release symbols letter key. - chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Release "=\<" key, switch back to symbols shifted. - releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED); + releaseKey(CODE_SYMBOL, SYMBOLS); // Press/release "ABC" key, switch to alphabet shift locked. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); } @@ -249,9 +143,9 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Update shift state with auto caps enabled. pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); // Press "123?" key and hold, enter into chording symbols state. - pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + pressKey(CODE_SYMBOL, SYMBOLS); // Press/release symbol letter key. - chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + chordingPressAndReleaseKey('1', SYMBOLS, SYMBOLS); // Release "123?" key, switch back to alphabet. releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); } diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java index c7ac76d93..611482bcf 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java @@ -34,38 +34,14 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); } - // Shift key in symbols. - public void testShiftSymbols() { - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - - // Press/release "?123" key, back to symbols. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press/release symbol letter key, remain in symbols shifted. - pressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - } - // Switching between alphabet and symbols. public void testAlphabetAndSymbols() { // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press/release "ABC" key, back to alphabet. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, back to alphabet. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Press/release "?123" key, back to symbols (not symbols shifted). - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); } // Switching between alphabet shifted and symbols. @@ -74,16 +50,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "ABC" key, back to alphabet (not alphabet shifted). - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Press/release shift key, enter into alphabet shifted. - pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\< key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press/release "ABC" key, back to alphabet (not alphabet shifted). pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); } @@ -95,39 +62,21 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press/release "ABC" key, back to alphabet shift locked. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, back to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, back to symbols (not symbols shifted). - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); } // Automatic switch back to alphabet by space key. public void testSwitchBackBySpace() { // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter symbol letter. - pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter space, switch back to alphabet. - pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter symbol shift letter. - pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + pressAndReleaseKey('1', SYMBOLS, SYMBOLS); // Enter space, switch back to alphabet. - pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_UNSHIFTED); - // Press/release "?123" key, enter into symbols (not symbols shifted). - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SPACE, SYMBOLS, ALPHABET_UNSHIFTED); } // Automatic switch back to alphabet shift locked test by space key. @@ -137,20 +86,11 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter symbol letter. - pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey('1', SYMBOLS, SYMBOLS); // Enter space, switch back to alphabet shift locked. - pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED); - - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter symbol shift letter. - pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter space, switch back to alphabet shift locked. - pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED); + pressAndReleaseKey(CODE_SPACE, SYMBOLS, ALPHABET_SHIFT_LOCKED); } // Automatic upper case test @@ -173,20 +113,11 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press/release symbol letter key, remain in symbols. - pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release space, switch back to automatic shifted. - pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); - - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press/release symbol shift letter key, remain in symbols shifted. - pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + pressAndReleaseKey('1', SYMBOLS, SYMBOLS); // Press/release space, switch back to automatic shifted. - pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + pressAndReleaseKey(CODE_SPACE, SYMBOLS, ALPHABET_AUTOMATIC_SHIFTED); } // Long press shift key. @@ -302,14 +233,9 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { ALPHABET_UNSHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Update shift state, remained in symbols. - updateShiftState(SYMBOLS_UNSHIFTED); - - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Update shift state, remained in symbols shifted. - updateShiftState(SYMBOLS_SHIFTED); + updateShiftState(SYMBOLS); // Set capitalize the first character of all words mode. setAutoCapsMode(CAP_MODE_WORDS); @@ -337,14 +263,9 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Load keyboard, should be in automatic shifted. loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Update shift state, remained in symbols. - updateShiftState(SYMBOLS_UNSHIFTED); - - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Update shift state, remained in symbols shifted. - updateShiftState(SYMBOLS_SHIFTED); + updateShiftState(SYMBOLS); } // Sliding input in alphabet. @@ -358,10 +279,10 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Alphabet -> "?123" key + letter -> alphabet. // Press and slide from "123?" key, enter symbols. - pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter/release into symbol letter keys, switch back to alphabet. - pressAndSlideFromKey('@', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - stopSlidingOnKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); + pressAndSlideFromKey('@', SYMBOLS, SYMBOLS); + stopSlidingOnKey('!', SYMBOLS, ALPHABET_UNSHIFTED); // Alphabet shifted -> shift key + letter -> alphabet. // Press/release shift key, enter alphabet shifted. @@ -376,20 +297,20 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Press/release shift key, enter alphabet shifted. pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); // Press and slide from "123?" key, enter symbols. - pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter/release into symbol letter keys, switch back to alphabet (not alphabet shifted). - pressAndSlideFromKey('@', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - stopSlidingOnKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); + pressAndSlideFromKey('@', SYMBOLS, SYMBOLS); + stopSlidingOnKey('!', SYMBOLS, ALPHABET_UNSHIFTED); // Alphabet shift locked -> shift key + letter -> alphabet shift locked. // Long press shift key, enter alphabet shift locked. longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press and slide from "123?" key, enter symbols. - pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter/release into symbol letter keys, switch back to alphabet shift locked. - pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - stopSlidingOnKey('!', SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED); + pressAndSlideFromKey('!', SYMBOLS, SYMBOLS); + stopSlidingOnKey('!', SYMBOLS, ALPHABET_SHIFT_LOCKED); // Alphabet shift locked -> "?123" key + letter -> alphabet shift locked. // Press and slide from shift key, enter alphabet shifted. @@ -413,9 +334,9 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Alphabet -> "?123" key + letter -> cancel -> alphabet. // Press and slide from "123?" key, enter symbols. - pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter/release into symbol letter key, remains in symbols. - pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey('!', SYMBOLS, SYMBOLS); // Cancel sliding, switch back to alphabet. stopSlidingAndCancel(ALPHABET_UNSHIFTED); @@ -433,9 +354,9 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Press/release shift key, enter alphabet shifted. pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); // Press and slide from "123?" key, enter symbols. - pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter/release into symbol letter key, remains in symbols. - pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey('!', SYMBOLS, SYMBOLS); // Cancel sliding, switch back to alphabet (not alphabet shifted). stopSlidingAndCancel(ALPHABET_UNSHIFTED); @@ -444,9 +365,9 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press and slide from "123?" key, enter symbols. - pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Enter/release into symbol letter key, remains in symbols. - pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndSlideFromKey('!', SYMBOLS, SYMBOLS); // Cancel sliding, switch back to alphabet shift locked. stopSlidingAndCancel( ALPHABET_SHIFT_LOCKED); @@ -461,21 +382,14 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Sliding input in symbols. public void testSlidingSymbols() { - // Symbols -> "=\<" key + letter -> symbols. // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press and slide from shift key, enter symbols shifted. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter/release symbol shifted letter keys, switch back to symbols. - pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - stopSlidingOnKey('~', SYMBOLS_SHIFTED, SYMBOLS_UNSHIFTED); - + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Symbols -> "ABC" key + letter -> Symbols. // Press and slide from "ABC" key, enter alphabet. pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Enter/release letter keys, switch back to symbols. pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS); // Press/release "ABC" key, switch to alphabet. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); @@ -486,12 +400,12 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Press/release shift key, enter alphabet shifted. pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press and slide from "ABC" key. pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Enter/release letter keys, switch back to symbols. pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS); // Press/release "ABC" key, switch to alphabet (not alphabet shifted). pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); @@ -503,52 +417,27 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press and slide from "ABC" key, enter alphabet shift locked. pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); // Enter/release letter keys, switch back to symbols. pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - stopSlidingOnKey('A', ALPHABET_SHIFT_LOCKED, SYMBOLS_UNSHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols -> "=\<" key + letter -> symbols -> - // alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press and slide from "=\<" key, enter symbols shifted. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter/release symbols shift letter keys, switch back to symbols. - pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - stopSlidingOnKey('~', SYMBOLS_SHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('A', ALPHABET_SHIFT_LOCKED, SYMBOLS); // Press/release "ABC" key, switch to alphabet shift locked. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); } // Cancel sliding input in symbols. public void testSlidingSymbolsCancel() { - // Symbols -> "=\<" key + letter -> cancel -> symbols. // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press and slide from shift key, enter symbols shifted. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter/release symbol shifted letter key, remains in symbols shifted. - pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Cancel sliding, switch back to symbols. - stopSlidingAndCancel(SYMBOLS_UNSHIFTED); - + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Symbols -> "ABC" key + letter -> Symbols. // Press and slide from "ABC" key, enter alphabet. pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Enter/release letter keys, remains in alphabet. pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Cancel sliding, switch back to symbols. - stopSlidingAndCancel(SYMBOLS_UNSHIFTED); + stopSlidingAndCancel(SYMBOLS); // Press/release "ABC" key, switch to alphabet. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); @@ -559,13 +448,13 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Press/release shift key, enter alphabet shifted. pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press and slide from "ABC" key. pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Enter/release letter key, remains in alphabet. pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); // Cancel sliding, switch back to symbols. - stopSlidingAndCancel(SYMBOLS_UNSHIFTED); + stopSlidingAndCancel(SYMBOLS); // Press/release "ABC" key, switch to alphabet (not alphabet shifted). pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); @@ -577,194 +466,13 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Press and slide from "ABC" key, enter alphabet shift locked. pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); // Enter/release letter key, remains in alphabet shifted. pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); // Cancel sliding, switch back to symbols. - stopSlidingAndCancel(SYMBOLS_UNSHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols -> "=\<" key + letter -> symbols -> - // alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press and slide from "=\<" key, enter symbols shifted. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter/release symbols shift letter key, remains in symbols shifted. - pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Cancel sliding, switch back to symbols. - stopSlidingAndCancel(SYMBOLS_UNSHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - } - - // Sliding input in symbols shifted. - public void testSlidingSymbolsShifted() { - // Symbols shifted -> "?123" + letter -> symbols shifted. - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from shift key, enter symbols. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter/release symbol letter keys, switch back to symbols shifted. - pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - stopSlidingOnKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_SHIFTED); - - // Symbols shifted -> "ABC" key + letter -> symbols shifted. - // Press and slide from "ABC" key, enter alphabet. - pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Enter/release letter keys, switch back to symbols shifted. - pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Alphabet shifted -> symbols shifted -> "ABC" + letter -> symbols shifted -> - // alphabet. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Press/release shift key, enter alphabet shifted. - pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from "ABC" key. - pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Enter/release letter keys, switch back to symbols shifted. - pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet (not alphabet shifted). - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Alphabet shift locked -> symbols shifted -> "ABC" + letter -> symbols shifted -> - // alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from "ABC" key. - pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Enter/release letter keys, switch back to symbols shifted. - pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - stopSlidingOnKey('A', ALPHABET_SHIFT_LOCKED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols shifted -> "?123" + letter -> symbols shifted -> - // alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from "?123" key. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter/release symbol letter keys, switch back to symbols shifted. - pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - stopSlidingOnKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - } - - // Cancel sliding input in symbols shifted. - public void testSlidingSymbolsShiftedCancel() { - // Symbols shifted -> "?123" + letter -> symbols shifted. - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from shift key, enter symbols. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter/release symbol letter key, remains in symbols. - pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Cancel sliding, switch back to symbols shifted. - stopSlidingAndCancel(SYMBOLS_SHIFTED); - - // Symbols shifted -> "ABC" key + letter -> symbols shifted. - // Press and slide from "ABC" key, enter alphabet. - pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Enter/release letter key, remains in alphabet. - pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Cancel sliding, switch back to symbols shifted. - stopSlidingAndCancel(SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Alphabet shifted -> symbols shifted -> "ABC" + letter -> symbols shifted -> - // alphabet. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Press/release shift key, enter alphabet shifted. - pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from "ABC" key. - pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Enter/release letter key, remains in alphabet. - pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Cancel sliding, switch back to symbols shifted. - stopSlidingAndCancel(SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet (not alphabet shifted). - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Alphabet shift locked -> symbols shifted -> "ABC" + letter -> symbols shifted -> - // alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from "ABC" key. - pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Enter/release letter key, remains in alphabet shift locked. - pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Cancel sliding, switch back to symbols shifted. - stopSlidingAndCancel(SYMBOLS_SHIFTED); - // Press/release "ABC" key, switch to alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols shifted -> "?123" + letter -> symbols shifted -> - // alphabet shift locked. - // Load keyboard - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press and slide from "?123" key. - pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter/release symbol letter key, remains in symbols. - pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Cancel sliding, switch back to symbols shifted. - stopSlidingAndCancel(SYMBOLS_SHIFTED); + stopSlidingAndCancel(SYMBOLS); // Press/release "ABC" key, switch to alphabet shift locked. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); } @@ -783,14 +491,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { loadKeyboard(ALPHABET_UNSHIFTED); // Press/release "?123" key. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Change focus to new text field. - loadKeyboard(ALPHABET_UNSHIFTED); - - // Press/release "?123" key. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Change focus to new text field. loadKeyboard(ALPHABET_UNSHIFTED); } @@ -814,14 +515,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); // Press/release "?123" key. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Change focus to new text field. - loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); - - // Press/release "?123" key. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Change focus to new text field. loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); } @@ -860,49 +554,11 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Alphabet shift locked -> symbols -> rotate -> symbols -> // Alphabet shift locked. // Press/release "?123" key, enter symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS, SYMBOLS); // Rotate device, remain in symbols, - rotateDevice(SYMBOLS_UNSHIFTED); - // Press/release "ABC" key, alphabet shift locked state should be maintained. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols shifted -> rotate -> symbols shifted -> - // Alphabet shift locked. - // Press/release "?123" key, enter symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Rotate device, remain in symbols shifted. - rotateDevice(SYMBOLS_SHIFTED); + rotateDevice(SYMBOLS); // Press/release "ABC" key, alphabet shift locked state should be maintained. pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - - // Alphabet shift locked -> symbols shifted -> alphabet shift locked -> rotate -> - // Alphabet shift locked -> symbols. - // Press/release "?123" key, enter symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, enter alphabet shift locked. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Rotate device, remain in alphabet shift locked. - rotateDevice(ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key, enter symbols (not symbols shifted). - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - - // Alphabet -> symbols shifted -> alphabet -> rotate -> - // Alphabet -> symbols. - loadKeyboard(ALPHABET_UNSHIFTED); - // Press/release "?123" key, enter symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Press/release "ABC" key, enter alphabet. - pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); - // Rotate device, remain in alphabet shift locked. - rotateDevice(ALPHABET_UNSHIFTED); - // Press/release "?123" key, enter symbols (not symbols shifted). - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); } // Rapidly type shift key. diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java index db3997651..682d8fc63 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java @@ -43,8 +43,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { public static final int ALPHABET_AUTOMATIC_SHIFTED = 2; public static final int ALPHABET_SHIFT_LOCKED = 3; public static final int ALPHABET_SHIFT_LOCK_SHIFTED = 4; - public static final int SYMBOLS_UNSHIFTED = 5; - public static final int SYMBOLS_SHIFTED = 6; + public static final int SYMBOLS = 5; } private int mLayout = MockConstants.ALPHABET_UNSHIFTED; @@ -69,8 +68,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { case MockConstants.ALPHABET_AUTOMATIC_SHIFTED: return "ALPHABET_AUTOMATIC_SHIFTED"; case MockConstants.ALPHABET_SHIFT_LOCKED: return "ALPHABET_SHIFT_LOCKED"; case MockConstants.ALPHABET_SHIFT_LOCK_SHIFTED: return "ALPHABET_SHIFT_LOCK_SHIFTED"; - case MockConstants.SYMBOLS_UNSHIFTED: return "SYMBOLS_UNSHIFTED"; - case MockConstants.SYMBOLS_SHIFTED: return "SYMBOLS_SHIFTED"; + case MockConstants.SYMBOLS: return "SYMBOLS"; default: return "UNKNOWN<" + layoutId + ">"; } } @@ -111,12 +109,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { @Override public void setSymbolsKeyboard() { - mLayout = MockConstants.SYMBOLS_UNSHIFTED; - } - - @Override - public void setSymbolsShiftedKeyboard() { - mLayout = MockConstants.SYMBOLS_SHIFTED; + mLayout = MockConstants.SYMBOLS; } @Override diff --git a/tests/src/com/android/inputmethod/latin/ExpandableDictionaryTests.java b/tests/src/com/android/inputmethod/latin/ExpandableDictionaryTests.java new file mode 100644 index 000000000..ecf3af736 --- /dev/null +++ b/tests/src/com/android/inputmethod/latin/ExpandableDictionaryTests.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +/** + * Unit test for ExpandableDictionary + */ +@SmallTest +public class ExpandableDictionaryTests extends AndroidTestCase { + + private final static int UNIGRAM_FREQ = 50; + + public void testAddWordAndGetWordFrequency() { + final ExpandableDictionary dict = new ExpandableDictionary(Dictionary.TYPE_USER); + + // Add words + dict.addWord("abcde", "abcde", UNIGRAM_FREQ); + dict.addWord("abcef", null, UNIGRAM_FREQ + 1); + + // Check words + assertFalse(dict.isValidWord("abcde")); + assertEquals(UNIGRAM_FREQ, dict.getWordFrequency("abcde")); + assertTrue(dict.isValidWord("abcef")); + assertEquals(UNIGRAM_FREQ+1, dict.getWordFrequency("abcef")); + + dict.addWord("abc", null, UNIGRAM_FREQ + 2); + assertTrue(dict.isValidWord("abc")); + assertEquals(UNIGRAM_FREQ + 2, dict.getWordFrequency("abc")); + + // Add existing word with lower frequency + dict.addWord("abc", null, UNIGRAM_FREQ); + assertEquals(UNIGRAM_FREQ + 2, dict.getWordFrequency("abc")); + + // Add existing word with higher frequency + dict.addWord("abc", null, UNIGRAM_FREQ + 3); + assertEquals(UNIGRAM_FREQ + 3, dict.getWordFrequency("abc")); + } +} diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index 6cc4befae..fe92be618 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -305,5 +305,33 @@ public class InputLogicTests extends InputTestsBase { assertEquals("resume suggestion on backspace", 8, BaseInputConnection.getComposingSpanEnd(mEditText.getText())); } + + private void helperTestComposing(final String wordToType, final boolean shouldBeComposing) { + mEditText.setText(""); + type(wordToType); + assertEquals("start composing inside text", shouldBeComposing ? 0 : -1, + BaseInputConnection.getComposingSpanStart(mEditText.getText())); + assertEquals("start composing inside text", shouldBeComposing ? wordToType.length() : -1, + BaseInputConnection.getComposingSpanEnd(mEditText.getText())); + } + + public void testStartComposing() { + // Should start composing on a letter + helperTestComposing("a", true); + type(" "); // To reset the composing state + // Should not start composing on quote + helperTestComposing("'", false); + type(" "); + helperTestComposing("'-", false); + type(" "); + // Should not start composing on dash + helperTestComposing("-", false); + type(" "); + helperTestComposing("-'", false); + type(" "); + helperTestComposing("a-", true); + type(" "); + helperTestComposing("a'", true); + } // TODO: Add some tests for non-BMP characters } diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java index f3ca2b147..72ec5a302 100644 --- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java @@ -22,29 +22,30 @@ import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; import android.util.SparseArray; +import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.CharEncoding; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; +import com.android.inputmethod.latin.utils.ByteArrayDictBuffer; import com.android.inputmethod.latin.utils.CollectionUtils; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Map.Entry; import java.util.Random; import java.util.Set; +import java.util.TreeMap; /** - * Unit tests for BinaryDictDecoderUtils and BinaryDictEncoder. + * Unit tests for BinaryDictDecoderUtils and BinaryDictEncoderUtils. */ @LargeTest public class BinaryDictDecoderEncoderTests extends AndroidTestCase { @@ -54,16 +55,19 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { private static final int UNIGRAM_FREQ = 10; private static final int BIGRAM_FREQ = 50; private static final int TOLERANCE_OF_BIGRAM_FREQ = 5; + private static final int NUM_OF_NODES_HAVING_SHORTCUTS = 50; + private static final int NUM_OF_SHORTCUTS = 5; private static final int USE_BYTE_ARRAY = 1; private static final int USE_BYTE_BUFFER = 2; - private static final List<String> sWords = CollectionUtils.newArrayList(); + private static final ArrayList<String> sWords = CollectionUtils.newArrayList(); private static final SparseArray<List<Integer>> sEmptyBigrams = CollectionUtils.newSparseArray(); private static final SparseArray<List<Integer>> sStarBigrams = CollectionUtils.newSparseArray(); private static final SparseArray<List<Integer>> sChainBigrams = CollectionUtils.newSparseArray(); + private static final HashMap<String, List<String>> sShortcuts = CollectionUtils.newHashMap(); private static final FormatSpec.FormatOptions VERSION2 = new FormatSpec.FormatOptions(2); private static final FormatSpec.FormatOptions VERSION3_WITHOUT_DYNAMIC_UPDATE = @@ -96,6 +100,16 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { for (int i = 1; i < sWords.size(); ++i) { sStarBigrams.get(0).add(i); } + + sShortcuts.clear(); + for (int i = 0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) { + final int from = Math.abs(random.nextInt()) % sWords.size(); + sShortcuts.put(sWords.get(from), new ArrayList<String>()); + for (int j = 0; j < NUM_OF_SHORTCUTS; ++j) { + final int to = Math.abs(random.nextInt()) % sWords.size(); + sShortcuts.get(sWords.get(from)).add(sWords.get(to)); + } + } } private int[] generateCodePointSet(final int codePointSetSize, final Random random) { @@ -105,7 +119,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { if (r < 0) continue; // Don't insert 0~0x20, but insert any other code point. // Code points are in the range 0~0x10FFFF. - final int candidateCodePoint = (int)(0x20 + r % (Character.MAX_CODE_POINT - 0x20)); + final int candidateCodePoint = 0x20 + r % (Character.MAX_CODE_POINT - 0x20); // Code points between MIN_ and MAX_SURROGATE are not valid on their own. if (candidateCodePoint >= Character.MIN_SURROGATE && candidateCodePoint <= Character.MAX_SURROGATE) continue; @@ -118,17 +132,15 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { // Utilities for test /** - * Makes new DictBuffer according to BUFFER_TYPE. + * Makes new DictDecoder according to BUFFER_TYPE. */ - private void getDictBuffer(final Ver3DictDecoder dictDecoder, final int bufferType) - throws FileNotFoundException, IOException { + private Ver3DictDecoder getDictDecoder(final File file, final int bufferType) { if (bufferType == USE_BYTE_BUFFER) { - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); - } else if (bufferType == USE_BYTE_ARRAY) { - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory()); + return new Ver3DictDecoder(file, DictDecoder.USE_READONLY_BYTEBUFFER); + } else if (bufferType == USE_BYTE_ARRAY) { + return new Ver3DictDecoder(file, DictDecoder.USE_BYTEARRAY); } + return null; } /** @@ -165,7 +177,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { * Adds unigrams to the dictionary. */ private void addUnigrams(final int number, final FusionDictionary dict, - final List<String> words, final Map<String, List<String>> shortcutMap) { + final List<String> words, final HashMap<String, List<String>> shortcutMap) { for (int i = 0; i < number; ++i) { final String word = words.get(i); final ArrayList<WeightedString> shortcuts = CollectionUtils.newArrayList(); @@ -204,17 +216,14 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { long now = -1, diff = -1; try { - final FileOutputStream out = new FileOutputStream(file); + final DictEncoder dictEncoder = new Ver3DictEncoder(file); now = System.currentTimeMillis(); // If you need to dump the dict to a textual file, uncomment the line below and the // function above // dumpToCombinedFileForDebug(file, "/tmp/foo"); - BinaryDictEncoder.writeDictionaryBinary(out, dict, formatOptions); + dictEncoder.writeDictionary(dict, formatOptions); diff = System.currentTimeMillis() - now; - - out.flush(); - out.close(); } catch (IOException e) { Log.e(TAG, "IO exception while writing file", e); } catch (UnsupportedFormatException e) { @@ -225,33 +234,35 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { } private void checkDictionary(final FusionDictionary dict, final List<String> words, - final SparseArray<List<Integer>> bigrams, final Map<String, List<String>> shortcutMap) { + final SparseArray<List<Integer>> bigrams, + final HashMap<String, List<String>> shortcutMap) { assertNotNull(dict); // check unigram for (final String word : words) { - final CharGroup cg = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); - assertNotNull(cg); + final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); + assertNotNull(ptNode); } // check bigram for (int i = 0; i < bigrams.size(); ++i) { final int w1 = bigrams.keyAt(i); for (final int w2 : bigrams.valueAt(i)) { - final CharGroup cg = FusionDictionary.findWordInTree(dict.mRootNodeArray, + final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, words.get(w1)); - assertNotNull(words.get(w1) + "," + words.get(w2), cg.getBigram(words.get(w2))); + assertNotNull(words.get(w1) + "," + words.get(w2), ptNode.getBigram(words.get(w2))); } } // check shortcut if (shortcutMap != null) { - for (final Map.Entry<String, List<String>> entry : shortcutMap.entrySet()) { - final CharGroup group = FusionDictionary.findWordInTree(dict.mRootNodeArray, + for (final Entry<String, List<String>> entry : shortcutMap.entrySet()) { + assertTrue(words.contains(entry.getKey())); + final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, entry.getKey()); for (final String word : entry.getValue()) { assertNotNull("shortcut not found: " + entry.getKey() + ", " + word, - group.getShortcut(word)); + ptNode.getShortcut(word)); } } } @@ -268,17 +279,17 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { // Tests for readDictionaryBinary and writeDictionaryBinary private long timeReadingAndCheckDict(final File file, final List<String> words, - final SparseArray<List<Integer>> bigrams, final Map<String, List<String>> shortcutMap, - final int bufferType) { + final SparseArray<List<Integer>> bigrams, + final HashMap<String, List<String>> shortcutMap, final int bufferType) { long now, diff = -1; - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); FusionDictionary dict = null; try { - getDictBuffer(dictDecoder, bufferType); + final Ver3DictDecoder dictDecoder = getDictDecoder(file, bufferType); + dictDecoder.openDictBuffer(); assertNotNull(dictDecoder.getDictBuffer()); now = System.currentTimeMillis(); - dict = BinaryDictDecoderUtils.readDictionaryBinary(dictDecoder, null); + dict = dictDecoder.readDictionaryBinary(null); diff = System.currentTimeMillis() - now; } catch (IOException e) { Log.e(TAG, "IOException while reading dictionary", e); @@ -292,7 +303,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { // Tests for readDictionaryBinary and writeDictionaryBinary private String runReadAndWrite(final List<String> words, - final SparseArray<List<Integer>> bigrams, final Map<String, List<String>> shortcuts, + final SparseArray<List<Integer>> bigrams, final HashMap<String, List<String>> shortcuts, final int bufferType, final FormatSpec.FormatOptions formatOptions, final String message) { File file = null; @@ -325,6 +336,28 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { formatOptions, "chain")); results.add(runReadAndWrite(sWords, sStarBigrams, null /* shortcuts */, bufferType, formatOptions, "star")); + results.add(runReadAndWrite(sWords, sEmptyBigrams, sShortcuts, bufferType, formatOptions, + "unigram with shortcuts")); + results.add(runReadAndWrite(sWords, sChainBigrams, sShortcuts, bufferType, formatOptions, + "chain with shortcuts")); + results.add(runReadAndWrite(sWords, sStarBigrams, sShortcuts, bufferType, formatOptions, + "star with shortcuts")); + } + + // Unit test for CharEncoding.readString and CharEncoding.writeString. + public void testCharEncoding() { + // the max length of a word in sWords is less than 50. + // See generateWords. + final byte[] buffer = new byte[50 * 3]; + final DictBuffer dictBuffer = new ByteArrayDictBuffer(buffer); + for (final String word : sWords) { + Log.d("testReadAndWriteString", "write : " + word); + Arrays.fill(buffer, (byte)0); + CharEncoding.writeString(buffer, 0, word); + dictBuffer.position(0); + final String str = CharEncoding.readString(dictBuffer); + assertEquals(word, str); + } } public void testReadAndWriteWithByteBuffer() { @@ -355,9 +388,9 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { private void checkWordMap(final List<String> expectedWords, final SparseArray<List<Integer>> expectedBigrams, - final Map<Integer, String> resultWords, - final Map<Integer, Integer> resultFrequencies, - final Map<Integer, ArrayList<PendingAttribute>> resultBigrams) { + final TreeMap<Integer, String> resultWords, + final TreeMap<Integer, Integer> resultFrequencies, + final TreeMap<Integer, ArrayList<PendingAttribute>> resultBigrams) { // check unigrams final Set<String> actualWordsSet = new HashSet<String>(resultWords.values()); final Set<String> expectedWordsSet = new HashSet<String>(expectedWords); @@ -368,7 +401,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { } // check bigrams - final Map<String, List<String>> expBigrams = new HashMap<String, List<String>>(); + final HashMap<String, List<String>> expBigrams = new HashMap<String, List<String>>(); for (int i = 0; i < expectedBigrams.size(); ++i) { final String word1 = expectedWords.get(expectedBigrams.keyAt(i)); for (int w2 : expectedBigrams.valueAt(i)) { @@ -379,7 +412,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { } } - final Map<String, List<String>> actBigrams = new HashMap<String, List<String>>(); + final HashMap<String, List<String>> actBigrams = new HashMap<String, List<String>>(); for (Entry<Integer, ArrayList<PendingAttribute>> entry : resultBigrams.entrySet()) { final String word1 = resultWords.get(entry.getKey()); final int unigramFreq = resultFrequencies.get(entry.getKey()); @@ -403,19 +436,18 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { final SparseArray<List<Integer>> bigrams, final int bufferType) { FileInputStream inStream = null; - final Map<Integer, String> resultWords = CollectionUtils.newTreeMap(); - final Map<Integer, ArrayList<PendingAttribute>> resultBigrams = + final TreeMap<Integer, String> resultWords = CollectionUtils.newTreeMap(); + final TreeMap<Integer, ArrayList<PendingAttribute>> resultBigrams = CollectionUtils.newTreeMap(); - final Map<Integer, Integer> resultFreqs = CollectionUtils.newTreeMap(); + final TreeMap<Integer, Integer> resultFreqs = CollectionUtils.newTreeMap(); long now = -1, diff = -1; - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); try { - getDictBuffer(dictDecoder, bufferType); + final Ver3DictDecoder dictDecoder = getDictDecoder(file, bufferType); + dictDecoder.openDictBuffer(); assertNotNull("Can't get buffer.", dictDecoder.getDictBuffer()); now = System.currentTimeMillis(); - BinaryDictIOUtils.readUnigramsAndBigramsBinary(dictDecoder, resultWords, resultFreqs, - resultBigrams); + dictDecoder.readUnigramsAndBigramsBinary(resultWords, resultFreqs, resultBigrams); diff = System.currentTimeMillis() - now; } catch (IOException e) { Log.e(TAG, "IOException", e); @@ -435,7 +467,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { return diff; } - private String runReadUnigramsAndBigramsBinary(final List<String> words, + private String runReadUnigramsAndBigramsBinary(final ArrayList<String> words, final SparseArray<List<Integer>> bigrams, final int bufferType, final FormatSpec.FormatOptions formatOptions, final String message) { File file = null; @@ -464,8 +496,8 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { + " : " + message + " : " + outputOptions(bufferType, formatOptions); } - private void runReadUnigramsAndBigramsTests(final List<String> results, final int bufferType, - final FormatSpec.FormatOptions formatOptions) { + private void runReadUnigramsAndBigramsTests(final ArrayList<String> results, + final int bufferType, final FormatSpec.FormatOptions formatOptions) { results.add(runReadUnigramsAndBigramsBinary(sWords, sEmptyBigrams, bufferType, formatOptions, "unigram")); results.add(runReadUnigramsAndBigramsBinary(sWords, sChainBigrams, bufferType, @@ -475,7 +507,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { } public void testReadUnigramsAndBigramsBinaryWithByteBuffer() { - final List<String> results = CollectionUtils.newArrayList(); + final ArrayList<String> results = CollectionUtils.newArrayList(); runReadUnigramsAndBigramsTests(results, USE_BYTE_BUFFER, VERSION2); runReadUnigramsAndBigramsTests(results, USE_BYTE_BUFFER, VERSION3_WITHOUT_DYNAMIC_UPDATE); @@ -487,7 +519,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { } public void testReadUnigramsAndBigramsBinaryWithByteArray() { - final List<String> results = CollectionUtils.newArrayList(); + final ArrayList<String> results = CollectionUtils.newArrayList(); runReadUnigramsAndBigramsTests(results, USE_BYTE_ARRAY, VERSION2); runReadUnigramsAndBigramsTests(results, USE_BYTE_ARRAY, VERSION3_WITHOUT_DYNAMIC_UPDATE); @@ -512,8 +544,8 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { return null; } if (fileHeader == null) return null; - return BinaryDictDecoderUtils.getWordAtAddress(dictBuffer, fileHeader.mHeaderSize, - address - fileHeader.mHeaderSize, fileHeader.mFormatOptions).mWord; + return BinaryDictDecoderUtils.getWordAtPosition(dictDecoder, fileHeader.mHeaderSize, + address, fileHeader.mFormatOptions).mWord; } private long runGetTerminalPosition(final Ver3DictDecoder dictDecoder, final String word, @@ -523,7 +555,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { int position = -1; try { final long now = System.nanoTime(); - position = BinaryDictIOUtils.getTerminalPosition(dictDecoder, word); + position = dictDecoder.getTerminalPosition(word); diff = System.nanoTime() - now; } catch (IOException e) { Log.e(TAG, "IOException while getTerminalPosition", e); @@ -552,10 +584,9 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { addUnigrams(sWords.size(), dict, sWords, null /* shortcutMap */); timeWritingDictToFile(file, dict, VERSION3_WITH_DYNAMIC_UPDATE); - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file, DictDecoder.USE_BYTEARRAY); try { - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory()); + dictDecoder.openDictBuffer(); } catch (IOException e) { // ignore Log.e(TAG, "IOException while opening the buffer", e); @@ -565,16 +596,13 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { try { // too long word final String longWord = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; - assertEquals(FormatSpec.NOT_VALID_WORD, - BinaryDictIOUtils.getTerminalPosition(dictDecoder, longWord)); + assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(longWord)); // null - assertEquals(FormatSpec.NOT_VALID_WORD, - BinaryDictIOUtils.getTerminalPosition(dictDecoder, null)); + assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(null)); // empty string - assertEquals(FormatSpec.NOT_VALID_WORD, - BinaryDictIOUtils.getTerminalPosition(dictDecoder, "")); + assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition("")); } catch (IOException e) { } catch (UnsupportedFormatException e) { } @@ -613,10 +641,9 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { addUnigrams(sWords.size(), dict, sWords, null /* shortcutMap */); timeWritingDictToFile(file, dict, VERSION3_WITH_DYNAMIC_UPDATE); - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file, DictDecoder.USE_BYTEARRAY); try { - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory()); + dictDecoder.openDictBuffer(); } catch (IOException e) { // ignore Log.e(TAG, "IOException while opening the buffer", e); @@ -625,16 +652,16 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { try { MoreAsserts.assertNotEqual(FormatSpec.NOT_VALID_WORD, - BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(0))); + dictDecoder.getTerminalPosition(sWords.get(0))); DynamicBinaryDictIOUtils.deleteWord(dictDecoder, sWords.get(0)); assertEquals(FormatSpec.NOT_VALID_WORD, - BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(0))); + dictDecoder.getTerminalPosition(sWords.get(0))); MoreAsserts.assertNotEqual(FormatSpec.NOT_VALID_WORD, - BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(5))); + dictDecoder.getTerminalPosition(sWords.get(5))); DynamicBinaryDictIOUtils.deleteWord(dictDecoder, sWords.get(5)); assertEquals(FormatSpec.NOT_VALID_WORD, - BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(5))); + dictDecoder.getTerminalPosition(sWords.get(5))); } catch (IOException e) { } catch (UnsupportedFormatException e) { } diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java index 74c20a38c..8e0c6dfe2 100644 --- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java @@ -22,8 +22,6 @@ import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer; -import com.android.inputmethod.latin.makedict.DictDecoder. - DictionaryBufferFromWritableByteBufferFactory; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; @@ -31,7 +29,6 @@ import com.android.inputmethod.latin.utils.CollectionUtils; import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -87,8 +84,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { return builder.toString(); } - private static void printCharGroup(final CharGroupInfo info) { - Log.d(TAG, " CharGroup at " + info.mOriginalAddress); + private static void printPtNode(final PtNodeInfo info) { + Log.d(TAG, " PtNode at " + info.mOriginalAddress); Log.d(TAG, " flags = " + info.mFlags); Log.d(TAG, " parentAddress = " + info.mParentAddress); Log.d(TAG, " characters = " + new String(info.mCharacters, 0, @@ -112,15 +109,16 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { Log.d(TAG, " end address = " + info.mEndAddress); } - private static void printNode(final DictBuffer dictBuffer, + private static void printNode(final Ver3DictDecoder dictDecoder, final FormatSpec.FormatOptions formatOptions) { + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); Log.d(TAG, "Node at " + dictBuffer.position()); - final int count = BinaryDictDecoderUtils.readCharGroupCount(dictBuffer); - Log.d(TAG, " charGroupCount = " + count); + final int count = BinaryDictDecoderUtils.readPtNodeCount(dictBuffer); + Log.d(TAG, " ptNodeCount = " + count); for (int i = 0; i < count; ++i) { - final CharGroupInfo currentInfo = BinaryDictDecoderUtils.readCharGroup(dictBuffer, - dictBuffer.position(), formatOptions); - printCharGroup(currentInfo); + final PtNodeInfo currentInfo = dictDecoder.readPtNode(dictBuffer.position(), + formatOptions); + printPtNode(currentInfo); } if (formatOptions.mSupportsDynamicUpdate) { final int forwardLinkAddress = dictBuffer.readUnsignedInt24(); @@ -128,45 +126,56 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { } } + @SuppressWarnings("unused") private static void printBinaryFile(final Ver3DictDecoder dictDecoder) throws IOException, UnsupportedFormatException { final FileHeader fileHeader = dictDecoder.readHeader(); - final DictBuffer buffer = dictDecoder.getDictBuffer(); - while (buffer.position() < buffer.limit()) { - printNode(buffer, fileHeader.mFormatOptions); + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); + while (dictBuffer.position() < dictBuffer.limit()) { + printNode(dictDecoder, fileHeader.mFormatOptions); } } private int getWordPosition(final File file, final String word) { int position = FormatSpec.NOT_VALID_WORD; - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); - FileInputStream inStream = null; + try { - inStream = new FileInputStream(file); - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); - position = BinaryDictIOUtils.getTerminalPosition(dictDecoder, word); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); + position = dictDecoder.getTerminalPosition(word); } catch (IOException e) { } catch (UnsupportedFormatException e) { - } finally { - if (inStream != null) { - try { - inStream.close(); - } catch (IOException e) { - // do nothing - } - } } return position; } - private CharGroupInfo findWordFromFile(final File file, final String word) { + /** + * Find a word using the Ver3DictDecoder. + * + * @param dictDecoder the dict decoder + * @param word the word searched + * @return the found ptNodeInfo + * @throws IOException + * @throws UnsupportedFormatException + */ + private static PtNodeInfo findWordByBinaryDictReader(final Ver3DictDecoder dictDecoder, + final String word) throws IOException, UnsupportedFormatException { + int position = dictDecoder.getTerminalPosition(word); + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); + if (position != FormatSpec.NOT_VALID_WORD) { + dictBuffer.position(0); + final FileHeader header = dictDecoder.readHeader(); + dictBuffer.position(position); + return dictDecoder.readPtNode(position, header.mFormatOptions); + } + return null; + } + + private PtNodeInfo findWordFromFile(final File file, final String word) { final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); - CharGroupInfo info = null; + PtNodeInfo info = null; try { - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); - info = BinaryDictIOUtils.findWordByBinaryDictReader(dictDecoder, word); + dictDecoder.openDictBuffer(); + info = findWordByBinaryDictReader(dictDecoder, word); } catch (IOException e) { } catch (UnsupportedFormatException e) { } @@ -177,11 +186,12 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { private long insertAndCheckWord(final File file, final String word, final int frequency, final boolean exist, final ArrayList<WeightedString> bigrams, final ArrayList<WeightedString> shortcuts) { - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); BufferedOutputStream outStream = null; long amountOfTime = -1; try { - dictDecoder.openDictBuffer(new DictionaryBufferFromWritableByteBufferFactory()); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file, + DictDecoder.USE_WRITABLE_BYTEBUFFER); + dictDecoder.openDictBuffer(); outStream = new BufferedOutputStream(new FileOutputStream(file, true)); if (!exist) { @@ -211,9 +221,10 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { } private void deleteWord(final File file, final String word) { - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); try { - dictDecoder.openDictBuffer(new DictionaryBufferFromWritableByteBufferFactory()); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file, + DictDecoder.USE_WRITABLE_BYTEBUFFER); + dictDecoder.openDictBuffer(); DynamicBinaryDictIOUtils.deleteWord(dictDecoder, word); } catch (IOException e) { } catch (UnsupportedFormatException e) { @@ -221,15 +232,13 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { } private void checkReverseLookup(final File file, final String word, final int position) { - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); + try { - final DictBuffer dictBuffer = dictDecoder.openAndGetDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); final FileHeader fileHeader = dictDecoder.readHeader(); assertEquals(word, - BinaryDictDecoderUtils.getWordAtAddress(dictDecoder.getDictBuffer(), - fileHeader.mHeaderSize, position - fileHeader.mHeaderSize, - fileHeader.mFormatOptions).mWord); + BinaryDictDecoderUtils.getWordAtPosition(dictDecoder, fileHeader.mHeaderSize, + position, fileHeader.mFormatOptions).mWord); } catch (IOException e) { Log.e(TAG, "Raised an IOException while looking up a word", e); } catch (UnsupportedFormatException e) { @@ -252,9 +261,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { dict.add("abcd", 10, null, false); try { - final FileOutputStream out = new FileOutputStream(file); - BinaryDictEncoder.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); - out.close(); + final DictEncoder dictEncoder = new Ver3DictEncoder(file); + dictEncoder.writeDictionary(dict, FORMAT_OPTIONS); } catch (IOException e) { fail("IOException while writing an initial dictionary : " + e); } catch (UnsupportedFormatException e) { @@ -304,9 +312,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { dict.add("efgh", 15, null, false); try { - final FileOutputStream out = new FileOutputStream(file); - BinaryDictEncoder.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); - out.close(); + final DictEncoder dictEncoder = new Ver3DictEncoder(file); + dictEncoder.writeDictionary(dict, FORMAT_OPTIONS); } catch (IOException e) { fail("IOException while writing an initial dictionary : " + e); } catch (UnsupportedFormatException e) { @@ -319,7 +326,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { insertAndCheckWord(file, "banana", 0, false, null, null); insertAndCheckWord(file, "recursive", 60, true, banana, null); - final CharGroupInfo info = findWordFromFile(file, "recursive"); + final PtNodeInfo info = findWordFromFile(file, "recursive"); int bananaPos = getWordPosition(file, "banana"); assertNotNull(info.mBigrams); assertEquals(info.mBigrams.size(), 1); @@ -342,9 +349,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { dict.add("initial", 10, null, false); try { - final FileOutputStream out = new FileOutputStream(file); - BinaryDictEncoder.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); - out.close(); + final DictEncoder dictEncoder = new Ver3DictEncoder(file); + dictEncoder.writeDictionary(dict, FORMAT_OPTIONS); } catch (IOException e) { assertTrue(false); } catch (UnsupportedFormatException e) { diff --git a/tests/src/com/android/inputmethod/latin/makedict/Ver3DictDecoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/Ver3DictDecoderTests.java index 20e8b4fda..9611599b9 100644 --- a/tests/src/com/android/inputmethod/latin/makedict/Ver3DictDecoderTests.java +++ b/tests/src/com/android/inputmethod/latin/makedict/Ver3DictDecoderTests.java @@ -68,9 +68,9 @@ public class Ver3DictDecoderTests extends AndroidTestCase { } assertNotNull(testFile); - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(testFile); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(testFile, factory); try { - dictDecoder.openDictBuffer(factory); + dictDecoder.openDictBuffer(); } catch (Exception e) { Log.e(TAG, "Failed to open the buffer", e); } @@ -78,7 +78,7 @@ public class Ver3DictDecoderTests extends AndroidTestCase { writeDataToFile(testFile); try { - dictDecoder.openDictBuffer(factory); + dictDecoder.openDictBuffer(); } catch (Exception e) { Log.e(TAG, "Raised the exception while opening buffer", e); } @@ -110,7 +110,7 @@ public class Ver3DictDecoderTests extends AndroidTestCase { Log.e(TAG, "IOException while the creating temporary file", e); } - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(testFile); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(testFile, factory); // the default return value of getBuffer() must be null. assertNull("the default return value of getBuffer() is not null", @@ -122,7 +122,7 @@ public class Ver3DictDecoderTests extends AndroidTestCase { DictBuffer dictBuffer = null; try { - dictBuffer = dictDecoder.openAndGetDictBuffer(factory); + dictBuffer = dictDecoder.openAndGetDictBuffer(); } catch (IOException e) { Log.e(TAG, "Failed to open and get the buffer", e); } diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java index 99ccb1a75..1fd1b8a81 100644 --- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java @@ -86,7 +86,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase { final Random random) { final List<String> words = generateWords(numberOfWords, random); final UserHistoryPredictionDictionary dict = - PersonalizationDictionaryHelper.getUserHistoryPredictionDictionary(getContext(), + PersonalizationHelper.getUserHistoryPredictionDictionary(getContext(), testFilenameSuffix /* locale */, mPrefs); // Add random words to the user history dictionary. addToDict(dict, words); diff --git a/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java index eca12c0d8..72b9478d4 100644 --- a/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java @@ -21,17 +21,19 @@ import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; +import com.android.inputmethod.latin.makedict.DictDecoder; +import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; import com.android.inputmethod.latin.makedict.Ver3DictDecoder; +import com.android.inputmethod.latin.makedict.Ver3DictEncoder; import com.android.inputmethod.latin.personalization.UserHistoryDictionaryBigramList; import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface; import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.OnAddWordListener; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -87,12 +89,12 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase private void checkWordInFusionDict(final FusionDictionary dict, final String word, final ArrayList<String> expectedBigrams) { - final CharGroup group = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); - assertNotNull(group); - assertTrue(group.isTerminal()); + final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); + assertNotNull(ptNode); + assertTrue(ptNode.isTerminal()); for (final String bigram : expectedBigrams) { - assertNotNull(group.getBigram(bigram)); + assertNotNull(ptNode.getBigram(bigram)); } } @@ -136,21 +138,14 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase private void writeDictToFile(final File file, final UserHistoryDictionaryBigramList bigramList) { - try { - final FileOutputStream out = new FileOutputStream(file); - UserHistoryDictIOUtils.writeDictionaryBinary(out, this, bigramList, FORMAT_OPTIONS); - out.flush(); - out.close(); - } catch (IOException e) { - Log.e(TAG, "IO exception while writing file", e); - } + final DictEncoder dictEncoder = new Ver3DictEncoder(file); + UserHistoryDictIOUtils.writeDictionary(dictEncoder, this, bigramList, FORMAT_OPTIONS); } private void readDictFromFile(final File file, final OnAddWordListener listener) { - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); + final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file, DictDecoder.USE_BYTEARRAY); try { - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory()); + dictDecoder.openDictBuffer(); } catch (FileNotFoundException e) { Log.e(TAG, "file not found", e); } catch (IOException e) { diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java index d8fcbeeaf..465b17766 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtils.java @@ -17,6 +17,7 @@ package com.android.inputmethod.latin.dicttool; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils; +import com.android.inputmethod.latin.makedict.DictDecoder; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import com.android.inputmethod.latin.makedict.Ver3DictDecoder; @@ -184,15 +185,14 @@ public final class BinaryDictOffdeviceUtils { crash(filename, new RuntimeException( filename + " does not seem to be a dictionary file")); } else { - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(decodedSpec.mFile); - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory()); + final DictDecoder dictDecoder = new Ver3DictDecoder(decodedSpec.mFile, + DictDecoder.USE_BYTEARRAY); if (report) { System.out.println("Format : Binary dictionary format"); System.out.println("Packaging : " + decodedSpec.describeChain()); System.out.println("Uncompressed size : " + decodedSpec.mFile.length()); } - return BinaryDictDecoderUtils.readDictionaryBinary(dictDecoder, null); + return dictDecoder.readDictionaryBinary(null); } } } catch (IOException e) { diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java index a0fcaabd0..709b8196c 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/DictionaryMaker.java @@ -17,18 +17,19 @@ package com.android.inputmethod.latin.dicttool; import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils; -import com.android.inputmethod.latin.makedict.BinaryDictEncoder; +import com.android.inputmethod.latin.makedict.DictDecoder; +import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.MakedictLog; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import com.android.inputmethod.latin.makedict.Ver3DictDecoder; +import com.android.inputmethod.latin.makedict.Ver3DictEncoder; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.util.Arrays; @@ -266,10 +267,8 @@ public class DictionaryMaker { private static FusionDictionary readBinaryFile(final String binaryFilename) throws FileNotFoundException, IOException, UnsupportedFormatException { final File file = new File(binaryFilename); - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file); - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); - return BinaryDictDecoderUtils.readDictionaryBinary(dictDecoder, null); + final DictDecoder dictDecoder = new Ver3DictDecoder(file); + return dictDecoder.readDictionaryBinary(null); } /** @@ -358,8 +357,8 @@ public class DictionaryMaker { throws FileNotFoundException, IOException, UnsupportedFormatException { final File outputFile = new File(outputFilename); final FormatSpec.FormatOptions formatOptions = new FormatSpec.FormatOptions(version); - BinaryDictEncoder.writeDictionaryBinary(new FileOutputStream(outputFilename), dict, - formatOptions); + final DictEncoder dictEncoder = new Ver3DictEncoder(outputFile); + dictEncoder.writeDictionary(dict, formatOptions); } /** diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java index d790d0652..66fd084cd 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java @@ -17,7 +17,7 @@ package com.android.inputmethod.latin.dicttool; import com.android.inputmethod.latin.makedict.FusionDictionary; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; import com.android.inputmethod.latin.makedict.Word; @@ -121,7 +121,7 @@ public class Diff extends Dicttool.Command { private static void diffWords(final FusionDictionary dict0, final FusionDictionary dict1) { boolean hasDifferences = false; for (final Word word0 : dict0) { - final CharGroup word1 = FusionDictionary.findWordInTree(dict1.mRootNodeArray, + final PtNode word1 = FusionDictionary.findWordInTree(dict1.mRootNodeArray, word0.mWord); if (null == word1) { // This word is not in dict1 @@ -151,7 +151,7 @@ public class Diff extends Dicttool.Command { } } for (final Word word1 : dict1) { - final CharGroup word0 = FusionDictionary.findWordInTree(dict0.mRootNodeArray, + final PtNode word0 = FusionDictionary.findWordInTree(dict0.mRootNodeArray, word1.mWord); if (null == word0) { // This word is not in dict0 diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java index fa8c5f776..350f42772 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java @@ -18,7 +18,7 @@ package com.android.inputmethod.latin.dicttool; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; import com.android.inputmethod.latin.makedict.Word; @@ -65,20 +65,20 @@ public class Info extends Dicttool.Command { private static void showWordInfo(final FusionDictionary dict, final String word, final boolean plumbing) { - final CharGroup group = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); - if (null == group) { + final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); + if (null == ptNode) { System.out.println(word + " is not in the dictionary"); return; } System.out.println("Word: " + word); - System.out.println(" Freq: " + group.getFrequency()); - if (group.getIsNotAWord()) { + System.out.println(" Freq: " + ptNode.getFrequency()); + if (ptNode.getIsNotAWord()) { System.out.println(" Is not a word"); } - if (group.getIsBlacklistEntry()) { + if (ptNode.getIsBlacklistEntry()) { System.out.println(" Is a blacklist entry"); } - final ArrayList<WeightedString> shortcutTargets = group.getShortcutTargets(); + final ArrayList<WeightedString> shortcutTargets = ptNode.getShortcutTargets(); if (null == shortcutTargets || shortcutTargets.isEmpty()) { System.out.println(" No shortcuts"); } else { @@ -88,7 +88,7 @@ public class Info extends Dicttool.Command { ? "whitelist" : shortcutTarget.mFrequency) + ")"); } } - final ArrayList<WeightedString> bigrams = group.getBigrams(); + final ArrayList<WeightedString> bigrams = ptNode.getBigrams(); if (null == bigrams || bigrams.isEmpty()) { System.out.println(" No bigrams"); } else { diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java index 451b145e9..47e220617 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java @@ -16,14 +16,15 @@ package com.android.inputmethod.latin.dicttool; -import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils; -import com.android.inputmethod.latin.makedict.BinaryDictEncoder; +import com.android.inputmethod.latin.makedict.DictDecoder; +import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import com.android.inputmethod.latin.makedict.Ver3DictDecoder; +import com.android.inputmethod.latin.makedict.Ver3DictEncoder; import junit.framework.TestCase; @@ -53,12 +54,13 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase { final File dst = File.createTempFile("testGetRawDict", ".tmp"); dst.deleteOnExit(); + final OutputStream out = Compress.getCompressedStream( Compress.getCompressedStream( Compress.getCompressedStream( new BufferedOutputStream(new FileOutputStream(dst))))); - - BinaryDictEncoder.writeDictionaryBinary(out, dict, new FormatOptions(2, false)); + final DictEncoder dictEncoder = new Ver3DictEncoder(out); + dictEncoder.writeDictionary(dict, new FormatOptions(2, false)); // Test for an actually compressed dictionary and its contents final BinaryDictOffdeviceUtils.DecoderChainSpec decodeSpec = @@ -67,10 +69,8 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase { assertEquals("Wrong decode spec", BinaryDictOffdeviceUtils.COMPRESSION, step); } assertEquals("Wrong decode spec", 3, decodeSpec.mDecoderSpec.size()); - final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(decodeSpec.mFile); - dictDecoder.openDictBuffer( - new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); - final FusionDictionary resultDict = BinaryDictDecoderUtils.readDictionaryBinary(dictDecoder, + final DictDecoder dictDecoder = new Ver3DictDecoder(decodeSpec.mFile); + final FusionDictionary resultDict = dictDecoder.readDictionaryBinary( null /* dict : an optional dictionary to add words to, or null */); assertEquals("Dictionary can't be read back correctly", FusionDictionary.findWordInTree(resultDict.mRootNodeArray, "foo").getFrequency(), diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java index fe6738303..55058238c 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.HashMap; /** - * Unit tests for BinaryDictEncoder.flattenTree(). + * Unit tests for BinaryDictEncoderUtils.flattenTree(). */ public class BinaryDictEncoderFlattenTreeTests extends TestCase { // Test the flattened array contains the expected number of nodes, and @@ -39,7 +39,8 @@ public class BinaryDictEncoderFlattenTreeTests extends TestCase { dict.add("ftb", 1, null, false /* isNotAWord */); dict.add("bar", 1, null, false /* isNotAWord */); dict.add("fool", 1, null, false /* isNotAWord */); - final ArrayList<PtNodeArray> result = BinaryDictEncoder.flattenTree(dict.mRootNodeArray); + final ArrayList<PtNodeArray> result = + BinaryDictEncoderUtils.flattenTree(dict.mRootNodeArray); assertEquals(4, result.size()); while (!result.isEmpty()) { final PtNodeArray n = result.remove(0); diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java index 22c0ceb4c..659650a05 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java @@ -17,7 +17,7 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.makedict.FusionDictionary; -import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; +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.Word; @@ -72,8 +72,8 @@ public class FusionDictionaryTest extends TestCase { assertNotNull(dict); for (final String word : words) { if (--limit < 0) return; - final CharGroup cg = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); - assertNotNull(cg); + final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word); + assertNotNull(ptNode); } } diff --git a/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml index 6d13d6bb6..5a03c803c 100644 --- a/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-fa/donottranslate-more-keys.xml @@ -86,6 +86,8 @@ <string name="keylabel_for_apostrophe">،</string> <string name="keyhintlabel_for_apostrophe">؟</string> <string name="more_keys_for_apostrophe">"!fixedColumnOrder!4,:,!,؟,؛,-,/,«|»,»|«"</string> + <!-- U+FDFC: "﷼" RIAL SIGN --> + <string name="keylabel_for_currency">﷼</string> <!-- U+061F: "؟" ARABIC QUESTION MARK U+060C: "،" ARABIC COMMA U+061B: "؛" ARABIC SEMICOLON --> diff --git a/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml index 98ad2cb3e..b0d010f81 100644 --- a/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-hi/donottranslate-more-keys.xml @@ -59,5 +59,5 @@ <string name="additional_more_keys_for_symbols_9">9</string> <string name="additional_more_keys_for_symbols_0">0</string> <!-- U+20B9: "₹" INDIAN RUPEE SIGN --> - <string name="keylabel_for_currency_generic">₹</string> + <string name="keylabel_for_currency">₹</string> </resources> diff --git a/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml index 9d2e01ebd..15ac050ee 100644 --- a/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-iw/donottranslate-more-keys.xml @@ -26,9 +26,8 @@ <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,\\,,\?,\@,&,\\%,+,;,/,(|),)|("</string> <!-- U+2605: "★" BLACK STAR --> <string name="more_keys_for_star">★</string> - <!-- U+00B1: "±" PLUS-MINUS SIGN - U+FB29: "﬩" HEBREW LETTER ALTERNATIVE PLUS SIGN --> - <string name="more_keys_for_plus">±,﬩</string> + <!-- U+FB29: "﬩" HEBREW LETTER ALTERNATIVE PLUS SIGN --> + <string name="more_keys_for_plus">﬩</string> <!-- The all letters need to be mirrored are found at http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> <string name="more_keys_for_left_parenthesis">!fixedColumnOrder!3,<|>,{|},[|]</string> @@ -52,4 +51,6 @@ <string name="double_quotes">“,”,„</string> <string name="single_angle_quotes">!text/single_laqm_raqm_rtl</string> <string name="double_angle_quotes">!text/double_laqm_raqm_rtl</string> + <!-- U+20AA: "₪" NEW SHEQEL SIGN --> + <string name="keylabel_for_currency">₪</string> </resources> diff --git a/tools/make-keyboard-text/res/values-mn/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-mn/donottranslate-more-keys.xml index fd1853e85..a7f366685 100644 --- a/tools/make-keyboard-text/res/values-mn/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-mn/donottranslate-more-keys.xml @@ -24,5 +24,5 @@ U+0412: "В" CYRILLIC CAPITAL LETTER VE --> <string name="label_to_alpha_key">АБВ</string> <!-- U+20AE: "₮" TUGRIK SIGN --> - <string name="keylabel_for_currency_generic">₮</string> + <string name="keylabel_for_currency">₮</string> </resources> diff --git a/tools/make-keyboard-text/res/values-th/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-th/donottranslate-more-keys.xml index 6350d4b8e..070c91526 100644 --- a/tools/make-keyboard-text/res/values-th/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-th/donottranslate-more-keys.xml @@ -24,5 +24,5 @@ U+0E04: "ค" THAI CHARACTER KHO KHWAI --> <string name="label_to_alpha_key">กขค</string> <!-- U+0E3F: "฿" THAI CURRENCY SYMBOL BAHT --> - <string name="keylabel_for_currency_generic">฿</string> + <string name="keylabel_for_currency">฿</string> </resources> diff --git a/tools/make-keyboard-text/res/values-uk/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-uk/donottranslate-more-keys.xml index cc05cc697..6ee34e305 100644 --- a/tools/make-keyboard-text/res/values-uk/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-uk/donottranslate-more-keys.xml @@ -35,7 +35,7 @@ <!-- U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN --> <string name="more_keys_for_cyrillic_soft_sign">ъ</string> <!-- U+20B4: "₴" HRYVNIA SIGN --> - <string name="keylabel_for_currency_generic">₴</string> + <string name="keylabel_for_currency">₴</string> <!-- Label for "switch to alphabetic" key. U+0410: "А" CYRILLIC CAPITAL LETTER A U+0411: "Б" CYRILLIC CAPITAL LETTER BE diff --git a/tools/make-keyboard-text/res/values-vi/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-vi/donottranslate-more-keys.xml index fa98ea9e1..f01f0687a 100644 --- a/tools/make-keyboard-text/res/values-vi/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values-vi/donottranslate-more-keys.xml @@ -93,5 +93,5 @@ <!-- U+0111: "đ" LATIN SMALL LETTER D WITH STROKE --> <string name="more_keys_for_d">đ</string> <!-- U+20AB: "₫" DONG SIGN --> - <string name="keylabel_for_currency_generic">₫</string> + <string name="keylabel_for_currency">₫</string> </resources> diff --git a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml index 4cf26505f..66172bd25 100644 --- a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml @@ -75,8 +75,8 @@ U+00A5: "¥" YEN SIGN U+20B1: "₱" PESO SIGN --> <string name="more_keys_for_currency_dollar">¢,£,€,¥,₱</string> - <string name="keylabel_for_currency_generic">$</string> - <string name="more_keys_for_currency_generic">$,¢,€,£,¥,₱</string> + <string name="keylabel_for_currency">$</string> + <string name="more_keys_for_currency">$,¢,€,£,¥,₱</string> <string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,\\,,\?,\@,&,\\%,+,;,/,(,)"</string> <!-- U+2020: "†" DAGGER U+2021: "‡" DOUBLE DAGGER @@ -88,8 +88,7 @@ U+2666: "♦" BLACK DIAMOND SUIT U+2663: "♣" BLACK CLUB SUIT --> <string name="more_keys_for_bullet">♪,♥,♠,♦,♣</string> - <!-- U+00B1: "±" PLUS-MINUS SIGN --> - <string name="more_keys_for_plus">±</string> + <string name="more_keys_for_plus"></string> <!-- The all letters need to be mirrored are found at http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> <string name="more_keys_for_left_parenthesis">!fixedColumnOrder!3,<,{,[</string> @@ -186,10 +185,6 @@ <string name="shortcut_as_more_key">!icon/shortcut_key|!code/key_shortcut</string> <string name="action_next_as_more_key">!hasLabels!,\@string/label_next_key|!code/key_action_next</string> <string name="action_previous_as_more_key">!hasLabels!,\@string/label_previous_key|!code/key_action_previous</string> - <!-- Label for "switch to more symbol" modifier key. Must be short to fit on key! --> - <string name="label_to_more_symbol_key">= \\ <</string> - <!-- Label for "switch to more symbol" modifier key on tablets. Must be short to fit on key! --> - <string name="label_to_more_symbol_for_tablet_key">~ \\ {</string> <!-- Label for "Tab" key. Must be short to fit on key! --> <string name="label_tab_key">Tab</string> <!-- Label for "switch to phone numeric" key. Must be short to fit on key! --> @@ -202,8 +197,6 @@ <string name="label_time_am">"AM"</string> <!-- Key label for "post meridiem" --> <string name="label_time_pm">"PM"</string> - <!-- Label for "switch to symbols" key on PC QWERTY layout --> - <string name="label_to_symbol_key_pcqwerty">Sym</string> <string name="keylabel_for_popular_domain">".com"</string> <!-- popular web domains for the locale - most popular, displayed on the keyboard --> <string name="more_keys_for_popular_domain">"!hasLabels!,.net,.org,.gov,.edu"</string> |