优化导航栏

pull/487/head^2
gedoor 4 years ago
parent 926f7dfedb
commit 94496e2a54
  1. 1
      app/src/main/java/io/legado/app/App.kt
  2. 8
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  3. 78
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -34,6 +34,7 @@ class App : MultiDexApplication() {
lateinit var androidId: String lateinit var androidId: String
var versionCode = 0 var versionCode = 0
var versionName = "" var versionName = ""
var navigationBarHeight = 0
} }
override fun onCreate() { override fun onCreate() {

@ -10,6 +10,7 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.Theme import io.legado.app.constant.Theme
@ -71,6 +72,13 @@ abstract class BaseActivity(
observeLiveBus() observeLiveBus()
} }
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
App.navigationBarHeight = navigationBarHeight
}
}
override fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration?) { override fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration?) {
super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig) super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig)
findViewById<TitleBar>(R.id.title_bar) findViewById<TitleBar>(R.id.title_bar)

@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseActivity import io.legado.app.base.BaseActivity
import io.legado.app.constant.AppConst.timeFormat import io.legado.app.constant.AppConst.timeFormat
@ -51,49 +52,42 @@ class ContentView(context: Context) : FrameLayout(context) {
} }
} }
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { fun upStyle() = ReadBookConfig.apply {
super.onSizeChanged(w, h, oldw, oldh) bv_header_left.typeface = ChapterProvider.typeface
upStyle() tv_header_left.typeface = ChapterProvider.typeface
} tv_header_middle.typeface = ChapterProvider.typeface
tv_header_right.typeface = ChapterProvider.typeface
fun upStyle() { bv_footer_left.typeface = ChapterProvider.typeface
ReadBookConfig.apply { tv_footer_left.typeface = ChapterProvider.typeface
bv_header_left.typeface = ChapterProvider.typeface tv_footer_middle.typeface = ChapterProvider.typeface
tv_header_left.typeface = ChapterProvider.typeface tv_footer_right.typeface = ChapterProvider.typeface
tv_header_middle.typeface = ChapterProvider.typeface bv_header_left.setColor(textColor)
tv_header_right.typeface = ChapterProvider.typeface tv_header_left.setColor(textColor)
bv_footer_left.typeface = ChapterProvider.typeface tv_header_middle.setColor(textColor)
tv_footer_left.typeface = ChapterProvider.typeface tv_header_right.setColor(textColor)
tv_footer_middle.typeface = ChapterProvider.typeface bv_footer_left.setColor(textColor)
tv_footer_right.typeface = ChapterProvider.typeface tv_footer_left.setColor(textColor)
bv_header_left.setColor(textColor) tv_footer_middle.setColor(textColor)
tv_header_left.setColor(textColor) tv_footer_right.setColor(textColor)
tv_header_middle.setColor(textColor) upStatusBar()
tv_header_right.setColor(textColor) ll_header.setPadding(
bv_footer_left.setColor(textColor) headerPaddingLeft.dp,
tv_footer_left.setColor(textColor) headerPaddingTop.dp,
tv_footer_middle.setColor(textColor) headerPaddingRight.dp,
tv_footer_right.setColor(textColor) headerPaddingBottom.dp
upStatusBar() )
ll_header.setPadding( ll_footer.setPadding(
headerPaddingLeft.dp, footerPaddingLeft.dp,
headerPaddingTop.dp, footerPaddingTop.dp,
headerPaddingRight.dp, footerPaddingRight.dp,
headerPaddingBottom.dp footerPaddingBottom.dp
) )
ll_footer.setPadding( vw_top_divider.visible(showHeaderLine)
footerPaddingLeft.dp, vw_bottom_divider.visible(showFooterLine)
footerPaddingTop.dp, page_nv_bar.layoutParams = page_nv_bar.layoutParams.apply {
footerPaddingRight.dp, height = if (hideNavigationBar) 0 else App.navigationBarHeight
footerPaddingBottom.dp
)
vw_top_divider.visible(showHeaderLine)
vw_bottom_divider.visible(showFooterLine)
page_nv_bar.layoutParams = page_nv_bar.layoutParams.apply {
height = if (hideNavigationBar) 0 else activity!!.navigationBarHeight
}
content_text_view.upVisibleRect()
} }
content_text_view.upVisibleRect()
upTime() upTime()
upBattery(battery) upBattery(battery)
} }

@ -112,7 +112,7 @@ class PageView(context: Context, attrs: AttributeSet) :
brRect.set(width * 0.66f, height * 0.66f, width - 10f, height - 10f) brRect.set(width * 0.66f, height * 0.66f, width - 10f, height - 10f)
prevPage.x = -w.toFloat() prevPage.x = -w.toFloat()
pageDelegate?.setViewSize(w, h) pageDelegate?.setViewSize(w, h)
if (oldw != 0 && oldh != 0) { if (w != 0 && h != 0) {
ReadBook.loadContent(resetPageOffset = false) ReadBook.loadContent(resetPageOffset = false)
} }
} }

Loading…
Cancel
Save