For #2435 - adds URL to bookmarks in library
parent
d7d470d5e6
commit
cc03aeb9f0
|
@ -4,9 +4,11 @@
|
|||
|
||||
package org.mozilla.fenix.library.bookmarks
|
||||
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.Observer
|
||||
|
@ -132,8 +134,16 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
|
|||
@Suppress("ComplexMethod")
|
||||
override fun bind(item: BookmarkNode, mode: BookmarkState.Mode, selected: Boolean) {
|
||||
|
||||
val shiftThreeDp = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, TWO_DIGIT_PADDING, containerView!!.context.resources.displayMetrics
|
||||
).toInt()
|
||||
val params = bookmark_title.getLayoutParams() as ViewGroup.MarginLayoutParams
|
||||
params.topMargin = shiftThreeDp
|
||||
bookmark_title.setLayoutParams(params)
|
||||
|
||||
bookmark_favicon.visibility = View.VISIBLE
|
||||
bookmark_title.visibility = View.VISIBLE
|
||||
bookmark_url.visibility = View.VISIBLE
|
||||
bookmark_overflow.visibility = View.VISIBLE
|
||||
bookmark_separator.visibility = View.GONE
|
||||
bookmark_layout.isClickable = true
|
||||
|
@ -172,6 +182,7 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
|
|||
)
|
||||
}
|
||||
bookmark_title.text = if (item.title.isNullOrBlank()) item.url else item.title
|
||||
bookmark_url.text = item.url
|
||||
updateUrl(item, mode, selected)
|
||||
}
|
||||
|
||||
|
@ -230,6 +241,8 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
|
|||
}
|
||||
|
||||
companion object {
|
||||
internal const val TWO_DIGIT_PADDING = 2F
|
||||
|
||||
val viewType = ViewType.ITEM
|
||||
}
|
||||
}
|
||||
|
@ -244,9 +257,15 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
|
|||
|
||||
override fun bind(item: BookmarkNode, mode: BookmarkState.Mode, selected: Boolean) {
|
||||
|
||||
val constraintSet = ConstraintSet()
|
||||
constraintSet.clone(bookmark_layout)
|
||||
constraintSet.connect(bookmark_title.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM);
|
||||
constraintSet.applyTo(bookmark_layout);
|
||||
|
||||
bookmark_favicon.setImageResource(R.drawable.ic_folder_icon)
|
||||
bookmark_favicon.visibility = View.VISIBLE
|
||||
bookmark_title.visibility = View.VISIBLE
|
||||
bookmark_url.visibility = View.GONE
|
||||
bookmark_overflow.visibility = View.VISIBLE
|
||||
bookmark_separator.visibility = View.GONE
|
||||
bookmark_layout.isClickable = true
|
||||
|
@ -342,6 +361,7 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
|
|||
|
||||
bookmark_favicon.visibility = View.GONE
|
||||
bookmark_title.visibility = View.GONE
|
||||
bookmark_url.visibility = View.GONE
|
||||
bookmark_overflow.increaseTapArea(bookmarkOverflowExtraDips)
|
||||
bookmark_overflow.visibility = View.VISIBLE
|
||||
bookmark_separator.visibility = View.VISIBLE
|
||||
|
|
|
@ -11,42 +11,53 @@
|
|||
android:layout_height="56dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingStart="16dp"
|
||||
android:padding="4dp"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bookmark_favicon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/favicon_background"
|
||||
android:importantForAccessibility="no"
|
||||
android:padding="10dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
tools:src="@drawable/ic_folder_icon" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookmark_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:textSize="16sp"
|
||||
android:singleLine="true"
|
||||
android:textAlignment="viewStart"
|
||||
android:textSize="18sp"
|
||||
android:textColor="?primaryText"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/bookmark_overflow"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/bookmark_favicon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Internet" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookmark_url"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?secondaryText"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toStartOf="@id/bookmark_overflow"
|
||||
app:layout_constraintStart_toEndOf="@id/bookmark_favicon"
|
||||
app:layout_constraintTop_toBottomOf="@id/bookmark_title" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/bookmark_overflow"
|
||||
android:layout_width="@dimen/glyph_button_width"
|
||||
|
|
Loading…
Reference in New Issue