diff --git a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt index ddb35c2cc..c0c55d6a8 100644 --- a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt @@ -5,6 +5,7 @@ import android.view.View import androidx.annotation.LayoutRes import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager +import io.legado.app.R import io.legado.app.help.coroutine.Coroutine import io.legado.app.lib.theme.ThemeStore import kotlinx.coroutines.CoroutineScope @@ -14,12 +15,28 @@ import kotlinx.coroutines.cancel import kotlin.coroutines.CoroutineContext -abstract class BaseDialogFragment(@LayoutRes layoutID: Int) : DialogFragment(layoutID), +abstract class BaseDialogFragment( + @LayoutRes layoutID: Int, + private val adaptationSoftKeyboard: Boolean = false +) : DialogFragment(layoutID), + CoroutineScope by MainScope() { + override fun onStart() { + super.onStart() + if (adaptationSoftKeyboard) { + dialog?.window?.setBackgroundDrawableResource(R.color.transparent) + } + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - view.setBackgroundColor(ThemeStore.backgroundColor()) + if (adaptationSoftKeyboard) { + view.findViewById(R.id.vw_bg)?.setOnClickListener(null) + view.setOnClickListener { dismiss() } + } else { + view.setBackgroundColor(ThemeStore.backgroundColor()) + } onFragmentCreated(view, savedInstanceState) observeLiveBus() } diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index 6cf4c248d..52289e9d5 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -292,6 +292,7 @@ abstract class BaseReadAloudService : BaseService(), } AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> { // 短暂丢失焦点,这种情况是被其他应用申请了短暂的焦点希望其他声音能压低音量(或者关闭声音)凸显这个声音(比如短信提示音), + AppLog.put("短暂丢失焦点,不做处理") } } } diff --git a/app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkDialog.kt b/app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkDialog.kt index 11405efca..3688ae131 100644 --- a/app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkDialog.kt @@ -16,7 +16,7 @@ import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark) { +class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark, true) { constructor(bookmark: Bookmark, editPos: Int = -1) : this() { arguments = Bundle().apply { @@ -30,12 +30,9 @@ class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark) { override fun onStart() { super.onStart() setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) - dialog?.window?.setBackgroundDrawableResource(R.color.transparent) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - view.setBackgroundResource(R.color.transparent) - view.setOnClickListener { dismiss() } binding.toolBar.setBackgroundColor(primaryColor) val arguments = arguments ?: let { dismiss() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt index a30dbf956..eed08b409 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt @@ -21,7 +21,7 @@ import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding -class HttpTtsEditDialog() : BaseDialogFragment(R.layout.dialog_http_tts_edit), +class HttpTtsEditDialog() : BaseDialogFragment(R.layout.dialog_http_tts_edit, true), Toolbar.OnMenuItemClickListener { constructor(id: Long) : this() { @@ -36,12 +36,9 @@ class HttpTtsEditDialog() : BaseDialogFragment(R.layout.dialog_http_tts_edit), override fun onStart() { super.onStart() setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) - dialog?.window?.setBackgroundDrawableResource(R.color.transparent) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - view.setBackgroundResource(R.color.transparent) - view.setOnClickListener { dismiss() } binding.toolBar.setBackgroundColor(primaryColor) binding.tvUrl.run { addLegadoPattern() diff --git a/app/src/main/java/io/legado/app/ui/login/SourceLoginDialog.kt b/app/src/main/java/io/legado/app/ui/login/SourceLoginDialog.kt index 1a32c0645..4a956a4dd 100644 --- a/app/src/main/java/io/legado/app/ui/login/SourceLoginDialog.kt +++ b/app/src/main/java/io/legado/app/ui/login/SourceLoginDialog.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.withContext import splitties.views.onClick -class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) { +class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login, true) { private val binding by viewBinding(DialogLoginBinding::bind) private val viewModel by activityViewModels() @@ -34,12 +34,9 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) { override fun onStart() { super.onStart() setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) - dialog?.window?.setBackgroundDrawableResource(R.color.transparent) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - view.setBackgroundResource(R.color.transparent) - view.setOnClickListener { dismiss() } val source = viewModel.source ?: return binding.toolBar.setBackgroundColor(primaryColor) binding.toolBar.title = getString(R.string.login_source, source.getTag()) diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt index 7a7e90ce2..0c4825f0a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt @@ -14,6 +14,7 @@ import io.legado.app.databinding.ItemLogBinding import io.legado.app.utils.setLayout import io.legado.app.utils.viewbindingdelegate.viewBinding +@Suppress("unused") class TextListDialog() : BaseDialogFragment(R.layout.dialog_recycler_view) { constructor(title: String, values: ArrayList) : this() { diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt index 2b3b84146..2b4a02bb2 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt @@ -24,9 +24,8 @@ class UrlOptionDialog(context: Context, private val success: (String) -> Unit) : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) - binding.root.setOnClickListener { - dismiss() - } + binding.root.setOnClickListener { dismiss() } + binding.vwBg.setOnClickListener(null) binding.editMethod.setFilterValues("POST", "GET") binding.editCharset.setFilterValues(AppConst.charsets) binding.tvOk.setOnClickListener {