默认封面添加删除功能

pull/328/head
gedoor 4 years ago
parent 71c58db4e0
commit 8c2afe51d2
  1. 23
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt

@ -20,6 +20,7 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp
import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.theme.ATH
import io.legado.app.receiver.SharedReceiverActivity
import io.legado.app.service.WebService
@ -83,11 +84,16 @@ class OtherConfigFragment : BasePreferenceFragment(),
FileUtils.deleteFile(requireActivity().cacheDir.absolutePath)
toast(R.string.clear_cache_success)
}
PreferKey.defaultCover -> {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "image/*"
startActivityForResult(intent, requestCodeCover)
PreferKey.defaultCover -> if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) {
selectDefaultCover()
} else {
selector(items = arrayListOf("删除图片", "选择图片")) { _, i ->
if (i == 0) {
removePref(PreferKey.defaultCover)
} else {
selectDefaultCover()
}
}
}
}
return super.onPreferenceTreeClick(preference)
@ -139,6 +145,13 @@ class OtherConfigFragment : BasePreferenceFragment(),
}
}
private fun selectDefaultCover() {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "image/*"
startActivityForResult(intent, requestCodeCover)
}
private fun isProcessTextEnabled(): Boolean {
return packageManager.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED
}

Loading…
Cancel
Save