diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 2a4eed68..ef93cd5c 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -963,7 +963,7 @@ 2段目の余白の微調整 3段目の両端の余白 キーの文字サイズ - 記号キーマップの文字サイズ + 記号キーマップ・数字フリック文字のサイズ 特殊キーの文字サイズ 特殊キーのアイコンサイズ 初期値に戻す diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f305c1d2..79c824d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1086,7 +1086,7 @@ Indent Small (Adjustment) Side Margin (Edge keys) Key Letter Size - Symbol Keymap Text Size + Symbol Map / Number Flick Text Size Special Key Text Size Special Key Icon Size Reset to Default diff --git a/qwerty_keyboard/src/androidTest/java/com/kazumaproject/qwerty_keyboard/ui/QwertyGuideTextSizeInstrumentedTest.kt b/qwerty_keyboard/src/androidTest/java/com/kazumaproject/qwerty_keyboard/ui/QwertyGuideTextSizeInstrumentedTest.kt new file mode 100644 index 00000000..09893733 --- /dev/null +++ b/qwerty_keyboard/src/androidTest/java/com/kazumaproject/qwerty_keyboard/ui/QwertyGuideTextSizeInstrumentedTest.kt @@ -0,0 +1,60 @@ +package com.kazumaproject.qwerty_keyboard.ui + +import android.content.Context +import android.view.ContextThemeWrapper +import android.view.View +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import com.kazumaproject.qwerty_keyboard.R +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class QwertyGuideTextSizeInstrumentedTest { + + @Test + fun guideTextSizeAppliesToLetterAndNumberKeyGuides() { + runOnMain { + val keyboard = createKeyboard() + + keyboard.setKeyMargins(symbolKeymapTextSizeSp = 15f) + + assertEquals(15f, keyboard.findViewById(R.id.key_a).guideTextSizeSp) + assertEquals(15f, keyboard.findViewById(R.id.key_1).guideTextSizeSp) + assertEquals(15f, keyboard.findViewById(R.id.key_0).guideTextSizeSp) + } + } + + @Test + fun guideTextSizeUsesQwertyButtonBounds() { + runOnMain { + val keyboard = createKeyboard() + val numberKey = keyboard.findViewById(R.id.key_1) + + keyboard.setKeyMargins(symbolKeymapTextSizeSp = 100f) + assertEquals(24f, numberKey.guideTextSizeSp) + + keyboard.setKeyMargins(symbolKeymapTextSizeSp = 1f) + assertEquals(4f, numberKey.guideTextSizeSp) + } + } + + private fun createKeyboard(): QWERTYKeyboardView { + val targetContext = InstrumentationRegistry.getInstrumentation().targetContext + val themedContext: Context = ContextThemeWrapper( + targetContext, + com.google.android.material.R.style.Theme_Material3_DayNight_NoActionBar + ) + return QWERTYKeyboardView(themedContext).apply { + val widthSpec = View.MeasureSpec.makeMeasureSpec(1080, View.MeasureSpec.EXACTLY) + val heightSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY) + measure(widthSpec, heightSpec) + layout(0, 0, 1080, 500) + } + } + + private fun runOnMain(block: () -> Unit) { + InstrumentationRegistry.getInstrumentation().runOnMainSync(block) + } +} diff --git a/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/QWERTYKeyboardView.kt b/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/QWERTYKeyboardView.kt index 65ed86f3..e4225bbc 100644 --- a/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/QWERTYKeyboardView.kt +++ b/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/QWERTYKeyboardView.kt @@ -777,7 +777,7 @@ class QWERTYKeyboardView @JvmOverloads constructor( applyLayoutForMode(qwertyMode.value) updateAllKeyTextSizes() - updateSymbolKeymapTextSizes() + updateGuideTextSizes() updateSpecialKeyTextSizes() refreshSpecialKeyIconSizesWhenLaidOut() } @@ -805,8 +805,9 @@ class QWERTYKeyboardView @JvmOverloads constructor( } } - private fun updateSymbolKeymapTextSizes() { - defaultQWERTYButtonsRoman.distinct().forEach { view -> + private fun updateGuideTextSizes() { + val guideButtons = defaultQWERTYButtonsRoman.asList() + numberRowButtons.asList() + guideButtons.distinct().forEach { view -> view.guideTextSizeSp = symbolKeymapTextSizeSp } } @@ -1314,6 +1315,13 @@ class QWERTYKeyboardView @JvmOverloads constructor( ) } + private val numberRowButtons: Array by lazy { + arrayOf( + binding.key1, binding.key2, binding.key3, binding.key4, binding.key5, + binding.key6, binding.key7, binding.key8, binding.key9, binding.key0 + ) + } + private fun attachDefaultKeyLabels() { val chars = if (romajiModeState.value) QWERTYKeys.DEFAULT_KEYS_JP else QWERTYKeys.DEFAULT_KEYS