Skip to content

Commit

Permalink
refactor: Key.java to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
nopdan authored and WhiredPlanck committed Jan 25, 2024
1 parent f053f45 commit 89593e3
Show file tree
Hide file tree
Showing 9 changed files with 610 additions and 684 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/osfans/trime/data/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Theme private constructor(isDarkMode: Boolean) {
Timber.d("Fetching done")
generalStyle = fullThemeConfigMap!!["style"] as Map<String, Any?>?
fallbackColors = fullThemeConfigMap!!["fallback_colors"] as Map<String, String>?
Key.presetKeys = fullThemeConfigMap!!["preset_keys"] as Map<String?, Map<String?, Any?>?>?
Key.presetKeys = fullThemeConfigMap!!["preset_keys"] as Map<String, Map<String, Any?>?>?
presetColorSchemes = fullThemeConfigMap!!["preset_color_schemes"] as Map<String, Map<String, Any>?>?
presetKeyboards = fullThemeConfigMap!!["preset_keyboards"] as Map<String, Any?>?
liquidKeyboard = fullThemeConfigMap!!["liquid_keyboard"] as Map<String, Any?>?
Expand Down Expand Up @@ -176,7 +176,7 @@ class Theme private constructor(isDarkMode: Boolean) {
}

fun getColor(
m: Map<String?, Any?>,
m: Map<String, Any?>,
key: String?,
): Int? {
var value = theme.getColorValue(m[key] as String?)
Expand All @@ -199,7 +199,7 @@ class Theme private constructor(isDarkMode: Boolean) {

// API 2.0
fun getDrawable(
m: Map<String?, Any?>,
m: Map<String, Any?>,
key: String,
): Drawable? {
var value = theme.getColorValue(m[key] as String?)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/osfans/trime/ime/enums/Keycode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,14 @@ enum class Keycode {
): String =
if (isStdKey(keyCode)) {
// Android keycode区域
if (Key.getKcm().isPrintingKey(keyCode)) {
if (Key.kcm.isPrintingKey(keyCode)) {
val event = KeyEvent(0, 0, KeyEvent.ACTION_DOWN, keyCode, 0, mask)
val charCode = event.getUnicodeChar(mask)
Timber.d("getDisplayLabel(): keycode=$keyCode, mask=$mask, charCode=$charCode")
if (charCode > 0) {
charCode.toChar().toString()
} else {
Key.getKcm().getDisplayLabel(keyCode).lowercase()
Key.kcm.getDisplayLabel(keyCode).lowercase()
}
} else {
keyNameOf(keyCode)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/osfans/trime/ime/keyboard/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Event(Keyboard keyboard, @NonNull String s) {
}
if (Key.presetKeys.containsKey(s)) {
// todo 把presetKeys缓存为presetKeyEvents,减少重新载入
Map<String, Object> presetKey = Key.presetKeys.get(s);
Map<String, Object> presetKey = (Map<String, Object>) Key.presetKeys.get(s);
command = CollectionUtils.obtainString(presetKey, "command", "");
option = CollectionUtils.obtainString(presetKey, "option", "");
select = CollectionUtils.obtainString(presetKey, "select", "");
Expand Down Expand Up @@ -104,7 +104,7 @@ public Event(Keyboard keyboard, @NonNull String s) {

shiftLabel = label;
if (Keycode.Companion.isStdKey(code)) { // Android keycode区域
if (Key.getKcm().isPrintingKey(code)) {
if (Key.kcm.isPrintingKey(code)) {
int mMask = KeyEvent.META_SHIFT_ON | mask;
KeyEvent event = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, code, 0, mMask);
int k = event.getUnicodeChar(mMask);
Expand Down
Loading

0 comments on commit 89593e3

Please sign in to comment.