Merge "Cleanup key drawing code"
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 506 B |
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 657 B |
Before Width: | Height: | Size: 944 B After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 972 B |
Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 505 B |
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 835 B |
Before Width: | Height: | Size: 904 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 831 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 729 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 790 B After Width: | Height: | Size: 358 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1008 B |
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 588 B |
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 960 B |
Before Width: | Height: | Size: 514 B After Width: | Height: | Size: 849 B |
Before Width: | Height: | Size: 687 B After Width: | Height: | Size: 957 B |
Before Width: | Height: | Size: 940 B After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1021 B After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 454 B |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 717 B |
Before Width: | Height: | Size: 726 B After Width: | Height: | Size: 991 B |
Before Width: | Height: | Size: 860 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 926 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 664 B After Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 836 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 886 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 546 B After Width: | Height: | Size: 571 B |
Before Width: | Height: | Size: 735 B After Width: | Height: | Size: 727 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 709 B After Width: | Height: | Size: 1007 B |
Before Width: | Height: | Size: 924 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 529 B After Width: | Height: | Size: 548 B |
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 359 B |
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 860 B |
Before Width: | Height: | Size: 1004 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 921 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Normal keys -->
|
||||
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
|
||||
<item
|
||||
android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" />
|
||||
|
||||
</selector>
|
|
@ -17,5 +17,5 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_light_popup_selected" />
|
||||
<item android:drawable="@drawable/btn_keyboard_key_light_popup_normal" />
|
||||
<item android:drawable="@drawable/transparent" />
|
||||
</selector>
|
||||
|
|
|
@ -17,5 +17,5 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_popup_selected_holo" />
|
||||
<item android:drawable="@drawable/btn_keyboard_key_popup_background_holo" />
|
||||
<item android:drawable="@drawable/transparent" />
|
||||
</selector>
|
||||
|
|
|
@ -24,24 +24,33 @@
|
|||
<fraction name="minKeyboardHeight">45%p</fraction>
|
||||
<!-- key_height + key_bottom_gap = popup_key_height -->
|
||||
<!-- <dimen name="key_height">0.260in</dimen>-->
|
||||
<dimen name="key_bottom_gap">0.020in</dimen>
|
||||
<dimen name="popup_key_height">0.280in</dimen>
|
||||
<dimen name="keyboard_top_padding">0.00in</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.00in</dimen>
|
||||
<dimen name="key_bottom_gap_ics">0.04in</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">0.01in</dimen>
|
||||
<dimen name="keyboard_top_padding_ics">0.03in</dimen>
|
||||
<dimen name="keyboard_bottom_padding_ics">0.00in</dimen>
|
||||
<dimen name="keyboard_horizontal_edges_padding">0.0in</dimen>
|
||||
|
||||
<!-- left or right padding of label alignment -->
|
||||
<dimen name="key_label_horizontal_alignment_padding">8dip</dimen>
|
||||
<dimen name="keyboard_top_padding">0.02in</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.00in</dimen>
|
||||
<dimen name="key_bottom_gap">1.21mm</dimen>
|
||||
<dimen name="key_horizontal_gap">0.35mm</dimen>
|
||||
|
||||
<fraction name="key_letter_ratio">55%</fraction>
|
||||
<fraction name="key_large_letter_ratio">68%</fraction>
|
||||
<fraction name="key_label_ratio">35%</fraction>
|
||||
<fraction name="key_hint_letter_ratio">28%</fraction>
|
||||
<fraction name="key_hint_label_ratio">45%</fraction>
|
||||
<dimen name="key_bottom_gap_stone">1.40mm</dimen>
|
||||
<dimen name="key_horizontal_gap_stone">1.00mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_gb">1.66mm</dimen>
|
||||
<dimen name="key_horizontal_gap_gb">0.86mm</dimen>
|
||||
|
||||
<dimen name="keyboard_top_padding_ics">0.03in</dimen>
|
||||
<dimen name="keyboard_bottom_padding_ics">0.00in</dimen>
|
||||
<dimen name="key_bottom_gap_ics">1.79mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">0.88mm</dimen>
|
||||
|
||||
<!-- left or right padding of label alignment -->
|
||||
<dimen name="key_label_horizontal_padding">8dip</dimen>
|
||||
|
||||
<fraction name="key_letter_ratio">65%</fraction>
|
||||
<fraction name="key_large_letter_ratio">74%</fraction>
|
||||
<fraction name="key_label_ratio">40%</fraction>
|
||||
<fraction name="key_hint_letter_ratio">30%</fraction>
|
||||
<fraction name="key_hint_label_ratio">52%</fraction>
|
||||
<fraction name="key_uppercase_letter_ratio">40%</fraction>
|
||||
<fraction name="key_preview_text_ratio">90%</fraction>
|
||||
<dimen name="key_preview_offset">0.08in</dimen>
|
||||
|
|
|
@ -22,20 +22,28 @@
|
|||
<!-- keyboardHeight = key_height*4 + key_bottom_gap*3 -->
|
||||
<dimen name="keyboardHeight">45.0mm</dimen>
|
||||
<fraction name="minKeyboardHeight">45%p</fraction>
|
||||
<!-- key_height + key_bottom_gap = popup_key_height -->
|
||||
<!-- <dimen name="key_height">14.5mm</dimen> -->
|
||||
<dimen name="key_bottom_gap">1.3mm</dimen>
|
||||
<dimen name="key_horizontal_gap">1.3mm</dimen>
|
||||
|
||||
<dimen name="keyboard_horizontal_edges_padding">0dp</dimen>
|
||||
<dimen name="keyboard_top_padding">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.0mm</dimen>
|
||||
<dimen name="key_bottom_gap_ics">1.3mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">1.3mm</dimen>
|
||||
<dimen name="key_bottom_gap">2.21mm</dimen>
|
||||
<dimen name="key_horizontal_gap">1.97mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_stone">1.96mm</dimen>
|
||||
<dimen name="key_horizontal_gap_stone">2.31mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_gb">2.34mm</dimen>
|
||||
<dimen name="key_horizontal_gap_gb">2.22mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_ics">1.66mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">1.66mm</dimen>
|
||||
<dimen name="keyboard_top_padding_ics">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding_ics">0.0mm</dimen>
|
||||
|
||||
<dimen name="popup_key_height">13.0mm</dimen>
|
||||
|
||||
<!-- left or right padding of label alignment -->
|
||||
<dimen name="key_label_horizontal_alignment_padding">18dip</dimen>
|
||||
<dimen name="key_label_horizontal_padding">18dip</dimen>
|
||||
|
||||
<fraction name="key_letter_ratio">45%</fraction>
|
||||
<fraction name="key_large_letter_ratio">45%</fraction>
|
||||
|
|
|
@ -23,18 +23,27 @@
|
|||
<dimen name="keyboardHeight">48.0mm</dimen>
|
||||
<fraction name="maxKeyboardHeight">50%p</fraction>
|
||||
<fraction name="minKeyboardHeight">-35.0%p</fraction>
|
||||
<!-- key_height + key_bottom_gap = popup_key_height -->
|
||||
<!-- <dimen name="key_height">14.5mm</dimen> -->
|
||||
<dimen name="key_bottom_gap">1.0mm</dimen>
|
||||
<dimen name="key_horizontal_gap">1.0mm</dimen>
|
||||
|
||||
<dimen name="popup_key_height">10.0mm</dimen>
|
||||
|
||||
<dimen name="keyboard_horizontal_edges_padding">0.0mm</dimen>
|
||||
<dimen name="keyboard_top_padding">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.0mm</dimen>
|
||||
<dimen name="key_bottom_gap_ics">1.0mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">1.0mm</dimen>
|
||||
<dimen name="key_bottom_gap">1.80mm</dimen>
|
||||
<dimen name="key_horizontal_gap">1.67mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_stone">1.80mm</dimen>
|
||||
<dimen name="key_horizontal_gap_stone">1.44mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_gb">2.22mm</dimen>
|
||||
<dimen name="key_horizontal_gap_gb">1.90mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_ics">1.37mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">1.53mm</dimen>
|
||||
<dimen name="keyboard_top_padding_ics">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding_ics">0.0mm</dimen>
|
||||
<dimen name="mini_keyboard_key_horizontal_padding">12dip</dimen>
|
||||
|
||||
<dimen name="mini_keyboard_key_horizontal_padding">6dip</dimen>
|
||||
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
|
||||
<!-- popup_key_height x 1.2 -->
|
||||
<dimen name="mini_keyboard_slide_allowance">15.6mm</dimen>
|
||||
|
@ -42,7 +51,9 @@
|
|||
<dimen name="mini_keyboard_vertical_correction">-13.0mm</dimen>
|
||||
|
||||
<!-- left or right padding of label alignment -->
|
||||
<dimen name="key_label_horizontal_alignment_padding">6dip</dimen>
|
||||
<dimen name="key_label_horizontal_padding">6dip</dimen>
|
||||
<dimen name="key_hint_letter_padding">3dp</dimen>
|
||||
<dimen name="key_uppercase_letter_padding">3dp</dimen>
|
||||
|
||||
<fraction name="key_letter_ratio">37%</fraction>
|
||||
<fraction name="key_large_letter_ratio">37%</fraction>
|
||||
|
|
|
@ -22,27 +22,35 @@
|
|||
<!-- keyboardHeight = key_height*4 + key_bottom_gap*3, key_height=14.5mm -->
|
||||
<dimen name="keyboardHeight">58.0mm</dimen>
|
||||
<fraction name="minKeyboardHeight">45%p</fraction>
|
||||
<!-- key_height + key_bottom_gap = popup_key_height -->
|
||||
<!-- <dimen name="key_height">14.5mm</dimen> -->
|
||||
<dimen name="key_bottom_gap">1.6mm</dimen>
|
||||
<dimen name="key_horizontal_gap">1.6mm</dimen>
|
||||
|
||||
<dimen name="keyboard_horizontal_edges_padding">0.0mm</dimen>
|
||||
<dimen name="keyboard_top_padding">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.0mm</dimen>
|
||||
<dimen name="key_bottom_gap_ics">1.6mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">1.6mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap">2.65mm</dimen>
|
||||
<dimen name="key_horizontal_gap">2.34mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_stone">1.96mm</dimen>
|
||||
<dimen name="key_horizontal_gap_stone">2.31mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_gb">2.80mm</dimen>
|
||||
<dimen name="key_horizontal_gap_gb">2.60mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_ics">2.25mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">2.22mm</dimen>
|
||||
<dimen name="keyboard_top_padding_ics">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding_ics">0.0mm</dimen>
|
||||
|
||||
<dimen name="popup_key_height">13.0mm</dimen>
|
||||
<dimen name="keyboard_horizontal_edges_padding">0.0mm</dimen>
|
||||
|
||||
<!-- left or right padding of label alignment -->
|
||||
<dimen name="key_label_horizontal_alignment_padding">18dip</dimen>
|
||||
<dimen name="key_label_horizontal_padding">18dip</dimen>
|
||||
|
||||
<fraction name="key_letter_ratio">38%</fraction>
|
||||
<fraction name="key_large_letter_ratio">38%</fraction>
|
||||
<fraction name="key_label_ratio">26%</fraction>
|
||||
<fraction name="key_letter_ratio">43%</fraction>
|
||||
<fraction name="key_large_letter_ratio">42%</fraction>
|
||||
<fraction name="key_label_ratio">28%</fraction>
|
||||
<fraction name="key_hint_letter_ratio">23%</fraction>
|
||||
<fraction name="key_hint_label_ratio">26%</fraction>
|
||||
<fraction name="key_hint_label_ratio">28%</fraction>
|
||||
<fraction name="key_uppercase_letter_ratio">24%</fraction>
|
||||
<dimen name="key_preview_height">17.0mm</dimen>
|
||||
|
||||
|
|
|
@ -23,19 +23,27 @@
|
|||
<dimen name="keyboardHeight">48.0mm</dimen>
|
||||
<fraction name="maxKeyboardHeight">50%p</fraction>
|
||||
<fraction name="minKeyboardHeight">-35.0%p</fraction>
|
||||
<!-- key_height + key_bottom_gap = popup_key_height -->
|
||||
<!-- <dimen name="key_height">14.5mm</dimen> -->
|
||||
<dimen name="key_bottom_gap">1.1mm</dimen>
|
||||
<dimen name="key_horizontal_gap">1.1mm</dimen>
|
||||
|
||||
<dimen name="keyboard_horizontal_edges_padding">0.0mm</dimen>
|
||||
<dimen name="keyboard_top_padding">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.0mm</dimen>
|
||||
<dimen name="key_bottom_gap_ics">1.1mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">1.1mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap">2.05mm</dimen>
|
||||
<dimen name="key_horizontal_gap">2.11mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_stone">1.80mm</dimen>
|
||||
<dimen name="key_horizontal_gap_stone">1.44mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_gb">2.25mm</dimen>
|
||||
<dimen name="key_horizontal_gap_gb">1.96mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_ics">1.75mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">1.79mm</dimen>
|
||||
<dimen name="keyboard_top_padding_ics">1.1mm</dimen>
|
||||
<dimen name="keyboard_bottom_padding_ics">0.0mm</dimen>
|
||||
|
||||
<dimen name="popup_key_height">10.0mm</dimen>
|
||||
<dimen name="keyboard_horizontal_edges_padding">0.0mm</dimen>
|
||||
<dimen name="mini_keyboard_horizontal_padding_ics">40dip</dimen>
|
||||
|
||||
<dimen name="mini_keyboard_key_horizontal_padding">12dip</dimen>
|
||||
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
|
||||
<!-- popup_key_height x 1.2 -->
|
||||
|
@ -44,14 +52,16 @@
|
|||
<dimen name="mini_keyboard_vertical_correction">-13.0mm</dimen>
|
||||
|
||||
<!-- left or right padding of label alignment -->
|
||||
<dimen name="key_label_horizontal_alignment_padding">6dip</dimen>
|
||||
<dimen name="key_label_horizontal_padding">6dip</dimen>
|
||||
<dimen name="key_hint_letter_padding">3dp</dimen>
|
||||
<dimen name="key_uppercase_letter_padding">3dp</dimen>
|
||||
|
||||
<fraction name="key_letter_ratio">38%</fraction>
|
||||
<fraction name="key_large_letter_ratio">38%</fraction>
|
||||
<fraction name="key_label_ratio">26%</fraction>
|
||||
<fraction name="key_letter_ratio">40%</fraction>
|
||||
<fraction name="key_large_letter_ratio">42%</fraction>
|
||||
<fraction name="key_label_ratio">28%</fraction>
|
||||
<fraction name="key_hint_letter_ratio">23%</fraction>
|
||||
<fraction name="key_hint_label_ratio">26%</fraction>
|
||||
<fraction name="key_uppercase_letter_ratio">25%</fraction>
|
||||
<fraction name="key_hint_label_ratio">28%</fraction>
|
||||
<fraction name="key_uppercase_letter_ratio">26%</fraction>
|
||||
<fraction name="key_preview_text_ratio">50%</fraction>
|
||||
<dimen name="key_preview_height">15.0mm</dimen>
|
||||
<dimen name="key_preview_offset">0.1in</dimen>
|
||||
|
|
|
@ -51,6 +51,12 @@
|
|||
<attr name="keyHintLabelRatio" format="float" />
|
||||
<!-- Size of the text for upper case letter, in the proportion of key height. -->
|
||||
<attr name="keyUppercaseLetterRatio" format="float" />
|
||||
<!-- Horizontal padding of left/right aligned key label to the edge of the key. -->
|
||||
<attr name="keyLabelHorizontalPadding" format="dimension" />
|
||||
<!-- Top and right padding of hint letter to the edge of the key.-->
|
||||
<attr name="keyHintLetterPadding" format="dimension" />
|
||||
<!-- Top and right padding of upper case letter to the edge of the key.-->
|
||||
<attr name="keyUppercaseLetterPadding" format="dimension" />
|
||||
|
||||
<!-- Color to use for the label in a key. -->
|
||||
<attr name="keyTextColor" format="color" />
|
||||
|
@ -199,7 +205,6 @@
|
|||
<!-- This should be aligned with Key.LABEL_OPTION_* -->
|
||||
<flag name="alignLeft" value="0x01" />
|
||||
<flag name="alignRight" value="0x02" />
|
||||
<flag name="alignBottom" value="0x04" />
|
||||
<flag name="alignLeftOfCenter" value="0x08" />
|
||||
<flag name="largeLetter" value="0x10" />
|
||||
<flag name="fontNormal" value="0x20" />
|
||||
|
|
|
@ -19,26 +19,33 @@
|
|||
-->
|
||||
|
||||
<resources>
|
||||
<!-- keyboardHeight = key_height*4 + key_bottom_gap*3, key_height=0.295in -->
|
||||
<!-- keyboardHeight = row_height*4 + key_bottom_gap*3 -->
|
||||
<dimen name="keyboardHeight">1.285in</dimen>
|
||||
<fraction name="maxKeyboardHeight">50%p</fraction>
|
||||
<fraction name="minKeyboardHeight">-61.8%p</fraction>
|
||||
<!-- key_height + key_bottom_gap = popup_key_height -->
|
||||
<!-- <dimen name="key_height">0.295in</dimen> -->
|
||||
<dimen name="key_bottom_gap">0.035in</dimen>
|
||||
<dimen name="key_horizontal_gap">0.000in</dimen>
|
||||
|
||||
<dimen name="popup_key_height">0.330in</dimen>
|
||||
<dimen name="keyboard_top_padding">0.00in</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.06in</dimen>
|
||||
<dimen name="keyboard_horizontal_edges_padding">0.0in</dimen>
|
||||
<dimen name="mini_keyboard_horizontal_padding">16dip</dimen>
|
||||
|
||||
<dimen name="mini_keyboard_horizontal_edges_padding">16dip</dimen>
|
||||
<dimen name="mini_keyboard_key_horizontal_padding">8dip</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_ics">0.06in</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">0.01in</dimen>
|
||||
<dimen name="keyboard_horizontal_edges_padding">0dp</dimen>
|
||||
<dimen name="keyboard_top_padding">0.02in</dimen>
|
||||
<dimen name="keyboard_bottom_padding">0.06in</dimen>
|
||||
<dimen name="key_bottom_gap">2.04mm</dimen>
|
||||
<dimen name="key_horizontal_gap">0.70mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_stone">2.45mm</dimen>
|
||||
<dimen name="key_horizontal_gap_stone">0.90mm</dimen>
|
||||
|
||||
<dimen name="key_bottom_gap_gb">2.12mm</dimen>
|
||||
<dimen name="key_horizontal_gap_gb">1.02mm</dimen>
|
||||
|
||||
<dimen name="keyboard_top_padding_ics">0.03in</dimen>
|
||||
<dimen name="keyboard_bottom_padding_ics">0.06in</dimen>
|
||||
<dimen name="mini_keyboard_horizontal_padding_ics">38dip</dimen>
|
||||
<dimen name="mini_keyboard_horizontal_edges_padding_ics">6dp</dimen>
|
||||
<dimen name="key_bottom_gap_ics">2.37mm</dimen>
|
||||
<dimen name="key_horizontal_gap_ics">0.90mm</dimen>
|
||||
|
||||
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
|
||||
<!-- popup_key_height x 1.2 -->
|
||||
|
@ -49,19 +56,20 @@
|
|||
to user's finger. -->
|
||||
<dimen name="keyboard_vertical_correction">-0.05in</dimen>
|
||||
|
||||
<!-- left or right padding of label alignment -->
|
||||
<dimen name="key_label_horizontal_alignment_padding">4dip</dimen>
|
||||
|
||||
<fraction name="key_letter_ratio">45%</fraction>
|
||||
<fraction name="key_large_letter_ratio">55%</fraction>
|
||||
<fraction name="key_label_ratio">29%</fraction>
|
||||
<fraction name="key_hint_letter_ratio">23%</fraction>
|
||||
<fraction name="key_hint_label_ratio">36%</fraction>
|
||||
<fraction name="key_letter_ratio">55%</fraction>
|
||||
<fraction name="key_large_letter_ratio">65%</fraction>
|
||||
<fraction name="key_label_ratio">34%</fraction>
|
||||
<fraction name="key_hint_letter_ratio">25%</fraction>
|
||||
<fraction name="key_hint_label_ratio">44%</fraction>
|
||||
<fraction name="key_uppercase_letter_ratio">35%</fraction>
|
||||
<fraction name="key_preview_text_ratio">82%</fraction>
|
||||
<dimen name="key_preview_height">80sp</dimen>
|
||||
<dimen name="key_preview_offset">0.1in</dimen>
|
||||
|
||||
<dimen name="key_label_horizontal_padding">4dip</dimen>
|
||||
<dimen name="key_hint_letter_padding">2dp</dimen>
|
||||
<dimen name="key_uppercase_letter_padding">2dp</dimen>
|
||||
|
||||
<dimen name="key_preview_height_ics">80sp</dimen>
|
||||
<dimen name="key_preview_offset_ics">0.05in</dimen>
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<item name="keyHintLabelColor">#E0E0E4E5</item>
|
||||
<item name="keyUppercaseLetterInactivatedColor">#66E0E4E5</item>
|
||||
<item name="keyUppercaseLetterActivatedColor">#CCE0E4E5</item>
|
||||
<item name="keyLabelHorizontalPadding">@dimen/key_label_horizontal_padding</item>
|
||||
<item name="keyHintLetterPadding">@dimen/key_hint_letter_padding</item>
|
||||
<item name="keyUppercaseLetterPadding">@dimen/key_uppercase_letter_padding</item>
|
||||
<item name="keyPreviewLayout">@layout/key_preview</item>
|
||||
<item name="keyPreviewBackground">@drawable/keyboard_key_feedback</item>
|
||||
<item name="keyPreviewLeftBackground">@null</item>
|
||||
|
@ -72,8 +75,8 @@
|
|||
</style>
|
||||
<style name="PopupMiniKeyboardPanelStyle">
|
||||
<item name="android:background">@drawable/keyboard_popup_panel_background</item>
|
||||
<item name="android:paddingLeft">@dimen/mini_keyboard_horizontal_padding</item>
|
||||
<item name="android:paddingRight">@dimen/mini_keyboard_horizontal_padding</item>
|
||||
<item name="android:paddingLeft">@dimen/mini_keyboard_horizontal_edges_padding</item>
|
||||
<item name="android:paddingRight">@dimen/mini_keyboard_horizontal_edges_padding</item>
|
||||
</style>
|
||||
<style name="SuggestionsStripBackgroundStyle">
|
||||
<item name="android:background">@drawable/keyboard_suggest_strip</item>
|
||||
|
@ -99,8 +102,8 @@
|
|||
</style>
|
||||
<!-- Theme "Stone" -->
|
||||
<style name="Keyboard.Stone" parent="Keyboard">
|
||||
<item name="horizontalGap">@dimen/key_horizontal_gap</item>
|
||||
<item name="verticalGap">@dimen/key_bottom_gap</item>
|
||||
<item name="horizontalGap">@dimen/key_horizontal_gap_stone</item>
|
||||
<item name="verticalGap">@dimen/key_bottom_gap_stone</item>
|
||||
</style>
|
||||
<style name="LatinKeyboard.Stone" parent="LatinKeyboard">
|
||||
<item name="spacebarTextColor">#FF000000</item>
|
||||
|
@ -126,6 +129,10 @@
|
|||
<item name="keyTextStyle">bold</item>
|
||||
</style>
|
||||
<!-- Theme "Gingerbread" -->
|
||||
<style name="Keyboard.Gingerbread" parent="Keyboard">
|
||||
<item name="horizontalGap">@dimen/key_horizontal_gap_gb</item>
|
||||
<item name="verticalGap">@dimen/key_bottom_gap_gb</item>
|
||||
</style>
|
||||
<style name="KeyboardView.Gingerbread" parent="KeyboardView">
|
||||
<item name="android:background">@drawable/keyboard_dark_background</item>
|
||||
<item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item>
|
||||
|
@ -168,9 +175,9 @@
|
|||
<item name="keyBackground">@drawable/btn_keyboard_key_popup_ics</item>
|
||||
</style>
|
||||
<style name="PopupMiniKeyboardPanelStyle.IceCreamSandwich">
|
||||
<item name="android:background">@drawable/keyboard_popup_panel_background_holo</item>
|
||||
<item name="android:paddingLeft">@dimen/mini_keyboard_horizontal_padding_ics</item>
|
||||
<item name="android:paddingRight">@dimen/mini_keyboard_horizontal_padding_ics</item>
|
||||
<item name="android:background">@drawable/btn_keyboard_key_popup_background_holo</item>
|
||||
<item name="android:paddingLeft">@dimen/mini_keyboard_horizontal_edges_padding_ics</item>
|
||||
<item name="android:paddingRight">@dimen/mini_keyboard_horizontal_edges_padding_ics</item>
|
||||
</style>
|
||||
<style name="SuggestionsStripBackgroundStyle.IceCreamSandwich">
|
||||
<item name="android:background">@drawable/keyboard_suggest_strip_holo</item>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
<resources>
|
||||
<style name="KeyboardTheme.Gingerbread" parent="KeyboardIcons">
|
||||
<item name="keyboardStyle">@style/Keyboard</item>
|
||||
<item name="keyboardStyle">@style/Keyboard.Gingerbread</item>
|
||||
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
||||
<item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
|
||||
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Gingerbread</item>
|
||||
|
|
|
@ -52,7 +52,6 @@ public class Key {
|
|||
public final int mLabelOption;
|
||||
public static final int LABEL_OPTION_ALIGN_LEFT = 0x01;
|
||||
public static final int LABEL_OPTION_ALIGN_RIGHT = 0x02;
|
||||
public static final int LABEL_OPTION_ALIGN_BOTTOM = 0x04;
|
||||
public static final int LABEL_OPTION_ALIGN_LEFT_OF_CENTER = 0x08;
|
||||
private static final int LABEL_OPTION_LARGE_LETTER = 0x10;
|
||||
private static final int LABEL_OPTION_FONT_NORMAL = 0x20;
|
||||
|
@ -276,9 +275,9 @@ public class Key {
|
|||
|
||||
final KeyboardIconsSet iconsSet = mKeyboard.mIconsSet;
|
||||
mVisualInsetsLeft = KeyboardParser.getDimensionOrFraction(keyAttr,
|
||||
R.styleable.Keyboard_Key_visualInsetsLeft, mKeyboard.getDisplayHeight(), 0);
|
||||
R.styleable.Keyboard_Key_visualInsetsLeft, keyboardWidth, 0);
|
||||
mVisualInsetsRight = KeyboardParser.getDimensionOrFraction(keyAttr,
|
||||
R.styleable.Keyboard_Key_visualInsetsRight, mKeyboard.getDisplayHeight(), 0);
|
||||
R.styleable.Keyboard_Key_visualInsetsRight, keyboardWidth, 0);
|
||||
mPreviewIcon = iconsSet.getIcon(style.getInt(
|
||||
keyAttr, R.styleable.Keyboard_Key_keyIconPreview,
|
||||
KeyboardIconsSet.ICON_UNDEFINED));
|
||||
|
@ -314,6 +313,10 @@ public class Key {
|
|||
}
|
||||
}
|
||||
|
||||
public CharSequence getCaseAdjustedLabel() {
|
||||
return mKeyboard.adjustLabelCase(mLabel);
|
||||
}
|
||||
|
||||
public Typeface selectTypeface(Typeface defaultTypeface) {
|
||||
// TODO: Handle "bold" here too?
|
||||
if ((mLabelOption & LABEL_OPTION_FONT_NORMAL) != 0) {
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard;
|
|||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||
|
@ -345,15 +346,23 @@ public class Keyboard {
|
|||
}
|
||||
|
||||
public boolean isAlphaKeyboard() {
|
||||
return mId != null && mId.isAlphabetKeyboard();
|
||||
return mId.isAlphabetKeyboard();
|
||||
}
|
||||
|
||||
public boolean isPhoneKeyboard() {
|
||||
return mId != null && mId.isPhoneKeyboard();
|
||||
return mId.isPhoneKeyboard();
|
||||
}
|
||||
|
||||
public boolean isNumberKeyboard() {
|
||||
return mId != null && mId.isNumberKeyboard();
|
||||
return mId.isNumberKeyboard();
|
||||
}
|
||||
|
||||
public CharSequence adjustLabelCase(CharSequence label) {
|
||||
if (isShiftedOrShiftLocked() && !TextUtils.isEmpty(label) && label.length() < 3
|
||||
&& Character.isLowerCase(label.charAt(0))) {
|
||||
return label.toString().toUpperCase(mId.mLocale);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
// TODO: Move this function to ProximityInfo and make this private.
|
||||
|
|
|
@ -42,6 +42,8 @@ public class KeyboardId {
|
|||
public static final int F2KEY_MODE_SHORTCUT_IME = 2;
|
||||
public static final int F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS = 3;
|
||||
|
||||
private static final int MINI_KEYBOARD_ID_MARKER = -1;
|
||||
|
||||
public final Locale mLocale;
|
||||
public final int mOrientation;
|
||||
public final int mWidth;
|
||||
|
@ -112,6 +114,11 @@ public class KeyboardId {
|
|||
});
|
||||
}
|
||||
|
||||
public KeyboardId cloneAsMiniKeyboard() {
|
||||
return new KeyboardId("mini popup keyboard", MINI_KEYBOARD_ID_MARKER, mLocale, mOrientation,
|
||||
mWidth, mMode, mAttribute, false, F2KEY_MODE_NONE, false, false, false, false);
|
||||
}
|
||||
|
||||
public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) {
|
||||
return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mAttribute,
|
||||
mHasSettingsKey, mF2KeyMode, mClobberSettingsKey, mVoiceKeyEnabled, mHasVoiceKey,
|
||||
|
@ -130,6 +137,10 @@ public class KeyboardId {
|
|||
return mXmlId;
|
||||
}
|
||||
|
||||
public boolean isMiniKeyboard() {
|
||||
return mXmlId == MINI_KEYBOARD_ID_MARKER;
|
||||
}
|
||||
|
||||
public boolean isAlphabetKeyboard() {
|
||||
return mXmlId == R.xml.kbd_qwerty;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ import java.util.WeakHashMap;
|
|||
* @attr ref R.styleable#KeyboardView_keyHintLetterRatio
|
||||
* @attr ref R.styleable#KeyboardView_keyUppercaseLetterRatio
|
||||
* @attr ref R.styleable#KeyboardView_keyHintLabelRatio
|
||||
* @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding
|
||||
* @attr ref R.styleable#KeyboardView_keyHintLetterPadding
|
||||
* @attr ref R.styleable#KeyboardView_keyUppercaseLetterPadding
|
||||
* @attr ref R.styleable#KeyboardView_keyTextStyle
|
||||
* @attr ref R.styleable#KeyboardView_keyPreviewLayout
|
||||
* @attr ref R.styleable#KeyboardView_keyPreviewTextRatio
|
||||
|
@ -89,7 +92,6 @@ import java.util.WeakHashMap;
|
|||
*/
|
||||
public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||
private static final String TAG = KeyboardView.class.getSimpleName();
|
||||
private static final boolean DEBUG_SHOW_ALIGN = LatinImeLogger.sVISUALDEBUG;
|
||||
private static final boolean DEBUG_KEYBOARD_GRID = false;
|
||||
|
||||
private static final boolean ENABLE_CAPSLOCK_BY_LONGPRESS = true;
|
||||
|
@ -102,55 +104,25 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
|
||||
|
||||
// XML attribute
|
||||
private final int mKeyTextColor;
|
||||
private final int mKeyTextInactivatedColor;
|
||||
private final Typeface mKeyTextStyle;
|
||||
private final float mKeyLetterRatio;
|
||||
private final float mKeyLargeLetterRatio;
|
||||
private final float mKeyLabelRatio;
|
||||
private final float mKeyHintLetterRatio;
|
||||
private final float mKeyUppercaseLetterRatio;
|
||||
private final float mKeyHintLabelRatio;
|
||||
private final int mShadowColor;
|
||||
private final float mShadowRadius;
|
||||
private final Drawable mKeyBackground;
|
||||
private final float mBackgroundDimAmount;
|
||||
private final float mKeyHysteresisDistance;
|
||||
private final float mVerticalCorrection;
|
||||
private final Drawable mPreviewBackground;
|
||||
private final Drawable mPreviewLeftBackground;
|
||||
private final Drawable mPreviewRightBackground;
|
||||
private final Drawable mPreviewSpacebarBackground;
|
||||
private final int mPreviewTextColor;
|
||||
private final float mPreviewTextRatio;
|
||||
private final int mPreviewOffset;
|
||||
private final int mPreviewHeight;
|
||||
private final int mPopupLayout;
|
||||
private final int mKeyHintLetterColor;
|
||||
private final int mKeyHintLabelColor;
|
||||
private final int mKeyUppercaseLetterInactivatedColor;
|
||||
private final int mKeyUppercaseLetterActivatedColor;
|
||||
|
||||
// HORIZONTAL ELLIPSIS "...", character for popup hint.
|
||||
private static final String POPUP_HINT_CHAR = "\u2026";
|
||||
|
||||
// Main keyboard
|
||||
private Keyboard mKeyboard;
|
||||
private int mKeyLetterSize;
|
||||
private int mKeyLargeLetterSize;
|
||||
private int mKeyLabelSize;
|
||||
private int mKeyHintLetterSize;
|
||||
private int mKeyUppercaseLetterSize;
|
||||
private int mKeyHintLabelSize;
|
||||
private final KeyDrawParams mKeyDrawParams;
|
||||
|
||||
// Key preview
|
||||
private final KeyPreviewDrawParams mKeyPreviewDrawParams;
|
||||
private final TextView mPreviewText;
|
||||
private int mPreviewTextSize;
|
||||
private boolean mShowKeyPreviewPopup = true;
|
||||
private final int mDelayBeforePreview;
|
||||
private int mDelayAfterPreview;
|
||||
private ViewGroup mPreviewPlacer;
|
||||
private final int[] mCoordinates = new int[2];
|
||||
|
||||
// Mini keyboard
|
||||
private PopupWindow mPopupWindow;
|
||||
|
@ -194,16 +166,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
/** The canvas for the above mutable keyboard bitmap */
|
||||
private Canvas mCanvas;
|
||||
private final Paint mPaint = new Paint();
|
||||
private final Rect mPadding = new Rect();
|
||||
// This map caches key label text height in pixel as value and key label text size as map key.
|
||||
private final HashMap<Integer, Integer> mTextHeightCache = new HashMap<Integer, Integer>();
|
||||
private static final HashMap<Integer, Float> sTextHeightCache =
|
||||
new HashMap<Integer, Float>();
|
||||
// This map caches key label text width in pixel as value and key label text size as map key.
|
||||
private final HashMap<Integer, Integer> mTextWidthCache = new HashMap<Integer, Integer>();
|
||||
// Distance from horizontal center of the key, proportional to key label text height and width.
|
||||
private static final float KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR_CENTER = 0.45f;
|
||||
private static final float KEY_LABEL_VERTICAL_PADDING_FACTOR = 1.60f;
|
||||
private static final HashMap<Integer, Float> sTextWidthCache =
|
||||
new HashMap<Integer, Float>();
|
||||
private static final String KEY_LABEL_REFERENCE_CHAR = "M";
|
||||
private final int mKeyLabelHorizontalPadding;
|
||||
|
||||
private static final int MEASURESPEC_UNSPECIFIED = MeasureSpec.makeMeasureSpec(
|
||||
0, MeasureSpec.UNSPECIFIED);
|
||||
|
@ -334,37 +303,39 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
}
|
||||
}
|
||||
|
||||
public KeyboardView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.keyboardViewStyle);
|
||||
}
|
||||
private static class KeyDrawParams {
|
||||
// XML attributes
|
||||
public final int mKeyTextColor;
|
||||
public final int mKeyTextInactivatedColor;
|
||||
public final Typeface mKeyTextStyle;
|
||||
public final float mKeyLabelHorizontalPadding;
|
||||
public final float mKeyHintLetterPadding;
|
||||
public final float mKeyUppercaseLetterPadding;
|
||||
public final int mShadowColor;
|
||||
public final float mShadowRadius;
|
||||
public final Drawable mKeyBackground;
|
||||
public final int mKeyHintLetterColor;
|
||||
public final int mKeyHintLabelColor;
|
||||
public final int mKeyUppercaseLetterInactivatedColor;
|
||||
public final int mKeyUppercaseLetterActivatedColor;
|
||||
|
||||
public KeyboardView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
private final float mKeyLetterRatio;
|
||||
private final float mKeyLargeLetterRatio;
|
||||
private final float mKeyLabelRatio;
|
||||
private final float mKeyHintLetterRatio;
|
||||
private final float mKeyUppercaseLetterRatio;
|
||||
private final float mKeyHintLabelRatio;
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
|
||||
public final Rect mPadding = new Rect();
|
||||
public int mKeyLetterSize;
|
||||
public int mKeyLargeLetterSize;
|
||||
public int mKeyLabelSize;
|
||||
public int mKeyHintLetterSize;
|
||||
public int mKeyUppercaseLetterSize;
|
||||
public int mKeyHintLabelSize;
|
||||
|
||||
public KeyDrawParams(TypedArray a) {
|
||||
mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
|
||||
mKeyHysteresisDistance = a.getDimensionPixelOffset(
|
||||
R.styleable.KeyboardView_keyHysteresisDistance, 0);
|
||||
mVerticalCorrection = a.getDimensionPixelOffset(
|
||||
R.styleable.KeyboardView_verticalCorrection, 0);
|
||||
mPreviewTextColor = a.getColor(R.styleable.KeyboardView_keyPreviewTextColor, 0);
|
||||
final int previewLayout = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0);
|
||||
if (previewLayout != 0) {
|
||||
mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null);
|
||||
mPreviewText.setTextColor(mPreviewTextColor);
|
||||
} else {
|
||||
mPreviewText = null;
|
||||
mShowKeyPreviewPopup = false;
|
||||
}
|
||||
mPreviewBackground = a.getDrawable(R.styleable.KeyboardView_keyPreviewBackground);
|
||||
mPreviewLeftBackground = a.getDrawable(R.styleable.KeyboardView_keyPreviewLeftBackground);
|
||||
mPreviewRightBackground = a.getDrawable(R.styleable.KeyboardView_keyPreviewRightBackground);
|
||||
mPreviewSpacebarBackground = a.getDrawable(
|
||||
R.styleable.KeyboardView_keyPreviewSpacebarBackground);
|
||||
mPreviewOffset = a.getDimensionPixelOffset(R.styleable.KeyboardView_keyPreviewOffset, 0);
|
||||
mPreviewHeight = a.getDimensionPixelSize(R.styleable.KeyboardView_keyPreviewHeight, 80);
|
||||
mKeyLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLetterRatio);
|
||||
mKeyLargeLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLargeLetterRatio);
|
||||
mKeyLabelRatio = getRatio(a, R.styleable.KeyboardView_keyLabelRatio);
|
||||
|
@ -372,7 +343,12 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
mKeyUppercaseLetterRatio = getRatio(a,
|
||||
R.styleable.KeyboardView_keyUppercaseLetterRatio);
|
||||
mKeyHintLabelRatio = getRatio(a, R.styleable.KeyboardView_keyHintLabelRatio);
|
||||
mPreviewTextRatio = getRatio(a, R.styleable.KeyboardView_keyPreviewTextRatio);
|
||||
mKeyLabelHorizontalPadding = a.getDimension(
|
||||
R.styleable.KeyboardView_keyLabelHorizontalPadding, 0);
|
||||
mKeyHintLetterPadding = a.getDimension(
|
||||
R.styleable.KeyboardView_keyHintLetterPadding, 0);
|
||||
mKeyUppercaseLetterPadding = a.getDimension(
|
||||
R.styleable.KeyboardView_keyUppercaseLetterPadding, 0);
|
||||
mKeyTextColor = a.getColor(R.styleable.KeyboardView_keyTextColor, 0xFF000000);
|
||||
mKeyTextInactivatedColor = a.getColor(
|
||||
R.styleable.KeyboardView_keyTextInactivatedColor, 0xFF000000);
|
||||
|
@ -384,9 +360,89 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
R.styleable.KeyboardView_keyUppercaseLetterActivatedColor, 0);
|
||||
mKeyTextStyle = Typeface.defaultFromStyle(
|
||||
a.getInt(R.styleable.KeyboardView_keyTextStyle, Typeface.NORMAL));
|
||||
mPopupLayout = a.getResourceId(R.styleable.KeyboardView_popupLayout, 0);
|
||||
mShadowColor = a.getColor(R.styleable.KeyboardView_shadowColor, 0);
|
||||
mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f);
|
||||
|
||||
mKeyBackground.getPadding(mPadding);
|
||||
}
|
||||
|
||||
public void updateKeyHeight(int keyHeight) {
|
||||
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
|
||||
mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
|
||||
mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
|
||||
mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio);
|
||||
mKeyUppercaseLetterSize = (int)(keyHeight * mKeyUppercaseLetterRatio);
|
||||
mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
|
||||
}
|
||||
}
|
||||
|
||||
private static class KeyPreviewDrawParams {
|
||||
// XML attributes.
|
||||
public final Drawable mPreviewBackground;
|
||||
public final Drawable mPreviewLeftBackground;
|
||||
public final Drawable mPreviewRightBackground;
|
||||
public final Drawable mPreviewSpacebarBackground;
|
||||
public final int mPreviewTextColor;
|
||||
public final int mPreviewOffset;
|
||||
public final int mPreviewHeight;
|
||||
public final Typeface mKeyTextStyle;
|
||||
|
||||
private final float mPreviewTextRatio;
|
||||
private final float mKeyLetterRatio;
|
||||
|
||||
public int mPreviewTextSize;
|
||||
public int mKeyLetterSize;
|
||||
public final int[] mCoordinates = new int[2];
|
||||
|
||||
public KeyPreviewDrawParams(TypedArray a, KeyDrawParams keyDrawParams) {
|
||||
mPreviewBackground = a.getDrawable(R.styleable.KeyboardView_keyPreviewBackground);
|
||||
mPreviewLeftBackground = a.getDrawable(
|
||||
R.styleable.KeyboardView_keyPreviewLeftBackground);
|
||||
mPreviewRightBackground = a.getDrawable(
|
||||
R.styleable.KeyboardView_keyPreviewRightBackground);
|
||||
mPreviewSpacebarBackground = a.getDrawable(
|
||||
R.styleable.KeyboardView_keyPreviewSpacebarBackground);
|
||||
mPreviewOffset = a.getDimensionPixelOffset(
|
||||
R.styleable.KeyboardView_keyPreviewOffset, 0);
|
||||
mPreviewHeight = a.getDimensionPixelSize(
|
||||
R.styleable.KeyboardView_keyPreviewHeight, 80);
|
||||
mPreviewTextRatio = getRatio(a, R.styleable.KeyboardView_keyPreviewTextRatio);
|
||||
mPreviewTextColor = a.getColor(R.styleable.KeyboardView_keyPreviewTextColor, 0);
|
||||
|
||||
mKeyLetterRatio = keyDrawParams.mKeyLetterRatio;
|
||||
mKeyTextStyle = keyDrawParams.mKeyTextStyle;
|
||||
}
|
||||
|
||||
public void updateKeyHeight(int keyHeight) {
|
||||
mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio);
|
||||
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
|
||||
}
|
||||
}
|
||||
|
||||
public KeyboardView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, R.attr.keyboardViewStyle);
|
||||
}
|
||||
|
||||
public KeyboardView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
|
||||
|
||||
mKeyDrawParams = new KeyDrawParams(a);
|
||||
mKeyPreviewDrawParams = new KeyPreviewDrawParams(a, mKeyDrawParams);
|
||||
mKeyHysteresisDistance = a.getDimensionPixelOffset(
|
||||
R.styleable.KeyboardView_keyHysteresisDistance, 0);
|
||||
mVerticalCorrection = a.getDimensionPixelOffset(
|
||||
R.styleable.KeyboardView_verticalCorrection, 0);
|
||||
final int previewLayout = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0);
|
||||
if (previewLayout != 0) {
|
||||
mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null);
|
||||
} else {
|
||||
mPreviewText = null;
|
||||
mShowKeyPreviewPopup = false;
|
||||
}
|
||||
mPopupLayout = a.getResourceId(R.styleable.KeyboardView_popupLayout, 0);
|
||||
// TODO: Use Theme (android.R.styleable.Theme_backgroundDimAmount)
|
||||
mBackgroundDimAmount = a.getFloat(R.styleable.KeyboardView_backgroundDimAmount, 0.5f);
|
||||
a.recycle();
|
||||
|
@ -395,15 +451,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
|
||||
mDelayBeforePreview = res.getInteger(R.integer.config_delay_before_preview);
|
||||
mDelayAfterPreview = res.getInteger(R.integer.config_delay_after_preview);
|
||||
mKeyLabelHorizontalPadding = (int)res.getDimension(
|
||||
R.dimen.key_label_horizontal_alignment_padding);
|
||||
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setTextAlign(Align.CENTER);
|
||||
mPaint.setAlpha(255);
|
||||
|
||||
mKeyBackground.getPadding(mPadding);
|
||||
|
||||
mSwipeThreshold = (int) (500 * res.getDisplayMetrics().density);
|
||||
// TODO: Refer to frameworks/base/core/res/res/values/config.xml
|
||||
mDisambiguateSwipe = res.getBoolean(R.bool.config_swipeDisambiguation);
|
||||
|
@ -539,14 +591,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
mKeyDetector.setProximityThreshold(keyboard.getMostCommonKeyWidth());
|
||||
mPopupPanelCache.clear();
|
||||
final int keyHeight = keyboard.getRowHeight() - keyboard.getVerticalGap();
|
||||
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
|
||||
mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
|
||||
mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
|
||||
mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio);
|
||||
mKeyUppercaseLetterSize = (int)(
|
||||
keyHeight * mKeyUppercaseLetterRatio);
|
||||
mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
|
||||
mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio);
|
||||
mKeyDrawParams.updateKeyHeight(keyHeight);
|
||||
mKeyPreviewDrawParams.updateKeyHeight(keyHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -605,14 +651,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
return mKeyDetector.isProximityCorrectionEnabled();
|
||||
}
|
||||
|
||||
protected CharSequence adjustCase(CharSequence label) {
|
||||
if (mKeyboard.isShiftedOrShiftLocked() && label != null && label.length() < 3
|
||||
&& Character.isLowerCase(label.charAt(0))) {
|
||||
return label.toString().toUpperCase(mKeyboard.mId.mLocale);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// Round up a little
|
||||
|
@ -663,13 +701,24 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
|
||||
if (mKeyboard == null) return;
|
||||
|
||||
final boolean isManualTemporaryUpperCase = mKeyboard.isManualTemporaryUpperCase();
|
||||
final KeyDrawParams params = mKeyDrawParams;
|
||||
if (mInvalidatedKey != null && mInvalidatedKeyRect.contains(mDirtyRect)) {
|
||||
// Draw a single key.
|
||||
onBufferDrawKey(canvas, mInvalidatedKey);
|
||||
final int keyDrawX = mInvalidatedKey.mX + mInvalidatedKey.mVisualInsetsLeft
|
||||
+ getPaddingLeft();
|
||||
final int keyDrawY = mInvalidatedKey.mY + getPaddingTop();
|
||||
canvas.translate(keyDrawX, keyDrawY);
|
||||
onBufferDrawKey(mInvalidatedKey, canvas, mPaint, params, isManualTemporaryUpperCase);
|
||||
canvas.translate(-keyDrawX, -keyDrawY);
|
||||
} else {
|
||||
// Draw all keys.
|
||||
for (final Key key : mKeyboard.getKeys()) {
|
||||
onBufferDrawKey(canvas, key);
|
||||
final int keyDrawX = key.mX + key.mVisualInsetsLeft + getPaddingLeft();
|
||||
final int keyDrawY = key.mY + getPaddingTop();
|
||||
canvas.translate(keyDrawX, keyDrawY);
|
||||
onBufferDrawKey(key, canvas, mPaint, params, isManualTemporaryUpperCase);
|
||||
canvas.translate(-keyDrawX, -keyDrawY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -702,58 +751,61 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
mDirtyRect.setEmpty();
|
||||
}
|
||||
|
||||
private void onBufferDrawKey(final Canvas canvas, final Key key) {
|
||||
final Paint paint = mPaint;
|
||||
final Drawable keyBackground = mKeyBackground;
|
||||
final Rect padding = mPadding;
|
||||
final int kbdPaddingLeft = getPaddingLeft();
|
||||
final int kbdPaddingTop = getPaddingTop();
|
||||
final int keyDrawX = key.mX + key.mVisualInsetsLeft;
|
||||
final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
|
||||
final int centerX = (keyDrawWidth + padding.left - padding.right) / 2;
|
||||
final float centerY = (key.mHeight + padding.top - padding.bottom) / 2;
|
||||
final int rowHeight = padding.top + key.mHeight;
|
||||
final boolean isManualTemporaryUpperCase = mKeyboard.isManualTemporaryUpperCase();
|
||||
|
||||
canvas.translate(keyDrawX + kbdPaddingLeft, key.mY + kbdPaddingTop);
|
||||
|
||||
private static void onBufferDrawKey(final Key key, final Canvas canvas, Paint paint,
|
||||
KeyDrawParams params, boolean isManualTemporaryUpperCase) {
|
||||
final boolean debugShowAlign = LatinImeLogger.sVISUALDEBUG;
|
||||
// Draw key background.
|
||||
final int bgWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight
|
||||
+ params.mPadding.left + params.mPadding.right;
|
||||
final int bgHeight = key.mHeight + params.mPadding.top + params.mPadding.bottom;
|
||||
final int bgX = -params.mPadding.left;
|
||||
final int bgY = -params.mPadding.top;
|
||||
final int[] drawableState = key.getCurrentDrawableState();
|
||||
keyBackground.setState(drawableState);
|
||||
final Rect bounds = keyBackground.getBounds();
|
||||
if (keyDrawWidth != bounds.right || key.mHeight != bounds.bottom) {
|
||||
keyBackground.setBounds(0, 0, keyDrawWidth, key.mHeight);
|
||||
final Drawable background = params.mKeyBackground;
|
||||
background.setState(drawableState);
|
||||
final Rect bounds = background.getBounds();
|
||||
if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
|
||||
background.setBounds(0, 0, bgWidth, bgHeight);
|
||||
}
|
||||
canvas.translate(bgX, bgY);
|
||||
background.draw(canvas);
|
||||
if (debugShowAlign) {
|
||||
drawRectangle(canvas, 0, 0, bgWidth, bgHeight, 0x80c00000, new Paint());
|
||||
}
|
||||
canvas.translate(-bgX, -bgY);
|
||||
|
||||
// Draw key top visuals.
|
||||
final int keyWidth = key.mWidth;
|
||||
final int keyHeight = key.mHeight;
|
||||
final float centerX = keyWidth * 0.5f;
|
||||
final float centerY = keyHeight * 0.5f;
|
||||
|
||||
if (debugShowAlign) {
|
||||
drawRectangle(canvas, 0, 0, keyWidth, keyHeight, 0x800000c0, new Paint());
|
||||
}
|
||||
keyBackground.draw(canvas);
|
||||
|
||||
// Draw key label.
|
||||
int positionX = centerX;
|
||||
float positionX = centerX;
|
||||
if (key.mLabel != null) {
|
||||
// Switch the character to uppercase if shift is pressed
|
||||
final CharSequence label = key.mLabel == null ? null : adjustCase(key.mLabel);
|
||||
final CharSequence label = key.getCaseAdjustedLabel();
|
||||
// For characters, use large font. For labels like "Done", use smaller font.
|
||||
paint.setTypeface(key.selectTypeface(mKeyTextStyle));
|
||||
final int labelSize = key.selectTextSize(mKeyLetterSize, mKeyLargeLetterSize,
|
||||
mKeyLabelSize, mKeyHintLabelSize);
|
||||
paint.setTypeface(key.selectTypeface(params.mKeyTextStyle));
|
||||
final int labelSize = key.selectTextSize(params.mKeyLetterSize,
|
||||
params.mKeyLargeLetterSize, params.mKeyLabelSize, params.mKeyHintLabelSize);
|
||||
paint.setTextSize(labelSize);
|
||||
final int labelCharHeight = getLabelCharHeight(paint);
|
||||
final int labelCharWidth = getLabelCharWidth(paint);
|
||||
final float labelCharHeight = getCharHeight(paint);
|
||||
final float labelCharWidth = getCharWidth(paint);
|
||||
|
||||
// Vertical label text alignment.
|
||||
final float baseline;
|
||||
// TODO: Generalize the following calculations.
|
||||
if ((key.mLabelOption & Key.LABEL_OPTION_ALIGN_BOTTOM) != 0) {
|
||||
baseline = key.mHeight - labelCharHeight * KEY_LABEL_VERTICAL_PADDING_FACTOR;
|
||||
} else { // Align center
|
||||
baseline = centerY + labelCharHeight * KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR_CENTER;
|
||||
}
|
||||
final float baseline = centerY + labelCharHeight / 2;
|
||||
|
||||
// Horizontal label text alignment
|
||||
if ((key.mLabelOption & Key.LABEL_OPTION_ALIGN_LEFT) != 0) {
|
||||
positionX = padding.left + mKeyLabelHorizontalPadding;
|
||||
positionX = (int)params.mKeyLabelHorizontalPadding;
|
||||
paint.setTextAlign(Align.LEFT);
|
||||
} else if ((key.mLabelOption & Key.LABEL_OPTION_ALIGN_RIGHT) != 0) {
|
||||
positionX = keyDrawWidth - mKeyLabelHorizontalPadding - padding.right;
|
||||
positionX = keyWidth - (int)params.mKeyLabelHorizontalPadding;
|
||||
paint.setTextAlign(Align.RIGHT);
|
||||
} else if ((key.mLabelOption & Key.LABEL_OPTION_ALIGN_LEFT_OF_CENTER) != 0) {
|
||||
// TODO: Parameterise this?
|
||||
|
@ -763,20 +815,15 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
positionX = centerX;
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
}
|
||||
if (DEBUG_SHOW_ALIGN) {
|
||||
final Paint line = new Paint();
|
||||
drawHorizontalLine(canvas, (int)baseline, keyDrawWidth, 0xc0008000, line);
|
||||
drawVerticalLine(canvas, positionX, rowHeight, 0xc0800080, line);
|
||||
}
|
||||
|
||||
if (key.hasUppercaseLetter() && isManualTemporaryUpperCase) {
|
||||
paint.setColor(mKeyTextInactivatedColor);
|
||||
paint.setColor(params.mKeyTextInactivatedColor);
|
||||
} else {
|
||||
paint.setColor(mKeyTextColor);
|
||||
paint.setColor(params.mKeyTextColor);
|
||||
}
|
||||
if (key.isEnabled()) {
|
||||
// Set a drop shadow for the text
|
||||
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
|
||||
paint.setShadowLayer(params.mShadowRadius, 0, 0, params.mShadowColor);
|
||||
} else {
|
||||
// Make label invisible
|
||||
paint.setColor(Color.TRANSPARENT);
|
||||
|
@ -785,6 +832,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
// Turn off drop shadow
|
||||
paint.setShadowLayer(0, 0, 0, 0);
|
||||
|
||||
if (debugShowAlign) {
|
||||
final Paint line = new Paint();
|
||||
drawHorizontalLine(canvas, baseline, keyWidth, 0xc0008000, line);
|
||||
drawVerticalLine(canvas, positionX, keyHeight, 0xc0800080, line);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw hint label.
|
||||
|
@ -792,31 +844,44 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
final CharSequence hint = key.mHintLabel;
|
||||
final int hintColor;
|
||||
final int hintSize;
|
||||
if (key.hasUppercaseLetter()) {
|
||||
hintColor = isManualTemporaryUpperCase ? mKeyUppercaseLetterActivatedColor
|
||||
: mKeyUppercaseLetterInactivatedColor;
|
||||
hintSize = mKeyUppercaseLetterSize;
|
||||
} else if (key.hasHintLabel()) {
|
||||
hintColor = mKeyHintLabelColor;
|
||||
hintSize = mKeyHintLabelSize;
|
||||
if (key.hasHintLabel()) {
|
||||
hintColor = params.mKeyHintLabelColor;
|
||||
hintSize = params.mKeyHintLabelSize;
|
||||
paint.setTypeface(Typeface.DEFAULT);
|
||||
} else {
|
||||
hintColor = mKeyHintLetterColor;
|
||||
hintSize = mKeyHintLetterSize;
|
||||
} else if (key.hasUppercaseLetter()) {
|
||||
hintColor = isManualTemporaryUpperCase
|
||||
? params.mKeyUppercaseLetterActivatedColor
|
||||
: params.mKeyUppercaseLetterInactivatedColor;
|
||||
hintSize = params.mKeyUppercaseLetterSize;
|
||||
} else { // key.hasHintLetter()
|
||||
hintColor = params.mKeyHintLetterColor;
|
||||
hintSize = params.mKeyHintLetterSize;
|
||||
}
|
||||
paint.setColor(hintColor);
|
||||
paint.setTextSize(hintSize);
|
||||
// Note: padding.right for drawX?
|
||||
final float hintCharWidth = getCharWidth(paint);
|
||||
final float hintX, hintY;
|
||||
if (key.hasHintLabel()) {
|
||||
// TODO: Generalize the following calculations.
|
||||
hintX = positionX + getLabelCharWidth(paint) * 2;
|
||||
hintY = centerY + getLabelCharHeight(paint) / 2;
|
||||
} else {
|
||||
hintX = keyDrawWidth - getLabelCharWidth(paint);
|
||||
hintY = -paint.ascent() + padding.top;
|
||||
hintX = positionX + hintCharWidth * 2;
|
||||
hintY = centerY + getCharHeight(paint) / 2;
|
||||
paint.setTextAlign(Align.LEFT);
|
||||
} else if (key.hasUppercaseLetter()) {
|
||||
hintX = keyWidth - params.mKeyUppercaseLetterPadding - hintCharWidth / 2;
|
||||
hintY = -paint.ascent() + params.mKeyUppercaseLetterPadding;
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
} else { // key.hasHintLetter()
|
||||
hintX = keyWidth - params.mKeyHintLetterPadding - hintCharWidth / 2;
|
||||
hintY = -paint.ascent() + params.mKeyHintLetterPadding;
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
}
|
||||
canvas.drawText(hint, 0, hint.length(), hintX, hintY, paint);
|
||||
|
||||
if (debugShowAlign) {
|
||||
final Paint line = new Paint();
|
||||
drawHorizontalLine(canvas, (int)hintY, keyWidth, 0xc0808000, line);
|
||||
drawVerticalLine(canvas, (int)hintX, keyHeight, 0xc0808000, line);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw key icon.
|
||||
|
@ -825,63 +890,67 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
final int iconWidth = icon.getIntrinsicWidth();
|
||||
final int iconHeight = icon.getIntrinsicHeight();
|
||||
final int iconX, alignX;
|
||||
final int iconY = (key.mHeight + padding.top - padding.bottom - iconHeight) / 2;
|
||||
final int iconY = (keyHeight - iconHeight) / 2;
|
||||
if ((key.mLabelOption & Key.LABEL_OPTION_ALIGN_LEFT) != 0) {
|
||||
iconX = padding.left + mKeyLabelHorizontalPadding;
|
||||
iconX = (int)params.mKeyLabelHorizontalPadding;
|
||||
alignX = iconX;
|
||||
} else if ((key.mLabelOption & Key.LABEL_OPTION_ALIGN_RIGHT) != 0) {
|
||||
iconX = keyDrawWidth - padding.right - mKeyLabelHorizontalPadding - iconWidth;
|
||||
iconX = keyWidth - (int)params.mKeyLabelHorizontalPadding - iconWidth;
|
||||
alignX = iconX + iconWidth;
|
||||
} else { // Align center
|
||||
iconX = (keyDrawWidth + padding.left - padding.right - iconWidth) / 2;
|
||||
iconX = (keyWidth - iconWidth) / 2;
|
||||
alignX = iconX + iconWidth / 2;
|
||||
}
|
||||
drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight);
|
||||
if (DEBUG_SHOW_ALIGN) {
|
||||
|
||||
if (debugShowAlign) {
|
||||
final Paint line = new Paint();
|
||||
drawVerticalLine(canvas, alignX, rowHeight, 0xc0800080, line);
|
||||
drawVerticalLine(canvas, alignX, keyHeight, 0xc0800080, line);
|
||||
drawRectangle(canvas, iconX, iconY, iconWidth, iconHeight, 0x80c00000, line);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw popup hint "..." at the bottom right corner of the key.
|
||||
if (key.hasPopupHint()) {
|
||||
paint.setTextSize(mKeyHintLetterSize);
|
||||
paint.setColor(mKeyHintLabelColor);
|
||||
final int hintX = keyDrawWidth - getLabelCharWidth(paint);
|
||||
// Using y-coordinate "key.mHeight - paint.descent()" draws "..." just on the bottom
|
||||
// edge of the key. So we use slightly higher position by multiply descent length by 2.
|
||||
final int hintY = key.mHeight - (int)paint.descent() * 2;
|
||||
paint.setTextSize(params.mKeyHintLetterSize);
|
||||
paint.setColor(params.mKeyHintLabelColor);
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
final float hintX = keyWidth - params.mKeyHintLetterPadding - getCharWidth(paint) / 2;
|
||||
final float hintY = keyHeight - params.mKeyHintLetterPadding;
|
||||
canvas.drawText(POPUP_HINT_CHAR, hintX, hintY, paint);
|
||||
}
|
||||
|
||||
canvas.translate(-keyDrawX - kbdPaddingLeft, -key.mY - kbdPaddingTop);
|
||||
if (debugShowAlign) {
|
||||
final Paint line = new Paint();
|
||||
drawHorizontalLine(canvas, (int)hintY, keyWidth, 0xc0808000, line);
|
||||
drawVerticalLine(canvas, (int)hintX, keyHeight, 0xc0808000, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This method is currently being used only by MiniKeyboardBuilder
|
||||
public int getDefaultLabelSizeAndSetPaint(Paint paint) {
|
||||
// For characters, use large font. For labels like "Done", use small font.
|
||||
final int labelSize = mKeyLabelSize;
|
||||
final int labelSize = mKeyDrawParams.mKeyLabelSize;
|
||||
paint.setTextSize(labelSize);
|
||||
paint.setTypeface(mKeyTextStyle);
|
||||
paint.setTypeface(mKeyDrawParams.mKeyTextStyle);
|
||||
return labelSize;
|
||||
}
|
||||
|
||||
private final Rect mTextBounds = new Rect();
|
||||
private static final Rect sTextBounds = new Rect();
|
||||
|
||||
private int getLabelCharHeight(Paint paint) {
|
||||
private static float getCharHeight(Paint paint) {
|
||||
final int labelSize = (int)paint.getTextSize();
|
||||
final Integer cachedValue = mTextHeightCache.get(labelSize);
|
||||
final Float cachedValue = sTextHeightCache.get(labelSize);
|
||||
if (cachedValue != null)
|
||||
return cachedValue;
|
||||
|
||||
paint.getTextBounds(KEY_LABEL_REFERENCE_CHAR, 0, 1, mTextBounds);
|
||||
final int height = mTextBounds.height();
|
||||
mTextHeightCache.put(labelSize, height);
|
||||
paint.getTextBounds(KEY_LABEL_REFERENCE_CHAR, 0, 1, sTextBounds);
|
||||
final float height = sTextBounds.height();
|
||||
sTextHeightCache.put(labelSize, height);
|
||||
return height;
|
||||
}
|
||||
|
||||
private int getLabelCharWidth(Paint paint) {
|
||||
private static float getCharWidth(Paint paint) {
|
||||
final int labelSize = (int)paint.getTextSize();
|
||||
final Typeface face = paint.getTypeface();
|
||||
final Integer key;
|
||||
|
@ -895,13 +964,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
key = labelSize;
|
||||
}
|
||||
|
||||
final Integer cached = mTextWidthCache.get(key);
|
||||
final Float cached = sTextWidthCache.get(key);
|
||||
if (cached != null)
|
||||
return cached;
|
||||
|
||||
paint.getTextBounds(KEY_LABEL_REFERENCE_CHAR, 0, 1, mTextBounds);
|
||||
final int width = mTextBounds.width();
|
||||
mTextWidthCache.put(key, width);
|
||||
paint.getTextBounds(KEY_LABEL_REFERENCE_CHAR, 0, 1, sTextBounds);
|
||||
final float width = sTextBounds.width();
|
||||
sTextWidthCache.put(key, width);
|
||||
return width;
|
||||
}
|
||||
|
||||
|
@ -913,21 +982,21 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
canvas.translate(-x, -y);
|
||||
}
|
||||
|
||||
private static void drawHorizontalLine(Canvas canvas, int y, int w, int color, Paint paint) {
|
||||
private static void drawHorizontalLine(Canvas canvas, float y, float w, int color, Paint paint) {
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(1.0f);
|
||||
paint.setColor(color);
|
||||
canvas.drawLine(0, y, w, y, paint);
|
||||
}
|
||||
|
||||
private static void drawVerticalLine(Canvas canvas, int x, int h, int color, Paint paint) {
|
||||
private static void drawVerticalLine(Canvas canvas, float x, float h, int color, Paint paint) {
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(1.0f);
|
||||
paint.setColor(color);
|
||||
canvas.drawLine(x, 0, x, h, paint);
|
||||
}
|
||||
|
||||
private static void drawRectangle(Canvas canvas, int x, int y, int w, int h, int color,
|
||||
private static void drawRectangle(Canvas canvas, float x, float y, float w, float h, int color,
|
||||
Paint paint) {
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(1.0f);
|
||||
|
@ -997,7 +1066,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
return;
|
||||
|
||||
mHandler.cancelAllDismissKeyPreviews();
|
||||
|
||||
final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
|
||||
final int keyDrawX = key.mX + key.mVisualInsetsLeft;
|
||||
final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
|
||||
// What we show as preview should match what we show on key top in onBufferDraw().
|
||||
|
@ -1005,13 +1074,13 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
// TODO Should take care of temporaryShiftLabel here.
|
||||
previewText.setCompoundDrawables(null, null, null, null);
|
||||
if (key.mLabel.length() > 1) {
|
||||
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyLetterSize);
|
||||
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mKeyLetterSize);
|
||||
previewText.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
} else {
|
||||
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSize);
|
||||
previewText.setTypeface(mKeyTextStyle);
|
||||
previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mPreviewTextSize);
|
||||
previewText.setTypeface(params.mKeyTextStyle);
|
||||
}
|
||||
previewText.setText(adjustCase(tracker.getPreviewText(key)));
|
||||
previewText.setText(key.getCaseAdjustedLabel());
|
||||
} else {
|
||||
final Drawable previewIcon = key.getPreviewIcon();
|
||||
previewText.setCompoundDrawables(null, null, null,
|
||||
|
@ -1019,29 +1088,31 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
previewText.setText(null);
|
||||
}
|
||||
if (key.mCode == Keyboard.CODE_SPACE) {
|
||||
previewText.setBackgroundDrawable(mPreviewSpacebarBackground);
|
||||
previewText.setBackgroundDrawable(params.mPreviewSpacebarBackground);
|
||||
} else {
|
||||
previewText.setBackgroundDrawable(mPreviewBackground);
|
||||
previewText.setBackgroundDrawable(params.mPreviewBackground);
|
||||
}
|
||||
|
||||
previewText.measure(MEASURESPEC_UNSPECIFIED, MEASURESPEC_UNSPECIFIED);
|
||||
final int previewWidth = Math.max(previewText.getMeasuredWidth(), keyDrawWidth
|
||||
+ previewText.getPaddingLeft() + previewText.getPaddingRight());
|
||||
final int previewHeight = mPreviewHeight;
|
||||
getLocationInWindow(mCoordinates);
|
||||
int previewX = keyDrawX - (previewWidth - keyDrawWidth) / 2 + mCoordinates[0];
|
||||
final int previewY = key.mY - previewHeight + mCoordinates[1] + mPreviewOffset;
|
||||
if (previewX < 0 && mPreviewLeftBackground != null) {
|
||||
previewText.setBackgroundDrawable(mPreviewLeftBackground);
|
||||
final int previewHeight = params.mPreviewHeight;
|
||||
getLocationInWindow(params.mCoordinates);
|
||||
int previewX = keyDrawX - (previewWidth - keyDrawWidth) / 2 + params.mCoordinates[0];
|
||||
final int previewY = key.mY - previewHeight
|
||||
+ params.mCoordinates[1] + params.mPreviewOffset;
|
||||
if (previewX < 0 && params.mPreviewLeftBackground != null) {
|
||||
previewText.setBackgroundDrawable(params.mPreviewLeftBackground);
|
||||
previewX = 0;
|
||||
} else if (previewX + previewWidth > getWidth() && mPreviewRightBackground != null) {
|
||||
previewText.setBackgroundDrawable(mPreviewRightBackground);
|
||||
} else if (previewX + previewWidth > getWidth() && params.mPreviewRightBackground != null) {
|
||||
previewText.setBackgroundDrawable(params.mPreviewRightBackground);
|
||||
previewX = getWidth() - previewWidth;
|
||||
}
|
||||
|
||||
// Set the preview background state
|
||||
previewText.getBackground().setState(
|
||||
key.mPopupCharacters != null ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
|
||||
previewText.setTextColor(params.mPreviewTextColor);
|
||||
FrameLayoutCompatUtils.placeViewAt(
|
||||
previewText, previewX, previewY, previewWidth, previewHeight);
|
||||
previewText.setVisibility(VISIBLE);
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.inputmethod.keyboard.internal.SlidingLocaleDrawable;
|
||||
import com.android.inputmethod.latin.R;
|
||||
|
@ -182,6 +183,15 @@ public class LatinKeyboard extends Keyboard {
|
|||
return mSpaceKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence adjustLabelCase(CharSequence label) {
|
||||
if (isAlphaKeyboard() && isShiftedOrShiftLocked() && !TextUtils.isEmpty(label)
|
||||
&& label.length() < 3 && Character.isLowerCase(label.charAt(0))) {
|
||||
return label.toString().toUpperCase(mId.mLocale);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
private void updateSpacebarForLocale(boolean isAutoCorrection) {
|
||||
if (mSpaceKey == null)
|
||||
return;
|
||||
|
|
|
@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -113,18 +112,6 @@ public class LatinKeyboardView extends KeyboardView {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence adjustCase(CharSequence label) {
|
||||
LatinKeyboard keyboard = getLatinKeyboard();
|
||||
if (keyboard.isAlphaKeyboard()
|
||||
&& keyboard.isShiftedOrShiftLocked()
|
||||
&& !TextUtils.isEmpty(label) && label.length() < 3
|
||||
&& Character.isLowerCase(label.charAt(0))) {
|
||||
return label.toString().toUpperCase(keyboard.mId.mLocale);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks to see if we need to handle any sudden jumps in the pointer location
|
||||
* that could be due to a multi-touch being treated as a move by the firmware or hardware.
|
||||
|
|
|
@ -18,13 +18,22 @@ package com.android.inputmethod.keyboard;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MiniKeyboard extends Keyboard {
|
||||
private int mDefaultKeyCoordX;
|
||||
|
||||
public MiniKeyboard(Context context, int xmlLayoutResId, Keyboard parentKeyboard) {
|
||||
super(context, xmlLayoutResId, null, parentKeyboard.getMinWidth());
|
||||
super(context, xmlLayoutResId, parentKeyboard.mId.cloneAsMiniKeyboard(),
|
||||
parentKeyboard.getMinWidth());
|
||||
// HACK: Current mini keyboard design totally relies on the 9-patch padding about horizontal
|
||||
// and vertical key spacing. To keep the visual of mini keyboard as is, these hacks are
|
||||
// needed to keep having the same horizontal and vertical key spacing.
|
||||
setHorizontalGap(0);
|
||||
setVerticalGap(parentKeyboard.getVerticalGap() / 2);
|
||||
|
||||
// TODO: When we have correctly padded key background 9-patch drawables for mini keyboard,
|
||||
// revert the above hacks and uncomment the following lines.
|
||||
//setHorizontalGap(parentKeyboard.getHorizontalGap());
|
||||
//setVerticalGap(parentKeyboard.getVerticalGap());
|
||||
}
|
||||
|
||||
public void setDefaultCoordX(int pos) {
|
||||
|
@ -34,19 +43,4 @@ public class MiniKeyboard extends Keyboard {
|
|||
public int getDefaultCoordX() {
|
||||
return mDefaultKeyCoordX;
|
||||
}
|
||||
|
||||
public boolean isOneRowKeyboard() {
|
||||
final List<Key> keys = getKeys();
|
||||
if (keys.size() == 0) return false;
|
||||
final int edgeFlags = keys.get(0).mEdgeFlags;
|
||||
// HACK: The first key of mini keyboard which was inflated from xml and has multiple rows,
|
||||
// does not have both top and bottom edge flags on at the same time. On the other hand,
|
||||
// the first key of mini keyboard that was created with popupCharacters must have both top
|
||||
// and bottom edge flags on.
|
||||
// When you want to use one row mini-keyboard from xml file, make sure that the row has
|
||||
// both top and bottom edge flags set.
|
||||
return (edgeFlags & Keyboard.EDGE_TOP) != 0
|
||||
&& (edgeFlags & Keyboard.EDGE_BOTTOM) != 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -686,10 +686,6 @@ public class PointerTracker {
|
|||
}
|
||||
}
|
||||
|
||||
public CharSequence getPreviewText(Key key) {
|
||||
return key.mLabel;
|
||||
}
|
||||
|
||||
private long mPreviousEventTime;
|
||||
|
||||
private void printTouchEvent(String title, int x, int y, long eventTime) {
|
||||
|
|
|
@ -195,6 +195,7 @@ public class KeyboardParser {
|
|||
|
||||
private void parseKeyboardAttributes(XmlResourceParser parser) {
|
||||
final Keyboard keyboard = mKeyboard;
|
||||
final int displayWidth = keyboard.getDisplayWidth();
|
||||
final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
|
||||
Xml.asAttributeSet(parser), R.styleable.Keyboard, R.attr.keyboardStyle,
|
||||
R.style.Keyboard);
|
||||
|
@ -211,7 +212,6 @@ public class KeyboardParser {
|
|||
if (minKeyboardHeight < 0) {
|
||||
// Specified fraction was negative, so it should be calculated against display
|
||||
// width.
|
||||
final int displayWidth = keyboard.getDisplayWidth();
|
||||
minKeyboardHeight = -getDimensionOrFraction(keyboardAttr,
|
||||
R.styleable.Keyboard_minKeyboardHeight, displayWidth, displayWidth / 2);
|
||||
}
|
||||
|
@ -219,20 +219,19 @@ public class KeyboardParser {
|
|||
// minKeyboardHeight.
|
||||
final int height = Math.max(
|
||||
Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight);
|
||||
final int width = keyboard.getDisplayWidth();
|
||||
|
||||
|
||||
keyboard.setKeyboardHeight(height);
|
||||
keyboard.setKeyWidth(getDimensionOrFraction(keyboardAttr,
|
||||
R.styleable.Keyboard_keyWidth, width, width / 10));
|
||||
R.styleable.Keyboard_keyWidth, displayWidth, displayWidth / 10));
|
||||
keyboard.setRowHeight(getDimensionOrFraction(keyboardAttr,
|
||||
R.styleable.Keyboard_rowHeight, height, 50));
|
||||
keyboard.setHorizontalGap(getDimensionOrFraction(keyboardAttr,
|
||||
R.styleable.Keyboard_horizontalGap, width, 0));
|
||||
R.styleable.Keyboard_horizontalGap, displayWidth, 0));
|
||||
keyboard.setVerticalGap(getDimensionOrFraction(keyboardAttr,
|
||||
R.styleable.Keyboard_verticalGap, height, 0));
|
||||
keyboard.setPopupKeyboardResId(keyboardAttr.getResourceId(
|
||||
R.styleable.Keyboard_popupKeyboardTemplate, 0));
|
||||
|
||||
keyboard.setMaxPopupKeyboardColumn(keyAttr.getInt(
|
||||
R.styleable.Keyboard_Key_maxPopupKeyboardColumn, 5));
|
||||
|
||||
|
@ -352,18 +351,18 @@ public class KeyboardParser {
|
|||
R.styleable.Keyboard);
|
||||
if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap))
|
||||
throw new IllegalAttribute(parser, "horizontalGap");
|
||||
final int defaultWidth = (row != null) ? row.mDefaultWidth : 0;
|
||||
final int keyboardWidth = mKeyboard.getDisplayWidth();
|
||||
final int keyWidth = getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyWidth,
|
||||
mKeyboard.getDisplayWidth(), defaultWidth);
|
||||
keyboardWidth, row.mDefaultWidth);
|
||||
keyboardAttr.recycle();
|
||||
|
||||
final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser),
|
||||
R.styleable.Keyboard_Key);
|
||||
int keyXPos = KeyboardParser.getDimensionOrFraction(keyAttr,
|
||||
R.styleable.Keyboard_Key_keyXPos, mKeyboard.getDisplayWidth(), mCurrentX);
|
||||
R.styleable.Keyboard_Key_keyXPos, keyboardWidth, mCurrentX);
|
||||
if (keyXPos < 0) {
|
||||
// If keyXPos is negative, the actual x-coordinate will be display_width + keyXPos.
|
||||
keyXPos += mKeyboard.getDisplayWidth();
|
||||
keyXPos += keyboardWidth;
|
||||
}
|
||||
|
||||
checkEndTag(TAG_SPACER, parser);
|
||||
|
|