From 0ead92bab06f492fde58457da1c06e2d75d977a1 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 27 Jun 2023 11:43:23 +0700 Subject: [PATCH] fix(language): fix review code from @tibbi Signed-off-by: Hung <> --- .../keyboard/activities/SettingsActivity.kt | 1 - .../simplemobiletools/keyboard/helpers/EmojiHelper.kt | 10 +++++----- .../keyboard/services/SimpleKeyboardIME.kt | 4 +--- .../simplemobiletools/keyboard/views/MyKeyboardView.kt | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt index 8681413..8b93961 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt @@ -14,7 +14,6 @@ import com.simplemobiletools.keyboard.extensions.getKeyboardLanguages import com.simplemobiletools.keyboard.helpers.KEYBOARD_HEIGHT_MULTIPLIER_LARGE import com.simplemobiletools.keyboard.helpers.KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM import com.simplemobiletools.keyboard.helpers.KEYBOARD_HEIGHT_MULTIPLIER_SMALL -import com.simplemobiletools.keyboard.helpers.LANGUAGE_VIETNAMESE_TELEX import kotlinx.android.synthetic.main.activity_settings.* import java.util.* import kotlin.system.exitProcess diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/EmojiHelper.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/EmojiHelper.kt index 9805c9d..54cff78 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/EmojiHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/EmojiHelper.kt @@ -5,7 +5,7 @@ import org.json.JSONObject import java.io.InputStream private var cachedEmojiData: MutableList? = null -val cachedVNTelexData: HashMap = HashMap() +val cachedVNTelexData: HashMap = HashMap() /** * Reads the emoji list at the given [path] and returns an parsed [MutableList]. If the @@ -64,18 +64,18 @@ fun parseRawEmojiSpecsFile(context: Context, path: String): MutableList } -fun parseRawJsonSpecsFile(context: Context, path: String): HashMap { +fun parseRawJsonSpecsFile(context: Context, path: String): HashMap { if (cachedVNTelexData.isNotEmpty()) { return cachedVNTelexData } try { - val inputStream: InputStream = context.assets.open(path) - val jsonString = inputStream.bufferedReader().use{it.readText()} + val inputStream: InputStream = context.assets.open(path) + val jsonString = inputStream.bufferedReader().use { it.readText() } val jsonData = JSONObject(jsonString) val rulesObj = jsonData.getJSONObject("rules") val ruleKeys = rulesObj.keys() - while (ruleKeys.hasNext()){ + while (ruleKeys.hasNext()) { val key = ruleKeys.next() val value = rulesObj.getString(key) cachedVNTelexData[key] = value diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt index 7018947..68045c0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -188,7 +188,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared val word = fullText.subSequence(lastIndexEmpty, fullText.length).trim().toString() val wordChars = word.toCharArray() val predictWord = StringBuilder() - for (char in wordChars.size -1 downTo 0) { + for (char in wordChars.size - 1 downTo 0) { predictWord.append(wordChars[char]) val shouldChangeText = predictWord.reverse().toString() if (cachedVNTelexData.containsKey(shouldChangeText)) { @@ -208,8 +208,6 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } } } - - } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index c344779..293b28a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -418,9 +418,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } setupEmojiPalette(toolbarColor = toolbarColor, backgroundColor = mBackgroundColor, textColor = mTextColor) - if(context.config.keyboardLanguage == LANGUAGE_VIETNAMESE_TELEX){ + if (context.config.keyboardLanguage == LANGUAGE_VIETNAMESE_TELEX) { setupLanguageTelex() - }else{ + } else { cachedVNTelexData.clear() } setupStoredClips()