pull/32/head
kunfei 5 years ago
parent 213df1e0e2
commit 326bba2303
  1. 20
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 22
      app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt
  3. 2
      app/src/main/res/layout/activity_read_book.xml
  4. 32
      app/src/main/res/layout/view_read_menu.xml

@ -75,7 +75,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
tv_chapter_url.onClick {
}
fl_menu.setListener(object : ReadMenu.Callback {
read_menu.setListener(object : ReadMenu.Callback {
override fun skipToPage(page: Int) {
}
@ -102,10 +102,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
}
override fun openAdjust() {
}
override fun showReadStyle() {
ReadStyleDialog().show(supportFragmentManager, "readStyle")
}
@ -142,12 +138,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
val isDown = action == 0
if (keyCode == KeyEvent.KEYCODE_MENU) {
if (isDown && !fl_menu.menuBarShow) {
fl_menu.runMenuIn()
if (isDown && !read_menu.menuBarShow) {
read_menu.runMenuIn()
return true
}
if (!isDown && !fl_menu.menuBarShow) {
fl_menu.menuBarShow = true
if (!isDown && !read_menu.menuBarShow) {
read_menu.menuBarShow = true
return true
}
}
@ -180,9 +176,11 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
tv_chapter_url.text = bookChapter.url
tv_chapter_url.visible()
}
viewModel.curTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content)
ChapterProvider.getTextChapter(content_text_view, bookChapter, content).let {
viewModel.curTextChapter = it
page_view.chapterLoadFinish()
read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex)
}
}
viewModel.durChapterIndex - 1 -> {
viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content)

@ -108,11 +108,16 @@ class ReadMenu : FrameLayout {
}
}
fun upReadProgress(max: Int, dur: Int) {
seek_read_page.max = max
seek_read_page.progress = dur
}
private fun bindEvent() {
ll_floating_button.onClick { runMenuOut() }
//阅读进度
seek_bar_read_page.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
seek_read_page.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) {
}
@ -126,12 +131,6 @@ class ReadMenu : FrameLayout {
}
})
//朗读
fab_read_aloud.onClick {
postEvent(Bus.READ_ALOUD, true)
runMenuOut()
}
//自动翻页
fabAutoPage.onClick { callback?.autoPage() }
@ -157,8 +156,11 @@ class ReadMenu : FrameLayout {
}
}
//调节
ll_adjust.onClick { callback?.openAdjust() }
//朗读
ll_read_aloud.onClick {
postEvent(Bus.READ_ALOUD, true)
runMenuOut()
}
//界面
ll_font.onClick {
@ -198,8 +200,6 @@ class ReadMenu : FrameLayout {
fun openChapterList()
fun openAdjust()
fun showReadStyle()
fun showMoreSetting()

@ -17,7 +17,7 @@
<io.legado.app.ui.readbook.ReadMenu
android:id="@+id/fl_menu"
android:id="@+id/read_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />

@ -57,26 +57,6 @@
android:paddingStart="32dp"
android:paddingEnd="32dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_read_aloud"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:contentDescription="@string/read_aloud"
android:src="@drawable/ic_read_aloud"
android:tint="@color/tv_text_default"
android:tooltipText="@string/read_aloud"
app:backgroundTint="@color/background_menu"
app:elevation="2dp"
app:fabSize="mini"
app:pressedTranslationZ="2dp"
tools:ignore="UnusedAttribute" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabAutoPage"
android:layout_width="wrap_content"
@ -179,7 +159,7 @@
android:textSize="14sp" />
<io.legado.app.lib.theme.view.ATESeekBar
android:id="@+id/seek_bar_read_page"
android:id="@+id/seek_read_page"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"
@ -250,12 +230,12 @@
android:layout_weight="2" />
<!--调节按钮-->
<LinearLayout
android:id="@+id/ll_adjust"
android:id="@+id/ll_read_aloud"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/adjust"
android:contentDescription="@string/read_aloud"
android:focusable="true"
android:orientation="vertical"
android:paddingBottom="7dp">
@ -264,8 +244,8 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:contentDescription="@string/adjust"
android:src="@drawable/ic_tune"
android:contentDescription="@string/read_aloud"
android:src="@drawable/ic_read_aloud"
app:tint="@color/tv_text_default"
tools:ignore="NestedWeights" />
@ -274,7 +254,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="3dp"
android:text="@string/adjust"
android:text="@string/read_aloud"
android:textColor="@color/tv_text_default"
android:textSize="12sp" />
</LinearLayout>

Loading…
Cancel
Save