From: Soren Stoutner Date: Mon, 29 May 2023 20:23:38 +0000 (-0700) Subject: Add a cancel action to the save URL snackbar. https://redmine.stoutner.com/issues/782 X-Git-Tag: v3.15~5 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=2f0d40bbfc1aca5d88e711422cec58d912b66884;p=PrivacyBrowserAndroid.git Add a cancel action to the save URL snackbar. https://redmine.stoutner.com/issues/782 --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/coroutines/SaveUrlCoroutine.kt b/app/src/main/java/com/stoutner/privacybrowser/coroutines/SaveUrlCoroutine.kt index d2765814..f6b7a832 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/coroutines/SaveUrlCoroutine.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/coroutines/SaveUrlCoroutine.kt @@ -47,6 +47,9 @@ import java.text.NumberFormat class SaveUrlCoroutine { fun save(context: Context, activity: Activity, urlString: String, fileUri: Uri, userAgent: String, cookiesEnabled: Boolean) { + // Create a canceled boolean. + var canceled = false + // Use a coroutine to save the URL. CoroutineScope(Dispatchers.Main).launch { // Create a file name string. @@ -75,6 +78,7 @@ class SaveUrlCoroutine { // Create a saving file snackbar. val savingFileSnackbar = Snackbar.make(webViewViewPager2, activity.getString(R.string.saving_file, 0, fileNameString), Snackbar.LENGTH_INDEFINITE) + .setAction(R.string.cancel) { canceled = true } // Display the saving file snackbar. savingFileSnackbar.show() @@ -160,7 +164,7 @@ class SaveUrlCoroutine { var bufferLength: Int // Attempt to read data from the input stream and store it in the output stream. Also store the amount of data read in the buffer length variable. - while (inputStream.read(conversionBufferByteArray).also { bufferLength = it } > 0) { // Proceed while the amount of data stored in the buffer in > 0. + while ((inputStream.read(conversionBufferByteArray).also { bufferLength = it } > 0) && !canceled) { // Proceed while the amount of data stored in the buffer in > 0. // Write the contents of the conversion buffer to the file output stream. outputStream.write(conversionBufferByteArray, 0, bufferLength) @@ -204,8 +208,13 @@ class SaveUrlCoroutine { // Dismiss the saving file snackbar. savingFileSnackbar.dismiss() - // Display the file saved snackbar. - Snackbar.make(webViewViewPager2, activity.getString(R.string.saved, fileNameString), Snackbar.LENGTH_LONG).show() + // Display a final disposition snackbar. + if (canceled) + // Display the download cancelled snackbar. + Snackbar.make(webViewViewPager2, activity.getString(R.string.download_cancelled), Snackbar.LENGTH_SHORT).show() + else + // Display the file saved snackbar. + Snackbar.make(webViewViewPager2, activity.getString(R.string.saved, fileNameString), Snackbar.LENGTH_LONG).show() } } catch (exception: Exception) { // Update the UI. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f8fa7f22..545b18a5 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -3,7 +3,7 @@ + Por defecto del sistema + Datos de formulario habilitados + Datos de formulario deshabilitados + + + Por defecto del sistema + EasyList habilitada + EasyList deshabilitada + + + Por defecto del sistema + EasyPrivacy habilitada + EasyPrivacy deshabilitada + + + Por defecto del sistema + Lista molesta de Fanboy habilitada + Lista molesta de Fanboy deshabilitada + + + Por defecto del sistema + Lista de bloqueo social de Fanboy habilitada + Lista de bloqueo social de Fanboy deshabilitada + + + Por defecto del sistema + UltraList habilitada + UltraList deshabilitada + + + Por defecto del sistema + Ultra Privacidad habilitada + Ultra Privacidad deshabilitada + + + Por defecto del sistema + Bloquear todas las solicitudes de terceras partes habilitada + Bloquear todas las solicitudes de terceras partes deshabilitada + Por defecto del sistema Tamaño de letra personalizado diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 31919afb..22db320c 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -324,6 +324,61 @@ Nome del Dominio Dominio Eliminato è possibile anteporre *. a un dominio per includere tutti i sottodomini (es. *.stoutner.com) + + Default di Sistema + JavaScript abilitato + JavaScript disabilitato + + + Default di Sistema + Cookies abilitati + Cookies disabilitati + + + Default di Sistema + DOM storage abilitato + DOM storage disabilitato + + + Default di Sistema + Dati dei Form abilitati + Dati dei Form disabilitati + + + Default di Sistema + EasyList abilitata + EasyList disabilitata + + + Default di Sistema + EasyPrivacy abilitata + EasyPrivacy disabilitata + + + Default di Sistema + Fanboy’s Annoyance List abilitata + Fanboy’s Annoyance List disabilitata + + + Default di Sistema + Fanboy’s Social Blocking List abilitata + Fanboy’s Social Blocking List disabilitata + + + Default di Sistema + UltraList abilitata + UltraList disabilitata + + + Default di Sistema + UltraPrivacy abilitata + UltraPrivacy disabilitata + + + Default di Sistema + Bloccco di tutte le richieste di terze parti abilitato + Bloccco di tutte le richieste di terze parti disabilitato + Impostazioni di default Dimensione carattere personalizzata diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index a37179d9..c2e16c8a 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -321,6 +321,61 @@ Имя домена Домен удален добавьте *. для включения всех поддоменов (напр. *.stoutner.com) + + По умолчанию + JavaScript включен + JavaScript отключен + + + По умолчанию + Cookie включены + Cookie отключены + + + По умолчанию + DOM-хранилище включено + DOM-хранилище отключено + + + По умолчанию + Данные форм включены + Данные форм отключены + + + По умолчанию + EasyList включен + EasyList отключен + + + По умолчанию + EasyPrivacy включен + EasyPrivacy отключен + + + По умолчанию + Fanboy’s Annoyance List включен + Fanboy’s Annoyance List отключен + + + По умолчанию + Fanboy’s Social Blocking List включен + Fanboy’s Social Blocking List отключен + + + По умолчанию + UltraList включен + UltraList отключен + + + По умолчанию + UltraPrivacy включен + UltraPrivacy отключен + + + По умолчанию + Блокировка всех сторонних запросов включена + Блокировка всех сторонних запросов отключена + Настройки по умолчанию Пользовательский размер шрифта diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index efa98477..62c7f948 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -213,6 +213,7 @@ Saving file:\u0020 %1$s bytes - %2$s Saving file:\u0020 %1$d%% - %2$s bytes / %3$s bytes - %4$s %1$s saved. + Download cancelled. Processing image:\u0020 %1$s Error saving %1$s:\u0020 %2$s Unknown error diff --git a/gradle.properties b/gradle.properties index edf379e7..b8a7a355 100644 --- a/gradle.properties +++ b/gradle.properties @@ -41,5 +41,7 @@ org.gradle.unsafe.configuration-cache=true # Use non-transitive R classes, which speed up the build process when the configuration has not changed. android.nonTransitiveRClass=true +# Use non-final resource IDs for faster incremental compilation. +android.nonFinalResIds=true + android.defaults.buildfeatures.buildconfig=true -android.nonFinalResIds=false