diff --git a/app/src/main/java/live/mehiz/mpvkt/ui/player/PlayerActivity.kt b/app/src/main/java/live/mehiz/mpvkt/ui/player/PlayerActivity.kt index 74ac9f0..d48c61d 100644 --- a/app/src/main/java/live/mehiz/mpvkt/ui/player/PlayerActivity.kt +++ b/app/src/main/java/live/mehiz/mpvkt/ui/player/PlayerActivity.kt @@ -264,7 +264,8 @@ class PlayerActivity : AppCompatActivity() { .copyTo(File("$cachePath/fonts/subfont.ttf").outputStream()) } DocumentFile.fromTreeUri(this, Uri.parse(subtitlesPreferences.fontsFolder.get()))?.listFiles()?.forEach { - if (it.isDirectory || fontsDir.findFile(it.name!!)?.exists() == true) return + if (it.isDirectory || fontsDir.findFile(it.name!!)?.exists() == true) return@forEach + if (!it.name!!.endsWith("ttf", true) || !it.name!!.endsWith("otf")) return@forEach val input = contentResolver.openInputStream(it.uri) input!!.copyTo(File("$cachePath/fonts/${it.name}").outputStream()) input.close() diff --git a/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/sheets/subtitles/SubtitleSettingsTypographyCard.kt b/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/sheets/subtitles/SubtitleSettingsTypographyCard.kt index cd810c7..ab0e490 100644 --- a/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/sheets/subtitles/SubtitleSettingsTypographyCard.kt +++ b/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/sheets/subtitles/SubtitleSettingsTypographyCard.kt @@ -67,9 +67,16 @@ fun SubtitleSettingsTypographyCard( mutableStateOf(indicator) } LaunchedEffect(Unit) { + if (!preferences.fontsFolder.isSet()) { + fontsLoadingIndicator = null + return@LaunchedEffect + } withContext(Dispatchers.IO) { fonts.addAll( - DocumentFile.fromTreeUri(context, Uri.parse(preferences.fontsFolder.get()))!!.listFiles().filter { + DocumentFile.fromTreeUri( + context, + Uri.parse(preferences.fontsFolder.get()), + )!!.listFiles().filter { it.isFile && (it.name!!.endsWith("ttf", true) || it.name!!.endsWith("otf", true)) }.map { TTFFile.open(context.contentResolver.openInputStream(it.uri)!!).families.values.first() }, )