This commit is contained in:
kunfei
2023-03-16 17:23:23 +08:00
parent c9c9a88a14
commit 78acf41cd7
10 changed files with 41 additions and 16 deletions

View File

@@ -88,6 +88,12 @@ object LocalConfig :
return true
}
var bookInfoDeleteAlert: Boolean
get() = getBoolean("bookInfoDeleteAlert", true)
set(value) {
putBoolean("bookInfoDeleteAlert", value)
}
var deleteBookOriginal: Boolean
get() = getBoolean("deleteBookOriginal")
set(value) {

View File

@@ -146,6 +146,8 @@ class BookInfoActivity :
viewModel.bookData.value?.isLocalTxt ?: false
menu.findItem(R.id.menu_upload)?.isVisible =
viewModel.bookData.value?.isLocal ?: false
menu.findItem(R.id.menu_delete_alert)?.isChecked =
LocalConfig.bookInfoDeleteAlert
return super.onMenuOpened(featureId, menu)
}
@@ -206,7 +208,7 @@ class BookInfoActivity :
item.isChecked = !item.isChecked
if (!item.isChecked) longToastOnUi(R.string.need_more_time_load_content)
}
R.id.menu_delete_alert -> LocalConfig.bookInfoDeleteAlert = !item.isChecked
R.id.menu_upload -> {
viewModel.bookData.value?.let { book ->
book.getRemoteUrl()?.let {
@@ -471,32 +473,36 @@ class BookInfoActivity :
@SuppressLint("InflateParams")
private fun deleteBook() {
viewModel.bookData.value?.let {
if (it.isLocal) {
if (LocalConfig.bookInfoDeleteAlert) {
alert(
titleResource = R.string.sure,
titleResource = R.string.draw,
messageResource = R.string.sure_del
) {
val checkBox = CheckBox(this@BookInfoActivity).apply {
setText(R.string.delete_book_file)
isChecked = LocalConfig.deleteBookOriginal
var checkBox: CheckBox? = null
if (it.isLocal) {
checkBox = CheckBox(this@BookInfoActivity).apply {
setText(R.string.delete_book_file)
isChecked = LocalConfig.deleteBookOriginal
}
val view = LinearLayout(this@BookInfoActivity).apply {
setPadding(16.dpToPx(), 0, 16.dpToPx(), 0)
addView(checkBox)
}
customView { view }
}
val view = LinearLayout(this@BookInfoActivity).apply {
setPadding(16.dpToPx(), 0, 16.dpToPx(), 0)
addView(checkBox)
}
customView { view }
yesButton {
LocalConfig.deleteBookOriginal = checkBox.isChecked
viewModel.delBook(checkBox.isChecked) {
if (checkBox != null) {
LocalConfig.deleteBookOriginal = checkBox.isChecked
}
viewModel.delBook(LocalConfig.deleteBookOriginal) {
finish()
}
}
noButton()
}
} else {
//网络书籍删除了在退出详情页之前可以重新加入书架,不需要确认,实在不行还有阅读记录,不会找不到
viewModel.delBook {
upTvBookshelf()
viewModel.delBook(LocalConfig.deleteBookOriginal) {
finish()
}
}
}

View File

@@ -66,6 +66,12 @@
android:checkable="true"
app:showAsAction="never" />
<item
android:id="@+id/menu_delete_alert"
android:title="@string/delete_alert"
android:checkable="true"
app:showAsAction="never" />
<item
android:id="@+id/menu_clear_cache"
android:title="@string/clear_cache"

View File

@@ -1082,4 +1082,5 @@
<string name="sure_upload">Remote webDav url exists, Continue?</string>
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
<string name="no_books_dir">没有设置书籍保存位置!</string>
<string name="delete_alert">删除提醒</string>
</resources>

View File

@@ -1085,4 +1085,5 @@
<string name="sure_upload">Remote webDav url exists, Continue?</string>
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
<string name="no_books_dir">没有设置书籍保存位置!</string>
<string name="delete_alert">删除提醒</string>
</resources>

View File

@@ -1085,4 +1085,5 @@
<string name="sure_upload">Remote webDav url exists, Continue?</string>
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
<string name="no_books_dir">没有设置书籍保存位置!</string>
<string name="delete_alert">删除提醒</string>
</resources>

View File

@@ -1082,4 +1082,5 @@
<string name="sure_upload">远程webDav链接已存在是否继续</string>
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
<string name="no_books_dir">没有设置书籍保存位置!</string>
<string name="delete_alert">删除提醒</string>
</resources>

View File

@@ -1084,4 +1084,5 @@
<string name="sure_upload">远程webDav链接已存在是否继续</string>
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
<string name="no_books_dir">没有设置书籍保存位置!</string>
<string name="delete_alert">删除提醒</string>
</resources>

View File

@@ -1084,4 +1084,5 @@
<string name="sure_upload">远程webDav链接已存在是否继续</string>
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
<string name="no_books_dir">没有设置书籍保存位置!</string>
<string name="delete_alert">删除提醒</string>
</resources>

View File

@@ -1085,4 +1085,5 @@
<string name="sure_upload">Remote webDav url exists, Continue?</string>
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
<string name="no_books_dir">没有设置书籍保存位置!</string>
<string name="delete_alert">删除提醒</string>
</resources>