优化
This commit is contained in:
@@ -88,6 +88,12 @@ object LocalConfig :
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bookInfoDeleteAlert: Boolean
|
||||||
|
get() = getBoolean("bookInfoDeleteAlert", true)
|
||||||
|
set(value) {
|
||||||
|
putBoolean("bookInfoDeleteAlert", value)
|
||||||
|
}
|
||||||
|
|
||||||
var deleteBookOriginal: Boolean
|
var deleteBookOriginal: Boolean
|
||||||
get() = getBoolean("deleteBookOriginal")
|
get() = getBoolean("deleteBookOriginal")
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ class BookInfoActivity :
|
|||||||
viewModel.bookData.value?.isLocalTxt ?: false
|
viewModel.bookData.value?.isLocalTxt ?: false
|
||||||
menu.findItem(R.id.menu_upload)?.isVisible =
|
menu.findItem(R.id.menu_upload)?.isVisible =
|
||||||
viewModel.bookData.value?.isLocal ?: false
|
viewModel.bookData.value?.isLocal ?: false
|
||||||
|
menu.findItem(R.id.menu_delete_alert)?.isChecked =
|
||||||
|
LocalConfig.bookInfoDeleteAlert
|
||||||
return super.onMenuOpened(featureId, menu)
|
return super.onMenuOpened(featureId, menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +208,7 @@ class BookInfoActivity :
|
|||||||
item.isChecked = !item.isChecked
|
item.isChecked = !item.isChecked
|
||||||
if (!item.isChecked) longToastOnUi(R.string.need_more_time_load_content)
|
if (!item.isChecked) longToastOnUi(R.string.need_more_time_load_content)
|
||||||
}
|
}
|
||||||
|
R.id.menu_delete_alert -> LocalConfig.bookInfoDeleteAlert = !item.isChecked
|
||||||
R.id.menu_upload -> {
|
R.id.menu_upload -> {
|
||||||
viewModel.bookData.value?.let { book ->
|
viewModel.bookData.value?.let { book ->
|
||||||
book.getRemoteUrl()?.let {
|
book.getRemoteUrl()?.let {
|
||||||
@@ -471,32 +473,36 @@ class BookInfoActivity :
|
|||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
private fun deleteBook() {
|
private fun deleteBook() {
|
||||||
viewModel.bookData.value?.let {
|
viewModel.bookData.value?.let {
|
||||||
if (it.isLocal) {
|
if (LocalConfig.bookInfoDeleteAlert) {
|
||||||
alert(
|
alert(
|
||||||
titleResource = R.string.sure,
|
titleResource = R.string.draw,
|
||||||
messageResource = R.string.sure_del
|
messageResource = R.string.sure_del
|
||||||
) {
|
) {
|
||||||
val checkBox = CheckBox(this@BookInfoActivity).apply {
|
var checkBox: CheckBox? = null
|
||||||
setText(R.string.delete_book_file)
|
if (it.isLocal) {
|
||||||
isChecked = LocalConfig.deleteBookOriginal
|
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 {
|
yesButton {
|
||||||
LocalConfig.deleteBookOriginal = checkBox.isChecked
|
if (checkBox != null) {
|
||||||
viewModel.delBook(checkBox.isChecked) {
|
LocalConfig.deleteBookOriginal = checkBox.isChecked
|
||||||
|
}
|
||||||
|
viewModel.delBook(LocalConfig.deleteBookOriginal) {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
noButton()
|
noButton()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//网络书籍删除了在退出详情页之前可以重新加入书架,不需要确认,实在不行还有阅读记录,不会找不到
|
viewModel.delBook(LocalConfig.deleteBookOriginal) {
|
||||||
viewModel.delBook {
|
finish()
|
||||||
upTvBookshelf()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,12 @@
|
|||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_delete_alert"
|
||||||
|
android:title="@string/delete_alert"
|
||||||
|
android:checkable="true"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_clear_cache"
|
android:id="@+id/menu_clear_cache"
|
||||||
android:title="@string/clear_cache"
|
android:title="@string/clear_cache"
|
||||||
|
|||||||
@@ -1082,4 +1082,5 @@
|
|||||||
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
||||||
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
||||||
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
||||||
|
<string name="delete_alert">删除提醒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1085,4 +1085,5 @@
|
|||||||
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
||||||
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
||||||
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
||||||
|
<string name="delete_alert">删除提醒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1085,4 +1085,5 @@
|
|||||||
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
||||||
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
||||||
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
||||||
|
<string name="delete_alert">删除提醒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1082,4 +1082,5 @@
|
|||||||
<string name="sure_upload">远程webDav链接已存在,是否继续</string>
|
<string name="sure_upload">远程webDav链接已存在,是否继续</string>
|
||||||
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
|
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
|
||||||
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
||||||
|
<string name="delete_alert">删除提醒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1084,4 +1084,5 @@
|
|||||||
<string name="sure_upload">远程webDav链接已存在,是否继续</string>
|
<string name="sure_upload">远程webDav链接已存在,是否继续</string>
|
||||||
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
|
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
|
||||||
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
||||||
|
<string name="delete_alert">删除提醒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1084,4 +1084,5 @@
|
|||||||
<string name="sure_upload">远程webDav链接已存在,是否继续</string>
|
<string name="sure_upload">远程webDav链接已存在,是否继续</string>
|
||||||
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
|
<string name="unsupport_archivefile_entry">压缩文件内没有支持的文件</string>
|
||||||
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
||||||
|
<string name="delete_alert">删除提醒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1085,4 +1085,5 @@
|
|||||||
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
<string name="sure_upload">Remote webDav url exists, Continue?</string>
|
||||||
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
<string name="unsupport_archivefile_entry">Cannot find supported files in archive</string>
|
||||||
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
<string name="no_books_dir">没有设置书籍保存位置!</string>
|
||||||
|
<string name="delete_alert">删除提醒</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user