Skip to content

Commit

Permalink
Use different icons for bookmarks and favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisBarreiro committed Mar 21, 2024
1 parent 69e720e commit 0aa4b9a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface AutoComplete {
override val phrase: String,
val title: String,
val url: String,
val isFavorite: Boolean
) :
AutoCompleteSuggestion(phrase)

Expand Down Expand Up @@ -108,7 +109,7 @@ class AutoCompleteApi @Inject constructor(
.map { rankBookmarks(query, it) }
.flattenAsObservable { it }
.map {
AutoCompleteBookmarkSuggestion(phrase = it.url.toUri().toStringDropScheme(), title = it.title.orEmpty(), url = it.url)
AutoCompleteBookmarkSuggestion(phrase = it.url.toUri().toStringDropScheme(), title = it.title, url = it.url, isFavorite = false)
}
.distinctUntilChanged()
.take(2)
Expand All @@ -121,7 +122,7 @@ class AutoCompleteApi @Inject constructor(
.map { rankFavorites(query, it) }
.flattenAsObservable { it }
.map {
AutoCompleteBookmarkSuggestion(phrase = it.url.toUri().toStringDropScheme(), title = it.title.orEmpty(), url = it.url)
AutoCompleteBookmarkSuggestion(phrase = it.url.toUri().toStringDropScheme(), title = it.title, url = it.url, isFavorite = true)
}
.distinctUntilChanged()
.take(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ sealed class AutoCompleteViewHolder(itemView: View) : RecyclerView.ViewHolder(it
title.text = item.title
url.text = item.url

bookmarkIndicator.setImageResource(if (item.isFavorite) R.drawable.ic_bookmark_favorite_20 else R.drawable.ic_bookmark_20)
goToBookmarkImage.setOnClickListener { editableSearchClickListener(item) }
root.setOnClickListener { immediateSearchListener(item) }
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_bookmark_favorite_20.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M6.75,1C5.231,1 4,2.231 4,3.75V17.617C4,18.642 5.109,19.284 5.998,18.772L10,16.469L14.002,18.772C14.891,19.284 16,18.642 16,17.617V16.125C16,15.711 15.664,15.375 15.25,15.375C14.836,15.375 14.5,15.711 14.5,16.125V17.328L10.665,15.12C10.253,14.884 9.747,14.884 9.335,15.12L5.5,17.328V3.75C5.5,3.06 6.06,2.5 6.75,2.5H13.813C14.192,2.5 14.5,2.808 14.5,3.188V3.5C14.5,3.914 14.836,4.25 15.25,4.25C15.664,4.25 16,3.914 16,3.5V3.188C16,1.979 15.021,1 13.813,1H6.75ZM16.139,6.339C15.767,5.615 14.733,5.615 14.361,6.339L13.448,8.112L11.416,8.395C10.583,8.511 10.256,9.542 10.871,10.116L12.315,11.465L11.973,13.375C11.828,14.187 12.672,14.816 13.408,14.445L15.25,13.516L17.092,14.445C17.828,14.816 18.672,14.187 18.527,13.375L18.185,11.465L19.629,10.116C20.244,9.542 19.918,8.511 19.084,8.395L17.052,8.112L16.139,6.339ZM14.663,9.029L15.25,7.889L15.837,9.029C15.986,9.318 16.266,9.517 16.588,9.562L17.839,9.736L16.962,10.555C16.715,10.787 16.601,11.128 16.661,11.462L16.874,12.655L15.7,12.063C15.417,11.92 15.083,11.92 14.8,12.063L13.626,12.655L13.839,11.462C13.899,11.128 13.785,10.787 13.538,10.555L12.661,9.736L13.912,9.562C14.234,9.517 14.514,9.318 14.663,9.029Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
</vector>

0 comments on commit 0aa4b9a

Please sign in to comment.