[components] For https://github.com/mozilla-mobile/android-components/issues/6324 Allow customization of display url in toolbar

This commit is contained in:
Kate Glazko
2020-02-21 10:04:43 -08:00
parent 20078a6f87
commit ff29354b85
6 changed files with 82 additions and 3 deletions

View File

@@ -42,6 +42,8 @@ dependencies {
implementation project(':support-ktx')
implementation project(':support-utils')
implementation Dependencies.kotlin_stdlib
implementation Dependencies.kotlin_coroutines

View File

@@ -40,6 +40,7 @@ import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature
import mozilla.components.support.ktx.android.content.res.resolveAttribute
import mozilla.components.support.ktx.android.view.hideKeyboard
import mozilla.components.ui.tabcounter.TabCounter
import mozilla.components.support.utils.URLStringUtils
/**
* This sample application shows how to use and customize the browser-toolbar component.
@@ -304,6 +305,10 @@ class ToolbarActivity : AppCompatActivity() {
hint = 0x1E15141a.toInt()
)
toolbar.display.urlFormatter = { url ->
URLStringUtils.toDisplayUrl(url)
}
toolbar.display.setUrlBackground(getDrawable(R.drawable.fenix_url_background))
toolbar.display.hint = "Search or enter address"
toolbar.display.setOnUrlLongClickListener {