From 9a907f5f1984dcd222675112d813fe55ba4f71a1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 22:20:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=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/AndroidManifest.xml | 1 + .../main/java/io/legado/app/ui/book/read/Help.kt | 13 +++++++++++++ .../io/legado/app/ui/book/read/ReadBookActivity.kt | 5 +++++ .../app/ui/book/read/config/MoreConfigDialog.kt | 5 +++++ .../io/legado/app/ui/config/OtherConfigFragment.kt | 7 ------- app/src/main/res/xml/pref_config_other.xml | 8 -------- app/src/main/res/xml/pref_config_read.xml | 8 ++++++++ 7 files changed, 32 insertions(+), 15 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 67af4688e..543c13f6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -185,6 +185,7 @@ android:launchMode="singleTop" /> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED + "1" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + "2" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE + "3" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR + } + } + + /** * 返回NavigationBar是否存在 * 该方法需要在View完全被绘制出来之后调用,否则判断不了 diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 2ca4555a3..3696ccbab 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -88,6 +88,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo override val pageFactory: TextPageFactory get() = page_view.pageFactory override val headerHeight: Int get() = page_view.curPage.headerHeight + override fun onCreate(savedInstanceState: Bundle?) { + Help.setOrientation(this) + super.onCreate(savedInstanceState) + } + override fun onActivityCreated(savedInstanceState: Bundle?) { Help.upLayoutInDisplayCutoutMode(window) initView() 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 6f472f270..a23725143 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 @@ -104,6 +104,11 @@ class MoreConfigDialog : DialogFragment() { } PreferKey.keepLight -> postEvent(key, true) PreferKey.textSelectAble -> postEvent(key, getPrefBoolean(key)) + getString(R.string.pk_requested_direction) -> { + activity?.let { + Help.setOrientation(it) + } + } } } diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index c6633461a..a010428fd 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -43,10 +43,6 @@ class OtherConfigFragment : PreferenceFragmentCompat(), upPreferenceSummary(getString(R.string.pk_download_path), BookHelp.downloadPath) upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) upPreferenceSummary(PreferKey.webPort, webPort.toString()) - upPreferenceSummary( - getString(R.string.pk_requested_direction), - AppConfig.requestedDirection - ) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -107,9 +103,6 @@ class OtherConfigFragment : PreferenceFragmentCompat(), setProcessTextEnable(it.getBoolean(key, true)) } PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "unused") - getString(R.string.pk_requested_direction) -> { - upPreferenceSummary(key, AppConfig.requestedDirection) - } } } diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 6bf712292..b049bcf22 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -6,14 +6,6 @@ android:title="@string/main_activity" app:iconSpaceReserved="false"> - - + +