pull/32/head
kunfei 5 years ago
parent 820c3b18cd
commit 1cee44e72d
  1. 22
      app/src/main/java/io/legado/app/lib/theme/view/ATESeekBar.kt
  2. 14
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  3. 3
      app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt
  4. 6
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt

@ -4,26 +4,24 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatSeekBar import androidx.appcompat.widget.AppCompatSeekBar
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.accentColor
/** /**
* @author Aidan Follestad (afollestad) * @author Aidan Follestad (afollestad)
*/ */
class ATESeekBar : AppCompatSeekBar { class ATESeekBar : AppCompatSeekBar {
constructor(context: Context) : super(context) { constructor(context: Context) : super(context)
init(context, null)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
init(context, attrs)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
init(context, attrs) context,
} attrs,
defStyleAttr
)
private fun init(context: Context, attrs: AttributeSet?) { init {
ATH.setTint(this, ThemeStore.accentColor(context)) ATH.setTint(this, context.accentColor)
} }
} }

@ -16,11 +16,13 @@ import io.legado.app.constant.Bus
import io.legado.app.constant.Status import io.legado.app.constant.Status
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.help.IntentDataHelp
import io.legado.app.receiver.TimeElectricityReceiver import io.legado.app.receiver.TimeElectricityReceiver
import io.legado.app.service.ReadAloudService import io.legado.app.service.ReadAloudService
import io.legado.app.ui.changesource.ChangeSourceDialog import io.legado.app.ui.changesource.ChangeSourceDialog
import io.legado.app.ui.chapterlist.ChapterListActivity import io.legado.app.ui.chapterlist.ChapterListActivity
import io.legado.app.ui.readbook.config.MoreConfigDialog import io.legado.app.ui.readbook.config.MoreConfigDialog
import io.legado.app.ui.readbook.config.ReadAloudDialog
import io.legado.app.ui.readbook.config.ReadStyleDialog import io.legado.app.ui.readbook.config.ReadStyleDialog
import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.replacerule.ReplaceRuleActivity
import io.legado.app.ui.sourceedit.SourceEditActivity import io.legado.app.ui.sourceedit.SourceEditActivity
@ -141,6 +143,14 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
MoreConfigDialog().show(supportFragmentManager, "moreConfig") MoreConfigDialog().show(supportFragmentManager, "moreConfig")
} }
override fun showReadAloud(): Boolean {
if (readAloudStatus == Status.STOP) {
return false
}
ReadAloudDialog().show(supportFragmentManager, "readAloud")
return true
}
override fun menuShow() { override fun menuShow() {
Help.upSystemUiVisibility(window, !read_menu.isVisible) Help.upSystemUiVisibility(window, !read_menu.isVisible)
} }
@ -297,12 +307,14 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
val book = viewModel.bookData.value val book = viewModel.bookData.value
val textChapter = viewModel.curTextChapter val textChapter = viewModel.curTextChapter
if (book != null && textChapter != null) { if (book != null && textChapter != null) {
val key = System.currentTimeMillis().toString()
IntentDataHelp.putData(key, textChapter)
ReadAloudService.play( ReadAloudService.play(
this, this,
book.name, book.name,
textChapter.title, textChapter.title,
textChapter.getReadLength(viewModel.durPageIndex), textChapter.getReadLength(viewModel.durPageIndex),
System.currentTimeMillis().toString() key
) )
} }
} }

@ -67,12 +67,14 @@ class ReadMenu : FrameLayout {
} }
fun runMenuIn() { fun runMenuIn() {
if (callback?.showReadAloud() != true) {
this.visible() this.visible()
title_bar.visible() title_bar.visible()
bottom_menu.visible() bottom_menu.visible()
title_bar.startAnimation(menuTopIn) title_bar.startAnimation(menuTopIn)
bottom_menu.startAnimation(menuBottomIn) bottom_menu.startAnimation(menuBottomIn)
} }
}
fun runMenuOut(onMenuOutEnd: (() -> Unit)? = null) { fun runMenuOut(onMenuOutEnd: (() -> Unit)? = null) {
this.onMenuOutEnd = onMenuOutEnd this.onMenuOutEnd = onMenuOutEnd
@ -239,6 +241,7 @@ class ReadMenu : FrameLayout {
fun openChapterList() fun openChapterList()
fun showReadStyle() fun showReadStyle()
fun showMoreSetting() fun showMoreSetting()
fun showReadAloud(): Boolean
fun menuShow() fun menuShow()
fun menuHide() fun menuHide()
} }

@ -20,7 +20,11 @@ import org.jetbrains.anko.sdk27.listeners.onClick
class ReadStyleDialog : DialogFragment() { class ReadStyleDialog : DialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.dialog_read_book_style, container) return inflater.inflate(R.layout.dialog_read_book_style, container)
} }

Loading…
Cancel
Save