From 6c600b758bc8fbc9d2fc4a43931e0d2a535e793d Mon Sep 17 00:00:00 2001 From: KazumaProject <59742125+KazumaProject@users.noreply.github.com> Date: Wed, 17 Jun 2026 00:31:07 -0400 Subject: [PATCH 1/3] fix build --- .github/workflows/android.yml | 18 +++++++--- .../ime_service/IMEService.kt | 34 +++++++++++++++++-- .../ime_service/ImePreferencesSnapshot.kt | 6 ++++ .../image_effect/FluidInkEffectView.kt | 6 ++-- .../image_effect/FluidInkRenderer.kt | 2 ++ .../image_effect/FluidInputCommand.kt | 8 ++++- .../image_effect/FluidSimulation.kt | 32 +++++++++++++++-- .../setting_activity/AppPreference.kt | 30 +++++++++++++++- .../ui/setting/CommonPreferenceFragment.kt | 22 ++++++++++++ .../ui/setting/SettingCardEditorController.kt | 3 ++ .../ui/setting/SettingDestination.kt | 2 ++ .../ui/setting/SettingSearchIndex.kt | 6 ++++ app/src/main/res/values-ja/strings.xml | 4 +++ app/src/main/res/values/strings.xml | 4 +++ app/src/main/res/xml/pref_common_legacy.xml | 20 +++++++++++ .../main/res/xml/pref_keyboard_display.xml | 20 +++++++++++ gradle.properties | 2 +- 17 files changed, 204 insertions(+), 15 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1727828f..d1ece16c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -60,12 +60,20 @@ jobs: - name: Build Release Variants run: | ./gradlew clean \ - assembleFullStandardRelease \ - assembleLiteStandardRelease \ + :app:assembleFullStandardRelease \ -PsplitApks \ - --stacktrace - ./gradlew assembleLiteFdroidRelease \ - --stacktrace + --stacktrace \ + --no-daemon \ + --max-workers=1 + ./gradlew :app:assembleLiteStandardRelease \ + -PsplitApks \ + --stacktrace \ + --no-daemon \ + --max-workers=1 + ./gradlew :app:assembleLiteFdroidRelease \ + --stacktrace \ + --no-daemon \ + --max-workers=1 - name: Create Release and Upload APK uses: softprops/action-gh-release@v2 diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt index 651aa508..d71b2a03 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt @@ -950,6 +950,8 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, private var keyboardTouchEffectQualityPreference: String = KeyboardTouchEffectQuality.HIGH private var keyboardTouchEffectColorModePreference: String = "random" private var keyboardTouchEffectPalettePreference: String = SprayPaintSettings.PALETTE_PAINT_SPLASH + private var liquidInkDensityPreference: Int = 100 + private var auroraInkDensityPreference: Int = 100 @ColorInt private var keyboardTouchEffectColorPreference: Int = Color.rgb(17, 17, 17) @@ -1913,6 +1915,8 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, keyboardTouchEffectColorModePreference = preferences.keyboardTouchEffectColorModePreference keyboardTouchEffectColorPreference = preferences.keyboardTouchEffectColorPreference keyboardTouchEffectPalettePreference = preferences.keyboardTouchEffectPalettePreference + liquidInkDensityPreference = preferences.liquidInkDensityPreference + auroraInkDensityPreference = preferences.auroraInkDensityPreference cinematicWaveColorModePreference = CinematicWaveSettings.normalizeColorMode(preferences.cinematicWaveColorModePreference) cinematicWavePrimaryColorPreference = preferences.cinematicWavePrimaryColorPreference @@ -2345,10 +2349,30 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, mainView: MainLayoutBinding, floatingView: FloatingKeyboardLayoutBinding? ) { + refreshFluidInkDensityPreferences() setupMainKeyboardTouchEffect(mainView) floatingView?.let { setupFloatingKeyboardTouchEffect(it) } } + private fun refreshFluidInkDensityPreferences() { + liquidInkDensityPreference = + appPreference.keyboard_touch_effect_liquid_ink_density_preference + auroraInkDensityPreference = + appPreference.keyboard_touch_effect_aurora_ink_density_preference + } + + private fun resolveFluidInkDensityPercent(effectType: String): Int { + return when { + KeyboardTouchEffectType.isLiquidInk(effectType) -> + liquidInkDensityPreference.coerceIn(50, 300) + + KeyboardTouchEffectType.isAuroraInk(effectType) -> + auroraInkDensityPreference.coerceIn(50, 300) + + else -> 100 + } + } + private fun clearAndPauseKeyboardTouchEffects() { mainLayoutBinding?.suminagashiInkView?.apply { clearInk() @@ -2418,6 +2442,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, } else { FluidInkTransportMode.PHYSICAL } + val inkDensityPercent = resolveFluidInkDensityPercent(effectType) val liquidRippleEnabled = mainSurfaceActive && KeyboardTouchEffectType.isLiquidRipple(effectType) val sprayPaintEnabled = @@ -2433,7 +2458,8 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, colorMode = keyboardTouchEffectColorModePreference, fixedColor = keyboardTouchEffectColorPreference, quality = keyboardTouchEffectQualityPreference, - transportMode = inkTransportMode + transportMode = inkTransportMode, + densityPercent = inkDensityPercent ) mainView.liquidRippleEffectView.configure( enabled = liquidRippleEnabled, @@ -2542,6 +2568,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, } else { FluidInkTransportMode.PHYSICAL } + val inkDensityPercent = resolveFluidInkDensityPercent(effectType) val liquidRippleEnabled = floatingSurfaceActive && KeyboardTouchEffectType.isLiquidRipple(effectType) val sprayPaintEnabled = @@ -2557,7 +2584,8 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, colorMode = keyboardTouchEffectColorModePreference, fixedColor = keyboardTouchEffectColorPreference, quality = keyboardTouchEffectQualityPreference, - transportMode = inkTransportMode + transportMode = inkTransportMode, + densityPercent = inkDensityPercent ) floatingView.floatingLiquidRippleEffectView.configure( enabled = liquidRippleEnabled, @@ -3931,6 +3959,8 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, keyboardTouchEffectColorModePreference = "random" keyboardTouchEffectColorPreference = Color.rgb(17, 17, 17) keyboardTouchEffectPalettePreference = SprayPaintSettings.PALETTE_PAINT_SPLASH + liquidInkDensityPreference = 100 + auroraInkDensityPreference = 100 cinematicWaveColorModePreference = CinematicWaveSettings.COLOR_MODE_CINEMATIC_RANDOM cinematicWavePrimaryColorPreference = CinematicWaveSettings.DEFAULT_PRIMARY_COLOR cinematicWaveSecondaryColorPreference = CinematicWaveSettings.DEFAULT_SECONDARY_COLOR diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/ImePreferencesSnapshot.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/ImePreferencesSnapshot.kt index f17bef87..b358d6b3 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/ImePreferencesSnapshot.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/ImePreferencesSnapshot.kt @@ -187,6 +187,8 @@ data class ImePreferencesSnapshot( val keyboardTouchEffectColorModePreference: String, val keyboardTouchEffectColorPreference: Int, val keyboardTouchEffectPalettePreference: String, + val liquidInkDensityPreference: Int, + val auroraInkDensityPreference: Int, val cinematicWaveColorModePreference: String, val cinematicWavePrimaryColorPreference: Int, val cinematicWaveSecondaryColorPreference: Int, @@ -535,6 +537,10 @@ data class ImePreferencesSnapshot( keyboardTouchEffectColorPreference = appPreference.keyboard_touch_effect_color_preference, keyboardTouchEffectPalettePreference = appPreference.keyboard_touch_effect_palette_preference, + liquidInkDensityPreference = + appPreference.keyboard_touch_effect_liquid_ink_density_preference, + auroraInkDensityPreference = + appPreference.keyboard_touch_effect_aurora_ink_density_preference, cinematicWaveColorModePreference = appPreference.keyboard_touch_effect_cinematic_wave_color_mode_preference, cinematicWavePrimaryColorPreference = diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkEffectView.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkEffectView.kt index e25b6c5b..d9d645ae 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkEffectView.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkEffectView.kt @@ -45,14 +45,16 @@ open class FluidInkEffectView @JvmOverloads constructor( colorMode: String, @ColorInt fixedColor: Int, quality: String = KeyboardTouchEffectQuality.HIGH, - transportMode: FluidInkTransportMode = FluidInkTransportMode.PHYSICAL + transportMode: FluidInkTransportMode = FluidInkTransportMode.PHYSICAL, + densityPercent: Int = FluidInkSettings.DEFAULT_DENSITY_PERCENT ) { currentSettings = FluidInkSettings( enabled = enabled, colorMode = colorMode, fixedColor = FluidInkSettings.withoutTransparentAlpha(fixedColor), quality = KeyboardTouchEffectQuality.normalize(quality), - transportMode = transportMode + transportMode = transportMode, + densityPercent = densityPercent ) if (!enabled) { diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkRenderer.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkRenderer.kt index 5e764cf0..c5842bc0 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkRenderer.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInkRenderer.kt @@ -60,6 +60,7 @@ internal class FluidInkRenderer( paused = true return@postOnRenderer } + simulation?.setInkDensityPercent(settings.normalizedDensityPercent) if (qualityChanged && surfaceWidth > 0 && surfaceHeight > 0 && simulation != null) { simulation?.resizeSurface( surfaceWidth = surfaceWidth, @@ -80,6 +81,7 @@ internal class FluidInkRenderer( if (egl == null) { egl = EglEnvironment(surfaceTexture) simulation = simulationFactory() + simulation?.setInkDensityPercent(settings.normalizedDensityPercent) simulation?.initialize( surfaceWidth = width, surfaceHeight = height, diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInputCommand.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInputCommand.kt index a94c06b4..72cd0d2f 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInputCommand.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidInputCommand.kt @@ -8,15 +8,21 @@ internal data class FluidInkSettings( val colorMode: String, @ColorInt val fixedColor: Int, val quality: String = KeyboardTouchEffectQuality.HIGH, - val transportMode: FluidInkTransportMode = FluidInkTransportMode.PHYSICAL + val transportMode: FluidInkTransportMode = FluidInkTransportMode.PHYSICAL, + val densityPercent: Int = DEFAULT_DENSITY_PERCENT ) { val normalizedColorMode: String = if (colorMode == COLOR_MODE_FIXED) COLOR_MODE_FIXED else COLOR_MODE_RANDOM val normalizedQuality: String = KeyboardTouchEffectQuality.normalize(quality) + val normalizedDensityPercent: Int = + densityPercent.coerceIn(MIN_DENSITY_PERCENT, MAX_DENSITY_PERCENT) companion object { const val COLOR_MODE_RANDOM = "random" const val COLOR_MODE_FIXED = "fixed" + const val MIN_DENSITY_PERCENT = 50 + const val MAX_DENSITY_PERCENT = 300 + const val DEFAULT_DENSITY_PERCENT = 100 @ColorInt const val DEFAULT_INK_COLOR: Int = 0xFF111111.toInt() diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidSimulation.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidSimulation.kt index de812101..26cfd66b 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidSimulation.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/image_effect/FluidSimulation.kt @@ -81,6 +81,8 @@ internal class FluidSimulation( private var velocityDiffusionSource: RenderTarget? = null private var renderTargetFormat = FluidRenderTargetFormat.HalfFloat private var waterPhaseSeconds = 0f + private var inkDensityMultiplier = 1f + private var maxDyeDensity = DEFAULT_MAX_DYE_DENSITY private var copyProgram = 0 private var splatProgram = 0 @@ -152,6 +154,21 @@ internal class FluidSimulation( resizeTargets(nextGrid = nextGrid, preserveExistingDye = true) } + fun setInkDensityPercent(percent: Int) { + val clamped = percent.coerceIn( + FluidInkSettings.MIN_DENSITY_PERCENT, + FluidInkSettings.MAX_DENSITY_PERCENT + ) + inkDensityMultiplier = clamped / 100f + maxDyeDensity = if (clamped <= FluidInkSettings.DEFAULT_DENSITY_PERCENT) { + DEFAULT_MAX_DYE_DENSITY + } else { + val t = ((clamped - FluidInkSettings.DEFAULT_DENSITY_PERCENT).toFloat() / 200f) + .coerceIn(0f, 1f) + DEFAULT_MAX_DYE_DENSITY + (1f - DEFAULT_MAX_DYE_DENSITY) * t + } + } + fun render( inputCommands: List, dtSeconds: Float, @@ -395,6 +412,8 @@ internal class FluidSimulation( uniform1f(splatProgram, "uRadius", radius) uniform1f(splatProgram, "uAspect", grid.width.toFloat() / grid.height.toFloat()) uniform1f(splatProgram, "uIsDye", if (isDye) 1f else 0f) + uniform1f(splatProgram, "uInkDensity", inkDensityMultiplier) + uniform1f(splatProgram, "uMaxDyeDensity", maxDyeDensity) uniformEncoding(splatProgram, "uTargetEncoded", source) uniformEncoding(splatProgram, "uOutputEncoded", destination) uniform1f(splatProgram, "uSignedRange", SIGNED_FIELD_RANGE) @@ -748,6 +767,7 @@ internal class FluidSimulation( private const val MIN_DT_SECONDS = 1f / 120f private const val MAX_DT_SECONDS = 1f / 24f private const val WATER_PHASE_WRAP_SECONDS = 10_000f + private const val DEFAULT_MAX_DYE_DENSITY = 0.84f private val QUAD = floatArrayOf( -1f, -1f, @@ -789,6 +809,8 @@ internal class FluidSimulation( uniform float uRadius; uniform float uAspect; uniform float uIsDye; + uniform float uInkDensity; + uniform float uMaxDyeDensity; uniform float uTargetEncoded; uniform float uOutputEncoded; uniform float uSignedRange; @@ -806,12 +828,16 @@ internal class FluidSimulation( float radiusSquared = radius * radius; float falloff = exp(-dot(delta, delta) / radiusSquared); if (uIsDye > 0.5) { - const float MAX_DYE_DENSITY = 0.84; const float INK_DEPOSIT_STRENGTH = 0.52; vec4 base = texture(uTarget, vUv); vec3 baseColor = base.a > 0.0001 ? base.rgb / base.a : uValue; - float deposit = clamp(uAlpha * falloff * INK_DEPOSIT_STRENGTH, 0.0, 0.42); - float remainingCapacity = max(MAX_DYE_DENSITY - base.a, 0.0); + float depositLimit = min(1.0, 0.42 * uInkDensity); + float deposit = clamp( + uAlpha * falloff * INK_DEPOSIT_STRENGTH * uInkDensity, + 0.0, + depositLimit + ); + float remainingCapacity = max(uMaxDyeDensity - base.a, 0.0); float nextAlpha = base.a + min(deposit, remainingCapacity); float colorWeight = clamp(deposit / (base.a + deposit + 0.0001), 0.0, 0.24); vec3 mixedColor = mix(baseColor, uValue, colorWeight); diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt index 54ae1b8a..e5d0373c 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt @@ -12,9 +12,9 @@ import com.kazumaproject.custom_keyboard.data.CircularFlickDirection import com.kazumaproject.custom_keyboard.data.KeyboardInputMode import com.kazumaproject.custom_keyboard.data.buildEvenCircularRanges import com.kazumaproject.domain.EmojiSkinToneSupport +import com.kazumaproject.markdownhelperkeyboard.ime_service.image_effect.CinematicWaveSettings import com.kazumaproject.markdownhelperkeyboard.ime_service.image_effect.KeyboardTouchEffectQuality import com.kazumaproject.markdownhelperkeyboard.ime_service.image_effect.KeyboardTouchEffectType -import com.kazumaproject.markdownhelperkeyboard.ime_service.image_effect.CinematicWaveSettings import com.kazumaproject.markdownhelperkeyboard.ime_service.image_effect.SprayPaintSettings import com.kazumaproject.markdownhelperkeyboard.ime_service.state.CandidateTab import com.kazumaproject.markdownhelperkeyboard.ime_service.state.KeyboardType @@ -645,6 +645,10 @@ object AppPreference { "keyboard_touch_effect_palette_preference", SprayPaintSettings.PALETTE_PAINT_SPLASH ) + private val KEYBOARD_TOUCH_EFFECT_LIQUID_INK_DENSITY = + Pair("keyboard_touch_effect_liquid_ink_density_preference", 100) + private val KEYBOARD_TOUCH_EFFECT_AURORA_INK_DENSITY = + Pair("keyboard_touch_effect_aurora_ink_density_preference", 100) private val KEYBOARD_TOUCH_EFFECT_CINEMATIC_WAVE_COLOR_MODE = Pair( "keyboard_touch_effect_cinematic_wave_color_mode_preference", @@ -3383,6 +3387,30 @@ object AppPreference { ) } + var keyboard_touch_effect_liquid_ink_density_preference: Int + get() = preferences.getInt( + KEYBOARD_TOUCH_EFFECT_LIQUID_INK_DENSITY.first, + KEYBOARD_TOUCH_EFFECT_LIQUID_INK_DENSITY.second + ).coerceIn(50, 300) + set(value) = preferences.edit { + it.putInt( + KEYBOARD_TOUCH_EFFECT_LIQUID_INK_DENSITY.first, + value.coerceIn(50, 300) + ) + } + + var keyboard_touch_effect_aurora_ink_density_preference: Int + get() = preferences.getInt( + KEYBOARD_TOUCH_EFFECT_AURORA_INK_DENSITY.first, + KEYBOARD_TOUCH_EFFECT_AURORA_INK_DENSITY.second + ).coerceIn(50, 300) + set(value) = preferences.edit { + it.putInt( + KEYBOARD_TOUCH_EFFECT_AURORA_INK_DENSITY.first, + value.coerceIn(50, 300) + ) + } + var keyboard_touch_effect_cinematic_wave_color_mode_preference: String get() { val value = preferences.getString( diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt index 8da8082c..2ababafd 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt @@ -613,6 +613,28 @@ open class CommonPreferenceFragment : PreferenceFragmentCompat() { } } + findPreference( + "keyboard_touch_effect_liquid_ink_density_preference" + )?.apply { + value = appPreference.keyboard_touch_effect_liquid_ink_density_preference + setOnPreferenceChangeListener { _, newValue -> + val nextValue = (newValue as? Int ?: value).coerceIn(50, 300) + appPreference.keyboard_touch_effect_liquid_ink_density_preference = nextValue + true + } + } + + findPreference( + "keyboard_touch_effect_aurora_ink_density_preference" + )?.apply { + value = appPreference.keyboard_touch_effect_aurora_ink_density_preference + setOnPreferenceChangeListener { _, newValue -> + val nextValue = (newValue as? Int ?: value).coerceIn(50, 300) + appPreference.keyboard_touch_effect_aurora_ink_density_preference = nextValue + true + } + } + findPreference( "keyboard_touch_effect_cinematic_wave_color_mode_preference" )?.apply { diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingCardEditorController.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingCardEditorController.kt index 2001911c..973d74dc 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingCardEditorController.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingCardEditorController.kt @@ -426,6 +426,9 @@ class SettingCardEditorController( context.getString(R.string.key_sound_volume_percent, value) } + "keyboard_touch_effect_liquid_ink_density_preference", + "keyboard_touch_effect_aurora_ink_density_preference" -> "$value%" + "zenz_debounce_time_preference" -> "$value ms" else -> if (unit.isBlank()) { diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt index fe98d542..bc85704a 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt @@ -399,6 +399,8 @@ object SettingDestinations { "keyboard_background_image_select_preference", "keyboard_background_video_select_preference", "keyboard_touch_effect_type_preference", + "keyboard_touch_effect_liquid_ink_density_preference", + "keyboard_touch_effect_aurora_ink_density_preference", "keyboard_touch_effect_cinematic_wave_color_mode_preference", "keyboard_touch_effect_cinematic_wave_type_preference", "keyboard_touch_effect_cinematic_wave_primary_color_preference", diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchIndex.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchIndex.kt index c039aa81..7eea1aec 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchIndex.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchIndex.kt @@ -442,6 +442,12 @@ object SettingSearchIndex { add("keyboard_touch_effect_type_preference") add("keyboard_touch_effect_cinematic_wave_color_mode_preference") } + if ( + key == "keyboard_touch_effect_liquid_ink_density_preference" || + key == "keyboard_touch_effect_aurora_ink_density_preference" + ) { + add("keyboard_touch_effect_type_preference") + } if (!dependencyKey.isNullOrBlank()) { add(dependencyKey) } diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index d03aa65c..3ae43637 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -1039,6 +1039,10 @@ 触れた位置から、水面のようなやわらかい波紋が広がります。 黄色い発光膜がゆっくり漂い、タッチ位置に反応して柔らかく歪みます。 キーの奥でオーロラのような光の波が流れ、タッチ位置で柔らかく歪みます。 + リキッドインクの濃さ + リキッドインクの表示濃度を調整します。100%で標準です。 + オーロラインクの濃さ + オーロラインクの表示濃度を調整します。100%で標準です。 タップ時のエフェクト キーボードに触れた位置から、インクが広がる背景エフェクトを表示します。 インクの色 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 23855cdd..92f7efd6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1050,6 +1050,10 @@ Gentle water ripples spread from the touched position. A glowing luminous membrane drifts softly and deforms around your touch. A cinematic aurora-like wave drifts behind the keys and bends softly around your touch. + Liquid Ink Density + Adjusts the opacity of the Liquid Ink effect. 100% is the default. + Aurora Ink Density + Adjusts the opacity of the Aurora Ink effect. 100% is the default. Liquid Ink Background Shows an ink-diffusion background effect from the touched position on the keyboard. Ink Color diff --git a/app/src/main/res/xml/pref_common_legacy.xml b/app/src/main/res/xml/pref_common_legacy.xml index 9b4b07c1..cda7e2c7 100644 --- a/app/src/main/res/xml/pref_common_legacy.xml +++ b/app/src/main/res/xml/pref_common_legacy.xml @@ -145,6 +145,26 @@ android:summary="@string/keyboard_touch_effect_palette_summary" android:title="@string/keyboard_touch_effect_palette_title" /> + + + + + + + + Date: Wed, 17 Jun 2026 01:14:43 -0400 Subject: [PATCH 2/3] add popview custom colot --- app/build.gradle | 4 +- .../ime_service/IMEService.kt | 34 +++++-- .../setting_activity/AppPreference.kt | 31 +++++++ .../keyboard_theme/KeyboardThemeFragment.kt | 49 +++++++++- .../ui/popup_style/PopupStyleFragments.kt | 4 +- .../ui/popup_style/PopupStylePreviewViews.kt | 32 +++++-- .../ui/setting/CommonPreferenceFragment.kt | 11 ++- .../FrequentSettingsAddBottomSheetFragment.kt | 15 +++- .../KeyboardTouchEffectSettingVisibility.kt | 22 +++++ .../ui/setting/SettingDestination.kt | 69 ++++++++++++++ .../ui/setting/SettingHomeFragment.kt | 10 ++- .../ui/setting/SettingSearchFragment.kt | 10 ++- .../main/res/navigation/mobile_navigation.xml | 6 +- app/src/main/res/values-ja/strings.xml | 17 +++- app/src/main/res/values/strings.xml | 17 +++- app/src/main/res/xml/pref_custom.xml | 4 +- app/src/main/res/xml/pref_kana.xml | 4 +- app/src/main/res/xml/pref_sumire.xml | 4 +- .../core/data/popup/PopupViewStyle.kt | 4 +- .../controller/CrossFlickInputController.kt | 8 +- .../StandardFlickInputController.kt | 4 +- .../TfbiHierarchicalFlickController.kt | 4 +- .../controller/TfbiInputController.kt | 4 +- .../controller/TfbiStickyFlickController.kt | 4 +- .../view/CrossFlickPopupView.kt | 90 +++++++++++++++---- .../view/DirectionalKeyPopupView.kt | 10 ++- .../custom_keyboard/view/FlickKeyboardView.kt | 4 +- .../view/StandardFlickPopupView.kt | 15 +++- .../view/TfbiFlickPopupView.kt | 14 +++ .../qwerty_keyboard/ui/QWERTYKeyboardView.kt | 14 ++- .../qwerty_keyboard/ui/VariationsPopupView.kt | 16 +++- .../java/com/kazumaproject/tenkey/TenKey.kt | 36 +++++++- 32 files changed, 491 insertions(+), 79 deletions(-) create mode 100644 app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/KeyboardTouchEffectSettingVisibility.kt diff --git a/app/build.gradle b/app/build.gradle index 4c3b5219..c5014f32 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,8 +31,8 @@ android { applicationId "com.kazumaproject.markdownhelperkeyboard" minSdk 24 targetSdk 36 - versionCode 780 - versionName "1.7.87" + versionCode 781 + versionName "1.7.88" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt index d71b2a03..d2f4bc89 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/ime_service/IMEService.kt @@ -10070,10 +10070,18 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, configureFlickKeyboardView(mainView.customLayoutDefault, mainView, isFloatingView = false) } + private fun popupBackgroundColorOrNull(): Int? = + if (appPreference.key_popup_use_custom_color) appPreference.key_popup_background_color else null + + private fun popupTextColorOrNull(): Int? = + if (appPreference.key_popup_use_custom_color) appPreference.key_popup_text_color else null + private fun currentTenKeyPopupViewStyle(): PopupViewStyle { return PopupViewStyle( sizeScalePercent = appPreference.tenkey_popup_size_scale_percent ?: 100, - textSizeSp = appPreference.tenkey_popup_text_size_sp ?: 28.0f + textSizeSp = appPreference.tenkey_popup_text_size_sp ?: 28.0f, + backgroundColor = popupBackgroundColorOrNull(), + textColor = popupTextColorOrNull() ) } @@ -10081,11 +10089,15 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, return QwertyPopupViewStyleSet( keyPreview = PopupViewStyle( sizeScalePercent = appPreference.qwerty_key_preview_popup_size_scale_percent ?: 100, - textSizeSp = appPreference.qwerty_key_preview_popup_text_size_sp ?: 28.0f + textSizeSp = appPreference.qwerty_key_preview_popup_text_size_sp ?: 28.0f, + backgroundColor = popupBackgroundColorOrNull(), + textColor = popupTextColorOrNull() ), variation = PopupViewStyle( sizeScalePercent = appPreference.qwerty_variation_popup_size_scale_percent ?: 100, - textSizeSp = appPreference.qwerty_variation_popup_text_size_sp ?: 28.0f + textSizeSp = appPreference.qwerty_variation_popup_text_size_sp ?: 28.0f, + backgroundColor = popupBackgroundColorOrNull(), + textColor = popupTextColorOrNull() ) ) } @@ -10094,19 +10106,27 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection, return FlickPopupViewStyleSet( directional = PopupViewStyle( sizeScalePercent = appPreference.flick_directional_popup_size_scale_percent ?: 100, - textSizeSp = appPreference.flick_directional_popup_text_size_sp ?: 28.0f + textSizeSp = appPreference.flick_directional_popup_text_size_sp ?: 28.0f, + backgroundColor = popupBackgroundColorOrNull(), + textColor = popupTextColorOrNull() ), cross = PopupViewStyle( sizeScalePercent = appPreference.flick_cross_popup_size_scale_percent ?: 100, - textSizeSp = appPreference.flick_cross_popup_text_size_sp ?: 18.0f + textSizeSp = appPreference.flick_cross_popup_text_size_sp ?: 18.0f, + backgroundColor = popupBackgroundColorOrNull(), + textColor = popupTextColorOrNull() ), standard = PopupViewStyle( sizeScalePercent = appPreference.flick_standard_popup_size_scale_percent ?: 100, - textSizeSp = appPreference.flick_standard_popup_text_size_sp ?: 19.0f + textSizeSp = appPreference.flick_standard_popup_text_size_sp ?: 19.0f, + backgroundColor = popupBackgroundColorOrNull(), + textColor = popupTextColorOrNull() ), tfbi = PopupViewStyle( sizeScalePercent = appPreference.flick_tfbi_popup_size_scale_percent ?: 100, - textSizeSp = appPreference.flick_tfbi_popup_text_size_sp ?: 20.0f + textSizeSp = appPreference.flick_tfbi_popup_text_size_sp ?: 20.0f, + backgroundColor = popupBackgroundColorOrNull(), + textColor = popupTextColorOrNull() ) ) } diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt index e5d0373c..a3db4dc3 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/AppPreference.kt @@ -172,6 +172,13 @@ object AppPreference { private val QWERTY_SHOW_POPUP_WINDOW = Pair("qwerty_show_popup_window_preference", true) + private val KEY_POPUP_USE_CUSTOM_COLOR = + Pair("key_popup_use_custom_color_preference", false) + private val KEY_POPUP_BACKGROUND_COLOR = + Pair("key_popup_background_color_preference", Color.WHITE) + private val KEY_POPUP_TEXT_COLOR = + Pair("key_popup_text_color_preference", Color.BLACK) + private val TENKEY_POPUP_SIZE_SCALE_PERCENT = Pair("tenkey_popup_size_scale_percent_preference", 100) private val TENKEY_POPUP_TEXT_SIZE_SP = Pair("tenkey_popup_text_size_sp_preference", 28.0f) @@ -1163,6 +1170,30 @@ object AppPreference { it.putBoolean(QWERTY_SHOW_POPUP_WINDOW.first, value ?: true) } + var key_popup_use_custom_color: Boolean + get() = preferences.getBoolean( + KEY_POPUP_USE_CUSTOM_COLOR.first, + KEY_POPUP_USE_CUSTOM_COLOR.second + ) + set(value) = preferences.edit { + it.putBoolean(KEY_POPUP_USE_CUSTOM_COLOR.first, value) + } + + var key_popup_background_color: Int + get() = readIntPreference( + KEY_POPUP_BACKGROUND_COLOR.first, + KEY_POPUP_BACKGROUND_COLOR.second + ) + set(value) = preferences.edit { + it.putInt(KEY_POPUP_BACKGROUND_COLOR.first, value) + } + + var key_popup_text_color: Int + get() = readIntPreference(KEY_POPUP_TEXT_COLOR.first, KEY_POPUP_TEXT_COLOR.second) + set(value) = preferences.edit { + it.putInt(KEY_POPUP_TEXT_COLOR.first, value) + } + var show_candidates_password: Boolean? get() = preferences.getBoolean( CANDIDATE_IN_PASSWORD.first, CANDIDATE_IN_PASSWORD.second diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/keyboard_theme/KeyboardThemeFragment.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/keyboard_theme/KeyboardThemeFragment.kt index d73050a3..3c910113 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/keyboard_theme/KeyboardThemeFragment.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/keyboard_theme/KeyboardThemeFragment.kt @@ -31,6 +31,12 @@ class KeyboardThemeFragment : PreferenceFragmentCompat() { // System Theme Keys private const val PREF_KEY_DEFAULT = "theme_default" private const val PREF_KEY_ROUND_CORNER = "round_corner_keyboard_preference" + private const val PREF_KEY_POPUP_USE_CUSTOM_COLOR = + "key_popup_use_custom_color_preference" + private const val PREF_KEY_POPUP_BACKGROUND_COLOR = + "key_popup_background_color_preference" + private const val PREF_KEY_POPUP_TEXT_COLOR = + "key_popup_text_color_preference" // Liquid Glass Keys private const val PREF_KEY_LIQUID_GLASS = "liquid_glass_preference" @@ -162,7 +168,6 @@ class KeyboardThemeFragment : PreferenceFragmentCompat() { } systemCategory.addPreference(defaultPref) - // ------------------------------------------------------- // Custom Category (Keyboard Appearance) // ------------------------------------------------------- @@ -222,6 +227,41 @@ class KeyboardThemeFragment : PreferenceFragmentCompat() { ) { appPreference.custom_theme_special_key_text_color } customCategory.addPreference(customSpecialTextPref) + val popupUseCustomColorPref = SwitchPreferenceCompat(context).apply { + key = PREF_KEY_POPUP_USE_CUSTOM_COLOR + title = getString(R.string.key_popup_use_custom_color_title) + summaryOn = getString(R.string.key_popup_use_custom_color_summary_on) + summaryOff = getString(R.string.key_popup_use_custom_color_summary_off) + setDefaultValue(false) + } + customCategory.addPreference(popupUseCustomColorPref) + + val popupBackgroundColorPref = createColorPreference( + context, + PREF_KEY_POPUP_BACKGROUND_COLOR, + getString(R.string.key_popup_background_color_title) + ) { appPreference.key_popup_background_color } + customCategory.addPreference(popupBackgroundColorPref) + + val popupTextColorPref = createColorPreference( + context, + PREF_KEY_POPUP_TEXT_COLOR, + getString(R.string.key_popup_text_color_title) + ) { appPreference.key_popup_text_color } + customCategory.addPreference(popupTextColorPref) + + fun updatePopupColorPrefsState(enabled: Boolean) { + popupBackgroundColorPref.isEnabled = enabled + popupTextColorPref.isEnabled = enabled + } + + updatePopupColorPrefsState(appPreference.key_popup_use_custom_color) + + popupUseCustomColorPref.setOnPreferenceChangeListener { _, newValue -> + updatePopupColorPrefsState(newValue as Boolean) + true + } + val customCandidateTextPref = createColorPreference( context, PREF_KEY_CUSTOM_CANDIDATE_TEXT, @@ -443,6 +483,9 @@ class KeyboardThemeFragment : PreferenceFragmentCompat() { findPreference(PREF_KEY_CUSTOM_SPECIAL_KEY)?.isVisible = isVisible findPreference(PREF_KEY_CUSTOM_TEXT)?.isVisible = isVisible findPreference(PREF_KEY_CUSTOM_SPECIAL_TEXT)?.isVisible = isVisible + findPreference(PREF_KEY_POPUP_USE_CUSTOM_COLOR)?.isVisible = isVisible + findPreference(PREF_KEY_POPUP_BACKGROUND_COLOR)?.isVisible = isVisible + findPreference(PREF_KEY_POPUP_TEXT_COLOR)?.isVisible = isVisible findPreference(PREF_KEY_CUSTOM_CANDIDATE_TEXT)?.isVisible = isVisible findPreference(PREF_KEY_CUSTOM_CANDIDATE_ITEM_BG)?.isVisible = isVisible findPreference(PREF_KEY_CUSTOM_CANDIDATE_ITEM_PRESSED_BG)?.isVisible = isVisible @@ -490,6 +533,10 @@ class KeyboardThemeFragment : PreferenceFragmentCompat() { PREF_KEY_CUSTOM_POST_EDIT_BG -> appPreference.custom_theme_post_edit_bg_color = color PREF_KEY_CUSTOM_POST_EDIT_TEXT -> appPreference.custom_theme_post_edit_text_color = color + + // Tap/Flick PopupView Colors + PREF_KEY_POPUP_BACKGROUND_COLOR -> appPreference.key_popup_background_color = color + PREF_KEY_POPUP_TEXT_COLOR -> appPreference.key_popup_text_color = color } } diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStyleFragments.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStyleFragments.kt index 95d813e3..9d0869cf 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStyleFragments.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStyleFragments.kt @@ -349,7 +349,9 @@ private fun Fragment.styleEditorSection( fun currentStyle(): PopupViewStyle { return PopupViewStyle( MIN_SIZE + sizeSeek.progress, - MIN_TEXT + textSeek.progress + MIN_TEXT + textSeek.progress, + backgroundColor = initialStyle.backgroundColor, + textColor = initialStyle.textColor ) } diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStylePreviewViews.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStylePreviewViews.kt index 89389228..04a61461 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStylePreviewViews.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/popup_style/PopupStylePreviewViews.kt @@ -19,11 +19,13 @@ class PopupStylePreviewView @JvmOverloads constructor( private val backgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { color = Color.rgb(245, 247, 250) } + private val defaultBubbleColor = Color.rgb(55, 71, 79) + private val defaultTextColor = Color.WHITE private val bubblePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { - color = Color.rgb(55, 71, 79) + color = defaultBubbleColor } private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { - color = Color.WHITE + color = defaultTextColor textAlign = Paint.Align.CENTER typeface = android.graphics.Typeface.DEFAULT_BOLD } @@ -37,7 +39,9 @@ class PopupStylePreviewView @JvmOverloads constructor( fun applyStyle(style: PopupViewStyle) { this.style = PopupViewStyle( style.sizeScalePercent.coerceIn(50, 200), - style.textSizeSp.coerceIn(8f, 48f) + style.textSizeSp.coerceIn(8f, 48f), + backgroundColor = style.backgroundColor, + textColor = style.textColor ) invalidate() } @@ -61,8 +65,10 @@ class PopupStylePreviewView @JvmOverloads constructor( val left = width / 2f - w / 2f val top = height / 2f - h / 2f val rect = RectF(left, top, left + w, top + h) + bubblePaint.color = style.backgroundColor ?: defaultBubbleColor canvas.drawRoundRect(rect, dpToPx(18f), dpToPx(18f), bubblePaint) + textPaint.color = style.textColor ?: defaultTextColor textPaint.textSize = spToPx(style.textSizeSp) val textY = rect.centerY() - (textPaint.descent() + textPaint.ascent()) / 2f canvas.drawText(previewText, rect.centerX(), textY, textPaint) @@ -92,19 +98,22 @@ class FlickPopupStylePreviewView @JvmOverloads constructor( private val bgPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { color = Color.rgb(245, 247, 250) } + private val defaultPopupColor = Color.rgb(69, 90, 100) + private val defaultHighlightColor = Color.rgb(96, 125, 139) + private val defaultTextColor = Color.WHITE private val popupPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { - color = Color.rgb(69, 90, 100) + color = defaultPopupColor } private val highlightPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { - color = Color.rgb(96, 125, 139) + color = defaultHighlightColor } private val strokePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { - color = Color.WHITE + color = defaultTextColor style = Paint.Style.STROKE strokeWidth = dpToPx(1f) } private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { - color = Color.WHITE + color = defaultTextColor textAlign = Paint.Align.CENTER typeface = android.graphics.Typeface.DEFAULT_BOLD } @@ -116,7 +125,9 @@ class FlickPopupStylePreviewView @JvmOverloads constructor( this.target = target this.style = PopupViewStyle( style.sizeScalePercent.coerceIn(50, 200), - style.textSizeSp.coerceIn(8f, 48f) + style.textSizeSp.coerceIn(8f, 48f), + backgroundColor = style.backgroundColor, + textColor = style.textColor ) invalidate() } @@ -132,6 +143,11 @@ class FlickPopupStylePreviewView @JvmOverloads constructor( override fun onDraw(canvas: Canvas) { super.onDraw(canvas) canvas.drawColor(bgPaint.color) + popupPaint.color = style.backgroundColor ?: defaultPopupColor + highlightPaint.color = style.backgroundColor ?: defaultHighlightColor + val resolvedTextColor = style.textColor ?: defaultTextColor + textPaint.color = resolvedTextColor + strokePaint.color = resolvedTextColor textPaint.textSize = spToPx(style.textSizeSp) when (target) { Target.DIRECTIONAL -> drawDirectionalPreview(canvas) diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt index 2ababafd..8596f69f 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/CommonPreferenceFragment.kt @@ -309,6 +309,13 @@ open class CommonPreferenceFragment : PreferenceFragmentCompat() { findPreference("keyboard_touch_effect_palette_preference")?.isVisible = visibility.showPalette + findPreference( + KeyboardTouchEffectSettingVisibility.LIQUID_INK_DENSITY_KEY + )?.isVisible = KeyboardTouchEffectType.isLiquidInk(normalizedEffect) + findPreference( + KeyboardTouchEffectSettingVisibility.AURORA_INK_DENSITY_KEY + )?.isVisible = KeyboardTouchEffectType.isAuroraInk(normalizedEffect) + findPreference( "keyboard_touch_effect_cinematic_wave_color_mode_preference" )?.isVisible = visibility.showCinematicWaveSettings @@ -614,7 +621,7 @@ open class CommonPreferenceFragment : PreferenceFragmentCompat() { } findPreference( - "keyboard_touch_effect_liquid_ink_density_preference" + KeyboardTouchEffectSettingVisibility.LIQUID_INK_DENSITY_KEY )?.apply { value = appPreference.keyboard_touch_effect_liquid_ink_density_preference setOnPreferenceChangeListener { _, newValue -> @@ -625,7 +632,7 @@ open class CommonPreferenceFragment : PreferenceFragmentCompat() { } findPreference( - "keyboard_touch_effect_aurora_ink_density_preference" + KeyboardTouchEffectSettingVisibility.AURORA_INK_DENSITY_KEY )?.apply { value = appPreference.keyboard_touch_effect_aurora_ink_density_preference setOnPreferenceChangeListener { _, newValue -> diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/FrequentSettingsAddBottomSheetFragment.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/FrequentSettingsAddBottomSheetFragment.kt index c23298d0..2bd65b9e 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/FrequentSettingsAddBottomSheetFragment.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/FrequentSettingsAddBottomSheetFragment.kt @@ -16,6 +16,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.chip.Chip import com.kazumaproject.markdownhelperkeyboard.databinding.FragmentFrequentSettingsAddBottomSheetBinding +import com.kazumaproject.markdownhelperkeyboard.setting_activity.AppPreference class FrequentSettingsAddBottomSheetFragment : BottomSheetDialogFragment() { @@ -97,7 +98,7 @@ class FrequentSettingsAddBottomSheetFragment : BottomSheetDialogFragment() { } private fun setupCategoryChips() { - val filters = FrequentSettingFilters.filters(requireContext(), candidates) + val filters = FrequentSettingFilters.filters(requireContext(), visibleCandidates()) val idMap = mutableMapOf() binding.frequentSettingsAddCategoryChipGroup.removeAllViews() filters.forEachIndexed { index, filter -> @@ -132,7 +133,7 @@ class FrequentSettingsAddBottomSheetFragment : BottomSheetDialogFragment() { } private fun renderCandidates() { - val availableCandidates = candidates.filterNot { it.key in selectedKeys } + val availableCandidates = visibleCandidates().filterNot { it.key in selectedKeys } val filteredCandidates = FrequentSettingFilters.filter( context = requireContext(), candidates = availableCandidates, @@ -144,6 +145,16 @@ class FrequentSettingsAddBottomSheetFragment : BottomSheetDialogFragment() { adapter.submitList(filteredCandidates) } + private fun visibleCandidates(): List { + val touchEffectType = AppPreference.keyboard_touch_effect_type_preference + return candidates.filter { destination -> + KeyboardTouchEffectSettingVisibility.isVisibleForEffect( + destination = destination, + effectType = touchEffectType, + ) + } + } + private fun add(destination: SettingDestination) { if (!selectedKeys.add(destination.key)) return parentFragmentManager.setFragmentResult( diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/KeyboardTouchEffectSettingVisibility.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/KeyboardTouchEffectSettingVisibility.kt new file mode 100644 index 00000000..b6b9fd1a --- /dev/null +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/KeyboardTouchEffectSettingVisibility.kt @@ -0,0 +1,22 @@ +package com.kazumaproject.markdownhelperkeyboard.setting_activity.ui.setting + +import com.kazumaproject.markdownhelperkeyboard.ime_service.image_effect.KeyboardTouchEffectType + +internal object KeyboardTouchEffectSettingVisibility { + const val LIQUID_INK_DENSITY_KEY = + "keyboard_touch_effect_liquid_ink_density_preference" + const val AURORA_INK_DENSITY_KEY = + "keyboard_touch_effect_aurora_ink_density_preference" + + fun isVisibleForEffect(preferenceKey: String, effectType: String): Boolean { + val normalizedEffect = KeyboardTouchEffectType.normalize(effectType) + return when (preferenceKey) { + LIQUID_INK_DENSITY_KEY -> KeyboardTouchEffectType.isLiquidInk(normalizedEffect) + AURORA_INK_DENSITY_KEY -> KeyboardTouchEffectType.isAuroraInk(normalizedEffect) + else -> true + } + } + + fun isVisibleForEffect(destination: SettingDestination, effectType: String): Boolean = + isVisibleForEffect(destination.key, effectType) +} diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt index bc85704a..08d2dd49 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingDestination.kt @@ -237,6 +237,72 @@ object SettingDestinations { highlightPreferenceKey = "theme_custom_candidate_empty_popup_text_color", ) ) + add( + destination( + key = "key_popup_use_custom_color_preference", + title = context.getString(R.string.key_popup_use_custom_color_title), + summary = context.getString(R.string.key_popup_use_custom_color_summary_off), + category = SettingCategory.KEYBOARD_DISPLAY, + keywords = listOf( + "popup", + "PopupView", + "tap", + "flick", + "color", + "theme", + "タップ", + "フリック", + "色", + ), + destinationId = R.id.keyboardThemeFragment, + iconRes = CoreR.drawable.outline_border_color_24, + highlightPreferenceKey = "key_popup_use_custom_color_preference", + ) + ) + add( + destination( + key = "key_popup_background_color_preference", + title = context.getString(R.string.key_popup_background_color_title), + summary = context.getString(R.string.key_popup_use_custom_color_summary_on), + category = SettingCategory.KEYBOARD_DISPLAY, + keywords = listOf( + "popup", + "PopupView", + "tap", + "flick", + "background", + "color", + "タップ", + "フリック", + "背景色", + ), + destinationId = R.id.keyboardThemeFragment, + iconRes = CoreR.drawable.outline_border_color_24, + highlightPreferenceKey = "key_popup_background_color_preference", + ) + ) + add( + destination( + key = "key_popup_text_color_preference", + title = context.getString(R.string.key_popup_text_color_title), + summary = context.getString(R.string.key_popup_use_custom_color_summary_on), + category = SettingCategory.KEYBOARD_DISPLAY, + keywords = listOf( + "popup", + "PopupView", + "tap", + "flick", + "text", + "color", + "タップ", + "フリック", + "文字色", + ), + destinationId = R.id.keyboardThemeFragment, + iconRes = CoreR.drawable.outline_border_color_24, + highlightPreferenceKey = "key_popup_text_color_preference", + ) + ) add( destination( key = "candidate_view_height_setting_fragment_preference", @@ -666,6 +732,9 @@ object SettingDestinations { "setting_route_keyboard_theme" -> R.id.keyboardThemeFragment "theme_custom_candidate_empty_popup_bg_color" -> R.id.keyboardThemeFragment "theme_custom_candidate_empty_popup_text_color" -> R.id.keyboardThemeFragment + "key_popup_use_custom_color_preference" -> R.id.keyboardThemeFragment + "key_popup_background_color_preference" -> R.id.keyboardThemeFragment + "key_popup_text_color_preference" -> R.id.keyboardThemeFragment "setting_route_kana_preferences" -> R.id.kanaPreferenceFragment "setting_route_qwerty_preferences" -> R.id.qwertyPreferenceFragment "setting_route_sumire_preferences" -> R.id.sumirePreferenceFragment diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingHomeFragment.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingHomeFragment.kt index a8f91f5c..dc3af1f2 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingHomeFragment.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingHomeFragment.kt @@ -377,7 +377,15 @@ class SettingHomeFragment : Fragment() { } else { SettingDestinations.defaultFrequent(context).map { it.key } } - return selected.mapNotNull { candidates[it] } + val touchEffectType = appPreference.keyboard_touch_effect_type_preference + return selected + .mapNotNull { candidates[it] } + .filter { destination -> + KeyboardTouchEffectSettingVisibility.isVisibleForEffect( + destination = destination, + effectType = touchEffectType, + ) + } } private fun currentSummary(destination: SettingDestination): String { diff --git a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchFragment.kt b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchFragment.kt index 76f2b510..dc2a6680 100644 --- a/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchFragment.kt +++ b/app/src/main/java/com/kazumaproject/markdownhelperkeyboard/setting_activity/ui/setting/SettingSearchFragment.kt @@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import com.kazumaproject.markdownhelperkeyboard.R import com.kazumaproject.markdownhelperkeyboard.databinding.FragmentSettingSearchBinding +import com.kazumaproject.markdownhelperkeyboard.setting_activity.AppPreference class SettingSearchFragment : Fragment() { @@ -74,9 +75,16 @@ class SettingSearchFragment : Fragment() { private fun renderResults(query: String) { val normalizedQuery = SettingSearchIndex.normalizeForSearch(query) + val touchEffectType = AppPreference.keyboard_touch_effect_type_preference + val visibleDestinations = searchableDestinations.filter { destination -> + KeyboardTouchEffectSettingVisibility.isVisibleForEffect( + destination = destination, + effectType = touchEffectType, + ) + } val results = SettingSearchIndex.search( context = requireContext(), - destinations = searchableDestinations, + destinations = visibleDestinations, query = query, ) searchAdapter.submitList(results) diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index 25d9e1ee..0e179db5 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -395,15 +395,15 @@ + android:label="@string/tenkey_popup_view_style_preference_title" /> + android:label="@string/qwerty_popup_view_style_preference_title" /> + android:label="@string/flick_keyboard_popup_view_style_preference_title"> diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 3ae43637..91ca50ec 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -774,11 +774,16 @@ 候補文字色 候補項目の背景色 候補項目の押下時背景色 - ポップアップ背景色 - ポップアップ文字色 + 候補欄補助ボタン背景色 + 候補欄補助ボタン文字色 ショートカットアイコン色 候補欄が空のときに表示される補助ボタンの背景色 候補欄が空のときに表示される補助ボタンの文字色とアイコン色 + タップ・フリック PopupView の色を指定 + 指定した色をタップ・フリック時の PopupView に適用します + 現在のテーマ色を使用します + タップ・フリック PopupView 背景色 + タップ・フリック PopupView 文字色 色を選択 テーマ キーのサイズ @@ -1111,8 +1116,12 @@ 完了 キーのサイズ キー、文字、特殊キーのアイコンサイズを変更します - ポップアップ表示 - QWERTY のキー preview と長押し popup のサイズと文字サイズを設定します + タップ・フリック PopupView のサイズ + TenKey の PopupView サイズと文字サイズを設定します + タップ・フリック PopupView のサイズ + QWERTY/ローマ字のキー preview と長押し候補 PopupView のサイズと文字サイズを設定します + タップ・フリック PopupView のサイズ + 方向別・十字・サークル・2段/3段フリック PopupView のサイズと文字サイズを設定します QWERTY 数字キーの上・下フリックで出力する文字を設定します 数字キーのフリック設定 数字入力欄で使用する diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 92f7efd6..2feeabb4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -858,11 +858,16 @@ Candidate text color Candidate item background color Candidate item pressed background color - Popup background color - Popup text color + Candidate helper button background color + Candidate helper button text color Shortcut icon color Background color for helper buttons shown when the candidate row is empty Text and icon color for helper buttons shown when the candidate row is empty + Specify tap/flick PopupView colors + Apply the specified colors to PopupViews shown while tapping or flicking + Use the current theme colors + Tap/flick PopupView background color + Tap/flick PopupView text color Select Color Keyboard Theme Adjust key size @@ -1119,8 +1124,12 @@ Donuts Flick Key size Change the size of keys, text, and special key icons. - Popup display - Configure the size and text size of QWERTY key previews and long-press popups. + Tap/flick PopupView size + Configure TenKey PopupView size and text size. + Tap/flick PopupView size + Configure the size and text size of QWERTY/Romaji key previews and long-press variation PopupViews. + Tap/flick PopupView size + Configure size and text size for directional, cross, circle, and 2-step/3-step flick PopupViews. Number key flick settings Configure the characters output by upward and downward flicks on QWERTY number keys. Use for number input fields diff --git a/app/src/main/res/xml/pref_custom.xml b/app/src/main/res/xml/pref_custom.xml index b539c71d..94f2739c 100644 --- a/app/src/main/res/xml/pref_custom.xml +++ b/app/src/main/res/xml/pref_custom.xml @@ -11,8 +11,8 @@ + android:title="@string/flick_keyboard_popup_view_style_preference_title" + android:summary="@string/flick_keyboard_popup_view_style_preference_summary" /> + android:title="@string/tenkey_popup_view_style_preference_title" + android:summary="@string/tenkey_popup_view_style_preference_summary" /> + android:title="@string/flick_keyboard_popup_view_style_preference_title" + android:summary="@string/flick_keyboard_popup_view_style_preference_summary" /> + textView.setTextColor(resolvedTextColor) + imageView.setColorFilter(resolvedTextColor, PorterDuff.Mode.SRC_IN) + } } fun applyTextSize(textSizeSp: Float) { @@ -134,6 +149,8 @@ class CrossFlickPopupView(context: Context) : FrameLayout(context) { private var colorTheme: FlickPopupColorTheme? = null private var highlightedDirection: FlickDirection? = null private var popupTextSizeSp: Float = 18f + private var popupBackgroundColor: Int? = null + private var popupTextColor: Int? = null init { addView(gridLayout, LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)) @@ -141,14 +158,15 @@ class CrossFlickPopupView(context: Context) : FrameLayout(context) { fun setColors(theme: FlickPopupColorTheme) { colorTheme = theme - cells.forEach { (dir, cell) -> - cell.applyColors(theme, dir == highlightedDirection) - } + updateCellColors() } fun applyPopupViewStyle(style: PopupViewStyle) { popupTextSizeSp = style.textSizeSp.coerceIn(8f, 48f) + popupBackgroundColor = style.backgroundColor + popupTextColor = style.textColor updateCellTextSizes() + updateCellColors() invalidate() } @@ -174,9 +192,19 @@ class CrossFlickPopupView(context: Context) : FrameLayout(context) { applyTextSize(popupTextSizeSp) val theme = colorTheme if (theme != null) { - applyColors(theme, direction == highlightedDirection) + applyColors( + theme, + direction == highlightedDirection, + popupBackgroundColor, + popupTextColor + ) } else { - applyFallbackColors(context, direction == highlightedDirection) + applyFallbackColors( + context, + direction == highlightedDirection, + popupBackgroundColor, + popupTextColor + ) } } cell.layoutParams = params @@ -215,9 +243,19 @@ class CrossFlickPopupView(context: Context) : FrameLayout(context) { applyTextSize(popupTextSizeSp) val theme = colorTheme if (theme != null) { - applyColors(theme, direction == highlightedDirection) + applyColors( + theme, + direction == highlightedDirection, + popupBackgroundColor, + popupTextColor + ) } else { - applyFallbackColors(context, direction == highlightedDirection) + applyFallbackColors( + context, + direction == highlightedDirection, + popupBackgroundColor, + popupTextColor + ) } } cell.layoutParams = params @@ -233,17 +271,31 @@ class CrossFlickPopupView(context: Context) : FrameLayout(context) { fun highlightDirection(direction: FlickDirection?) { highlightedDirection = direction + updateCellColors() + } + + private fun updateCellTextSizes() { + cells.values.forEach { it.applyTextSize(popupTextSizeSp) } + } + + private fun updateCellColors() { val theme = colorTheme cells.forEach { (dir, cell) -> if (theme != null) { - cell.applyColors(theme, dir == direction) + cell.applyColors( + theme, + dir == highlightedDirection, + popupBackgroundColor, + popupTextColor + ) } else { - cell.applyFallbackColors(context, dir == direction) + cell.applyFallbackColors( + context, + dir == highlightedDirection, + popupBackgroundColor, + popupTextColor + ) } } } - - private fun updateCellTextSizes() { - cells.values.forEach { it.applyTextSize(popupTextSizeSp) } - } } diff --git a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/DirectionalKeyPopupView.kt b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/DirectionalKeyPopupView.kt index be301116..c17e48c2 100644 --- a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/DirectionalKeyPopupView.kt +++ b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/DirectionalKeyPopupView.kt @@ -42,6 +42,8 @@ class DirectionalKeyPopupView(context: Context) : AppCompatTextView(context) { // ▼▼▼ 追加: 枠線用の色を保持するプロパティ ▼▼▼ private var separatorColor = Color.LTGRAY + private var popupBackgroundColor: Int? = null + private var popupTextColor: Int? = null init { // init時のテキスト色はテーマで上書きされる前提 @@ -59,7 +61,7 @@ class DirectionalKeyPopupView(context: Context) : AppCompatTextView(context) { this.highlightColor = theme.centerGradientStartColor this.separatorColor = theme.separatorColor // Viewのテキストカラー状態を更新する - setTextColor(theme.textColor) + setTextColor(popupTextColor ?: theme.textColor) } fun setFlickDirection(direction: FlickDirection) { @@ -75,7 +77,11 @@ class DirectionalKeyPopupView(context: Context) : AppCompatTextView(context) { } fun applyPopupViewStyle(style: PopupViewStyle) { + popupBackgroundColor = style.backgroundColor + popupTextColor = style.textColor setTextSize(TypedValue.COMPLEX_UNIT_SP, style.textSizeSp.coerceIn(8f, 48f)) + style.textColor?.let { setTextColor(it) } + invalidate() } /** @@ -86,7 +92,7 @@ class DirectionalKeyPopupView(context: Context) : AppCompatTextView(context) { val h = height.toFloat() if (w == 0f || h == 0f) return - backgroundPaint.color = if (currentDirection == FlickDirection.TAP) { + backgroundPaint.color = popupBackgroundColor ?: if (currentDirection == FlickDirection.TAP) { this.highlightColor } else { this.highlightColor diff --git a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/FlickKeyboardView.kt b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/FlickKeyboardView.kt index a1bf8084..ecd965d5 100644 --- a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/FlickKeyboardView.kt +++ b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/FlickKeyboardView.kt @@ -218,7 +218,9 @@ class FlickKeyboardView @JvmOverloads constructor( private fun clampPopupStyle(style: PopupViewStyle): PopupViewStyle { return PopupViewStyle( sizeScalePercent = style.sizeScalePercent.coerceIn(50, 200), - textSizeSp = style.textSizeSp.coerceIn(8f, 48f) + textSizeSp = style.textSizeSp.coerceIn(8f, 48f), + backgroundColor = style.backgroundColor, + textColor = style.textColor ) } diff --git a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/StandardFlickPopupView.kt b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/StandardFlickPopupView.kt index 43b05b0c..a39bb531 100644 --- a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/StandardFlickPopupView.kt +++ b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/StandardFlickPopupView.kt @@ -44,6 +44,8 @@ class StandardFlickPopupView(context: Context) : AppCompatTextView(context) { private var lastTextColor: Int = Color.BLACK private var lastStrokeColor: Int = Color.LTGRAY private var popupTextSizeSp: Float = 19f + private var popupBackgroundColor: Int? = null + private var popupTextColor: Int? = null private class YOffsetSpan(private val yOffset: Int) : ReplacementSpan() { override fun getSize( @@ -89,9 +91,7 @@ class StandardFlickPopupView(context: Context) : AppCompatTextView(context) { lastTextColor = textColor lastStrokeColor = strokeColor - setTextColor(textColor) - backgroundDrawable.setColor(backgroundColor) - backgroundDrawable.setStroke(dpToPx(1), strokeColor) + applyResolvedColors() invalidate() } @@ -230,12 +230,21 @@ class StandardFlickPopupView(context: Context) : AppCompatTextView(context) { val scale = style.sizeScalePercent.coerceIn(50, 200) / 100f viewSize = (dpToPx(72) * scale).toInt().coerceAtLeast(1) popupTextSizeSp = style.textSizeSp.coerceIn(8f, 48f) + popupBackgroundColor = style.backgroundColor + popupTextColor = style.textColor + applyResolvedColors() width = viewSize height = viewSize requestLayout() invalidate() } + private fun applyResolvedColors() { + setTextColor(popupTextColor ?: lastTextColor) + backgroundDrawable.setColor(popupBackgroundColor ?: lastBackgroundColor) + backgroundDrawable.setStroke(dpToPx(1), lastStrokeColor) + } + private fun createBackground(): GradientDrawable { return GradientDrawable().apply { shape = GradientDrawable.OVAL diff --git a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/TfbiFlickPopupView.kt b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/TfbiFlickPopupView.kt index b6b73f63..ac66b472 100644 --- a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/TfbiFlickPopupView.kt +++ b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/view/TfbiFlickPopupView.kt @@ -41,6 +41,8 @@ class TfbiFlickPopupView(context: Context) : View(context) { textAlign = Paint.Align.CENTER textSize = spToPx(20f) } + private var popupBackgroundColor: Int? = null + private var popupTextColor: Int? = null private val rects = mutableMapOf() private var cornerRadius = 20f @@ -68,6 +70,7 @@ class TfbiFlickPopupView(context: Context) : View(context) { highlightBgPaint.color = highlightedBackgroundColor strokePaint.color = textColor textPaint.color = textColor + applyPopupColorOverrides() invalidate() } @@ -85,10 +88,21 @@ class TfbiFlickPopupView(context: Context) : View(context) { } fun applyPopupViewStyle(style: PopupViewStyle) { + popupBackgroundColor = style.backgroundColor + popupTextColor = style.textColor textPaint.textSize = spToPx(style.textSizeSp.coerceIn(8f, 48f)) + applyPopupColorOverrides() invalidate() } + private fun applyPopupColorOverrides() { + popupBackgroundColor?.let { bgPaint.color = it } + popupTextColor?.let { textColor -> + textPaint.color = textColor + strokePaint.color = textColor + } + } + // ===== Viewのライフサイクル ===== override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { 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 55507420..72854851 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 @@ -2298,6 +2298,12 @@ class QWERTYKeyboardView @JvmOverloads constructor( } } + keyPreviewPopupStyle.backgroundColor?.let { backgroundColor -> + iv.setDrawableSolidColor(backgroundColor) + } + keyPreviewPopupStyle.textColor?.let { textColor -> + tv.setTextColor(textColor) + } popupView.rootView.layoutParams.height = previewHeight when (view) { @@ -2572,11 +2578,15 @@ class QWERTYKeyboardView @JvmOverloads constructor( fun applyPopupViewStyleSet(styleSet: QwertyPopupViewStyleSet) { keyPreviewPopupStyle = PopupViewStyle( sizeScalePercent = styleSet.keyPreview.sizeScalePercent.coerceIn(50, 200), - textSizeSp = styleSet.keyPreview.textSizeSp.coerceIn(8f, 48f) + textSizeSp = styleSet.keyPreview.textSizeSp.coerceIn(8f, 48f), + backgroundColor = styleSet.keyPreview.backgroundColor, + textColor = styleSet.keyPreview.textColor ) variationPopupStyle = PopupViewStyle( sizeScalePercent = styleSet.variation.sizeScalePercent.coerceIn(50, 200), - textSizeSp = styleSet.variation.textSizeSp.coerceIn(8f, 48f) + textSizeSp = styleSet.variation.textSizeSp.coerceIn(8f, 48f), + backgroundColor = styleSet.variation.backgroundColor, + textColor = styleSet.variation.textColor ) variationPopupView?.applyPopupViewStyle(variationPopupStyle) } diff --git a/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/VariationsPopupView.kt b/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/VariationsPopupView.kt index 5d0064c8..238724eb 100644 --- a/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/VariationsPopupView.kt +++ b/qwerty_keyboard/src/main/java/com/kazumaproject/qwerty_keyboard/ui/VariationsPopupView.kt @@ -34,6 +34,8 @@ class VariationsPopupView(context: Context) : View(context) { private var itemHeight = 0f private var numColumns = 1 private var numRows = 1 + private var popupBackgroundColor: Int? = null + private var popupTextColor: Int? = null // ■■■ FLATモード用 (元のコードの変数) ■■■ private val flatTextPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { @@ -71,6 +73,8 @@ class VariationsPopupView(context: Context) : View(context) { private val itemCornerRadius = 15f fun applyPopupViewStyle(style: PopupViewStyle) { + popupBackgroundColor = style.backgroundColor + popupTextColor = style.textColor val textSizePx = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, style.textSizeSp.coerceIn(8f, 48f), @@ -78,6 +82,14 @@ class VariationsPopupView(context: Context) : View(context) { ) flatTextPaint.textSize = textSizePx neuTextPaint.textSize = textSizePx + style.backgroundColor?.let { backgroundColor -> + flatBackgroundPaint.color = backgroundColor + neuBackgroundPaint.color = backgroundColor + } + style.textColor?.let { textColor -> + flatTextPaint.color = textColor + neuTextPaint.color = textColor + } invalidate() } @@ -90,8 +102,8 @@ class VariationsPopupView(context: Context) : View(context) { // モードを自動的にニューモーフィズムに切り替え currentStyle = PopupStyle.NEUMORPHISM - neuBackgroundPaint.color = bgColor - neuTextPaint.color = textColor + neuBackgroundPaint.color = popupBackgroundColor ?: bgColor + neuTextPaint.color = popupTextColor ?: textColor neuSelectedFillPaint.color = selectedColor // 影の色を計算 diff --git a/tenkey/src/main/java/com/kazumaproject/tenkey/TenKey.kt b/tenkey/src/main/java/com/kazumaproject/tenkey/TenKey.kt index 2f9bb4b7..2cca5a81 100644 --- a/tenkey/src/main/java/com/kazumaproject/tenkey/TenKey.kt +++ b/tenkey/src/main/java/com/kazumaproject/tenkey/TenKey.kt @@ -576,14 +576,18 @@ class TenKey(context: Context, attributeSet: AttributeSet) : popTextCenter = centerBinding.popupText } applyPopupTextSize() + applyPopupColors() } fun applyPopupViewStyle(style: PopupViewStyle) { popupViewStyle = PopupViewStyle( sizeScalePercent = style.sizeScalePercent.coerceIn(50, 200), - textSizeSp = style.textSizeSp.coerceIn(8f, 48f) + textSizeSp = style.textSizeSp.coerceIn(8f, 48f), + backgroundColor = style.backgroundColor, + textColor = style.textColor ) applyPopupTextSize() + applyPopupColors() } private fun applyPopupTextSize() { @@ -603,6 +607,34 @@ class TenKey(context: Context, attributeSet: AttributeSet) : } } + private fun applyPopupColors() { + if (!::bubbleViewActive.isInitialized || !::popTextActive.isInitialized) return + popupViewStyle.backgroundColor?.let { backgroundColor -> + listOf( + bubbleViewActive, + bubbleViewLeft, + bubbleViewTop, + bubbleViewRight, + bubbleViewBottom, + bubbleViewCenter + ).forEach { bubbleView -> + bubbleView.setBubbleColor(backgroundColor) + } + } + popupViewStyle.textColor?.let { textColor -> + listOf( + popTextActive, + popTextLeft, + popTextTop, + popTextRight, + popTextBottom, + popTextCenter + ).forEach { textView -> + textView.setTextColor(textColor) + } + } + } + fun setLanguageEnableKeyState(state: Boolean) { this.isLanguageIconEnabled = state } @@ -965,6 +997,8 @@ class TenKey(context: Context, attributeSet: AttributeSet) : specialKeyTextColor = customSpecialKeyTextColor, borderWidth = borderWidth ) + applyPopupTextSize() + applyPopupColors() } else -> { From f7691e21a482be49af3f1db8c70876950652b260 Mon Sep 17 00:00:00 2001 From: KazumaProject <59742125+KazumaProject@users.noreply.github.com> Date: Wed, 17 Jun 2026 01:44:24 -0400 Subject: [PATCH 3/3] fix build --- .github/workflows/android.yml | 10 ++++++++ app/build.gradle | 4 +-- zenz/build.gradle | 6 +++++ zenz/scripts/prepare_zenz_model.sh | 40 +++++++++++++++++++++++++++++- 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d1ece16c..a6ebebf5 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,6 +11,8 @@ permissions: jobs: build: runs-on: ubuntu-latest + env: + ZENZ_MODEL_CACHE_DIR: ${{ github.workspace }}/.zenz-model-cache steps: - name: Checkout code @@ -40,6 +42,12 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- + - name: Cache Zenz model + uses: actions/cache@v4 + with: + path: .zenz-model-cache + key: ${{ runner.os }}-zenz-model-v1-a728931c8b4867a53ca33d1ff3fe7360b0f15cd5-Q5_K_M-ggml-model-Q5_K_M.gguf + - name: Decode JKS from Base64 run: | echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > my-release-key.jks @@ -58,6 +66,8 @@ jobs: echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> local.properties - name: Build Release Variants + env: + HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | ./gradlew clean \ :app:assembleFullStandardRelease \ diff --git a/app/build.gradle b/app/build.gradle index c5014f32..49387eaf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,8 +31,8 @@ android { applicationId "com.kazumaproject.markdownhelperkeyboard" minSdk 24 targetSdk 36 - versionCode 781 - versionName "1.7.88" + versionCode 782 + versionName "1.7.89" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/zenz/build.gradle b/zenz/build.gradle index 1ac1b24e..88c7166d 100644 --- a/zenz/build.gradle +++ b/zenz/build.gradle @@ -24,6 +24,9 @@ def zenzModelAssetName = providers.gradleProperty("zenzModelAssetName") def zenzModelHfToken = providers.gradleProperty("zenzModelHfToken") .orElse(localProperties.getProperty("zenzModelHfToken") ?: System.getenv("HF_TOKEN") ?: "") .get() +def zenzModelCacheDir = providers.gradleProperty("zenzModelCacheDir") + .orElse(localProperties.getProperty("zenzModelCacheDir") ?: System.getenv("ZENZ_MODEL_CACHE_DIR") ?: "") + .get() def generatedZenzAssetsDir = layout.buildDirectory.dir("generated/assets/zenzModel/main") android { @@ -100,6 +103,9 @@ def prepareZenzModel = tasks.register("prepareZenzModel", Exec) { environment "ZENZ_MODEL_WORK_DIR", layout.buildDirectory.dir("intermediates/zenzModel").get().asFile.absolutePath environment "ZENZ_MODEL_HF_TOKEN", zenzModelHfToken environment "ZENZ_LLAMA_CPP_DIR", file("src/main/cpp/llama.cpp").absolutePath + if (zenzModelCacheDir) { + environment "ZENZ_MODEL_CACHE_DIR", zenzModelCacheDir + } } tasks.named("preBuild").configure { diff --git a/zenz/scripts/prepare_zenz_model.sh b/zenz/scripts/prepare_zenz_model.sh index 63d431b7..35855efb 100644 --- a/zenz/scripts/prepare_zenz_model.sh +++ b/zenz/scripts/prepare_zenz_model.sh @@ -35,15 +35,33 @@ F16_FILE="${WORK_DIR}/ggml-model-f16.gguf" OUTPUT_FILE="${OUTPUT_DIR}/${ZENZ_MODEL_ASSET_NAME}" STAMP_FILE="${WORK_DIR}/build-stamp.txt" EXPECTED_STAMP="${ZENZ_MODEL_REPO}|${ZENZ_MODEL_REVISION}|${ZENZ_MODEL_QUANTIZATION}|${ZENZ_MODEL_ASSET_NAME}" +CACHE_DIR="${ZENZ_MODEL_CACHE_DIR:-}" +CACHE_FILE="" +CACHE_STAMP_FILE="" export MODEL_DIR +if [[ -n "${CACHE_DIR}" ]]; then + CACHE_FILE="${CACHE_DIR}/${ZENZ_MODEL_ASSET_NAME}" + CACHE_STAMP_FILE="${CACHE_DIR}/build-stamp.txt" +fi + mkdir -p "${OUTPUT_DIR}" "${WORK_DIR}" +if [[ -n "${CACHE_DIR}" ]]; then + mkdir -p "${CACHE_DIR}" +fi if [[ -f "${OUTPUT_FILE}" && -f "${STAMP_FILE}" ]] && grep -qx "${EXPECTED_STAMP}" "${STAMP_FILE}"; then echo "Zenz model already prepared at ${OUTPUT_FILE}" exit 0 fi +if [[ -n "${CACHE_FILE}" && -f "${CACHE_FILE}" && -f "${CACHE_STAMP_FILE}" ]] && grep -qx "${EXPECTED_STAMP}" "${CACHE_STAMP_FILE}"; then + cp "${CACHE_FILE}" "${OUTPUT_FILE}" + cp "${CACHE_STAMP_FILE}" "${STAMP_FILE}" + echo "Restored Zenz model from cache at ${CACHE_FILE}" + exit 0 +fi + python3 -m venv "${VENV_DIR}" PYTHON_BIN="${VENV_DIR}/bin/python" PIP_BIN="${VENV_DIR}/bin/pip" @@ -55,7 +73,8 @@ PIP_BIN="${VENV_DIR}/bin/pip" rm -rf "${MODEL_DIR}" mkdir -p "${MODEL_DIR}" -HF_TOKEN="${ZENZ_MODEL_HF_TOKEN:-}" "${PYTHON_BIN}" - <<'PY' +download_model() { + HF_TOKEN="${ZENZ_MODEL_HF_TOKEN:-}" "${PYTHON_BIN}" - <<'PY' import os from huggingface_hub import snapshot_download @@ -72,6 +91,21 @@ snapshot_download( token=token, ) PY +} + +max_attempts=6 +for attempt in $(seq 1 "${max_attempts}"); do + if download_model; then + break + fi + if [[ "${attempt}" -eq "${max_attempts}" ]]; then + echo "Failed to download Zenz model after ${max_attempts} attempts." >&2 + exit 1 + fi + sleep_seconds=$((attempt * 15)) + echo "Zenz model download failed; retrying in ${sleep_seconds}s (${attempt}/${max_attempts})..." >&2 + sleep "${sleep_seconds}" +done cmake -S "${LLAMA_CPP_DIR}" -B "${HOST_BUILD_DIR}" \ -DCMAKE_BUILD_TYPE=Release \ @@ -93,4 +127,8 @@ cmake --build "${HOST_BUILD_DIR}" --config Release --target llama-quantize -j >/ "${ZENZ_MODEL_QUANTIZATION}" >/dev/null printf '%s\n' "${EXPECTED_STAMP}" > "${STAMP_FILE}" +if [[ -n "${CACHE_FILE}" ]]; then + cp "${OUTPUT_FILE}" "${CACHE_FILE}" + cp "${STAMP_FILE}" "${CACHE_STAMP_FILE}" +fi echo "Prepared ${OUTPUT_FILE}"