pull/913/head
gedoor 4 years ago
parent 2dc6766f43
commit e74a7cdb4f
  1. 9
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  3. 9
      app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt
  4. 9
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  5. 9
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -118,6 +118,14 @@ class BookInfoEditActivity :
} }
} else { } else {
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
var hasPermission = true
it.forEach { (t, u) ->
if (!u) {
hasPermission = false
toastOnUi(t)
}
}
if (hasPermission) {
RealPathUtil.getPath(this, uri)?.let { path -> RealPathUtil.getPath(this, uri)?.let { path ->
val imgFile = File(path) val imgFile = File(path)
if (imgFile.exists()) { if (imgFile.exists()) {
@ -127,6 +135,7 @@ class BookInfoEditActivity :
coverChangeTo(file.absolutePath) coverChangeTo(file.absolutePath)
} }
} }
}
}.launch(Permissions.Group.STORAGE) }.launch(Permissions.Group.STORAGE)
} }
} }

@ -149,10 +149,19 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
else -> { else -> {
binding.tvEmptyMsg.visible() binding.tvEmptyMsg.visible()
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
var hasPermission = true
it.forEach { (t, u) ->
if (!u) {
hasPermission = false
toastOnUi(t)
}
}
if (hasPermission) {
rootDoc = null rootDoc = null
subDocs.clear() subDocs.clear()
path = lastPath path = lastPath
upPath() upPath()
}
}.launch(Permissions.Group.STORAGE) }.launch(Permissions.Group.STORAGE)
} }
} }

@ -57,12 +57,21 @@ object BackupRestoreUi {
path: String path: String
) { ) {
fragment.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { fragment.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
var hasPermission = true
it.forEach { (t, u) ->
if (!u) {
hasPermission = false
fragment.toastOnUi(t)
}
}
if (hasPermission) {
Coroutine.async { Coroutine.async {
AppConfig.backupPath = path AppConfig.backupPath = path
Backup.backup(fragment.requireContext(), path) Backup.backup(fragment.requireContext(), path)
}.onSuccess { }.onSuccess {
fragment.toastOnUi(R.string.backup_success) fragment.toastOnUi(R.string.backup_success)
} }
}
}.launch(Permissions.Group.STORAGE) }.launch(Permissions.Group.STORAGE)
} }

@ -280,6 +280,14 @@ class ThemeConfigFragment : BasePreferenceFragment(),
} }
} else { } else {
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
var hasPermission = true
it.forEach { (t, u) ->
if (!u) {
hasPermission = false
toastOnUi(t)
}
}
if (hasPermission) {
RealPathUtil.getPath(requireContext(), uri)?.let { path -> RealPathUtil.getPath(requireContext(), uri)?.let { path ->
val imgFile = File(path) val imgFile = File(path)
if (imgFile.exists()) { if (imgFile.exists()) {
@ -291,6 +299,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
success() success()
} }
} }
}
}.launch(Permissions.Group.STORAGE) }.launch(Permissions.Group.STORAGE)
} }
} }

@ -163,7 +163,16 @@ class FontSelectDialog : BaseDialogFragment(),
private fun loadFontFilesByPermission(path: String) { private fun loadFontFilesByPermission(path: String) {
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
var hasPermission = true
it.forEach { (t, u) ->
if (!u) {
hasPermission = false
toastOnUi(t)
}
}
if (hasPermission) {
loadFontFiles(path) loadFontFiles(path)
}
}.launch(Permissions.Group.STORAGE) }.launch(Permissions.Group.STORAGE)
} }

Loading…
Cancel
Save