|
|
@ -21,6 +21,7 @@ import io.legado.app.data.appDb |
|
|
|
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.databinding.ActivityBookInfoBinding |
|
|
|
import io.legado.app.databinding.ActivityBookInfoBinding |
|
|
|
|
|
|
|
import io.legado.app.databinding.DialogEditTextBinding |
|
|
|
import io.legado.app.help.BlurTransformation |
|
|
|
import io.legado.app.help.BlurTransformation |
|
|
|
import io.legado.app.help.glide.ImageLoader |
|
|
|
import io.legado.app.help.glide.ImageLoader |
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
@ -119,6 +120,8 @@ class BookInfoActivity : |
|
|
|
viewModel.bookData.value?.canUpdate ?: true |
|
|
|
viewModel.bookData.value?.canUpdate ?: true |
|
|
|
menu.findItem(R.id.menu_login)?.isVisible = |
|
|
|
menu.findItem(R.id.menu_login)?.isVisible = |
|
|
|
!viewModel.bookSource?.loginUrl.isNullOrBlank() |
|
|
|
!viewModel.bookSource?.loginUrl.isNullOrBlank() |
|
|
|
|
|
|
|
menu.findItem(R.id.menu_set_source_variable)?.isVisible = |
|
|
|
|
|
|
|
viewModel.bookSource != null |
|
|
|
return super.onMenuOpened(featureId, menu) |
|
|
|
return super.onMenuOpened(featureId, menu) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -157,6 +160,7 @@ class BookInfoActivity : |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
R.id.menu_top -> viewModel.topBook() |
|
|
|
R.id.menu_top -> viewModel.topBook() |
|
|
|
|
|
|
|
R.id.menu_set_source_variable -> setSourceVariable() |
|
|
|
R.id.menu_copy_book_url -> viewModel.bookData.value?.bookUrl?.let { |
|
|
|
R.id.menu_copy_book_url -> viewModel.bookData.value?.bookUrl?.let { |
|
|
|
sendToClip(it) |
|
|
|
sendToClip(it) |
|
|
|
} ?: toastOnUi(R.string.no_book) |
|
|
|
} ?: toastOnUi(R.string.no_book) |
|
|
@ -309,6 +313,32 @@ class BookInfoActivity : |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setSourceVariable() { |
|
|
|
|
|
|
|
launch { |
|
|
|
|
|
|
|
val variable = withContext(IO) { viewModel.bookSource?.getVariable() } |
|
|
|
|
|
|
|
alert(R.string.set_source_variable) { |
|
|
|
|
|
|
|
setMessage("源变量可在js中通过source.getVariable()获取") |
|
|
|
|
|
|
|
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { |
|
|
|
|
|
|
|
editView.hint = "source variable" |
|
|
|
|
|
|
|
editView.setText(variable) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
customView { alertBinding.root } |
|
|
|
|
|
|
|
okButton { |
|
|
|
|
|
|
|
launch(IO) { |
|
|
|
|
|
|
|
viewModel.bookSource?.setVariable(alertBinding.editView.text?.toString()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cancelButton() |
|
|
|
|
|
|
|
neutralButton(R.string.delete) { |
|
|
|
|
|
|
|
launch(IO) { |
|
|
|
|
|
|
|
viewModel.bookSource?.setVariable(null) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.show() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("InflateParams") |
|
|
|
@SuppressLint("InflateParams") |
|
|
|
private fun deleteBook() { |
|
|
|
private fun deleteBook() { |
|
|
|
viewModel.bookData.value?.let { |
|
|
|
viewModel.bookData.value?.let { |
|
|
|