fix(language): fix review code from @tibbi
Signed-off-by: Hung <>
This commit is contained in:
parent
177be0205f
commit
0ead92bab0
|
@ -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
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.json.JSONObject
|
|||
import java.io.InputStream
|
||||
|
||||
private var cachedEmojiData: MutableList<String>? = null
|
||||
val cachedVNTelexData: HashMap<String,String> = HashMap()
|
||||
val cachedVNTelexData: HashMap<String, String> = 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<String>
|
|||
}
|
||||
|
||||
|
||||
fun parseRawJsonSpecsFile(context: Context, path: String): HashMap<String,String> {
|
||||
fun parseRawJsonSpecsFile(context: Context, path: String): HashMap<String, String> {
|
||||
if (cachedVNTelexData.isNotEmpty()) {
|
||||
return cachedVNTelexData
|
||||
}
|
||||
|
||||
try {
|
||||
val inputStream: InputStream = context.assets.open(path)
|
||||
val jsonString = inputStream.bufferedReader().use{it.readText()}
|
||||
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
|
||||
|
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue