Merge pull request #1876 from Bnyro/master

[fix] actually show the determined file type
This commit is contained in:
Bnyro 2022-11-17 15:38:38 +01:00 committed by GitHub
commit 0039f502b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,7 +36,12 @@ class ImportHelper(
}
} catch (e: IllegalArgumentException) {
Log.e(TAG(), e.toString())
Toast.makeText(activity, R.string.unsupported_file_format, Toast.LENGTH_SHORT).show()
Toast.makeText(
activity,
activity.getString(R.string.unsupported_file_format) +
" (${activity.contentResolver.getType(uri)}",
Toast.LENGTH_SHORT
).show()
} catch (e: Exception) {
Log.e(TAG(), e.toString())
Toast.makeText(activity, R.string.server_error, Toast.LENGTH_SHORT).show()
@ -47,8 +52,7 @@ class ImportHelper(
* Get a list of channel IDs from a file [Uri]
*/
private fun getChannelsFromUri(uri: Uri): List<String> {
val fileType = activity.contentResolver.getType(uri)
return when (fileType) {
return when (val fileType = activity.contentResolver.getType(uri)) {
"application/json" -> {
// NewPipe subscriptions format
val mapper = ObjectMapper()