diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 39cca5312..b0fb383bb 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -1,11 +1,15 @@ package io.legado.app.ui.book.info +import android.annotation.SuppressLint import android.app.Activity import android.content.Intent import android.graphics.drawable.Drawable import android.os.Bundle +import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem +import android.widget.CheckBox +import android.widget.LinearLayout import androidx.lifecycle.Observer import com.bumptech.glide.RequestBuilder import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions @@ -229,23 +233,27 @@ class BookInfoActivity : } } + @SuppressLint("InflateParams") private fun deleteBook() { viewModel.bookData.value?.let { if (it.isLocalBook()) { alert( titleResource = R.string.sure, - messageResource = R.string.sure_delete_book_file + messageResource = R.string.sure_del ) { - positiveButton(R.string.yes) { - viewModel.delBook(true) { - finish() - } + val checkBox = CheckBox(this@BookInfoActivity).apply { + setText(R.string.delete_book_file) } - negativeButton(R.string.no) { - viewModel.delBook(false) { + val view = LayoutInflater.from(this@BookInfoActivity) + .inflate(R.layout.dialog_linear_layout, null) + (view as LinearLayout).addView(checkBox) + customView = view + positiveButton(R.string.yes) { + viewModel.delBook(checkBox.isChecked) { finish() } } + negativeButton(R.string.no) }.show() } else { viewModel.delBook { diff --git a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt index f0334504e..e37539851 100644 --- a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt @@ -6,6 +6,7 @@ import android.graphics.Canvas import android.os.Build import android.view.View import android.view.View.* +import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.RadioGroup import android.widget.SeekBar @@ -75,6 +76,13 @@ fun View.screenshot(): Bitmap? { }.getOrNull() } +fun View.setMargin(left: Int, top: Int, right: Int, bottom: Int) { + if (layoutParams is ViewGroup.MarginLayoutParams) { + (layoutParams as ViewGroup.MarginLayoutParams).setMargins(left, top, right, bottom) + requestLayout() + } +} + fun SeekBar.progressAdd(int: Int) { progress += int } diff --git a/app/src/main/res/layout/dialog_linear_layout.xml b/app/src/main/res/layout/dialog_linear_layout.xml new file mode 100644 index 000000000..2f73f4bc3 --- /dev/null +++ b/app/src/main/res/layout/dialog_linear_layout.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 84e6e6bb2..9432842a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -630,7 +630,7 @@ 其它朗读设置 系统内置字体样式 - 是否删除源文件 + 删除源文件 预设一 预设二 预设三