|
|
|
@ -70,6 +70,23 @@ class FontSelectDialog : DialogFragment(), |
|
|
|
|
|
|
|
|
|
val fontPath = getPrefString(PreferKey.fontFolder) |
|
|
|
|
if (fontPath.isNullOrEmpty()) { |
|
|
|
|
openFolder() |
|
|
|
|
} else { |
|
|
|
|
val uri = Uri.parse(fontPath) |
|
|
|
|
if (DocumentFile.fromTreeUri(requireContext(), uri)?.canRead() == true) { |
|
|
|
|
getFontFiles(uri) |
|
|
|
|
} else { |
|
|
|
|
openFolder() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
|
super.onDestroy() |
|
|
|
|
job.cancel() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun openFolder() { |
|
|
|
|
try { |
|
|
|
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) |
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) |
|
|
|
@ -81,15 +98,6 @@ class FontSelectDialog : DialogFragment(), |
|
|
|
|
.onGranted { getFontFilesOld() } |
|
|
|
|
.request() |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
val uri = Uri.parse(fontPath) |
|
|
|
|
getFontFiles(uri) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onDestroy() { |
|
|
|
|
super.onDestroy() |
|
|
|
|
job.cancel() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressLint("DefaultLocale") |
|
|
|
|