pull/2287/head
kunfei 2 years ago
parent 26ca62b117
commit 7685360e08
  1. 19
      app/src/main/java/io/legado/app/base/BaseDialogFragment.kt
  2. 1
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  3. 5
      app/src/main/java/io/legado/app/ui/book/bookmark/BookmarkDialog.kt
  4. 5
      app/src/main/java/io/legado/app/ui/book/read/config/HttpTtsEditDialog.kt
  5. 5
      app/src/main/java/io/legado/app/ui/login/SourceLoginDialog.kt
  6. 1
      app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt
  7. 5
      app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt

@ -5,6 +5,7 @@ import android.view.View
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import io.legado.app.R
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.ThemeStore
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -14,12 +15,28 @@ import kotlinx.coroutines.cancel
import kotlin.coroutines.CoroutineContext 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() { CoroutineScope by MainScope() {
override fun onStart() {
super.onStart()
if (adaptationSoftKeyboard) {
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
if (adaptationSoftKeyboard) {
view.findViewById<View>(R.id.vw_bg)?.setOnClickListener(null)
view.setOnClickListener { dismiss() }
} else {
view.setBackgroundColor(ThemeStore.backgroundColor()) view.setBackgroundColor(ThemeStore.backgroundColor())
}
onFragmentCreated(view, savedInstanceState) onFragmentCreated(view, savedInstanceState)
observeLiveBus() observeLiveBus()
} }

@ -292,6 +292,7 @@ abstract class BaseReadAloudService : BaseService(),
} }
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> { AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
// 短暂丢失焦点,这种情况是被其他应用申请了短暂的焦点希望其他声音能压低音量(或者关闭声音)凸显这个声音(比如短信提示音), // 短暂丢失焦点,这种情况是被其他应用申请了短暂的焦点希望其他声音能压低音量(或者关闭声音)凸显这个声音(比如短信提示音),
AppLog.put("短暂丢失焦点,不做处理")
} }
} }
} }

@ -16,7 +16,7 @@ import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext 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() { constructor(bookmark: Bookmark, editPos: Int = -1) : this() {
arguments = Bundle().apply { arguments = Bundle().apply {
@ -30,12 +30,9 @@ class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark) {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
view.setBackgroundResource(R.color.transparent)
view.setOnClickListener { dismiss() }
binding.toolBar.setBackgroundColor(primaryColor) binding.toolBar.setBackgroundColor(primaryColor)
val arguments = arguments ?: let { val arguments = arguments ?: let {
dismiss() dismiss()

@ -21,7 +21,7 @@ import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding 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 { Toolbar.OnMenuItemClickListener {
constructor(id: Long) : this() { constructor(id: Long) : this() {
@ -36,12 +36,9 @@ class HttpTtsEditDialog() : BaseDialogFragment(R.layout.dialog_http_tts_edit),
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
view.setBackgroundResource(R.color.transparent)
view.setOnClickListener { dismiss() }
binding.toolBar.setBackgroundColor(primaryColor) binding.toolBar.setBackgroundColor(primaryColor)
binding.tvUrl.run { binding.tvUrl.run {
addLegadoPattern() addLegadoPattern()

@ -26,7 +26,7 @@ import kotlinx.coroutines.withContext
import splitties.views.onClick 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 binding by viewBinding(DialogLoginBinding::bind)
private val viewModel by activityViewModels<SourceLoginViewModel>() private val viewModel by activityViewModels<SourceLoginViewModel>()
@ -34,12 +34,9 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
view.setBackgroundResource(R.color.transparent)
view.setOnClickListener { dismiss() }
val source = viewModel.source ?: return val source = viewModel.source ?: return
binding.toolBar.setBackgroundColor(primaryColor) binding.toolBar.setBackgroundColor(primaryColor)
binding.toolBar.title = getString(R.string.login_source, source.getTag()) binding.toolBar.title = getString(R.string.login_source, source.getTag())

@ -14,6 +14,7 @@ import io.legado.app.databinding.ItemLogBinding
import io.legado.app.utils.setLayout import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
@Suppress("unused")
class TextListDialog() : BaseDialogFragment(R.layout.dialog_recycler_view) { class TextListDialog() : BaseDialogFragment(R.layout.dialog_recycler_view) {
constructor(title: String, values: ArrayList<String>) : this() { constructor(title: String, values: ArrayList<String>) : this() {

@ -24,9 +24,8 @@ class UrlOptionDialog(context: Context, private val success: (String) -> Unit) :
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(binding.root) setContentView(binding.root)
binding.root.setOnClickListener { binding.root.setOnClickListener { dismiss() }
dismiss() binding.vwBg.setOnClickListener(null)
}
binding.editMethod.setFilterValues("POST", "GET") binding.editMethod.setFilterValues("POST", "GET")
binding.editCharset.setFilterValues(AppConst.charsets) binding.editCharset.setFilterValues(AppConst.charsets)
binding.tvOk.setOnClickListener { binding.tvOk.setOnClickListener {

Loading…
Cancel
Save