kunfei 3 лет назад
Родитель
Сommit
4b761b2d33

+ 6 - 0
app/src/main/java/io/legado/app/help/config/LocalConfig.kt

@@ -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) {

+ 22 - 16
app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt

@@ -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 {
-                        setText(R.string.delete_book_file)
-                        isChecked = LocalConfig.deleteBookOriginal
-                    }
-                    val view = LinearLayout(this@BookInfoActivity).apply {
-                        setPadding(16.dpToPx(), 0, 16.dpToPx(), 0)
-                        addView(checkBox)
+                    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 }
                     }
                     }
-                    customView { view }
                     yesButton {
                     yesButton {
-                        LocalConfig.deleteBookOriginal = checkBox.isChecked
-                        viewModel.delBook(checkBox.isChecked) {
+                        if (checkBox != null) {
+                            LocalConfig.deleteBookOriginal = checkBox.isChecked
+                        }
+                        viewModel.delBook(LocalConfig.deleteBookOriginal) {
                             finish()
                             finish()
                         }
                         }
                     }
                     }
                     noButton()
                     noButton()
                 }
                 }
             } else {
             } else {
-                //网络书籍删除了在退出详情页之前可以重新加入书架,不需要确认,实在不行还有阅读记录,不会找不到
-                viewModel.delBook {
-                    upTvBookshelf()
+                viewModel.delBook(LocalConfig.deleteBookOriginal) {
+                    finish()
                 }
                 }
             }
             }
         }
         }

+ 6 - 0
app/src/main/res/menu/book_info.xml

@@ -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"

+ 1 - 0
app/src/main/res/values-es-rES/strings.xml

@@ -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>

+ 1 - 0
app/src/main/res/values-ja-rJP/strings.xml

@@ -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>

+ 1 - 0
app/src/main/res/values-pt-rBR/strings.xml

@@ -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>

+ 1 - 0
app/src/main/res/values-zh-rHK/strings.xml

@@ -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>

+ 1 - 0
app/src/main/res/values-zh-rTW/strings.xml

@@ -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>

+ 1 - 0
app/src/main/res/values-zh/strings.xml

@@ -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>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -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>