diff --git a/templates/Custom-Keyboard/.gitignore b/templates/Custom-Keyboard/.gitignore new file mode 100644 index 000000000..73042af80 --- /dev/null +++ b/templates/Custom-Keyboard/.gitignore @@ -0,0 +1,4 @@ +# The bundle and its provenance record are generated by the publish workflow. +# Neither is ever committed — see templates/README.md, "Build provenance". +*.cgt +cgt-build.properties diff --git a/templates/Custom-Keyboard/CustomKeyboard/.gitignore b/templates/Custom-Keyboard/CustomKeyboard/.gitignore new file mode 100644 index 000000000..b6bc0116e --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/.gitignore @@ -0,0 +1,83 @@ +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +/bin/ +/gen/ +/out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# Gradle files +.gradle/ +/build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/.gitignore b/templates/Custom-Keyboard/CustomKeyboard/app/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/build.gradle.kts.peb b/templates/Custom-Keyboard/CustomKeyboard/app/build.gradle.kts.peb new file mode 100644 index 000000000..9ed6825bf --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/build.gradle.kts.peb @@ -0,0 +1,149 @@ + +import java.util.Properties +import java.io.FileInputStream + +plugins { + alias(libs.plugins.android.application) +} + +val keystorePropsFile = rootProject.file("release.properties") +val keystoreProps = Properties() + +if (keystorePropsFile.exists()) { + keystoreProps.load(FileInputStream(keystorePropsFile)) +} + +val hasValidSigningProps = keystorePropsFile.exists().also { exists -> + if (exists) { + FileInputStream(keystorePropsFile).use { keystoreProps.load(it) } + } +}.let { + listOf("storeFile", "storePassword", + "keyAlias", "keyPassword").all { key -> + keystoreProps[key] != null + } +} + + +android { + namespace = "${{PACKAGE_NAME}}" + compileSdk = ${{COMPILE_SDK}} + + // disable linter + lint { + checkReleaseBuilds = false + } + + signingConfigs { + if (hasValidSigningProps) { + create("release") { + storeFile = rootProject.file(keystoreProps["storeFile"] as String) + storePassword = keystoreProps["storePassword"] as String + keyAlias = keystoreProps["keyAlias"] as String + keyPassword = keystoreProps["keyPassword"] as String + } + } + } + + defaultConfig { + applicationId = "${{PACKAGE_NAME}}" + minSdk = ${{MIN_SDK}} + targetSdk = ${{TARGET_SDK}} + versionCode = 1 + versionName = "1.0" + + vectorDrawables { + useSupportLibrary = true + } + } + + compileOptions { + sourceCompatibility = ${{JAVA_SOURCE_COMPAT}} + targetCompatibility = ${{JAVA_TARGET_COMPAT}} + } + + buildTypes { + release { + if (hasValidSigningProps) { + signingConfig = signingConfigs.getByName("release") + } + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + buildFeatures { + viewBinding = true + + } + packaging { + resources { + resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}") + resources.excludes.add("META-INF/kotlinx_coroutines_core.version") + + // The part below is only needed for compose builds. + // This packaging block is required to solve interdependency conflicts. + // They arise only when using local maven repo, so I suppose online repos have some way of solving such issues. + + // Caused by: com.android.builder.merge.DuplicateRelativeFileException: 4 files found with path 'commonMain/default/linkdata/module' from inputs: + // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\collection\collection\1.4.2\collection-1.4.2.jar + // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\lifecycle\lifecycle-common\2.8.7\lifecycle-common-2.8.7.jar + // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\annotation\annotation\1.8.1\annotation-1.8.1.jar + // - AndroidIDE\libs_source\gradle\localMvnRepository\org\jetbrains\kotlinx\kotlinx-coroutines-core\1.7.3\kotlinx-coroutines-core-1.7.3.jar + // And some others. + resources.pickFirsts.add("nonJvmMain/default/linkdata/package_androidx/0_androidx.knm") + resources.pickFirsts.add("nonJvmMain/default/linkdata/root_package/0_.knm") + resources.pickFirsts.add("nonJvmMain/default/linkdata/module") + + resources.pickFirsts.add("nativeMain/default/linkdata/root_package/0_.knm") + resources.pickFirsts.add("nativeMain/default/linkdata/module") + + resources.pickFirsts.add("commonMain/default/linkdata/root_package/0_.knm") + resources.pickFirsts.add("commonMain/default/linkdata/module") + resources.pickFirsts.add("commonMain/default/linkdata/package_androidx/0_androidx.knm") + + resources.pickFirsts.add("META-INF/kotlin-project-structure-metadata.json") + + resources.merges.add("commonMain/default/manifest") + resources.merges.add("nonJvmMain/default/manifest") + resources.merges.add("nativeMain/default/manifest") + } + } + + configurations.all { + resolutionStrategy { + // Force the use of Kotlin stdlib 1.9.22 for all modules + force("org.jetbrains.kotlin:kotlin-stdlib:${{KOTLIN_VERSION}}") + force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${{KOTLIN_VERSION}}") + force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${{KOTLIN_VERSION}}") + + // Force specific AndroidX versions to avoid conflicts + force("androidx.collection:collection:1.4.2") + force("androidx.annotation:annotation:1.8.1") + force("androidx.core:core-ktx:1.8.0") + force("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1") + force("androidx.collection:collection-ktx:1.4.2") + } + } +} + +tasks.withType { + options.compilerArgs.add("-Xlint:deprecation") +} + +kotlin { + compilerOptions { + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget("${{JAVA_TARGET}}")) + } +} + + +dependencies { + + + implementation(libs.androidx.appcompat) + implementation(libs.androidx.constraintlayout) + implementation(libs.android.material) + implementation(libs.androidx.startup.runtime) + implementation(libs.androidx.interpolator) +} diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/proguard-rules.pro b/templates/Custom-Keyboard/CustomKeyboard/app/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/AndroidManifest.xml b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..781dd97d9 --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/assets/layouts/01-english.json b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/assets/layouts/01-english.json new file mode 100644 index 000000000..cb4cb6479 --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/assets/layouts/01-english.json @@ -0,0 +1,25 @@ +{ + "name": "English", + "shortName": "EN", + "locale": "en-US", + "autoCapitalize": true, + "layers": { + "main": [ + ["q", "w", {"output": "e", "popup": ["é", "è", "ê", "ë"]}, "r", "t", "y", + {"output": "u", "popup": ["ú", "ü", "û"]}, {"output": "i", "popup": ["í", "ï", "î"]}, + {"output": "o", "popup": ["ó", "ö", "ô"]}, "p"], + [{"output": "a", "popup": ["á", "à", "â", "ä"]}, "s", "d", "f", "g", "h", "j", "k", "l"], + [{"type": "shift", "width": 1.5}, "z", "x", {"output": "c", "popup": ["ç"]}, "v", "b", + {"output": "n", "popup": ["ñ"]}, "m", {"type": "backspace", "width": 1.5}], + [{"type": "symbols", "width": 1.5}, {"type": "language"}, ",", {"type": "space", "width": 4}, + {"output": ".", "popup": ["?", "!", "'", "\""]}, {"type": "enter", "width": 1.5}] + ], + "symbols": [ + ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"], + ["@", "#", "$", "%", "&", "-", "+", "(", ")", "/"], + ["*", "\"", "'", ":", ";", "!", "?", "_", {"type": "backspace", "width": 2}], + [{"type": "letters", "width": 1.5}, {"type": "language"}, ",", {"type": "space", "width": 4}, + ".", {"type": "enter", "width": 1.5}] + ] + } +} diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/assets/layouts/02-hindi.json b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/assets/layouts/02-hindi.json new file mode 100644 index 000000000..b34fdd2ff --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/assets/layouts/02-hindi.json @@ -0,0 +1,37 @@ +{ + "name": "हिन्दी", + "shortName": "हि", + "locale": "hi-IN", + "layers": { + "main": [ + ["ा", "ि", "ी", {"output": "ु", "popup": ["ृ"]}, "ू", {"output": "े", "popup": ["ॅ"]}, "ै", + {"output": "ो", "popup": ["ॉ"]}, "ौ", {"output": "ं", "popup": ["ँ", "ः"]}, "्"], + [{"output": "क", "popup": ["क़", "क्ष"]}, {"output": "ख", "popup": ["ख़"]}, {"output": "ग", "popup": ["ग़"]}, + "घ", "ङ", "च", "छ", {"output": "ज", "popup": ["ज़", "ज्ञ"]}, "झ", "ञ", "ट"], + ["ठ", {"output": "ड", "popup": ["ड़"]}, {"output": "ढ", "popup": ["ढ़"]}, "ण", {"output": "त", "popup": ["त्र"]}, + "थ", "द", "ध", "न", "प", {"output": "फ", "popup": ["फ़"]}], + [{"type": "shift"}, "ब", "भ", "म", "य", {"output": "र", "popup": ["ऋ"]}, "ल", "व", + {"output": "स", "popup": ["श", "ष", "श्र"]}, "ह", {"type": "backspace"}], + [{"type": "symbols", "width": 1.5}, {"type": "language", "width": 1.5}, {"type": "space", "width": 5}, + {"output": "।", "popup": ["॥", ",", ".", "?"]}, {"type": "enter", "width": 2}] + ], + "shift": [ + ["अ", "आ", "इ", "ई", "उ", "ऊ", "ए", "ऐ", "ओ", "औ", "ऋ"], + ["क्ष", "त्र", "ज्ञ", "श्र", "श", "ष", "ऑ", "ॅ", "ॉ", "ँ", "ः"], + ["क़", "ख़", "ग़", "ज़", "ड़", "ढ़", "फ़", "़", "ृ", "ॐ", "ऽ"], + [{"type": "shift"}, "।", "॥", ",", ".", "?", "!", "-", "'", {"type": "backspace"}], + [{"type": "symbols", "width": 1.5}, {"type": "language", "width": 1.5}, {"type": "space", "width": 5}, + "।", {"type": "enter", "width": 2}] + ], + "symbols": [ + [{"output": "1", "popup": ["१"]}, {"output": "2", "popup": ["२"]}, {"output": "3", "popup": ["३"]}, + {"output": "4", "popup": ["४"]}, {"output": "5", "popup": ["५"]}, {"output": "6", "popup": ["६"]}, + {"output": "7", "popup": ["७"]}, {"output": "8", "popup": ["८"]}, {"output": "9", "popup": ["९"]}, + {"output": "0", "popup": ["०"]}], + ["@", "#", "₹", "%", "&", "-", "+", "(", ")", "/"], + ["*", "\"", "'", ":", ";", "!", "?", "_", {"type": "backspace", "width": 2}], + [{"type": "letters", "label": "कखग", "width": 1.5}, {"type": "language"}, ",", {"type": "space", "width": 4}, + "।", {"type": "enter", "width": 1.5}] + ] + } +} diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardLayout.kt.peb b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardLayout.kt.peb new file mode 100644 index 000000000..7a5415ddb --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardLayout.kt.peb @@ -0,0 +1,132 @@ +package ${{PACKAGE_NAME}} + +import android.content.Context +import android.util.Log +import org.json.JSONArray +import org.json.JSONObject +import java.util.Locale + +/** What a key does. Every type except CHARACTER is handled by [KeyboardService]. */ +enum class KeyType { CHARACTER, SHIFT, BACKSPACE, ENTER, SPACE, SYMBOLS, LETTERS, LANGUAGE } + +data class Key( + val type: KeyType, + val label: String, + // The text a CHARACTER key types. It may be several code points: a + // Devanagari conjunct such as "क्ष" is three. + val output: String = label, + // Alternatives offered on long-press. + val popup: List = emptyList(), + // Relative width; an ordinary key is 1. + val width: Float = 1f, +) { + fun uppercase(locale: Locale): Key = + if (type != KeyType.CHARACTER) this + else copy( + label = label.uppercase(locale), + output = output.uppercase(locale), + popup = popup.map { it.uppercase(locale) }, + ) +} + +typealias Row = List + +/** One keyboard language, read from a JSON file in assets/layouts. See the README. */ +class KeyboardLayout( + val name: String, + // Shown on the language key of the layout before this one, e.g. "EN". + val shortName: String, + val locale: Locale, + // Shift automatically at the start of a sentence, where the app asks for it. + val autoCapitalize: Boolean, + private val layers: Map>, +) { + fun layer(name: String): List = layers[name] ?: layers.getValue(MAIN) + + fun hasLayer(name: String): Boolean = name in layers + + // The keyboard keeps one height for all of a layout's layers, so it does not jump. + val heightInRows: Int = layers.values.maxOf { it.size } + + companion object { + const val MAIN = "main" + const val SHIFT = "shift" + const val SYMBOLS = "symbols" + + private const val TAG = "KeyboardLayout" + private const val DIR = "layouts" + + /** + * Every layout in assets/layouts, in file-name order. A file that does not + * parse is skipped and the reason logged, so a typo in one layout does not + * take the whole keyboard down. Run a debug build and read App Logs. + */ + fun loadAll(context: Context): List { + val files = context.assets.list(DIR).orEmpty().filter { it.endsWith(".json") }.sorted() + val layouts = files.mapNotNull { file -> + runCatching { + context.assets.open("$DIR/$file").bufferedReader().use { parse(it.readText()) } + }.onFailure { + Log.e(TAG, "Skipping $DIR/$file: ${it.message}") + }.getOrNull() + } + check(layouts.isNotEmpty()) { "No usable layout in assets/$DIR" } + return layouts + } + + fun parse(json: String): KeyboardLayout { + val root = JSONObject(json) + val locale = Locale.forLanguageTag(root.getString("locale")) + val layersJson = root.getJSONObject("layers") + val layers = mutableMapOf>() + for (name in layersJson.keys()) { + layers[name] = parseRows(layersJson.getJSONArray(name)) + } + require(MAIN in layers) { "no \"$MAIN\" layer" } + // A layout without a shift layer of its own gets its main layer in capitals. + if (SHIFT !in layers) { + layers[SHIFT] = layers.getValue(MAIN).map { row -> row.map { it.uppercase(locale) } } + } + return KeyboardLayout( + name = root.getString("name"), + shortName = root.getString("shortName"), + locale = locale, + autoCapitalize = root.optBoolean("autoCapitalize", false), + layers = layers, + ) + } + + private fun parseRows(rows: JSONArray): List = + (0 until rows.length()).map { r -> + val keys = rows.getJSONArray(r) + (0 until keys.length()).map { k -> parseKey(keys.get(k)) } + } + + // A key is either a plain string, which types itself, or an object. + private fun parseKey(spec: Any): Key { + if (spec is String) return Key(KeyType.CHARACTER, spec) + val obj = spec as? JSONObject ?: throw IllegalArgumentException("bad key: $spec") + val type = KeyType.valueOf(obj.optString("type", "character").uppercase(Locale.ROOT)) + val label = obj.optString("label", defaultLabel(type, obj)) + val popup = obj.optJSONArray("popup")?.let { a -> (0 until a.length()).map { a.getString(it) } } + return Key( + type = type, + label = label, + output = obj.optString("output", label), + popup = popup.orEmpty(), + width = obj.optDouble("width", 1.0).toFloat(), + ) + } + + private fun defaultLabel(type: KeyType, obj: JSONObject): String = when (type) { + KeyType.CHARACTER -> obj.getString("output") + KeyType.SHIFT -> "⇧" + KeyType.BACKSPACE -> "⌫" + KeyType.ENTER -> "⏎" + KeyType.SYMBOLS -> "?123" + KeyType.LETTERS -> "ABC" + // The view draws the layout name on SPACE and the next layout's name on LANGUAGE. + KeyType.SPACE, KeyType.LANGUAGE -> "" + } + } +} diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardService.kt.peb b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardService.kt.peb new file mode 100644 index 000000000..baa3fa325 --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardService.kt.peb @@ -0,0 +1,194 @@ +package ${{PACKAGE_NAME}} + +import android.inputmethodservice.InputMethodService +import android.os.SystemClock +import android.text.InputType +import android.view.KeyEvent +import android.view.View +import android.view.inputmethod.EditorInfo +import android.view.inputmethod.InputMethodManager +import ${{PACKAGE_NAME}}.KeyboardView.Shift + +/** + * The keyboard. Android starts it when the user picks this keyboard, and calls + * [onStartInputView] each time a text field gains focus. + * + * Never log what the user types: this service sees passwords too. + */ +class KeyboardService : InputMethodService(), KeyboardView.Listener { + + private lateinit var layouts: List + private var layoutIndex = 0 + private var layer = KeyboardLayout.MAIN + private var shift = Shift.OFF + private var lastShiftTap = 0L + private var view: KeyboardView? = null + + private val layout: KeyboardLayout + get() = layouts[layoutIndex] + + override fun onCreate() { + super.onCreate() + layouts = KeyboardLayout.loadAll(this) + layoutIndex = prefs().getInt(PREF_LAYOUT, 0).coerceIn(0, layouts.lastIndex) + } + + override fun onCreateInputView(): View = KeyboardView(this, this).also { view = it } + + override fun onStartInputView(info: EditorInfo, restarting: Boolean) { + super.onStartInputView(info, restarting) + // Number and phone fields open on the symbols layer, where the digits are. + val textClass = info.inputType and InputType.TYPE_MASK_CLASS + val numeric = textClass == InputType.TYPE_CLASS_NUMBER || textClass == InputType.TYPE_CLASS_PHONE + layer = if (numeric && layout.hasLayer(KeyboardLayout.SYMBOLS)) KeyboardLayout.SYMBOLS else KeyboardLayout.MAIN + shift = Shift.OFF + updateAutoCapitalize() + render() + } + + override fun onKey(key: Key, output: String) { + // Only two shift taps in a row make a double-tap. + if (key.type != KeyType.SHIFT) lastShiftTap = 0L + when (key.type) { + KeyType.CHARACTER -> { + currentInputConnection?.commitText(output, 1) + if (shift == Shift.ONCE) shift = Shift.OFF + updateAutoCapitalize() + } + KeyType.SPACE -> { + currentInputConnection?.commitText(" ", 1) + updateAutoCapitalize() + } + KeyType.BACKSPACE -> { + deleteBackward() + updateAutoCapitalize() + } + KeyType.ENTER -> { + pressEnter() + updateAutoCapitalize() + } + KeyType.SHIFT -> toggleShift() + KeyType.SYMBOLS -> layer = KeyboardLayout.SYMBOLS + KeyType.LETTERS -> { + layer = KeyboardLayout.MAIN + // Caps lock survives a trip to symbols; otherwise shift follows the sentence. + if (shift != Shift.LOCKED) { + shift = Shift.OFF + updateAutoCapitalize() + } + } + KeyType.LANGUAGE -> nextLayout() + } + render() + } + + override fun onKeyLongPress(key: Key) { + // Long-press on the language key lists every keyboard on the device. + if (key.type == KeyType.LANGUAGE) { + (getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager).showInputMethodPicker() + } + } + + private fun render() { + val v = view ?: return + val name = if (layer == KeyboardLayout.MAIN && shift != Shift.OFF) KeyboardLayout.SHIFT else layer + val next = layouts[(layoutIndex + 1) % layouts.size] + v.show(layout.layer(name), layout.heightInRows, shift, enterLabel(), layout.name, next.shortName) + } + + // Tap: shift the next letter. Double-tap: caps lock, whatever shift was before, + // including ONCE set by auto-capitalize. Tap again: off. + private fun toggleShift() { + val now = SystemClock.uptimeMillis() + val previous = shift + val doubleTap = now - lastShiftTap < DOUBLE_TAP_MS + shift = when { + previous == Shift.LOCKED -> Shift.OFF + doubleTap -> Shift.LOCKED + previous == Shift.OFF -> Shift.ONCE + else -> Shift.OFF + } + // A tap that locks or unlocks does not start another double-tap. + lastShiftTap = if (previous == Shift.LOCKED || shift == Shift.LOCKED) 0L else now + } + + private fun nextLayout() { + if (layouts.size == 1) { + (getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager).showInputMethodPicker() + return + } + layoutIndex = (layoutIndex + 1) % layouts.size + prefs().edit().putInt(PREF_LAYOUT, layoutIndex).apply() + layer = KeyboardLayout.MAIN + shift = Shift.OFF + updateAutoCapitalize() + } + + // Shift at the start of a sentence, if both the layout and the text field want it. + private fun updateAutoCapitalize() { + if (!layout.autoCapitalize || layer != KeyboardLayout.MAIN || shift == Shift.LOCKED) return + val info = currentInputEditorInfo ?: return + val caps = currentInputConnection?.getCursorCapsMode(info.inputType) ?: 0 + shift = if (caps != 0) Shift.ONCE else Shift.OFF + } + + private fun deleteBackward() { + val ic = currentInputConnection ?: return + if (!ic.getSelectedText(0).isNullOrEmpty()) { + ic.commitText("", 1) + return + } + val before = ic.getTextBeforeCursor(2, 0) + if (before.isNullOrEmpty()) { + // Nothing to delete as text. Some apps, terminals among them, want a key event. + sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL) + return + } + // Delete one code point. Devanagari removes a vowel sign before its consonant; + // an emoji outside the Basic Multilingual Plane is two UTF-16 units. + val pair = before.length == 2 && Character.isSurrogatePair(before[0], before[1]) + ic.deleteSurroundingText(if (pair) 2 else 1, 0) + } + + private fun pressEnter() { + val info = currentInputEditorInfo + val action = (info?.imeOptions ?: 0) and EditorInfo.IME_MASK_ACTION + if (hasEnterAction(info, action)) { + currentInputConnection?.performEditorAction(action) + } else { + sendKeyChar('\n') + } + } + + private fun hasEnterAction(info: EditorInfo?, action: Int): Boolean { + if (info == null) return false + val multiLine = info.inputType and InputType.TYPE_TEXT_FLAG_MULTI_LINE != 0 + val noAction = info.imeOptions and EditorInfo.IME_FLAG_NO_ENTER_ACTION != 0 + return !multiLine && !noAction && + action != EditorInfo.IME_ACTION_NONE && action != EditorInfo.IME_ACTION_UNSPECIFIED + } + + private fun enterLabel(): String { + val info = currentInputEditorInfo + val action = (info?.imeOptions ?: 0) and EditorInfo.IME_MASK_ACTION + if (!hasEnterAction(info, action)) return "⏎" + return getString( + when (action) { + EditorInfo.IME_ACTION_GO -> R.string.action_go + EditorInfo.IME_ACTION_SEARCH -> R.string.action_search + EditorInfo.IME_ACTION_SEND -> R.string.action_send + EditorInfo.IME_ACTION_NEXT -> R.string.action_next + EditorInfo.IME_ACTION_PREVIOUS -> R.string.action_previous + else -> R.string.action_done + }, + ) + } + + private fun prefs() = getSharedPreferences(PREFS, MODE_PRIVATE) + + private companion object { + const val PREFS = "keyboard" + const val PREF_LAYOUT = "layout" + const val DOUBLE_TAP_MS = 400L + } +} diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardView.kt.peb b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardView.kt.peb new file mode 100644 index 000000000..383aac23f --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/KeyboardView.kt.peb @@ -0,0 +1,410 @@ +package ${{PACKAGE_NAME}} + +import android.annotation.SuppressLint +import android.content.Context +import android.graphics.Canvas +import android.graphics.Paint +import android.graphics.Rect +import android.graphics.RectF +import android.os.Bundle +import android.util.TypedValue +import android.view.HapticFeedbackConstants +import android.view.MotionEvent +import android.view.View +import androidx.core.content.ContextCompat +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.accessibility.AccessibilityNodeInfoCompat +import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat +import androidx.customview.widget.ExploreByTouchHelper + +/** + * Draws one layer of a [KeyboardLayout] and reports key presses to a [Listener]. + * It holds no typing state of its own; [KeyboardService] decides what to show. + */ +@SuppressLint("ViewConstructor") +class KeyboardView(context: Context, private val listener: Listener) : View(context) { + + interface Listener { + /** [output] is the key's own text, or the alternative picked on long-press. */ + fun onKey(key: Key, output: String) + + fun onKeyLongPress(key: Key) + } + + enum class Shift { OFF, ONCE, LOCKED } + + private class KeyBox(val key: Key, val rect: RectF) + + private var rows: List = emptyList() + private var heightInRows = 1 + // Room left under the keys for the navigation bar. + private var bottomInset = 0 + private var boxes: List = emptyList() + private var shift = Shift.OFF + private var enterLabel = "" + private var layoutName = "" + private var nextLayoutName = "" + + private var pressed: KeyBox? = null + private var activePointer = -1 + private var lastX = 0f + private var longPressFired = false + private var popupOptions: List = emptyList() + private var popupRect = RectF() + private var popupSelection = 0 + + private val gap = dp(3f) + private val radius = dp(6f) + + // Text sizes are in sp so they follow the system font size, and the keys grow with them. + private val labelPaint = textPaint(sp(22f), R.color.key_text) + private val smallPaint = textPaint(sp(14f), R.color.key_text) + // Hints stay small at large font sizes, where a growing hint would cover the label. + private val hintPaint = textPaint(minOf(sp(11f), dp(14f)), R.color.key_hint) + + private val keyPaint = fillPaint(R.color.key_background) + private val specialPaint = fillPaint(R.color.key_special_background) + private val pressedPaint = fillPaint(R.color.key_pressed) + private val accentPaint = fillPaint(R.color.key_accent) + private val popupPaint = fillPaint(R.color.popup_background) + + private val longPress = Runnable { onLongPressTimeout() } + private val repeat = object : Runnable { + override fun run() { + val box = pressed ?: return + listener.onKey(box.key, box.key.output) + // The re-render may have dropped the press; then stop repeating. + if (pressed != null) postDelayed(this, REPEAT_INTERVAL_MS) + } + } + + private val accessibility = KeyAccessibility() + + init { + setBackgroundColor(ContextCompat.getColor(context, R.color.keyboard_background)) + ViewCompat.setAccessibilityDelegate(this, accessibility) + // From Android 15 a keyboard window is drawn edge to edge, behind the navigation + // bar. Keep the keys above it; the background still fills the space below. + ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets -> + val bottom = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom + if (bottom != bottomInset) { + bottomInset = bottom + requestLayout() + } + insets + } + } + + fun show( + rows: List, + heightInRows: Int, + shift: Shift, + enterLabel: String, + layoutName: String, + nextLayoutName: String, + ) { + this.rows = rows + this.heightInRows = maxOf(heightInRows, rows.size) + this.shift = shift + this.enterLabel = enterLabel + this.layoutName = layoutName + this.nextLayoutName = nextLayoutName + // Lay out now for the next frame; requestLayout() re-measures if the height changed. + if (width > 0) layoutKeys(width, height) + requestLayout() + accessibility.invalidateRoot() + invalidate() + } + + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + val width = MeasureSpec.getSize(widthMeasureSpec) + // The listener below can run after the first measure of a new view, so read the + // inset here too. + ViewCompat.getRootWindowInsets(this)?.let { + bottomInset = it.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom + } + val rowHeight = maxOf(dp(48f), labelPaint.textSize * 2.2f) + // At very large font sizes, stop before the keyboard hides the app entirely. + val maxHeight = resources.displayMetrics.heightPixels * 0.5f + val height = minOf(rowHeight * heightInRows, maxHeight) + gap * 2 + setMeasuredDimension(width, height.toInt() + bottomInset) + } + + override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { + layoutKeys(right - left, bottom - top) + } + + private fun layoutKeys(w: Int, h: Int) { + if (rows.isEmpty()) return + val rowHeight = (h - bottomInset - gap * 2) / rows.size + // One width unit for the whole layer, so keys line up from row to row. + // A row with less total width than the widest is centred. + val unit = (w - gap * 2) / rows.maxOf { row -> row.sumOf { it.width.toDouble() } }.toFloat() + val result = mutableListOf() + rows.forEachIndexed { r, row -> + val rowWidth = row.sumOf { it.width.toDouble() }.toFloat() * unit + var x = (w - rowWidth) / 2 + val top = gap + r * rowHeight + for (key in row) { + val keyWidth = key.width * unit + result += KeyBox(key, RectF(x, top, x + keyWidth, top + rowHeight)) + x += keyWidth + } + } + boxes = result + followPressedKey() + } + + // A key press can re-render the keyboard (backspace does, on every repeat), which + // replaces every KeyBox. Point the press at the same key in the new list, or drop it + // if the new layer has no such key where the finger is. + private fun followPressedKey() { + val old = pressed ?: return + val match = boxes.firstOrNull { + it.key == old.key && it.rect.contains(old.rect.centerX(), old.rect.centerY()) + } + if (match != null) pressed = match else cancel() + } + + override fun onDraw(canvas: Canvas) { + for (box in boxes) drawKey(canvas, box) + if (popupOptions.isNotEmpty()) drawPopup(canvas) + } + + private fun drawKey(canvas: Canvas, box: KeyBox) { + val key = box.key + val r = RectF(box.rect).apply { inset(gap, gap) } + val fill = when { + box === pressed && popupOptions.isEmpty() -> pressedPaint + key.type == KeyType.SHIFT && shift == Shift.LOCKED -> accentPaint + key.type == KeyType.SHIFT && shift == Shift.ONCE -> pressedPaint + key.type == KeyType.CHARACTER || key.type == KeyType.SPACE -> keyPaint + else -> specialPaint + } + canvas.drawRoundRect(r, radius, radius, fill) + + val (text, paint) = when (key.type) { + KeyType.SPACE -> layoutName to smallPaint + KeyType.LANGUAGE -> nextLayoutName to smallPaint + KeyType.ENTER -> enterLabel to (if (enterLabel.length > 2) smallPaint else labelPaint) + KeyType.SYMBOLS, KeyType.LETTERS -> key.label to smallPaint + else -> key.label to labelPaint + } + drawCentred(canvas, text, paint, r) + + // A small mark in the corner shows that a key has alternatives. + key.popup.firstOrNull()?.let { + val x = r.right - hintPaint.measureText(it) / 2 - gap + canvas.drawText(it, x, r.top + hintPaint.textSize * 1.1f, hintPaint) + } + } + + private fun drawPopup(canvas: Canvas) { + canvas.drawRoundRect(popupRect, radius, radius, popupPaint) + val cell = popupRect.width() / popupOptions.size + popupOptions.forEachIndexed { i, option -> + val r = RectF(popupRect.left + i * cell, popupRect.top, popupRect.left + (i + 1) * cell, popupRect.bottom) + if (i == popupSelection) canvas.drawRoundRect(RectF(r).apply { inset(gap, gap) }, radius, radius, accentPaint) + drawCentred(canvas, option, labelPaint, r) + } + } + + // Shrinks a label that is too wide for its key rather than letting it spill over. + private fun drawCentred(canvas: Canvas, text: String, paint: Paint, r: RectF) { + if (text.isEmpty()) return + val size = paint.textSize + val width = paint.measureText(text) + val room = r.width() * 0.85f + if (width > room) paint.textSize = size * room / width + val y = r.centerY() - (paint.descent() + paint.ascent()) / 2 + canvas.drawText(text, r.centerX(), y, paint) + paint.textSize = size + } + + @SuppressLint("ClickableViewAccessibility") + override fun onTouchEvent(event: MotionEvent): Boolean { + when (event.actionMasked) { + MotionEvent.ACTION_DOWN -> press(event.getPointerId(0), event.x, event.y) + MotionEvent.ACTION_POINTER_DOWN -> { + // A fast typist presses the next key before lifting the last one. + // Finish the first key now, then follow the new finger. + release() + val i = event.actionIndex + press(event.getPointerId(i), event.getX(i), event.getY(i)) + } + MotionEvent.ACTION_MOVE -> { + val i = event.findPointerIndex(activePointer) + if (i >= 0) move(event.getX(i), event.getY(i)) + } + MotionEvent.ACTION_UP -> release() + MotionEvent.ACTION_POINTER_UP -> + if (event.getPointerId(event.actionIndex) == activePointer) release() + MotionEvent.ACTION_CANCEL -> cancel() + } + return true + } + + private fun press(pointer: Int, x: Float, y: Float) { + val box = boxAt(x, y) ?: return + activePointer = pointer + pressed = box + lastX = x + longPressFired = false + performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP) + if (box.key.type == KeyType.BACKSPACE) { + listener.onKey(box.key, box.key.output) + if (pressed != null) postDelayed(repeat, REPEAT_DELAY_MS) + } else if (box.key.popup.isNotEmpty() || box.key.type == KeyType.LANGUAGE) { + postDelayed(longPress, LONG_PRESS_MS) + } + invalidate() + } + + private fun move(x: Float, y: Float) { + lastX = x + if (popupOptions.isNotEmpty()) { + selectPopupOptionAt(x) + return + } + // Sliding onto another key moves the press there, as on a physical keyboard. + val box = boxAt(x, y) + if (box != null && box !== pressed && pressed?.key?.type != KeyType.BACKSPACE) { + removeCallbacks(longPress) + pressed = box + if (box.key.popup.isNotEmpty() || box.key.type == KeyType.LANGUAGE) postDelayed(longPress, LONG_PRESS_MS) + invalidate() + } + } + + private fun release() { + val box = pressed + when { + box == null -> Unit + popupOptions.isNotEmpty() -> listener.onKey(box.key, popupOptions[popupSelection]) + longPressFired || box.key.type == KeyType.BACKSPACE -> Unit + else -> listener.onKey(box.key, box.key.output) + } + cancel() + } + + private fun cancel() { + removeCallbacks(longPress) + removeCallbacks(repeat) + pressed = null + activePointer = -1 + popupOptions = emptyList() + invalidate() + } + + private fun onLongPressTimeout() { + val box = pressed ?: return + longPressFired = true + if (box.key.popup.isEmpty()) { + listener.onKeyLongPress(box.key) + return + } + popupOptions = box.key.popup + // Above the key, the same height, kept inside the view. + val cell = box.rect.width() + val popupWidth = minOf(cell * popupOptions.size, width.toFloat()) + val left = (box.rect.centerX() - cell / 2).coerceIn(0f, width - popupWidth) + val top = (box.rect.top - box.rect.height()).coerceAtLeast(0f) + popupRect = RectF(left, top, left + popupWidth, top + box.rect.height()) + // Near the edge the popup shifts sideways, so the finger may already be over a + // later option. Select whatever is under it, as a move would. + selectPopupOptionAt(lastX) + performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) + } + + private fun selectPopupOptionAt(x: Float) { + val cell = popupRect.width() / popupOptions.size + popupSelection = ((x - popupRect.left) / cell).toInt().coerceIn(0, popupOptions.lastIndex) + invalidate() + } + + private fun boxAt(x: Float, y: Float): KeyBox? = boxes.firstOrNull { it.rect.contains(x, y) } + + override fun dispatchHoverEvent(event: MotionEvent): Boolean = + accessibility.dispatchHoverEvent(event) || super.dispatchHoverEvent(event) + + /** Exposes each key to TalkBack, which a custom-drawn view does not do by itself. */ + private inner class KeyAccessibility : ExploreByTouchHelper(this) { + override fun getVirtualViewAt(x: Float, y: Float): Int = + boxes.indexOfFirst { it.rect.contains(x, y) }.takeIf { it >= 0 } ?: INVALID_ID + + override fun getVisibleVirtualViews(ids: MutableList) { + boxes.indices.forEach { ids += it } + } + + override fun onPopulateNodeForVirtualView(id: Int, node: AccessibilityNodeInfoCompat) { + val box = boxes.getOrNull(id) + if (box == null) { + // A stale id after a layer change; give it an empty, valid node. + node.contentDescription = "" + node.setBoundsInParent(Rect()) + return + } + node.contentDescription = describe(box.key) + node.setBoundsInParent(Rect().also { box.rect.roundOut(it) }) + node.addAction(AccessibilityNodeInfoCompat.ACTION_CLICK) + if (box.key.type == KeyType.LANGUAGE) { + node.addAction(AccessibilityNodeInfoCompat.ACTION_LONG_CLICK) + } + // Each long-press alternative is a custom action in TalkBack's actions menu. + box.key.popup.zip(ALTERNATIVE_ACTIONS.asList()) { option, actionId -> + node.addAction(AccessibilityActionCompat(actionId, context.getString(R.string.key_alternative, option))) + } + } + + override fun onPerformActionForVirtualView(id: Int, action: Int, arguments: Bundle?): Boolean { + val box = boxes.getOrNull(id) ?: return false + when (action) { + AccessibilityNodeInfoCompat.ACTION_CLICK -> listener.onKey(box.key, box.key.output) + AccessibilityNodeInfoCompat.ACTION_LONG_CLICK -> listener.onKeyLongPress(box.key) + else -> { + val option = box.key.popup.getOrNull(ALTERNATIVE_ACTIONS.indexOf(action)) ?: return false + listener.onKey(box.key, option) + } + } + return true + } + + private fun describe(key: Key): String = when (key.type) { + KeyType.CHARACTER -> key.output + KeyType.SHIFT -> context.getString(R.string.key_shift) + KeyType.BACKSPACE -> context.getString(R.string.key_backspace) + KeyType.ENTER -> context.getString(R.string.key_enter) + KeyType.SPACE -> context.getString(R.string.key_space) + KeyType.SYMBOLS -> context.getString(R.string.key_symbols) + KeyType.LETTERS -> context.getString(R.string.key_letters) + KeyType.LANGUAGE -> context.getString(R.string.key_language, nextLayoutName) + } + } + + private fun dp(value: Float) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, resources.displayMetrics) + + private fun sp(value: Float) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, value, resources.displayMetrics) + + private fun textPaint(size: Float, color: Int) = Paint(Paint.ANTI_ALIAS_FLAG).apply { + textSize = size + textAlign = Paint.Align.CENTER + this.color = ContextCompat.getColor(context, color) + } + + private fun fillPaint(color: Int) = Paint(Paint.ANTI_ALIAS_FLAG).apply { + this.color = ContextCompat.getColor(context, color) + } + + private companion object { + // Custom accessibility actions need resource ids. Alternatives past the last id + // are not offered to TalkBack. + val ALTERNATIVE_ACTIONS = intArrayOf( + R.id.key_alternative_1, R.id.key_alternative_2, R.id.key_alternative_3, R.id.key_alternative_4, + R.id.key_alternative_5, R.id.key_alternative_6, R.id.key_alternative_7, R.id.key_alternative_8, + ) + const val LONG_PRESS_MS = 350L + const val REPEAT_DELAY_MS = 400L + const val REPEAT_INTERVAL_MS = 50L + } +} diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb new file mode 100644 index 000000000..adc4c47dc --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb @@ -0,0 +1,78 @@ + +package ${{PACKAGE_NAME}} + +import android.content.Intent +import android.os.Bundle +import android.provider.Settings +import android.view.inputmethod.InputMethodManager +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import ${{PACKAGE_NAME}}.databinding.ActivityMainBinding + +/** + * The setup screen. Android does not let an app turn itself on as a keyboard, + * so this walks the user through doing it in Settings. + */ +class MainActivity : AppCompatActivity() { + + private var _binding: ActivityMainBinding? = null + + private val binding: ActivityMainBinding + get() = checkNotNull(_binding) { "Activity has been destroyed" } + + private val imm by lazy { getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + _binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) + + // Keep content clear of the system bars (edge-to-edge is enforced on API 35+), + // and of the keyboard itself, so the "Try it" field scrolls into view above it. + ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets -> + val bars = insets.getInsets( + WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout() or + WindowInsetsCompat.Type.ime() + ) + v.setPadding(bars.left, bars.top, bars.right, bars.bottom) + insets + } + + binding.enableButton.setOnClickListener { + startActivity(Intent(Settings.ACTION_INPUT_METHOD_SETTINGS)) + } + binding.chooseButton.setOnClickListener { imm.showInputMethodPicker() } + } + + override fun onResume() { + super.onResume() + updateStatus() + } + + // The keyboard picker is a dialog over this activity, so onResume does not run when it closes. + override fun onWindowFocusChanged(hasFocus: Boolean) { + super.onWindowFocusChanged(hasFocus) + if (hasFocus) updateStatus() + } + + private fun updateStatus() { + val enabled = imm.enabledInputMethodList.any { it.packageName == packageName } + val current = Settings.Secure.getString(contentResolver, Settings.Secure.DEFAULT_INPUT_METHOD) + val selected = current?.startsWith("$packageName/") == true + binding.chooseButton.isEnabled = enabled + binding.statusText.setText( + when { + selected -> R.string.status_selected + enabled -> R.string.status_enabled + else -> R.string.status_disabled + }, + ) + } + + override fun onDestroy() { + super.onDestroy() + _binding = null + } +} diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 000000000..2b068d114 --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable/ic_launcher_background.xml b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 000000000..07d5da9cb --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable/ic_launcher_round.webp b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable/ic_launcher_round.webp new file mode 100644 index 000000000..ead67900d Binary files /dev/null and b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/drawable/ic_launcher_round.webp differ diff --git a/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/layout/activity_main.xml b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..6cc65b303 --- /dev/null +++ b/templates/Custom-Keyboard/CustomKeyboard/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + +