pull/600/head
codrut.topliceanu 3 years ago committed by mergify[bot]
parent d10d841c11
commit 7ea5cdbe39

@ -6,7 +6,6 @@ package org.mozilla.fenix.home.recentbookmarks.view
import android.view.View import android.view.View
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.RecentBookmarkItemBinding import org.mozilla.fenix.databinding.RecentBookmarkItemBinding
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
@ -23,7 +22,6 @@ class RecentBookmarkItemViewHolder(
val binding = RecentBookmarkItemBinding.bind(view) val binding = RecentBookmarkItemBinding.bind(view)
binding.bookmarkTitle.text = bookmark.title ?: bookmark.url binding.bookmarkTitle.text = bookmark.title ?: bookmark.url
binding.bookmarkSubtitle.text = bookmark.url?.tryGetHostFromUrl() ?: bookmark.title ?: ""
binding.bookmarkItem.setOnClickListener { binding.bookmarkItem.setOnClickListener {
interactor.onRecentBookmarkClicked(bookmark) interactor.onRecentBookmarkClicked(bookmark)

@ -2,64 +2,40 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public <!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<com.google.android.material.card.MaterialCardView <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/bookmark_item" android:id="@+id/bookmark_item"
android:layout_width="@dimen/recent_bookmark_item_width" android:layout_width="@dimen/recent_bookmark_item_width"
android:layout_height="@dimen/recent_bookmark_item_height" android:layout_height="@dimen/recent_bookmark_item_height"
android:layout_marginEnd="8dp" android:padding="4dp">
android:layout_marginBottom="16dp"
android:scrollbars="none"
android:nestedScrollingEnabled="false"
android:importantForAccessibility="no"
style="@style/RecentBookmarks.FaviconCard">
<com.google.android.material.imageview.ShapeableImageView <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/favicon_image" android:id="@+id/favicon_image"
style="@style/recentBookmarkFavicon" style="@style/recentBookmarkFavicon"
android:layout_width="24dp" android:layout_width="0dp"
android:layout_height="24dp" android:layout_height="0dp"
android:layout_marginTop="24dp" android:scaleType="centerCrop"
android:layout_gravity="center_horizontal" /> android:paddingBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/bookmark_title"
<View app:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent" app:layout_constraintStart_toStartOf="parent"
android:layout_height="1dp" app:layout_constraintTop_toTopOf="parent" />
android:background="@color/tab_tray_item_divider_normal_theme"
android:importantForAccessibility="no"
android:layout_marginTop="72dp"
android:clickable="false"/>
<TextView <TextView
android:id="@+id/bookmark_title" android:id="@+id/bookmark_title"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="wrap_content"
android:layout_marginTop="72dp"
android:maxHeight="30dp"
android:paddingStart="16dp"
android:paddingTop="7dp"
android:paddingEnd="16dp"
android:scrollbars="none"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"
android:nestedScrollingEnabled="false"
android:importantForAccessibility="yes" android:importantForAccessibility="yes"
android:textAppearance="@style/recentBookmarkItemTitleText"
tools:text="Recently Saved bookmark item" />
<TextView
android:id="@+id/bookmark_subtitle"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_marginTop="105dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:scrollbars="none"
android:nestedScrollingEnabled="false" android:nestedScrollingEnabled="false"
android:scrollbars="none"
android:textAppearance="@style/recentBookmarkItemSubTitleText" android:textAppearance="@style/recentBookmarkItemSubTitleText"
tools:text="Subtitle text" app:layout_constraintBottom_toBottomOf="parent"
android:textColor="@color/home_recent_bookmarks_item_url" /> app:layout_constraintEnd_toEndOf="parent"
</com.google.android.material.card.MaterialCardView> app:layout_constraintStart_toStartOf="parent"
tools:text="Recently Saved bookmark item" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -94,7 +94,6 @@
<!-- Home screen --> <!-- Home screen -->
<color name="home_show_all_button_text">@color/photonLightGrey50</color> <color name="home_show_all_button_text">@color/photonLightGrey50</color>
<color name="home_recent_bookmarks_item_url">@color/photonLightGrey50</color>
<!-- Search Widget --> <!-- Search Widget -->
<color name="search_widget_background">@color/inset_dark_theme</color> <color name="search_widget_background">@color/inset_dark_theme</color>

@ -283,7 +283,6 @@
<!-- Home screen --> <!-- Home screen -->
<color name="home_show_all_button_text">@color/photonDarkGrey05</color> <color name="home_show_all_button_text">@color/photonDarkGrey05</color>
<color name="home_recent_bookmarks_item_url">@color/photonDarkGrey05</color>
<!-- Quick action buttons--> <!-- Quick action buttons-->

@ -95,11 +95,11 @@
<dimen name="home_item_elevation">5dp</dimen> <dimen name="home_item_elevation">5dp</dimen>
<!-- Home - Recently saved bookmarks --> <!-- Home - Recently saved bookmarks -->
<dimen name="recent_bookmark_item_height">128dp</dimen> <dimen name="recent_bookmark_item_height">132dp</dimen>
<dimen name="recent_bookmark_item_width">152dp</dimen> <dimen name="recent_bookmark_item_width">161dp</dimen>
<dimen name="recent_bookmark_item_favicon_height">72dp</dimen> <dimen name="recent_bookmark_item_favicon_height">72dp</dimen>
<dimen name="recent_bookmark_item_favicon_elevation">0dp</dimen> <dimen name="recent_bookmark_item_favicon_elevation">0dp</dimen>
<dimen name="recent_bookmark_item_favicon_corner_size">4dp</dimen> <dimen name="recent_bookmark_item_favicon_corner_size">8dp</dimen>
<!-- Browser Fragment --> <!-- Browser Fragment -->
<!--The size of the gap between the tab preview and content layout.--> <!--The size of the gap between the tab preview and content layout.-->

@ -680,15 +680,6 @@
<item name="cornerSize">@dimen/top_sites_favicon_corner_size</item> <item name="cornerSize">@dimen/top_sites_favicon_corner_size</item>
</style> </style>
<style name="RecentBookmarks.FaviconCard" parent="Mozac.Widgets.Favicon">
<item name="android:layout_width">@dimen/recent_bookmark_item_width</item>
<item name="android:layout_height">@dimen/recent_bookmark_item_height</item>
<item name="android:padding">16dp</item>
<item name="cardBackgroundColor">?mozac_widget_favicon_background_color</item>
<item name="cardCornerRadius">8dp</item>
<item name="cardElevation">@dimen/home_item_elevation</item>
</style>
<style name="recentBookmarkFavicon"> <style name="recentBookmarkFavicon">
<item name="android:layout_width">@dimen/recent_bookmark_item_width</item> <item name="android:layout_width">@dimen/recent_bookmark_item_width</item>
<item name="android:layout_height">@dimen/recent_bookmark_item_favicon_height</item> <item name="android:layout_height">@dimen/recent_bookmark_item_favicon_height</item>
@ -703,15 +694,6 @@
<item name="cornerSize">@dimen/recent_bookmark_item_favicon_corner_size</item> <item name="cornerSize">@dimen/recent_bookmark_item_favicon_corner_size</item>
</style> </style>
<style name="recentBookmarkItemTitleText" parent="Body16TextStyle">
<item name="android:gravity">start</item>
<item name="android:textAlignment">gravity</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">?primaryText</item>
<item name="android:ellipsize">end</item>
<item name="android:maxLines">1</item>
</style>
<style name="recentBookmarkItemSubTitleText" parent="Body12TextStyle"> <style name="recentBookmarkItemSubTitleText" parent="Body12TextStyle">
<item name="android:gravity">start</item> <item name="android:gravity">start</item>
<item name="android:textColor">?primaryText</item> <item name="android:textColor">?primaryText</item>

@ -8,7 +8,6 @@ import android.view.LayoutInflater
import io.mockk.mockk import io.mockk.mockk
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
@ -65,13 +64,10 @@ class RecentBookmarkItemViewHolderTest {
} }
@Test @Test
fun `GIVEN a bookmark exists in the list THEN set the title text and subtitle from item`() { fun `GIVEN a bookmark exists in the list THEN set the title text`() {
RecentBookmarkItemViewHolder(binding.root, interactor).bind(bookmarkWithUrl) RecentBookmarkItemViewHolder(binding.root, interactor).bind(bookmarkWithUrl)
val hostFromUrl = bookmarkWithUrl.url?.tryGetHostFromUrl()
Assert.assertEquals(bookmarkWithUrl.title, binding.bookmarkTitle.text) Assert.assertEquals(bookmarkWithUrl.title, binding.bookmarkTitle.text)
Assert.assertEquals(hostFromUrl, binding.bookmarkSubtitle.text)
} }
@Test @Test

Loading…
Cancel
Save