pull/32/head
kunfei 5 years ago
parent 2f68219359
commit fb76647362
  1. 77
      app/src/main/java/io/legado/app/ui/readbook/ReadBottomMenu.kt
  2. 44
      app/src/main/res/layout/view_read_bottom_menu.xml

@ -6,8 +6,7 @@ import android.widget.FrameLayout
import android.widget.SeekBar
import io.legado.app.R
import io.legado.app.service.ReadAloudService
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import io.legado.app.utils.isNightTheme
import kotlinx.android.synthetic.main.view_read_bottom_menu.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.sdk27.listeners.onLongClick
@ -16,42 +15,37 @@ class ReadBottomMenu : FrameLayout {
private var callback: Callback? = null
val readProgress: SeekBar
get() = hpb_read_progress
constructor(context: Context) : super(context)
constructor(context: Context) : super(context) {
init(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
private fun init(context: Context) {
init {
inflate(context, R.layout.view_read_bottom_menu, this)
if (context.isNightTheme) {
fabNightTheme.setImageResource(R.drawable.ic_daytime)
} else {
fabNightTheme.setImageResource(R.drawable.ic_brightness)
}
vw_bg.onClick { }
vwNavigationBar.onClick { }
}
fun setNavigationBarHeight(height: Int) {
vwNavigationBar.layoutParams.height = height
}
fun setListener(callback: Callback) {
this.callback = callback
bindEvent()
}
private fun bindEvent() {
ll_read_aloud_timer.onClick { callback?.dismiss() }
ll_floating_button.onClick { callback?.dismiss() }
//阅读进度
hpb_read_progress.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
seek_bar_read_page.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) {
}
@ -65,9 +59,6 @@ class ReadBottomMenu : FrameLayout {
}
})
//朗读定时
fab_read_aloud_timer.onClick { }
//朗读
fab_read_aloud.onClick { callback?.clickReadAloud() }
//长按停止朗读
@ -102,36 +93,6 @@ class ReadBottomMenu : FrameLayout {
//设置
ll_setting.onClick { callback?.showMoreSetting() }
tv_read_aloud_timer.onClick { }
}
fun setFabReadAloudImage(id: Int) {
fab_read_aloud.setImageResource(id)
}
fun setReadAloudTimer(visibility: Boolean) {
if (visibility) {
ll_read_aloud_timer.visible()
} else {
ll_read_aloud_timer.gone()
}
}
fun setReadAloudTimer(text: String) {
tv_read_aloud_timer.text = text
}
fun setFabReadAloudText(text: String) {
fab_read_aloud.contentDescription = text
}
fun setTvPre(enable: Boolean) {
tv_pre.isEnabled = enable
}
fun setTvNext(enable: Boolean) {
tv_next.isEnabled = enable
}
fun setAutoPage(autoPage: Boolean) {
@ -144,14 +105,6 @@ class ReadBottomMenu : FrameLayout {
}
}
fun setFabNightTheme(isNightTheme: Boolean) {
if (isNightTheme) {
fabNightTheme.setImageResource(R.drawable.ic_daytime)
} else {
fabNightTheme.setImageResource(R.drawable.ic_brightness)
}
}
interface Callback {
fun skipToPage(page: Int)

@ -6,48 +6,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_read_aloud_timer"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:visibility="gone">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_read_aloud_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:contentDescription="@string/set_timer"
android:src="@drawable/ic_timer_black_24dp"
android:tint="@color/tv_text_default"
android:tooltipText="@string/set_timer"
app:backgroundTint="@color/background_menu"
app:elevation="2dp"
app:fabSize="mini"
app:pressedTranslationZ="2dp"
tools:ignore="UnusedAttribute" />
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:cardBackgroundColor="@color/background_card">
<TextView
android:id="@+id/tv_read_aloud_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="10dp"
android:text="@string/read_aloud_timer" />
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_floating_button"
android:layout_width="match_parent"
@ -178,7 +136,7 @@
android:textSize="14sp" />
<io.legado.app.lib.theme.view.ATESeekBar
android:id="@+id/hpb_read_progress"
android:id="@+id/seek_bar_read_page"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"

Loading…
Cancel
Save