From f7377fd19a601b61e45ce28cd2a72857a6f5ba84 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Thu, 25 Oct 2018 15:33:32 -0700 Subject: [PATCH] Load unspecified URLs as HTTPS by default. https://redmine.stoutner.com/issues/165 --- .../activities/ImportExportActivity.java | 15 ++++++++++---- .../activities/MainWebViewActivity.java | 4 ++-- app/src/main/res/values-es/strings.xml | 20 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 - 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java index 705a662b..26f2e1bc 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java @@ -132,10 +132,17 @@ public class ImportExportActivity extends AppCompatActivity implements ImportExp } }); - // Set the default download file path if the storage permission has not been granted. - if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { + // Set the initial file paths. + if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { // The storage permission has been granted. + // Create a string for the external public path. + String EXTERNAL_PUBLIC_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/" + getString(R.string.privacy_browser_settings); + + // Set the default path. + exportFileEditText.setText(EXTERNAL_PUBLIC_PATH); + importFileEditText.setText(EXTERNAL_PUBLIC_PATH); + } else { // The storage permission has not been granted. // Create a string for the external private path. - String EXTERNAL_PRIVATE_PATH = getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS) + "/Privacy Browser Backup"; + String EXTERNAL_PRIVATE_PATH = getApplicationContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS) + "/" + getString(R.string.privacy_browser_settings); // Set the default path. exportFileEditText.setText(EXTERNAL_PRIVATE_PATH); @@ -156,7 +163,7 @@ public class ImportExportActivity extends AppCompatActivity implements ImportExp intent.setType("*/*"); // Set the initial export file name. - intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.privacy_browser_backup)); + intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.privacy_browser_settings)); // Set the initial directory if API >= 26. if (Build.VERSION.SDK_INT >= 26) { diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index f2a422a2..9bd75895 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -3787,9 +3787,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Check to see if `unformattedUrlString` is a valid URL. Otherwise, convert it into a search. if ((Patterns.WEB_URL.matcher(unformattedUrlString).matches()) || (unformattedUrlString.startsWith("http://")) || (unformattedUrlString.startsWith("https://"))) { - // Add `http://` at the beginning if it is missing. Otherwise the app will segfault. + // Add `https://` at the beginning if it is missing. Otherwise the app will segfault. if (!unformattedUrlString.startsWith("http")) { - unformattedUrlString = "http://" + unformattedUrlString; + unformattedUrlString = "https://" + unformattedUrlString; } // Initialize `unformattedUrl`. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8cad4e19..97979b85 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -114,6 +114,7 @@ Favoritos Descargas Configuración + Importar/Exportar Guía Acerca de Borrar y salir @@ -312,6 +313,25 @@ Certificado SSL actual de la web Cargar una página web cifrada antes de abrir la configuración de dominio para rellenar el certificado SSL de la página web actual. + + Navegar + Acceder a los archivos en directorios públicos requiere el permiso de almacenamiento. De lo contrario, sólo funcionarán los directorios privados. + Exportar los ajustes + Importar los ajustes + Exportar nombre de archivo + Importar nombre de archivo + Exportar + Importar + Exportación exitosa. + Exportación fallida: + Importación fallida: + Los ajustes no pueden exportarse a esta ubicación porque no se ha concedido el permiso de almacenamiento. + Los ajustes no pueden importarse a esta ubicación porque no se ha concedido el permiso de almacenamiento. + no es una ubicación válida. + Permiso de almacenamiento + Navegador Privado necesita el permiso de almacenamiento para acceder a los directorios públicos. + Si se deniega, el directorio privado de la aplicación todavía puede utilizarse. + Guía de Navegador Privado Visión general diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1b011f47..8b07106c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -317,7 +317,6 @@ Browse Accessing files in public directories requires the storage permission. Otherwise only private directories will work. - Privacy Browser Backup Export Settings Import Settings Export file name -- 2.45.2