Merge remote-tracking branch 'hakkikaancaliskan/strip-url-pref' into fork

pull/21/head fork-5
Adam Novak 4 years ago
commit 10c43fdbab

@ -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,

@ -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<SwitchPreference>(R.string.pref_key_strip_url).apply {
isChecked = context.settings().shouldStripUrl
onPreferenceChangeListener = SharedPreferenceUpdater()
}
}
override fun onResume() {

@ -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

@ -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

@ -112,6 +112,7 @@
<!-- Toolbar Settings -->
<string name="pref_key_toolbar_top" translatable="false">pref_key_toolbar_top</string>
<string name="pref_key_toolbar_bottom" translatable="false">pref_key_toolbar_bottom</string>
<string name="pref_key_strip_url" translatable="false">pref_key_strip_url</string>
<!-- Theme Settings -->
<string name="pref_key_light_theme" translatable="false">pref_key_light_theme</string>

@ -1259,6 +1259,10 @@
<string name="preferences_passwords_saved_logins_username">Username</string>
<!-- The header for the password for a login -->
<string name="preferences_passwords_saved_logins_password">Password</string>
<!-- Title for strip url preference in customization settings -->
<string name="preferences_strip_url_title">Strip HTTP/HTTPS/WWW from urls</string>
<!-- Description for strip url preference in customization settings -->
<string name="preferences_strip_url_description">Enable to strip out HTTP/HTTPS/WWW from urls in toolbar and tab tray</string>
<!-- Message displayed in security prompt to reenter a secret pin to access saved logins -->
<string name="preferences_passwords_saved_logins_enter_pin">Re-enter your PIN</string>
<!-- Message displayed in security prompt to access saved logins -->

@ -43,5 +43,10 @@
<org.mozilla.fenix.settings.RadioButtonPreference
android:key="@string/pref_key_toolbar_bottom"
android:title="@string/preference_bottom_toolbar" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/pref_key_strip_url"
android:summary="@string/preferences_strip_url_description"
android:title="@string/preferences_strip_url_title" />
</androidx.preference.PreferenceCategory>
</androidx.preference.PreferenceScreen>

Loading…
Cancel
Save