From e42dc586564b52788e6b7a58a61c518d10cd013c Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 24 Aug 2019 08:04:44 +0800 Subject: [PATCH] up --- .../app/ui/readbook/ReadBookActivity.kt | 28 ++++++++++--------- .../io/legado/app/ui/readbook/ReadMenu.kt | 20 ++++++++----- .../readbook/config/ReadPreferenceFragment.kt | 6 ++-- .../app/ui/readbook/config/ReadStyleDialog.kt | 10 +++---- app/src/main/res/layout/view_read_menu.xml | 1 - 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 65dfd1481..a0582c6ea 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -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(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(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(R.layout.activity_rea observeEvent(Bus.BATTERY_CHANGED) { page_view.upBattery(it) } observeEvent(Bus.OPEN_CHAPTER) { viewModel.openChapter(it) } observeEventSticky(Bus.READ_ALOUD) { onClickReadAloud() } - observeEventSticky(Bus.UP_CONFIG) { - when (it) { - 0 -> { - page_view.upBg() - content_view.upStyle() - page_view.upStyle() - } - 1 -> { - content_view.upStyle() - page_view.upStyle() - } - } + observeEvent(Bus.UP_CONFIG) { + upBar() + page_view.upBg() + content_view.upStyle() + page_view.upStyle() } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt index 94db4efc8..da1ce7511 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt @@ -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() } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadPreferenceFragment.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadPreferenceFragment.kt index f66d7e222..47b27bf33 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadPreferenceFragment.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadPreferenceFragment.kt @@ -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) } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index 6f6611f93..530fa4a8a 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -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) } } diff --git a/app/src/main/res/layout/view_read_menu.xml b/app/src/main/res/layout/view_read_menu.xml index b1f3ea57b..515353389 100644 --- a/app/src/main/res/layout/view_read_menu.xml +++ b/app/src/main/res/layout/view_read_menu.xml @@ -154,7 +154,6 @@ android:layout_height="match_parent" />