From 4234de1c32bc947f4699752fff7ff51954584aab Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 13 Dec 2020 18:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/AppConfig.kt | 4 ++-- .../java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt | 2 +- .../io/legado/app/ui/book/read/config/MoreConfigDialog.kt | 4 ++-- app/src/main/java/io/legado/app/utils/ContextExtensions.kt | 3 --- app/src/main/res/values/pref_key_value.xml | 1 - app/src/main/res/xml/pref_config_read.xml | 2 +- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 22a96517a..76a17bca1 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -61,6 +61,7 @@ object PreferKey { const val autoClearExpired = "autoClearExpired" const val autoChangeSource = "autoChangeSource" const val importKeepName = "importKeepName" + const val screenDirection = "screenDirection" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index bf15b1781..d6854a306 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -79,8 +79,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { context.putPrefBoolean(PreferKey.transparentStatusBar, value) } - val requestedDirection: String? - get() = context.getPrefString(R.string.pk_requested_direction) + val screenDirection: String? + get() = context.getPrefString(PreferKey.screenDirection) var backupPath: String? get() = context.getPrefString(PreferKey.backupPath) 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 250a0ff38..22b4c1e80 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 @@ -77,7 +77,7 @@ abstract class ReadBookBaseActivity : */ @SuppressLint("SourceLockedOrientationActivity") fun setOrientation() { - when (AppConfig.requestedDirection) { + when (AppConfig.screenDirection) { "0" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED "1" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT "2" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE 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 897895b09..a23dd1ddc 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 @@ -41,7 +41,7 @@ class MoreConfigDialog : DialogFragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { + ): View { (activity as ReadBookActivity).bottomDialog++ val view = LinearLayout(context) view.setBackgroundColor(requireContext().bottomBackground) @@ -107,7 +107,7 @@ class MoreConfigDialog : DialogFragment() { } PreferKey.keepLight -> postEvent(key, true) PreferKey.textSelectAble -> postEvent(key, getPrefBoolean(key)) - getString(R.string.pk_requested_direction) -> { + PreferKey.screenDirection -> { (activity as? ReadBookActivity)?.setOrientation() } PreferKey.textFullJustify, diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index cd391a0c3..d0f693069 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -53,9 +53,6 @@ fun Context.putPrefLong(key: String, value: Long) = fun Context.getPrefString(key: String, defValue: String? = null) = defaultSharedPreferences.getString(key, defValue) -fun Context.getPrefString(@StringRes keyId: Int, defValue: String? = null) = - defaultSharedPreferences.getString(getString(keyId), defValue) - fun Context.putPrefString(key: String, value: String?) = defaultSharedPreferences.edit { putString(key, value) } diff --git a/app/src/main/res/values/pref_key_value.xml b/app/src/main/res/values/pref_key_value.xml index 266c4cb51..78e9f018d 100644 --- a/app/src/main/res/values/pref_key_value.xml +++ b/app/src/main/res/values/pref_key_value.xml @@ -1,7 +1,6 @@ auto_refresh - list_screen_direction bookshelf_px defaultToRead 开源阅读 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 65b8c94e9..fea7ed25c 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto">