优化分屏模式

pull/368/head
gedoor 4 years ago
parent 022c1e29b7
commit 7225449c41
  1. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt
  3. 20
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  4. 8
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -125,6 +125,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
page_view.upStatusBar()
ReadBook.loadContent(resetPageOffset = false)
}

@ -10,7 +10,6 @@ import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.EventBus
import io.legado.app.help.ReadTipConfig
import io.legado.app.lib.dialogs.selector
import io.legado.app.ui.book.read.ReadBookActivityHelp
import io.legado.app.utils.postEvent
import kotlinx.android.synthetic.main.dialog_tip_config.*
import org.jetbrains.anko.sdk27.listeners.onCheckedChange
@ -24,11 +23,8 @@ class TipConfigDialog : BaseDialogFragment() {
activity?.let {
it.windowManager?.defaultDisplay?.getMetrics(dm)
}
dialog?.window?.let {
ReadBookActivityHelp.upSystemUiVisibility(it)
it.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
}
dialog?.window
?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
}
override fun onCreateView(

@ -7,17 +7,16 @@ import android.widget.FrameLayout
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.constant.AppConst.timeFormat
import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig
import io.legado.app.ui.book.read.page.entities.TextPage
import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.widget.BatteryView
import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.statusBarHeight
import io.legado.app.utils.visible
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.view_book_page.view.*
import org.jetbrains.anko.topPadding
import java.util.*
@ -65,9 +64,7 @@ class ContentView(context: Context) : FrameLayout(context) {
tv_footer_left.setColor(textColor)
tv_footer_middle.setColor(textColor)
tv_footer_right.setColor(textColor)
//显示状态栏时隐藏header
vw_status_bar.setPadding(0, context.statusBarHeight, 0, 0)
vw_status_bar.isGone = hideStatusBar
upStatusBar()
ll_header.setPadding(
headerPaddingLeft.dp,
headerPaddingTop.dp,
@ -88,6 +85,15 @@ class ContentView(context: Context) : FrameLayout(context) {
upBattery(battery)
}
/**
* 显示状态栏时隐藏header
*/
fun upStatusBar() {
vw_status_bar.topPadding = context.statusBarHeight
vw_status_bar.isGone =
ReadBookConfig.hideStatusBar || (activity as? BaseActivity)?.isInMultiWindow == true
}
fun upTipStyle() {
ReadTipConfig.apply {
tv_header_left.isInvisible = tipHeaderLeft != chapterTitle

@ -85,9 +85,9 @@ class PageView(context: Context, attrs: AttributeSet) :
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
centerRectF.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
prevPage.x = -w.toFloat()
pageDelegate?.setViewSize(w, h)
centerRectF.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
if (oldw != 0 && oldh != 0) {
ReadBook.loadContent(resetPageOffset = false)
}
@ -180,6 +180,12 @@ class PageView(context: Context, attrs: AttributeSet) :
return true
}
fun upStatusBar() {
curPage.upStatusBar()
prevPage.upStatusBar()
nextPage.upStatusBar()
}
/**
* 保存开始位置
*/

Loading…
Cancel
Save