mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 04:28:00 +01:00
Show user friendly error messages
See https://github.com/FossifyOrg/Gallery/issues/309
This commit is contained in:
parent
43eff348e6
commit
1edcd5d161
4 changed files with 31 additions and 3 deletions
|
@ -311,7 +311,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
|||
override fun onPlayerErrorChanged(error: PlaybackException?) {
|
||||
binding.errorMessageHolder.errorMessage.apply {
|
||||
if (error != null) {
|
||||
text = error.localizedMessage ?: getString(R.string.failed_to_load_media)
|
||||
text = error.getFriendlyMessage(context)
|
||||
setTextColor(if (context.config.blackBackground) Color.WHITE else context.getProperTextColor())
|
||||
fadeIn()
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package org.fossify.gallery.extensions
|
||||
|
||||
import android.content.Context
|
||||
import androidx.media3.common.PlaybackException
|
||||
import androidx.media3.common.PlaybackException.*
|
||||
import androidx.media3.common.Player
|
||||
import org.fossify.gallery.R
|
||||
|
||||
fun Player.mute() {
|
||||
volume = 0f
|
||||
|
@ -9,3 +13,22 @@ fun Player.mute() {
|
|||
fun Player.unmute() {
|
||||
volume = 1f
|
||||
}
|
||||
|
||||
fun PlaybackException.getFriendlyMessage(context: Context): String? {
|
||||
val resource = when (errorCode) {
|
||||
ERROR_CODE_PARSING_CONTAINER_MALFORMED,
|
||||
ERROR_CODE_PARSING_MANIFEST_MALFORMED -> R.string.file_is_malformed_or_corrupted
|
||||
|
||||
ERROR_CODE_DECODER_INIT_FAILED,
|
||||
ERROR_CODE_DECODING_FAILED,
|
||||
ERROR_CODE_DECODING_FORMAT_EXCEEDS_CAPABILITIES -> R.string.media_exceeds_device_capabilities
|
||||
|
||||
ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED,
|
||||
ERROR_CODE_DECODING_FORMAT_UNSUPPORTED,
|
||||
ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED -> R.string.unsupported_format
|
||||
|
||||
else -> return localizedMessage ?: context.getString(R.string.failed_to_load_media)
|
||||
}
|
||||
|
||||
return context.getString(resource)
|
||||
}
|
||||
|
|
|
@ -452,7 +452,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
|||
if (error != null) {
|
||||
binding.videoPreview.beGone()
|
||||
binding.videoPlayOutline.beGone()
|
||||
text = error.localizedMessage ?: getString(R.string.failed_to_load_media)
|
||||
text = error.getFriendlyMessage(context)
|
||||
setTextColor(if (context.config.blackBackground) Color.WHITE else context.getProperTextColor())
|
||||
fadeIn()
|
||||
} else {
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
<string name="reorder_by_dragging_pro">Reorder folders by dragging (Pro)</string>
|
||||
<string name="restore_to_path">Restoring to \'%s\'</string>
|
||||
<string name="full_storage_permission_required">Fossify Gallery needs full access to display all your photos and videos. Go to Settings > Permissions > Photos and videos > Allow all.</string>
|
||||
<string name="failed_to_load_media">Failed to load media.</string>
|
||||
|
||||
<!-- Filter -->
|
||||
<string name="filter_media">Filter media</string>
|
||||
|
@ -242,6 +241,12 @@
|
|||
<string name="toggle_favorite">Toggle favorite</string>
|
||||
<string name="toggle_file_visibility">Toggle file visibility</string>
|
||||
|
||||
<!-- Errors -->
|
||||
<string name="failed_to_load_media">Failed to load media.</string>
|
||||
<string name="file_is_malformed_or_corrupted">File is malformed or corrupted.</string>
|
||||
<string name="media_exceeds_device_capabilities">Media exceeds device capabilities.</string>
|
||||
<string name="unsupported_format">Unsupported format.</string>
|
||||
|
||||
<!-- FAQ -->
|
||||
<string name="faq_1_title">How can I make Fossify Gallery the default device gallery?</string>
|
||||
<string name="faq_1_text">First you have to find the currently default gallery in the Apps section of your device settings, look for a button that says something like \"Open by default\", click on it, then select \"Clear defaults\".
|
||||
|
|
Loading…
Reference in a new issue