From edf5fb7a07a66160217448d61c2660ea054b6749 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Wed, 15 Dec 2021 15:14:57 +0100 Subject: [PATCH] Closes #6009: Update strings for HTTPS-Only mode --- .../focus/engine/AppContentInterceptor.kt | 28 ++++++++++++++++++- .../focus/settings/HttpsOnlyModePreference.kt | 6 ---- app/src/main/res/values/strings.xml | 8 ++++-- .../res/xml/privacy_security_settings.xml | 2 +- buildSrc/src/main/java/AndroidComponents.kt | 2 +- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/mozilla/focus/engine/AppContentInterceptor.kt b/app/src/main/java/org/mozilla/focus/engine/AppContentInterceptor.kt index 0039c28b507..7ce17da80ce 100644 --- a/app/src/main/java/org/mozilla/focus/engine/AppContentInterceptor.kt +++ b/app/src/main/java/org/mozilla/focus/engine/AppContentInterceptor.kt @@ -11,6 +11,7 @@ import mozilla.components.browser.errorpages.ErrorPages import mozilla.components.browser.errorpages.ErrorType import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.request.RequestInterceptor +import org.mozilla.focus.R import org.mozilla.focus.activity.CrashListActivity import org.mozilla.focus.browser.LocalizedContent import org.mozilla.focus.ext.components @@ -71,9 +72,34 @@ class AppContentInterceptor( errorType: ErrorType, uri: String? ): RequestInterceptor.ErrorResponse { - val errorPage = ErrorPages.createUrlEncodedErrorPage(context, errorType, uri) + val errorPage = ErrorPages.createUrlEncodedErrorPage( + context, + errorType, + uri, + titleOverride = { type -> getErrorPageTitle(context, type) }, + descriptionOverride = { type -> getErrorPageDescription(context, type) } + ) return RequestInterceptor.ErrorResponse(errorPage) } override fun interceptsAppInitiatedRequests() = true } + +private fun getErrorPageTitle(context: Context, type: ErrorType): String? { + if (type == ErrorType.ERROR_HTTPS_ONLY) { + return context.getString(R.string.errorpage_httpsonly_title) + } + // Returning `null` here will let the component use its default title for this error type + return null +} + +private fun getErrorPageDescription(context: Context, type: ErrorType): String? { + if (type == ErrorType.ERROR_HTTPS_ONLY) { + return context.getString( + R.string.errorpage_httpsonly_message, + context.getString(R.string.app_name) + ) + } + // Returning `null` here will let the component use its default description for this error type + return null +} diff --git a/app/src/main/java/org/mozilla/focus/settings/HttpsOnlyModePreference.kt b/app/src/main/java/org/mozilla/focus/settings/HttpsOnlyModePreference.kt index 347708ef104..441535db658 100644 --- a/app/src/main/java/org/mozilla/focus/settings/HttpsOnlyModePreference.kt +++ b/app/src/main/java/org/mozilla/focus/settings/HttpsOnlyModePreference.kt @@ -7,7 +7,6 @@ package org.mozilla.focus.settings import android.content.Context import android.util.AttributeSet import mozilla.components.concept.engine.Engine -import org.mozilla.focus.R import org.mozilla.focus.ext.components import org.mozilla.focus.utils.Features @@ -37,9 +36,4 @@ class HttpsOnlyModePreference( true } } - - override fun getDescription(): String { - val appName = context.getString(R.string.app_name) - return context.getString(R.string.preference_https_only_summary, appName) - } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 20c6a30b51e..d9d09b00cdd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -754,8 +754,8 @@ The new line here must be kept as the second half of the string is clickable for Block reported deceptive and attack sites, malware sites, and unwanted software sites. HTTPS-Only Mode - - HTTPS provides a secure, encrypted connection between %1$s and the websites you visit. Most websites support HTTPS, and if HTTPS-Only Mode is enabled, then %1$s will upgrade all connections to HTTPS. + + Automatically attempts to connect to sites using HTTPS for increased security. HTTPS connections provide a secure, encrypted connection to websites you visit. Exceptions @@ -834,6 +834,10 @@ The new line here must be kept as the second half of the string is clickable for Follow device theme + + The site you requested does not support HTTPS + + By default, %1$s attempts to connect using HTTPS for increased security. To change this setting or to learn more, go to Settings > Privacy & Security > Security. diff --git a/app/src/main/res/xml/privacy_security_settings.xml b/app/src/main/res/xml/privacy_security_settings.xml index 92e17babf53..bbdb187c2d4 100644 --- a/app/src/main/res/xml/privacy_security_settings.xml +++ b/app/src/main/res/xml/privacy_security_settings.xml @@ -119,7 +119,7 @@ android:defaultValue="true" android:key="@string/pref_key_https_only" android:layout="@layout/focus_preference_no_icon" - android:summary="@string/preference_https_only_summary" + android:summary="@string/preference_https_only_summary2" android:title="@string/preference_https_only_title" /> diff --git a/buildSrc/src/main/java/AndroidComponents.kt b/buildSrc/src/main/java/AndroidComponents.kt index 60eb7a5fa14..7915f74aba0 100644 --- a/buildSrc/src/main/java/AndroidComponents.kt +++ b/buildSrc/src/main/java/AndroidComponents.kt @@ -3,5 +3,5 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ object AndroidComponents { - const val VERSION = "97.0.20211213190046" + const val VERSION = "97.0.20211215133053" }