ui: do not crash w/large playlists

This commit is contained in:
Alexander Capehart
2026-04-05 19:40:16 -06:00
parent 92ba2a376f
commit 15f4bef8bc
2 changed files with 12 additions and 1 deletions
@@ -24,6 +24,7 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.PointF
import android.os.Build
import android.os.TransactionTooLargeException
import android.view.View
import android.view.WindowInsets
import androidx.annotation.RequiresApi
@@ -300,7 +301,15 @@ fun Context.share(songs: Collection<Song>) {
mimeTypes.add(song.format.mimeType)
}
builder.setType(mimeTypes.singleOrNull() ?: "audio/*").startChooser()
try {
builder.setType(mimeTypes.singleOrNull() ?: "audio/*").startChooser()
} catch (e: TransactionTooLargeException) {
L.e("Failed to share ${songs.size} songs: Too large")
showToast(R.string.err_share_too_large)
} catch (e: Exception) {
L.e("Failed to share ${songs.size} songs: $e")
showToast(R.string.err_share_failed)
}
}
/**
+2
View File
@@ -347,6 +347,8 @@
<string name="err_index_failed">Music loading failed</string>
<string name="err_import_failed">Unable to import a playlist from this file</string>
<string name="err_export_failed">Unable to export the playlist to this file</string>
<string name="err_share_too_large">This is too large to share</string>
<string name="err_share_failed">Unable to share this</string>
<string name="err_no_app">No app found that can handle this task</string>
<!-- No folders in the "Music Folders" setting -->
<string name="err_bad_location">This folder is not supported</string>