]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Update Download with External App summary. https://redmine.stoutner.com/issues/921
authorSoren Stoutner <soren@stoutner.com>
Thu, 10 Nov 2022 18:51:01 +0000 (11:51 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 10 Nov 2022 18:51:01 +0000 (11:51 -0700)
12 files changed:
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/java/com/stoutner/privacybrowser/asynctasks/SaveAboutVersionImage.java
app/src/main/java/com/stoutner/privacybrowser/asynctasks/SaveUrl.java
app/src/main/java/com/stoutner/privacybrowser/asynctasks/SaveWebpageImage.java
app/src/main/java/com/stoutner/privacybrowser/fragments/AboutVersionFragment.kt
app/src/main/res/values-de/strings.xml
app/src/main/res/values-es/strings.xml
app/src/main/res/values-fr/strings.xml
app/src/main/res/values-it/strings.xml
app/src/main/res/values-pt-rBR/strings.xml
app/src/main/res/values-ru/strings.xml
app/src/main/res/values/strings.xml

index e1a8ca78f0b25e39d28b5348d394f30463a6e988..1ee31db40a03cb8dfe9996eacfeaa79140aa230e 100644 (file)
@@ -391,11 +391,30 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                 public void onActivityResult(Uri fileUri) {
                     // Only save the webpage archive if the file URI is not null, which happens if the user exited the file picker by pressing back.
                     if (fileUri != null) {
+                        // Initialize the file name string from the file URI last path segment.
+                        String temporaryFileNameString = fileUri.getLastPathSegment();
+
+                        // Query the exact file name if the API >= 26.
+                        if (Build.VERSION.SDK_INT >= 26) {
+                            // Get a cursor from the content resolver.
+                            Cursor contentResolverCursor = resultLauncherActivityHandle.getContentResolver().query(fileUri, null, null, null);
+
+                            // Move to the fist row.
+                            contentResolverCursor.moveToFirst();
+
+                            // Get the file name from the cursor.
+                            temporaryFileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME));
+
+                            // Close the cursor.
+                            contentResolverCursor.close();
+                        }
+
+                        // Save the final file name string so it can be used inside the lambdas.  This will no longer be needed once this activity has transitioned to Kotlin.
+                        String finalFileNameString = temporaryFileNameString;
+
                         try {
                             // Create a temporary MHT file.
                             File temporaryMhtFile = File.createTempFile("temporary_mht_file", ".mht", getCacheDir());
-
-                            // Save the temporary MHT file.
                             currentWebView.saveWebArchive(temporaryMhtFile.toString(), false, callbackValue -> {
                                 if (callbackValue != null) {  // The temporary MHT file was saved successfully.
                                     try {
@@ -420,29 +439,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                                         mhtOutputStream.close();
                                         temporaryMhtFileInputStream.close();
 
-                                        // Initialize the file name string from the file URI last path segment.
-                                        String fileNameString = fileUri.getLastPathSegment();
-
-                                        // Query the exact file name if the API >= 26.
-                                        if (Build.VERSION.SDK_INT >= 26) {
-                                            // Get a cursor from the content resolver.
-                                            Cursor contentResolverCursor = resultLauncherActivityHandle.getContentResolver().query(fileUri, null, null, null);
-
-                                            // Move to the fist row.
-                                            contentResolverCursor.moveToFirst();
-
-                                            // Get the file name from the cursor.
-                                            fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME));
-
-                                            // Close the cursor.
-                                            contentResolverCursor.close();
-                                        }
-
                                         // Display a snackbar.
-                                        Snackbar.make(currentWebView, getString(R.string.file_saved) + "  " + fileNameString, Snackbar.LENGTH_SHORT).show();
+                                        Snackbar.make(currentWebView, getString(R.string.saved, finalFileNameString), Snackbar.LENGTH_SHORT).show();
                                     } catch (Exception exception) {
                                         // Display a snackbar with the exception.
-                                        Snackbar.make(currentWebView, getString(R.string.error_saving_file) + "  " + exception, Snackbar.LENGTH_INDEFINITE).show();
+                                        Snackbar.make(currentWebView, getString(R.string.error_saving_file, finalFileNameString, exception), Snackbar.LENGTH_INDEFINITE).show();
                                     } finally {
                                         // Delete the temporary MHT file.
                                         //noinspection ResultOfMethodCallIgnored
@@ -450,12 +451,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                                     }
                                 } else {  // There was an unspecified error while saving the temporary MHT file.
                                     // Display an error snackbar.
-                                    Snackbar.make(currentWebView, getString(R.string.error_saving_file), Snackbar.LENGTH_INDEFINITE).show();
+                                    Snackbar.make(currentWebView, getString(R.string.error_saving_file, finalFileNameString, getString(R.string.unknown_error)), Snackbar.LENGTH_INDEFINITE).show();
                                 }
                             });
                         } catch (IOException ioException) {
                             // Display a snackbar with the IO exception.
-                            Snackbar.make(currentWebView, getString(R.string.error_saving_file) + "  " + ioException, Snackbar.LENGTH_INDEFINITE).show();
+                            Snackbar.make(currentWebView, getString(R.string.error_saving_file, finalFileNameString, ioException), Snackbar.LENGTH_INDEFINITE).show();
                         }
                     }
                 }
