From 161f928463d8702672d2f7937ef83e67484e9725 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 28 Feb 2022 22:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/changecover/ChangeCoverDialog.kt | 2 +- .../ui/book/changesource/ChangeBookSourceDialog.kt | 2 +- .../book/changesource/ChangeChapterSourceDialog.kt | 2 +- .../io/legado/app/ui/book/group/GroupEditDialog.kt | 5 +---- .../java/io/legado/app/ui/book/read/PhotoDialog.kt | 10 ++++------ .../app/ui/book/read/config/AutoReadDialog.kt | 14 +++++++------- .../app/ui/book/read/config/BgTextConfigDialog.kt | 14 +++++++------- .../ui/book/read/config/ClickActionConfigDialog.kt | 6 +++--- .../app/ui/book/read/config/MoreConfigDialog.kt | 14 +++++++------- .../ui/book/read/config/ReadAloudConfigDialog.kt | 8 +++----- .../app/ui/book/read/config/ReadAloudDialog.kt | 14 +++++++------- .../app/ui/book/read/config/ReadStyleDialog.kt | 14 +++++++------- .../io/legado/app/ui/book/toc/BookmarkDialog.kt | 5 +---- .../io/legado/app/ui/config/CheckSourceConfig.kt | 5 +---- .../legado/app/ui/config/DirectLinkUploadConfig.kt | 5 +---- .../io/legado/app/ui/login/SourceLoginDialog.kt | 5 +---- .../app/ui/widget/prefs/IconListPreference.kt | 5 +---- 17 files changed, 54 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt index 8c3f60e64..c15c07e8e 100644 --- a/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt @@ -42,7 +42,7 @@ class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover), override fun onStart() { super.onStart() - setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 0.96f) + setLayout(0.98f, ViewGroup.LayoutParams.MATCH_PARENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt index c857838b4..8911be760 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt @@ -57,7 +57,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_ override fun onStart() { super.onStart() - setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 0.96f) + setLayout(0.98f, ViewGroup.LayoutParams.MATCH_PARENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt index c18323129..7b2a1f3d5 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt @@ -81,7 +81,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c override fun onStart() { super.onStart() - setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 0.96f) + setLayout(0.98f, ViewGroup.LayoutParams.MATCH_PARENT) dialog?.setOnKeyListener(this) } diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt index 50df3f2a1..34afb7c16 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupEditDialog.kt @@ -36,10 +36,7 @@ class GroupEditDialog() : BaseDialogFragment(R.layout.dialog_book_group_edit) { override fun onStart() { super.onStart() - setLayout( - 0.9f, - ViewGroup.LayoutParams.WRAP_CONTENT - ) + setLayout(0.9f, ViewGroup.LayoutParams.WRAP_CONTENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt index c3c8678e8..a2a8bcab0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt @@ -2,7 +2,6 @@ package io.legado.app.ui.book.read import android.os.Bundle import android.view.View -import android.view.ViewGroup import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.databinding.DialogPhotoViewBinding @@ -11,7 +10,9 @@ import io.legado.app.ui.book.read.page.provider.ImageProvider import io.legado.app.utils.setLayout import io.legado.app.utils.viewbindingdelegate.viewBinding - +/** + * 显示图片 + */ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { constructor(chapterIndex: Int, src: String) : this() { @@ -25,10 +26,7 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { override fun onStart() { super.onStart() - setLayout( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT - ) + setLayout(0.98f, 0.98f) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt index 13656f015..e3f631439 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt @@ -30,15 +30,15 @@ class AutoReadDialog : BaseDialogFragment(R.layout.dialog_auto_read) { override fun onStart() { super.onStart() - dialog?.window?.let { - it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) - it.setBackgroundDrawableResource(R.color.background) - it.decorView.setPadding(0, 0, 0, 0) - val attr = it.attributes + dialog?.window?.run { + clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + setBackgroundDrawableResource(R.color.background) + decorView.setPadding(0, 0, 0, 0) + val attr = attributes attr.dimAmount = 0.0f attr.gravity = Gravity.BOTTOM - it.attributes = attr - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + attributes = attr + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index f3cbd8976..c41a31bac 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -71,15 +71,15 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) { override fun onStart() { super.onStart() - dialog?.window?.let { - it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) - it.setBackgroundDrawableResource(R.color.background) - it.decorView.setPadding(0, 0, 0, 0) - val attr = it.attributes + dialog?.window?.run { + clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + setBackgroundDrawableResource(R.color.background) + decorView.setPadding(0, 0, 0, 0) + val attr = attributes attr.dimAmount = 0.0f attr.gravity = Gravity.BOTTOM - it.attributes = attr - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + attributes = attr + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt index fe492cac0..4c700d5e3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt @@ -34,9 +34,9 @@ class ClickActionConfigDialog : BaseDialogFragment(R.layout.dialog_click_action_ override fun onStart() { super.onStart() - dialog?.window?.let { - it.setBackgroundDrawableResource(R.color.transparent) - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) + dialog?.window?.run { + setBackgroundDrawableResource(R.color.transparent) + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 362fe5524..9e3118d1f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -28,15 +28,15 @@ class MoreConfigDialog : DialogFragment() { override fun onStart() { super.onStart() - dialog?.window?.let { - it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) - it.setBackgroundDrawableResource(R.color.background) - it.decorView.setPadding(0, 0, 0, 0) - val attr = it.attributes + dialog?.window?.run { + clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + setBackgroundDrawableResource(R.color.background) + decorView.setPadding(0, 0, 0, 0) + val attr = attributes attr.dimAmount = 0.0f attr.gravity = Gravity.BOTTOM - it.attributes = attr - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 360.dp) + attributes = attr + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 360.dp) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt index a1d78afc4..b7d67ee56 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt @@ -14,7 +14,6 @@ import io.legado.app.base.BasePreferenceFragment import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.appDb -import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.SelectItem import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.primaryColor @@ -27,10 +26,9 @@ class ReadAloudConfigDialog : DialogFragment() { override fun onStart() { super.onStart() - val dm = requireActivity().windowSize - dialog?.window?.let { - it.setBackgroundDrawableResource(R.color.transparent) - it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) + dialog?.window?.run { + setBackgroundDrawableResource(R.color.transparent) + setLayout(0.9f, ViewGroup.LayoutParams.WRAP_CONTENT) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index 39911df6b..4ed564bd6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -32,15 +32,15 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) { override fun onStart() { super.onStart() - dialog?.window?.let { - it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) - it.setBackgroundDrawableResource(R.color.background) - it.decorView.setPadding(0, 0, 0, 0) - val attr = it.attributes + dialog?.window?.run { + clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + setBackgroundDrawableResource(R.color.background) + decorView.setPadding(0, 0, 0, 0) + val attr = attributes attr.dimAmount = 0.0f attr.gravity = Gravity.BOTTOM - it.attributes = attr - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + attributes = attr + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 768dc3ef1..a993c3840 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -35,15 +35,15 @@ class ReadStyleDialog : BaseDialogFragment(R.layout.dialog_read_book_style), override fun onStart() { super.onStart() - dialog?.window?.let { - it.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) - it.setBackgroundDrawableResource(R.color.background) - it.decorView.setPadding(0, 0, 0, 0) - val attr = it.attributes + dialog?.window?.run { + clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + setBackgroundDrawableResource(R.color.background) + decorView.setPadding(0, 0, 0, 0) + val attr = attributes attr.dimAmount = 0.0f attr.gravity = Gravity.BOTTOM - it.attributes = attr - it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + attributes = attr + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } } diff --git a/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt b/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt index de9a31ff9..3452c4c7e 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt @@ -27,10 +27,7 @@ class BookmarkDialog() : BaseDialogFragment(R.layout.dialog_bookmark) { override fun onStart() { super.onStart() - setLayout( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ) + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt b/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt index af994bac0..b0c9254a3 100644 --- a/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt +++ b/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt @@ -23,10 +23,7 @@ class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config override fun onStart() { super.onStart() - setLayout( - 0.9f, - ViewGroup.LayoutParams.WRAP_CONTENT - ) + setLayout(0.9f, ViewGroup.LayoutParams.WRAP_CONTENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/ui/config/DirectLinkUploadConfig.kt b/app/src/main/java/io/legado/app/ui/config/DirectLinkUploadConfig.kt index 0e7359bd0..72fe9699b 100644 --- a/app/src/main/java/io/legado/app/ui/config/DirectLinkUploadConfig.kt +++ b/app/src/main/java/io/legado/app/ui/config/DirectLinkUploadConfig.kt @@ -19,10 +19,7 @@ class DirectLinkUploadConfig : BaseDialogFragment(R.layout.dialog_direct_link_up override fun onStart() { super.onStart() - setLayout( - 0.9f, - ViewGroup.LayoutParams.WRAP_CONTENT - ) + setLayout(0.9f, ViewGroup.LayoutParams.WRAP_CONTENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { 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 ef1ccab10..2acd49aa0 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 @@ -33,10 +33,7 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) { override fun onStart() { super.onStart() - setLayout( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ) + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index 7bfbe4c47..de1718472 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -130,10 +130,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference override fun onStart() { super.onStart() - setLayout( - 0.8f, - ViewGroup.LayoutParams.WRAP_CONTENT - ) + setLayout(0.8f, ViewGroup.LayoutParams.WRAP_CONTENT) } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {