Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
0bd7546e
Commit
0bd7546e
authored
Apr 07, 2020
by
David Walsh
Browse files
For #6564 - Only display URL hostname for tabstray
parent
2f4dba99
Changes
4
Hide whitespace changes
Inline
Side-by-side
components/browser/tabstray/build.gradle
View file @
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
...
...
components/browser/tabstray/src/main/java/mozilla/components/browser/tabstray/TabViewHolder.kt
View file @
0bd7546e
...
...
@@ -15,6 +15,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.
...
...
@@ -47,7 +48,7 @@ class TabViewHolder(
}
titleView
.
text
=
title
urlView
?.
text
=
tab
.
url
urlView
?.
text
=
tab
.
url
.
tryGetHostFromUrl
()
itemView
.
setOnClickListener
{
observable
.
notifyObservers
{
onTabSelected
(
tab
)
}
...
...
components/browser/tabstray/src/test/java/mozilla/components/browser/tabstray/TabViewHolderTest.kt
View file @
0bd7546e
...
...
@@ -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
...
...
docs/changelog.md
View file @
0bd7546e
...
...
@@ -81,6 +81,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
# 37.0.0
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment