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
|
||||
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:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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
|
||||
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:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:keyBackground="@drawable/btn_keyboard_key3"
|
||||
android:background="@android:color/black"
|
||||
|
||||
latin:keyBackground="@drawable/btn_keyboard_key3"
|
||||
/>
|
||||
|
@ -20,10 +20,12 @@
|
||||
|
||||
<com.android.inputmethod.latin.LatinKeyboardView
|
||||
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:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:keyBackground="@drawable/btn_keyboard_key2"
|
||||
android:background="@drawable/keyboard_background_4"
|
||||
|
||||
latin:keyBackground="@drawable/btn_keyboard_key2"
|
||||
/>
|
||||
|
@ -20,10 +20,12 @@
|
||||
|
||||
<com.android.inputmethod.latin.LatinKeyboardView
|
||||
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:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:keyBackground="@drawable/btn_keyboard_key3"
|
||||
android:background="@drawable/keyboard_background_4"
|
||||
|
||||
latin:keyBackground="@drawable/btn_keyboard_key3"
|
||||
/>
|
||||
|
@ -20,10 +20,12 @@
|
||||
|
||||
<com.android.inputmethod.latin.LatinKeyboardView
|
||||
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:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:keyBackground="@drawable/btn_keyboard_key2"
|
||||
android:background="@drawable/keyboard_background_5"
|
||||
|
||||
latin:keyBackground="@drawable/btn_keyboard_key2"
|
||||
/>
|
||||
|
@ -20,10 +20,12 @@
|
||||
|
||||
<com.android.inputmethod.latin.LatinKeyboardView
|
||||
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:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:keyBackground="@drawable/btn_keyboard_key3"
|
||||
android:background="@drawable/keyboard_background_5"
|
||||
|
||||
latin:keyBackground="@drawable/btn_keyboard_key3"
|
||||
/>
|
||||
|
@ -20,14 +20,16 @@
|
||||
|
||||
<com.android.inputmethod.latin.LatinKeyboardView
|
||||
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_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/keyboard_background"
|
||||
android:keyBackground="@drawable/btn_keyboard_key_ginger"
|
||||
android:keyTextSize="22dip"
|
||||
android:keyTextColor="@color/latinkeyboard_key_color_black"
|
||||
android:shadowColor="@color/latinkeyboard_key_color_white"
|
||||
android:popupLayout="@layout/input7_popup"
|
||||
|
||||
latin:keyBackground="@drawable/btn_keyboard_key_ginger"
|
||||
latin:keyTextSize="22dip"
|
||||
latin:keyTextColor="@color/latinkeyboard_key_color_black"
|
||||
latin:shadowColor="@color/latinkeyboard_key_color_white"
|
||||
latin:popupLayout="@layout/input7_popup"
|
||||
/>
|
||||
|
@ -25,18 +25,20 @@
|
||||
android:orientation="horizontal"
|
||||
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:latin="http://schemas.android.com/apk/res/com.google.android.inputmethod.latin"
|
||||
android:id="@android:id/keyboardView"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:keyBackground="@drawable/btn_keyboard_key_ginger"
|
||||
android:background="@drawable/keyboard_background"
|
||||
android:keyTextColor="@color/latinkeyboard_key_color_black"
|
||||
android:shadowColor="@color/latinkeyboard_key_color_white"
|
||||
android:keyTextSize="22dip"
|
||||
android:popupLayout="@layout/input7_popup"
|
||||
|
||||
latin:keyBackground="@drawable/btn_keyboard_key_ginger"
|
||||
latin:keyTextColor="@color/latinkeyboard_key_color_black"
|
||||
latin:shadowColor="@color/latinkeyboard_key_color_white"
|
||||
latin:keyTextSize="22dip"
|
||||
latin:popupLayout="@layout/input7_popup"
|
||||
/>
|
||||
<ImageButton android:id="@android:id/closeButton"
|
||||
android:background="@android:color/transparent"
|
||||
|
@ -20,11 +20,13 @@
|
||||
|
||||
<com.android.inputmethod.latin.LatinKeyboardView
|
||||
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:layout_alignParentBottom="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/latinkeyboard_extension_background"
|
||||
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>
|
||||
<!-- Whether or not voice input is enabled by default. -->
|
||||
<bool name="voice_input_default">true</bool>
|
||||
<bool name="config_swipeDisambiguation">true</bool>
|
||||
</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.inputmethodservice.InputMethodService;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
@ -74,7 +73,7 @@ import java.util.Map;
|
||||
* Input method implementation for Qwerty'ish keyboard.
|
||||
*/
|
||||
public class LatinIME extends InputMethodService
|
||||
implements KeyboardView.OnKeyboardActionListener,
|
||||
implements LatinKeyboardBaseView.OnKeyboardActionListener,
|
||||
VoiceInput.UiListener,
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
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
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* 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
|
||||
* 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.
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.inputmethodservice;
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
@ -27,6 +27,7 @@ import android.graphics.Typeface;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Region.Op;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.Keyboard.Key;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@ -42,73 +43,83 @@ import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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.
|
||||
*
|
||||
* @attr ref android.R.styleable#KeyboardView_keyBackground
|
||||
* @attr ref android.R.styleable#KeyboardView_keyPreviewLayout
|
||||
* @attr ref android.R.styleable#KeyboardView_keyPreviewOffset
|
||||
* @attr ref android.R.styleable#KeyboardView_labelTextSize
|
||||
* @attr ref android.R.styleable#KeyboardView_keyTextSize
|
||||
* @attr ref android.R.styleable#KeyboardView_keyTextColor
|
||||
* @attr ref android.R.styleable#KeyboardView_verticalCorrection
|
||||
* @attr ref android.R.styleable#KeyboardView_popupLayout
|
||||
* @attr ref R.styleable#LatinKeyboardBaseView_keyBackground
|
||||
* @attr ref R.styleable#LatinKeyboardBaseView_keyPreviewLayout
|
||||
* @attr ref R.styleable#LatinKeyboardBaseView_keyPreviewOffset
|
||||
* @attr ref R.styleable#LatinKeyboardBaseView_labelTextSize
|
||||
* @attr ref R.styleable#LatinKeyboardBaseView_keyTextSize
|
||||
* @attr ref R.styleable#LatinKeyboardBaseView_keyTextColor
|
||||
* @attr ref R.styleable#LatinKeyboardBaseView_verticalCorrection
|
||||
* @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 {
|
||||
|
||||
/**
|
||||
* Called when the user presses a key. This is sent before the {@link #onKey} is called.
|
||||
* For keys that repeat, this is only called once.
|
||||
* @param primaryCode the unicode of the key being pressed. If the touch is not on a valid
|
||||
* key, the value will be zero.
|
||||
* Called when the user presses a key. This is sent before the
|
||||
* {@link #onKey} is called. For keys that repeat, this is only
|
||||
* called once.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Called when the user releases a key. This is sent after the {@link #onKey} is called.
|
||||
* For keys that repeat, this is only called once.
|
||||
* @param primaryCode the code of the key that was released
|
||||
* Called when the user releases a key. This is sent after the
|
||||
* {@link #onKey} is called. For keys that repeat, this is only
|
||||
* called once.
|
||||
*
|
||||
* @param primaryCode
|
||||
* the code of the key that was released
|
||||
*/
|
||||
void onRelease(int primaryCode);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* with the primary code being the first. If the primary 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.
|
||||
*
|
||||
* @param primaryCode
|
||||
* this is the key that was pressed
|
||||
* @param keyCodes
|
||||
* the codes for all the possible alternative keys with
|
||||
* the primary code being the first. If the primary 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
@ -126,7 +137,7 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final int NOT_A_KEY = -1;
|
||||
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 int mCurrentKeyIndex = NOT_A_KEY;
|
||||
@ -146,7 +157,7 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
|
||||
private PopupWindow mPopupKeyboard;
|
||||
private View mMiniKeyboardContainer;
|
||||
private KeyboardView mMiniKeyboard;
|
||||
private LatinKeyboardBaseView mMiniKeyboard;
|
||||
private boolean mMiniKeyboardOnScreen;
|
||||
private View mPopupParent;
|
||||
private int mMiniKeyboardOffsetX;
|
||||
@ -266,21 +277,17 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
}
|
||||
};
|
||||
|
||||
public KeyboardView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, com.android.internal.R.attr.keyboardViewStyle);
|
||||
public LatinKeyboardBaseView(Context context, AttributeSet attrs) {
|
||||
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);
|
||||
|
||||
TypedArray a =
|
||||
context.obtainStyledAttributes(
|
||||
attrs, android.R.styleable.KeyboardView, defStyle, 0);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.LatinKeyboardBaseView, defStyle, R.style.LatinKeyboardBaseView);
|
||||
LayoutInflater inflate =
|
||||
(LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
int previewLayout = 0;
|
||||
int keyTextSize = 0;
|
||||
|
||||
@ -290,46 +297,46 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
int attr = a.getIndex(i);
|
||||
|
||||
switch (attr) {
|
||||
case com.android.internal.R.styleable.KeyboardView_keyBackground:
|
||||
case R.styleable.LatinKeyboardBaseView_keyBackground:
|
||||
mKeyBackground = a.getDrawable(attr);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_verticalCorrection:
|
||||
case R.styleable.LatinKeyboardBaseView_verticalCorrection:
|
||||
mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_keyPreviewLayout:
|
||||
case R.styleable.LatinKeyboardBaseView_keyPreviewLayout:
|
||||
previewLayout = a.getResourceId(attr, 0);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_keyPreviewOffset:
|
||||
case R.styleable.LatinKeyboardBaseView_keyPreviewOffset:
|
||||
mPreviewOffset = a.getDimensionPixelOffset(attr, 0);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_keyPreviewHeight:
|
||||
case R.styleable.LatinKeyboardBaseView_keyPreviewHeight:
|
||||
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_keyTextSize:
|
||||
case R.styleable.LatinKeyboardBaseView_keyTextSize:
|
||||
mKeyTextSize = a.getDimensionPixelSize(attr, 18);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_keyTextColor:
|
||||
case R.styleable.LatinKeyboardBaseView_keyTextColor:
|
||||
mKeyTextColor = a.getColor(attr, 0xFF000000);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_labelTextSize:
|
||||
case R.styleable.LatinKeyboardBaseView_labelTextSize:
|
||||
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_popupLayout:
|
||||
case R.styleable.LatinKeyboardBaseView_popupLayout:
|
||||
mPopupLayout = a.getResourceId(attr, 0);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_shadowColor:
|
||||
case R.styleable.LatinKeyboardBaseView_shadowColor:
|
||||
mShadowColor = a.getColor(attr, 0);
|
||||
break;
|
||||
case com.android.internal.R.styleable.KeyboardView_shadowRadius:
|
||||
case R.styleable.LatinKeyboardBaseView_shadowRadius:
|
||||
mShadowRadius = a.getFloat(attr, 0f);
|
||||
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);
|
||||
if (previewLayout != 0) {
|
||||
mPreviewText = (TextView) inflate.inflate(previewLayout, null);
|
||||
@ -360,14 +367,15 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
mKeyBackground.getPadding(mPadding);
|
||||
|
||||
mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
|
||||
mDisambiguateSwipe = getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_swipeDisambiguation);
|
||||
// TODO: Refer frameworks/base/core/res/res/values/config.xml
|
||||
mDisambiguateSwipe = getResources().getBoolean(R.bool.config_swipeDisambiguation);
|
||||
resetMultiTap();
|
||||
initGestureDetector();
|
||||
}
|
||||
|
||||
private void initGestureDetector() {
|
||||
mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
|
||||
mGestureDetector = new GestureDetector(
|
||||
getContext(), new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onFling(MotionEvent me1, MotionEvent me2,
|
||||
float velocityX, float velocityY) {
|
||||
@ -455,7 +463,8 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
mKeyboardChanged = true;
|
||||
invalidateAllKeys();
|
||||
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
|
||||
// doesn't get delivered to the old or new keyboard
|
||||
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.
|
||||
* @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
|
||||
* @see KeyboardView#isShifted()
|
||||
*/
|
||||
public boolean setShifted(boolean shifted) {
|
||||
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.
|
||||
* @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.
|
||||
* @see KeyboardView#setShifted(boolean)
|
||||
*/
|
||||
public boolean isShifted() {
|
||||
if (mKeyboard != null) {
|
||||
@ -520,8 +527,8 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
}
|
||||
|
||||
public void setVerticalCorrection(int verticalOffset) {
|
||||
|
||||
}
|
||||
|
||||
public void setPopupParent(View v) {
|
||||
mPopupParent = v;
|
||||
}
|
||||
@ -571,13 +578,15 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// Round up a little
|
||||
if (mKeyboard == null) {
|
||||
setMeasuredDimension(mPaddingLeft + mPaddingRight, mPaddingTop + mPaddingBottom);
|
||||
setMeasuredDimension(
|
||||
getPaddingLeft() + getPaddingRight(), getPaddingTop() + getPaddingBottom());
|
||||
} else {
|
||||
int width = mKeyboard.getMinWidth() + mPaddingLeft + mPaddingRight;
|
||||
int width = mKeyboard.getMinWidth() + getPaddingLeft() + getPaddingRight();
|
||||
if (MeasureSpec.getSize(widthMeasureSpec) < width + 10) {
|
||||
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 Rect clipRegion = mClipRegion;
|
||||
final Rect padding = mPadding;
|
||||
final int kbdPaddingLeft = mPaddingLeft;
|
||||
final int kbdPaddingTop = mPaddingTop;
|
||||
final int kbdPaddingLeft = getPaddingLeft();
|
||||
final int kbdPaddingTop = getPaddingTop();
|
||||
final Key[] keys = mKeys;
|
||||
final Key invalidKey = mInvalidatedKey;
|
||||
|
||||
@ -717,15 +726,17 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
|
||||
}
|
||||
|
||||
if (DEBUG && mShowTouchPoints) {
|
||||
paint.setAlpha(128);
|
||||
paint.setColor(0xFFFF0000);
|
||||
canvas.drawCircle(mStartX, mStartY, 3, paint);
|
||||
canvas.drawLine(mStartX, mStartY, mLastX, mLastY, paint);
|
||||
paint.setColor(0xFF0000FF);
|
||||
canvas.drawCircle(mLastX, mLastY, 3, paint);
|
||||
paint.setColor(0xFF00FF00);
|
||||
canvas.drawCircle((mStartX + mLastX) / 2, (mStartY + mLastY) / 2, 2, paint);
|
||||
if (DEBUG) {
|
||||
if (mShowTouchPoints) {
|
||||
paint.setAlpha(128);
|
||||
paint.setColor(0xFFFF0000);
|
||||
canvas.drawCircle(mStartX, mStartY, 3, paint);
|
||||
canvas.drawLine(mStartX, mStartY, mLastX, mLastY, paint);
|
||||
paint.setColor(0xFF0000FF);
|
||||
canvas.drawCircle(mLastX, mLastY, 3, paint);
|
||||
paint.setColor(0xFF00FF00);
|
||||
canvas.drawCircle((mStartX + mLastX) / 2, (mStartY + mLastY) / 2, 2, paint);
|
||||
}
|
||||
}
|
||||
|
||||
mDrawPending = false;
|
||||
@ -897,7 +908,7 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
lp.height = popupHeight;
|
||||
}
|
||||
if (!mPreviewCentered) {
|
||||
mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
|
||||
mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + getPaddingLeft();
|
||||
mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
|
||||
} else {
|
||||
// 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];
|
||||
mInvalidatedKey = key;
|
||||
mDirtyRect.union(key.x + mPaddingLeft, key.y + mPaddingTop,
|
||||
key.x + key.width + mPaddingLeft, key.y + key.height + mPaddingTop);
|
||||
mDirtyRect.union(key.x + getPaddingLeft(), key.y + getPaddingTop(),
|
||||
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
||||
onBufferDraw();
|
||||
invalidate(key.x + mPaddingLeft, key.y + mPaddingTop,
|
||||
key.x + key.width + mPaddingLeft, key.y + key.height + mPaddingTop);
|
||||
invalidate(key.x + getPaddingLeft(), key.y + getPaddingTop(),
|
||||
key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
|
||||
}
|
||||
|
||||
private boolean openPopupIfRequired(MotionEvent me) {
|
||||
@ -1011,10 +1022,10 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null);
|
||||
mMiniKeyboard = (KeyboardView) mMiniKeyboardContainer.findViewById(
|
||||
com.android.internal.R.id.keyboardView);
|
||||
mMiniKeyboard = (LatinKeyboardBaseView) mMiniKeyboardContainer.findViewById(
|
||||
R.id.LatinKeyboardBaseView);
|
||||
View closeButton = mMiniKeyboardContainer.findViewById(
|
||||
com.android.internal.R.id.closeButton);
|
||||
R.id.closeButton);
|
||||
if (closeButton != null) closeButton.setOnClickListener(this);
|
||||
mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
|
||||
public void onKey(int primaryCode, int[] keyCodes) {
|
||||
@ -1054,15 +1065,15 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
|
||||
mMiniKeyboardCache.put(popupKey, mMiniKeyboardContainer);
|
||||
} else {
|
||||
mMiniKeyboard = (KeyboardView) mMiniKeyboardContainer.findViewById(
|
||||
com.android.internal.R.id.keyboardView);
|
||||
mMiniKeyboard = (LatinKeyboardBaseView) mMiniKeyboardContainer.findViewById(
|
||||
R.id.LatinKeyboardBaseView);
|
||||
}
|
||||
if (mWindowOffset == null) {
|
||||
mWindowOffset = new int[2];
|
||||
getLocationInWindow(mWindowOffset);
|
||||
}
|
||||
mPopupX = popupKey.x + mPaddingLeft;
|
||||
mPopupY = popupKey.y + mPaddingTop;
|
||||
mPopupX = popupKey.x + getPaddingLeft();
|
||||
mPopupY = popupKey.y + getPaddingTop();
|
||||
mPopupX = mPopupX + popupKey.width - mMiniKeyboardContainer.getMeasuredWidth();
|
||||
mPopupY = mPopupY - mMiniKeyboardContainer.getMeasuredHeight();
|
||||
final int x = mPopupX + mMiniKeyboardContainer.getPaddingRight() + mWindowOffset[0];
|
||||
@ -1081,9 +1092,6 @@ public class KeyboardView extends View implements View.OnClickListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
private long mOldEventTime;
|
||||
private boolean mUsedVelocity;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent me) {
|
||||
// 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) {
|
||||
int touchX = (int) me.getX() - mPaddingLeft;
|
||||
int touchY = (int) me.getY() + mVerticalCorrection - mPaddingTop;
|
||||
int touchX = (int) me.getX() - getPaddingLeft();
|
||||
int touchY = (int) me.getY() + mVerticalCorrection - getPaddingTop();
|
||||
final int action = me.getAction();
|
||||
final long eventTime = me.getEventTime();
|
||||
mOldEventTime = eventTime;
|
||||
int keyIndex = getKeyIndices(touchX, touchY, null);
|
||||
mPossiblePoly = possiblePoly;
|
||||
|
@ -22,7 +22,6 @@ import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.inputmethodservice.Keyboard.Key;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@ -32,7 +31,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
public class LatinKeyboardView extends KeyboardView {
|
||||
public class LatinKeyboardView extends LatinKeyboardBaseView {
|
||||
|
||||
static final int KEYCODE_OPTIONS = -100;
|
||||
static final int KEYCODE_SHIFT_LONGPRESS = -101;
|
||||
|
Loading…
x
Reference in New Issue
Block a user