mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-21 22:59:10 +00:00
some fixes
This commit is contained in:
parent
a91a90bfbd
commit
40f39a70d0
6 changed files with 24 additions and 21 deletions
|
@ -7,7 +7,7 @@ android {
|
|||
buildToolsVersion = '34.0.0'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "helium314.keyboard.latin"
|
||||
applicationId "helium314.keyboard"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 34
|
||||
versionCode 1000
|
||||
|
|
|
@ -1,17 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2012 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.
|
||||
<!--
|
||||
Copyright (C) 2012 The Android Open Source Project
|
||||
modified
|
||||
SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
|
|
@ -204,10 +204,10 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
|
|||
val layoutName = Settings.readSymbolsLayoutName(context, params.mId.locale)
|
||||
val layout = if (layoutName.startsWith(CUSTOM_LAYOUT_PREFIX)) {
|
||||
val parser = if (layoutName.endsWith("json")) JsonKeyboardParser(params, context)
|
||||
else SimpleKeyboardParser(params, context)
|
||||
else SimpleKeyboardParser(params, context, false)
|
||||
parser.parseCoreLayout(getLayoutFile(layoutName, context).readText())
|
||||
} else {
|
||||
SimpleKeyboardParser(params, context).parseCoreLayout(context.readAssetsFile("layouts/$layoutName.txt"))
|
||||
SimpleKeyboardParser(params, context, false).parseCoreLayout(context.readAssetsFile("layouts/$layoutName.txt"))
|
||||
}
|
||||
layout.forEachIndexed { i, row ->
|
||||
val baseRow = baseKeys.getOrNull(i) ?: return@forEachIndexed
|
||||
|
|
|
@ -13,9 +13,11 @@ import helium314.keyboard.latin.common.splitOnWhitespace
|
|||
* for alphabet, 3 keys for symbols and 4 keys for shift symbols. MoreKeys on period and comma get
|
||||
* merged with defaults.
|
||||
*/
|
||||
class SimpleKeyboardParser(private val params: KeyboardParams, private val context: Context) : KeyboardParser(params, context) {
|
||||
private val addExtraKeys = params.mId.mSubtype.keyboardLayoutSetName.endsWith("+")
|
||||
|
||||
class SimpleKeyboardParser(
|
||||
private val params: KeyboardParams,
|
||||
context: Context,
|
||||
private val addExtraKeys: Boolean = params.mId.mSubtype.keyboardLayoutSetName.endsWith("+") && params.mId.isAlphabetKeyboard
|
||||
) : KeyboardParser(params, context) {
|
||||
override fun parseCoreLayout(layoutContent: String): MutableList<List<KeyData>> {
|
||||
val rowStrings = layoutContent.replace("\r\n", "\n").split("\\n\\s*\\n".toRegex())
|
||||
return rowStrings.mapIndexedNotNullTo(mutableListOf()) { i, row ->
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
|
||||
package helium314.keyboard.latin
|
||||
|
||||
import android.app.Application
|
||||
|
@ -9,6 +10,7 @@ import helium314.keyboard.latin.settings.Settings
|
|||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.upgradeToolbarPref
|
||||
import java.io.File
|
||||
|
||||
|
@ -33,6 +35,7 @@ class App : Application() {
|
|||
fun checkVersionUpgrade(context: Context) {
|
||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
||||
val oldVersion = prefs.getInt(Settings.PREF_VERSION_CODE, 0)
|
||||
Log.d("test", "old v $oldVersion, current ${BuildConfig.VERSION_CODE}")
|
||||
if (oldVersion == BuildConfig.VERSION_CODE)
|
||||
return
|
||||
upgradeToolbarPref(prefs)
|
||||
|
@ -85,6 +88,7 @@ private fun upgradesWhenComingFromOldAppName(context: Context) {
|
|||
}
|
||||
prefs.all.toMap().forEach {
|
||||
if (it.key.startsWith("pref_key_") && it.key != "pref_key_longpress_timeout") {
|
||||
Log.d("test", "adjusting ${it.key}")
|
||||
var remove = true
|
||||
when (val value = it.value) {
|
||||
is Boolean -> prefs.edit().putBoolean(it.key.substringAfter("pref_key_"), value).apply()
|
||||
|
@ -97,6 +101,7 @@ private fun upgradesWhenComingFromOldAppName(context: Context) {
|
|||
if (remove)
|
||||
prefs.edit().remove(it.key).apply()
|
||||
} else if (it.key.startsWith("pref_")) {
|
||||
Log.d("test", "adjusting ${it.key}")
|
||||
var remove = true
|
||||
when (val value = it.value) {
|
||||
is Boolean -> prefs.edit().putBoolean(it.key.substringAfter("pref_"), value).apply()
|
||||
|
@ -108,19 +113,24 @@ private fun upgradesWhenComingFromOldAppName(context: Context) {
|
|||
}
|
||||
if (remove)
|
||||
prefs.edit().remove(it.key).apply()
|
||||
} else {
|
||||
Log.d("test", "keeping ${it.key}")
|
||||
}
|
||||
}
|
||||
// change more_keys to popup_keys
|
||||
if (prefs.contains("more_keys_order")) {
|
||||
Log.d("test", "more_keys_order")
|
||||
prefs.edit().putString(Settings.PREF_POPUP_KEYS_ORDER, prefs.getString("more_keys_order", "")).apply()
|
||||
prefs.edit().remove("more_keys_order").apply()
|
||||
}
|
||||
if (prefs.contains("more_keys_labels_order")) {
|
||||
Log.d("test", "more_keys_labels_order")
|
||||
prefs.edit().putString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, prefs.getString("more_keys_labels_order", "")).apply()
|
||||
prefs.edit().remove("more_keys_labels_order").apply()
|
||||
}
|
||||
if (prefs.contains("more_more_keys")) {
|
||||
prefs.edit().putString(Settings.PREF_POPUP_KEYS_ORDER, prefs.getString("more_more_keys", "")).apply()
|
||||
Log.d("test", "more_more_keys")
|
||||
prefs.edit().putString(Settings.PREF_MORE_POPUP_KEYS, prefs.getString("more_more_keys", "")).apply()
|
||||
prefs.edit().remove("more_more_keys").apply()
|
||||
}
|
||||
// upgrade additional subtype locale strings
|
||||
|
|
|
@ -27,7 +27,7 @@ object ShadowLocaleManagerCompat {
|
|||
class ShadowInputMethodManager2 : ShadowInputMethodManager() {
|
||||
@Implementation
|
||||
override fun getInputMethodList() = listOf(
|
||||
InputMethodInfo("helium314.keyboard.latin.debug", "LatinIME", "openboard debug", null),
|
||||
InputMethodInfo("helium314.keyboard.debug", "LatinIME", "openboard debug", null),
|
||||
)
|
||||
@Implementation
|
||||
fun getShortcutInputMethodsAndSubtypes() = emptyMap<InputMethodInfo, List<InputMethodSubtype>>()
|
||||
|
|
Loading…
Add table
Reference in a new issue