Rename CandidateView to SuggestionsView
Change-Id: I6480cdf025f065130e1969899b259a243e7a11be
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2010, The Android Open Source Project
|
** Copyright 2011, The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
||||||
@ -23,5 +23,5 @@
|
|||||||
>
|
>
|
||||||
<item
|
<item
|
||||||
android:state_pressed="true"
|
android:state_pressed="true"
|
||||||
android:drawable="@drawable/btn_candidate_pressed" />
|
android:drawable="@drawable/btn_suggestion_pressed" />
|
||||||
</selector>
|
</selector>
|
@ -25,55 +25,34 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
>
|
>
|
||||||
<!-- On tablets, the candidate strip is centered with horizontal paddings on both sides because
|
<!-- On tablets, the suggestions strip is centered with horizontal paddings on both sides
|
||||||
width of the landscape mode is too long for the candidate strip. This LinearLayout is
|
because width of the landscape mode is too long for the suggestions strip. This
|
||||||
required to hold the paddings. -->
|
LinearLayout is required to hold the paddings. -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/candidates_container"
|
android:id="@+id/suggestions_container"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="@dimen/candidate_strip_minimum_height"
|
android:minHeight="@dimen/suggestions_strip_minimum_height"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
android:layout_width="@dimen/candidate_strip_padding"
|
android:layout_width="@dimen/suggestions_strip_padding"
|
||||||
android:layout_height="@dimen/candidate_strip_height"
|
android:layout_height="@dimen/suggestions_strip_height"
|
||||||
style="?attr/suggestionsStripBackgroundStyle" />
|
style="?attr/suggestionsStripBackgroundStyle" />
|
||||||
<com.android.inputmethod.latin.CandidateView
|
<com.android.inputmethod.latin.SuggestionsView
|
||||||
android:id="@+id/candidates"
|
android:id="@+id/suggestions_view"
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="@dimen/candidate_strip_height"
|
android:layout_height="@dimen/suggestions_strip_height"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
style="?attr/candidateViewStyle" />
|
style="?attr/suggestionsViewStyle" />
|
||||||
<View
|
<View
|
||||||
android:layout_width="@dimen/candidate_strip_padding"
|
android:layout_width="@dimen/suggestions_strip_padding"
|
||||||
android:layout_height="@dimen/candidate_strip_height"
|
android:layout_height="@dimen/suggestions_strip_height"
|
||||||
style="?attr/suggestionsStripBackgroundStyle" />
|
style="?attr/suggestionsStripBackgroundStyle" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/candidates_pane_container"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"
|
|
||||||
style="?attr/suggestionsStripBackgroundStyle"
|
|
||||||
>
|
|
||||||
<View
|
|
||||||
android:layout_width="@dimen/candidate_strip_padding"
|
|
||||||
android:layout_height="@dimen/candidate_strip_height" />
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/candidates_pane"
|
|
||||||
android:layout_weight="1.0"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
<View
|
|
||||||
android:layout_width="@dimen/candidate_strip_padding"
|
|
||||||
android:layout_height="@dimen/candidate_strip_height" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<com.android.inputmethod.keyboard.LatinKeyboardView
|
<com.android.inputmethod.keyboard.LatinKeyboardView
|
||||||
android:id="@+id/keyboard_view"
|
android:id="@+id/keyboard_view"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
latin:keyLabelSize="@dimen/candidate_text_size"
|
latin:keyLabelSize="@dimen/suggestion_text_size"
|
||||||
latin:keyHintLetterRatio="@fraction/more_suggestions_info_ratio"
|
latin:keyHintLetterRatio="@fraction/more_suggestions_info_ratio"
|
||||||
latin:keyHintLetterColor="@android:color/white"
|
latin:keyHintLetterColor="@android:color/white"
|
||||||
/>
|
/>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2010, The Android Open Source Project
|
** Copyright 2011, The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
@ -1,19 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2008, The Android Open Source Project
|
** Copyright 2011, The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
||||||
** You may obtain a copy of the License at
|
** You may obtain a copy of the License at
|
||||||
**
|
**
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
**
|
**
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
** See the License for the specific language governing permissions and
|
** See the License for the specific language governing permissions and
|
||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
-->
|
-->
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2010, The Android Open Source Project
|
** Copyright 2011, The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
||||||
@ -22,12 +22,12 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:minWidth="@dimen/candidate_min_width"
|
android:minWidth="@dimen/suggestion_min_width"
|
||||||
android:textSize="@dimen/candidate_text_size"
|
android:textSize="@dimen/suggestion_text_size"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:paddingLeft="@dimen/candidate_padding"
|
android:paddingLeft="@dimen/suggestion_padding"
|
||||||
android:paddingTop="0dp"
|
android:paddingTop="0dp"
|
||||||
android:paddingRight="@dimen/candidate_padding"
|
android:paddingRight="@dimen/suggestion_padding"
|
||||||
android:paddingBottom="0dp"
|
android:paddingBottom="0dp"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
@ -24,12 +24,12 @@
|
|||||||
>
|
>
|
||||||
<!-- Placer for debug information -->
|
<!-- Placer for debug information -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/candidates_placer"
|
android:id="@+id/suggestions_placer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
>
|
>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/candidates_strip"
|
android:id="@+id/suggestions_strip"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
@ -58,10 +58,9 @@
|
|||||||
|
|
||||||
<dimen name="key_preview_offset_ics">0.01in</dimen>
|
<dimen name="key_preview_offset_ics">0.01in</dimen>
|
||||||
|
|
||||||
<dimen name="candidate_strip_height">36dip</dimen>
|
<dimen name="suggestions_strip_height">36dip</dimen>
|
||||||
<dimen name="more_suggestions_row_height">36dip</dimen>
|
<dimen name="more_suggestions_row_height">36dip</dimen>
|
||||||
<dimen name="candidate_strip_minimum_height">160sp</dimen>
|
<dimen name="suggestions_strip_minimum_height">160sp</dimen>
|
||||||
<dimen name="candidate_strip_fading_edge_length">63dip</dimen>
|
|
||||||
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
|
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
|
||||||
<!-- popup_key_height x 1.2 -->
|
<!-- popup_key_height x 1.2 -->
|
||||||
<dimen name="mini_keyboard_slide_allowance">0.336in</dimen>
|
<dimen name="mini_keyboard_slide_allowance">0.336in</dimen>
|
||||||
|
@ -50,5 +50,5 @@
|
|||||||
<fraction name="key_hint_label_ratio">34%</fraction>
|
<fraction name="key_hint_label_ratio">34%</fraction>
|
||||||
<fraction name="key_uppercase_letter_ratio">29%</fraction>
|
<fraction name="key_uppercase_letter_ratio">29%</fraction>
|
||||||
|
|
||||||
<dimen name="candidate_strip_padding">40.0mm</dimen>
|
<dimen name="suggestions_strip_padding">40.0mm</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -66,10 +66,10 @@
|
|||||||
<dimen name="key_preview_height_ics">15.0mm</dimen>
|
<dimen name="key_preview_height_ics">15.0mm</dimen>
|
||||||
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
||||||
|
|
||||||
<dimen name="candidate_strip_height">44dip</dimen>
|
<dimen name="suggestions_strip_height">44dip</dimen>
|
||||||
<dimen name="more_suggestions_row_height">44dip</dimen>
|
<dimen name="more_suggestions_row_height">44dip</dimen>
|
||||||
<dimen name="candidate_strip_padding">15.0mm</dimen>
|
<dimen name="suggestions_strip_padding">15.0mm</dimen>
|
||||||
<dimen name="candidate_min_width">0.3in</dimen>
|
<dimen name="suggestion_min_width">0.3in</dimen>
|
||||||
<dimen name="candidate_padding">12dip</dimen>
|
<dimen name="suggestion_padding">12dip</dimen>
|
||||||
<dimen name="candidate_text_size">22dip</dimen>
|
<dimen name="suggestion_text_size">22dip</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -58,5 +58,5 @@
|
|||||||
<dimen name="key_preview_height_ics">26.5mm</dimen>
|
<dimen name="key_preview_height_ics">26.5mm</dimen>
|
||||||
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
||||||
|
|
||||||
<dimen name="candidate_strip_padding">40.0mm</dimen>
|
<dimen name="suggestions_strip_padding">40.0mm</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -69,11 +69,11 @@
|
|||||||
<dimen name="key_preview_height_ics">15.0mm</dimen>
|
<dimen name="key_preview_height_ics">15.0mm</dimen>
|
||||||
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
||||||
|
|
||||||
<dimen name="candidate_strip_height">44dip</dimen>
|
<dimen name="suggestions_strip_height">44dip</dimen>
|
||||||
<dimen name="more_suggestions_row_height">44dip</dimen>
|
<dimen name="more_suggestions_row_height">44dip</dimen>
|
||||||
<dimen name="candidate_strip_minimum_height">200sp</dimen>
|
<dimen name="suggestions_strip_minimum_height">200sp</dimen>
|
||||||
<dimen name="candidate_strip_padding">15.0mm</dimen>
|
<dimen name="suggestions_strip_padding">15.0mm</dimen>
|
||||||
<dimen name="candidate_min_width">46dip</dimen>
|
<dimen name="suggestion_min_width">46dip</dimen>
|
||||||
<dimen name="candidate_padding">8dip</dimen>
|
<dimen name="suggestion_padding">8dip</dimen>
|
||||||
<dimen name="candidate_text_size">22dip</dimen>
|
<dimen name="suggestion_text_size">22dip</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<attr name="suggestionsPaneViewStyle" format="reference" />
|
<attr name="suggestionsPaneViewStyle" format="reference" />
|
||||||
<attr name="suggestionBackgroundStyle" format="reference" />
|
<attr name="suggestionBackgroundStyle" format="reference" />
|
||||||
<attr name="suggestionPreviewBackgroundStyle" format="reference" />
|
<attr name="suggestionPreviewBackgroundStyle" format="reference" />
|
||||||
<attr name="candidateViewStyle" format="reference" />
|
<attr name="suggestionsViewStyle" format="reference" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="KeyboardView">
|
<declare-styleable name="KeyboardView">
|
||||||
@ -112,7 +112,7 @@
|
|||||||
</attr>
|
</attr>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="CandidateView">
|
<declare-styleable name="SuggestionsView">
|
||||||
<attr name="suggestionStripOption" format="integer">
|
<attr name="suggestionStripOption" format="integer">
|
||||||
<flag name="autoCorrectBold" value="0x01" />
|
<flag name="autoCorrectBold" value="0x01" />
|
||||||
<flag name="autoCorrectUnderline" value="0x02" />
|
<flag name="autoCorrectUnderline" value="0x02" />
|
||||||
@ -122,8 +122,8 @@
|
|||||||
<attr name="colorTypedWord" format="color" />
|
<attr name="colorTypedWord" format="color" />
|
||||||
<attr name="colorAutoCorrect" format="color" />
|
<attr name="colorAutoCorrect" format="color" />
|
||||||
<attr name="colorSuggested" format="color" />
|
<attr name="colorSuggested" format="color" />
|
||||||
<attr name="candidateCountInStrip" format="integer" />
|
<attr name="suggestionsCountInStrip" format="integer" />
|
||||||
<attr name="centerCandidatePercentile" format="integer" />
|
<attr name="centerSuggestionPercentile" format="integer" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="Keyboard">
|
<declare-styleable name="Keyboard">
|
||||||
|
@ -30,11 +30,11 @@
|
|||||||
<bool name="config_digit_more_keys_enabled">true</bool>
|
<bool name="config_digit_more_keys_enabled">true</bool>
|
||||||
<!-- Whether or not Popup on key press is enabled by default -->
|
<!-- Whether or not Popup on key press is enabled by default -->
|
||||||
<bool name="config_default_popup_preview">true</bool>
|
<bool name="config_default_popup_preview">true</bool>
|
||||||
<!-- Default value for bigram suggestion: while showing candidates for a word should we weigh
|
<!-- Default value for bigram suggestion: while showing suggestions for a word should we weigh
|
||||||
in the previous word? -->
|
in the previous word? -->
|
||||||
<bool name="config_default_bigram_suggestions">true</bool>
|
<bool name="config_default_bigram_suggestions">true</bool>
|
||||||
<!-- Default value for bigram prediction: after entering a word and a space only, should we look
|
<!-- Default value for bigram prediction: after entering a word and a space only, should we look
|
||||||
at input history to suggest a hopefully helpful candidate for the next word? -->
|
at input history to suggest a hopefully helpful suggestions for the next word? -->
|
||||||
<bool name="config_default_bigram_prediction">false</bool>
|
<bool name="config_default_bigram_prediction">false</bool>
|
||||||
<bool name="config_default_compat_recorrection_enabled">true</bool>
|
<bool name="config_default_compat_recorrection_enabled">true</bool>
|
||||||
<bool name="config_default_sound_enabled">false</bool>
|
<bool name="config_default_sound_enabled">false</bool>
|
||||||
|
@ -76,19 +76,18 @@
|
|||||||
<dimen name="key_preview_height_ics">80sp</dimen>
|
<dimen name="key_preview_height_ics">80sp</dimen>
|
||||||
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
||||||
|
|
||||||
<dimen name="candidate_strip_height">40dip</dimen>
|
<dimen name="suggestions_strip_height">40dip</dimen>
|
||||||
<dimen name="more_suggestions_key_horizontal_padding">12dip</dimen>
|
<dimen name="more_suggestions_key_horizontal_padding">12dip</dimen>
|
||||||
<dimen name="more_suggestions_row_height">40dip</dimen>
|
<dimen name="more_suggestions_row_height">40dip</dimen>
|
||||||
<dimen name="more_suggestions_slide_allowance">0.2in</dimen>
|
<dimen name="more_suggestions_slide_allowance">0.2in</dimen>
|
||||||
<fraction name="more_suggestions_info_ratio">12%</fraction>
|
<fraction name="more_suggestions_info_ratio">12%</fraction>
|
||||||
<dimen name="candidate_strip_minimum_height">200sp</dimen>
|
<dimen name="suggestions_strip_minimum_height">200sp</dimen>
|
||||||
<dimen name="candidate_strip_fading_edge_length">63dip</dimen>
|
<dimen name="suggestions_strip_padding">0dip</dimen>
|
||||||
<dimen name="candidate_strip_padding">0dip</dimen>
|
<dimen name="suggestion_min_width">44dip</dimen>
|
||||||
<dimen name="candidate_min_width">44dip</dimen>
|
<dimen name="suggestion_padding">6dip</dimen>
|
||||||
<dimen name="candidate_padding">6dip</dimen>
|
<dimen name="suggestion_text_size">18dip</dimen>
|
||||||
<dimen name="candidate_text_size">18dip</dimen>
|
<integer name="suggestions_count_in_strip">3</integer>
|
||||||
<integer name="candidate_count_in_strip">3</integer>
|
<integer name="center_suggestion_percentile">36</integer>
|
||||||
<integer name="center_candidate_percentile">36</integer>
|
|
||||||
|
|
||||||
<!-- If the screen height in landscape is larger than the below value, then the keyboard
|
<!-- If the screen height in landscape is larger than the below value, then the keyboard
|
||||||
will not go into extract (fullscreen) mode. -->
|
will not go into extract (fullscreen) mode. -->
|
||||||
|
@ -44,13 +44,6 @@
|
|||||||
<!-- Label for "switch to phone symbols" key. Must be short to fit on key! -->
|
<!-- Label for "switch to phone symbols" key. Must be short to fit on key! -->
|
||||||
<string name="label_to_phone_symbols_key">\uff0a\uff03</string>
|
<string name="label_to_phone_symbols_key">\uff0a\uff03</string>
|
||||||
|
|
||||||
<!-- Character for candidate divider (BOX DRAWINGS LIGHT VERTICAL) -->
|
|
||||||
<string name="label_candidate_divider">\u2502</string>
|
|
||||||
<!-- Character for expand candidates pane (BLACK DOWN-POINTING TRIANGLE) -->
|
|
||||||
<string name="label_expand_candidates_pane">\u25bc</string>
|
|
||||||
<!-- Character for close candidates pane (BLACK UP-POINTING TRIANGLE) -->
|
|
||||||
<string name="label_close_candidates_pane">\u25b2</string>
|
|
||||||
|
|
||||||
<!-- Always show the suggestion strip -->
|
<!-- Always show the suggestion strip -->
|
||||||
<string name="prefs_suggestion_visibility_show_value">0</string>
|
<string name="prefs_suggestion_visibility_show_value">0</string>
|
||||||
<!-- Show the suggestion strip only on portrait mode -->
|
<!-- Show the suggestion strip only on portrait mode -->
|
||||||
|
@ -99,11 +99,11 @@
|
|||||||
<string name="auto_correction_summary">Spacebar and punctuation automatically correct mistyped words</string>
|
<string name="auto_correction_summary">Spacebar and punctuation automatically correct mistyped words</string>
|
||||||
<!-- Option to disable auto correction. [CHAR LIMIT=20] -->
|
<!-- Option to disable auto correction. [CHAR LIMIT=20] -->
|
||||||
<string name="auto_correction_threshold_mode_off">Off</string>
|
<string name="auto_correction_threshold_mode_off">Off</string>
|
||||||
<!-- Option to suggest auto correction candidates modestly. Auto-corrects only to a word which has small edit distance from typed word. [CHAR LIMIT=20] -->
|
<!-- Option to suggest auto correction suggestions modestly. Auto-corrects only to a word which has small edit distance from typed word. [CHAR LIMIT=20] -->
|
||||||
<string name="auto_correction_threshold_mode_modest">Modest</string>
|
<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] -->
|
<!-- Option to suggest auto correction suggestions 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>
|
<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] -->
|
<!-- Option to suggest auto correction suggestions 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>
|
<string name="auto_correction_threshold_mode_very_aggeressive">Very aggressive</string>
|
||||||
|
|
||||||
<!-- Option to enable bigram correction -->
|
<!-- Option to enable bigram correction -->
|
||||||
|
@ -88,21 +88,21 @@
|
|||||||
<item name="android:background">@drawable/keyboard_suggest_strip</item>
|
<item name="android:background">@drawable/keyboard_suggest_strip</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="SuggestionBackgroundStyle">
|
<style name="SuggestionBackgroundStyle">
|
||||||
<item name="android:background">@drawable/btn_candidate</item>
|
<item name="android:background">@drawable/btn_suggestion</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="SuggestionPreviewBackgroundStyle">
|
<style name="SuggestionPreviewBackgroundStyle">
|
||||||
<item name="android:background">@drawable/candidate_feedback_background</item>
|
<item name="android:background">@drawable/suggestion_feedback_background</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="CandidateViewStyle"
|
name="SuggestionsViewStyle"
|
||||||
parent="SuggestionsStripBackgroundStyle"
|
parent="SuggestionsStripBackgroundStyle"
|
||||||
>
|
>
|
||||||
<item name="suggestionStripOption">autoCorrectBold</item>
|
<item name="suggestionStripOption">autoCorrectBold</item>
|
||||||
<item name="colorTypedWord">#FFFFFFFF</item>
|
<item name="colorTypedWord">#FFFFFFFF</item>
|
||||||
<item name="colorAutoCorrect">#FFFCAE00</item>
|
<item name="colorAutoCorrect">#FFFCAE00</item>
|
||||||
<item name="colorSuggested">#FFFCAE00</item>
|
<item name="colorSuggested">#FFFCAE00</item>
|
||||||
<item name="candidateCountInStrip">@integer/candidate_count_in_strip</item>
|
<item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item>
|
||||||
<item name="centerCandidatePercentile">@integer/center_candidate_percentile</item>
|
<item name="centerSuggestionPercentile">@integer/center_suggestion_percentile</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Theme "Basic high contrast" -->
|
<!-- Theme "Basic high contrast" -->
|
||||||
<style
|
<style
|
||||||
@ -233,7 +233,7 @@
|
|||||||
<item name="android:background">@drawable/keyboard_suggest_strip_holo</item>
|
<item name="android:background">@drawable/keyboard_suggest_strip_holo</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="SuggestionBackgroundStyle.IceCreamSandwich">
|
<style name="SuggestionBackgroundStyle.IceCreamSandwich">
|
||||||
<item name="android:background">@drawable/btn_candidate_ics</item>
|
<item name="android:background">@drawable/btn_suggestion_ics</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="SuggestionPreviewBackgroundStyle.IceCreamSandwich"
|
name="SuggestionPreviewBackgroundStyle.IceCreamSandwich"
|
||||||
@ -246,15 +246,15 @@
|
|||||||
>
|
>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
name="CandidateViewStyle.IceCreamSandwich"
|
name="SuggestionsViewStyle.IceCreamSandwich"
|
||||||
parent="SuggestionsStripBackgroundStyle.IceCreamSandwich"
|
parent="SuggestionsStripBackgroundStyle.IceCreamSandwich"
|
||||||
>
|
>
|
||||||
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
|
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
|
||||||
<item name="colorTypedWord">#FFBCBEC0</item>
|
<item name="colorTypedWord">#FFBCBEC0</item>
|
||||||
<item name="colorAutoCorrect">#FF0099CC</item>
|
<item name="colorAutoCorrect">#FF0099CC</item>
|
||||||
<item name="colorSuggested">#FFA7A9AC</item>
|
<item name="colorSuggested">#FFA7A9AC</item>
|
||||||
<item name="candidateCountInStrip">@integer/candidate_count_in_strip</item>
|
<item name="suggestionsCountInStrip">@integer/suggestions_count_in_strip</item>
|
||||||
<item name="centerCandidatePercentile">@integer/center_candidate_percentile</item>
|
<item name="centerSuggestionPercentile">@integer/center_suggestion_percentile</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="MiniKeyboardAnimation">
|
<style name="MiniKeyboardAnimation">
|
||||||
<item name="android:windowEnterAnimation">@anim/mini_keyboard_fadein</item>
|
<item name="android:windowEnterAnimation">@anim/mini_keyboard_fadein</item>
|
||||||
|
@ -25,6 +25,6 @@
|
|||||||
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
||||||
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
||||||
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
||||||
<item name="candidateViewStyle">@style/CandidateViewStyle</item>
|
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -25,6 +25,6 @@
|
|||||||
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
||||||
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
||||||
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
||||||
<item name="candidateViewStyle">@style/CandidateViewStyle</item>
|
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -25,6 +25,6 @@
|
|||||||
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
||||||
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
||||||
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
||||||
<item name="candidateViewStyle">@style/CandidateViewStyle</item>
|
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -25,6 +25,6 @@
|
|||||||
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle.IceCreamSandwich</item>
|
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle.IceCreamSandwich</item>
|
||||||
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item>
|
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item>
|
||||||
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle.IceCreamSandwich</item>
|
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle.IceCreamSandwich</item>
|
||||||
<item name="candidateViewStyle">@style/CandidateViewStyle.IceCreamSandwich</item>
|
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle.IceCreamSandwich</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -25,6 +25,6 @@
|
|||||||
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
||||||
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
||||||
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
||||||
<item name="candidateViewStyle">@style/CandidateViewStyle</item>
|
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -25,6 +25,6 @@
|
|||||||
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
<item name="suggestionsPaneViewStyle">@style/SuggestionsPaneViewStyle</item>
|
||||||
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
|
||||||
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>
|
||||||
<item name="candidateViewStyle">@style/CandidateViewStyle</item>
|
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -16,21 +16,6 @@
|
|||||||
|
|
||||||
package com.android.inputmethod.deprecated.recorrection;
|
package com.android.inputmethod.deprecated.recorrection;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.InputConnectionCompatUtils;
|
|
||||||
import com.android.inputmethod.compat.SuggestionSpanUtils;
|
|
||||||
import com.android.inputmethod.deprecated.VoiceProxy;
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
|
||||||
import com.android.inputmethod.latin.AutoCorrection;
|
|
||||||
import com.android.inputmethod.latin.CandidateView;
|
|
||||||
import com.android.inputmethod.latin.EditingUtils;
|
|
||||||
import com.android.inputmethod.latin.LatinIME;
|
|
||||||
import com.android.inputmethod.latin.R;
|
|
||||||
import com.android.inputmethod.latin.Settings;
|
|
||||||
import com.android.inputmethod.latin.Suggest;
|
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
|
||||||
import com.android.inputmethod.latin.TextEntryState;
|
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -38,6 +23,21 @@ import android.view.inputmethod.ExtractedText;
|
|||||||
import android.view.inputmethod.ExtractedTextRequest;
|
import android.view.inputmethod.ExtractedTextRequest;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
|
|
||||||
|
import com.android.inputmethod.compat.InputConnectionCompatUtils;
|
||||||
|
import com.android.inputmethod.compat.SuggestionSpanUtils;
|
||||||
|
import com.android.inputmethod.deprecated.VoiceProxy;
|
||||||
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
|
import com.android.inputmethod.latin.AutoCorrection;
|
||||||
|
import com.android.inputmethod.latin.EditingUtils;
|
||||||
|
import com.android.inputmethod.latin.LatinIME;
|
||||||
|
import com.android.inputmethod.latin.R;
|
||||||
|
import com.android.inputmethod.latin.Settings;
|
||||||
|
import com.android.inputmethod.latin.Suggest;
|
||||||
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
|
import com.android.inputmethod.latin.SuggestionsView;
|
||||||
|
import com.android.inputmethod.latin.TextEntryState;
|
||||||
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +107,7 @@ public class Recorrection implements SharedPreferences.OnSharedPreferenceChangeL
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateRecorrectionSelection(KeyboardSwitcher keyboardSwitcher,
|
public void updateRecorrectionSelection(KeyboardSwitcher keyboardSwitcher,
|
||||||
CandidateView candidateView, int candidatesStart, int candidatesEnd,
|
SuggestionsView suggestionsView, int candidatesStart, int candidatesEnd,
|
||||||
int newSelStart, int newSelEnd, int oldSelStart, int lastSelectionStart,
|
int newSelStart, int newSelEnd, int oldSelStart, int lastSelectionStart,
|
||||||
int lastSelectionEnd, boolean hasUncommittedTypedChars) {
|
int lastSelectionEnd, boolean hasUncommittedTypedChars) {
|
||||||
if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED || !mRecorrectionEnabled) return;
|
if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED || !mRecorrectionEnabled) return;
|
||||||
@ -127,7 +127,7 @@ public class Recorrection implements SharedPreferences.OnSharedPreferenceChangeL
|
|||||||
// If showing the "touch again to save" hint, do not replace it. Else,
|
// If showing the "touch again to save" hint, do not replace it. Else,
|
||||||
// show the bigrams if we are at the end of the text, punctuation
|
// show the bigrams if we are at the end of the text, punctuation
|
||||||
// otherwise.
|
// otherwise.
|
||||||
if (candidateView != null && !candidateView.isShowingAddToDictionaryHint()) {
|
if (suggestionsView != null && !suggestionsView.isShowingAddToDictionaryHint()) {
|
||||||
InputConnection ic = mService.getCurrentInputConnection();
|
InputConnection ic = mService.getCurrentInputConnection();
|
||||||
if (null == ic || !TextUtils.isEmpty(ic.getTextAfterCursor(1, 0))) {
|
if (null == ic || !TextUtils.isEmpty(ic.getTextAfterCursor(1, 0))) {
|
||||||
if (!mService.isShowingPunctuationList()) {
|
if (!mService.isShowingPunctuationList()) {
|
||||||
@ -219,13 +219,13 @@ public class Recorrection implements SharedPreferences.OnSharedPreferenceChangeL
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fetchAndDisplayRecorrectionSuggestions(VoiceProxy voiceProxy,
|
public void fetchAndDisplayRecorrectionSuggestions(VoiceProxy voiceProxy,
|
||||||
CandidateView candidateView, Suggest suggest, KeyboardSwitcher keyboardSwitcher,
|
SuggestionsView suggestionsView, Suggest suggest, KeyboardSwitcher keyboardSwitcher,
|
||||||
WordComposer word, boolean hasUncommittedTypedChars, int lastSelectionStart,
|
WordComposer word, boolean hasUncommittedTypedChars, int lastSelectionStart,
|
||||||
int lastSelectionEnd, String wordSeparators) {
|
int lastSelectionEnd, String wordSeparators) {
|
||||||
if (!InputConnectionCompatUtils.RECORRECTION_SUPPORTED) return;
|
if (!InputConnectionCompatUtils.RECORRECTION_SUPPORTED) return;
|
||||||
if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED || !mRecorrectionEnabled) return;
|
if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED || !mRecorrectionEnabled) return;
|
||||||
voiceProxy.setShowingVoiceSuggestions(false);
|
voiceProxy.setShowingVoiceSuggestions(false);
|
||||||
if (candidateView != null && candidateView.isShowingAddToDictionaryHint()) {
|
if (suggestionsView != null && suggestionsView.isShowingAddToDictionaryHint()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InputConnection ic = mService.getCurrentInputConnection();
|
InputConnection ic = mService.getCurrentInputConnection();
|
||||||
@ -260,7 +260,7 @@ public class Recorrection implements SharedPreferences.OnSharedPreferenceChangeL
|
|||||||
if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED) return;
|
if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED) return;
|
||||||
if (force || TextEntryState.isRecorrecting()) {
|
if (force || TextEntryState.isRecorrecting()) {
|
||||||
TextEntryState.onAbortRecorrection();
|
TextEntryState.onAbortRecorrection();
|
||||||
mService.setCandidatesViewShown(mService.isCandidateStripVisible());
|
mService.setCandidatesViewShown(mService.isSuggestionsStripVisible());
|
||||||
mService.getCurrentInputConnection().finishComposingText();
|
mService.getCurrentInputConnection().finishComposingText();
|
||||||
mService.clearSuggestions();
|
mService.clearSuggestions();
|
||||||
}
|
}
|
||||||
|
@ -119,15 +119,15 @@ public class AutoCorrection {
|
|||||||
if (wordComposer.size() > 1 && (correctionMode == Suggest.CORRECTION_FULL
|
if (wordComposer.size() > 1 && (correctionMode == Suggest.CORRECTION_FULL
|
||||||
|| correctionMode == Suggest.CORRECTION_FULL_BIGRAM)
|
|| correctionMode == Suggest.CORRECTION_FULL_BIGRAM)
|
||||||
&& typedWord != null && suggestions.size() > 0 && sortedScores.length > 0) {
|
&& typedWord != null && suggestions.size() > 0 && sortedScores.length > 0) {
|
||||||
final CharSequence autoCorrectionCandidate = suggestions.get(0);
|
final CharSequence autoCorrectionSuggestion = suggestions.get(0);
|
||||||
final int autoCorrectionCandidateScore = sortedScores[0];
|
final int autoCorrectionSuggestionScore = sortedScores[0];
|
||||||
// TODO: when the normalized score of the first suggestion is nearly equals to
|
// TODO: when the normalized score of the first suggestion is nearly equals to
|
||||||
// the normalized score of the second suggestion, behave less aggressive.
|
// the normalized score of the second suggestion, behave less aggressive.
|
||||||
mNormalizedScore = Utils.calcNormalizedScore(
|
mNormalizedScore = Utils.calcNormalizedScore(
|
||||||
typedWord,autoCorrectionCandidate, autoCorrectionCandidateScore);
|
typedWord,autoCorrectionSuggestion, autoCorrectionSuggestionScore);
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, "Normalized " + typedWord + "," + autoCorrectionCandidate + ","
|
Log.d(TAG, "Normalized " + typedWord + "," + autoCorrectionSuggestion + ","
|
||||||
+ autoCorrectionCandidateScore + ", " + mNormalizedScore
|
+ autoCorrectionSuggestionScore + ", " + mNormalizedScore
|
||||||
+ "(" + autoCorrectionThreshold + ")");
|
+ "(" + autoCorrectionThreshold + ")");
|
||||||
}
|
}
|
||||||
if (mNormalizedScore >= autoCorrectionThreshold) {
|
if (mNormalizedScore >= autoCorrectionThreshold) {
|
||||||
|
@ -77,7 +77,7 @@ import java.util.Locale;
|
|||||||
* Input method implementation for Qwerty'ish keyboard.
|
* Input method implementation for Qwerty'ish keyboard.
|
||||||
*/
|
*/
|
||||||
public class LatinIME extends InputMethodServiceCompatWrapper implements KeyboardActionListener,
|
public class LatinIME extends InputMethodServiceCompatWrapper implements KeyboardActionListener,
|
||||||
CandidateView.Listener {
|
SuggestionsView.Listener {
|
||||||
private static final String TAG = LatinIME.class.getSimpleName();
|
private static final String TAG = LatinIME.class.getSimpleName();
|
||||||
private static final boolean PERF_DEBUG = false;
|
private static final boolean PERF_DEBUG = false;
|
||||||
private static final boolean TRACE = false;
|
private static final boolean TRACE = false;
|
||||||
@ -157,9 +157,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
|
|
||||||
private Settings.Values mSettingsValues;
|
private Settings.Values mSettingsValues;
|
||||||
|
|
||||||
private View mCandidateViewContainer;
|
private View mSuggestionsContainer;
|
||||||
private int mCandidateStripHeight;
|
private int mSuggestionsStripHeight;
|
||||||
private CandidateView mCandidateView;
|
private SuggestionsView mSuggestionsView;
|
||||||
private Suggest mSuggest;
|
private Suggest mSuggest;
|
||||||
private CompletionInfo[] mApplicationSpecifiedCompletions;
|
private CompletionInfo[] mApplicationSpecifiedCompletions;
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
break;
|
break;
|
||||||
case MSG_UPDATE_OLD_SUGGESTIONS:
|
case MSG_UPDATE_OLD_SUGGESTIONS:
|
||||||
latinIme.mRecorrection.fetchAndDisplayRecorrectionSuggestions(
|
latinIme.mRecorrection.fetchAndDisplayRecorrectionSuggestions(
|
||||||
latinIme.mVoiceProxy, latinIme.mCandidateView,
|
latinIme.mVoiceProxy, latinIme.mSuggestionsView,
|
||||||
latinIme.mSuggest, latinIme.mKeyboardSwitcher, latinIme.mWordComposer,
|
latinIme.mSuggest, latinIme.mKeyboardSwitcher, latinIme.mWordComposer,
|
||||||
latinIme.mHasUncommittedTypedChars, latinIme.mLastSelectionStart,
|
latinIme.mHasUncommittedTypedChars, latinIme.mLastSelectionStart,
|
||||||
latinIme.mLastSelectionEnd, latinIme.mSettingsValues.mWordSeparators);
|
latinIme.mLastSelectionEnd, latinIme.mSettingsValues.mWordSeparators);
|
||||||
@ -607,11 +607,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
@Override
|
@Override
|
||||||
public void setInputView(View view) {
|
public void setInputView(View view) {
|
||||||
super.setInputView(view);
|
super.setInputView(view);
|
||||||
mCandidateViewContainer = view.findViewById(R.id.candidates_container);
|
mSuggestionsContainer = view.findViewById(R.id.suggestions_container);
|
||||||
mCandidateView = (CandidateView) view.findViewById(R.id.candidates);
|
mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view);
|
||||||
if (mCandidateView != null)
|
if (mSuggestionsView != null)
|
||||||
mCandidateView.setListener(this, view);
|
mSuggestionsView.setListener(this, view);
|
||||||
mCandidateStripHeight = (int)mResources.getDimension(R.dimen.candidate_strip_height);
|
mSuggestionsStripHeight = (int)mResources.getDimension(R.dimen.suggestions_strip_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -678,9 +678,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
switcher.loadKeyboard(attribute, mSettingsValues);
|
switcher.loadKeyboard(attribute, mSettingsValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCandidateView != null)
|
if (mSuggestionsView != null)
|
||||||
mCandidateView.clear();
|
mSuggestionsView.clear();
|
||||||
setSuggestionStripShownInternal(isCandidateStripVisible(), /* needsInputViewShown */ false);
|
setSuggestionStripShownInternal(
|
||||||
|
isSuggestionsStripVisible(), /* needsInputViewShown */ false);
|
||||||
// Delay updating suggestions because keyboard input view may not be shown at this point.
|
// Delay updating suggestions because keyboard input view may not be shown at this point.
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
|
|
||||||
@ -708,7 +709,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
|
|
||||||
if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
|
if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
|
||||||
mIsSettingsSuggestionStripOn = true;
|
mIsSettingsSuggestionStripOn = true;
|
||||||
// Make sure that passwords are not displayed in candidate view
|
// Make sure that passwords are not displayed in {@link SuggestionsView}.
|
||||||
if (InputTypeCompatUtils.isPasswordInputType(inputType)
|
if (InputTypeCompatUtils.isPasswordInputType(inputType)
|
||||||
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType)) {
|
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType)) {
|
||||||
mIsSettingsSuggestionStripOn = false;
|
mIsSettingsSuggestionStripOn = false;
|
||||||
@ -819,7 +820,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
&& (selectionChanged || candidatesCleared)) {
|
&& (selectionChanged || candidatesCleared)) {
|
||||||
if (candidatesCleared) {
|
if (candidatesCleared) {
|
||||||
// If the composing span has been cleared, save the typed word in the history for
|
// If the composing span has been cleared, save the typed word in the history for
|
||||||
// recorrection before we reset the candidate strip. Then, we'll be able to show
|
// recorrection before we reset the suggestions strip. Then, we'll be able to show
|
||||||
// suggestions for recorrection right away.
|
// suggestions for recorrection right away.
|
||||||
mRecorrection.saveRecorrectionSuggestion(mWordComposer, mComposingStringBuilder);
|
mRecorrection.saveRecorrectionSuggestion(mWordComposer, mComposingStringBuilder);
|
||||||
}
|
}
|
||||||
@ -853,7 +854,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
mLastSelectionEnd = newSelEnd;
|
mLastSelectionEnd = newSelEnd;
|
||||||
|
|
||||||
mRecorrection.updateRecorrectionSelection(mKeyboardSwitcher,
|
mRecorrection.updateRecorrectionSelection(mKeyboardSwitcher,
|
||||||
mCandidateView, candidatesStart, candidatesEnd, newSelStart,
|
mSuggestionsView, candidatesStart, candidatesEnd, newSelStart,
|
||||||
newSelEnd, oldSelStart, mLastSelectionStart,
|
newSelEnd, oldSelStart, mLastSelectionStart,
|
||||||
mLastSelectionEnd, mHasUncommittedTypedChars);
|
mLastSelectionEnd, mHasUncommittedTypedChars);
|
||||||
}
|
}
|
||||||
@ -866,10 +867,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
/**
|
/**
|
||||||
* This is called when the user has clicked on the extracted text view,
|
* This is called when the user has clicked on the extracted text view,
|
||||||
* when running in fullscreen mode. The default implementation hides
|
* when running in fullscreen mode. The default implementation hides
|
||||||
* the candidates view when this happens, but only if the extracted text
|
* the suggestions view when this happens, but only if the extracted text
|
||||||
* editor has a vertical scroll bar because its text doesn't fit.
|
* editor has a vertical scroll bar because its text doesn't fit.
|
||||||
* Here we override the behavior due to the possibility that a re-correction could
|
* Here we override the behavior due to the possibility that a re-correction could
|
||||||
* cause the candidate strip to disappear and re-appear.
|
* cause the suggestions strip to disappear and re-appear.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onExtractedTextClicked() {
|
public void onExtractedTextClicked() {
|
||||||
@ -881,11 +882,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
/**
|
/**
|
||||||
* This is called when the user has performed a cursor movement in the
|
* This is called when the user has performed a cursor movement in the
|
||||||
* extracted text view, when it is running in fullscreen mode. The default
|
* extracted text view, when it is running in fullscreen mode. The default
|
||||||
* implementation hides the candidates view when a vertical movement
|
* implementation hides the suggestions view when a vertical movement
|
||||||
* happens, but only if the extracted text editor has a vertical scroll bar
|
* happens, but only if the extracted text editor has a vertical scroll bar
|
||||||
* because its text doesn't fit.
|
* because its text doesn't fit.
|
||||||
* Here we override the behavior due to the possibility that a re-correction could
|
* Here we override the behavior due to the possibility that a re-correction could
|
||||||
* cause the candidate strip to disappear and re-appear.
|
* cause the suggestions strip to disappear and re-appear.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onExtractedCursorMovement(int dx, int dy) {
|
public void onExtractedCursorMovement(int dx, int dy) {
|
||||||
@ -938,20 +939,20 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) {
|
private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) {
|
||||||
// TODO: Modify this if we support candidates with hard keyboard
|
// TODO: Modify this if we support suggestions with hard keyboard
|
||||||
if (onEvaluateInputViewShown() && mCandidateViewContainer != null) {
|
if (onEvaluateInputViewShown() && mSuggestionsContainer != null) {
|
||||||
final boolean shouldShowCandidates = shown
|
final boolean shouldShowSuggestions = shown
|
||||||
&& (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true);
|
&& (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true);
|
||||||
if (isFullscreenMode()) {
|
if (isFullscreenMode()) {
|
||||||
// No need to have extra space to show the key preview.
|
// No need to have extra space to show the key preview.
|
||||||
mCandidateViewContainer.setMinimumHeight(0);
|
mSuggestionsContainer.setMinimumHeight(0);
|
||||||
mCandidateViewContainer.setVisibility(
|
mSuggestionsContainer.setVisibility(
|
||||||
shouldShowCandidates ? View.VISIBLE : View.GONE);
|
shouldShowSuggestions ? View.VISIBLE : View.GONE);
|
||||||
} else {
|
} else {
|
||||||
// We must control the visibility of the suggestion strip in order to avoid clipped
|
// We must control the visibility of the suggestion strip in order to avoid clipped
|
||||||
// key previews, even when we don't show the suggestion strip.
|
// key previews, even when we don't show the suggestion strip.
|
||||||
mCandidateViewContainer.setVisibility(
|
mSuggestionsContainer.setVisibility(
|
||||||
shouldShowCandidates ? View.VISIBLE : View.INVISIBLE);
|
shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -964,14 +965,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
public void onComputeInsets(InputMethodService.Insets outInsets) {
|
public void onComputeInsets(InputMethodService.Insets outInsets) {
|
||||||
super.onComputeInsets(outInsets);
|
super.onComputeInsets(outInsets);
|
||||||
final KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
final KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
||||||
if (inputView == null || mCandidateViewContainer == null)
|
if (inputView == null || mSuggestionsContainer == null)
|
||||||
return;
|
return;
|
||||||
final int containerHeight = mCandidateViewContainer.getHeight();
|
final int containerHeight = mSuggestionsContainer.getHeight();
|
||||||
int touchY = containerHeight;
|
int touchY = containerHeight;
|
||||||
// Need to set touchable region only if input view is being shown
|
// Need to set touchable region only if input view is being shown
|
||||||
if (mKeyboardSwitcher.isInputViewShown()) {
|
if (mKeyboardSwitcher.isInputViewShown()) {
|
||||||
if (mCandidateViewContainer.getVisibility() == View.VISIBLE) {
|
if (mSuggestionsContainer.getVisibility() == View.VISIBLE) {
|
||||||
touchY -= mCandidateStripHeight;
|
touchY -= mSuggestionsStripHeight;
|
||||||
}
|
}
|
||||||
final int touchWidth = inputView.getWidth();
|
final int touchWidth = inputView.getWidth();
|
||||||
final int touchHeight = inputView.getHeight() + containerHeight
|
final int touchHeight = inputView.getHeight() + containerHeight
|
||||||
@ -1321,7 +1322,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
|
if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
|
||||||
ic.deleteSurroundingText(mEnteredText.length(), 0);
|
ic.deleteSurroundingText(mEnteredText.length(), 0);
|
||||||
} else if (deleteChar) {
|
} else if (deleteChar) {
|
||||||
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
|
if (mSuggestionsView != null && mSuggestionsView.dismissAddToDictionaryHint()) {
|
||||||
// Go back to the suggestion mode if the user canceled the
|
// Go back to the suggestion mode if the user canceled the
|
||||||
// "Touch again to save".
|
// "Touch again to save".
|
||||||
// NOTE: In gerenal, we don't revert the word when backspacing
|
// NOTE: In gerenal, we don't revert the word when backspacing
|
||||||
@ -1440,7 +1441,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
mVoiceProxy.handleSeparator();
|
mVoiceProxy.handleSeparator();
|
||||||
|
|
||||||
// Should dismiss the "Touch again to save" message when handling separator
|
// Should dismiss the "Touch again to save" message when handling separator
|
||||||
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
|
if (mSuggestionsView != null && mSuggestionsView.dismissAddToDictionaryHint()) {
|
||||||
mHandler.cancelUpdateBigramPredictions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
@ -1491,8 +1492,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
if (!TextUtils.isEmpty(typedWord) && !typedWord.equals(mBestWord)) {
|
if (!TextUtils.isEmpty(typedWord) && !typedWord.equals(mBestWord)) {
|
||||||
InputConnectionCompatUtils.commitCorrection(
|
InputConnectionCompatUtils.commitCorrection(
|
||||||
ic, mLastSelectionEnd - typedWord.length(), typedWord, mBestWord);
|
ic, mLastSelectionEnd - typedWord.length(), typedWord, mBestWord);
|
||||||
if (mCandidateView != null)
|
if (mSuggestionsView != null)
|
||||||
mCandidateView.onAutoCorrectionInverted(mBestWord);
|
mSuggestionsView.onAutoCorrectionInverted(mBestWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Keyboard.CODE_SPACE == primaryCode) {
|
if (Keyboard.CODE_SPACE == primaryCode) {
|
||||||
@ -1527,7 +1528,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingPunctuationList() {
|
public boolean isShowingPunctuationList() {
|
||||||
return mSettingsValues.mSuggestPuncList == mCandidateView.getSuggestions();
|
return mSettingsValues.mSuggestPuncList == mSuggestionsView.getSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingSuggestionsStrip() {
|
public boolean isShowingSuggestionsStrip() {
|
||||||
@ -1536,10 +1537,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
&& mDisplayOrientation == Configuration.ORIENTATION_PORTRAIT);
|
&& mDisplayOrientation == Configuration.ORIENTATION_PORTRAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCandidateStripVisible() {
|
public boolean isSuggestionsStripVisible() {
|
||||||
if (mCandidateView == null)
|
if (mSuggestionsView == null)
|
||||||
return false;
|
return false;
|
||||||
if (mCandidateView.isShowingAddToDictionaryHint() || TextEntryState.isRecorrecting())
|
if (mSuggestionsView.isShowingAddToDictionaryHint() || TextEntryState.isRecorrecting())
|
||||||
return true;
|
return true;
|
||||||
if (!isShowingSuggestionsStrip())
|
if (!isShowingSuggestionsStrip())
|
||||||
return false;
|
return false;
|
||||||
@ -1561,7 +1562,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
}
|
}
|
||||||
setInputView(v);
|
setInputView(v);
|
||||||
}
|
}
|
||||||
setSuggestionStripShown(isCandidateStripVisible());
|
setSuggestionStripShown(isSuggestionsStripVisible());
|
||||||
updateInputViewShown();
|
updateInputViewShown();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
@ -1571,8 +1572,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSuggestions(SuggestedWords words) {
|
public void setSuggestions(SuggestedWords words) {
|
||||||
if (mCandidateView != null) {
|
if (mSuggestionsView != null) {
|
||||||
mCandidateView.setSuggestions(words);
|
mSuggestionsView.setSuggestions(words);
|
||||||
mKeyboardSwitcher.onAutoCorrectionStateChanged(
|
mKeyboardSwitcher.onAutoCorrectionStateChanged(
|
||||||
words.hasWordAboveAutoCorrectionScoreThreshold());
|
words.hasWordAboveAutoCorrectionScoreThreshold());
|
||||||
}
|
}
|
||||||
@ -1625,11 +1626,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
// length == 1).
|
// length == 1).
|
||||||
if (typedWord != null) {
|
if (typedWord != null) {
|
||||||
if (builder.size() > 1 || typedWord.length() == 1 || typedWordValid
|
if (builder.size() > 1 || typedWord.length() == 1 || typedWordValid
|
||||||
|| mCandidateView.isShowingAddToDictionaryHint()) {
|
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
|
||||||
builder.setTypedWordValid(typedWordValid).setHasMinimalSuggestion(
|
builder.setTypedWordValid(typedWordValid).setHasMinimalSuggestion(
|
||||||
autoCorrectionAvailable);
|
autoCorrectionAvailable);
|
||||||
} else {
|
} else {
|
||||||
final SuggestedWords previousSuggestions = mCandidateView.getSuggestions();
|
final SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions();
|
||||||
if (previousSuggestions == mSettingsValues.mSuggestPuncList)
|
if (previousSuggestions == mSettingsValues.mSuggestPuncList)
|
||||||
return;
|
return;
|
||||||
builder.addTypedWordAndPreviousSuggestions(typedWord, previousSuggestions);
|
builder.addTypedWordAndPreviousSuggestions(typedWord, previousSuggestions);
|
||||||
@ -1651,11 +1652,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
} else {
|
} else {
|
||||||
mBestWord = null;
|
mBestWord = null;
|
||||||
}
|
}
|
||||||
setSuggestionStripShown(isCandidateStripVisible());
|
setSuggestionStripShown(isSuggestionsStripVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean pickDefaultSuggestion(int separatorCode) {
|
private boolean pickDefaultSuggestion(int separatorCode) {
|
||||||
// Complete any pending candidate query first
|
// Complete any pending suggestions query first
|
||||||
if (mHandler.hasPendingUpdateSuggestions()) {
|
if (mHandler.hasPendingUpdateSuggestions()) {
|
||||||
mHandler.cancelUpdateSuggestions();
|
mHandler.cancelUpdateSuggestions();
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
@ -1674,7 +1675,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pickSuggestionManually(int index, CharSequence suggestion) {
|
public void pickSuggestionManually(int index, CharSequence suggestion) {
|
||||||
SuggestedWords suggestions = mCandidateView.getSuggestions();
|
SuggestedWords suggestions = mSuggestionsView.getSuggestions();
|
||||||
mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,
|
mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,
|
||||||
mSettingsValues.mWordSeparators);
|
mSettingsValues.mWordSeparators);
|
||||||
|
|
||||||
@ -1690,8 +1691,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
ic.commitCompletion(completionInfo);
|
ic.commitCompletion(completionInfo);
|
||||||
}
|
}
|
||||||
mCommittedLength = suggestion.length();
|
mCommittedLength = suggestion.length();
|
||||||
if (mCandidateView != null) {
|
if (mSuggestionsView != null) {
|
||||||
mCandidateView.clear();
|
mSuggestionsView.clear();
|
||||||
}
|
}
|
||||||
mKeyboardSwitcher.updateShiftState();
|
mKeyboardSwitcher.updateShiftState();
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
@ -1786,7 +1787,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
}
|
}
|
||||||
if (showingAddToDictionaryHint) {
|
if (showingAddToDictionaryHint) {
|
||||||
if (mIsUserDictionaryAvaliable) {
|
if (mIsUserDictionaryAvaliable) {
|
||||||
mCandidateView.showAddToDictionaryHint(suggestion);
|
mSuggestionsView.showAddToDictionaryHint(suggestion);
|
||||||
} else {
|
} else {
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
@ -1806,7 +1807,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
mVoiceProxy.rememberReplacedWord(bestWord, mSettingsValues.mWordSeparators);
|
mVoiceProxy.rememberReplacedWord(bestWord, mSettingsValues.mWordSeparators);
|
||||||
SuggestedWords suggestedWords = mCandidateView.getSuggestions();
|
SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();
|
||||||
ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(
|
ic.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(
|
||||||
this, bestWord, suggestedWords), 1);
|
this, bestWord, suggestedWords), 1);
|
||||||
}
|
}
|
||||||
@ -1842,7 +1843,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||||||
|
|
||||||
public void setPunctuationSuggestions() {
|
public void setPunctuationSuggestions() {
|
||||||
setSuggestions(mSettingsValues.mSuggestPuncList);
|
setSuggestions(mSettingsValues.mSuggestPuncList);
|
||||||
setSuggestionStripShown(isCandidateStripVisible());
|
setSuggestionStripShown(isSuggestionsStripVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToUserUnigramAndBigramDictionaries(CharSequence suggestion,
|
private void addToUserUnigramAndBigramDictionaries(CharSequence suggestion,
|
||||||
|
@ -43,10 +43,10 @@ public class MoreSuggestions extends Keyboard {
|
|||||||
private int mToPos;
|
private int mToPos;
|
||||||
|
|
||||||
public static class MoreSuggestionsParam extends KeyboardParams {
|
public static class MoreSuggestionsParam extends KeyboardParams {
|
||||||
private final int[] mWidths = new int[CandidateView.MAX_SUGGESTIONS];
|
private final int[] mWidths = new int[SuggestionsView.MAX_SUGGESTIONS];
|
||||||
private final int[] mRowNumbers = new int[CandidateView.MAX_SUGGESTIONS];
|
private final int[] mRowNumbers = new int[SuggestionsView.MAX_SUGGESTIONS];
|
||||||
private final int[] mColumnOrders = new int[CandidateView.MAX_SUGGESTIONS];
|
private final int[] mColumnOrders = new int[SuggestionsView.MAX_SUGGESTIONS];
|
||||||
private final int[] mNumColumnsInRow = new int[CandidateView.MAX_SUGGESTIONS];
|
private final int[] mNumColumnsInRow = new int[SuggestionsView.MAX_SUGGESTIONS];
|
||||||
private static final int MAX_COLUMNS_IN_ROW = 3;
|
private static final int MAX_COLUMNS_IN_ROW = 3;
|
||||||
private int mNumRows;
|
private int mNumRows;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public class MoreSuggestions extends Keyboard {
|
|||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
int pos = fromPos, rowStartPos = fromPos;
|
int pos = fromPos, rowStartPos = fromPos;
|
||||||
final int size = Math.min(suggestions.size(), CandidateView.MAX_SUGGESTIONS);
|
final int size = Math.min(suggestions.size(), SuggestionsView.MAX_SUGGESTIONS);
|
||||||
while (pos < size) {
|
while (pos < size) {
|
||||||
final CharSequence word = suggestions.getWord(pos);
|
final CharSequence word = suggestions.getWord(pos);
|
||||||
// TODO: Should take care of text x-scaling.
|
// TODO: Should take care of text x-scaling.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 The Android Open Source Project
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* 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
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
@ -57,7 +57,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CandidateView extends LinearLayout implements OnClickListener, OnLongClickListener {
|
public class SuggestionsView extends LinearLayout implements OnClickListener, OnLongClickListener {
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
public boolean addWordToDictionary(String word);
|
public boolean addWordToDictionary(String word);
|
||||||
public void pickSuggestionManually(int index, CharSequence word);
|
public void pickSuggestionManually(int index, CharSequence word);
|
||||||
@ -68,8 +68,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
|
|
||||||
private static final boolean DBG = LatinImeLogger.sDBG;
|
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||||
|
|
||||||
private final ViewGroup mCandidatesPlacer;
|
private final ViewGroup mSuggestionsPlacer;
|
||||||
private final ViewGroup mCandidatesStrip;
|
private final ViewGroup mSuggestionsStrip;
|
||||||
private View mKeyboardView;
|
private View mKeyboardView;
|
||||||
|
|
||||||
private final View mMoreSuggestionsContainer;
|
private final View mMoreSuggestionsContainer;
|
||||||
@ -93,26 +93,26 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
|
|
||||||
private final UiHandler mHandler = new UiHandler(this);
|
private final UiHandler mHandler = new UiHandler(this);
|
||||||
|
|
||||||
private static class UiHandler extends StaticInnerHandlerWrapper<CandidateView> {
|
private static class UiHandler extends StaticInnerHandlerWrapper<SuggestionsView> {
|
||||||
private static final int MSG_HIDE_PREVIEW = 0;
|
private static final int MSG_HIDE_PREVIEW = 0;
|
||||||
private static final int MSG_UPDATE_SUGGESTION = 1;
|
private static final int MSG_UPDATE_SUGGESTION = 1;
|
||||||
|
|
||||||
private static final long DELAY_HIDE_PREVIEW = 1300;
|
private static final long DELAY_HIDE_PREVIEW = 1300;
|
||||||
private static final long DELAY_UPDATE_SUGGESTION = 300;
|
private static final long DELAY_UPDATE_SUGGESTION = 300;
|
||||||
|
|
||||||
public UiHandler(CandidateView outerInstance) {
|
public UiHandler(SuggestionsView outerInstance) {
|
||||||
super(outerInstance);
|
super(outerInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispatchMessage(Message msg) {
|
public void dispatchMessage(Message msg) {
|
||||||
final CandidateView candidateView = getOuterInstance();
|
final SuggestionsView suggestionsView = getOuterInstance();
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_HIDE_PREVIEW:
|
case MSG_HIDE_PREVIEW:
|
||||||
candidateView.hidePreview();
|
suggestionsView.hidePreview();
|
||||||
break;
|
break;
|
||||||
case MSG_UPDATE_SUGGESTION:
|
case MSG_UPDATE_SUGGESTION:
|
||||||
candidateView.updateSuggestions();
|
suggestionsView.updateSuggestions();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,16 +142,16 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CandidateViewParams {
|
private static class SuggestionsViewParams {
|
||||||
public final int mPadding;
|
public final int mPadding;
|
||||||
public final int mDividerWidth;
|
public final int mDividerWidth;
|
||||||
public final int mCandidateStripHeight;
|
public final int mSuggestionsStripHeight;
|
||||||
|
|
||||||
protected final List<TextView> mWords;
|
protected final List<TextView> mWords;
|
||||||
protected final List<View> mDividers;
|
protected final List<View> mDividers;
|
||||||
protected final List<TextView> mInfos;
|
protected final List<TextView> mInfos;
|
||||||
|
|
||||||
protected CandidateViewParams(List<TextView> words, List<View> dividers,
|
protected SuggestionsViewParams(List<TextView> words, List<View> dividers,
|
||||||
List<TextView> infos) {
|
List<TextView> infos) {
|
||||||
mWords = words;
|
mWords = words;
|
||||||
mDividers = dividers;
|
mDividers = dividers;
|
||||||
@ -165,22 +165,22 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
mDividerWidth = divider.getMeasuredWidth();
|
mDividerWidth = divider.getMeasuredWidth();
|
||||||
|
|
||||||
final Resources res = word.getResources();
|
final Resources res = word.getResources();
|
||||||
mCandidateStripHeight = res.getDimensionPixelSize(R.dimen.candidate_strip_height);
|
mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.suggestions_strip_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SuggestionsStripParams extends CandidateViewParams {
|
private static class SuggestionsStripParams extends SuggestionsViewParams {
|
||||||
private static final int DEFAULT_CANDIDATE_COUNT_IN_STRIP = 3;
|
private static final int DEFAULT_SUGGESTIONS_COUNT_IN_STRIP = 3;
|
||||||
private static final int DEFAULT_CENTER_CANDIDATE_PERCENTILE = 40;
|
private static final int DEFAULT_CENTER_SUGGESTION_PERCENTILE = 40;
|
||||||
private static final int PUNCTUATIONS_IN_STRIP = 6;
|
private static final int PUNCTUATIONS_IN_STRIP = 6;
|
||||||
|
|
||||||
private final int mColorTypedWord;
|
private final int mColorTypedWord;
|
||||||
private final int mColorAutoCorrect;
|
private final int mColorAutoCorrect;
|
||||||
private final int mColorSuggestedCandidate;
|
private final int mColorSuggested;
|
||||||
public final int mCandidateCountInStrip;
|
public final int mSuggestionsCountInStrip;
|
||||||
private final float mCenterCandidateWeight;
|
private final float mCenterSuggestionWeight;
|
||||||
private final int mCenterCandidateIndex;
|
private final int mCenterSuggestionIndex;
|
||||||
private final Drawable mMoreCandidateHint;
|
private final Drawable mMoreSuggestionsHint;
|
||||||
|
|
||||||
private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD);
|
private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD);
|
||||||
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
|
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
|
||||||
@ -205,33 +205,33 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
List<TextView> words, List<View> dividers, List<TextView> infos) {
|
List<TextView> words, List<View> dividers, List<TextView> infos) {
|
||||||
super(words, dividers, infos);
|
super(words, dividers, infos);
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.CandidateView, defStyle, R.style.CandidateViewStyle);
|
attrs, R.styleable.SuggestionsView, defStyle, R.style.SuggestionsViewStyle);
|
||||||
mSuggestionStripOption = a.getInt(R.styleable.CandidateView_suggestionStripOption, 0);
|
mSuggestionStripOption = a.getInt(R.styleable.SuggestionsView_suggestionStripOption, 0);
|
||||||
mColorTypedWord = a.getColor(R.styleable.CandidateView_colorTypedWord, 0);
|
mColorTypedWord = a.getColor(R.styleable.SuggestionsView_colorTypedWord, 0);
|
||||||
mColorAutoCorrect = a.getColor(R.styleable.CandidateView_colorAutoCorrect, 0);
|
mColorAutoCorrect = a.getColor(R.styleable.SuggestionsView_colorAutoCorrect, 0);
|
||||||
mColorSuggestedCandidate = a.getColor(R.styleable.CandidateView_colorSuggested, 0);
|
mColorSuggested = a.getColor(R.styleable.SuggestionsView_colorSuggested, 0);
|
||||||
mCandidateCountInStrip = a.getInt(
|
mSuggestionsCountInStrip = a.getInt(
|
||||||
R.styleable.CandidateView_candidateCountInStrip,
|
R.styleable.SuggestionsView_suggestionsCountInStrip,
|
||||||
DEFAULT_CANDIDATE_COUNT_IN_STRIP);
|
DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
|
||||||
mCenterCandidateWeight = a.getInt(
|
mCenterSuggestionWeight = a.getInt(
|
||||||
R.styleable.CandidateView_centerCandidatePercentile,
|
R.styleable.SuggestionsView_centerSuggestionPercentile,
|
||||||
DEFAULT_CENTER_CANDIDATE_PERCENTILE) / 100.0f;
|
DEFAULT_CENTER_SUGGESTION_PERCENTILE) / 100.0f;
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
mCenterCandidateIndex = mCandidateCountInStrip / 2;
|
mCenterSuggestionIndex = mSuggestionsCountInStrip / 2;
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
mMoreCandidateHint = res.getDrawable(R.drawable.more_suggestions_hint);
|
mMoreSuggestionsHint = res.getDrawable(R.drawable.more_suggestions_hint);
|
||||||
|
|
||||||
mInvertedForegroundColorSpan = new ForegroundColorSpan(mColorTypedWord ^ 0x00ffffff);
|
mInvertedForegroundColorSpan = new ForegroundColorSpan(mColorTypedWord ^ 0x00ffffff);
|
||||||
mInvertedBackgroundColorSpan = new BackgroundColorSpan(mColorTypedWord);
|
mInvertedBackgroundColorSpan = new BackgroundColorSpan(mColorTypedWord);
|
||||||
|
|
||||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
mWordToSaveView = (TextView)inflater.inflate(R.layout.candidate_word, null);
|
mWordToSaveView = (TextView)inflater.inflate(R.layout.suggestion_word, null);
|
||||||
mHintToSaveView = (TextView)inflater.inflate(R.layout.candidate_word, null);
|
mHintToSaveView = (TextView)inflater.inflate(R.layout.suggestion_word, null);
|
||||||
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
|
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence getStyledCandidateWord(SuggestedWords suggestions, int pos) {
|
private CharSequence getStyledSuggestionWord(SuggestedWords suggestions, int pos) {
|
||||||
final CharSequence word = suggestions.getWord(pos);
|
final CharSequence word = suggestions.getWord(pos);
|
||||||
final boolean isAutoCorrect = pos == 1 && willAutoCorrect(suggestions);
|
final boolean isAutoCorrect = pos == 1 && willAutoCorrect(suggestions);
|
||||||
final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid;
|
final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid;
|
||||||
@ -259,24 +259,24 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
// TODO: This works for 3 suggestions. Revisit this algorithm when there are 5 or more
|
// TODO: This works for 3 suggestions. Revisit this algorithm when there are 5 or more
|
||||||
// suggestions.
|
// suggestions.
|
||||||
final int centerPos = willAutoCorrect(suggestions) ? 1 : 0;
|
final int centerPos = willAutoCorrect(suggestions) ? 1 : 0;
|
||||||
if (index == mCenterCandidateIndex) {
|
if (index == mCenterSuggestionIndex) {
|
||||||
return centerPos;
|
return centerPos;
|
||||||
} else if (index == centerPos) {
|
} else if (index == centerPos) {
|
||||||
return mCenterCandidateIndex;
|
return mCenterSuggestionIndex;
|
||||||
} else {
|
} else {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCandidateTextColor(int index, SuggestedWords suggestions, int pos) {
|
private int getSuggestionTextColor(int index, SuggestedWords suggestions, int pos) {
|
||||||
// TODO: Need to revisit this logic with bigram suggestions
|
// TODO: Need to revisit this logic with bigram suggestions
|
||||||
final boolean isSuggestedCandidate = (pos != 0);
|
final boolean isSuggested = (pos != 0);
|
||||||
|
|
||||||
final int color;
|
final int color;
|
||||||
if (index == mCenterCandidateIndex && willAutoCorrect(suggestions)) {
|
if (index == mCenterSuggestionIndex && willAutoCorrect(suggestions)) {
|
||||||
color = mColorAutoCorrect;
|
color = mColorAutoCorrect;
|
||||||
} else if (isSuggestedCandidate) {
|
} else if (isSuggested) {
|
||||||
color = mColorSuggestedCandidate;
|
color = mColorSuggested;
|
||||||
} else {
|
} else {
|
||||||
color = mColorTypedWord;
|
color = mColorTypedWord;
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int countInStrip = mCandidateCountInStrip;
|
final int countInStrip = mSuggestionsCountInStrip;
|
||||||
setupTexts(suggestions, countInStrip);
|
setupTexts(suggestions, countInStrip);
|
||||||
mMoreSuggestionsAvailable = (suggestions.size() > countInStrip);
|
mMoreSuggestionsAvailable = (suggestions.size() > countInStrip);
|
||||||
int x = 0;
|
int x = 0;
|
||||||
@ -321,34 +321,34 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
|
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
final View divider = mDividers.get(pos);
|
final View divider = mDividers.get(pos);
|
||||||
// Add divider if this isn't the left most suggestion in candidate strip.
|
// Add divider if this isn't the left most suggestion in suggestions strip.
|
||||||
stripView.addView(divider);
|
stripView.addView(divider);
|
||||||
x += divider.getMeasuredWidth();
|
x += divider.getMeasuredWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence styled = mTexts.get(pos);
|
final CharSequence styled = mTexts.get(pos);
|
||||||
final TextView word = mWords.get(pos);
|
final TextView word = mWords.get(pos);
|
||||||
if (index == mCenterCandidateIndex && mMoreSuggestionsAvailable) {
|
if (index == mCenterSuggestionIndex && mMoreSuggestionsAvailable) {
|
||||||
// TODO: This "more suggestions hint" should have nicely designed icon.
|
// TODO: This "more suggestions hint" should have nicely designed icon.
|
||||||
word.setCompoundDrawablesWithIntrinsicBounds(
|
word.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
null, null, null, mMoreCandidateHint);
|
null, null, null, mMoreSuggestionsHint);
|
||||||
// HACK: To align with other TextView that has no compound drawables.
|
// HACK: To align with other TextView that has no compound drawables.
|
||||||
word.setCompoundDrawablePadding(-mMoreCandidateHint.getIntrinsicHeight());
|
word.setCompoundDrawablePadding(-mMoreSuggestionsHint.getIntrinsicHeight());
|
||||||
} else {
|
} else {
|
||||||
word.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
word.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable this candidate if the suggestion is null or empty.
|
// Disable this suggestion if the suggestion is null or empty.
|
||||||
word.setEnabled(!TextUtils.isEmpty(styled));
|
word.setEnabled(!TextUtils.isEmpty(styled));
|
||||||
word.setTextColor(getCandidateTextColor(index, suggestions, pos));
|
word.setTextColor(getSuggestionTextColor(index, suggestions, pos));
|
||||||
final int width = getCandidateWidth(index, stripWidth);
|
final int width = getSuggestionWidth(index, stripWidth);
|
||||||
final CharSequence text = getEllipsizedText(styled, width, word.getPaint());
|
final CharSequence text = getEllipsizedText(styled, width, word.getPaint());
|
||||||
final float scaleX = word.getTextScaleX();
|
final float scaleX = word.getTextScaleX();
|
||||||
word.setText(text); // TextView.setText() resets text scale x to 1.0.
|
word.setText(text); // TextView.setText() resets text scale x to 1.0.
|
||||||
word.setTextScaleX(scaleX);
|
word.setTextScaleX(scaleX);
|
||||||
stripView.addView(word);
|
stripView.addView(word);
|
||||||
setLayoutWeight(
|
setLayoutWeight(
|
||||||
word, getCandidateWeight(index), ViewGroup.LayoutParams.MATCH_PARENT);
|
word, getSuggestionWeight(index), ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
x += word.getMeasuredWidth();
|
x += word.getMeasuredWidth();
|
||||||
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
@ -368,19 +368,19 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCandidateWidth(int index, int maxWidth) {
|
private int getSuggestionWidth(int index, int maxWidth) {
|
||||||
final int paddings = mPadding * mCandidateCountInStrip;
|
final int paddings = mPadding * mSuggestionsCountInStrip;
|
||||||
final int dividers = mDividerWidth * (mCandidateCountInStrip - 1);
|
final int dividers = mDividerWidth * (mSuggestionsCountInStrip - 1);
|
||||||
final int availableWidth = maxWidth - paddings - dividers;
|
final int availableWidth = maxWidth - paddings - dividers;
|
||||||
return (int)(availableWidth * getCandidateWeight(index));
|
return (int)(availableWidth * getSuggestionWeight(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getCandidateWeight(int index) {
|
private float getSuggestionWeight(int index) {
|
||||||
if (index == mCenterCandidateIndex) {
|
if (index == mCenterSuggestionIndex) {
|
||||||
return mCenterCandidateWeight;
|
return mCenterSuggestionWeight;
|
||||||
} else {
|
} else {
|
||||||
// TODO: Revisit this for cases of 5 or more suggestions
|
// TODO: Revisit this for cases of 5 or more suggestions
|
||||||
return (1.0f - mCenterCandidateWeight) / (mCandidateCountInStrip - 1);
|
return (1.0f - mCenterSuggestionWeight) / (mSuggestionsCountInStrip - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
mTexts.clear();
|
mTexts.clear();
|
||||||
final int count = Math.min(suggestions.size(), countInStrip);
|
final int count = Math.min(suggestions.size(), countInStrip);
|
||||||
for (int pos = 0; pos < count; pos++) {
|
for (int pos = 0; pos < count; pos++) {
|
||||||
final CharSequence styled = getStyledCandidateWord(suggestions, pos);
|
final CharSequence styled = getStyledSuggestionWord(suggestions, pos);
|
||||||
mTexts.add(styled);
|
mTexts.add(styled);
|
||||||
}
|
}
|
||||||
for (int pos = count; pos < countInStrip; pos++) {
|
for (int pos = count; pos < countInStrip; pos++) {
|
||||||
@ -401,7 +401,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
final int countInStrip = Math.min(suggestions.size(), PUNCTUATIONS_IN_STRIP);
|
final int countInStrip = Math.min(suggestions.size(), PUNCTUATIONS_IN_STRIP);
|
||||||
for (int index = 0; index < countInStrip; index++) {
|
for (int index = 0; index < countInStrip; index++) {
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
// Add divider if this isn't the left most suggestion in candidate strip.
|
// Add divider if this isn't the left most suggestion in suggestions strip.
|
||||||
stripView.addView(mDividers.get(index));
|
stripView.addView(mDividers.get(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
word.setTextScaleX(1.0f);
|
word.setTextScaleX(1.0f);
|
||||||
word.setCompoundDrawables(null, null, null, null);
|
word.setCompoundDrawables(null, null, null, null);
|
||||||
stripView.addView(word);
|
stripView.addView(word);
|
||||||
setLayoutWeight(word, 1.0f, mCandidateStripHeight);
|
setLayoutWeight(word, 1.0f, mSuggestionsStripHeight);
|
||||||
}
|
}
|
||||||
mMoreSuggestionsAvailable = false;
|
mMoreSuggestionsAvailable = false;
|
||||||
}
|
}
|
||||||
@ -424,14 +424,14 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
|
|
||||||
final TextView wordView = mWordToSaveView;
|
final TextView wordView = mWordToSaveView;
|
||||||
wordView.setTextColor(mColorTypedWord);
|
wordView.setTextColor(mColorTypedWord);
|
||||||
final int wordWidth = (int)(width * mCenterCandidateWeight);
|
final int wordWidth = (int)(width * mCenterSuggestionWeight);
|
||||||
final CharSequence text = getEllipsizedText(word, wordWidth, wordView.getPaint());
|
final CharSequence text = getEllipsizedText(word, wordWidth, wordView.getPaint());
|
||||||
final float wordScaleX = wordView.getTextScaleX();
|
final float wordScaleX = wordView.getTextScaleX();
|
||||||
wordView.setTag(word);
|
wordView.setTag(word);
|
||||||
wordView.setText(text);
|
wordView.setText(text);
|
||||||
wordView.setTextScaleX(wordScaleX);
|
wordView.setTextScaleX(wordScaleX);
|
||||||
stripView.addView(wordView);
|
stripView.addView(wordView);
|
||||||
setLayoutWeight(wordView, mCenterCandidateWeight, ViewGroup.LayoutParams.MATCH_PARENT);
|
setLayoutWeight(wordView, mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
|
|
||||||
stripView.addView(mDividers.get(0));
|
stripView.addView(mDividers.get(0));
|
||||||
|
|
||||||
@ -443,56 +443,56 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
hintView.setTextScaleX(hintScaleX);
|
hintView.setTextScaleX(hintScaleX);
|
||||||
stripView.addView(hintView);
|
stripView.addView(hintView);
|
||||||
setLayoutWeight(
|
setLayoutWeight(
|
||||||
hintView, 1.0f - mCenterCandidateWeight, ViewGroup.LayoutParams.MATCH_PARENT);
|
hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a CandidateView for showing suggested words for completion.
|
* Construct a {@link SuggestionsView} for showing suggested words for completion.
|
||||||
* @param context
|
* @param context
|
||||||
* @param attrs
|
* @param attrs
|
||||||
*/
|
*/
|
||||||
public CandidateView(Context context, AttributeSet attrs) {
|
public SuggestionsView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, R.attr.candidateViewStyle);
|
this(context, attrs, R.attr.suggestionsViewStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CandidateView(Context context, AttributeSet attrs, int defStyle) {
|
public SuggestionsView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
// Note: Up to version 10 (Gingerbread) of the API, LinearLayout doesn't have 3-argument
|
// Note: Up to version 10 (Gingerbread) of the API, LinearLayout doesn't have 3-argument
|
||||||
// constructor.
|
// constructor.
|
||||||
// TODO: Call 3-argument constructor, super(context, attrs, defStyle), when we abandon
|
// TODO: Call 3-argument constructor, super(context, attrs, defStyle), when we abandon
|
||||||
// backward compatibility with the version 10 or earlier of the API.
|
// backward compatibility with the version 10 or earlier of the API.
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
if (defStyle != R.attr.candidateViewStyle) {
|
if (defStyle != R.attr.suggestionsViewStyle) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"can't accept defStyle other than R.attr.candidateViewStyle: defStyle="
|
"can't accept defStyle other than R.attr.suggestionsViewStyle: defStyle="
|
||||||
+ defStyle);
|
+ defStyle);
|
||||||
}
|
}
|
||||||
setBackgroundDrawable(LinearLayoutCompatUtils.getBackgroundDrawable(
|
setBackgroundDrawable(LinearLayoutCompatUtils.getBackgroundDrawable(
|
||||||
context, attrs, defStyle, R.style.CandidateViewStyle));
|
context, attrs, defStyle, R.style.SuggestionsViewStyle));
|
||||||
|
|
||||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
inflater.inflate(R.layout.candidates_strip, this);
|
inflater.inflate(R.layout.suggestions_strip, this);
|
||||||
|
|
||||||
mPreviewPopup = new PopupWindow(context);
|
mPreviewPopup = new PopupWindow(context);
|
||||||
mPreviewText = (TextView) inflater.inflate(R.layout.candidate_preview, null);
|
mPreviewText = (TextView) inflater.inflate(R.layout.suggestion_preview, null);
|
||||||
mPreviewPopup.setWindowLayoutMode(
|
mPreviewPopup.setWindowLayoutMode(
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
mPreviewPopup.setContentView(mPreviewText);
|
mPreviewPopup.setContentView(mPreviewText);
|
||||||
mPreviewPopup.setBackgroundDrawable(null);
|
mPreviewPopup.setBackgroundDrawable(null);
|
||||||
|
|
||||||
mCandidatesPlacer = (ViewGroup)findViewById(R.id.candidates_placer);
|
mSuggestionsPlacer = (ViewGroup)findViewById(R.id.suggestions_placer);
|
||||||
mCandidatesStrip = (ViewGroup)findViewById(R.id.candidates_strip);
|
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
|
||||||
for (int pos = 0; pos < MAX_SUGGESTIONS; pos++) {
|
for (int pos = 0; pos < MAX_SUGGESTIONS; pos++) {
|
||||||
final TextView word = (TextView)inflater.inflate(R.layout.candidate_word, null);
|
final TextView word = (TextView)inflater.inflate(R.layout.suggestion_word, null);
|
||||||
word.setTag(pos);
|
word.setTag(pos);
|
||||||
word.setOnClickListener(this);
|
word.setOnClickListener(this);
|
||||||
word.setOnLongClickListener(this);
|
word.setOnLongClickListener(this);
|
||||||
mWords.add(word);
|
mWords.add(word);
|
||||||
final View divider = inflater.inflate(R.layout.candidate_divider, null);
|
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
|
||||||
divider.setTag(pos);
|
divider.setTag(pos);
|
||||||
divider.setOnClickListener(this);
|
divider.setOnClickListener(this);
|
||||||
mDividers.add(divider);
|
mDividers.add(divider);
|
||||||
mInfos.add((TextView)inflater.inflate(R.layout.candidate_info, null));
|
mInfos.add((TextView)inflater.inflate(R.layout.suggestion_info, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
mStripParams = new SuggestionsStripParams(context, attrs, defStyle, mWords, mDividers,
|
mStripParams = new SuggestionsStripParams(context, attrs, defStyle, mWords, mDividers,
|
||||||
@ -534,7 +534,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
if (mSuggestions.size() == 0)
|
if (mSuggestions.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mStripParams.layout(mSuggestions, mCandidatesStrip, mCandidatesPlacer, getWidth());
|
mStripParams.layout(mSuggestions, mSuggestionsStrip, mSuggestionsPlacer, getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
|
private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
|
||||||
@ -632,13 +632,13 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingAddToDictionaryHint() {
|
public boolean isShowingAddToDictionaryHint() {
|
||||||
return mCandidatesStrip.getChildCount() > 0
|
return mSuggestionsStrip.getChildCount() > 0
|
||||||
&& mCandidatesStrip.getChildAt(0) == mStripParams.mWordToSaveView;
|
&& mSuggestionsStrip.getChildAt(0) == mStripParams.mWordToSaveView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddToDictionaryHint(CharSequence word) {
|
public void showAddToDictionaryHint(CharSequence word) {
|
||||||
clear();
|
clear();
|
||||||
mStripParams.layoutAddToDictionaryHint(word, mCandidatesStrip, getWidth());
|
mStripParams.layoutAddToDictionaryHint(word, mSuggestionsStrip, getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dismissAddToDictionaryHint() {
|
public boolean dismissAddToDictionaryHint() {
|
||||||
@ -655,9 +655,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
mShowingAutoCorrectionInverted = false;
|
mShowingAutoCorrectionInverted = false;
|
||||||
mCandidatesPlacer.removeAllViews();
|
mSuggestionsPlacer.removeAllViews();
|
||||||
mCandidatesPlacer.addView(mCandidatesStrip);
|
mSuggestionsPlacer.addView(mSuggestionsStrip);
|
||||||
mCandidatesStrip.removeAllViews();
|
mSuggestionsStrip.removeAllViews();
|
||||||
mMoreSuggestionsWindow.dismiss();
|
mMoreSuggestionsWindow.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,7 +736,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
|||||||
// TODO: Revise how we determine the height
|
// TODO: Revise how we determine the height
|
||||||
final int maxHeight = dm.heightPixels - mKeyboardView.getHeight() - getHeight() * 3;
|
final int maxHeight = dm.heightPixels - mKeyboardView.getHeight() - getHeight() * 3;
|
||||||
final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
|
final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
|
||||||
builder.layout(mSuggestions, params.mCandidateCountInStrip, maxWidth, maxHeight);
|
builder.layout(mSuggestions, params.mSuggestionsCountInStrip, maxWidth, maxHeight);
|
||||||
mMoreSuggestionsView.setKeyboard(builder.build());
|
mMoreSuggestionsView.setKeyboard(builder.build());
|
||||||
container.measure(
|
container.measure(
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
@ -16,15 +16,7 @@
|
|||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.InputMethodInfoCompatWrapper;
|
|
||||||
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
|
||||||
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
|
|
||||||
import com.android.inputmethod.compat.InputTypeCompatUtils;
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -37,6 +29,13 @@ import android.text.format.DateUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
|
import com.android.inputmethod.compat.InputMethodInfoCompatWrapper;
|
||||||
|
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
||||||
|
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
|
||||||
|
import com.android.inputmethod.compat.InputTypeCompatUtils;
|
||||||
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -47,7 +46,6 @@ import java.io.PrintWriter;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -175,21 +173,21 @@ public class Utils {
|
|||||||
// If user selected aggressive auto correction mode, there is no need to use the safety
|
// If user selected aggressive auto correction mode, there is no need to use the safety
|
||||||
// net.
|
// net.
|
||||||
if (suggest.isAggressiveAutoCorrectionMode()) return false;
|
if (suggest.isAggressiveAutoCorrectionMode()) return false;
|
||||||
CharSequence typedWord = suggestions.getWord(0);
|
final CharSequence typedWord = suggestions.getWord(0);
|
||||||
// If the length of typed word is less than MINIMUM_SAFETY_NET_CHAR_LENGTH,
|
// If the length of typed word is less than MINIMUM_SAFETY_NET_CHAR_LENGTH,
|
||||||
// we should not use net because relatively edit distance can be big.
|
// we should not use net because relatively edit distance can be big.
|
||||||
if (typedWord.length() < MINIMUM_SAFETY_NET_CHAR_LENGTH) return false;
|
if (typedWord.length() < MINIMUM_SAFETY_NET_CHAR_LENGTH) return false;
|
||||||
CharSequence candidateWord = suggestions.getWord(1);
|
final CharSequence suggestionWord = suggestions.getWord(1);
|
||||||
final int typedWordLength = typedWord.length();
|
final int typedWordLength = typedWord.length();
|
||||||
final int maxEditDistanceOfNativeDictionary = typedWordLength < 5 ? 2 : typedWordLength / 2;
|
final int maxEditDistanceOfNativeDictionary = typedWordLength < 5 ? 2 : typedWordLength / 2;
|
||||||
final int distance = Utils.editDistance(typedWord, candidateWord);
|
final int distance = Utils.editDistance(typedWord, suggestionWord);
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, "Autocorrected edit distance = " + distance
|
Log.d(TAG, "Autocorrected edit distance = " + distance
|
||||||
+ ", " + maxEditDistanceOfNativeDictionary);
|
+ ", " + maxEditDistanceOfNativeDictionary);
|
||||||
}
|
}
|
||||||
if (distance > maxEditDistanceOfNativeDictionary) {
|
if (distance > maxEditDistanceOfNativeDictionary) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, "Safety net: before = " + typedWord + ", after = " + candidateWord);
|
Log.d(TAG, "Safety net: before = " + typedWord + ", after = " + suggestionWord);
|
||||||
Log.w(TAG, "(Error) The edit distance of this correction exceeds limit. "
|
Log.w(TAG, "(Error) The edit distance of this correction exceeds limit. "
|
||||||
+ "Turning off auto-correction.");
|
+ "Turning off auto-correction.");
|
||||||
}
|
}
|
||||||
@ -717,7 +715,7 @@ public class Utils {
|
|||||||
// Don't cache suggestions.size(), since we may be removing items
|
// Don't cache suggestions.size(), since we may be removing items
|
||||||
while (i < suggestions.size()) {
|
while (i < suggestions.size()) {
|
||||||
final CharSequence cur = suggestions.get(i);
|
final CharSequence cur = suggestions.get(i);
|
||||||
// Compare each candidate with each previous candidate
|
// Compare each suggestion with each previous suggestion
|
||||||
for (int j = 0; j < i; j++) {
|
for (int j = 0; j < i; j++) {
|
||||||
CharSequence previous = suggestions.get(j);
|
CharSequence previous = suggestions.get(j);
|
||||||
if (TextUtils.equals(cur, previous)) {
|
if (TextUtils.equals(cur, previous)) {
|
||||||
|