From 7d91bf6549bab0069f8abaf58eaf9a59788e1ffc Mon Sep 17 00:00:00 2001
From: Potato Hatsue <1793913507@qq.com>
Date: Sun, 12 Nov 2023 22:37:50 -0500
Subject: [PATCH 001/281] F-Droid CI: Don't use dynamic linking GHC
---
app/org.fcitx.fcitx5.android.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/org.fcitx.fcitx5.android.yml b/app/org.fcitx.fcitx5.android.yml
index 62fdba70e..eb2277a5b 100644
--- a/app/org.fcitx.fcitx5.android.yml
+++ b/app/org.fcitx.fcitx5.android.yml
@@ -44,7 +44,6 @@ Builds:
- build-logic/convention/build
build:
- pushd $$fcitx5-android-prebuilder$$
- - cabal configure --disable-library-vanilla --enable-shared --enable-executable-dynamic --ghc-options=-dynamic
- ABI=%abi ANDROID_NDK_ROOT=$$NDK$$ CMAKE_VERSION=3.22.1 ANDROID_PLATFORM=23
COMP_SPELL_DICT=/usr/lib/x86_64-linux-gnu/fcitx5/libexec/comp-spell-dict
./build-cabal -j spell-dict fmt libevent libintl-lite boost marisa opencc libime lua chinese-addons-data zstd
From 377ac1a66caa322625a2757f6db0bc8651fba2bc Mon Sep 17 00:00:00 2001
From: Dmitry <87600810+gostsdmitry@users.noreply.github.com>
Date: Tue, 14 Nov 2023 10:15:29 +0700
Subject: [PATCH 002/281] Update fastlane translation (#380)
---
.../metadata/android/ru/full_description.txt | 20 ++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/fastlane/metadata/android/ru/full_description.txt b/fastlane/metadata/android/ru/full_description.txt
index 455ed0a6f..55f4e17d3 100644
--- a/fastlane/metadata/android/ru/full_description.txt
+++ b/fastlane/metadata/android/ru/full_description.txt
@@ -1,17 +1,27 @@
Поддерживаемые языки
- Английский (с проверкой орфографии)
-- Китайский (Pinyin, Shuangpin, Wubi, Cangjie и пользовательские таблицы)
-- Вьетнамский (на основе UniKey, поддерживает Telex, VNI и VIQR)
+- Китайский
+
+ - Pinyin, Shuangpin, Wubi, Cangjie и пользовательские таблицы (встроенные)
+ - Zhuyin/Bopomofo (через плагин Chewing)
+ - Jyutping (через плагин Jyutping)
+
+
+- Вьетнамский (через плагин UniKey, поддерживает Telex, VNI и VIQR)
+- Японский (через плагин Anthy)
+- Корейский (через плагин Hangul)
+- Сингальский (через плагин Sayura)
+- Универсальный (плагин Zhongzhouyun, поддерживает импорт пользовательских решений)
Функции
- Виртуальная клавиатура (раскладка пока не настраивается)
-- Постраничный расширяемый список кандидатов
+- Расширяемый обзор кандидатов
- Управление буфером обмена (только обычный текст)
- Темы (пользовательские цветовые схемы и фоновые изображения)
-- Предварительный просмотр всплывающего окна при нажатии клавиши
-- Нажмите и удерживайте, чтобы вызвать клавиатуру для быстрого ввода знаков препинания.
+- Всплывающее окно предварительного просмотра при нажатии клавиши
+- Длительное нажатие вызывает клавиатуру для быстрого ввода знаков препинания.
- Выбор символов и эмодзи
Функции в разработке
From 278c820ac4ab2f590ea39c97e1d2db0f0a44b8b4 Mon Sep 17 00:00:00 2001
From: Rocka
Date: Fri, 17 Nov 2023 22:56:18 +0800
Subject: [PATCH 003/281] Fix detecting other input methods on Android 14
---
app/src/main/AndroidManifest.xml | 5 ++++-
app/src/main/res/xml-v30/input_method.xml | 12 ------------
app/src/main/res/xml/input_method.xml | 5 ++++-
3 files changed, 8 insertions(+), 14 deletions(-)
delete mode 100644 app/src/main/res/xml-v30/input_method.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7c16296c4..07167884d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -21,6 +21,9 @@
+
+
+
diff --git a/app/src/main/res/xml-v30/input_method.xml b/app/src/main/res/xml-v30/input_method.xml
deleted file mode 100644
index d84c68696..000000000
--- a/app/src/main/res/xml-v30/input_method.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
diff --git a/app/src/main/res/xml/input_method.xml b/app/src/main/res/xml/input_method.xml
index 5bbf49e86..e10701f9b 100644
--- a/app/src/main/res/xml/input_method.xml
+++ b/app/src/main/res/xml/input_method.xml
@@ -1,7 +1,10 @@
+ android:supportsInlineSuggestions="true"
+ android:supportsSwitchingToNextInputMethod="true"
+ tools:targetApi="30">
Date: Sun, 3 Dec 2023 14:26:08 +0800
Subject: [PATCH 004/281] Update fcitx5 submodules
---
lib/fcitx5-chinese-addons/src/main/cpp/fcitx5-chinese-addons | 2 +-
lib/fcitx5/src/main/cpp/fcitx5 | 2 +-
lib/libime/src/main/cpp/libime | 2 +-
plugin/anthy/src/main/cpp/fcitx5-anthy | 2 +-
plugin/rime/src/main/cpp/fcitx5-rime | 2 +-
plugin/unikey/src/main/cpp/fcitx5-unikey | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/fcitx5-chinese-addons/src/main/cpp/fcitx5-chinese-addons b/lib/fcitx5-chinese-addons/src/main/cpp/fcitx5-chinese-addons
index 807be91e0..0f79e9be3 160000
--- a/lib/fcitx5-chinese-addons/src/main/cpp/fcitx5-chinese-addons
+++ b/lib/fcitx5-chinese-addons/src/main/cpp/fcitx5-chinese-addons
@@ -1 +1 @@
-Subproject commit 807be91e0fed18b919a2ba750038448163da400d
+Subproject commit 0f79e9be3778f2c5dd06e094c845234e49f98ed2
diff --git a/lib/fcitx5/src/main/cpp/fcitx5 b/lib/fcitx5/src/main/cpp/fcitx5
index f1404e3f7..64ae9d6d0 160000
--- a/lib/fcitx5/src/main/cpp/fcitx5
+++ b/lib/fcitx5/src/main/cpp/fcitx5
@@ -1 +1 @@
-Subproject commit f1404e3f7b80bddaae951a36e1bc78b183a4d760
+Subproject commit 64ae9d6d0e070d1f5657e7bb964f507afe6d7d10
diff --git a/lib/libime/src/main/cpp/libime b/lib/libime/src/main/cpp/libime
index 1045f2b94..59ae4a3ab 160000
--- a/lib/libime/src/main/cpp/libime
+++ b/lib/libime/src/main/cpp/libime
@@ -1 +1 @@
-Subproject commit 1045f2b94154d9d147cee90bdf8a25e1139206e4
+Subproject commit 59ae4a3ab4becdab164f29af07c502096c745b94
diff --git a/plugin/anthy/src/main/cpp/fcitx5-anthy b/plugin/anthy/src/main/cpp/fcitx5-anthy
index 1658a6aeb..1172f0343 160000
--- a/plugin/anthy/src/main/cpp/fcitx5-anthy
+++ b/plugin/anthy/src/main/cpp/fcitx5-anthy
@@ -1 +1 @@
-Subproject commit 1658a6aebd9a1bf61c62c88ada70a2e9e8eb5c84
+Subproject commit 1172f034313fb085e5b1e79382ad4f8fd03704cc
diff --git a/plugin/rime/src/main/cpp/fcitx5-rime b/plugin/rime/src/main/cpp/fcitx5-rime
index c32335c6b..9272fe6b1 160000
--- a/plugin/rime/src/main/cpp/fcitx5-rime
+++ b/plugin/rime/src/main/cpp/fcitx5-rime
@@ -1 +1 @@
-Subproject commit c32335c6b17b11d18078ec9e8ad1422b082c2bc3
+Subproject commit 9272fe6b14c9d7753fa18f001642fcdc4d067bd5
diff --git a/plugin/unikey/src/main/cpp/fcitx5-unikey b/plugin/unikey/src/main/cpp/fcitx5-unikey
index 1df3566d1..0a9f5645e 160000
--- a/plugin/unikey/src/main/cpp/fcitx5-unikey
+++ b/plugin/unikey/src/main/cpp/fcitx5-unikey
@@ -1 +1 @@
-Subproject commit 1df3566d1825f739bd58d0f041b6c46160ea0a52
+Subproject commit 0a9f5645ec979cd1cd44b9b78dadc1a21c24febf
From cd529e0c0abd1f2438bc5218c5e1349d8574d36b Mon Sep 17 00:00:00 2001
From: Rocka
Date: Sun, 3 Dec 2023 14:40:52 +0800
Subject: [PATCH 005/281] Remove client preedit workaround
---
.../cpp/androidfrontend/androidfrontend.cpp | 9 ---------
.../cpp/androidkeyboard/androidkeyboard.cpp | 20 ++++++++++---------
.../org/fcitx/fcitx5/android/core/Fcitx.kt | 3 ---
3 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/app/src/main/cpp/androidfrontend/androidfrontend.cpp b/app/src/main/cpp/androidfrontend/androidfrontend.cpp
index 60ce1ae36..4fec1c9bf 100644
--- a/app/src/main/cpp/androidfrontend/androidfrontend.cpp
+++ b/app/src/main/cpp/androidfrontend/androidfrontend.cpp
@@ -60,16 +60,7 @@ class AndroidInputContext : public InputContextV2 {
}
void updateInputPanel() {
- // Normally input method engine should check CapabilityFlag::Preedit before update clientPreedit,
- // and fcitx5 won't trigger UpdatePreeditEvent when that flag is not present, in which case
- // InputContext::updatePreeditImpl() won't be called.
- // However on Android, androidkeyboard uses clientPreedit unconditionally in order to provide
- // a more integrated experience, so we need to check clientPreedit update manually even if
- // clientPreedit is not enabled.
const InputPanel &ip = inputPanel();
- if (!isPreeditEnabled() && frontend_->instance()->inputMethod(this) == "keyboard-us") {
- frontend_->updateClientPreedit(filterText(ip.clientPreedit()));
- }
frontend_->updateInputPanel(
filterText(ip.preedit()),
filterText(ip.auxUp()),
diff --git a/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp b/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp
index 414f85a4a..420807e9f 100644
--- a/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp
+++ b/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp
@@ -269,15 +269,17 @@ void AndroidKeyboardEngine::updateCandidate(const InputMethodEntry &entry, Input
}
void AndroidKeyboardEngine::updateUI(InputContext *inputContext) {
- auto [preedit, cursor] = preeditWithCursor(inputContext);
- Text clientPreedit(preedit, TextFormatFlag::Underline);
- clientPreedit.setCursor(static_cast(cursor));
- inputContext->inputPanel().setClientPreedit(clientPreedit);
- // we don't want preedit here ...
-// if (!inputContext->capabilityFlags().test(CapabilityFlag::Preedit)) {
-// inputContext->inputPanel().setPreedit(preedit);
-// }
- inputContext->updatePreedit();
+ auto [text, cursor] = preeditWithCursor(inputContext);
+ if (inputContext->capabilityFlags().test(CapabilityFlag::Preedit)) {
+ Text clientPreedit(text, TextFormatFlag::Underline);
+ clientPreedit.setCursor(static_cast(cursor));
+ inputContext->inputPanel().setClientPreedit(clientPreedit);
+ inputContext->updatePreedit();
+ } else {
+ Text preedit(text);
+ preedit.setCursor(static_cast(cursor));
+ inputContext->inputPanel().setPreedit(preedit);
+ }
inputContext->updateUserInterface(UserInterfaceComponent::InputPanel);
}
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt b/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt
index d47361431..d50bd081c 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt
@@ -359,13 +359,10 @@ class Fcitx(private val context: Context) : FcitxAPI, FcitxLifecycleOwner {
getFcitxGlobalConfig()?.get("cfg")?.apply {
get("Behavior").apply {
get("ShareInputState").value = "All"
- get("PreeditEnabledByDefault").value = "False"
}
setFcitxGlobalConfig(this)
}
getFcitxAddonConfig("pinyin")?.get("cfg")?.apply {
- get("PreeditInApplication").value = "False"
- get("PreeditCursorPositionAtBeginning").value = "False"
get("QuickPhraseKey").value = ""
setFcitxAddonConfig("pinyin", this)
}
From beaef77e8872167d8b2b9c780d100b516b28b3d0 Mon Sep 17 00:00:00 2001
From: Rocka
Date: Sun, 3 Dec 2023 16:17:02 +0800
Subject: [PATCH 006/281] Update dependencies
targetSdk 34
---
app/build.gradle.kts | 1 +
app/src/main/AndroidManifest.xml | 8 ++-----
app/src/main/res/values-night/themes.xml | 4 ++--
app/src/main/res/values/themes.xml | 4 ++--
.../main/kotlin/AndroidAppConventionPlugin.kt | 1 +
.../convention/src/main/kotlin/Versions.kt | 6 +++---
gradle/libs.versions.toml | 21 ++++++++++---------
lib/plugin-base/src/debug/AndroidManifest.xml | 2 +-
.../src/main/AndroidManifest.xml | 2 +-
9 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index fc6c1364d..b0b0dbae5 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -114,6 +114,7 @@ dependencies {
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.room.paging)
+ implementation(libs.androidx.startup)
implementation(libs.androidx.viewpager2)
implementation(libs.material)
implementation(libs.arrow)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 07167884d..7a5aecc0d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -134,7 +134,8 @@
+ android:permission="${applicationId}.permission.IPC"
+ tools:ignore="SystemPermissionTypo">
@@ -158,11 +159,6 @@
android:exported="false"
tools:ignore="MissingClass"
tools:node="merge">
-
-
@android:color/transparent
- false
- @android:color/transparent
- - false
+ - false
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index f4c8693be..8a53d8641 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -12,14 +12,14 @@
- @android:color/transparent
- true
- @android:color/transparent
- - true
+ - true
diff --git a/build-logic/convention/src/main/kotlin/AndroidAppConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidAppConventionPlugin.kt
index c25394c55..0a8bbf436 100644
--- a/build-logic/convention/src/main/kotlin/AndroidAppConventionPlugin.kt
+++ b/build-logic/convention/src/main/kotlin/AndroidAppConventionPlugin.kt
@@ -64,6 +64,7 @@ class AndroidAppConventionPlugin : AndroidBaseConventionPlugin() {
tasks.findByName(DataDescriptorPlugin.TASK)?.also {
tasks.getByName("merge${variantName}Assets").dependsOn(it)
tasks.getByName("lintVitalAnalyzeRelease").dependsOn(it)
+ tasks.getByName("generateReleaseLintVitalReportModel").dependsOn(it)
}
}
}
diff --git a/build-logic/convention/src/main/kotlin/Versions.kt b/build-logic/convention/src/main/kotlin/Versions.kt
index a05c48bed..a2777fd2e 100644
--- a/build-logic/convention/src/main/kotlin/Versions.kt
+++ b/build-logic/convention/src/main/kotlin/Versions.kt
@@ -8,13 +8,13 @@ import org.gradle.api.Project
object Versions {
val java = JavaVersion.VERSION_11
- const val compileSdk = 33
+ const val compileSdk = 34
const val minSdk = 23
- const val targetSdk = 33
+ const val targetSdk = 34
private const val defaultCMake = "3.22.1"
private const val defaultNDK = "25.2.9519653"
- private const val defaultBuildTools = "33.0.2"
+ private const val defaultBuildTools = "34.0.0"
// NOTE: increase this value to bump version code
private const val baseVersionCode = 6
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 956736cbf..ea2a793c6 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,26 +1,26 @@
[versions]
-androidGradlePlugin = "8.1.2"
-androidDesugarJDKLibs = "2.0.3"
+androidGradlePlugin = "8.2.0"
+androidDesugarJDKLibs = "2.0.4"
kotlin = "1.9.20"
-ksp = "1.9.20-1.0.13"
+ksp = "1.9.20-1.0.14"
lifecycle = "2.6.2"
-navigation = "2.6.0"
-room = "2.5.2"
+navigation = "2.7.5"
+room = "2.6.1"
splitties = "3.0.0"
-aboutlibraries = "10.9.1"
+aboutlibraries = "10.9.2"
[libraries]
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
android-desugarJDKLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJDKLibs" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version = "1.7.3" }
-kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.0" }
-androidx-activity = { module = "androidx.activity:activity-ktx", version = "1.7.2" }
+kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.1" }
+androidx-activity = { module = "androidx.activity:activity-ktx", version = "1.8.1" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.6.1" }
androidx-autofill = { module = "androidx.autofill:autofill", version = "1.1.0" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version = "2.1.4" }
androidx-coordinatorlayout = { module = "androidx.coordinatorlayout:coordinatorlayout", version = "1.2.0" }
-androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.11.0-beta02" }
+androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.12.0" }
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
androidx-lifecycle-livedata = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" }
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
@@ -35,8 +35,9 @@ androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref =
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "room" }
+androidx-startup = { module = "androidx.startup:startup-runtime", version = "1.1.1" }
androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version = "1.1.0-beta02" }
-material = { module = "com.google.android.material:material", version = "1.9.0" }
+material = { module = "com.google.android.material:material", version = "1.10.0" }
arrow = { module = "io.arrow-kt:arrow-core", version = "1.2.1" }
imagecropper = { module = "com.vanniktech:android-image-cropper", version = "4.5.0" }
flexbox = { module = "com.google.android.flexbox:flexbox", version = "3.0.0" }
diff --git a/lib/plugin-base/src/debug/AndroidManifest.xml b/lib/plugin-base/src/debug/AndroidManifest.xml
index 9149acc34..6662c6746 100644
--- a/lib/plugin-base/src/debug/AndroidManifest.xml
+++ b/lib/plugin-base/src/debug/AndroidManifest.xml
@@ -15,7 +15,7 @@
android:directBootAware="true"
android:exported="true"
android:theme="@style/DeviceSettingsTheme"
- tools:targetApi="n">
+ tools:targetApi="24">
+ tools:targetApi="24">
From a2a67fc7cc0dddd230fbf317b1306a4ad00495c2 Mon Sep 17 00:00:00 2001
From: Rocka
Date: Sun, 3 Dec 2023 16:26:43 +0800
Subject: [PATCH 007/281] Expose input methods as subtypes on 34+
---
.../org/fcitx/fcitx5/android/core/Fcitx.kt | 6 +++
.../fcitx5/android/core/SubtypeManager.kt | 40 +++++++++++++++++++
.../android/input/status/StatusAreaWindow.kt | 5 ++-
.../settings/im/InputMethodListFragment.kt | 5 +++
.../fcitx5/android/utils/InputMethodUtil.kt | 15 +++----
.../org/fcitx/fcitx5/android/utils/Utils.kt | 4 ++
6 files changed, 64 insertions(+), 11 deletions(-)
create mode 100644 app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt b/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt
index d50bd081c..169ae99f5 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/core/Fcitx.kt
@@ -5,6 +5,7 @@
package org.fcitx.fcitx5.android.core
import android.content.Context
+import android.os.Build
import androidx.annotation.Keep
import androidx.core.content.ContextCompat
import kotlinx.coroutines.channels.BufferOverflow
@@ -425,6 +426,11 @@ class Fcitx(private val context: Context) : FcitxAPI, FcitxLifecycleOwner {
libraryDependency.toTypedArray()
)
}
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ lifecycle.launchWhenReady {
+ SubtypeManager.syncWith(enabledIme())
+ }
+ }
}
override fun nativeLoopOnce() {
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt b/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
new file mode 100644
index 000000000..17aa2ba98
--- /dev/null
+++ b/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
@@ -0,0 +1,40 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ * SPDX-FileCopyrightText: Copyright 2023 Fcitx5 for Android Contributors
+ */
+
+package org.fcitx.fcitx5.android.core
+
+import android.os.Build
+import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder
+import androidx.annotation.RequiresApi
+import org.fcitx.fcitx5.android.utils.InputMethodUtil
+import org.fcitx.fcitx5.android.utils.appContext
+import org.fcitx.fcitx5.android.utils.inputMethodManager
+
+object SubtypeManager {
+
+ private const val MODE_KEYBOARD = "keyboard"
+
+ @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
+ fun syncWith(inputMethods: Array) {
+ val subtypes = Array(inputMethods.size) { i ->
+ val im = inputMethods[i]
+ InputMethodSubtypeBuilder()
+ .setSubtypeId(im.uniqueName.hashCode())
+ .setSubtypeNameOverride(im.displayName)
+ .setSubtypeLocale(im.languageCode)
+ .setSubtypeMode(MODE_KEYBOARD)
+ .setIsAsciiCapable(im.uniqueName.startsWith(MODE_KEYBOARD))
+ .build()
+ }
+ val hashCodes = IntArray(subtypes.size) { subtypes[it].hashCode() }
+ val imm = appContext.inputMethodManager
+ val imiId = InputMethodUtil.serviceName
+ // although this method has been marked as deprecated,
+ // dynamic subtypes have to be "registered" before they can be "enabled"
+ @Suppress("DEPRECATION")
+ imm.setAdditionalInputMethodSubtypes(imiId, subtypes)
+ imm.setExplicitlyEnabledInputMethodSubtypes(imiId, hashCodes)
+ }
+}
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/input/status/StatusAreaWindow.kt b/app/src/main/java/org/fcitx/fcitx5/android/input/status/StatusAreaWindow.kt
index 6afb4b408..04bfb92de 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/input/status/StatusAreaWindow.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/input/status/StatusAreaWindow.kt
@@ -16,6 +16,7 @@ import org.fcitx.fcitx5.android.R
import org.fcitx.fcitx5.android.core.Action
import org.fcitx.fcitx5.android.daemon.FcitxConnection
import org.fcitx.fcitx5.android.daemon.launchOnReady
+import org.fcitx.fcitx5.android.core.SubtypeManager
import org.fcitx.fcitx5.android.data.prefs.AppPrefs
import org.fcitx.fcitx5.android.data.theme.ThemeManager
import org.fcitx.fcitx5.android.input.FcitxInputMethodService
@@ -34,7 +35,6 @@ import org.fcitx.fcitx5.android.input.wm.InputWindowManager
import org.fcitx.fcitx5.android.utils.AppUtil
import org.fcitx.fcitx5.android.utils.DeviceUtil
import org.fcitx.fcitx5.android.utils.alpha
-import org.fcitx.fcitx5.android.utils.styledFloat
import org.mechdancer.dependency.manager.must
import splitties.dimensions.dp
import splitties.resources.styledColor
@@ -143,6 +143,9 @@ class StatusAreaWindow : InputWindow.ExtendedInputWindow(),
}
ReloadConfig -> fcitx.launchOnReady { f ->
f.reloadConfig()
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ SubtypeManager.syncWith(f.enabledIme())
+ }
service.lifecycleScope.launch {
Toast.makeText(service, R.string.done, Toast.LENGTH_SHORT).show()
}
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/ui/main/settings/im/InputMethodListFragment.kt b/app/src/main/java/org/fcitx/fcitx5/android/ui/main/settings/im/InputMethodListFragment.kt
index b774437f5..481b822c9 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/ui/main/settings/im/InputMethodListFragment.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/ui/main/settings/im/InputMethodListFragment.kt
@@ -4,12 +4,14 @@
*/
package org.fcitx.fcitx5.android.ui.main.settings.im
+import android.os.Build
import android.view.View
import androidx.core.os.bundleOf
import androidx.navigation.findNavController
import org.fcitx.fcitx5.android.R
import org.fcitx.fcitx5.android.core.InputMethodEntry
import org.fcitx.fcitx5.android.daemon.launchOnReady
+import org.fcitx.fcitx5.android.core.SubtypeManager
import org.fcitx.fcitx5.android.ui.common.BaseDynamicListUi
import org.fcitx.fcitx5.android.ui.common.DynamicListUi
import org.fcitx.fcitx5.android.ui.common.OnItemChangedListener
@@ -21,6 +23,9 @@ class InputMethodListFragment : ProgressFragment(), OnItemChangedListener
f.setEnabledIme(ui.entries.map { it.uniqueName }.toTypedArray())
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ SubtypeManager.syncWith(f.enabledIme())
+ }
}
}
}
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt b/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt
index 6909cb68b..0baea40f1 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt
@@ -11,20 +11,15 @@ import android.os.Build
import android.provider.Settings
import android.view.inputmethod.InputMethodSubtype
import org.fcitx.fcitx5.android.input.FcitxInputMethodService
-import timber.log.Timber
-import java.util.TimeZone
object InputMethodUtil {
- private val serviceName =
+ val serviceName =
ComponentName(appContext, FcitxInputMethodService::class.java).flattenToShortString()
- private fun getSecureSettings(name: String) =
- Settings.Secure.getString(appContext.contentResolver, name)
-
- fun isEnabled(): Boolean =
- getSecureSettings(Settings.Secure.ENABLED_INPUT_METHODS)
- ?.split(":")?.contains(serviceName)
- ?: false
+ fun isEnabled(): Boolean {
+ val s = getSecureSettings(Settings.Secure.ENABLED_INPUT_METHODS) ?: return false
+ return s.split(':').map { it.substringBefore(';') }.contains(serviceName)
+ }
fun isSelected(): Boolean =
getSecureSettings(Settings.Secure.DEFAULT_INPUT_METHOD) == serviceName
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/utils/Utils.kt b/app/src/main/java/org/fcitx/fcitx5/android/utils/Utils.kt
index 7cfc9c547..4a1502622 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/utils/Utils.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/utils/Utils.kt
@@ -203,6 +203,10 @@ fun isSystemSettingEnabled(key: String): Boolean {
}
}
+fun getSecureSettings(name: String): String? {
+ return Settings.Secure.getString(appContext.contentResolver, name)
+}
+
/**
* @return top-level files in zip file
*/
From 885041d71e00789fe7d15d516b59efc70e1f6dc1 Mon Sep 17 00:00:00 2001
From: Rocka
Date: Sun, 3 Dec 2023 17:28:52 +0800
Subject: [PATCH 008/281] Avoid reading ENABLED_INPUT_METHODS on 34+
fix crash on samsung Android 14 devices
---
.../fcitx5/android/core/SubtypeManager.kt | 2 +-
.../fcitx5/android/ui/setup/SetupPage.kt | 11 ++++-----
.../fcitx5/android/utils/InputMethodUtil.kt | 24 +++++++++++++++----
3 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt b/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
index 17aa2ba98..87728b94e 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
@@ -30,7 +30,7 @@ object SubtypeManager {
}
val hashCodes = IntArray(subtypes.size) { subtypes[it].hashCode() }
val imm = appContext.inputMethodManager
- val imiId = InputMethodUtil.serviceName
+ val imiId = InputMethodUtil.componentName
// although this method has been marked as deprecated,
// dynamic subtypes have to be "registered" before they can be "enabled"
@Suppress("DEPRECATION")
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/ui/setup/SetupPage.kt b/app/src/main/java/org/fcitx/fcitx5/android/ui/setup/SetupPage.kt
index 3dee55775..f79a75255 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/ui/setup/SetupPage.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/ui/setup/SetupPage.kt
@@ -37,11 +37,10 @@ enum class SetupPage {
}
companion object {
- private val values = values()
- fun valueOf(value: Int) = values[value]
- fun SetupPage.isLastPage() = this == values.last()
- fun Int.isLastPage() = this == values.size - 1
- fun hasUndonePage() = values.any { !it.isDone() }
- fun firstUndonePage() = values.firstOrNull { !it.isDone() }
+ fun valueOf(value: Int) = entries[value]
+ fun SetupPage.isLastPage() = this == entries.last()
+ fun Int.isLastPage() = this == entries.size - 1
+ fun hasUndonePage() = entries.any { !it.isDone() }
+ fun firstUndonePage() = entries.firstOrNull { !it.isDone() }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt b/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt
index 0baea40f1..747421c32 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/utils/InputMethodUtil.kt
@@ -10,19 +10,33 @@ import android.content.Intent
import android.os.Build
import android.provider.Settings
import android.view.inputmethod.InputMethodSubtype
+import org.fcitx.fcitx5.android.BuildConfig
import org.fcitx.fcitx5.android.input.FcitxInputMethodService
object InputMethodUtil {
- val serviceName =
+
+ @JvmField
+ val serviceName: String = FcitxInputMethodService::class.java.name
+
+ @JvmField
+ val componentName: String =
ComponentName(appContext, FcitxInputMethodService::class.java).flattenToShortString()
fun isEnabled(): Boolean {
- val s = getSecureSettings(Settings.Secure.ENABLED_INPUT_METHODS) ?: return false
- return s.split(':').map { it.substringBefore(';') }.contains(serviceName)
+ return appContext.inputMethodManager.enabledInputMethodList.any {
+ it.packageName == BuildConfig.APPLICATION_ID && it.serviceName == serviceName
+ }
}
- fun isSelected(): Boolean =
- getSecureSettings(Settings.Secure.DEFAULT_INPUT_METHOD) == serviceName
+ fun isSelected(): Boolean {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ appContext.inputMethodManager.currentInputMethodInfo?.let {
+ it.packageName == BuildConfig.APPLICATION_ID && it.serviceName == serviceName
+ } ?: false
+ } else {
+ getSecureSettings(Settings.Secure.DEFAULT_INPUT_METHOD) == componentName
+ }
+ }
fun startSettingsActivity(context: Context) =
context.startActivity(Intent(Settings.ACTION_INPUT_METHOD_SETTINGS).apply {
From 8e504dbd1d909c9133bf59f026b2fb2c1c38971a Mon Sep 17 00:00:00 2001
From: Rocka
Date: Sun, 3 Dec 2023 21:32:19 +0800
Subject: [PATCH 009/281] Handle subtype switching via system input method
picker
---
.../fcitx5/android/core/SubtypeManager.kt | 30 +++++++++++++++----
.../android/input/FcitxInputMethodService.kt | 30 +++++++++++++++++++
2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt b/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
index 87728b94e..00706ed2a 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/core/SubtypeManager.kt
@@ -6,6 +6,7 @@
package org.fcitx.fcitx5.android.core
import android.os.Build
+import android.view.inputmethod.InputMethodSubtype
import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder
import androidx.annotation.RequiresApi
import org.fcitx.fcitx5.android.utils.InputMethodUtil
@@ -16,19 +17,38 @@ object SubtypeManager {
private const val MODE_KEYBOARD = "keyboard"
+ private const val IM_KEYBOARD = "keyboard-us"
+
+ private val knownSubtypes: HashMap = hashMapOf()
+
+ fun subtypeOf(inputMethod: String): InputMethodSubtype? {
+ return knownSubtypes[inputMethod]
+ }
+
+ fun inputMethodOf(subtype: InputMethodSubtype): String {
+ return subtype.extraValue.ifEmpty { IM_KEYBOARD }
+ }
+
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
fun syncWith(inputMethods: Array) {
- val subtypes = Array(inputMethods.size) { i ->
- val im = inputMethods[i]
- InputMethodSubtypeBuilder()
+ knownSubtypes.clear()
+ val size = inputMethods.size
+ val subtypes = arrayOfNulls(size)
+ val hashCodes = IntArray(size)
+ inputMethods.forEachIndexed { i, im ->
+ val subtype = InputMethodSubtypeBuilder()
.setSubtypeId(im.uniqueName.hashCode())
+ .setSubtypeExtraValue(im.uniqueName)
.setSubtypeNameOverride(im.displayName)
.setSubtypeLocale(im.languageCode)
.setSubtypeMode(MODE_KEYBOARD)
- .setIsAsciiCapable(im.uniqueName.startsWith(MODE_KEYBOARD))
+ .setIsAsciiCapable(im.uniqueName == IM_KEYBOARD)
.build()
+ val hashCode = subtype.hashCode()
+ subtypes[i] = subtype
+ hashCodes[i] = hashCode
+ knownSubtypes[im.uniqueName] = subtype
}
- val hashCodes = IntArray(subtypes.size) { subtypes[it].hashCode() }
val imm = appContext.inputMethodManager
val imiId = InputMethodUtil.componentName
// although this method has been marked as deprecated,
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/input/FcitxInputMethodService.kt b/app/src/main/java/org/fcitx/fcitx5/android/input/FcitxInputMethodService.kt
index 3925aae39..c9a75a484 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/input/FcitxInputMethodService.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/input/FcitxInputMethodService.kt
@@ -24,6 +24,7 @@ import android.view.inputmethod.CursorAnchorInfo
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InlineSuggestionsRequest
import android.view.inputmethod.InlineSuggestionsResponse
+import android.view.inputmethod.InputMethodSubtype
import android.widget.FrameLayout
import android.widget.inline.InlinePresentationSpec
import androidx.annotation.Keep
@@ -48,6 +49,7 @@ import org.fcitx.fcitx5.android.core.FcitxEvent
import org.fcitx.fcitx5.android.core.FormattedText
import org.fcitx.fcitx5.android.core.KeyStates
import org.fcitx.fcitx5.android.core.KeySym
+import org.fcitx.fcitx5.android.core.SubtypeManager
import org.fcitx.fcitx5.android.daemon.FcitxConnection
import org.fcitx.fcitx5.android.daemon.FcitxDaemon
import org.fcitx.fcitx5.android.data.InputFeedbacks
@@ -57,6 +59,7 @@ import org.fcitx.fcitx5.android.data.theme.Theme
import org.fcitx.fcitx5.android.data.theme.ThemeManager
import org.fcitx.fcitx5.android.input.cursor.CursorRange
import org.fcitx.fcitx5.android.input.cursor.CursorTracker
+import org.fcitx.fcitx5.android.utils.InputMethodUtil
import org.fcitx.fcitx5.android.utils.alpha
import org.fcitx.fcitx5.android.utils.inputMethodManager
import org.fcitx.fcitx5.android.utils.withBatchEdit
@@ -154,6 +157,11 @@ class FcitxInputMethodService : LifecycleInputMethodService() {
advanced.disableAnimation.registerOnChangeListener(recreateInputViewListener)
}
ThemeManager.addOnChangedListener(onThemeChangeListener)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ postFcitxJob {
+ SubtypeManager.syncWith(enabledIme())
+ }
+ }
super.onCreate()
}
@@ -204,6 +212,12 @@ class FcitxInputMethodService : LifecycleInputMethodService() {
val (before, after) = event.data
handleDeleteSurrounding(before, after)
}
+ is FcitxEvent.IMChangeEvent -> {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ val subtype = SubtypeManager.subtypeOf(event.data.uniqueName) ?: return
+ switchInputMethod(InputMethodUtil.componentName, subtype)
+ }
+ }
else -> {}
}
}
@@ -487,6 +501,22 @@ class FcitxInputMethodService : LifecycleInputMethodService() {
// ensure InputContext has been created before focusing it
activate(uid, pkgName)
}
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ val subtype = inputMethodManager.currentInputMethodSubtype ?: return
+ val im = SubtypeManager.inputMethodOf(subtype)
+ postFcitxJob {
+ activateIme(im)
+ }
+ }
+ }
+
+ override fun onCurrentInputMethodSubtypeChanged(newSubtype: InputMethodSubtype) {
+ super.onCurrentInputMethodSubtypeChanged(newSubtype)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ postFcitxJob {
+ activateIme(SubtypeManager.inputMethodOf(newSubtype))
+ }
+ }
}
override fun onStartInput(attribute: EditorInfo, restarting: Boolean) {
From b0b2590bb2191be589d14bf873e8f17a0c5a668e Mon Sep 17 00:00:00 2001
From: Potato Hatsue <1793913507@qq.com>
Date: Mon, 4 Dec 2023 01:16:22 -0500
Subject: [PATCH 010/281] Update nix
---
flake.lock | 6 +++---
flake.nix | 13 +++++++------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/flake.lock b/flake.lock
index 75f9e9943..17a4ea0c3 100644
--- a/flake.lock
+++ b/flake.lock
@@ -36,11 +36,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1697059129,
- "narHash": "sha256-9NJcFF9CEYPvHJ5ckE8kvINvI84SZZ87PvqMbH6pro0=",
+ "lastModified": 1701253981,
+ "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "5e4c2ada4fcd54b99d56d7bd62f384511a7e2593",
+ "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index 43201a07a..3c0db1ce3 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,9 +31,9 @@
# Update versions here
# This should match to build-logic/convention/src/main/kotlin/Versions.kt
cmakeVersion = "3.22.1";
- buildToolsVersion = "33.0.2";
- platformToolsVersion = "33.0.3";
- platformVersion = "33";
+ buildToolsVersion = "34.0.0";
+ platformToolsVersion = "34.0.5";
+ platformVersion = "34";
ndkVersion = "25.2.9519653";
includeNDK = true;
@@ -47,7 +47,7 @@
};
shell = final.lib.makeOverridable
- ({ androidStudio, generateLocalProperties }:
+ ({ androidStudio, generateLocalProperties, exportCMakeBin }:
with final;
with self;
mkShell rec {
@@ -68,14 +68,15 @@
"-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidComposition.androidsdk}/libexec/android-sdk/build-tools/${buildToolsVersion}/aapt2";
ECM_DIR = "${extra-cmake-modules}/share/ECM/cmake/";
JAVA_HOME = "${jdk17}";
- shellHook = ''
+ shellHook = lib.optionalString exportCMakeBin ''
export PATH="$ANDROID_SDK_ROOT/cmake/${cmakeVersion}/bin:$PATH"
'' + lib.optionalString generateLocalProperties ''
echo sdk.dir=$ANDROID_SDK_ROOT > local.properties
'';
}) {
- androidStudio = final.androidStudioPackages.stable;
+ androidStudio = final.androidStudioPackages.beta;
generateLocalProperties = true;
+ exportCMakeBin = true;
};
});
};
From 3472543be3664ed7dcff20297aafa77e2d5ea97b Mon Sep 17 00:00:00 2001
From: Rocka
Date: Fri, 8 Dec 2023 23:25:59 +0800
Subject: [PATCH 011/281] Fix crash in androidkeyboard when commit characters
with byte length > 1
---
app/src/main/cpp/androidkeyboard/androidkeyboard.cpp | 3 ++-
app/src/main/cpp/androidkeyboard/androidkeyboard.h | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp b/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp
index 420807e9f..9cee5de69 100644
--- a/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp
+++ b/app/src/main/cpp/androidkeyboard/androidkeyboard.cpp
@@ -322,8 +322,9 @@ void AndroidKeyboardEngine::commitBuffer(InputContext *inputContext) {
if (preedit.empty()) {
return;
}
+ auto characterCount = utf8::length(preedit, 0, cursor);
if (inputContext->capabilityFlags().test(CapabilityFlag::CommitStringWithCursor)) {
- inputContext->commitStringWithCursor(preedit, cursor);
+ inputContext->commitStringWithCursor(preedit, characterCount);
} else {
inputContext->commitString(preedit);
}
diff --git a/app/src/main/cpp/androidkeyboard/androidkeyboard.h b/app/src/main/cpp/androidkeyboard/androidkeyboard.h
index 377ed2de8..f16af96a8 100644
--- a/app/src/main/cpp/androidkeyboard/androidkeyboard.h
+++ b/app/src/main/cpp/androidkeyboard/androidkeyboard.h
@@ -107,6 +107,9 @@ class AndroidKeyboardEngine final : public InputMethodEngineV3 {
private:
bool supportHint(const std::string &language);
+ /**
+ * preedit string and byte cursor
+ */
std::pair preeditWithCursor(InputContext *inputContext);
Instance *instance_;
From 12aa5784dccc526ec329de3b1f09b618694ef0bf Mon Sep 17 00:00:00 2001
From: Rocka
Date: Thu, 14 Dec 2023 21:04:13 +0800
Subject: [PATCH 012/281] Make sure lastSymbolType is updated at every layout
switch
---
.../fcitx/fcitx5/android/input/keyboard/KeyboardWindow.kt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/KeyboardWindow.kt b/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/KeyboardWindow.kt
index f54e1b22b..26dcded01 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/KeyboardWindow.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/KeyboardWindow.kt
@@ -117,17 +117,18 @@ class KeyboardWindow : InputWindow.SimpleInputWindow(), Essentia
}
fun switchLayout(to: String, remember: Boolean = true) {
- if (to == currentKeyboardName) return
val target = to.ifEmpty { lastSymbolType }
ContextCompat.getMainExecutor(service).execute {
if (keyboards.containsKey(target)) {
if (remember && target != TextKeyboard.Name) {
lastSymbolType = target
}
+ if (target == currentKeyboardName) return@execute
detachCurrentLayout()
attachLayout(target)
- if (windowManager.isAttached(this))
+ if (windowManager.isAttached(this)) {
notifyBarLayoutChanged()
+ }
} else {
if (remember) {
lastSymbolType = PickerWindow.Key.Symbol.name
From d55ca8c103f950dae9c53b456b4f765bee88bf98 Mon Sep 17 00:00:00 2001
From: Rocka
Date: Sun, 17 Dec 2023 22:14:36 +0800
Subject: [PATCH 013/281] Apply kotlin 1.9 suggestions
---
.../fcitx5/android/ui/main/MainActivity.kt | 130 +++++++++---------
.../fcitx5/android/ui/setup/SetupActivity.kt | 4 +-
2 files changed, 68 insertions(+), 66 deletions(-)
diff --git a/app/src/main/java/org/fcitx/fcitx5/android/ui/main/MainActivity.kt b/app/src/main/java/org/fcitx/fcitx5/android/ui/main/MainActivity.kt
index f13b12dbd..96d330924 100644
--- a/app/src/main/java/org/fcitx/fcitx5/android/ui/main/MainActivity.kt
+++ b/app/src/main/java/org/fcitx/fcitx5/android/ui/main/MainActivity.kt
@@ -115,80 +115,82 @@ class MainActivity : AppCompatActivity() {
}
}
- override fun onCreateOptionsMenu(menu: Menu): Boolean = menu.run {
- add(R.string.save).apply {
- icon = drawable(R.drawable.ic_baseline_save_24)!!.apply {
- setTint(styledColor(android.R.attr.colorControlNormal))
- }
- setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
- viewModel.toolbarSaveButtonOnClickListener.apply {
- observe(this@MainActivity) { listener -> isVisible = listener != null }
- setValue(value)
- }
- setOnMenuItemClickListener {
- viewModel.toolbarSaveButtonOnClickListener.value?.invoke()
- true
- }
- }
- val aboutMenus = mutableListOf