diff options
Diffstat (limited to 'java')
62 files changed, 574 insertions, 273 deletions
diff --git a/java/res/drawable-sw600dp-hdpi/keyboard_key_feedback_background_holo.9.png b/java/res/drawable-sw600dp-hdpi/keyboard_key_feedback_background_holo.9.png Binary files differdeleted file mode 100644 index 39219a583..000000000 --- a/java/res/drawable-sw600dp-hdpi/keyboard_key_feedback_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw600dp-hdpi/keyboard_key_feedback_more_background_holo.9.png b/java/res/drawable-sw600dp-hdpi/keyboard_key_feedback_more_background_holo.9.png Binary files differdeleted file mode 100644 index e5cc5b7e2..000000000 --- a/java/res/drawable-sw600dp-hdpi/keyboard_key_feedback_more_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw600dp-mdpi/keyboard_key_feedback_background_holo.9.png b/java/res/drawable-sw600dp-mdpi/keyboard_key_feedback_background_holo.9.png Binary files differdeleted file mode 100644 index 5f152175d..000000000 --- a/java/res/drawable-sw600dp-mdpi/keyboard_key_feedback_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw600dp-mdpi/keyboard_key_feedback_more_background_holo.9.png b/java/res/drawable-sw600dp-mdpi/keyboard_key_feedback_more_background_holo.9.png Binary files differdeleted file mode 100644 index 77a806c1e..000000000 --- a/java/res/drawable-sw600dp-mdpi/keyboard_key_feedback_more_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw600dp-xhdpi/keyboard_key_feedback_background_holo.9.png b/java/res/drawable-sw600dp-xhdpi/keyboard_key_feedback_background_holo.9.png Binary files differdeleted file mode 100644 index 8d43a4bdb..000000000 --- a/java/res/drawable-sw600dp-xhdpi/keyboard_key_feedback_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw600dp-xhdpi/keyboard_key_feedback_more_background_holo.9.png b/java/res/drawable-sw600dp-xhdpi/keyboard_key_feedback_more_background_holo.9.png Binary files differdeleted file mode 100644 index e973c7e6a..000000000 --- a/java/res/drawable-sw600dp-xhdpi/keyboard_key_feedback_more_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw768dp-hdpi/keyboard_key_feedback_background_holo.9.png b/java/res/drawable-sw768dp-hdpi/keyboard_key_feedback_background_holo.9.png Binary files differdeleted file mode 100644 index 099a50873..000000000 --- a/java/res/drawable-sw768dp-hdpi/keyboard_key_feedback_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw768dp-hdpi/keyboard_key_feedback_more_background_holo.9.png b/java/res/drawable-sw768dp-hdpi/keyboard_key_feedback_more_background_holo.9.png Binary files differdeleted file mode 100644 index c21240f17..000000000 --- a/java/res/drawable-sw768dp-hdpi/keyboard_key_feedback_more_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw768dp-mdpi/keyboard_key_feedback_background_holo.9.png b/java/res/drawable-sw768dp-mdpi/keyboard_key_feedback_background_holo.9.png Binary files differdeleted file mode 100644 index 286cf84fc..000000000 --- a/java/res/drawable-sw768dp-mdpi/keyboard_key_feedback_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw768dp-mdpi/keyboard_key_feedback_more_background_holo.9.png b/java/res/drawable-sw768dp-mdpi/keyboard_key_feedback_more_background_holo.9.png Binary files differdeleted file mode 100644 index e3f5be86d..000000000 --- a/java/res/drawable-sw768dp-mdpi/keyboard_key_feedback_more_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw768dp-xhdpi/keyboard_key_feedback_background_holo.9.png b/java/res/drawable-sw768dp-xhdpi/keyboard_key_feedback_background_holo.9.png Binary files differdeleted file mode 100644 index 38c84e81b..000000000 --- a/java/res/drawable-sw768dp-xhdpi/keyboard_key_feedback_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable-sw768dp-xhdpi/keyboard_key_feedback_more_background_holo.9.png b/java/res/drawable-sw768dp-xhdpi/keyboard_key_feedback_more_background_holo.9.png Binary files differdeleted file mode 100644 index f66e54538..000000000 --- a/java/res/drawable-sw768dp-xhdpi/keyboard_key_feedback_more_background_holo.9.png +++ /dev/null diff --git a/java/res/drawable/transparent.xml b/java/res/drawable/transparent.xml new file mode 100644 index 000000000..855cf2ad5 --- /dev/null +++ b/java/res/drawable/transparent.xml @@ -0,0 +1,30 @@ +<?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. +*/ +--> + +<shape + xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" +> + <solid + android:color="@android:color/transparent" /> + <size + android:width="50dp" + android:height="40dp" /> +</shape> diff --git a/java/res/layout/candidate_info.xml b/java/res/layout/candidate_info.xml new file mode 100644 index 000000000..f3557289c --- /dev/null +++ b/java/res/layout/candidate_info.xml @@ -0,0 +1,28 @@ +<?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. +*/ +--> + +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="6sp" + android:textColor="@android:color/white" + android:visibility="gone" + style="?attr/suggestionBackgroundStyle" /> diff --git a/java/res/layout/candidate.xml b/java/res/layout/candidate_word.xml index 94ae2b44e..94ae2b44e 100644 --- a/java/res/layout/candidate.xml +++ b/java/res/layout/candidate_word.xml diff --git a/java/res/layout/candidates_strip.xml b/java/res/layout/candidates_strip.xml index 88f4c3830..c23c29cbe 100644 --- a/java/res/layout/candidates_strip.xml +++ b/java/res/layout/candidates_strip.xml @@ -22,14 +22,34 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <include - android:id="@+id/candidate_left" - layout="@layout/candidate" /> + <RelativeLayout + android:layout_weight="1.0" + android:layout_width="0dp" + android:layout_height="match_parent" + android:gravity="center" + > + <include + android:id="@+id/word_left" + layout="@layout/candidate_word" /> + <include + android:id="@+id/info_left" + layout="@layout/candidate_info" /> + </RelativeLayout> <include layout="@layout/candidate_divider" /> - <include - android:id="@+id/candidate_center" - layout="@layout/candidate" /> + <RelativeLayout + android:layout_weight="1.0" + android:layout_width="0dp" + android:layout_height="match_parent" + android:gravity="center" + > + <include + android:id="@+id/word_center" + layout="@layout/candidate_word" /> + <include + android:id="@+id/info_center" + layout="@layout/candidate_info" /> + </RelativeLayout> <include layout="@layout/candidate_divider" /> <LinearLayout @@ -39,9 +59,19 @@ android:layout_height="wrap_content" android:gravity="center_vertical" > - <include - android:id="@+id/candidate_right" - layout="@layout/candidate" /> + <RelativeLayout + android:layout_weight="1.0" + android:layout_width="0dp" + android:layout_height="match_parent" + android:gravity="center" + > + <include + android:id="@+id/word_right" + layout="@layout/candidate_word" /> + <include + android:id="@+id/info_right" + layout="@layout/candidate_info" /> + </RelativeLayout> <!-- Image drawables are set in CandidateView constructor --> <ImageButton android:id="@+id/expand_candidates_pane" diff --git a/java/res/layout/input_view.xml b/java/res/layout/input_view.xml index 93a046619..821082f91 100644 --- a/java/res/layout/input_view.xml +++ b/java/res/layout/input_view.xml @@ -32,7 +32,8 @@ android:id="@+id/candidates_container" android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="@dimen/candidate_strip_minimum_height" + android:layout_height="wrap_content" + android:minHeight="@dimen/candidate_strip_minimum_height" android:gravity="bottom" > <View diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index b374227af..8f6eb2339 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -37,8 +37,9 @@ <fraction name="key_label_ratio">35%</fraction> <fraction name="key_hint_letter_ratio">28%</fraction> <fraction name="key_uppercase_letter_ratio">40%</fraction> - <dimen name="key_preview_offset">0.08in</dimen> <fraction name="key_preview_text_ratio">90%</fraction> + <dimen name="key_preview_offset">0.08in</dimen> + <dimen name="key_preview_offset_ics">0.01in</dimen> <dimen name="candidate_strip_height">38dip</dimen> <dimen name="candidate_strip_fading_edge_length">63dip</dimen> <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> diff --git a/java/res/values-sw600dp-land/dimens.xml b/java/res/values-sw600dp-land/dimens.xml index 9da8f897b..6e583e3bf 100644 --- a/java/res/values-sw600dp-land/dimens.xml +++ b/java/res/values-sw600dp-land/dimens.xml @@ -33,8 +33,6 @@ <dimen name="keyboard_top_padding_ics">1.1mm</dimen> <dimen name="keyboard_bottom_padding_ics">0.0mm</dimen> <dimen name="popup_key_height">13.0mm</dimen> - <!-- key_height x 1.0 --> - <dimen name="key_preview_height">13.0mm</dimen> <fraction name="key_letter_ratio">45%</fraction> <fraction name="key_label_ratio">32%</fraction> diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml index c2c0c2588..75c0edf87 100644 --- a/java/res/values-sw600dp/config.xml +++ b/java/res/values-sw600dp/config.xml @@ -20,7 +20,6 @@ <resources> <bool name="config_enable_show_settings_key_option">true</bool> - <bool name="config_enable_show_subtype_settings">false</bool> <bool name="config_enable_show_voice_key_option">false</bool> <bool name="config_enable_show_popup_on_keypress_option">false</bool> <bool name="config_enable_show_recorrection_option">false</bool> diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml index 6c67746eb..274b62b4c 100644 --- a/java/res/values-sw600dp/dimens.xml +++ b/java/res/values-sw600dp/dimens.xml @@ -34,8 +34,6 @@ <dimen name="key_horizontal_gap_ics">1.0mm</dimen> <dimen name="keyboard_top_padding_ics">1.1mm</dimen> <dimen name="keyboard_bottom_padding_ics">0.0mm</dimen> - <!-- key_height x 1.0 --> - <dimen name="key_preview_height">13.0mm</dimen> <dimen name="mini_keyboard_key_horizontal_padding">12dip</dimen> <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. --> <!-- popup_key_height x 1.2 --> @@ -47,7 +45,10 @@ <fraction name="key_label_ratio">22%</fraction> <fraction name="key_hint_letter_ratio">23%</fraction> <fraction name="key_uppercase_letter_ratio">25%</fraction> - <fraction name="key_preview_text_ratio">82%</fraction> + <fraction name="key_preview_text_ratio">50%</fraction> + <dimen name="key_preview_height">15.0mm</dimen> + <dimen name="key_preview_offset">0.1in</dimen> + <dimen name="key_preview_offset_ics">0.05in</dimen> <!-- left or right padding of label alignment --> <dimen name="key_label_horizontal_alignment_padding">6dip</dimen> diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml index a6cd85b6e..74eb08aa3 100644 --- a/java/res/values-sw768dp-land/dimens.xml +++ b/java/res/values-sw768dp-land/dimens.xml @@ -39,6 +39,7 @@ <fraction name="key_label_ratio">26%</fraction> <fraction name="key_hint_letter_ratio">23%</fraction> <fraction name="key_uppercase_letter_ratio">24%</fraction> + <dimen name="key_preview_height">17.0mm</dimen> <!-- left or right padding of label alignment --> <dimen name="key_label_horizontal_alignment_padding">18dip</dimen> <dimen name="key_preview_height_holo">26.5mm</dimen> diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml index dc4c28774..4025b0e41 100644 --- a/java/res/values-sw768dp/config.xml +++ b/java/res/values-sw768dp/config.xml @@ -21,8 +21,7 @@ <resources> <bool name="config_enable_show_settings_key_option">false</bool> <bool name="config_enable_show_voice_key_option">false</bool> - <!-- TODO: This configuration value is temporary set true to check popup preview behavior. --> - <bool name="config_enable_show_popup_on_keypress_option">true</bool> + <bool name="config_enable_show_popup_on_keypress_option">false</bool> <bool name="config_enable_show_recorrection_option">false</bool> <bool name="config_enable_quick_fixes_option">false</bool> <bool name="config_enable_bigram_suggestions_option">false</bool> @@ -32,7 +31,7 @@ <!-- Whether or not Popup on key press is enabled by default --> <bool name="config_default_popup_preview">false</bool> <bool name="config_default_sound_enabled">true</bool> - <bool name="config_auto_correction_spacebar_led_enabled">true</bool> + <bool name="config_auto_correction_spacebar_led_enabled">false</bool> <bool name="config_use_spacebar_language_switcher">false</bool> <!-- Showing mini keyboard, just above the touched point if true, aligned to the key if false --> <bool name="config_show_mini_keyboard_at_touched_point">true</bool> diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml index 815267306..b5d5a8496 100644 --- a/java/res/values-sw768dp/dimens.xml +++ b/java/res/values-sw768dp/dimens.xml @@ -47,11 +47,12 @@ <fraction name="key_label_ratio">26%</fraction> <fraction name="key_hint_letter_ratio">23%</fraction> <fraction name="key_uppercase_letter_ratio">25%</fraction> + <fraction name="key_preview_text_ratio">50%</fraction> + <dimen name="key_preview_height">15.0mm</dimen> + <dimen name="key_preview_offset">0.1in</dimen> + <dimen name="key_preview_offset_ics">0.05in</dimen> <!-- left or right padding of label alignment --> <dimen name="key_label_horizontal_alignment_padding">6dip</dimen> - <fraction name="key_preview_text_ratio">26.3%</fraction> - <dimen name="key_preview_height_holo">23.0mm</dimen> - <dimen name="key_preview_offset_holo">8.0mm</dimen> <dimen name="candidate_strip_height">46dip</dimen> <!-- candidate_strip_minimum_height = diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 5c00510af..e9b6354a5 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -277,6 +277,14 @@ <attr name="navigateAction" format="boolean" /> <attr name="passwordInput" format="boolean" /> <attr name="hasSettingsKey" format="boolean" /> + <!-- This should be aligned with KeyboardID.F2KEY_MODE_* --> + <attr name="f2KeyMode" format="enum"> + <enum name="none" value="0" /> + <enum name="settings" value="1" /> + <enum name="shortcutIme" value="2" /> + <enum name="shortcutImeOrSettings" value="3" /> + </attr> + <attr name="clobberSettingsKey" format="boolean" /> <attr name="voiceKeyEnabled" format="boolean" /> <attr name="hasVoiceKey" format="boolean" /> <attr name="imeAction" format="enum"> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index ad580cc69..40cca9543 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -76,7 +76,9 @@ <!-- Modest : Suggestion whose normalized score is greater than this value will be subject to auto-correction. --> <item>0.22</item> - <!-- Aggressive : Suggestion whose normalized score is greater than this value + <!-- Aggressive --> + <item>0.08</item> + <!-- Very Aggressive : Suggestion whose normalized score is greater than this value will be subject to auto-correction. --> <item>0</item> </string-array> diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 665245c23..54256de3c 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -55,9 +55,9 @@ <fraction name="key_uppercase_letter_ratio">35%</fraction> <!-- left or right padding of label alignment --> <dimen name="key_label_horizontal_alignment_padding">21dip</dimen> + <fraction name="key_preview_text_ratio">82%</fraction> <dimen name="key_preview_height">80sp</dimen> <dimen name="key_preview_offset">0.1in</dimen> - <fraction name="key_preview_text_ratio">82%</fraction> <dimen name="key_preview_offset_ics">0.05in</dimen> <dimen name="candidate_strip_height">42dip</dimen> diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 1c198d9cb..21e6c55c6 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -86,15 +86,18 @@ <string name="auto_correction_threshold_mode_index_off">0</string> <string name="auto_correction_threshold_mode_index_modest">1</string> <string name="auto_correction_threshold_mode_index_aggeressive">2</string> + <string name="auto_correction_threshold_mode_index_very_aggeressive">3</string> <string-array name="auto_correction_threshold_mode_indexes"> <item>@string/auto_correction_threshold_mode_index_off</item> <item>@string/auto_correction_threshold_mode_index_modest</item> <item>@string/auto_correction_threshold_mode_index_aggeressive</item> + <item>@string/auto_correction_threshold_mode_index_very_aggeressive</item> </string-array> <string-array name="auto_correction_threshold_modes"> <item>@string/auto_correction_threshold_mode_off</item> <item>@string/auto_correction_threshold_mode_modest</item> <item>@string/auto_correction_threshold_mode_aggeressive</item> + <item>@string/auto_correction_threshold_mode_very_aggeressive</item> </string-array> <string name="voice_mode_main">0</string> diff --git a/java/res/values/keyboard-icons-ics.xml b/java/res/values/keyboard-icons-ics.xml index 3029695e6..1dfbdf96e 100644 --- a/java/res/values/keyboard-icons-ics.xml +++ b/java/res/values/keyboard-icons-ics.xml @@ -60,7 +60,7 @@ <item name="iconNum0Key">@drawable/sym_keyboard_num0</item> <!-- <item name="iconShiftedShiftKey">@drawable/sym_keyboard_shift_locked_holo</item> --> <item name="iconShiftedShiftKey">@drawable/sym_keyboard_shift_locked</item> - <item name="iconPreviewSpaceKey">@drawable/sym_keyboard_space_holo</item> + <item name="iconPreviewSpaceKey">@drawable/transparent</item> <!-- <item name="iconPreviewTabKey">@drawable/sym_keyboard_tab_holo</item> --> <item name="iconPreviewTabKey">@drawable/sym_keyboard_feedback_tab</item> <!-- <item name="iconPreviewSettingsKey">@drawable/sym_keyboard_settings_holo</item> --> @@ -72,7 +72,7 @@ <item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item> <item name="spacebarArrowLeftIcon">@drawable/sym_keyboard_language_arrows_left</item> <item name="spacebarArrowRightIcon">@drawable/sym_keyboard_language_arrows_right</item> - <item name="spacebarArrowPreviewLeftIcon">@drawable/sym_keyboard_feedback_language_arrows_left</item> - <item name="spacebarArrowPreviewRightIcon">@drawable/sym_keyboard_feedback_language_arrows_right</item> +<!-- <item name="spacebarArrowPreviewLeftIcon">@drawable/sym_keyboard_feedback_language_arrows_left</item> --> +<!-- <item name="spacebarArrowPreviewRightIcon">@drawable/sym_keyboard_feedback_language_arrows_right</item> --> </style> </resources> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 5d7a1f9c7..f6e130789 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -66,6 +66,9 @@ <!-- Option to enable auto capitalization of sentences --> <string name="auto_cap">Auto-capitalization</string> + <!-- Option to configure dictionaries --> + <string name="configure_dictionaries_title">Configure dictionaries</string> + <!-- Option to enable quick fixes --> <string name="quick_fixes">Quick fixes</string> <!-- Description for quick fixes --> @@ -101,6 +104,8 @@ <string name="auto_correction_threshold_mode_modest">Modest</string> <!-- Option to suggest auto correction candidates aggressively. Auto-corrects to a word which has even large edit distance from typed word. [CHAR LIMIT=20] --> <string name="auto_correction_threshold_mode_aggeressive">Aggressive</string> + <!-- Option to suggest auto correction candidates very aggressively. Auto-corrects to a word which has even large edit distance from typed word. [CHAR LIMIT=20] --> + <string name="auto_correction_threshold_mode_very_aggeressive">Very Aggressive</string> <!-- Option to enable bigram correction --> <string name="bigram_suggestion">Bigram suggestions</string> diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml index dbff293ba..e8e80ac03 100644 --- a/java/res/xml-sw600dp/kbd_key_styles.xml +++ b/java/res/xml-sw600dp/kbd_key_styles.xml @@ -25,6 +25,23 @@ <key-style latin:styleName="functionalKeyStyle" latin:isFunctional="true" /> + <!-- Base key style for the key which may have settings key as popup key --> + <switch> + <case + latin:clobberSettingsKey="true" + > + <key-style + latin:styleName="settingsPopupStyle" + latin:parentStyle="functionalKeyStyle" /> + </case> + <default> + <key-style + latin:styleName="settingsPopupStyle" + latin:keyLabelOption="popupHint" + latin:popupCharacters="\@icon/5|\@integer/key_settings" + latin:parentStyle="functionalKeyStyle" /> + </default> + </switch> <!-- Functional key styles --> <key-style latin:styleName="shiftKeyStyle" @@ -59,28 +76,18 @@ latin:keyLabelOption="popupHint" latin:popupCharacters="@string/alternates_for_smiley" latin:maxPopupKeyboardColumn="5" /> - <switch> - <case - latin:voiceKeyEnabled="true" - > - <key-style - latin:styleName="shortcutOrSettingsKeyStyle" - latin:code="@integer/key_shortcut" - latin:keyIcon="iconShortcutKey" - latin:keyIconPreview="iconPreviewShortcutKey" - latin:keyLabelOption="popupHint" - latin:popupCharacters="\@icon/5|\@integer/key_settings" - latin:parentStyle="functionalKeyStyle" /> - </case> - <default> - <key-style - latin:styleName="shortcutOrSettingsKeyStyle" - latin:code="@integer/key_settings" - latin:keyIcon="iconSettingsKey" - latin:keyIconPreview="iconPreviewSettingsKey" - latin:parentStyle="functionalKeyStyle" /> - </default> - </switch> + <key-style + latin:styleName="shortcutKeyStyle" + latin:code="@integer/key_shortcut" + latin:keyIcon="iconShortcutKey" + latin:keyIconPreview="iconPreviewShortcutKey" + latin:parentStyle="settingsPopupStyle" /> + <key-style + latin:styleName="settingsKeyStyle" + latin:code="@integer/key_settings" + latin:keyIcon="iconSettingsKey" + latin:keyIconPreview="iconPreviewSettingsKey" + latin:parentStyle="functionalKeyStyle" /> <key-style latin:styleName="tabKeyStyle" latin:code="@integer/key_tab" diff --git a/java/res/xml-sw600dp/kbd_number.xml b/java/res/xml-sw600dp/kbd_number.xml index 42d7d0777..2c7af0ae2 100644 --- a/java/res/xml-sw600dp/kbd_number.xml +++ b/java/res/xml-sw600dp/kbd_number.xml @@ -78,12 +78,11 @@ latin:keyXPos="24.875%p" /> <Key latin:keyStyle="num0KeyStyle" /> - <Spacer /> - <Key - latin:keyStyle="shortcutOrSettingsKeyStyle" + <Spacer latin:keyXPos="-11.00%p" - latin:keyWidth="fillRight" - latin:keyEdgeFlags="right" /> + latin:keyWidth="0%p" /> + <include + latin:keyboardLayout="@xml/kbd_qwerty_f2" /> </Row> </case> <!-- latin:passwordInput="false" --> @@ -185,11 +184,11 @@ <Key latin:keyLabel="#" latin:keyStyle="numLabelStyle" /> - <Key - latin:keyStyle="shortcutOrSettingsKeyStyle" + <Spacer latin:keyXPos="-11.00%p" - latin:keyWidth="fillBoth" - latin:keyEdgeFlags="right" /> + latin:keyWidth="0%p" /> + <include + latin:keyboardLayout="@xml/kbd_qwerty_f2" /> </Row> </default> </switch> diff --git a/java/res/xml-sw600dp/kbd_phone.xml b/java/res/xml-sw600dp/kbd_phone.xml index 017d00352..4dee882e9 100644 --- a/java/res/xml-sw600dp/kbd_phone.xml +++ b/java/res/xml-sw600dp/kbd_phone.xml @@ -115,10 +115,10 @@ <Key latin:keyLabel="#" latin:keyStyle="numLabelStyle" /> - <Key - latin:keyStyle="shortcutOrSettingsKeyStyle" + <Spacer latin:keyXPos="-11.00%p" - latin:keyWidth="fillBoth" - latin:keyEdgeFlags="right" /> + latin:keyWidth="0%p" /> + <include + latin:keyboardLayout="@xml/kbd_qwerty_f2" /> </Row> </Keyboard> diff --git a/java/res/xml-sw600dp/kbd_phone_symbols.xml b/java/res/xml-sw600dp/kbd_phone_symbols.xml index 168e6b114..87de880d9 100644 --- a/java/res/xml-sw600dp/kbd_phone_symbols.xml +++ b/java/res/xml-sw600dp/kbd_phone_symbols.xml @@ -125,10 +125,10 @@ <Key latin:keyLabel="#" latin:keyStyle="numLabelStyle" /> - <Key - latin:keyStyle="shortcutOrSettingsKeyStyle" + <Spacer latin:keyXPos="-11.00%p" - latin:keyWidth="fillBoth" - latin:keyEdgeFlags="right" /> + latin:keyWidth="0%p" /> + <include + latin:keyboardLayout="@xml/kbd_qwerty_f2" /> </Row> </Keyboard> diff --git a/java/res/xml-sw600dp/kbd_qwerty_f2.xml b/java/res/xml-sw600dp/kbd_qwerty_f2.xml new file mode 100644 index 000000000..7638ee4b4 --- /dev/null +++ b/java/res/xml-sw600dp/kbd_qwerty_f2.xml @@ -0,0 +1,77 @@ +<?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" +> + <switch> + <case + latin:f2KeyMode="settings" + > + <Key + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="fillBoth" + latin:keyEdgeFlags="right" /> + </case> + <case + latin:f2KeyMode="shortcutIme" + > + <switch> + <case + latin:voiceKeyEnabled="true" + > + <Key + latin:keyStyle="shortcutKeyStyle" + latin:keyWidth="fillBoth" + latin:keyEdgeFlags="right" /> + </case> + <!-- voiceKeyEnabled="false" --> + <default> + <Spacer /> + </default> + </switch> + </case> + <case + latin:f2KeyMode="shortcutImeOrSettings" + > + <switch> + <case + latin:voiceKeyEnabled="true" + > + <Key + latin:keyStyle="shortcutKeyStyle" + latin:keyWidth="fillBoth" + latin:keyEdgeFlags="right" /> + </case> + <!-- voiceKeyEnabled="false" --> + <default> + <Key + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="fillBoth" + latin:keyEdgeFlags="right" /> + </default> + </switch> + </case> + <!-- f2KeyMode="none" --> + <default> + <Spacer /> + </default> + </switch> +</merge> diff --git a/java/res/xml-sw600dp/kbd_qwerty_row4.xml b/java/res/xml-sw600dp/kbd_qwerty_row4.xml index 958a7ed8f..8fd65fe0e 100644 --- a/java/res/xml-sw600dp/kbd_qwerty_row4.xml +++ b/java/res/xml-sw600dp/kbd_qwerty_row4.xml @@ -154,10 +154,10 @@ </switch> </default> </switch> - <Key - latin:keyStyle="shortcutOrSettingsKeyStyle" - latin:keyXPos="-10.0%p" - latin:keyWidth="fillBoth" - latin:keyEdgeFlags="right" /> + <Spacer + latin:keyXPos="-10.00%p" + latin:keyWidth="0%p" /> + <include + latin:keyboardLayout="@xml/kbd_qwerty_f2" /> </Row> </merge> diff --git a/java/res/xml-sw600dp/kbd_symbols.xml b/java/res/xml-sw600dp/kbd_symbols.xml index fca97c737..77849f6fd 100644 --- a/java/res/xml-sw600dp/kbd_symbols.xml +++ b/java/res/xml-sw600dp/kbd_symbols.xml @@ -209,10 +209,10 @@ latin:keyWidth="9.750%p" /> </default> </switch> - <Key - latin:keyStyle="shortcutOrSettingsKeyStyle" - latin:keyXPos="-10.0%p" - latin:keyWidth="fillBoth" - latin:keyEdgeFlags="right" /> + <Spacer + latin:keyXPos="-10.00%p" + latin:keyWidth="0%p" /> + <include + latin:keyboardLayout="@xml/kbd_qwerty_f2" /> </Row> </Keyboard> diff --git a/java/res/xml-sw600dp/kbd_symbols_shift.xml b/java/res/xml-sw600dp/kbd_symbols_shift.xml index c23681d4e..b25292f27 100644 --- a/java/res/xml-sw600dp/kbd_symbols_shift.xml +++ b/java/res/xml-sw600dp/kbd_symbols_shift.xml @@ -147,10 +147,10 @@ latin:keyStyle="spaceKeyStyle" latin:keyXPos="30.750%p" latin:keyWidth="39.750%p" /> - <Key - latin:keyStyle="shortcutOrSettingsKeyStyle" - latin:keyXPos="-10.0%p" - latin:keyWidth="fillRight" - latin:keyEdgeFlags="right" /> + <Spacer + latin:keyXPos="-10.00%p" + latin:keyWidth="0%p" /> + <include + latin:keyboardLayout="@xml/kbd_qwerty_f2" /> </Row> </Keyboard> diff --git a/java/res/xml/kbd_key_styles.xml b/java/res/xml/kbd_key_styles.xml index e7d8d31b6..63d519c4c 100644 --- a/java/res/xml/kbd_key_styles.xml +++ b/java/res/xml/kbd_key_styles.xml @@ -28,13 +28,21 @@ <!-- Base key style for the key which may have settings key as popup key --> <switch> <case + latin:clobberSettingsKey="true" + > + <key-style + latin:styleName="settingsPopupStyle" + latin:parentStyle="functionalKeyStyle" /> + </case> + <case + latin:clobberSettingsKey="false" latin:hasSettingsKey="true" > <key-style latin:styleName="settingsPopupStyle" latin:parentStyle="functionalKeyStyle" /> </case> - <!-- latin:hasSettingsKey="false" --> + <!-- clobberSettingsKey="false" and hasSettingsKey="false" --> <default> <key-style latin:styleName="settingsPopupStyle" @@ -57,57 +65,6 @@ latin:keyIcon="iconDeleteKey" latin:parentStyle="functionalKeyStyle" latin:isRepeatable="true" /> - <switch> - <!-- When this qwerty keyboard has no voice key but voice key is enabled, then symbol - keyboard will have mic key. That means we should use "?123mic" key here. --> - <case - latin:voiceKeyEnabled="true" - latin:hasVoiceKey="false" - > - <key-style - latin:styleName="toSymbolKeyStyle" - latin:code="@integer/key_switch_alpha_symbol" - latin:keyIcon="iconToSymbolKeyWithShortcut" - latin:parentStyle="functionalKeyStyle" /> - </case> - <default> - <key-style - latin:styleName="toSymbolKeyStyle" - latin:code="@integer/key_switch_alpha_symbol" - latin:keyLabel="@string/label_to_symbol_key" - latin:parentStyle="functionalKeyStyle" /> - </default> - </switch> - <key-style - latin:styleName="settingsKeyStyle" - latin:code="@integer/key_settings" - latin:keyIcon="iconSettingsKey" - latin:keyIconPreview="iconPreviewSettingsKey" - latin:parentStyle="functionalKeyStyle" /> - <key-style - latin:styleName="spaceKeyStyle" - latin:code="@integer/key_space" - latin:keyIconPreview="iconPreviewSpaceKey" - latin:parentStyle="functionalKeyStyle" /> - <key-style - latin:styleName="tabKeyStyle" - latin:code="@integer/key_tab" - latin:keyIcon="iconTabKey" - latin:keyIconPreview="iconPreviewTabKey" - latin:parentStyle="functionalKeyStyle" /> - <key-style - latin:styleName="shortcutKeyStyle" - latin:code="@integer/key_shortcut" - latin:keyIcon="iconShortcutKey" - latin:keyIconPreview="iconPreviewShortcutKey" - latin:parentStyle="settingsPopupStyle" /> - <!-- Note: This key style is not for functional tab key. This is used for the tab key which is - laid out as normal letter key. --> - <key-style - latin:styleName="nonSpecialBackgroundTabKeyStyle" - latin:code="@integer/key_tab" - latin:keyIcon="iconTabKey" - latin:keyIconPreview="iconPreviewTabKey" /> <!-- Return key style --> <switch> <case @@ -164,6 +121,65 @@ </default> </switch> <key-style + latin:styleName="spaceKeyStyle" + latin:code="@integer/key_space" + latin:keyIconPreview="iconPreviewSpaceKey" + latin:parentStyle="functionalKeyStyle" /> + <key-style + latin:styleName="smileyKeyStyle" + latin:keyLabel=":-)" + latin:keyOutputText=":-) " + latin:keyLabelOption="popupHint" + latin:popupCharacters="@string/alternates_for_smiley" + latin:maxPopupKeyboardColumn="5" + latin:parentStyle="functionalKeyStyle" /> + <key-style + latin:styleName="shortcutKeyStyle" + latin:code="@integer/key_shortcut" + latin:keyIcon="iconShortcutKey" + latin:keyIconPreview="iconPreviewShortcutKey" + latin:parentStyle="settingsPopupStyle" /> + <key-style + latin:styleName="settingsKeyStyle" + latin:code="@integer/key_settings" + latin:keyIcon="iconSettingsKey" + latin:keyIconPreview="iconPreviewSettingsKey" + latin:parentStyle="functionalKeyStyle" /> + <key-style + latin:styleName="tabKeyStyle" + latin:code="@integer/key_tab" + latin:keyIcon="iconTabKey" + latin:keyIconPreview="iconPreviewTabKey" + latin:parentStyle="functionalKeyStyle" /> + <!-- Note: This key style is not for functional tab key. This is used for the tab key which is + laid out as normal letter key. --> + <key-style + latin:styleName="nonSpecialBackgroundTabKeyStyle" + latin:code="@integer/key_tab" + latin:keyIcon="iconTabKey" + latin:keyIconPreview="iconPreviewTabKey" /> + <switch> + <!-- When this qwerty keyboard has no voice key but voice key is enabled, then symbol + keyboard will have mic key. That means we should use "?123mic" key here. --> + <case + latin:voiceKeyEnabled="true" + latin:hasVoiceKey="false" + > + <key-style + latin:styleName="toSymbolKeyStyle" + latin:code="@integer/key_switch_alpha_symbol" + latin:keyIcon="iconToSymbolKeyWithShortcut" + latin:parentStyle="functionalKeyStyle" /> + </case> + <default> + <key-style + latin:styleName="toSymbolKeyStyle" + latin:code="@integer/key_switch_alpha_symbol" + latin:keyLabel="@string/label_to_symbol_key" + latin:parentStyle="functionalKeyStyle" /> + </default> + </switch> + <key-style latin:styleName="toAlphaKeyStyle" latin:code="@integer/key_switch_alpha_symbol" latin:keyLabel="@string/label_to_alpha_key" @@ -174,14 +190,6 @@ latin:keyLabel="@string/label_alt_key" latin:parentStyle="functionalKeyStyle" latin:isSticky="true" /> - <key-style - latin:styleName="smileyKeyStyle" - latin:keyLabel=":-)" - latin:keyOutputText=":-) " - latin:keyLabelOption="popupHint" - latin:popupCharacters="@string/alternates_for_smiley" - latin:maxPopupKeyboardColumn="5" - latin:parentStyle="functionalKeyStyle" /> <switch> <case latin:passwordInput="true" diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index 5f4a27d91..f68ee0168 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -68,6 +68,14 @@ <PreferenceCategory android:title="@string/correction_category" android:key="correction_settings"> + <PreferenceScreen + android:key="configure_dictionaries_key" + android:title="@string/configure_dictionaries_title"> + <intent + android:action="android.intent.action.MAIN" + android:targetPackage="com.google.android.inputmethod.latin.dictionarypack" + android:targetClass="com.google.android.inputmethod.latin.dictionarypack.DictionarySettings" /> + </PreferenceScreen> <CheckBoxPreference android:key="quick_fixes" android:title="@string/quick_fixes" diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index 1adef9057..96f7fc9f2 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -27,10 +27,10 @@ import android.view.accessibility.AccessibilityEvent; import com.android.inputmethod.compat.AccessibilityEventCompatUtils; import com.android.inputmethod.compat.MotionEventCompatUtils; +import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.PointerTracker; -import com.android.inputmethod.keyboard.internal.Key; public class AccessibleKeyboardViewProxy { private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName(); diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 5e6f10b04..154f4af91 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -20,9 +20,9 @@ import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; +import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardId; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.latin.R; import java.util.HashMap; diff --git a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java b/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java index 46499f19a..523bf7d0e 100644 --- a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java +++ b/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java @@ -16,6 +16,7 @@ package com.android.inputmethod.compat; +import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.MarginLayoutParams; import android.widget.FrameLayout; @@ -49,4 +50,14 @@ public class FrameLayoutCompatUtils { + placer.getClass().getName()); } } + + public static void placeViewAt(View view, int x, int y, int w, int h) { + final ViewGroup.LayoutParams lp = view.getLayoutParams(); + if (lp instanceof MarginLayoutParams) { + final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp; + marginLayoutParams.width = w; + marginLayoutParams.height = h; + marginLayoutParams.setMargins(x, y, 0, 0); + } + } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index ebd80be5e..2850c95df 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -14,7 +14,7 @@ * the License. */ -package com.android.inputmethod.keyboard.internal; +package com.android.inputmethod.keyboard; import android.content.res.Resources; import android.content.res.TypedArray; @@ -23,7 +23,11 @@ import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.Xml; -import com.android.inputmethod.keyboard.Keyboard; +import com.android.inputmethod.keyboard.internal.KeyStyles; +import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; +import com.android.inputmethod.keyboard.internal.KeyboardParser; +import com.android.inputmethod.keyboard.internal.PopupCharactersParser; +import com.android.inputmethod.keyboard.internal.Row; import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle; import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException; import com.android.inputmethod.latin.R; @@ -97,11 +101,11 @@ public class Key { private final Keyboard mKeyboard; /** The current pressed state of this key */ - public boolean mPressed; + private boolean mPressed; /** If this is a sticky key, is its highlight on? */ - public boolean mHighlightOn; + private boolean mHighlightOn; /** Key is enabled and responds on press */ - public boolean mEnabled = true; + private boolean mEnabled = true; // keyWidth constants private static final int KEYWIDTH_FILL_RIGHT = 0; @@ -377,6 +381,18 @@ public class Key { mPressed = false; } + public void setHighlightOn(boolean highlightOn) { + mHighlightOn = highlightOn; + } + + public boolean isEnabled() { + return mEnabled; + } + + public void setEnabled(boolean enabled) { + mEnabled = enabled; + } + /** * Detects if a point falls on this key. * @param x the x-coordinate of the point diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java index 818f3f925..7add43a6d 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java @@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard; import android.util.Log; -import com.android.inputmethod.keyboard.internal.Key; - import java.util.Arrays; import java.util.List; diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 889d54bf3..20327c5b2 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -21,7 +21,6 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.util.Log; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardParser; import com.android.inputmethod.keyboard.internal.KeyboardShiftState; @@ -297,7 +296,7 @@ public class Keyboard { public boolean setShiftLocked(boolean newShiftLockState) { final Map<Key, Drawable> shiftedIcons = getShiftedIcons(); for (final Key key : getShiftKeys()) { - key.mHighlightOn = newShiftLockState; + key.setHighlightOn(newShiftLockState); key.setIcon(newShiftLockState ? shiftedIcons.get(key) : mNormalShiftIcons.get(key)); } mShiftState.setShiftLocked(newShiftLockState); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index b91134dd6..9c63c198c 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -37,6 +37,11 @@ public class KeyboardId { public static final int MODE_PHONE = 4; public static final int MODE_NUMBER = 5; + public static final int F2KEY_MODE_NONE = 0; + public static final int F2KEY_MODE_SETTINGS = 1; + public static final int F2KEY_MODE_SHORTCUT_IME = 2; + public static final int F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS = 3; + public final Locale mLocale; public final int mOrientation; public final int mWidth; @@ -44,7 +49,10 @@ public class KeyboardId { public final int mXmlId; public final boolean mNavigateAction; public final boolean mPasswordInput; + // TODO: Clean up these booleans and modes. public final boolean mHasSettingsKey; + public final int mF2KeyMode; + public final boolean mClobberSettingsKey; public final boolean mVoiceKeyEnabled; public final boolean mHasVoiceKey; public final int mImeAction; @@ -56,8 +64,9 @@ public class KeyboardId { private final int mHashCode; public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width, - int mode, EditorInfo attribute, boolean hasSettingsKey, boolean voiceKeyEnabled, - boolean hasVoiceKey, boolean enableShiftLock) { + int mode, EditorInfo attribute, boolean hasSettingsKey, int f2KeyMode, + boolean clobberSettingsKey, boolean voiceKeyEnabled, boolean hasVoiceKey, + boolean enableShiftLock) { final int inputType = (attribute != null) ? attribute.inputType : 0; final int imeOptions = (attribute != null) ? attribute.imeOptions : 0; this.mLocale = locale; @@ -72,6 +81,8 @@ public class KeyboardId { this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType) || InputTypeCompatUtils.isVisiblePasswordInputType(inputType); this.mHasSettingsKey = hasSettingsKey; + this.mF2KeyMode = f2KeyMode; + this.mClobberSettingsKey = clobberSettingsKey; this.mVoiceKeyEnabled = voiceKeyEnabled; this.mHasVoiceKey = hasVoiceKey; // We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and @@ -92,6 +103,8 @@ public class KeyboardId { mNavigateAction, mPasswordInput, hasSettingsKey, + f2KeyMode, + clobberSettingsKey, voiceKeyEnabled, hasVoiceKey, mImeAction, @@ -101,14 +114,16 @@ public class KeyboardId { public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) { return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mAttribute, - mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); + mHasSettingsKey, mF2KeyMode, mClobberSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, + mEnableShiftLock); } public KeyboardId cloneWithNewGeometry(int width) { if (mWidth == width) return this; return new KeyboardId(mXmlName, mXmlId, mLocale, mOrientation, width, mMode, mAttribute, - mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock); + mHasSettingsKey, mF2KeyMode, mClobberSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, + mEnableShiftLock); } public int getXmlId() { @@ -149,6 +164,8 @@ public class KeyboardId { && other.mNavigateAction == this.mNavigateAction && other.mPasswordInput == this.mPasswordInput && other.mHasSettingsKey == this.mHasSettingsKey + && other.mF2KeyMode == this.mF2KeyMode + && other.mClobberSettingsKey == this.mClobberSettingsKey && other.mVoiceKeyEnabled == this.mVoiceKeyEnabled && other.mHasVoiceKey == this.mHasVoiceKey && other.mImeAction == this.mImeAction @@ -162,12 +179,14 @@ public class KeyboardId { @Override public String toString() { - return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s]", + return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s%s]", mXmlName, mLocale, (mOrientation == 1 ? "port" : "land"), mWidth, modeName(mMode), EditorInfoCompatUtils.imeOptionsName(mImeAction), + f2KeyModeName(mF2KeyMode), + (mClobberSettingsKey ? " clobberSettingsKey" : ""), (mNavigateAction ? " navigateAction" : ""), (mPasswordInput ? " passwordInput" : ""), (mHasSettingsKey ? " hasSettingsKey" : ""), @@ -185,7 +204,17 @@ public class KeyboardId { case MODE_IM: return "im"; case MODE_PHONE: return "phone"; case MODE_NUMBER: return "number"; + default: return null; + } + } + + public static String f2KeyModeName(int f2KeyMode) { + switch (f2KeyMode) { + case F2KEY_MODE_NONE: return "none"; + case F2KEY_MODE_SETTINGS: return "settings"; + case F2KEY_MODE_SHORTCUT_IME: return "shortcutIme"; + case F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS: return "shortcutImeOrSettings"; + default: return null; } - return null; } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 1ad5b08eb..275e9d1fe 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -28,7 +28,6 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.keyboard.internal.ModifierKeyState; import com.android.inputmethod.keyboard.internal.ShiftKeyState; import com.android.inputmethod.latin.LatinIME; @@ -285,6 +284,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } final boolean hasSettingsKey = hasSettingsKey(attribute); + final int f2KeyMode = getF2KeyMode(mPrefs, mInputMethodService, attribute); + final boolean clobberSettingsKey = Utils.inPrivateImeOptions( + mInputMethodService.getPackageName(), LatinIME.IME_OPTION_NO_SETTINGS_KEY, + attribute); final Resources res = mInputMethodService.getResources(); final int orientation = res.getConfiguration().orientation; if (mKeyboardWidth == 0) @@ -292,7 +295,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha final Locale locale = mSubtypeSwitcher.getInputLocale(); return new KeyboardId( res.getResourceEntryName(xmlId), xmlId, locale, orientation, mKeyboardWidth, - mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock); + mode, attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, mVoiceKeyEnabled, + hasVoiceKey, enableShiftLock); } private KeyboardId makeSiblingKeyboardId(KeyboardId base, int alphabet, int phone) { @@ -806,16 +810,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } private static boolean getSettingsKeyMode(SharedPreferences prefs, Context context) { - Resources resources = context.getResources(); - final boolean showSettingsKeyOption = resources.getBoolean( + final Resources res = context.getResources(); + final boolean showSettingsKeyOption = res.getBoolean( R.bool.config_enable_show_settings_key_option); if (showSettingsKeyOption) { final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY, - resources.getString(DEFAULT_SETTINGS_KEY_MODE)); + res.getString(DEFAULT_SETTINGS_KEY_MODE)); // We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or // 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system - if (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW)) - || (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_AUTO)) + if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW)) + || (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO)) && Utils.hasMultipleEnabledIMEsOrSubtypes( (InputMethodManagerCompatWrapper.getInstance(context))))) { return true; @@ -825,4 +829,21 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha // If the show settings key option is disabled, we always try showing the settings key. return true; } + + private static int getF2KeyMode(SharedPreferences prefs, Context context, + EditorInfo attribute) { + final boolean clobberSettingsKey = Utils.inPrivateImeOptions( + context.getPackageName(), LatinIME.IME_OPTION_NO_SETTINGS_KEY, attribute); + final Resources res = context.getResources(); + final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY, + res.getString(DEFAULT_SETTINGS_KEY_MODE)); + if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO))) { + return clobberSettingsKey ? KeyboardId.F2KEY_MODE_SHORTCUT_IME + : KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS; + } else if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))) { + return clobberSettingsKey ? KeyboardId.F2KEY_MODE_NONE : KeyboardId.F2KEY_MODE_SETTINGS; + } else { // SETTINGS_KEY_MODE_ALWAYS_HIDE + return KeyboardId.F2KEY_MODE_SHORTCUT_IME; + } + } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index a6aef27e0..9dc019c61 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -41,7 +41,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; -import android.view.ViewGroup.MarginLayoutParams; import android.view.accessibility.AccessibilityEvent; import android.widget.PopupWindow; import android.widget.TextView; @@ -49,7 +48,6 @@ import android.widget.TextView; import com.android.inputmethod.accessibility.AccessibilityUtils; import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.compat.FrameLayoutCompatUtils; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.keyboard.internal.SwipeTracker; @@ -132,10 +130,10 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { // Key preview private boolean mInForeground; private TextView mPreviewText; + private Drawable mPreviewBackground; private float mPreviewTextRatio; private int mPreviewTextSize; private boolean mShowKeyPreviewPopup = true; - private int mKeyPreviewPopupDisplayedY = -1; private final int mDelayBeforePreview; private int mDelayAfterPreview; private ViewGroup mPreviewPlacer; @@ -360,6 +358,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { if (previewLayout != 0) { mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null); + mPreviewBackground = mPreviewText.getBackground(); mPreviewTextRatio = getRatio(res, R.fraction.key_preview_text_ratio); } else { mShowKeyPreviewPopup = false; @@ -745,7 +744,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { } else { paint.setColor(mKeyTextColor); } - if (key.mEnabled) { + if (key.isEnabled()) { // Set a drop shadow for the text paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor); } else { @@ -935,8 +934,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { // Dismiss key preview (in this case, slide language switcher) without any delay. mPreviewText.setVisibility(View.INVISIBLE); } - // Clear key preview display position. - mKeyPreviewPopupDisplayedY = -1; } private void addKeyPreview(TextView keyPreview) { @@ -987,6 +984,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { previewIcon != null ? previewIcon : key.getIcon()); previewText.setText(null); } + if (key.mCode == Keyboard.CODE_SPACE) { + previewText.setBackgroundColor(Color.TRANSPARENT); + } else { + previewText.setBackgroundDrawable(mPreviewBackground); + } // Set the preview background state previewText.getBackground().setState( key.mPopupCharacters != null ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET); @@ -999,15 +1001,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { getLocationInWindow(mCoordinates); final int previewX = keyDrawX - (previewWidth - keyDrawWidth) / 2 + mCoordinates[0]; final int previewY = key.mY - previewHeight + mCoordinates[1] + mPreviewOffset; - // Record key preview position to display mini-keyboard later at the same position - mKeyPreviewPopupDisplayedY = previewY; // Place the key preview. // TODO: Adjust position of key previews which touch screen edges - final MarginLayoutParams lp = (MarginLayoutParams)previewText.getLayoutParams(); - lp.width = previewWidth; - lp.height = previewHeight; - lp.setMargins(previewX, previewY, 0, 0); + FrameLayoutCompatUtils.placeViewAt( + previewText, previewX, previewY, previewWidth, previewHeight); previewText.setVisibility(VISIBLE); } @@ -1151,7 +1149,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy { mPopupWindow.setClippingEnabled(false); } mPopupMiniKeyboardPanel = popupPanel; - popupPanel.showPanel(this, parentKey, tracker, mKeyPreviewPopupDisplayedY, mPopupWindow); + popupPanel.showPanel(this, parentKey, tracker, mPopupWindow); invalidateAllKeys(); return true; diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index 0329ee2b3..00bf348f2 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -33,7 +33,6 @@ import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.keyboard.internal.SlidingLocaleDrawable; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; @@ -141,7 +140,7 @@ public class LatinKeyboard extends Keyboard { // The threshold is "key width" x 1.25 mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4; - if (mSpaceKey != null) { + if (mSpaceKey != null && mSpacePreviewIcon != null) { final int slidingIconWidth = Math.max(mSpaceKey.mWidth, (int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO)); final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight(); @@ -175,7 +174,7 @@ public class LatinKeyboard extends Keyboard { public void updateShortcutKey(boolean available, LatinKeyboardView view) { if (mShortcutKey == null) return; - mShortcutKey.mEnabled = available; + mShortcutKey.setEnabled(available); mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon); if (view != null) view.invalidateKey(mShortcutKey); diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index d25d1f098..901df6ab7 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -24,7 +24,6 @@ import android.util.Log; import android.view.MotionEvent; import com.android.inputmethod.deprecated.VoiceProxy; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.Utils; diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java index d3d3fa59f..2d6766f2d 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java @@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard; import android.content.Context; -import com.android.inputmethod.keyboard.internal.Key; - import java.util.List; public class MiniKeyboard extends Keyboard { diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java index 9170c3bd1..cc5c3bbfe 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java @@ -16,8 +16,6 @@ package com.android.inputmethod.keyboard; -import com.android.inputmethod.keyboard.internal.Key; - import java.util.List; public class MiniKeyboardKeyDetector extends KeyDetector { diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 1d70481f4..c7620f946 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -22,7 +22,6 @@ import android.util.Log; import android.view.MotionEvent; import com.android.inputmethod.keyboard.KeyboardView.UIHandler; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.latin.LatinImeLogger; @@ -150,7 +149,7 @@ public class PointerTracker { + " ignoreModifier=" + ignoreModifierKey); if (ignoreModifierKey) return false; - if (key.mEnabled) { + if (key.isEnabled()) { mListener.onPress(key.mCode, withSliding); final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged; mKeyboardLayoutHasBeenChanged = false; @@ -169,14 +168,14 @@ public class PointerTracker { + " ignoreModifier=" + ignoreModifierKey); if (ignoreModifierKey) return; - if (key.mEnabled) + if (key.isEnabled()) mListener.onCodeInput(primaryCode, keyCodes, x, y); } private void callListenerOnTextInput(Key key) { if (DEBUG_LISTENER) Log.d(TAG, "onTextInput: text=" + key.mOutputText); - if (key.mEnabled) + if (key.isEnabled()) mListener.onTextInput(key.mOutputText); } @@ -189,7 +188,7 @@ public class PointerTracker { + withSliding + " ignoreModifier=" + ignoreModifierKey); if (ignoreModifierKey) return; - if (key.mEnabled) + if (key.isEnabled()) mListener.onRelease(primaryCode, withSliding); } @@ -269,7 +268,7 @@ public class PointerTracker { private void setPressedKeyGraphics(int keyIndex) { final Key key = getKey(keyIndex); - if (key != null && key.mEnabled) { + if (key != null && key.isEnabled()) { key.onPressed(); mProxy.invalidateKey(key); } @@ -618,7 +617,7 @@ public class PointerTracker { // The modifier key, such as shift key, should not show its key preview. private boolean isKeyPreviewNotRequired(int keyIndex) { final Key key = getKey(keyIndex); - if (key == null || !key.mEnabled) + if (key == null || !key.isEnabled()) return true; // Such as spacebar sliding language switch. if (mKeyboard.needSpacebarPreview(keyIndex)) diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java index 6180f09c1..3b8c36487 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java @@ -25,7 +25,6 @@ import android.view.MotionEvent; import android.view.View; import android.widget.PopupWindow; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.latin.R; /** @@ -67,7 +66,7 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { @Override public void showPanel(KeyboardView parentKeyboardView, Key parentKey, - PointerTracker tracker, int keyPreviewY, PopupWindow window) { + PointerTracker tracker, PopupWindow window) { final View container = (View)getParent(); final MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard(); final Keyboard parentKeyboard = parentKeyboardView.getKeyboard(); diff --git a/java/src/com/android/inputmethod/keyboard/PopupPanel.java b/java/src/com/android/inputmethod/keyboard/PopupPanel.java index 48454679e..386e11f2c 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupPanel.java +++ b/java/src/com/android/inputmethod/keyboard/PopupPanel.java @@ -19,20 +19,16 @@ package com.android.inputmethod.keyboard; import android.view.MotionEvent; import android.widget.PopupWindow; -import com.android.inputmethod.keyboard.internal.Key; - public interface PopupPanel { /** * Show popup panel. * @param parentKeyboardView the parent KeyboardView that has the parent key. * @param parentKey the parent key that is the source of this popup panel * @param tracker the pointer tracker that pressesd the parent key - * @param keyPreviewY the Y-coordinate of key preview * @param window PopupWindow to be used to show this popup panel */ - // TODO: Remove keyPreviewY from argument. public void showPanel(KeyboardView parentKeyboardView, Key parentKey, - PointerTracker tracker, int keyPreviewY, PopupWindow window); + PointerTracker tracker, PopupWindow window); /** * Check if the pointer is in siding key input mode. diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index a6a07e518..33acc6907 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -16,7 +16,6 @@ package com.android.inputmethod.keyboard; -import com.android.inputmethod.keyboard.internal.Key; import com.android.inputmethod.latin.Utils; import java.util.Arrays; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java index d5b364818..a6708171f 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java @@ -26,6 +26,7 @@ import android.util.Xml; import android.view.InflateException; import com.android.inputmethod.compat.EditorInfoCompatUtils; +import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.latin.R; @@ -331,7 +332,7 @@ public class KeyboardParser { } else { Key key = new Key(mResources, row, mCurrentX, mCurrentY, parser, mKeyStyles); if (DEBUG) Log.d(TAG, String.format("<%s%s keyLabel=%s code=%d popupCharacters=%s />", - TAG_KEY, (key.mEnabled ? "" : " disabled"), key.mLabel, key.mCode, + TAG_KEY, (key.isEnabled() ? "" : " disabled"), key.mLabel, key.mCode, Arrays.toString(key.mPopupCharacters))); checkEndTag(TAG_KEY, parser); keys.add(key); @@ -487,8 +488,12 @@ public class KeyboardParser { R.styleable.Keyboard_Case_navigateAction, id.mNavigateAction); final boolean passwordInputMatched = matchBoolean(a, R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput); - final boolean settingsKeyMatched = matchBoolean(a, + final boolean hasSettingsKeyMatched = matchBoolean(a, R.styleable.Keyboard_Case_hasSettingsKey, id.mHasSettingsKey); + final boolean f2KeyModeMatched = matchInteger(a, + R.styleable.Keyboard_Case_f2KeyMode, id.mF2KeyMode); + final boolean clobberSettingsKeyMatched = matchBoolean(a, + R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey); final boolean voiceEnabledMatched = matchBoolean(a, R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled); final boolean voiceKeyMatched = matchBoolean(a, @@ -506,15 +511,19 @@ public class KeyboardParser { final boolean countryCodeMatched = matchString(a, R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry()); final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched - && settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched - && imeActionMatched && localeCodeMatched && languageCodeMatched - && countryCodeMatched; + && hasSettingsKeyMatched && f2KeyModeMatched && clobberSettingsKeyMatched + && voiceEnabledMatched && voiceKeyMatched && imeActionMatched && + localeCodeMatched && languageCodeMatched && countryCodeMatched; - if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE, + if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE, textAttr(a.getString(R.styleable.Keyboard_Case_mode), "mode"), booleanAttr(a, R.styleable.Keyboard_Case_navigateAction, "navigateAction"), booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"), booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"), + textAttr(KeyboardId.f2KeyModeName( + a.getInt(R.styleable.Keyboard_Case_f2KeyMode, -1)), "f2KeyMode"), + booleanAttr(a, R.styleable.Keyboard_Case_clobberSettingsKey, + "clobberSettingsKey"), booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"), booleanAttr(a, R.styleable.Keyboard_Case_hasVoiceKey, "hasVoiceKey"), textAttr(EditorInfoCompatUtils.imeOptionsName( diff --git a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java index 01faae61d..040c16ded 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java +++ b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java @@ -21,6 +21,7 @@ import android.content.res.Resources; import android.graphics.Paint; import android.graphics.Rect; +import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.MiniKeyboard; diff --git a/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java b/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java index df4b575f1..f8c81adfb 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java +++ b/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java @@ -58,7 +58,7 @@ public class SlidingLocaleDrawable extends Drawable { public SlidingLocaleDrawable(Context context, Drawable background, int width, int height) { mBackground = background; - Keyboard.setDefaultBounds(mBackground); + Keyboard.setDefaultBounds(background); mWidth = width; mHeight = height; final TextPaint textPaint = new TextPaint(); @@ -68,7 +68,7 @@ public class SlidingLocaleDrawable extends Drawable { textPaint.setTextAlign(Align.CENTER); textPaint.setAntiAlias(true); mTextPaint = textPaint; - mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2; + mMiddleX = (background != null) ? (mWidth - mBackground.getIntrinsicWidth()) / 2 : 0; final TypedArray a = context.obtainStyledAttributes( null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard); @@ -119,11 +119,13 @@ public class SlidingLocaleDrawable extends Drawable { canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint); canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint); - Keyboard.setDefaultBounds(lArrow); - rArrow.setBounds(width - rArrow.getIntrinsicWidth(), 0, width, - rArrow.getIntrinsicHeight()); - lArrow.draw(canvas); - rArrow.draw(canvas); + if (lArrow != null && rArrow != null) { + Keyboard.setDefaultBounds(lArrow); + rArrow.setBounds(width - rArrow.getIntrinsicWidth(), 0, width, + rArrow.getIntrinsicHeight()); + lArrow.draw(canvas); + rArrow.draw(canvas); + } } if (mBackground != null) { canvas.translate(mMiddleX, 0); diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index 09b356d65..09fd3b473 100644 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -74,6 +74,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo private ViewGroup mCandidatesPaneContainer; private View mKeyboardView; private final ArrayList<TextView> mWords = new ArrayList<TextView>(); + private final ArrayList<TextView> mInfos = new ArrayList<TextView>(); private final ArrayList<View> mDividers = new ArrayList<View>(); private final int mCandidatePadding; private final int mCandidateStripHeight; @@ -177,29 +178,32 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo mCandidatePadding = res.getDimensionPixelOffset(R.dimen.candidate_padding); mCandidateStripHeight = res.getDimensionPixelOffset(R.dimen.candidate_strip_height); for (int i = 0; i < MAX_SUGGESTIONS; i++) { - final TextView tv; + final TextView word, info; switch (i) { case 0: - tv = (TextView)findViewById(R.id.candidate_left); - tv.setPadding(mCandidatePadding, 0, 0, 0); + word = (TextView)findViewById(R.id.word_left); + word.setPadding(mCandidatePadding, 0, 0, 0); + info = (TextView)findViewById(R.id.info_left); break; case 1: - tv = (TextView)findViewById(R.id.candidate_center); + word = (TextView)findViewById(R.id.word_center); + info = (TextView)findViewById(R.id.info_center); break; case 2: - tv = (TextView)findViewById(R.id.candidate_right); + word = (TextView)findViewById(R.id.word_right); + info = (TextView)findViewById(R.id.info_right); break; default: - tv = (TextView)inflater.inflate(R.layout.candidate, null); + word = (TextView)inflater.inflate(R.layout.candidate_word, null); + info = (TextView)inflater.inflate(R.layout.candidate_info, null); break; } - if (i < NUM_CANDIDATES_IN_STRIP) - setLayoutWeight(tv, 1.0f); - tv.setTag(i); - tv.setOnClickListener(this); + word.setTag(i); + word.setOnClickListener(this); if (i == 0) - tv.setOnLongClickListener(this); - mWords.add(tv); + word.setOnLongClickListener(this); + mWords.add(word); + mInfos.add(info); if (i > 0) { final View divider = inflater.inflate(R.layout.candidate_divider, null); divider.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC); @@ -263,15 +267,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo } } - private static void setLayoutWeight(View v, float weight) { - ViewGroup.LayoutParams lp = v.getLayoutParams(); - if (lp instanceof LinearLayout.LayoutParams) { - LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp; - llp.width = 0; - llp.weight = weight; - } - } - private CharSequence getStyledCandidateWord(CharSequence word, boolean isAutoCorrect) { if (!isAutoCorrect) return word; @@ -308,6 +303,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo clear(); final int paneWidth = getWidth(); final int dividerWidth = mDividers.get(0).getMeasuredWidth(); + final int dividerHeight = mDividers.get(0).getMeasuredHeight(); int x = 0; int y = 0; int fromIndex = NUM_CANDIDATES_IN_STRIP; @@ -315,10 +311,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo closeCandidatesPane(); mExpandCandidatesPane.setEnabled(count >= NUM_CANDIDATES_IN_STRIP); for (int i = 0; i < count; i++) { - final CharSequence word = suggestions.getWord(i); - if (word == null) continue; + final CharSequence suggestion = suggestions.getWord(i); + if (suggestion == null) continue; - final SuggestedWordInfo info = (suggestedWordInfoList != null) + final SuggestedWordInfo suggestionInfo = (suggestedWordInfoList != null) ? suggestedWordInfoList.get(i) : null; final boolean isAutoCorrect = suggestions.mHasMinimalSuggestion && ((i == 1 && !suggestions.mTypedWordValid) @@ -327,18 +323,37 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo // and there are multiple suggestions, such as the default punctuation list. // TODO: Need to revisit this logic with bigram suggestions final boolean isSuggestedCandidate = (i != 0); - final boolean isPunctuationSuggestions = (word.length() == 1 && count > 1); + final boolean isPunctuationSuggestions = (suggestion.length() == 1 && count > 1); - final TextView tv = mWords.get(i); + final TextView word = mWords.get(i); // TODO: Reorder candidates in strip as appropriate. The center candidate should hold // the word when space is typed (valid typed word or auto corrected word). - tv.setTextColor(getCandidateTextColor(isAutoCorrect, - isSuggestedCandidate || isPunctuationSuggestions, info)); - tv.setText(getStyledCandidateWord(word, isAutoCorrect)); + word.setTextColor(getCandidateTextColor(isAutoCorrect, + isSuggestedCandidate || isPunctuationSuggestions, suggestionInfo)); + word.setText(getStyledCandidateWord(suggestion, isAutoCorrect)); // TODO: call TextView.setTextScaleX() to fit the candidate in single line. - if (i >= NUM_CANDIDATES_IN_STRIP) { - tv.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC); - final int width = tv.getMeasuredWidth(); + word.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC); + final int width = word.getMeasuredWidth(); + final int height = word.getMeasuredHeight(); + + final TextView info; + if (DBG && suggestionInfo != null + && !TextUtils.isEmpty(suggestionInfo.getDebugString())) { + info = mInfos.get(i); + info.setText(suggestionInfo.getDebugString()); + info.setVisibility(View.VISIBLE); + info.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC); + } else { + info = null; + } + + if (i < NUM_CANDIDATES_IN_STRIP) { + if (info != null) { + final int infoWidth = info.getMeasuredWidth(); + FrameLayoutCompatUtils.placeViewAt( + info, x + width - infoWidth, y, infoWidth, info.getMeasuredHeight()); + } + } else { // TODO: Handle overflow case. if (dividerWidth + x + width >= paneWidth) { centeringCandidates(fromIndex, i - 1, x, paneWidth); @@ -348,23 +363,23 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo } if (x != 0) { final View divider = mDividers.get(i - NUM_CANDIDATES_IN_STRIP); - addCandidateAt(divider, x, y); + mCandidatesPane.addView(divider); + FrameLayoutCompatUtils.placeViewAt( + divider, x, y + (mCandidateStripHeight - dividerHeight) / 2, + dividerWidth, dividerHeight); x += dividerWidth; } - addCandidateAt(tv, x, y); + mCandidatesPane.addView(word); + FrameLayoutCompatUtils.placeViewAt( + word, x, y + (mCandidateStripHeight - height) / 2, width, height); + if (info != null) { + mCandidatesPane.addView(info); + final int infoWidth = info.getMeasuredWidth(); + FrameLayoutCompatUtils.placeViewAt( + info, x + width - infoWidth, y, infoWidth, info.getMeasuredHeight()); + } x += width; } - - if (DBG && info != null) { - final TextView dv = new TextView(getContext(), null); - dv.setTextSize(10.0f); - dv.setTextColor(0xff808080); - dv.setText(info.getDebugString()); - // TODO: debug view for candidate strip needed. -// mCandidatesPane.addView(dv); -// LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)dv.getLayoutParams(); -// lp.gravity = Gravity.BOTTOM; - } } if (x != 0) { // Centering last candidates row. @@ -372,19 +387,15 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo } } - private void addCandidateAt(View v, int x, int y) { - final int width = v.getMeasuredWidth(); - final int height = v.getMeasuredHeight(); - final MarginLayoutParams marginLayoutParams = FrameLayoutCompatUtils.newLayoutParam( - mCandidatesPane, width, height); - marginLayoutParams.setMargins(x, y + (mCandidateStripHeight - height) / 2, 0, 0); - mCandidatesPane.addView(v, marginLayoutParams); - } - private void centeringCandidates(int from, int to, int width, int paneWidth) { final ViewGroup pane = mCandidatesPane; final int fromIndex = pane.indexOfChild(mWords.get(from)); - final int toIndex = pane.indexOfChild(mWords.get(to)); + final int toIndex; + if (mInfos.get(to).getParent() != null) { + toIndex = pane.indexOfChild(mInfos.get(to)); + } else { + toIndex = pane.indexOfChild(mWords.get(to)); + } final int offset = (paneWidth - width) / 2; for (int index = fromIndex; index <= toIndex; index++) { offsetMargin(pane.getChildAt(index), offset, 0); @@ -394,9 +405,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo private static void offsetMargin(View v, int dx, int dy) { if (v == null) return; - ViewGroup.LayoutParams lp = v.getLayoutParams(); + final ViewGroup.LayoutParams lp = v.getLayoutParams(); if (lp instanceof ViewGroup.MarginLayoutParams) { - ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp; + final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp; mlp.setMargins(mlp.leftMargin + dx, mlp.topMargin + dy, 0, 0); } } @@ -458,8 +469,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo public void clear() { mShowingAddToDictionary = false; mShowingAutoCorrectionInverted = false; - for (int i = 0; i < NUM_CANDIDATES_IN_STRIP; i++) + for (int i = 0; i < NUM_CANDIDATES_IN_STRIP; i++) { mWords.get(i).setText(null); + mInfos.get(i).setVisibility(View.GONE); + } mCandidatesPane.removeAllViews(); } diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 3ad2a5965..6c515c845 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -25,6 +25,7 @@ import com.android.inputmethod.compat.VibratorCompatWrapper; import android.app.AlertDialog; import android.app.Dialog; import android.app.backup.BackupManager; +import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -65,6 +66,7 @@ public class Settings extends PreferenceActivity public static final String PREF_SELECTED_LANGUAGES = "selected_languages"; public static final String PREF_SUBTYPES = "subtype_settings"; + public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key"; public static final String PREF_CORRECTION_SETTINGS_KEY = "correction_settings"; public static final String PREF_QUICK_FIXES = "quick_fixes"; public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting"; @@ -424,6 +426,15 @@ public class Settings extends PreferenceActivity } mKeyPreviewPopupDismissDelay.setEnabled( Settings.Values.isKeyPreviewPopupEnabled(prefs, res)); + + final PreferenceScreen dictionaryLink = + (PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY); + final Intent intent = dictionaryLink.getIntent(); + + final int number = getPackageManager().queryIntentActivities(intent, 0).size(); + if (0 >= number) { + textCorrectionGroup.removePreference(dictionaryLink); + } } @Override |