优化导航栏

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
var versionCode = 0
var versionName = ""
var navigationBarHeight = 0
}
override fun onCreate() {

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

@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable
import android.widget.FrameLayout
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseActivity
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) {
super.onSizeChanged(w, h, oldw, oldh)
upStyle()
}
fun upStyle() {
ReadBookConfig.apply {
bv_header_left.typeface = ChapterProvider.typeface
tv_header_left.typeface = ChapterProvider.typeface
tv_header_middle.typeface = ChapterProvider.typeface
tv_header_right.typeface = ChapterProvider.typeface
bv_footer_left.typeface = ChapterProvider.typeface
tv_footer_left.typeface = ChapterProvider.typeface
tv_footer_middle.typeface = ChapterProvider.typeface
tv_footer_right.typeface = ChapterProvider.typeface
bv_header_left.setColor(textColor)
tv_header_left.setColor(textColor)
tv_header_middle.setColor(textColor)
tv_header_right.setColor(textColor)
bv_footer_left.setColor(textColor)
tv_footer_left.setColor(textColor)
tv_footer_middle.setColor(textColor)
tv_footer_right.setColor(textColor)
upStatusBar()
ll_header.setPadding(
headerPaddingLeft.dp,
headerPaddingTop.dp,
headerPaddingRight.dp,
headerPaddingBottom.dp
)
ll_footer.setPadding(
footerPaddingLeft.dp,
footerPaddingTop.dp,
footerPaddingRight.dp,
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()
fun upStyle() = ReadBookConfig.apply {
bv_header_left.typeface = ChapterProvider.typeface
tv_header_left.typeface = ChapterProvider.typeface
tv_header_middle.typeface = ChapterProvider.typeface
tv_header_right.typeface = ChapterProvider.typeface
bv_footer_left.typeface = ChapterProvider.typeface
tv_footer_left.typeface = ChapterProvider.typeface
tv_footer_middle.typeface = ChapterProvider.typeface
tv_footer_right.typeface = ChapterProvider.typeface
bv_header_left.setColor(textColor)
tv_header_left.setColor(textColor)
tv_header_middle.setColor(textColor)
tv_header_right.setColor(textColor)
bv_footer_left.setColor(textColor)
tv_footer_left.setColor(textColor)
tv_footer_middle.setColor(textColor)
tv_footer_right.setColor(textColor)
upStatusBar()
ll_header.setPadding(
headerPaddingLeft.dp,
headerPaddingTop.dp,
headerPaddingRight.dp,
headerPaddingBottom.dp
)
ll_footer.setPadding(
footerPaddingLeft.dp,
footerPaddingTop.dp,
footerPaddingRight.dp,
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 App.navigationBarHeight
}
content_text_view.upVisibleRect()
upTime()
upBattery(battery)
}

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

Loading…
Cancel
Save