mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Move KeyboardView in the framework to LatinKeyboardViewBase
Change-Id: I99e3ea5eb1f1f5e5f9b36306930cdf0f50acfb01
This commit is contained in:
parent
c9e1a333ea
commit
2b2db815d2
BIN
java/res/drawable-hdpi/keyboard_key_feedback_background.9.png
Normal file
BIN
java/res/drawable-hdpi/keyboard_key_feedback_background.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
java/res/drawable-mdpi/keyboard_key_feedback_background.9.png
Normal file
BIN
java/res/drawable-mdpi/keyboard_key_feedback_background.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
java/res/drawable-mdpi/keyboard_key_feedback_more_background.9.png
Executable file
BIN
java/res/drawable-mdpi/keyboard_key_feedback_more_background.9.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
22
java/res/drawable/keyboard_key_feedback.xml
Normal file
22
java/res/drawable/keyboard_key_feedback.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?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">
|
||||||
|
<item android:state_long_pressable="true"
|
||||||
|
android:drawable="@drawable/keyboard_key_feedback_more_background" />
|
||||||
|
|
||||||
|
<item android:drawable="@drawable/keyboard_key_feedback_background" />
|
||||||
|
</selector>
|
@ -20,10 +20,12 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/keyboard_background"
|
android:background="@drawable/keyboard_background"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key"
|
|
||||||
|
latin:keyBackground="@drawable/btn_keyboard_key"
|
||||||
/>
|
/>
|
||||||
|
@ -20,10 +20,13 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
|
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key3"
|
|
||||||
android:background="@android:color/black"
|
android:background="@android:color/black"
|
||||||
|
|
||||||
|
latin:keyBackground="@drawable/btn_keyboard_key3"
|
||||||
/>
|
/>
|
||||||
|
@ -20,10 +20,12 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key2"
|
|
||||||
android:background="@drawable/keyboard_background_4"
|
android:background="@drawable/keyboard_background_4"
|
||||||
|
|
||||||
|
latin:keyBackground="@drawable/btn_keyboard_key2"
|
||||||
/>
|
/>
|
||||||
|
@ -20,10 +20,12 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key3"
|
|
||||||
android:background="@drawable/keyboard_background_4"
|
android:background="@drawable/keyboard_background_4"
|
||||||
|
|
||||||
|
latin:keyBackground="@drawable/btn_keyboard_key3"
|
||||||
/>
|
/>
|
||||||
|
@ -20,10 +20,12 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key2"
|
|
||||||
android:background="@drawable/keyboard_background_5"
|
android:background="@drawable/keyboard_background_5"
|
||||||
|
|
||||||
|
latin:keyBackground="@drawable/btn_keyboard_key2"
|
||||||
/>
|
/>
|
||||||
|
@ -20,10 +20,12 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key3"
|
|
||||||
android:background="@drawable/keyboard_background_5"
|
android:background="@drawable/keyboard_background_5"
|
||||||
|
|
||||||
|
latin:keyBackground="@drawable/btn_keyboard_key3"
|
||||||
/>
|
/>
|
||||||
|
@ -20,14 +20,16 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/keyboardView"
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
|
android:id="@+id/LatinkeyboardBaseView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/keyboard_background"
|
android:background="@drawable/keyboard_background"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key_ginger"
|
|
||||||
android:keyTextSize="22dip"
|
latin:keyBackground="@drawable/btn_keyboard_key_ginger"
|
||||||
android:keyTextColor="@color/latinkeyboard_key_color_black"
|
latin:keyTextSize="22dip"
|
||||||
android:shadowColor="@color/latinkeyboard_key_color_white"
|
latin:keyTextColor="@color/latinkeyboard_key_color_black"
|
||||||
android:popupLayout="@layout/input7_popup"
|
latin:shadowColor="@color/latinkeyboard_key_color_white"
|
||||||
|
latin:popupLayout="@layout/input7_popup"
|
||||||
/>
|
/>
|
||||||
|
@ -25,18 +25,20 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:background="@drawable/keyboard_popup_panel_background"
|
android:background="@drawable/keyboard_popup_panel_background"
|
||||||
>
|
>
|
||||||
<android.inputmethodservice.KeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key_ginger"
|
|
||||||
android:background="@drawable/keyboard_background"
|
android:background="@drawable/keyboard_background"
|
||||||
android:keyTextColor="@color/latinkeyboard_key_color_black"
|
|
||||||
android:shadowColor="@color/latinkeyboard_key_color_white"
|
latin:keyBackground="@drawable/btn_keyboard_key_ginger"
|
||||||
android:keyTextSize="22dip"
|
latin:keyTextColor="@color/latinkeyboard_key_color_black"
|
||||||
android:popupLayout="@layout/input7_popup"
|
latin:shadowColor="@color/latinkeyboard_key_color_white"
|
||||||
|
latin:keyTextSize="22dip"
|
||||||
|
latin:popupLayout="@layout/input7_popup"
|
||||||
/>
|
/>
|
||||||
<ImageButton android:id="@android:id/closeButton"
|
<ImageButton android:id="@android:id/closeButton"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
|
|
||||||
<com.android.inputmethod.latin.LatinKeyboardView
|
<com.android.inputmethod.latin.LatinKeyboardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
android:id="@android:id/keyboardView"
|
android:id="@android:id/keyboardView"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/latinkeyboard_extension_background"
|
android:background="@color/latinkeyboard_extension_background"
|
||||||
android:verticalCorrection="0dip"
|
android:verticalCorrection="0dip"
|
||||||
android:keyBackground="@drawable/btn_keyboard_key_fulltrans"
|
|
||||||
|
latin:keyBackground="@drawable/btn_keyboard_key_fulltrans"
|
||||||
/>
|
/>
|
||||||
|
29
java/res/layout/keyboard_key_preview.xml
Normal file
29
java/res/layout/keyboard_key_preview.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2010, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="80sp"
|
||||||
|
android:textSize="40sp"
|
||||||
|
android:textColor="?android:attr/textColorPrimaryInverse"
|
||||||
|
android:minWidth="32dip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="@drawable/keyboard_key_feedback"
|
||||||
|
/>
|
48
java/res/layout/keyboard_popup_keyboard.xml
Normal file
48
java/res/layout/keyboard_popup_keyboard.xml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2010, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="@drawable/keyboard_popup_panel_background"
|
||||||
|
>
|
||||||
|
<com.android.inputmethod.latin.LatinKeyboardBaseView
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||||
|
android:id="@+id/LatinKeyboardBaseView"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
|
||||||
|
latin:keyPreviewLayout="@layout/keyboard_key_preview"
|
||||||
|
latin:keyTextSize="22sp"
|
||||||
|
latin:popupLayout="@layout/keyboard_popup_keyboard"
|
||||||
|
/>
|
||||||
|
<ImageButton android:id="@+id/closeButton"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:src="@drawable/btn_close"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
57
java/res/values/attrs.xml
Normal file
57
java/res/values/attrs.xml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<declare-styleable name="LatinKeyboardBaseView">
|
||||||
|
<!-- Default KeyboardView style. -->
|
||||||
|
<attr name="keyboardViewStyle" format="reference" />
|
||||||
|
|
||||||
|
<!-- Image for the key. This image needs to be a StateListDrawable, with the following
|
||||||
|
possible states: normal, pressed, checkable, checkable+pressed, checkable+checked,
|
||||||
|
checkable+checked+pressed. -->
|
||||||
|
<attr name="keyBackground" format="reference" />
|
||||||
|
|
||||||
|
<!-- Size of the text for character keys. -->
|
||||||
|
<attr name="keyTextSize" format="dimension" />
|
||||||
|
|
||||||
|
<!-- Size of the text for custom keys with some text and no icon. -->
|
||||||
|
<attr name="labelTextSize" format="dimension" />
|
||||||
|
|
||||||
|
<!-- Color to use for the label in a key. -->
|
||||||
|
<attr name="keyTextColor" format="color" />
|
||||||
|
|
||||||
|
<!-- Layout resource for key press feedback.-->
|
||||||
|
<attr name="keyPreviewLayout" format="reference" />
|
||||||
|
|
||||||
|
<!-- Vertical offset of the key press feedback from the key. -->
|
||||||
|
<attr name="keyPreviewOffset" format="dimension" />
|
||||||
|
|
||||||
|
<!-- Height of the key press feedback popup. -->
|
||||||
|
<attr name="keyPreviewHeight" format="dimension" />
|
||||||
|
|
||||||
|
<!-- Amount to offset the touch Y coordinate by, for bias correction. -->
|
||||||
|
<attr name="verticalCorrection" format="dimension" />
|
||||||
|
|
||||||
|
<!-- Layout resource for popup keyboards. -->
|
||||||
|
<attr name="popupLayout" format="reference" />
|
||||||
|
|
||||||
|
<attr name="shadowColor" format="color" />
|
||||||
|
<attr name="shadowRadius" format="float" />
|
||||||
|
<attr name="backgroundDimAmount" format="float" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
</resources>
|
@ -25,4 +25,5 @@
|
|||||||
<bool name="im_is_default">false</bool>
|
<bool name="im_is_default">false</bool>
|
||||||
<!-- Whether or not voice input is enabled by default. -->
|
<!-- Whether or not voice input is enabled by default. -->
|
||||||
<bool name="voice_input_default">true</bool>
|
<bool name="voice_input_default">true</bool>
|
||||||
|
<bool name="config_swipeDisambiguation">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
34
java/res/values/styles.xml
Normal file
34
java/res/values/styles.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<style name="LatinKeyboardBaseView">
|
||||||
|
<item name="android:background">@drawable/keyboard_background</item>
|
||||||
|
|
||||||
|
<item name="keyBackground">@drawable/btn_keyboard_key</item>
|
||||||
|
<item name="keyTextSize">22sp</item>
|
||||||
|
<item name="keyTextColor">#FFFFFFFF</item>
|
||||||
|
<item name="keyPreviewLayout">@layout/keyboard_key_preview</item>
|
||||||
|
<item name="keyPreviewOffset">-12dip</item>
|
||||||
|
<item name="keyPreviewHeight">80dip</item>
|
||||||
|
<item name="labelTextSize">14sp</item>
|
||||||
|
<item name="popupLayout">@layout/keyboard_popup_keyboard</item>
|
||||||
|
<item name="verticalCorrection">-10dip</item>
|
||||||
|
<item name="shadowColor">#BB000000</item>
|
||||||
|
<item name="shadowRadius">2.75</item>
|
||||||
|
<item name="backgroundDimAmount">0.5</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
@ -32,7 +32,6 @@ 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.inputmethodservice.Keyboard;
|
import android.inputmethodservice.Keyboard;
|
||||||
import android.inputmethodservice.KeyboardView;
|
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Debug;
|
import android.os.Debug;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -74,7 +73,7 @@ import java.util.Map;
|
|||||||
* Input method implementation for Qwerty'ish keyboard.
|
* Input method implementation for Qwerty'ish keyboard.
|
||||||
*/
|
*/
|
||||||
public class LatinIME extends InputMethodService
|
public class LatinIME extends InputMethodService
|
||||||
implements KeyboardView.OnKeyboardActionListener,
|
implements LatinKeyboardBaseView.OnKeyboardActionListener,
|
||||||
VoiceInput.UiListener,
|
VoiceInput.UiListener,
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private static final String TAG = "LatinIME";
|
private static final String TAG = "LatinIME";
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2008-2009 Google Inc.
|
* Copyright (C) 2010 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");
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
* you may not use this file except in compliance with the License.
|
||||||
* 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, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* License for the specific language governing permissions and limitations under
|
* See the License for the specific language governing permissions and
|
||||||
* the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.inputmethodservice;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@ -27,6 +27,7 @@ import android.graphics.Typeface;
|
|||||||
import android.graphics.Paint.Align;
|
import android.graphics.Paint.Align;
|
||||||
import android.graphics.Region.Op;
|
import android.graphics.Region.Op;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.inputmethodservice.Keyboard;
|
||||||
import android.inputmethodservice.Keyboard.Key;
|
import android.inputmethodservice.Keyboard.Key;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@ -42,73 +43,83 @@ import android.view.ViewGroup.LayoutParams;
|
|||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.R;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A view that renders a virtual {@link Keyboard}. It handles rendering of keys and
|
* A view that renders a virtual {@link LatinKeyboard}. It handles rendering of keys and
|
||||||
* detecting key presses and touch movements.
|
* detecting key presses and touch movements.
|
||||||
*
|
*
|
||||||
* @attr ref android.R.styleable#KeyboardView_keyBackground
|
* @attr ref R.styleable#LatinKeyboardBaseView_keyBackground
|
||||||
* @attr ref android.R.styleable#KeyboardView_keyPreviewLayout
|
* @attr ref R.styleable#LatinKeyboardBaseView_keyPreviewLayout
|
||||||
* @attr ref android.R.styleable#KeyboardView_keyPreviewOffset
|
* @attr ref R.styleable#LatinKeyboardBaseView_keyPreviewOffset
|
||||||
* @attr ref android.R.styleable#KeyboardView_labelTextSize
|
* @attr ref R.styleable#LatinKeyboardBaseView_labelTextSize
|
||||||
* @attr ref android.R.styleable#KeyboardView_keyTextSize
|
* @attr ref R.styleable#LatinKeyboardBaseView_keyTextSize
|
||||||
* @attr ref android.R.styleable#KeyboardView_keyTextColor
|
* @attr ref R.styleable#LatinKeyboardBaseView_keyTextColor
|
||||||
* @attr ref android.R.styleable#KeyboardView_verticalCorrection
|
* @attr ref R.styleable#LatinKeyboardBaseView_verticalCorrection
|
||||||
* @attr ref android.R.styleable#KeyboardView_popupLayout
|
* @attr ref R.styleable#LatinKeyboardBaseView_popupLayout
|
||||||
*/
|
*/
|
||||||
public class KeyboardView extends View implements View.OnClickListener {
|
public class LatinKeyboardBaseView extends View implements View.OnClickListener {
|
||||||
|
|
||||||
/**
|
|
||||||
* Listener for virtual keyboard events.
|
|
||||||
*/
|
|
||||||
public interface OnKeyboardActionListener {
|
public interface OnKeyboardActionListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user presses a key. This is sent before the {@link #onKey} is called.
|
* Called when the user presses a key. This is sent before the
|
||||||
* For keys that repeat, this is only called once.
|
* {@link #onKey} is called. For keys that repeat, this is only
|
||||||
* @param primaryCode the unicode of the key being pressed. If the touch is not on a valid
|
* called once.
|
||||||
* key, the value will be zero.
|
*
|
||||||
|
* @param primaryCode
|
||||||
|
* the unicode of the key being pressed. If the touch is
|
||||||
|
* not on a valid key, the value will be zero.
|
||||||
*/
|
*/
|
||||||
void onPress(int primaryCode);
|
void onPress(int primaryCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user releases a key. This is sent after the {@link #onKey} is called.
|
* Called when the user releases a key. This is sent after the
|
||||||
* For keys that repeat, this is only called once.
|
* {@link #onKey} is called. For keys that repeat, this is only
|
||||||
* @param primaryCode the code of the key that was released
|
* called once.
|
||||||
|
*
|
||||||
|
* @param primaryCode
|
||||||
|
* the code of the key that was released
|
||||||
*/
|
*/
|
||||||
void onRelease(int primaryCode);
|
void onRelease(int primaryCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a key press to the listener.
|
* Send a key press to the listener.
|
||||||
* @param primaryCode this is the key that was pressed
|
*
|
||||||
* @param keyCodes the codes for all the possible alternative keys
|
* @param primaryCode
|
||||||
* with the primary code being the first. If the primary key code is
|
* this is the key that was pressed
|
||||||
* a single character such as an alphabet or number or symbol, the alternatives
|
* @param keyCodes
|
||||||
* will include other characters that may be on the same key or adjacent keys.
|
* the codes for all the possible alternative keys with
|
||||||
* These codes are useful to correct for accidental presses of a key adjacent to
|
* the primary code being the first. If the primary key
|
||||||
* the intended key.
|
* code is a single character such as an alphabet or
|
||||||
|
* number or symbol, the alternatives will include other
|
||||||
|
* characters that may be on the same key or adjacent
|
||||||
|
* keys. These codes are useful to correct for
|
||||||
|
* accidental presses of a key adjacent to the intended
|
||||||
|
* key.
|
||||||
*/
|
*/
|
||||||
void onKey(int primaryCode, int[] keyCodes);
|
void onKey(int primaryCode, int[] keyCodes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a sequence of characters to the listener.
|
* Sends a sequence of characters to the listener.
|
||||||
* @param text the sequence of characters to be displayed.
|
*
|
||||||
|
* @param text
|
||||||
|
* the sequence of characters to be displayed.
|
||||||
*/
|
*/
|
||||||
void onText(CharSequence text);
|
void onText(CharSequence text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user quickly moves the finger from right to left.
|
* Called when the user quickly moves the finger from right to
|
||||||
|
* left.
|
||||||
*/
|
*/
|
||||||
void swipeLeft();
|
void swipeLeft();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the user quickly moves the finger from left to right.
|
* Called when the user quickly moves the finger from left to
|
||||||
|
* right.
|
||||||
*/
|
*/
|
||||||
void swipeRight();
|
void swipeRight();
|
||||||
|
|
||||||
@ -126,7 +137,7 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private static final int NOT_A_KEY = -1;
|
private static final int NOT_A_KEY = -1;
|
||||||
private static final int[] KEY_DELETE = { Keyboard.KEYCODE_DELETE };
|
private static final int[] KEY_DELETE = { Keyboard.KEYCODE_DELETE };
|
||||||
private static final int[] LONG_PRESSABLE_STATE_SET = { R.attr.state_long_pressable };
|
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
|
||||||
|
|
||||||
private Keyboard mKeyboard;
|
private Keyboard mKeyboard;
|
||||||
private int mCurrentKeyIndex = NOT_A_KEY;
|
private int mCurrentKeyIndex = NOT_A_KEY;
|
||||||
@ -146,7 +157,7 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
|
|
||||||
private PopupWindow mPopupKeyboard;
|
private PopupWindow mPopupKeyboard;
|
||||||
private View mMiniKeyboardContainer;
|
private View mMiniKeyboardContainer;
|
||||||
private KeyboardView mMiniKeyboard;
|
private LatinKeyboardBaseView mMiniKeyboard;
|
||||||
private boolean mMiniKeyboardOnScreen;
|
private boolean mMiniKeyboardOnScreen;
|
||||||
private View mPopupParent;
|
private View mPopupParent;
|
||||||
private int mMiniKeyboardOffsetX;
|
private int mMiniKeyboardOffsetX;
|
||||||
@ -266,21 +277,17 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public KeyboardView(Context context, AttributeSet attrs) {
|
public LatinKeyboardBaseView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, com.android.internal.R.attr.keyboardViewStyle);
|
this(context, attrs, R.attr.keyboardViewStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardView(Context context, AttributeSet attrs, int defStyle) {
|
public LatinKeyboardBaseView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
|
|
||||||
TypedArray a =
|
TypedArray a = context.obtainStyledAttributes(
|
||||||
context.obtainStyledAttributes(
|
attrs, R.styleable.LatinKeyboardBaseView, defStyle, R.style.LatinKeyboardBaseView);
|
||||||
attrs, android.R.styleable.KeyboardView, defStyle, 0);
|
|
||||||
|
|
||||||
LayoutInflater inflate =
|
LayoutInflater inflate =
|
||||||
(LayoutInflater) context
|
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
|
|
||||||
int previewLayout = 0;
|
int previewLayout = 0;
|
||||||
int keyTextSize = 0;
|
int keyTextSize = 0;
|
||||||
|
|
||||||
@ -290,46 +297,46 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
int attr = a.getIndex(i);
|
int attr = a.getIndex(i);
|
||||||
|
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case com.android.internal.R.styleable.KeyboardView_keyBackground:
|
case R.styleable.LatinKeyboardBaseView_keyBackground:
|
||||||
mKeyBackground = a.getDrawable(attr);
|
mKeyBackground = a.getDrawable(attr);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_verticalCorrection:
|
case R.styleable.LatinKeyboardBaseView_verticalCorrection:
|
||||||
mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);
|
mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_keyPreviewLayout:
|
case R.styleable.LatinKeyboardBaseView_keyPreviewLayout:
|
||||||
previewLayout = a.getResourceId(attr, 0);
|
previewLayout = a.getResourceId(attr, 0);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_keyPreviewOffset:
|
case R.styleable.LatinKeyboardBaseView_keyPreviewOffset:
|
||||||
mPreviewOffset = a.getDimensionPixelOffset(attr, 0);
|
mPreviewOffset = a.getDimensionPixelOffset(attr, 0);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_keyPreviewHeight:
|
case R.styleable.LatinKeyboardBaseView_keyPreviewHeight:
|
||||||
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
|
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_keyTextSize:
|
case R.styleable.LatinKeyboardBaseView_keyTextSize:
|
||||||
mKeyTextSize = a.getDimensionPixelSize(attr, 18);
|
mKeyTextSize = a.getDimensionPixelSize(attr, 18);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_keyTextColor:
|
case R.styleable.LatinKeyboardBaseView_keyTextColor:
|
||||||
mKeyTextColor = a.getColor(attr, 0xFF000000);
|
mKeyTextColor = a.getColor(attr, 0xFF000000);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_labelTextSize:
|
case R.styleable.LatinKeyboardBaseView_labelTextSize:
|
||||||
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
|
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_popupLayout:
|
case R.styleable.LatinKeyboardBaseView_popupLayout:
|
||||||
mPopupLayout = a.getResourceId(attr, 0);
|
mPopupLayout = a.getResourceId(attr, 0);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_shadowColor:
|
case R.styleable.LatinKeyboardBaseView_shadowColor:
|
||||||
mShadowColor = a.getColor(attr, 0);
|
mShadowColor = a.getColor(attr, 0);
|
||||||
break;
|
break;
|
||||||
case com.android.internal.R.styleable.KeyboardView_shadowRadius:
|
case R.styleable.LatinKeyboardBaseView_shadowRadius:
|
||||||
mShadowRadius = a.getFloat(attr, 0f);
|
mShadowRadius = a.getFloat(attr, 0f);
|
||||||
break;
|
break;
|
||||||
|
// TODO: Use Theme (android.R.styleable.Theme_backgroundDimAmount)
|
||||||
|
case R.styleable.LatinKeyboardBaseView_backgroundDimAmount:
|
||||||
|
mBackgroundDimAmount = a.getFloat(attr, 0.5f);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a = mContext.obtainStyledAttributes(
|
|
||||||
com.android.internal.R.styleable.Theme);
|
|
||||||
mBackgroundDimAmount = a.getFloat(android.R.styleable.Theme_backgroundDimAmount, 0.5f);
|
|
||||||
|
|
||||||
mPreviewPopup = new PopupWindow(context);
|
mPreviewPopup = new PopupWindow(context);
|
||||||
if (previewLayout != 0) {
|
if (previewLayout != 0) {
|
||||||
mPreviewText = (TextView) inflate.inflate(previewLayout, null);
|
mPreviewText = (TextView) inflate.inflate(previewLayout, null);
|
||||||
@ -360,14 +367,15 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
mKeyBackground.getPadding(mPadding);
|
mKeyBackground.getPadding(mPadding);
|
||||||
|
|
||||||
mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
|
mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
|
||||||
mDisambiguateSwipe = getResources().getBoolean(
|
// TODO: Refer frameworks/base/core/res/res/values/config.xml
|
||||||
com.android.internal.R.bool.config_swipeDisambiguation);
|
mDisambiguateSwipe = getResources().getBoolean(R.bool.config_swipeDisambiguation);
|
||||||
resetMultiTap();
|
resetMultiTap();
|
||||||
initGestureDetector();
|
initGestureDetector();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initGestureDetector() {
|
private void initGestureDetector() {
|
||||||
mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
|
mGestureDetector = new GestureDetector(
|
||||||
|
getContext(), new GestureDetector.SimpleOnGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onFling(MotionEvent me1, MotionEvent me2,
|
public boolean onFling(MotionEvent me1, MotionEvent me2,
|
||||||
float velocityX, float velocityY) {
|
float velocityX, float velocityY) {
|
||||||
@ -455,7 +463,8 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
mKeyboardChanged = true;
|
mKeyboardChanged = true;
|
||||||
invalidateAllKeys();
|
invalidateAllKeys();
|
||||||
computeProximityThreshold(keyboard);
|
computeProximityThreshold(keyboard);
|
||||||
mMiniKeyboardCache.clear(); // Not really necessary to do every time, but will free up views
|
mMiniKeyboardCache.clear();
|
||||||
|
// Not really necessary to do every time, but will free up views
|
||||||
// Switching to a different keyboard should abort any pending keys so that the key up
|
// Switching to a different keyboard should abort any pending keys so that the key up
|
||||||
// doesn't get delivered to the old or new keyboard
|
// doesn't get delivered to the old or new keyboard
|
||||||
mAbortKey = true; // Until the next ACTION_DOWN
|
mAbortKey = true; // Until the next ACTION_DOWN
|
||||||
@ -474,7 +483,6 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
* Sets the state of the shift key of the keyboard, if any.
|
* Sets the state of the shift key of the keyboard, if any.
|
||||||
* @param shifted whether or not to enable the state of the shift key
|
* @param shifted whether or not to enable the state of the shift key
|
||||||
* @return true if the shift key state changed, false if there was no change
|
* @return true if the shift key state changed, false if there was no change
|
||||||
* @see KeyboardView#isShifted()
|
|
||||||
*/
|
*/
|
||||||
public boolean setShifted(boolean shifted) {
|
public boolean setShifted(boolean shifted) {
|
||||||
if (mKeyboard != null) {
|
if (mKeyboard != null) {
|
||||||
@ -491,7 +499,6 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
* Returns the state of the shift key of the keyboard, if any.
|
* Returns the state of the shift key of the keyboard, if any.
|
||||||
* @return true if the shift is in a pressed state, false otherwise. If there is
|
* @return true if the shift is in a pressed state, false otherwise. If there is
|
||||||
* no shift key on the keyboard or there is no keyboard attached, it returns false.
|
* no shift key on the keyboard or there is no keyboard attached, it returns false.
|
||||||
* @see KeyboardView#setShifted(boolean)
|
|
||||||
*/
|
*/
|
||||||
public boolean isShifted() {
|
public boolean isShifted() {
|
||||||
if (mKeyboard != null) {
|
if (mKeyboard != null) {
|
||||||
@ -520,8 +527,8 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setVerticalCorrection(int verticalOffset) {
|
public void setVerticalCorrection(int verticalOffset) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPopupParent(View v) {
|
public void setPopupParent(View v) {
|
||||||
mPopupParent = v;
|
mPopupParent = v;
|
||||||
}
|
}
|
||||||
@ -571,13 +578,15 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
// Round up a little
|
// Round up a little
|
||||||
if (mKeyboard == null) {
|
if (mKeyboard == null) {
|
||||||
setMeasuredDimension(mPaddingLeft + mPaddingRight, mPaddingTop + mPaddingBottom);
|
setMeasuredDimension(
|
||||||
|
getPaddingLeft() + getPaddingRight(), getPaddingTop() + getPaddingBottom());
|
||||||
} else {
|
} else {
|
||||||
int width = mKeyboard.getMinWidth() + mPaddingLeft + mPaddingRight;
|
int width = mKeyboard.getMinWidth() + getPaddingLeft() + getPaddingRight();
|
||||||
if (MeasureSpec.getSize(widthMeasureSpec) < width + 10) {
|
if (MeasureSpec.getSize(widthMeasureSpec) < width + 10) {
|
||||||
width = MeasureSpec.getSize(widthMeasureSpec);
|
width = MeasureSpec.getSize(widthMeasureSpec);
|
||||||
}
|
}
|
||||||
setMeasuredDimension(width, mKeyboard.getHeight() + mPaddingTop + mPaddingBottom);
|
setMeasuredDimension(
|
||||||
|
width, mKeyboard.getHeight() + getPaddingTop() + getPaddingBottom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,8 +649,8 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
final Drawable keyBackground = mKeyBackground;
|
final Drawable keyBackground = mKeyBackground;
|
||||||
final Rect clipRegion = mClipRegion;
|
final Rect clipRegion = mClipRegion;
|
||||||
final Rect padding = mPadding;
|
final Rect padding = mPadding;
|
||||||
final int kbdPaddingLeft = mPaddingLeft;
|
final int kbdPaddingLeft = getPaddingLeft();
|
||||||
final int kbdPaddingTop = mPaddingTop;
|
final int kbdPaddingTop = getPaddingTop();
|
||||||
final Key[] keys = mKeys;
|
final Key[] keys = mKeys;
|
||||||
final Key invalidKey = mInvalidatedKey;
|
final Key invalidKey = mInvalidatedKey;
|
||||||
|
|
||||||
@ -717,15 +726,17 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
|
canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG && mShowTouchPoints) {
|
if (DEBUG) {
|
||||||
paint.setAlpha(128);
|
if (mShowTouchPoints) {
|
||||||
paint.setColor(0xFFFF0000);
|
paint.setAlpha(128);
|
||||||
canvas.drawCircle(mStartX, mStartY, 3, paint);
|
paint.setColor(0xFFFF0000);
|
||||||
canvas.drawLine(mStartX, mStartY, mLastX, mLastY, paint);
|
canvas.drawCircle(mStartX, mStartY, 3, paint);
|
||||||
paint.setColor(0xFF0000FF);
|
canvas.drawLine(mStartX, mStartY, mLastX, mLastY, paint);
|
||||||
canvas.drawCircle(mLastX, mLastY, 3, paint);
|
paint.setColor(0xFF0000FF);
|
||||||
paint.setColor(0xFF00FF00);
|
canvas.drawCircle(mLastX, mLastY, 3, paint);
|
||||||
canvas.drawCircle((mStartX + mLastX) / 2, (mStartY + mLastY) / 2, 2, paint);
|
paint.setColor(0xFF00FF00);
|
||||||
|
canvas.drawCircle((mStartX + mLastX) / 2, (mStartY + mLastY) / 2, 2, paint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDrawPending = false;
|
mDrawPending = false;
|
||||||
@ -897,7 +908,7 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
lp.height = popupHeight;
|
lp.height = popupHeight;
|
||||||
}
|
}
|
||||||
if (!mPreviewCentered) {
|
if (!mPreviewCentered) {
|
||||||
mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
|
mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + getPaddingLeft();
|
||||||
mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
|
mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
|
||||||
} else {
|
} else {
|
||||||
// TODO: Fix this if centering is brought back
|
// TODO: Fix this if centering is brought back
|
||||||
@ -970,11 +981,11 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
final Key key = mKeys[keyIndex];
|
final Key key = mKeys[keyIndex];
|
||||||
mInvalidatedKey = key;
|
mInvalidatedKey = key;
|
||||||
mDirtyRect.union(key.x + mPaddingLeft, key.y + mPaddingTop,
|
mDirtyRect.union(key.x + getPaddingLeft(), key.y + getPaddingTop(),
|
||||||
key.x + key.width + mPaddingLeft, key.y + key.height + mPaddingTop);
|
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
||||||
onBufferDraw();
|
onBufferDraw();
|
||||||
invalidate(key.x + mPaddingLeft, key.y + mPaddingTop,
|
invalidate(key.x + getPaddingLeft(), key.y + getPaddingTop(),
|
||||||
key.x + key.width + mPaddingLeft, key.y + key.height + mPaddingTop);
|
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openPopupIfRequired(MotionEvent me) {
|
private boolean openPopupIfRequired(MotionEvent me) {
|
||||||
@ -1011,10 +1022,10 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
|
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null);
|
mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null);
|
||||||
mMiniKeyboard = (KeyboardView) mMiniKeyboardContainer.findViewById(
|
mMiniKeyboard = (LatinKeyboardBaseView) mMiniKeyboardContainer.findViewById(
|
||||||
com.android.internal.R.id.keyboardView);
|
R.id.LatinKeyboardBaseView);
|
||||||
View closeButton = mMiniKeyboardContainer.findViewById(
|
View closeButton = mMiniKeyboardContainer.findViewById(
|
||||||
com.android.internal.R.id.closeButton);
|
R.id.closeButton);
|
||||||
if (closeButton != null) closeButton.setOnClickListener(this);
|
if (closeButton != null) closeButton.setOnClickListener(this);
|
||||||
mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
||||||
public void onKey(int primaryCode, int[] keyCodes) {
|
public void onKey(int primaryCode, int[] keyCodes) {
|
||||||
@ -1054,15 +1065,15 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
|
|
||||||
mMiniKeyboardCache.put(popupKey, mMiniKeyboardContainer);
|
mMiniKeyboardCache.put(popupKey, mMiniKeyboardContainer);
|
||||||
} else {
|
} else {
|
||||||
mMiniKeyboard = (KeyboardView) mMiniKeyboardContainer.findViewById(
|
mMiniKeyboard = (LatinKeyboardBaseView) mMiniKeyboardContainer.findViewById(
|
||||||
com.android.internal.R.id.keyboardView);
|
R.id.LatinKeyboardBaseView);
|
||||||
}
|
}
|
||||||
if (mWindowOffset == null) {
|
if (mWindowOffset == null) {
|
||||||
mWindowOffset = new int[2];
|
mWindowOffset = new int[2];
|
||||||
getLocationInWindow(mWindowOffset);
|
getLocationInWindow(mWindowOffset);
|
||||||
}
|
}
|
||||||
mPopupX = popupKey.x + mPaddingLeft;
|
mPopupX = popupKey.x + getPaddingLeft();
|
||||||
mPopupY = popupKey.y + mPaddingTop;
|
mPopupY = popupKey.y + getPaddingTop();
|
||||||
mPopupX = mPopupX + popupKey.width - mMiniKeyboardContainer.getMeasuredWidth();
|
mPopupX = mPopupX + popupKey.width - mMiniKeyboardContainer.getMeasuredWidth();
|
||||||
mPopupY = mPopupY - mMiniKeyboardContainer.getMeasuredHeight();
|
mPopupY = mPopupY - mMiniKeyboardContainer.getMeasuredHeight();
|
||||||
final int x = mPopupX + mMiniKeyboardContainer.getPaddingRight() + mWindowOffset[0];
|
final int x = mPopupX + mMiniKeyboardContainer.getPaddingRight() + mWindowOffset[0];
|
||||||
@ -1081,9 +1092,6 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long mOldEventTime;
|
|
||||||
private boolean mUsedVelocity;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent me) {
|
public boolean onTouchEvent(MotionEvent me) {
|
||||||
// Convert multi-pointer up/down events to single up/down events to
|
// Convert multi-pointer up/down events to single up/down events to
|
||||||
@ -1127,11 +1135,10 @@ public class KeyboardView extends View implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) {
|
private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) {
|
||||||
int touchX = (int) me.getX() - mPaddingLeft;
|
int touchX = (int) me.getX() - getPaddingLeft();
|
||||||
int touchY = (int) me.getY() + mVerticalCorrection - mPaddingTop;
|
int touchY = (int) me.getY() + mVerticalCorrection - getPaddingTop();
|
||||||
final int action = me.getAction();
|
final int action = me.getAction();
|
||||||
final long eventTime = me.getEventTime();
|
final long eventTime = me.getEventTime();
|
||||||
mOldEventTime = eventTime;
|
|
||||||
int keyIndex = getKeyIndices(touchX, touchY, null);
|
int keyIndex = getKeyIndices(touchX, touchY, null);
|
||||||
mPossiblePoly = possiblePoly;
|
mPossiblePoly = possiblePoly;
|
||||||
|
|
@ -22,7 +22,6 @@ import android.content.Context;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.inputmethodservice.Keyboard;
|
import android.inputmethodservice.Keyboard;
|
||||||
import android.inputmethodservice.KeyboardView;
|
|
||||||
import android.inputmethodservice.Keyboard.Key;
|
import android.inputmethodservice.Keyboard.Key;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@ -32,7 +31,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
public class LatinKeyboardView extends KeyboardView {
|
public class LatinKeyboardView extends LatinKeyboardBaseView {
|
||||||
|
|
||||||
static final int KEYCODE_OPTIONS = -100;
|
static final int KEYCODE_OPTIONS = -100;
|
||||||
static final int KEYCODE_SHIFT_LONGPRESS = -101;
|
static final int KEYCODE_SHIFT_LONGPRESS = -101;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user