diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt index ecaeff8356ce..8801075662ae 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt @@ -134,7 +134,12 @@ class BrowserToolbarView( ThemeManager.resolveAttribute(R.attr.toolbarDivider, container.context) ) - display.urlFormatter = { url -> URLStringUtils.toDisplayUrl(url) } + display.urlFormatter = + if (context.settings().shouldStripUrl) { + url -> URLStringUtils.toDisplayUrl(url) + } else { + url -> url + } display.colors = display.colors.copy( text = primaryTextColor, diff --git a/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt index 3d586befd9c9..4686a04a799c 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt @@ -10,6 +10,7 @@ import android.os.Build.VERSION.SDK_INT import android.os.Bundle import androidx.appcompat.app.AppCompatDelegate import androidx.preference.PreferenceFragmentCompat +import androidx.preference.SwitchPreference import org.mozilla.fenix.R import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.toolbar.ToolbarPosition @@ -32,6 +33,12 @@ class CustomizationFragment : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.customization_preferences, rootKey) + + requirePreference(R.string.pref_key_strip_url).apply { + isChecked = context.settings().shouldStripUrl + + onPreferenceChangeListener = SharedPreferenceUpdater() + } } override fun onResume() { diff --git a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayViewHolder.kt b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayViewHolder.kt index b2aba6fef164..ee9abd086ec6 100644 --- a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayViewHolder.kt @@ -36,6 +36,7 @@ import org.mozilla.fenix.ext.removeAndDisable import org.mozilla.fenix.ext.removeTouchDelegate import org.mozilla.fenix.ext.showAndEnable import org.mozilla.fenix.ext.toShortUrl +import org.mozilla.fenix.ext.settings import org.mozilla.fenix.utils.Do import kotlin.math.max @@ -160,9 +161,16 @@ class TabTrayViewHolder( // is done in the toolbar and awesomebar: // https://github.com/mozilla-mobile/fenix/issues/1824 // https://github.com/mozilla-mobile/android-components/issues/6985 - urlView?.text = tab.url - .toShortUrl(itemView.context.components.publicSuffixList) - .take(MAX_URI_LENGTH) + urlView?.apply { + text = + if (context.settings().shouldStripUrl) { + tab.url + .toShortUrl(itemView.context.components.publicSuffixList) + .take(MAX_URI_LENGTH) + } else { + tab.url.take(MAX_URI_LENGTH) + } + } } @VisibleForTesting diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index ba2390b3f256..1297eb5bbe41 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -488,6 +488,11 @@ class Settings(private val appContext: Context) : PreferencesHolder { val toolbarPosition: ToolbarPosition get() = if (shouldUseBottomToolbar) ToolbarPosition.BOTTOM else ToolbarPosition.TOP + var shouldStripUrl by booleanPreference( + appContext.getPreferenceKey(R.string.pref_key_strip_url), + default = true + ) + /** * Check each active accessibility service to see if it can perform gestures, if any can, * then it is *likely* a switch service is enabled. We are assuming this to be the case based on #7486 diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 317651afdf09..3fdca594509d 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -112,6 +112,7 @@ pref_key_toolbar_top pref_key_toolbar_bottom + pref_key_strip_url pref_key_light_theme diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8a411160a917..41bed2780a83 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1259,6 +1259,10 @@ Username Password + + Strip HTTP/HTTPS/WWW from urls + + Enable to strip out HTTP/HTTPS/WWW from urls in toolbar and tab tray Re-enter your PIN diff --git a/app/src/main/res/xml/customization_preferences.xml b/app/src/main/res/xml/customization_preferences.xml index 19ab4c97f1a0..23434807b98b 100644 --- a/app/src/main/res/xml/customization_preferences.xml +++ b/app/src/main/res/xml/customization_preferences.xml @@ -43,5 +43,10 @@ +