diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATESeekBar.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATESeekBar.kt index 4a49b34f3..e6725c42a 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATESeekBar.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATESeekBar.kt @@ -4,26 +4,24 @@ import android.content.Context import android.util.AttributeSet import androidx.appcompat.widget.AppCompatSeekBar 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) */ class ATESeekBar : AppCompatSeekBar { - constructor(context: Context) : super(context) { - init(context, null) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context, attrs: AttributeSet?) { - ATH.setTint(this, ThemeStore.accentColor(context)) + init { + ATH.setTint(this, context.accentColor) } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index e06c287f2..9c4c7c505 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -16,11 +16,13 @@ import io.legado.app.constant.Bus import io.legado.app.constant.Status import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.help.IntentDataHelp import io.legado.app.receiver.TimeElectricityReceiver import io.legado.app.service.ReadAloudService import io.legado.app.ui.changesource.ChangeSourceDialog import io.legado.app.ui.chapterlist.ChapterListActivity 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.replacerule.ReplaceRuleActivity import io.legado.app.ui.sourceedit.SourceEditActivity @@ -141,6 +143,14 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea MoreConfigDialog().show(supportFragmentManager, "moreConfig") } + override fun showReadAloud(): Boolean { + if (readAloudStatus == Status.STOP) { + return false + } + ReadAloudDialog().show(supportFragmentManager, "readAloud") + return true + } + override fun menuShow() { Help.upSystemUiVisibility(window, !read_menu.isVisible) } @@ -297,12 +307,14 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea val book = viewModel.bookData.value val textChapter = viewModel.curTextChapter if (book != null && textChapter != null) { + val key = System.currentTimeMillis().toString() + IntentDataHelp.putData(key, textChapter) ReadAloudService.play( this, book.name, textChapter.title, textChapter.getReadLength(viewModel.durPageIndex), - System.currentTimeMillis().toString() + key ) } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt index 81bdb2616..4b09ceb25 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt @@ -67,11 +67,13 @@ class ReadMenu : FrameLayout { } fun runMenuIn() { - this.visible() - title_bar.visible() - bottom_menu.visible() - title_bar.startAnimation(menuTopIn) - bottom_menu.startAnimation(menuBottomIn) + if (callback?.showReadAloud() != true) { + this.visible() + title_bar.visible() + bottom_menu.visible() + title_bar.startAnimation(menuTopIn) + bottom_menu.startAnimation(menuBottomIn) + } } fun runMenuOut(onMenuOutEnd: (() -> Unit)? = null) { @@ -239,6 +241,7 @@ class ReadMenu : FrameLayout { fun openChapterList() fun showReadStyle() fun showMoreSetting() + fun showReadAloud(): Boolean fun menuShow() fun menuHide() } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index f3f81f433..6579fbf65 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -20,7 +20,11 @@ import org.jetbrains.anko.sdk27.listeners.onClick 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) }