|
|
@ -280,15 +280,24 @@ class ThemeConfigFragment : BasePreferenceFragment(), |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { |
|
|
|
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { |
|
|
|
RealPathUtil.getPath(requireContext(), uri)?.let { path -> |
|
|
|
var hasPermission = true |
|
|
|
val imgFile = File(path) |
|
|
|
it.forEach { (t, u) -> |
|
|
|
if (imgFile.exists()) { |
|
|
|
if (!u) { |
|
|
|
var file = requireContext().externalFilesDir |
|
|
|
hasPermission = false |
|
|
|
file = FileUtils.createFileIfNotExist(file, preferenceKey, imgFile.name) |
|
|
|
toastOnUi(t) |
|
|
|
file.writeBytes(imgFile.readBytes()) |
|
|
|
} |
|
|
|
putPrefString(preferenceKey, file.absolutePath) |
|
|
|
} |
|
|
|
upPreferenceSummary(preferenceKey, file.absolutePath) |
|
|
|
if (hasPermission) { |
|
|
|
success() |
|
|
|
RealPathUtil.getPath(requireContext(), uri)?.let { path -> |
|
|
|
|
|
|
|
val imgFile = File(path) |
|
|
|
|
|
|
|
if (imgFile.exists()) { |
|
|
|
|
|
|
|
var file = requireContext().externalFilesDir |
|
|
|
|
|
|
|
file = FileUtils.createFileIfNotExist(file, preferenceKey, imgFile.name) |
|
|
|
|
|
|
|
file.writeBytes(imgFile.readBytes()) |
|
|
|
|
|
|
|
putPrefString(preferenceKey, file.absolutePath) |
|
|
|
|
|
|
|
upPreferenceSummary(preferenceKey, file.absolutePath) |
|
|
|
|
|
|
|
success() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}.launch(Permissions.Group.STORAGE) |
|
|
|
}.launch(Permissions.Group.STORAGE) |
|
|
|