This commit is contained in:
Horis
2024-09-20 19:22:48 +08:00
parent 38cecec4ad
commit 4b741f168d
2 changed files with 5 additions and 4 deletions
@@ -103,7 +103,7 @@ class ReadAloudConfigDialog : DialogFragment() {
override fun onPreferenceTreeClick(preference: Preference): Boolean { override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) { when (preference.key) {
PreferKey.ttsEngine -> showDialogFragment(SpeakEngineDialog(this)) PreferKey.ttsEngine -> showDialogFragment(SpeakEngineDialog())
"sysTtsConfig" -> IntentHelp.openTTSSetting() "sysTtsConfig" -> IntentHelp.openTTSSetting()
} }
return super.onPreferenceTreeClick(preference) return super.onPreferenceTreeClick(preference)
@@ -54,7 +54,7 @@ import kotlinx.coroutines.launch
/** /**
* tts引擎管理 * tts引擎管理
*/ */
class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.dialog_recycler_view), class SpeakEngineDialog() : BaseDialogFragment(R.layout.dialog_recycler_view),
Toolbar.OnMenuItemClickListener { Toolbar.OnMenuItemClickListener {
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
@@ -63,6 +63,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di
private val adapter by lazy { Adapter(requireContext()) } private val adapter by lazy { Adapter(requireContext()) }
private var ttsEngine: String? = ReadAloud.ttsEngine private var ttsEngine: String? = ReadAloud.ttsEngine
private val sysTtsViews = arrayListOf<RadioButton>() private val sysTtsViews = arrayListOf<RadioButton>()
private val callBack: CallBack? get() = parentFragment as? CallBack
private val importDocResult = registerForActivityResult(HandleFileContract()) { private val importDocResult = registerForActivityResult(HandleFileContract()) {
it.uri?.let { uri -> it.uri?.let { uri ->
viewModel.importLocal(uri) viewModel.importLocal(uri)
@@ -140,7 +141,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di
tvFooterLeft.visible() tvFooterLeft.visible()
tvFooterLeft.setOnClickListener { tvFooterLeft.setOnClickListener {
ReadBook.book?.setTtsEngine(ttsEngine) ReadBook.book?.setTtsEngine(ttsEngine)
callBack.upSpeakEngineSummary() callBack?.upSpeakEngineSummary()
ReadAloud.upReadAloudClass() ReadAloud.upReadAloudClass()
dismissAllowingStateLoss() dismissAllowingStateLoss()
} }
@@ -149,7 +150,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di
tvOk.setOnClickListener { tvOk.setOnClickListener {
ReadBook.book?.setTtsEngine(null) ReadBook.book?.setTtsEngine(null)
AppConfig.ttsEngine = ttsEngine AppConfig.ttsEngine = ttsEngine
callBack.upSpeakEngineSummary() callBack?.upSpeakEngineSummary()
ReadAloud.upReadAloudClass() ReadAloud.upReadAloudClass()
dismissAllowingStateLoss() dismissAllowingStateLoss()
} }