[Android] SubDownload: add failure visual feedback

Duncan McNamara git at videolan.org
Fri Feb 25 06:39:16 UTC 2022


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Wed Feb 16 18:15:45 2022 +0100| [afc595edadf0f97452211e1a46012cb1590a5128] | committer: Nicolas Pomepuy

SubDownload: add failure visual feedback

> https://code.videolan.org/videolan/vlc-android/commit/afc595edadf0f97452211e1a46012cb1590a5128
---

 application/resources/src/main/res/values/strings.xml     |  1 +
 .../src/org/videolan/vlc/util/VLCDownloadManager.kt       | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 14af2d7f0..f5ac8d170 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -646,6 +646,7 @@
     <string name="subtitle_search_name_hint">Name</string>
     <string name="subtitle_search_episode_hint">Episode</string>
     <string name="subtitle_search_season_hint">Season</string>
+    <string name="subtitles_download_failed">Failed to download</string>
     <string name="language_to_download">Language</string>
     <string name="delete_the_selected">Delete selection</string>
     <string name="download_the_selected">Download selection</string>
diff --git a/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt b/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
index 4a93259fc..e0d66da20 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
@@ -6,6 +6,7 @@ import android.content.Context
 import android.content.Intent
 import android.content.IntentFilter
 import android.os.Environment
+import android.widget.Toast
 import androidx.core.content.getSystemService
 import androidx.core.net.toUri
 import androidx.fragment.app.FragmentActivity
@@ -84,8 +85,17 @@ object VLCDownloadManager: BroadcastReceiver(), LifecycleObserver {
         subtitleItem.run {
             ExternalSubRepository.getInstance(context).removeDownloadingItem(id)
             downloadedPaths.forEach {
-                if (Extensions.SUBTITLES.contains(".${it.split('.').last()}"))
-                    ExternalSubRepository.getInstance(context).saveDownloadedSubtitle(idSubtitle, it, mediaUri.path!!, subLanguageID, movieReleaseName)
+                if (Extensions.SUBTITLES.contains(".${it.split('.').last()}")) {
+                    ExternalSubRepository.getInstance(context).saveDownloadedSubtitle(
+                        idSubtitle,
+                        it,
+                        mediaUri.path!!,
+                        subLanguageID,
+                        movieReleaseName
+                    )
+                }
+                else
+                    Toast.makeText(context, R.string.subtitles_download_failed, Toast.LENGTH_SHORT).show()
             }
             withContext(Dispatchers.IO) { FileUtils.deleteFile(localUri) }
         }
@@ -101,6 +111,7 @@ object VLCDownloadManager: BroadcastReceiver(), LifecycleObserver {
     }
 
     private fun downloadFailed(id: Long, context: Context) {
+        Toast.makeText(context, R.string.subtitles_download_failed, Toast.LENGTH_SHORT).show()
         ExternalSubRepository.getInstance(context).removeDownloadingItem(id)
     }
 



More information about the Android mailing list