|
|
@ -8,13 +8,15 @@ import android.content.Context
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.view.View
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
|
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import kotlinx.android.synthetic.main.checkbox_item.view.*
|
|
|
|
import kotlinx.android.synthetic.main.checkbox_item.view.*
|
|
|
|
import kotlinx.android.synthetic.main.tab_tray_item.view.*
|
|
|
|
import kotlinx.android.synthetic.main.tab_tray_item.view.*
|
|
|
|
import mozilla.components.browser.tabstray.TabViewHolder
|
|
|
|
import mozilla.components.browser.tabstray.TabViewHolder
|
|
|
|
import mozilla.components.browser.tabstray.TabsAdapter
|
|
|
|
import mozilla.components.browser.tabstray.TabsAdapter
|
|
|
|
|
|
|
|
import mozilla.components.concept.base.images.ImageLoader
|
|
|
|
import mozilla.components.concept.tabstray.Tab
|
|
|
|
import mozilla.components.concept.tabstray.Tab
|
|
|
|
import mozilla.components.concept.tabstray.Tabs
|
|
|
|
import mozilla.components.concept.tabstray.Tabs
|
|
|
|
import mozilla.components.concept.base.images.ImageLoader
|
|
|
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
@ -36,6 +38,7 @@ class FenixTabsAdapter(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
private lateinit var tabsList: RecyclerView
|
|
|
|
var tabTrayInteractor: TabTrayInteractor? = null
|
|
|
|
var tabTrayInteractor: TabTrayInteractor? = null
|
|
|
|
|
|
|
|
|
|
|
|
private val mode: TabTrayDialogFragmentState.Mode?
|
|
|
|
private val mode: TabTrayDialogFragmentState.Mode?
|
|
|
@ -67,10 +70,28 @@ class FenixTabsAdapter(
|
|
|
|
|
|
|
|
|
|
|
|
override fun onBindViewHolder(holder: TabViewHolder, position: Int) {
|
|
|
|
override fun onBindViewHolder(holder: TabViewHolder, position: Int) {
|
|
|
|
super.onBindViewHolder(holder, position)
|
|
|
|
super.onBindViewHolder(holder, position)
|
|
|
|
val newIndex = tabCount - position - 1
|
|
|
|
|
|
|
|
(holder as TabTrayViewHolder).updateAccessibilityRowInfo(
|
|
|
|
val isListTabView = context.settings().listTabView
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val itemIndex: Int
|
|
|
|
|
|
|
|
val rowIndex: Int
|
|
|
|
|
|
|
|
val columnIndex: Int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isListTabView) {
|
|
|
|
|
|
|
|
itemIndex = tabCount - position - 1
|
|
|
|
|
|
|
|
rowIndex = itemIndex
|
|
|
|
|
|
|
|
columnIndex = 1
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
val columnsCount = (tabsList.layoutManager as GridLayoutManager).spanCount
|
|
|
|
|
|
|
|
itemIndex = position
|
|
|
|
|
|
|
|
rowIndex = itemIndex / columnsCount
|
|
|
|
|
|
|
|
columnIndex = itemIndex % columnsCount
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(holder as TabTrayViewHolder).updateAccessibilityCollectionItemInfo(
|
|
|
|
holder.itemView,
|
|
|
|
holder.itemView,
|
|
|
|
newIndex,
|
|
|
|
rowIndex,
|
|
|
|
|
|
|
|
columnIndex,
|
|
|
|
selectedItems.contains(holder.tab)
|
|
|
|
selectedItems.contains(holder.tab)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -107,6 +128,11 @@ class FenixTabsAdapter(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
|
|
|
|
|
|
|
|
super.onAttachedToRecyclerView(recyclerView)
|
|
|
|
|
|
|
|
tabsList = recyclerView
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun showCheckedIfSelected(tab: Tab, view: View) {
|
|
|
|
private fun showCheckedIfSelected(tab: Tab, view: View) {
|
|
|
|
val shouldBeChecked =
|
|
|
|
val shouldBeChecked =
|
|
|
|
mode is TabTrayDialogFragmentState.Mode.MultiSelect && selectedItems.contains(tab)
|
|
|
|
mode is TabTrayDialogFragmentState.Mode.MultiSelect && selectedItems.contains(tab)
|
|
|
|