mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/2570: Hide 3-dots menu for all library items when in select mode (https://github.com/mozilla-mobile/fenix/pull/5699)
Removed items from RecyclerView cache to allow setting the new visibility Disabled hidden buttons, otherwise they could still be clicked
This commit is contained in:
parent
05b2e94dcf
commit
6875fa017a
18
app/src/main/java/org/mozilla/fenix/ext/ImageButton.kt
Normal file
18
app/src/main/java/org/mozilla/fenix/ext/ImageButton.kt
Normal file
@ -0,0 +1,18 @@
|
||||
/* 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/. */
|
||||
|
||||
package org.mozilla.fenix.ext
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageButton
|
||||
|
||||
fun ImageButton.hideAndDisable() {
|
||||
this.visibility = View.INVISIBLE
|
||||
this.isEnabled = false
|
||||
}
|
||||
|
||||
fun ImageButton.showAndEnable() {
|
||||
this.visibility = View.VISIBLE
|
||||
this.isEnabled = true
|
||||
}
|
@ -8,7 +8,6 @@ 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
|
||||
@ -21,9 +20,11 @@ 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 mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.asActivity
|
||||
import org.mozilla.fenix.ext.getColorFromAttr
|
||||
import org.mozilla.fenix.ext.hideAndDisable
|
||||
import org.mozilla.fenix.ext.showAndEnable
|
||||
|
||||
open class LibraryPageView(
|
||||
override val containerView: ViewGroup
|
||||
@ -40,8 +41,9 @@ open class LibraryPageView(
|
||||
context.getColorFromAttr(R.attr.primaryText),
|
||||
context.getColorFromAttr(R.attr.foundation)
|
||||
)
|
||||
libraryItemsList.children.forEach { item ->
|
||||
item.overflow_menu.visibility = View.VISIBLE
|
||||
libraryItemsList.setItemViewCacheSize(0)
|
||||
libraryItemsList.children.forEach {
|
||||
item -> item.overflow_menu.showAndEnable()
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,8 +56,9 @@ open class LibraryPageView(
|
||||
ContextCompat.getColor(context, R.color.white_color),
|
||||
context.getColorFromAttr(R.attr.accentHighContrast)
|
||||
)
|
||||
libraryItemsList.children.forEach { item ->
|
||||
item.overflow_menu.visibility = View.INVISIBLE
|
||||
libraryItemsList.setItemViewCacheSize(0)
|
||||
libraryItemsList.children.forEach {
|
||||
item -> item.overflow_menu.hideAndDisable()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@ import androidx.core.content.ContextCompat
|
||||
import mozilla.components.concept.storage.BookmarkNode
|
||||
import org.jetbrains.anko.image
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.hideAndDisable
|
||||
import org.mozilla.fenix.ext.showAndEnable
|
||||
import org.mozilla.fenix.library.LibrarySiteItemView
|
||||
import org.mozilla.fenix.library.SelectionHolder
|
||||
import org.mozilla.fenix.library.bookmarks.BookmarkViewInteractor
|
||||
@ -31,9 +33,10 @@ class BookmarkFolderViewHolder(
|
||||
|
||||
if (!item.inRoots()) {
|
||||
setupMenu(item)
|
||||
containerView.overflowView.visibility = when (selectionHolder.selectedItems.isEmpty()) {
|
||||
true -> View.VISIBLE
|
||||
false -> View.INVISIBLE
|
||||
if (selectionHolder.selectedItems.isEmpty()) {
|
||||
containerView.overflowView.showAndEnable()
|
||||
} else {
|
||||
containerView.overflowView.hideAndDisable()
|
||||
}
|
||||
} else {
|
||||
containerView.overflowView.visibility = View.GONE
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
package org.mozilla.fenix.library.bookmarks.viewholders
|
||||
|
||||
import android.view.View
|
||||
import mozilla.components.concept.storage.BookmarkNode
|
||||
import org.mozilla.fenix.ext.hideAndDisable
|
||||
import org.mozilla.fenix.ext.showAndEnable
|
||||
import org.mozilla.fenix.library.LibrarySiteItemView
|
||||
import org.mozilla.fenix.library.SelectionHolder
|
||||
import org.mozilla.fenix.library.bookmarks.BookmarkViewInteractor
|
||||
@ -23,9 +24,10 @@ class BookmarkItemViewHolder(
|
||||
|
||||
containerView.displayAs(LibrarySiteItemView.ItemType.SITE)
|
||||
|
||||
containerView.overflowView.visibility = when (selectionHolder.selectedItems.isEmpty()) {
|
||||
true -> View.VISIBLE
|
||||
false -> View.INVISIBLE
|
||||
if (selectionHolder.selectedItems.isEmpty()) {
|
||||
containerView.overflowView.showAndEnable()
|
||||
} else {
|
||||
containerView.overflowView.hideAndDisable()
|
||||
}
|
||||
setupMenu(item)
|
||||
containerView.titleView.text = if (item.title.isNullOrBlank()) item.url else item.title
|
||||
|
@ -7,7 +7,10 @@ package org.mozilla.fenix.library.history.viewholders
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.synthetic.main.history_list_item.view.*
|
||||
import kotlinx.android.synthetic.main.library_site_item.view.*
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.hideAndDisable
|
||||
import org.mozilla.fenix.ext.showAndEnable
|
||||
import org.mozilla.fenix.library.SelectionHolder
|
||||
import org.mozilla.fenix.library.history.HistoryInteractor
|
||||
import org.mozilla.fenix.library.history.HistoryItem
|
||||
@ -55,6 +58,11 @@ class HistoryListItemViewHolder(
|
||||
itemView.history_layout.setSelectionInteractor(item, selectionHolder, historyInteractor)
|
||||
itemView.history_layout.changeSelected(item in selectionHolder.selectedItems)
|
||||
itemView.history_layout.loadFavicon(item.url)
|
||||
if (mode === HistoryFragmentState.Mode.Normal) {
|
||||
itemView.overflow_menu.showAndEnable()
|
||||
} else {
|
||||
itemView.overflow_menu.hideAndDisable()
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleHeader(headerText: String?) {
|
||||
|
Loading…
Reference in New Issue
Block a user