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

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

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

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

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

Loading…
Cancel
Save