feat: 优化代码

pull/198/head
kunfei 5 years ago
parent ae1df73133
commit e9ce662725
  1. 3
      app/src/main/java/io/legado/app/help/AppConfig.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/Help.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  4. 4
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  5. 1
      app/src/main/res/values/strings.xml
  6. 6
      app/src/main/res/xml/pref_config_read.xml

@ -121,6 +121,9 @@ object AppConfig {
App.INSTANCE.putPrefInt("elevation", value)
}
val readBodyToLh: Boolean get() = App.INSTANCE.getPrefBoolean("readBodyToLh", true)
val isGooglePlay: Boolean get() = App.INSTANCE.channel == "google"
}
val Context.channel: String

@ -112,7 +112,7 @@ object Help {
* 适配刘海
*/
fun upLayoutInDisplayCutoutMode(window: Window) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && AppConfig.readBodyToLh) {
window.attributes = window.attributes.apply {
layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES

@ -41,9 +41,6 @@ class ContentView(context: Context) : FrameLayout(context) {
battery_view.typeface = ChapterProvider.typeface
//显示状态栏时隐藏header
if (hideStatusBar) {
ll_header.layoutParams = ll_header.layoutParams.apply {
height = context.statusBarHeight + headerPaddingTop.dp + headerPaddingBottom.dp
}
ll_header.setPadding(
headerPaddingLeft.dp,
headerPaddingTop.dp,

@ -13,7 +13,7 @@ import io.legado.app.R
import io.legado.app.base.BaseFragment
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.channel
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.ATH
import io.legado.app.service.WebService
import io.legado.app.ui.about.AboutActivity
@ -85,7 +85,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
true
}
}
if (requireContext().channel == "google") {
if (AppConfig.isGooglePlay) {
findPreference<PreferenceCategory>("aboutCategory")
?.removePreference(findPreference("donate"))
}

@ -646,4 +646,5 @@
<string name="request_permission">点击授予权限</string>
<string name="tip_local_perm_request_storage">阅读需要访问存储卡权限,请点击下方的"授予权限"按钮,或前往“设置”—“应用权限”—打开所需权限。如果授予权限后仍然不正常,请点击右上角的“选择文件夹”,使用系统文件夹选择器。</string>
<string name="alouding_disable">全文朗读中不能朗读选中文字</string>
<string name="read_body_to_lh">扩展到刘海</string>
</resources>

@ -24,6 +24,12 @@
android:key="hideStatusBar"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/read_body_to_lh"
android:key="readBodyToLh"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/pt_hide_navigation_bar"

Loading…
Cancel
Save