From e9c7bb0f118fb335778e93622a800be499c39c78 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 11 Nov 2020 09:31:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=89=93=E5=BC=80=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B8=AE=E5=8A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/LocalConfig.kt | 23 +++++++++++++++++++ .../app/ui/book/read/ReadBookBaseActivity.kt | 5 ++++ .../io/legado/app/ui/main/MainActivity.kt | 7 +++++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/io/legado/app/help/LocalConfig.kt diff --git a/app/src/main/java/io/legado/app/help/LocalConfig.kt b/app/src/main/java/io/legado/app/help/LocalConfig.kt new file mode 100644 index 000000000..aee7a8665 --- /dev/null +++ b/app/src/main/java/io/legado/app/help/LocalConfig.kt @@ -0,0 +1,23 @@ +package io.legado.app.help + +import android.content.Context +import androidx.core.content.edit +import io.legado.app.App + +object LocalConfig { + + private val localConfig = + App.INSTANCE.getSharedPreferences("local", Context.MODE_PRIVATE) + + var isFirstOpen: Boolean + get() = localConfig.getBoolean("firstOpen", true) + set(value) { + localConfig.edit { putBoolean("firstOpen", value) } + } + + var isFirstRead: Boolean + get() = localConfig.getBoolean("firstRead", true) + set(value) { + localConfig.edit { putBoolean("firstRead", value) } + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt index 47f3ac855..2b5f8c14a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt @@ -18,6 +18,7 @@ import io.legado.app.base.VMBaseActivity import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Bookmark import io.legado.app.help.AppConfig +import io.legado.app.help.LocalConfig import io.legado.app.help.ReadBookConfig import io.legado.app.help.coroutine.Coroutine import io.legado.app.lib.dialogs.* @@ -60,6 +61,10 @@ abstract class ReadBookBaseActivity : override fun onActivityCreated(savedInstanceState: Bundle?) { initView() + if (LocalConfig.isFirstRead) { + showClickRegionalConfig() + LocalConfig.isFirstRead = false + } } /** 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 59a5bd79c..b5d9eb333 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 @@ -17,6 +17,7 @@ import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp +import io.legado.app.help.LocalConfig import io.legado.app.help.storage.Backup import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.elevation @@ -102,7 +103,11 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), private fun upVersion() { if (getPrefInt(PreferKey.versionCode) != App.versionCode) { putPrefInt(PreferKey.versionCode, App.versionCode) - if (!BuildConfig.DEBUG) { + if (LocalConfig.isFirstOpen) { + val text = String(assets.open("help/help.md").readBytes()) + TextDialog.show(supportFragmentManager, text, TextDialog.MD) + LocalConfig.isFirstOpen = false + } else if (!BuildConfig.DEBUG) { val log = String(assets.open("updateLog.md").readBytes()) TextDialog.show(supportFragmentManager, log, TextDialog.MD, 5000, true) }