index 72be35125c6650afadc52463004e8707365eeab9..49ae1d9fe28a1ab8974073452f5f37d14839bb90 100644 (file)
@@ -163,9 +163,9 @@ public class SaveAboutVersionImage extends AsyncTask<Void, Void, String> {
         // Display a file creation disposition snackbar.
         if (fileCreationDisposition.equals(SUCCESS)) {
             // Create a file saved snackbar.
-            Snackbar.make(aboutVersionLinearLayout, activity.getString(R.string.file_saved) + "  " + fileNameString, Snackbar.LENGTH_SHORT).show();
+            Snackbar.make(aboutVersionLinearLayout, activity.getString(R.string.saved, fileNameString), Snackbar.LENGTH_SHORT).show();
         } else {
-            Snackbar.make(aboutVersionLinearLayout, activity.getString(R.string.error_saving_file) + "  " + fileCreationDisposition, Snackbar.LENGTH_INDEFINITE).show();
+            Snackbar.make(aboutVersionLinearLayout, activity.getString(R.string.error_saving_file, fileNameString, fileCreationDisposition), Snackbar.LENGTH_INDEFINITE).show();
         }
     }
 }
index 34fefc47925a6ad5b479aa1ef5a8fe5c7699b446..029929dd1f38880542f710b9d9dbe70ea2507e1c 100644 (file)
@@ -279,10 +279,10 @@ public class SaveUrl extends AsyncTask<String, Long, String> {
         // Display a save disposition snackbar.
         if (saveDisposition.equals(SUCCESS)) {
             // Display the file saved snackbar.
-            Snackbar.make(noSwipeViewPager, activity.getString(R.string.file_saved) + "  " + fileNameString, Snackbar.LENGTH_LONG).show();
+            Snackbar.make(noSwipeViewPager, activity.getString(R.string.saved, fileNameString), Snackbar.LENGTH_LONG).show();
         } else {
             // Display the file saving error.
-            Snackbar.make(noSwipeViewPager, activity.getString(R.string.error_saving_file) + "  " + saveDisposition, Snackbar.LENGTH_INDEFINITE).show();
+            Snackbar.make(noSwipeViewPager, activity.getString(R.string.error_saving_file, fileNameString, saveDisposition), Snackbar.LENGTH_INDEFINITE).show();
         }
     }
 }
index e18fbd9cc7e406d810a1415b0f82e99b1cf50a67..5a92123a043cd7b3f1a574c2774b5dc6ee69431b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright0 2019-2022 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
  *
@@ -159,10 +159,10 @@ public class SaveWebpageImage extends AsyncTask<Void, Void, String> {
         // Display a file creation disposition snackbar.
         if (fileCreationDisposition.equals(SUCCESS)) {
             // Display the image saved snackbar.
-            Snackbar.make(nestedScrollWebView, activity.getString(R.string.image_saved) + "  " + fileNameString, Snackbar.LENGTH_SHORT).show();
+            Snackbar.make(nestedScrollWebView, activity.getString(R.string.saved, fileNameString), Snackbar.LENGTH_SHORT).show();
         } else {
             // Display the file saving error.
-            Snackbar.make(nestedScrollWebView, activity.getString(R.string.error_saving_file) + "  " + fileCreationDisposition, Snackbar.LENGTH_INDEFINITE).show();
+            Snackbar.make(nestedScrollWebView, activity.getString(R.string.error_saving_file, fileNameString, fileCreationDisposition), Snackbar.LENGTH_INDEFINITE).show();
         }
     }
