From 05857ba55db5e173477f017cdc6757654d4486cc Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Thu, 10 Sep 2020 16:25:40 -0400 Subject: [PATCH] For #14145 - Add pinned badge for pinned sites --- .../topsites/TopSiteItemViewHolder.kt | 11 ++++- app/src/main/res/drawable/ic_pin.xml | 13 ++++++ app/src/main/res/layout/top_site_item.xml | 43 +++++++++++++++---- app/src/main/res/values/dimens.xml | 3 +- 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 app/src/main/res/drawable/ic_pin.xml diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt index af5bb1de53..ff7df347fa 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt @@ -16,6 +16,7 @@ import mozilla.components.browser.menu.item.SimpleBrowserMenuItem import mozilla.components.feature.top.sites.TopSite import mozilla.components.feature.top.sites.TopSite.Type.DEFAULT import mozilla.components.feature.top.sites.TopSite.Type.FRECENT +import mozilla.components.feature.top.sites.TopSite.Type.PINNED import org.mozilla.fenix.R import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.loadIntoView @@ -54,8 +55,14 @@ class TopSiteItemViewHolder( } fun bind(topSite: TopSite) { - this.topSite = topSite top_site_title.text = topSite.title + + pin_indicator.visibility = if (topSite.type == PINNED) { + View.VISIBLE + } else { + View.GONE + } + when (topSite.url) { SupportUtils.POCKET_TRENDING_URL -> { favicon_image.setImageDrawable(getDrawable(itemView.context, R.drawable.ic_pocket)) @@ -64,6 +71,8 @@ class TopSiteItemViewHolder( itemView.context.components.core.icons.loadIntoView(favicon_image, topSite.url) } } + + this.topSite = topSite } private fun onTouchEvent( diff --git a/app/src/main/res/drawable/ic_pin.xml b/app/src/main/res/drawable/ic_pin.xml new file mode 100644 index 0000000000..6d28ef432f --- /dev/null +++ b/app/src/main/res/drawable/ic_pin.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/app/src/main/res/layout/top_site_item.xml b/app/src/main/res/layout/top_site_item.xml index 84c9264805..17be2c75de 100644 --- a/app/src/main/res/layout/top_site_item.xml +++ b/app/src/main/res/layout/top_site_item.xml @@ -2,30 +2,57 @@ - - + android:importantForAccessibility="no" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@id/favicon_image" + tools:ignore="SmallSp" /> - + + + + + + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 20c024b775..207f1dfeec 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -174,7 +174,8 @@ 40dp 4dp 64dp - 12dp + 8dp + 12dp 8dp