|
|
@ -63,7 +63,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo |
|
|
|
private val requestCodeChapterList = 568 |
|
|
|
private val requestCodeChapterList = 568 |
|
|
|
private val requestCodeEditSource = 111 |
|
|
|
private val requestCodeEditSource = 111 |
|
|
|
private var timeElectricityReceiver: TimeElectricityReceiver? = null |
|
|
|
private var timeElectricityReceiver: TimeElectricityReceiver? = null |
|
|
|
override var readAloudStatus = Status.STOP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
Help.upLayoutInDisplayCutoutMode(window) |
|
|
|
Help.upLayoutInDisplayCutoutMode(window) |
|
|
@ -215,7 +214,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo |
|
|
|
&& event.isTracking |
|
|
|
&& event.isTracking |
|
|
|
&& !event.isCanceled |
|
|
|
&& !event.isCanceled |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (readAloudStatus == Status.PLAY) { |
|
|
|
if (!BaseReadAloudService.pause) { |
|
|
|
ReadAloud.pause(this) |
|
|
|
ReadAloud.pause(this) |
|
|
|
toast(R.string.read_aloud_pause) |
|
|
|
toast(R.string.read_aloud_pause) |
|
|
|
return true |
|
|
|
return true |
|
|
@ -231,7 +230,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo |
|
|
|
if (!read_menu.isVisible) { |
|
|
|
if (!read_menu.isVisible) { |
|
|
|
if (getPrefBoolean("volumeKeyPage", true)) { |
|
|
|
if (getPrefBoolean("volumeKeyPage", true)) { |
|
|
|
if (getPrefBoolean("volumeKeyPageOnPlay") |
|
|
|
if (getPrefBoolean("volumeKeyPageOnPlay") |
|
|
|
|| readAloudStatus != Status.PLAY |
|
|
|
|| BaseReadAloudService.pause |
|
|
|
) { |
|
|
|
) { |
|
|
|
when (direction) { |
|
|
|
when (direction) { |
|
|
|
PageDelegate.Direction.PREV -> page_view.moveToPrevPage() |
|
|
|
PageDelegate.Direction.PREV -> page_view.moveToPrevPage() |
|
|
@ -374,7 +373,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun clickCenter() { |
|
|
|
override fun clickCenter() { |
|
|
|
if (readAloudStatus != Status.STOP) { |
|
|
|
if (BaseReadAloudService.isRun) { |
|
|
|
showReadAloudDialog() |
|
|
|
showReadAloudDialog() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
read_menu.runMenuIn() |
|
|
|
read_menu.runMenuIn() |
|
|
@ -426,13 +425,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
override fun onClickReadAloud() { |
|
|
|
override fun onClickReadAloud() { |
|
|
|
if (!BaseReadAloudService.isRun) { |
|
|
|
if (!BaseReadAloudService.isRun) { |
|
|
|
readAloudStatus = Status.STOP |
|
|
|
|
|
|
|
SystemUtils.ignoreBatteryOptimization(this) |
|
|
|
SystemUtils.ignoreBatteryOptimization(this) |
|
|
|
} |
|
|
|
} |
|
|
|
when (readAloudStatus) { |
|
|
|
when { |
|
|
|
Status.STOP -> ReadBook.readAloud() |
|
|
|
!BaseReadAloudService.isRun -> ReadBook.readAloud() |
|
|
|
Status.PLAY -> ReadAloud.pause(this) |
|
|
|
BaseReadAloudService.pause -> ReadAloud.resume(this) |
|
|
|
Status.PAUSE -> ReadAloud.resume(this) |
|
|
|
else -> ReadAloud.pause(this) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -485,7 +483,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo |
|
|
|
override fun observeLiveBus() { |
|
|
|
override fun observeLiveBus() { |
|
|
|
super.observeLiveBus() |
|
|
|
super.observeLiveBus() |
|
|
|
observeEvent<Int>(Bus.ALOUD_STATE) { |
|
|
|
observeEvent<Int>(Bus.ALOUD_STATE) { |
|
|
|
readAloudStatus = it |
|
|
|
|
|
|
|
if (it == Status.STOP || it == Status.PAUSE) { |
|
|
|
if (it == Status.STOP || it == Status.PAUSE) { |
|
|
|
ReadBook.curTextChapter?.let { textChapter -> |
|
|
|
ReadBook.curTextChapter?.let { textChapter -> |
|
|
|
val page = textChapter.page(ReadBook.durPageIndex) |
|
|
|
val page = textChapter.page(ReadBook.durPageIndex) |
|
|
@ -506,7 +503,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo |
|
|
|
if (it) { |
|
|
|
if (it) { |
|
|
|
onClickReadAloud() |
|
|
|
onClickReadAloud() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ReadBook.readAloud(readAloudStatus == Status.PLAY) |
|
|
|
ReadBook.readAloud(!BaseReadAloudService.pause) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
observeEvent<Boolean>(Bus.UP_CONFIG) { |
|
|
|
observeEvent<Boolean>(Bus.UP_CONFIG) { |
|
|
|