Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
Closes #6009: Update strings for HTTPS-Only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo authored and mergify[bot] committed Dec 15, 2021
1 parent cd001e3 commit 4c7335c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
}
8 changes: 6 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ The new line here must be kept as the second half of the string is clickable for
<string name="preference_safe_browsing_summary">Block reported deceptive and attack sites, malware sites, and unwanted software sites.</string>
<!-- Title of the preference to enable "HTTPS-Only" mode -->
<string name="preference_https_only_title">HTTPS-Only Mode</string>
<!-- Description of the preference to enable "HTTPS-Only" mode. %1$s will get replaced with the name of the app. -->
<string name="preference_https_only_summary">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.</string>
<!-- Description of the preference to enable "HTTPS-Only" mode. -->
<string name="preference_https_only_summary2">Automatically attempts to connect to sites using HTTPS for increased security. HTTPS connections provide a secure, encrypted connection to websites you visit.</string>

<!-- Preference for exceptions tracking protection -->
<string name="preference_exceptions">Exceptions</string>
Expand Down Expand Up @@ -852,6 +852,10 @@ The new line here must be kept as the second half of the string is clickable for
<!-- Preference for using following device theme -->
<string name="preference_follow_device_theme">Follow device theme</string>

<!-- The title of the error page for websites that do not support HTTPS when HTTPS-Only is turned on -->
<string name="errorpage_httpsonly_title">The site you requested does not support HTTPS</string>
<!-- The text of the error page for websites that do not support HTTPS when HTTPS-Only is turned on. -->
<string name="errorpage_httpsonly_message">By default, %1$s attempts to connect using HTTPS for increased security. To change this setting or to learn more, go to Settings > Privacy &amp; Security > Security.</string>

<!-- Sessions List -->
<!-- Content description (not visible, for screen readers etc.): Button that closes a tab n the sessions list -->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/privacy_security_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,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" />
</androidx.preference.PreferenceCategory>

Expand Down

0 comments on commit 4c7335c

Please sign in to comment.