adding the initial version of an own implementation of MyKeyboardView

This commit is contained in:
tibbi 2022-01-06 15:53:22 +01:00
parent 63ed037827
commit 46a33d2397
10 changed files with 2927 additions and 7 deletions

View File

@ -2,24 +2,24 @@ package com.simplemobiletools.keyboard.services
import android.inputmethodservice.InputMethodService
import android.inputmethodservice.Keyboard
import android.inputmethodservice.KeyboardView
import android.text.TextUtils
import android.view.KeyEvent
import android.view.View
import com.simplemobiletools.commons.extensions.performHapticFeedback
import com.simplemobiletools.keyboard.R
import com.simplemobiletools.keyboard.views.MyKeyboardView
// based on https://www.androidauthority.com/lets-build-custom-keyboard-android-832362/
class SimpleKeyboardIME : InputMethodService(), KeyboardView.OnKeyboardActionListener {
class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionListener {
private var keyboard: Keyboard? = null
private var keyboardView: KeyboardView? = null
private var keyboardView: MyKeyboardView? = null
private var caps = false
override fun onCreateInputView(): View {
keyboardView = layoutInflater.inflate(R.layout.keyboard_view, null) as KeyboardView
keyboardView = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null) as MyKeyboardView
keyboard = Keyboard(this, R.xml.keys_layout)
keyboardView!!.keyboard = keyboard
keyboardView!!.setOnKeyboardActionListener(this)
keyboardView!!.onKeyboardActionListener = this
return keyboardView!!
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,28 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.simplemobiletools.keyboard.views.MyKeyboardView
android:id="@+id/keyboardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/transparent"
android:keyPreviewLayout="@layout/keyboard_key_preview"
android:keyTextSize="22sp"
android:popupLayout="@layout/keyboard_popup_keyboard"
tools:ignore="ResourceCycle" />
<ImageButton
android:id="@+id/closeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:background="@android:color/transparent"
android:clickable="true"
android:src="@drawable/ic_cross_vector" />
</LinearLayout>

View File

@ -1,7 +1,7 @@
<android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
<com.simplemobiletools.keyboard.views.MyKeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:background="@color/default_background_color"
android:keyPreviewLayout="@layout/keyboard_preview" />
android:keyPreviewLayout="@layout/keyboard_key_preview" />

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="KeyboardViewPreviewState">
<attr name="state_long_pressable" format="boolean" />
</declare-styleable>
</resources>

View File

@ -3,4 +3,20 @@
<string name="app_launcher_name">Keyboard</string>
<string name="redirection_note">Please enable Simple Keyboard on the next screen, to make it an available keyboard. Press \'Back\' once enabled.</string>
<string name="change_keyboard">Change Keyboard</string>
<!-- KeyboardView - accessibility support -->
<!-- Description of the Alt button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_alt">Alt</string>
<!-- Description of the Cancel button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_cancel">Cancel</string>
<!-- Description of the Delete button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_delete">Delete</string>
<!-- Description of the Done button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_done">Done</string>
<!-- Description of the Mode change button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_mode_change">Mode change</string>
<!-- Description of the Shift button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_shift">Shift</string>
<!-- Description of the Enter button in a KeyboardView. [CHAR LIMIT=NONE] -->
<string name="keyboardview_keycode_enter">Enter</string>
</resources>

View File

@ -2,4 +2,34 @@
<style name="AppTheme" parent="AppTheme.Base" />
<declare-styleable name="KeyboardView">
<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" />
<!-- Horizontal offset of the text shadow. -->
<attr name="shadowDx" format="dimension" />
<!-- Vertical offset of the text shadow. -->
<attr name="shadowDy" format="dimension" />
<!-- Blur radius of the text shadow. -->
<attr name="shadowRadius" format="dimension" />
</declare-styleable>
</resources>