diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AndroidTtsPlayer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AndroidTtsPlayer.kt index 8aec5d8d1c5a..b57e7d930717 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AndroidTtsPlayer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AndroidTtsPlayer.kt @@ -20,6 +20,7 @@ import android.content.Context import android.os.Bundle import android.speech.tts.TextToSpeech import android.speech.tts.TextToSpeech.ERROR +import android.speech.tts.TextToSpeech.Engine.KEY_PARAM_VOLUME import androidx.annotation.CheckResult import com.ichi2.anki.AndroidTtsError.TtsErrorCode import com.ichi2.compat.UtteranceProgressListenerCompat @@ -82,6 +83,11 @@ class AndroidTtsPlayer(private val context: Context, private val voices: List(R.string.tts_volume_key) + ttsVolumePref.setOnPreferenceChangeListener { _, newValue -> + val newVolume = newValue as Int + val sharedPref = requireContext().getSharedPreferences(getString(R.string.tts_volume_preferences), Context.MODE_PRIVATE) + with(sharedPref.edit()) { + putInt(getString(R.string.tts_volume_key), newVolume) + apply() + } + true // Indicate that the change has been handled + } + // Configure "Reset languages" preference requirePreference(R.string.pref_reset_languages_key).setOnPreferenceClickListener { AlertDialog.Builder(requireContext()).show { diff --git a/AnkiDroid/src/main/res/values/10-preferences.xml b/AnkiDroid/src/main/res/values/10-preferences.xml index b89ee70f4b0c..b7a68b63477a 100644 --- a/AnkiDroid/src/main/res/values/10-preferences.xml +++ b/AnkiDroid/src/main/res/values/10-preferences.xml @@ -100,7 +100,9 @@ Double the scroll gap with eReader Swipe sensitivity Text to speech + TTS volume Reads out question and answer if no sound file is included + tts_volume_preferences Fetch media on sync AnkiWeb account diff --git a/AnkiDroid/src/main/res/values/preferences.xml b/AnkiDroid/src/main/res/values/preferences.xml index e90c4c8a8e5d..23d20b879cc3 100644 --- a/AnkiDroid/src/main/res/values/preferences.xml +++ b/AnkiDroid/src/main/res/values/preferences.xml @@ -159,6 +159,7 @@ providerEnabled thirdpartyapps_link tts + tts_volume double_scrolling html_javascript_debugging card_browser_enable_external_context_menu diff --git a/AnkiDroid/src/main/res/xml/preferences_advanced.xml b/AnkiDroid/src/main/res/xml/preferences_advanced.xml index 6cd84e4c740f..9ee5a6f5b2af 100644 --- a/AnkiDroid/src/main/res/xml/preferences_advanced.xml +++ b/AnkiDroid/src/main/res/xml/preferences_advanced.xml @@ -110,4 +110,9 @@ android:key="@string/tts_key" android:summary="@string/tts_summ" android:title="@string/tts" /> +