For #2570: Hide 3-dots menu when in select mode for bookmarks and history (#5173)

Show or hide overflow menu for entire list is triggered when mode is changed
For bookmarks, due to implementation of selection and diffUtil,
additional check is necessary for current item (last selected) that is redrawn
nightly-build-test
Mihai Adrian 5 years ago committed by Sawyer Blatz
parent df8aed9158
commit c8bc144114

@ -8,6 +8,7 @@ import android.content.Context
import android.graphics.ColorFilter
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.view.View
import android.view.ViewGroup
import android.widget.ActionMenuView
import android.widget.ImageButton
@ -15,8 +16,11 @@ import androidx.annotation.ColorInt
import androidx.appcompat.view.menu.ActionMenuItemView
import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
import androidx.core.view.children
import androidx.core.view.forEach
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.library_site_item.view.*
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.asActivity
import org.mozilla.fenix.ext.getColorFromAttr
@ -27,20 +31,32 @@ open class LibraryPageView(
protected val context: Context inline get() = containerView.context
protected val activity = context.asActivity()
protected fun setUiForNormalMode(title: String?) {
protected fun setUiForNormalMode(
title: String?,
libraryItemsList: RecyclerView
) {
activity?.title = title
setToolbarColors(
context.getColorFromAttr(R.attr.primaryText),
context.getColorFromAttr(R.attr.foundation)
)
libraryItemsList.children.forEach {
item -> item.overflow_menu.visibility = View.VISIBLE
}
}
protected fun setUiForSelectingMode(title: String?) {
protected fun setUiForSelectingMode(
title: String?,
libraryItemsList: RecyclerView
) {
activity?.title = title
setToolbarColors(
ContextCompat.getColor(context, R.color.white_color),
context.getColorFromAttr(R.attr.accentHighContrast)
)
libraryItemsList.children.forEach {
item -> item.overflow_menu.visibility = View.INVISIBLE
}
}
/**

@ -125,7 +125,10 @@ class BookmarkView(
is BookmarkFragmentState.Mode.Normal ->
setUiForNormalMode(state.tree)
is BookmarkFragmentState.Mode.Selecting ->
setUiForSelectingMode(context.getString(R.string.bookmarks_multi_select_title, mode.selectedItems.size))
setUiForSelectingMode(
context.getString(R.string.bookmarks_multi_select_title, mode.selectedItems.size),
view.bookmark_list
)
}
}
@ -145,7 +148,8 @@ class BookmarkView(
private fun setUiForNormalMode(root: BookmarkNode?) {
super.setUiForNormalMode(
if (BookmarkRoot.Mobile.matches(root)) context.getString(R.string.library_bookmarks) else root?.title
if (BookmarkRoot.Mobile.matches(root)) context.getString(R.string.library_bookmarks) else root?.title,
view.bookmark_list
)
}

@ -31,6 +31,10 @@ class BookmarkFolderViewHolder(
if (!item.inRoots()) {
setupMenu(item)
containerView.overflowView.visibility = when (selectionHolder.selectedItems.isEmpty()) {
true -> View.VISIBLE
false -> View.INVISIBLE
}
} else {
containerView.overflowView.visibility = View.GONE
}

@ -4,6 +4,7 @@
package org.mozilla.fenix.library.bookmarks.viewholders
import android.view.View
import mozilla.components.concept.storage.BookmarkNode
import org.mozilla.fenix.library.LibrarySiteItemView
import org.mozilla.fenix.library.SelectionHolder
@ -22,6 +23,10 @@ class BookmarkItemViewHolder(
containerView.displayAs(LibrarySiteItemView.ItemType.SITE)
containerView.overflowView.visibility = when (selectionHolder.selectedItems.isEmpty()) {
true -> View.VISIBLE
false -> View.INVISIBLE
}
setupMenu(item)
containerView.titleView.text = if (item.title.isNullOrBlank()) item.url else item.title
containerView.urlView.text = item.url

@ -98,9 +98,13 @@ class HistoryView(
when (val mode = state.mode) {
is HistoryFragmentState.Mode.Normal ->
setUiForNormalMode(context.getString(R.string.library_history))
setUiForNormalMode(
context.getString(R.string.library_history),
view.history_list)
is HistoryFragmentState.Mode.Editing ->
setUiForSelectingMode(context.getString(R.string.history_multi_select_title, mode.selectedItems.size))
setUiForSelectingMode(
context.getString(R.string.history_multi_select_title, mode.selectedItems.size),
view.history_list)
}
}

Loading…
Cancel
Save