Commit 52ca085f authored by MozLando's avatar MozLando
Browse files

Merge #6566



6566: For #6564 - Only display URL hostname for tabstray r=jonalmeida a=darkwing

Fixes #6564. We don't want the entire URL, just the hostname, per @topotropic's direction.
Co-authored-by: default avatarDavid Walsh <davidwalsh83@gmail.com>
parents c5c42d17 0bd7546e
......@@ -31,6 +31,7 @@ dependencies {
implementation project(':ui-icons')
implementation project(':ui-colors')
implementation project(':support-base')
implementation project(':support-ktx')
implementation Dependencies.androidx_appcompat
implementation Dependencies.androidx_cardview
......
......@@ -14,6 +14,7 @@ import mozilla.components.browser.tabstray.thumbnail.TabThumbnailView
import mozilla.components.concept.tabstray.Tab
import mozilla.components.concept.tabstray.TabsTray
import mozilla.components.support.base.observer.Observable
import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl
/**
* A RecyclerView ViewHolder implementation for "tab" items.
......@@ -43,7 +44,7 @@ class TabViewHolder(
}
titleView.text = title
urlView?.text = tab.url
urlView?.text = tab.url.tryGetHostFromUrl()
itemView.setOnClickListener {
observable.notifyObservers { onTabSelected(tab) }
......
......@@ -40,7 +40,19 @@ class TabViewHolderTest {
holder.bind(session, isSelected = false, observable = mock())
assertEquals("https://www.mozilla.org", titleView.text)
assertEquals("https://www.mozilla.org", urlView.text)
assertEquals("www.mozilla.org", urlView.text)
}
@Test
fun `URL text is set to tab URL when exception is thrown`() {
val view = LayoutInflater.from(testContext).inflate(R.layout.mozac_browser_tabstray_item, null)
val urlView = view.findViewById<TextView>(R.id.mozac_browser_tabstray_url)
val holder = TabViewHolder(view, mockTabsTrayWithStyles())
val session = Tab("a", "about:home")
holder.bind(session, isSelected = false, observable = mock())
assertEquals("about:home", urlView.text)
}
@Test
......@@ -96,7 +108,7 @@ class TabViewHolderTest {
holder.bind(session, isSelected = true, observable = registry)
assertEquals(session.url, titleView.text)
assertEquals(session.url, urlView.text)
assertEquals("www.mozilla.org", urlView.text)
}
@Test
......@@ -116,7 +128,7 @@ class TabViewHolderTest {
holder.bind(session, isSelected = true, observable = registry)
assertEquals("Mozilla Firefox", titleView.text)
assertEquals("https://www.mozilla.org", urlView.text)
assertEquals("www.mozilla.org", urlView.text)
}
@Test
......
......@@ -99,6 +99,7 @@ permalink: /changelog/
* Added ability to let consumers pass a custom layout of `TabViewHolder` in order to control layout inflation and view binding.
* Added an optional URL view to the `TabViewHolder` to display the URL.
* Will expose a new `layout` parameter which allows consumers to change the tabs tray layout.
* Will only display a URL's hostname instead of the entire URL
* **browser-session**
* ⚠️ **This is a breaking change**: `SessionManager.runWithSessionIdOrSelected` now returns the result from the `block` it executes. This is consistent with `runWithSession`.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment