Skip to content

Commit

Permalink
For mozilla-mobile#21087: Updates Recently Saved design
Browse files Browse the repository at this point in the history
  • Loading branch information
codrut.topliceanu authored and mergify[bot] committed Sep 24, 2021
1 parent 2ea5d30 commit e8c3329
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package org.mozilla.fenix.home.recentbookmarks.view

import android.view.View
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl
import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.RecentBookmarkItemBinding
import org.mozilla.fenix.ext.components
Expand All @@ -23,7 +22,6 @@ class RecentBookmarkItemViewHolder(
val binding = RecentBookmarkItemBinding.bind(view)

binding.bookmarkTitle.text = bookmark.title ?: bookmark.url
binding.bookmarkSubtitle.text = bookmark.url?.tryGetHostFromUrl() ?: bookmark.title ?: ""

binding.bookmarkItem.setOnClickListener {
interactor.onRecentBookmarkClicked(bookmark)
Expand Down
64 changes: 20 additions & 44 deletions app/src/main/res/layout/recent_bookmark_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,40 @@
<!-- 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
- 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:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/bookmark_item"
android:layout_width="@dimen/recent_bookmark_item_width"
android:layout_height="@dimen/recent_bookmark_item_height"
android:layout_marginEnd="8dp"
android:layout_marginBottom="16dp"
android:scrollbars="none"
android:nestedScrollingEnabled="false"
android:importantForAccessibility="no"
style="@style/RecentBookmarks.FaviconCard">
android:padding="4dp">

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/favicon_image"
style="@style/recentBookmarkFavicon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="24dp"
android:layout_gravity="center_horizontal" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/tab_tray_item_divider_normal_theme"
android:importantForAccessibility="no"
android:layout_marginTop="72dp"
android:clickable="false"/>
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:paddingBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/bookmark_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/bookmark_title"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="72dp"
android:maxHeight="30dp"
android:paddingStart="16dp"
android:paddingTop="7dp"
android:paddingEnd="16dp"
android:scrollbars="none"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:nestedScrollingEnabled="false"
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:scrollbars="none"
android:nestedScrollingEnabled="false"
android:scrollbars="none"
android:textAppearance="@style/recentBookmarkItemSubTitleText"
tools:text="Subtitle text"
android:textColor="@color/home_recent_bookmarks_item_url" />
</com.google.android.material.card.MaterialCardView>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Recently Saved bookmark item" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 0 additions & 1 deletion app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@

<!-- Home screen -->
<color name="home_show_all_button_text">@color/photonLightGrey50</color>
<color name="home_recent_bookmarks_item_url">@color/photonLightGrey50</color>

<!-- Search Widget -->
<color name="search_widget_background">@color/inset_dark_theme</color>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@

<!-- Home screen -->
<color name="home_show_all_button_text">@color/photonDarkGrey05</color>
<color name="home_recent_bookmarks_item_url">@color/photonDarkGrey05</color>

<!-- Quick action buttons-->

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@
<dimen name="home_item_elevation">5dp</dimen>

<!-- Home - Recently saved bookmarks -->
<dimen name="recent_bookmark_item_height">128dp</dimen>
<dimen name="recent_bookmark_item_width">152dp</dimen>
<dimen name="recent_bookmark_item_height">132dp</dimen>
<dimen name="recent_bookmark_item_width">161dp</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_corner_size">4dp</dimen>
<dimen name="recent_bookmark_item_favicon_corner_size">8dp</dimen>

<!-- Browser Fragment -->
<!--The size of the gap between the tab preview and content layout.-->
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -680,15 +680,6 @@
<item name="cornerSize">@dimen/top_sites_favicon_corner_size</item>
</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">
<item name="android:layout_width">@dimen/recent_bookmark_item_width</item>
<item name="android:layout_height">@dimen/recent_bookmark_item_favicon_height</item>
Expand All @@ -703,15 +694,6 @@
<item name="cornerSize">@dimen/recent_bookmark_item_favicon_corner_size</item>
</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">
<item name="android:gravity">start</item>
<item name="android:textColor">?primaryText</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.view.LayoutInflater
import io.mockk.mockk
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert
import org.junit.Before
Expand Down Expand Up @@ -65,13 +64,10 @@ class RecentBookmarkItemViewHolderTest {
}

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

val hostFromUrl = bookmarkWithUrl.url?.tryGetHostFromUrl()

Assert.assertEquals(bookmarkWithUrl.title, binding.bookmarkTitle.text)
Assert.assertEquals(hostFromUrl, binding.bookmarkSubtitle.text)
}

@Test
Expand Down

0 comments on commit e8c3329

Please sign in to comment.