-}
\ No newline at end of file
+}
index e5d0c543e9d43d8b3e09d4b7cab6f9f67394601f..f4b673eaa468704ef1147c0007e8b8a161283b4f 100644 (file)
@@ -163,6 +163,24 @@ class AboutVersionFragment : Fragment() {
     private val saveAboutVersionTextActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument("text/plain")) { fileUri: Uri? ->
         // Only save the file if the URI is not null, which happens if the user exited the file picker by pressing back.
         if (fileUri != null) {
+            // Initialize the file name string from the file URI last path segment.
+            var fileNameString = fileUri.lastPathSegment
+
+            // Query the exact file name if the API >= 26.
+            if (Build.VERSION.SDK_INT >= 26) {
+                // Get a cursor from the content resolver.
+                val contentResolverCursor = requireActivity().contentResolver.query(fileUri, null, null, null)!!
+
+                // Move to the first row.
+                contentResolverCursor.moveToFirst()
+
+                // Get the file name from the cursor.
+                fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME))
+
+                // Close the cursor.
+                contentResolverCursor.close()
+            }
+
             try {
                 // Get the about version string.
                 val aboutVersionString = getAboutVersionString()
@@ -181,29 +199,11 @@ class AboutVersionFragment : Fragment() {
                     }
                 }
 
-                // Initialize the file name string from the file URI last path segment.
-                var fileNameString = fileUri.lastPathSegment
-
-                // Query the exact file name if the API >= 26.
-                if (Build.VERSION.SDK_INT >= 26) {
-                    // Get a cursor from the content resolver.
-                    val contentResolverCursor = requireActivity().contentResolver.query(fileUri, null, null, null)!!
-
-                    // Move to the first row.
-                    contentResolverCursor.moveToFirst()
-
-                    // Get the file name from the cursor.
-                    fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME))
-
-                    // Close the cursor.
-                    contentResolverCursor.close()
-                }
-
                 // Display a snackbar with the saved logcat information.
                 Snackbar.make(aboutVersionLayout, getString(R.string.saved, fileNameString), Snackbar.LENGTH_SHORT).show()
             } catch (exception: Exception) {
                 // Display a snackbar with the error message.
-                Snackbar.make(aboutVersionLayout, getString(R.string.error_saving_file, exception.toString()), Snackbar.LENGTH_INDEFINITE).show()
+                Snackbar.make(aboutVersionLayout, getString(R.string.error_saving_file, fileNameString, exception.toString()), Snackbar.LENGTH_INDEFINITE).show()
             }
         }
     }
index d331954c48d11be79290646b978dff1ba398643f..f0e0c5ebd161db4813c6d8f4311c70045ce5b210 100644 (file)
     <string name="unknown_size">Unbekannte Größe</string>
     <string name="invalid_url">Ungültige URL</string>
     <string name="saving_file">Speichere Datei:</string>
-    <string name="file_saved">Datei gespeichert:</string>
     <string name="processing_image">Bild wird bearbeitet… :</string>
-    <string name="image_saved">Bild gespeichert:</string>
-    <string name="error_saving_file">Fehler beim Speichern der Datei: \u0020 %1$sFf</string>
 
     <!-- View Source. -->
     <string name="request_headers">Anfragekopfzeilen</string>
         <string name="swipe_to_refresh">Herunterziehen zum Aktualisieren</string>
         <string name="swipe_to_refresh_summary">Einige Websites funktionieren nicht, wenn "Herunterziehen zum Aktualisieren" eingeschaltet ist.</string>
         <string name="download_with_external_app">Mit einer externen App herunterladen</string>
-        <string name="download_with_external_app_summary">Eine externe App verwenden, um Dateien herunterzuladen.</string>
         <string name="scroll_app_bar">App-Leiste scrollen</string>
         <string name="scroll_app_bar_summary">Scrollt die App-Leiste mit der URL nach oben, wenn die Webseite gescrollt wird.</string>
         <string name="bottom_app_bar">Untere Anwendungs-Leiste</string>
index df943b88738e26d554dae8f2e8f21a7e9d76a4e3..a304733fe3a4c48fa8aa9a2b359298c0d17a337d 100644 (file)
     <string name="unknown_size">Tamaño desconocido</string>
     <string name="invalid_url">URL inválida</string>
     <string name="saving_file">Guardando archivo:</string>
