pull/32/head
kunfei 5 years ago
parent c406f5592e
commit e42dc58656
  1. 28
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 20
      app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt
  3. 6
      app/src/main/java/io/legado/app/ui/readbook/config/ReadPreferenceFragment.kt
  4. 10
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt
  5. 1
      app/src/main/res/layout/view_read_menu.xml

@ -5,6 +5,7 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.*
import androidx.core.view.isVisible
import androidx.lifecycle.Observer
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -130,6 +131,14 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
override fun showMoreSetting() {
MoreConfigDialog().show(supportFragmentManager, "moreConfig")
}
override fun menuShow() {
upBar()
}
override fun menuHide() {
upBar()
}
})
}
@ -280,7 +289,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
if (getPrefBoolean("hideNavigationBar")) {
flag = flag or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
if (!read_menu.menuBarShow) {
if (!read_menu.isVisible) {
if (getPrefBoolean("hideStatusBar")) {
flag = flag or View.SYSTEM_UI_FLAG_FULLSCREEN
}
@ -308,18 +317,11 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
observeEvent<Int>(Bus.BATTERY_CHANGED) { page_view.upBattery(it) }
observeEvent<BookChapter>(Bus.OPEN_CHAPTER) { viewModel.openChapter(it) }
observeEventSticky<Boolean>(Bus.READ_ALOUD) { onClickReadAloud() }
observeEventSticky<Int>(Bus.UP_CONFIG) {
when (it) {
0 -> {
page_view.upBg()
content_view.upStyle()
page_view.upStyle()
}
1 -> {
content_view.upStyle()
page_view.upStyle()
}
}
observeEvent<Boolean>(Bus.UP_CONFIG) {
upBar()
page_view.upBg()
content_view.upStyle()
page_view.upStyle()
}
}

@ -77,10 +77,8 @@ class ReadMenu : FrameLayout {
fun runMenuOut(onMenuOutEnd: (() -> Unit)? = null) {
this.onMenuOutEnd = onMenuOutEnd
if (this.isVisible) {
if (bottom_menu.isVisible) {
title_bar.startAnimation(menuTopOut)
bottom_menu.startAnimation(menuBottomOut)
}
title_bar.startAnimation(menuTopOut)
bottom_menu.startAnimation(menuBottomOut)
}
}
@ -176,13 +174,18 @@ class ReadMenu : FrameLayout {
private fun initAnimation() {
menuTopIn = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_top_in)
menuBottomIn = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_bottom_in)
menuBottomIn.setAnimationListener(object : Animation.AnimationListener {
menuTopIn.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
callback?.menuShow()
}
override fun onAnimationEnd(animation: Animation) {
vw_menu_bg.onClick { runMenuOut() }
if (context.getPrefBoolean("hideNavigationBar")) {
vwNavigationBar.layoutParams.height = context.getNavigationBarHeight()
} else {
vwNavigationBar.layoutParams.height = 0
}
}
override fun onAnimationRepeat(animation: Animation) {
@ -193,7 +196,7 @@ class ReadMenu : FrameLayout {
//隐藏菜单
menuTopOut = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_top_out)
menuBottomOut = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_bottom_out)
menuBottomOut.setAnimationListener(object : Animation.AnimationListener {
menuTopOut.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
vw_menu_bg.setOnClickListener(null)
}
@ -204,6 +207,7 @@ class ReadMenu : FrameLayout {
bottom_menu.invisible()
menuBarShow = false
onMenuOutEnd?.invoke()
callback?.menuHide()
}
override fun onAnimationRepeat(animation: Animation) {
@ -232,6 +236,8 @@ class ReadMenu : FrameLayout {
fun openChapterList()
fun showReadStyle()
fun showMoreSetting()
fun menuShow()
fun menuHide()
}
}

@ -5,7 +5,9 @@ import android.os.Bundle
import android.view.View
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R
import io.legado.app.constant.Bus
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.postEvent
class ReadPreferenceFragment : PreferenceFragmentCompat(),
SharedPreferences.OnSharedPreferenceChangeListener {
@ -31,8 +33,8 @@ class ReadPreferenceFragment : PreferenceFragmentCompat(),
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
when (key) {
"hideStatusBar" -> {
}
"hideStatusBar" -> postEvent(Bus.UP_CONFIG, true)
"hideNavigationBar" -> postEvent(Bus.UP_CONFIG, true)
}
}

@ -55,31 +55,31 @@ class ReadStyleDialog : DialogFragment() {
ReadBookConfig.styleSelect = 0
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
postEvent(Bus.UP_CONFIG, true)
}
tv_bg1.onClick {
ReadBookConfig.styleSelect = 1
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
postEvent(Bus.UP_CONFIG, true)
}
tv_bg2.onClick {
ReadBookConfig.styleSelect = 2
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
postEvent(Bus.UP_CONFIG, true)
}
tv_bg3.onClick {
ReadBookConfig.styleSelect = 3
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
postEvent(Bus.UP_CONFIG, true)
}
tv_bg4.onClick {
ReadBookConfig.styleSelect = 4
ReadBookConfig.upBg()
upBg()
postEvent(Bus.UP_CONFIG, 0)
postEvent(Bus.UP_CONFIG, true)
}
}

@ -154,7 +154,6 @@
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/llNavigationBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_menu"

Loading…
Cancel
Save