diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index a7a2b3209..181ec0330 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -78,7 +78,7 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), putPrefInt(PreferKey.versionCode, App.INSTANCE.versionCode) if (!BuildConfig.DEBUG) { val log = String(assets.open("updateLog.md").readBytes()) - TextDialog.show(supportFragmentManager, log, TextDialog.MD, 5000) + TextDialog.show(supportFragmentManager, log, TextDialog.MD, 5000, true) } } } diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt index 9c1c75d5e..dc6ba868b 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt @@ -23,7 +23,8 @@ class TextDialog : BaseDialogFragment() { fragmentManager: FragmentManager, content: String?, mode: Int = 0, - time: Long = 0 + time: Long = 0, + autoClose: Boolean = false ) { TextDialog().apply { val bundle = Bundle() @@ -32,6 +33,7 @@ class TextDialog : BaseDialogFragment() { bundle.putLong("time", time) arguments = bundle isCancelable = false + this.autoClose = autoClose }.show(fragmentManager, "textDialog") } @@ -39,6 +41,8 @@ class TextDialog : BaseDialogFragment() { private var time = 0L + private var autoClose: Boolean = false + override fun onStart() { super.onStart() val dm = DisplayMetrics() @@ -79,6 +83,7 @@ class TextDialog : BaseDialogFragment() { if (time <= 0) { view.post { dialog?.setCancelable(true) + if (autoClose) dialog?.cancel() } } } @@ -86,6 +91,7 @@ class TextDialog : BaseDialogFragment() { } else { view.post { dialog?.setCancelable(true) + if (autoClose) dialog?.cancel() } } }