diff --git a/app/src/main/java/com/sortug/thaiinput/MyKeyboardService.kt b/app/src/main/java/com/sortug/thaiinput/MyKeyboardService.kt index dff683e..af86289 100644 --- a/app/src/main/java/com/sortug/thaiinput/MyKeyboardService.kt +++ b/app/src/main/java/com/sortug/thaiinput/MyKeyboardService.kt @@ -13,6 +13,7 @@ import android.widget.Button import android.widget.HorizontalScrollView import android.widget.LinearLayout import android.widget.TextView +import androidx.core.content.res.ResourcesCompat import kotlin.properties.Delegates @@ -25,6 +26,7 @@ class MyKeyboardService : InputMethodService() { private lateinit var keyboardContainer: LinearLayout private lateinit var suggestionsContainer: LinearLayout private lateinit var currentInputDisplay: TextView + private lateinit var currentTitle: TextView private var isShiftActive = false private fun updateCurrentInputDisplay(text: String) { @@ -40,10 +42,13 @@ class MyKeyboardService : InputMethodService() { "ASDFGHJKL".toList(), "ZXCVBNM".toList() ) - + data class FontInfo(val resourceId: Int, val name: String) private val fonts = listOf( - Typeface.NORMAL, -// Typeface.createFromAsset(assets, "fonts/round.ttf") + FontInfo(R.font.charm_regular,"charm"), + FontInfo(R.font.ibmplexsansthai_regular,"ibm"), + FontInfo(R.font.chonburi_regular,"chonburi"), + FontInfo(R.font.judson_regular,"judson"), + FontInfo(R.font.kanit_regular, "kanit") ) private var currentFontIndex = 0 @@ -53,6 +58,7 @@ class MyKeyboardService : InputMethodService() { val inputView = layoutInflater.inflate(R.layout.keyboard_layout, null) // Initialize views using findViewById + currentTitle = inputView.findViewById(R.id.keyboard_title) currentInputDisplay = inputView.findViewById(R.id.current_input_display) suggestionsContainer = inputView.findViewById(R.id.suggestions_container) keyboardContainer = inputView.findViewById(R.id.keyboard_container) @@ -211,7 +217,6 @@ class MyKeyboardService : InputMethodService() { val button = Button(this).apply{ text = option textSize = 20f -// typeface = fonts[currentFontIndex] // Set the current font setOnClickListener { onSuggestionClicked(option) } layoutParams = LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, @@ -243,22 +248,17 @@ class MyKeyboardService : InputMethodService() { } private fun changeFont(_thing: String){ currentFontIndex = (currentFontIndex + 1) % fonts.size - Log.d("THAI_IME", "🔤 Changed font to index: $currentFontIndex") - // Refresh suggestions with new font - redrawCurrentSuggestions() - } - private fun redrawCurrentSuggestions() { - val currentButtons = mutableListOf() + val currentFont = fonts[currentFontIndex] + currentTitle.text = currentFont.name + val typeface = ResourcesCompat.getFont(this, currentFont.resourceId) for (i in 0 until suggestionsContainer.childCount) { val button = suggestionsContainer.getChildAt(i) as? Button - button?.text?.toString()?.let { currentButtons.add(it) } + button?.let{ + it.typeface = typeface + } } - displaySuggestions(currentButtons) } - - - // TODO: Add methods for handling shift and number toggle } object ViewDebugUtils { fun getViewHierarchy(view: View?, level: Int = 0): String { diff --git a/app/src/main/res/font/charm.xml b/app/src/main/res/font/charm.xml new file mode 100644 index 0000000..9296e2e --- /dev/null +++ b/app/src/main/res/font/charm.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/charm_bold.ttf b/app/src/main/res/font/charm_bold.ttf new file mode 100755 index 0000000..d32f072 Binary files /dev/null and b/app/src/main/res/font/charm_bold.ttf differ diff --git a/app/src/main/res/font/charm_regular.ttf b/app/src/main/res/font/charm_regular.ttf new file mode 100755 index 0000000..02013a4 Binary files /dev/null and b/app/src/main/res/font/charm_regular.ttf differ diff --git a/app/src/main/res/font/chonburi.xml b/app/src/main/res/font/chonburi.xml new file mode 100644 index 0000000..c64ce77 --- /dev/null +++ b/app/src/main/res/font/chonburi.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/font/chonburi_regular.ttf b/app/src/main/res/font/chonburi_regular.ttf new file mode 100755 index 0000000..52fedc7 Binary files /dev/null and b/app/src/main/res/font/chonburi_regular.ttf differ diff --git a/app/src/main/res/font/ibm.xml b/app/src/main/res/font/ibm.xml new file mode 100644 index 0000000..09dca83 --- /dev/null +++ b/app/src/main/res/font/ibm.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/ibmplexsansthai_bold.ttf b/app/src/main/res/font/ibmplexsansthai_bold.ttf new file mode 100755 index 0000000..3a8583f Binary files /dev/null and b/app/src/main/res/font/ibmplexsansthai_bold.ttf differ diff --git a/app/src/main/res/font/ibmplexsansthai_extralight.ttf b/app/src/main/res/font/ibmplexsansthai_extralight.ttf new file mode 100755 index 0000000..c4161bd Binary files /dev/null and b/app/src/main/res/font/ibmplexsansthai_extralight.ttf differ diff --git a/app/src/main/res/font/ibmplexsansthai_light.ttf b/app/src/main/res/font/ibmplexsansthai_light.ttf new file mode 100755 index 0000000..a676550 Binary files /dev/null and b/app/src/main/res/font/ibmplexsansthai_light.ttf differ diff --git a/app/src/main/res/font/ibmplexsansthai_medium.ttf b/app/src/main/res/font/ibmplexsansthai_medium.ttf new file mode 100755 index 0000000..75e62df Binary files /dev/null and b/app/src/main/res/font/ibmplexsansthai_medium.ttf differ diff --git a/app/src/main/res/font/ibmplexsansthai_regular.ttf b/app/src/main/res/font/ibmplexsansthai_regular.ttf new file mode 100755 index 0000000..c31b8c2 Binary files /dev/null and b/app/src/main/res/font/ibmplexsansthai_regular.ttf differ diff --git a/app/src/main/res/font/ibmplexsansthai_semibold.ttf b/app/src/main/res/font/ibmplexsansthai_semibold.ttf new file mode 100755 index 0000000..9812b5a Binary files /dev/null and b/app/src/main/res/font/ibmplexsansthai_semibold.ttf differ diff --git a/app/src/main/res/font/ibmplexsansthai_thin.ttf b/app/src/main/res/font/ibmplexsansthai_thin.ttf new file mode 100755 index 0000000..2cc968f Binary files /dev/null and b/app/src/main/res/font/ibmplexsansthai_thin.ttf differ diff --git a/app/src/main/res/font/judson.xml b/app/src/main/res/font/judson.xml new file mode 100644 index 0000000..a68b26b --- /dev/null +++ b/app/src/main/res/font/judson.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/judson_bold.ttf b/app/src/main/res/font/judson_bold.ttf new file mode 100755 index 0000000..4b977b0 Binary files /dev/null and b/app/src/main/res/font/judson_bold.ttf differ diff --git a/app/src/main/res/font/judson_italic.ttf b/app/src/main/res/font/judson_italic.ttf new file mode 100755 index 0000000..b2ea190 Binary files /dev/null and b/app/src/main/res/font/judson_italic.ttf differ diff --git a/app/src/main/res/font/judson_regular.ttf b/app/src/main/res/font/judson_regular.ttf new file mode 100755 index 0000000..a1cbb58 Binary files /dev/null and b/app/src/main/res/font/judson_regular.ttf differ diff --git a/app/src/main/res/font/kanit.xml b/app/src/main/res/font/kanit.xml new file mode 100644 index 0000000..13a6038 --- /dev/null +++ b/app/src/main/res/font/kanit.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/kanit_black.ttf b/app/src/main/res/font/kanit_black.ttf new file mode 100755 index 0000000..2e37a00 Binary files /dev/null and b/app/src/main/res/font/kanit_black.ttf differ diff --git a/app/src/main/res/font/kanit_blackitalic.ttf b/app/src/main/res/font/kanit_blackitalic.ttf new file mode 100755 index 0000000..dc81853 Binary files /dev/null and b/app/src/main/res/font/kanit_blackitalic.ttf differ diff --git a/app/src/main/res/font/kanit_bold.ttf b/app/src/main/res/font/kanit_bold.ttf new file mode 100755 index 0000000..4686906 Binary files /dev/null and b/app/src/main/res/font/kanit_bold.ttf differ diff --git a/app/src/main/res/font/kanit_bolditalic.ttf b/app/src/main/res/font/kanit_bolditalic.ttf new file mode 100755 index 0000000..17eda2a Binary files /dev/null and b/app/src/main/res/font/kanit_bolditalic.ttf differ diff --git a/app/src/main/res/font/kanit_extrabold.ttf b/app/src/main/res/font/kanit_extrabold.ttf new file mode 100755 index 0000000..5240d38 Binary files /dev/null and b/app/src/main/res/font/kanit_extrabold.ttf differ diff --git a/app/src/main/res/font/kanit_extrabolditalic.ttf b/app/src/main/res/font/kanit_extrabolditalic.ttf new file mode 100755 index 0000000..037187a Binary files /dev/null and b/app/src/main/res/font/kanit_extrabolditalic.ttf differ diff --git a/app/src/main/res/font/kanit_extralight.ttf b/app/src/main/res/font/kanit_extralight.ttf new file mode 100755 index 0000000..404c1e0 Binary files /dev/null and b/app/src/main/res/font/kanit_extralight.ttf differ diff --git a/app/src/main/res/font/kanit_extralightitalic.ttf b/app/src/main/res/font/kanit_extralightitalic.ttf new file mode 100755 index 0000000..5d575cc Binary files /dev/null and b/app/src/main/res/font/kanit_extralightitalic.ttf differ diff --git a/app/src/main/res/font/kanit_italic.ttf b/app/src/main/res/font/kanit_italic.ttf new file mode 100755 index 0000000..e6d868b Binary files /dev/null and b/app/src/main/res/font/kanit_italic.ttf differ diff --git a/app/src/main/res/font/kanit_light.ttf b/app/src/main/res/font/kanit_light.ttf new file mode 100755 index 0000000..3c9d4b5 Binary files /dev/null and b/app/src/main/res/font/kanit_light.ttf differ diff --git a/app/src/main/res/font/kanit_lightitalic.ttf b/app/src/main/res/font/kanit_lightitalic.ttf new file mode 100755 index 0000000..59a3f2e Binary files /dev/null and b/app/src/main/res/font/kanit_lightitalic.ttf differ diff --git a/app/src/main/res/font/kanit_medium.ttf b/app/src/main/res/font/kanit_medium.ttf new file mode 100755 index 0000000..50413d0 Binary files /dev/null and b/app/src/main/res/font/kanit_medium.ttf differ diff --git a/app/src/main/res/font/kanit_mediumitalic.ttf b/app/src/main/res/font/kanit_mediumitalic.ttf new file mode 100755 index 0000000..2c6aa14 Binary files /dev/null and b/app/src/main/res/font/kanit_mediumitalic.ttf differ diff --git a/app/src/main/res/font/kanit_regular.ttf b/app/src/main/res/font/kanit_regular.ttf new file mode 100755 index 0000000..ef204c1 Binary files /dev/null and b/app/src/main/res/font/kanit_regular.ttf differ diff --git a/app/src/main/res/font/kanit_semibold.ttf b/app/src/main/res/font/kanit_semibold.ttf new file mode 100755 index 0000000..7501a2e Binary files /dev/null and b/app/src/main/res/font/kanit_semibold.ttf differ diff --git a/app/src/main/res/font/kanit_semibolditalic.ttf b/app/src/main/res/font/kanit_semibolditalic.ttf new file mode 100755 index 0000000..2284650 Binary files /dev/null and b/app/src/main/res/font/kanit_semibolditalic.ttf differ diff --git a/app/src/main/res/font/kanit_thin.ttf b/app/src/main/res/font/kanit_thin.ttf new file mode 100755 index 0000000..5c835ad Binary files /dev/null and b/app/src/main/res/font/kanit_thin.ttf differ diff --git a/app/src/main/res/font/kanit_thinitalic.ttf b/app/src/main/res/font/kanit_thinitalic.ttf new file mode 100755 index 0000000..25fd1f9 Binary files /dev/null and b/app/src/main/res/font/kanit_thinitalic.ttf differ diff --git a/app/src/main/res/font/kodchasan_bold.ttf b/app/src/main/res/font/kodchasan_bold.ttf new file mode 100755 index 0000000..cd36ffc Binary files /dev/null and b/app/src/main/res/font/kodchasan_bold.ttf differ diff --git a/app/src/main/res/font/kodchasan_bolditalic.ttf b/app/src/main/res/font/kodchasan_bolditalic.ttf new file mode 100755 index 0000000..f86a715 Binary files /dev/null and b/app/src/main/res/font/kodchasan_bolditalic.ttf differ diff --git a/app/src/main/res/font/kodchasan_extralight.ttf b/app/src/main/res/font/kodchasan_extralight.ttf new file mode 100755 index 0000000..af416d2 Binary files /dev/null and b/app/src/main/res/font/kodchasan_extralight.ttf differ diff --git a/app/src/main/res/font/kodchasan_extralightitalic.ttf b/app/src/main/res/font/kodchasan_extralightitalic.ttf new file mode 100755 index 0000000..3478406 Binary files /dev/null and b/app/src/main/res/font/kodchasan_extralightitalic.ttf differ diff --git a/app/src/main/res/font/kodchasan_italic.ttf b/app/src/main/res/font/kodchasan_italic.ttf new file mode 100755 index 0000000..3032d77 Binary files /dev/null and b/app/src/main/res/font/kodchasan_italic.ttf differ diff --git a/app/src/main/res/font/kodchasan_light.ttf b/app/src/main/res/font/kodchasan_light.ttf new file mode 100755 index 0000000..b3db128 Binary files /dev/null and b/app/src/main/res/font/kodchasan_light.ttf differ diff --git a/app/src/main/res/font/kodchasan_lightitalic.ttf b/app/src/main/res/font/kodchasan_lightitalic.ttf new file mode 100755 index 0000000..5acfdd5 Binary files /dev/null and b/app/src/main/res/font/kodchasan_lightitalic.ttf differ diff --git a/app/src/main/res/font/kodchasan_medium.ttf b/app/src/main/res/font/kodchasan_medium.ttf new file mode 100755 index 0000000..de8f843 Binary files /dev/null and b/app/src/main/res/font/kodchasan_medium.ttf differ diff --git a/app/src/main/res/font/kodchasan_mediumitalic.ttf b/app/src/main/res/font/kodchasan_mediumitalic.ttf new file mode 100755 index 0000000..2c0cb1e Binary files /dev/null and b/app/src/main/res/font/kodchasan_mediumitalic.ttf differ diff --git a/app/src/main/res/font/kodchasan_regular.ttf b/app/src/main/res/font/kodchasan_regular.ttf new file mode 100755 index 0000000..b6cb5d5 Binary files /dev/null and b/app/src/main/res/font/kodchasan_regular.ttf differ diff --git a/app/src/main/res/font/kodchasan_semibold.ttf b/app/src/main/res/font/kodchasan_semibold.ttf new file mode 100755 index 0000000..917a988 Binary files /dev/null and b/app/src/main/res/font/kodchasan_semibold.ttf differ diff --git a/app/src/main/res/font/kodchasan_semibolditalic.ttf b/app/src/main/res/font/kodchasan_semibolditalic.ttf new file mode 100755 index 0000000..36d3579 Binary files /dev/null and b/app/src/main/res/font/kodchasan_semibolditalic.ttf differ diff --git a/app/src/main/res/font/mali_bold.ttf b/app/src/main/res/font/mali_bold.ttf new file mode 100755 index 0000000..db8c190 Binary files /dev/null and b/app/src/main/res/font/mali_bold.ttf differ diff --git a/app/src/main/res/font/mali_bolditalic.ttf b/app/src/main/res/font/mali_bolditalic.ttf new file mode 100755 index 0000000..a67a0ae Binary files /dev/null and b/app/src/main/res/font/mali_bolditalic.ttf differ diff --git a/app/src/main/res/font/mali_extralight.ttf b/app/src/main/res/font/mali_extralight.ttf new file mode 100755 index 0000000..0e3f955 Binary files /dev/null and b/app/src/main/res/font/mali_extralight.ttf differ diff --git a/app/src/main/res/font/mali_extralightitalic.ttf b/app/src/main/res/font/mali_extralightitalic.ttf new file mode 100755 index 0000000..6f4d3d3 Binary files /dev/null and b/app/src/main/res/font/mali_extralightitalic.ttf differ diff --git a/app/src/main/res/font/mali_italic.ttf b/app/src/main/res/font/mali_italic.ttf new file mode 100755 index 0000000..479a8e8 Binary files /dev/null and b/app/src/main/res/font/mali_italic.ttf differ diff --git a/app/src/main/res/font/mali_light.ttf b/app/src/main/res/font/mali_light.ttf new file mode 100755 index 0000000..aaad3b6 Binary files /dev/null and b/app/src/main/res/font/mali_light.ttf differ diff --git a/app/src/main/res/font/mali_lightitalic.ttf b/app/src/main/res/font/mali_lightitalic.ttf new file mode 100755 index 0000000..cdfa5c6 Binary files /dev/null and b/app/src/main/res/font/mali_lightitalic.ttf differ diff --git a/app/src/main/res/font/mali_medium.ttf b/app/src/main/res/font/mali_medium.ttf new file mode 100755 index 0000000..658a6a1 Binary files /dev/null and b/app/src/main/res/font/mali_medium.ttf differ diff --git a/app/src/main/res/font/mali_mediumitalic.ttf b/app/src/main/res/font/mali_mediumitalic.ttf new file mode 100755 index 0000000..4b88574 Binary files /dev/null and b/app/src/main/res/font/mali_mediumitalic.ttf differ diff --git a/app/src/main/res/font/mali_regular.ttf b/app/src/main/res/font/mali_regular.ttf new file mode 100755 index 0000000..70cd35b Binary files /dev/null and b/app/src/main/res/font/mali_regular.ttf differ diff --git a/app/src/main/res/font/mali_semibold.ttf b/app/src/main/res/font/mali_semibold.ttf new file mode 100755 index 0000000..acdce49 Binary files /dev/null and b/app/src/main/res/font/mali_semibold.ttf differ diff --git a/app/src/main/res/font/mali_semibolditalic.ttf b/app/src/main/res/font/mali_semibolditalic.ttf new file mode 100755 index 0000000..fc76e74 Binary files /dev/null and b/app/src/main/res/font/mali_semibolditalic.ttf differ diff --git a/app/src/main/res/font/sarabun_bold.ttf b/app/src/main/res/font/sarabun_bold.ttf new file mode 100755 index 0000000..4d6bf36 Binary files /dev/null and b/app/src/main/res/font/sarabun_bold.ttf differ diff --git a/app/src/main/res/font/sarabun_bolditalic.ttf b/app/src/main/res/font/sarabun_bolditalic.ttf new file mode 100755 index 0000000..42857a5 Binary files /dev/null and b/app/src/main/res/font/sarabun_bolditalic.ttf differ diff --git a/app/src/main/res/font/sarabun_extrabold.ttf b/app/src/main/res/font/sarabun_extrabold.ttf new file mode 100755 index 0000000..27ba997 Binary files /dev/null and b/app/src/main/res/font/sarabun_extrabold.ttf differ diff --git a/app/src/main/res/font/sarabun_extrabolditalic.ttf b/app/src/main/res/font/sarabun_extrabolditalic.ttf new file mode 100755 index 0000000..bc36f97 Binary files /dev/null and b/app/src/main/res/font/sarabun_extrabolditalic.ttf differ diff --git a/app/src/main/res/font/sarabun_extralight.ttf b/app/src/main/res/font/sarabun_extralight.ttf new file mode 100755 index 0000000..060c6c1 Binary files /dev/null and b/app/src/main/res/font/sarabun_extralight.ttf differ diff --git a/app/src/main/res/font/sarabun_extralightitalic.ttf b/app/src/main/res/font/sarabun_extralightitalic.ttf new file mode 100755 index 0000000..beaa024 Binary files /dev/null and b/app/src/main/res/font/sarabun_extralightitalic.ttf differ diff --git a/app/src/main/res/font/sarabun_italic.ttf b/app/src/main/res/font/sarabun_italic.ttf new file mode 100755 index 0000000..51d6dbe Binary files /dev/null and b/app/src/main/res/font/sarabun_italic.ttf differ diff --git a/app/src/main/res/font/sarabun_light.ttf b/app/src/main/res/font/sarabun_light.ttf new file mode 100755 index 0000000..d2f2291 Binary files /dev/null and b/app/src/main/res/font/sarabun_light.ttf differ diff --git a/app/src/main/res/font/sarabun_lightitalic.ttf b/app/src/main/res/font/sarabun_lightitalic.ttf new file mode 100755 index 0000000..75eb8d8 Binary files /dev/null and b/app/src/main/res/font/sarabun_lightitalic.ttf differ diff --git a/app/src/main/res/font/sarabun_medium.ttf b/app/src/main/res/font/sarabun_medium.ttf new file mode 100755 index 0000000..e03148e Binary files /dev/null and b/app/src/main/res/font/sarabun_medium.ttf differ diff --git a/app/src/main/res/font/sarabun_mediumitalic.ttf b/app/src/main/res/font/sarabun_mediumitalic.ttf new file mode 100755 index 0000000..b172a09 Binary files /dev/null and b/app/src/main/res/font/sarabun_mediumitalic.ttf differ diff --git a/app/src/main/res/font/sarabun_regular.ttf b/app/src/main/res/font/sarabun_regular.ttf new file mode 100755 index 0000000..50fa707 Binary files /dev/null and b/app/src/main/res/font/sarabun_regular.ttf differ diff --git a/app/src/main/res/font/sarabun_semibold.ttf b/app/src/main/res/font/sarabun_semibold.ttf new file mode 100755 index 0000000..7b760ce Binary files /dev/null and b/app/src/main/res/font/sarabun_semibold.ttf differ diff --git a/app/src/main/res/font/sarabun_semibolditalic.ttf b/app/src/main/res/font/sarabun_semibolditalic.ttf new file mode 100755 index 0000000..ecc5fb6 Binary files /dev/null and b/app/src/main/res/font/sarabun_semibolditalic.ttf differ diff --git a/app/src/main/res/font/sarabun_thin.ttf b/app/src/main/res/font/sarabun_thin.ttf new file mode 100755 index 0000000..cdaabcb Binary files /dev/null and b/app/src/main/res/font/sarabun_thin.ttf differ diff --git a/app/src/main/res/font/sarabun_thinitalic.ttf b/app/src/main/res/font/sarabun_thinitalic.ttf new file mode 100755 index 0000000..e96d17e Binary files /dev/null and b/app/src/main/res/font/sarabun_thinitalic.ttf differ diff --git a/app/src/main/res/font/voces_regular.ttf b/app/src/main/res/font/voces_regular.ttf new file mode 100755 index 0000000..36aa975 Binary files /dev/null and b/app/src/main/res/font/voces_regular.ttf differ