[修复] 退出书籍提示添加书架,点击确定后主页未显示 #458
This commit is contained in:
@@ -581,29 +581,6 @@ class AudioPlayActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finish() {
|
|
||||||
val book = AudioPlay.book ?: return super.finish()
|
|
||||||
|
|
||||||
if (AudioPlay.inBookshelf) {
|
|
||||||
return super.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AppConfig.showAddToShelfAlert) {
|
|
||||||
viewModel.removeFromBookshelf { super.finish() }
|
|
||||||
} else {
|
|
||||||
alert(title = getString(R.string.add_to_bookshelf)) {
|
|
||||||
setMessage(getString(R.string.check_add_bookshelf, book.name))
|
|
||||||
okButton {
|
|
||||||
AudioPlay.book?.removeType(BookType.notShelf)
|
|
||||||
AudioPlay.book?.save()
|
|
||||||
AudioPlay.inBookshelf = true
|
|
||||||
setResult(RESULT_OK)
|
|
||||||
}
|
|
||||||
noButton { viewModel.removeFromBookshelf { super.finish() } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
if (AudioPlay.status != Status.PLAY) {
|
if (AudioPlay.status != Status.PLAY) {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import android.view.MenuItem
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.CheckBox
|
import android.widget.CheckBox
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.activity.OnBackPressedCallback
|
||||||
|
import androidx.activity.addCallback
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.app.ActivityOptionsCompat
|
import androidx.core.app.ActivityOptionsCompat
|
||||||
@@ -51,6 +53,7 @@ import io.legado.app.help.book.isAudio
|
|||||||
import io.legado.app.help.book.isImage
|
import io.legado.app.help.book.isImage
|
||||||
import io.legado.app.help.book.isLocal
|
import io.legado.app.help.book.isLocal
|
||||||
import io.legado.app.help.book.isLocalTxt
|
import io.legado.app.help.book.isLocalTxt
|
||||||
|
import io.legado.app.help.book.isNotShelf
|
||||||
import io.legado.app.help.book.isWebFile
|
import io.legado.app.help.book.isWebFile
|
||||||
import io.legado.app.help.book.removeType
|
import io.legado.app.help.book.removeType
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
@@ -58,6 +61,7 @@ import io.legado.app.help.config.LocalConfig
|
|||||||
import io.legado.app.lib.dialogs.alert
|
import io.legado.app.lib.dialogs.alert
|
||||||
import io.legado.app.lib.dialogs.selector
|
import io.legado.app.lib.dialogs.selector
|
||||||
import io.legado.app.model.BookCover
|
import io.legado.app.model.BookCover
|
||||||
|
import io.legado.app.model.ReadBook
|
||||||
import io.legado.app.model.remote.RemoteBookWebDav
|
import io.legado.app.model.remote.RemoteBookWebDav
|
||||||
import io.legado.app.ui.about.AppLogDialog
|
import io.legado.app.ui.about.AppLogDialog
|
||||||
import io.legado.app.ui.book.audio.AudioPlayActivity
|
import io.legado.app.ui.book.audio.AudioPlayActivity
|
||||||
@@ -153,7 +157,7 @@ class BookInfoActivity :
|
|||||||
viewModel.refreshBook(book)
|
viewModel.refreshBook(book)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private lateinit var backCallback: OnBackPressedCallback
|
||||||
private var surfaceFinalColor: Int = 0
|
private var surfaceFinalColor: Int = 0
|
||||||
private var surfaceContainerFinalColor: Int = 0
|
private var surfaceContainerFinalColor: Int = 0
|
||||||
private var secondaryFinalColor: Int = 0
|
private var secondaryFinalColor: Int = 0
|
||||||
@@ -184,6 +188,7 @@ class BookInfoActivity :
|
|||||||
window.sharedElementReturnTransition = transform
|
window.sharedElementReturnTransition = transform
|
||||||
window.sharedElementsUseOverlay = false
|
window.sharedElementsUseOverlay = false
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
setupBackCallback()
|
||||||
surfaceFinalColor =
|
surfaceFinalColor =
|
||||||
MaterialColors.getColor(this, com.google.android.material.R.attr.colorSurface, -1)
|
MaterialColors.getColor(this, com.google.android.material.R.attr.colorSurface, -1)
|
||||||
secondaryFinalColor =
|
secondaryFinalColor =
|
||||||
@@ -381,6 +386,27 @@ class BookInfoActivity :
|
|||||||
// return super.dispatchTouchEvent(ev)
|
// return super.dispatchTouchEvent(ev)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
private fun setupBackCallback() {
|
||||||
|
onBackPressedDispatcher.addCallback(this) {
|
||||||
|
if (!viewModel.inBookshelf) {
|
||||||
|
viewModel.getBook()?.let { book ->
|
||||||
|
alert(title = getString(R.string.add_to_bookshelf)) {
|
||||||
|
setMessage(getString(R.string.check_add_bookshelf, book.name))
|
||||||
|
okButton {
|
||||||
|
book.removeType(BookType.notShelf)
|
||||||
|
book.save()
|
||||||
|
viewModel.inBookshelf = true
|
||||||
|
super.finish()
|
||||||
|
}
|
||||||
|
noButton { super.finish() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun refreshBook() {
|
private fun refreshBook() {
|
||||||
upLoading(true)
|
upLoading(true)
|
||||||
viewModel.getBook()?.let {
|
viewModel.getBook()?.let {
|
||||||
|
|||||||
@@ -928,28 +928,6 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finish() {
|
|
||||||
val book = ReadManga.book ?: return super.finish()
|
|
||||||
|
|
||||||
if (ReadManga.inBookshelf) {
|
|
||||||
return super.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AppConfig.showAddToShelfAlert) {
|
|
||||||
viewModel.removeFromBookshelf { super.finish() }
|
|
||||||
} else {
|
|
||||||
alert(title = getString(R.string.add_to_bookshelf)) {
|
|
||||||
setMessage(getString(R.string.check_add_bookshelf, book.name))
|
|
||||||
okButton {
|
|
||||||
ReadManga.book?.removeType(BookType.notShelf)
|
|
||||||
ReadManga.book?.save()
|
|
||||||
ReadManga.inBookshelf = true
|
|
||||||
setResult(RESULT_OK)
|
|
||||||
}
|
|
||||||
noButton { viewModel.removeFromBookshelf { super.finish() } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun resetWindowToSystemBrightness() {
|
fun resetWindowToSystemBrightness() {
|
||||||
val layoutParams = window.attributes
|
val layoutParams = window.attributes
|
||||||
layoutParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
layoutParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||||
|
|||||||
@@ -1787,30 +1787,6 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finish() {
|
|
||||||
val book = ReadBook.book ?: return super.finish()
|
|
||||||
|
|
||||||
if (ReadBook.inBookshelf) {
|
|
||||||
return super.finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AppConfig.showAddToShelfAlert) {
|
|
||||||
viewModel.removeFromBookshelf { super.finish() }
|
|
||||||
} else {
|
|
||||||
alert(title = getString(R.string.add_to_bookshelf)) {
|
|
||||||
setMessage(getString(R.string.check_add_bookshelf, book.name))
|
|
||||||
okButton {
|
|
||||||
ReadBook.book?.removeType(BookType.notShelf)
|
|
||||||
ReadBook.book?.save()
|
|
||||||
ReadBook.inBookshelf = true
|
|
||||||
setResult(RESULT_OK)
|
|
||||||
super.finish()
|
|
||||||
}
|
|
||||||
noButton { viewModel.removeFromBookshelf { super.finish() } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
tts?.clearTts()
|
tts?.clearTts()
|
||||||
|
|||||||
Reference in New Issue
Block a user