-    <string name="file_saved">Archivo guardado:</string>
     <string name="processing_image">Procesando imagen… :</string>
-    <string name="image_saved">Imagen guardada:</string>
-    <string name="error_saving_file">Error guardando archivo: \u0020 %1$s</string>
 
     <!-- View Source. -->
     <string name="request_headers">Cabeceras de solicitud</string>
         <string name="swipe_to_refresh">Deslizar para actualizar</string>
         <string name="swipe_to_refresh_summary">Algunas webs no funcionan bien si la opción deslizar para actualizar está habilitada.</string>
         <string name="download_with_external_app">Descargar con una app externa</string>
-        <string name="download_with_external_app_summary">Use una app externa para descargar archivos.</string>
         <string name="scroll_app_bar">Desplazar la barra de aplicaciones</string>
         <string name="scroll_app_bar_summary">Desplazar la barra de aplicaciones desde la parte superior de la pantalla cuando el WebView se desplaza hacia abajo.</string>
         <string name="bottom_app_bar">Barra inferior de la app</string>
index 45b1f334331534acc49d8272596c0b366604e144..5f9cdc6f3785473ecd193b456ad1ce826fdf29be 100644 (file)
     <string name="unknown_size">taille inconnue</string>
     <string name="invalid_url">URL invalide</string>
     <string name="saving_file">Enregistrement du fichier :</string>
-    <string name="file_saved">Fichier enregistré :</string>
     <string name="processing_image">Traitement de l\'image… :</string>
-    <string name="image_saved">Image sauvegardée :</string>
-    <string name="error_saving_file">Erreur lors de l\'enregistrement du fichier : \u0020 %1$s</string>
 
     <!-- View Source. -->
     <string name="request_headers">En-tête de la requête</string>
         <string name="swipe_to_refresh">Glisser pour rafraîchir</string>
         <string name="swipe_to_refresh_summary">Certains sites Web ne fonctionnent pas bien lorsque "Glisser pour rafraîchir" est activé.</string>
         <string name="download_with_external_app">Téléchargement avec une app externe</string>
-        <string name="download_with_external_app_summary">Utiliser une application externe pour télécharger des fichiers.</string>
         <string name="bottom_app_bar">Barre d\'application en bas</string>
         <string name="bottom_app_bar_summary">Déplacer la barre d\'application vers le bas de l\'écran. La modification de ce paramètre entraîne le redémarrage de Privacy Browser.</string>
         <string name="scroll_app_bar">Défilement barre d\'applications</string>
index f89a1962109a92dca79d47da5c625c628e465832..d601ddbfe5fd335646722437d112a5b14af8d6e3 100644 (file)
     <string name="unknown_size">Dimensione sconosciuta</string>
     <string name="invalid_url">URL non valida</string>
     <string name="saving_file">Salvataggio file:</string>
-    <string name="file_saved">File salvato:</string>
     <string name="processing_image">Creazione immagine… :</string>
-    <string name="image_saved">Immagine salvata:</string>
-    <string name="error_saving_file">Errore salvataggio file: \u0020 %1$s</string>
 
     <!-- View Source. -->
     <string name="request_headers">Richiesta Intestazioni</string>
         <string name="swipe_to_refresh">Swipe per aggiornare</string>
         <string name="swipe_to_refresh_summary">Alcuni siti non funzionano correttamente se questa opzione è abilitata.</string>
         <string name="download_with_external_app">Scarica con una applicazione esterna</string>
-        <string name="download_with_external_app_summary">Utilizza una applicazione esterna per scaricare i file.</string>
         <string name="scroll_app_bar">Permetti lo scrolling della barra dell\'applicazione</string>
         <string name="scroll_app_bar_summary">Permette lo scorrere della barra dell\'applicazione dalla parte alta dello schermo quando si effettua lo scrolling.</string>
         <string name="bottom_app_bar">Barra dell\'app in basso</string>
index 387aed8e8c046170303b108ba48b323cbdf14668..4dac8dc442696e8f309e8dabdac46e75cc95f301 100644 (file)
     <string name="unknown_size">tamanho desconhecido</string>
     <string name="invalid_url">URL inválida</string>
     <string name="saving_file">Salvando file:</string>
-    <string name="file_saved">Arquivo Salvo:</string>
     <string name="processing_image">Processando imagem… :</string>
-    <string name="image_saved">Image saved:</string>
-    <string name="error_saving_file">Erro ao salvar o arquivo: \u0020 %1$s</string>
 
     <!-- View Source. -->
     <string name="request_headers">Solicitar cabeçalhos</string>
         <string name="swipe_to_refresh">Deslize para atualizar</string>
         <string name="swipe_to_refresh_summary">Alguns sites não funcionam bem se deslizar para atualizar estiver habilitado.</string>
         <string name="download_with_external_app">Download com aplicativo externo</string>
-        <string name="download_with_external_app_summary">Usar um aplicativo externo para baixar arquivos.</string>
         <string name="scroll_app_bar">Role a barra de aplicativos</string>
         <string name="scroll_app_bar_summary">Role a barra de aplicativos para fora da parte superior da tela quando o WebView rola para baixo.</string>
         <string name="bottom_app_bar">Barra de aplicativos inferior</string>
index 1cfa2fbf7dcedfd0fb99c2a46b7fb734b3c8ceff..3afebf9e670bf2987b4ed36b21650d01cd3b98dc 100644 (file)
     <string name="unknown_size">неизвестный размер</string>
     <string name="invalid_url">неправильный URL</string>
     <string name="saving_file">Сохранение файла:</string>
-    <string name="file_saved">Файл сохранен:</string>
     <string name="processing_image">Обработка изображения… :</string>
-    <string name="image_saved">Изображение сохранено:</string>
-    <string name="error_saving_file">Ошибка сохранения файла: \u0020 %1$s</string>
 
     <!-- View Source. -->
     <string name="request_headers">Заголовки запроса</string>
         <string name="swipe_to_refresh">Потянуть для обновления</string>
         <string name="swipe_to_refresh_summary">Некоторые веб-сайты могут работать некорректно при включении данной опции.</string>
         <string name="download_with_external_app">Загрузка во внешнем приложении</string>
-        <string name="download_with_external_app_summary">Использовать внешнее приложение для загрузки файлов.</string>
         <string name="scroll_app_bar">Прокручивать панель приложения</string>
         <string name="scroll_app_bar_summary">Прокручивает панель приложения вверху экрана при прокрутке WebView вниз.</string>
         <string name="bottom_app_bar">Нижняя панель приложения</string>
index 14d7389745d3c80f191a0d56ac690566d1293275..1e30a7a8c49e50e695877828803dacd7f1d6240b 100644 (file)
     <string name="unknown_size">unknown size</string>
     <string name="invalid_url">invalid URL</string>
     <string name="saving_file">Saving file:</string>
-    <string name="file_saved">File saved:</string>
+    <string name="saved">%1$s saved.</string>
     <string name="processing_image">Processing image… :</string>
-    <string name="image_saved">Image saved:</string>
-    <string name="error_saving_file">Error saving file: \u0020 %1$s</string>
+    <string name="error_saving_file">Error saving %1$s: \u0020 %2$s</string> -->
+    <string name="unknown_error">Unknown error</string>
 
     <!-- View Source. -->
     <string name="request_headers">Request Headers</string>
     <string name="clear">Clear</string>
     <string name="logcat_copied">Logcat copied.</string>
     <string name="privacy_browser_logcat_txt">Privacy Browser %1$s Logcat.txt</string>
-    <string name="saved">%1$s saved.</string>
     <string name="error_saving_logcat">Error saving logcat: \u0020 %1$s</string>
 
     <!-- Guide. -->
         <string name="swipe_to_refresh">Swipe to refresh</string>
         <string name="swipe_to_refresh_summary">Some websites don’t work well if swipe to refresh is enabled.</string>
         <string name="download_with_external_app">Download with external app</string>
-        <string name="download_with_external_app_summary">Use an external app to download files.</string>
+        <string name="download_with_external_app_summary">External apps will not honor Privacy Browser’s proxy settings and will not have access to cookies
+            (meaning that it is unlikely that files downloaded from sites that require a login will work).</string>
         <string name="scroll_app_bar">Scroll the app bar</string>
         <string name="scroll_app_bar_summary">Scroll the app bar off the top of the screen when the WebView scrolls down.</string>
         <string name="bottom_app_bar">Bottom app bar</string>