For #10504 - opens the tab tray and filters the tab based on the browser mode
parent
a674c5dfe7
commit
c32904a1d0
|
@ -14,6 +14,7 @@ import kotlinx.android.synthetic.main.component_tabstray.view.*
|
|||
import kotlinx.android.synthetic.main.fragment_tab_tray_dialog.*
|
||||
import kotlinx.android.synthetic.main.fragment_tab_tray_dialog.view.*
|
||||
import mozilla.components.concept.tabstray.Tab
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
|
||||
|
@ -38,7 +39,11 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
tabTrayView = TabTrayView(view.tabLayout, this)
|
||||
tabTrayView = TabTrayView(
|
||||
view.tabLayout,
|
||||
this,
|
||||
(activity as HomeActivity).browsingModeManager.mode.isPrivate
|
||||
)
|
||||
|
||||
tabLayout.setOnClickListener { dismissAllowingStateLoss() }
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ interface TabTrayInteractor {
|
|||
*/
|
||||
class TabTrayView(
|
||||
private val container: ViewGroup,
|
||||
private val interactor: TabTrayInteractor
|
||||
private val interactor: TabTrayInteractor,
|
||||
private val isPrivate: Boolean
|
||||
) : LayoutContainer, TabsTray.Observer, TabLayout.OnTabSelectedListener {
|
||||
val fabView = LayoutInflater.from(container.context)
|
||||
.inflate(R.layout.component_tabstray_fab, container, true)
|
||||
|
@ -47,7 +48,7 @@ class TabTrayView(
|
|||
get() = container
|
||||
|
||||
init {
|
||||
fabView.new_tab_button.compatElevation = 80.0f
|
||||
fabView.new_tab_button.compatElevation = 41.0f
|
||||
|
||||
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
|
@ -65,13 +66,23 @@ class TabTrayView(
|
|||
}
|
||||
})
|
||||
|
||||
val selectedTabIndex = if (!isPrivate) {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
|
||||
view.tab_layout.getTabAt(selectedTabIndex)?.also {
|
||||
view.tab_layout.selectTab(it, true)
|
||||
}
|
||||
|
||||
view.tab_layout.addOnTabSelectedListener(this)
|
||||
|
||||
tabsFeature = TabsFeature(
|
||||
view.tabsTray,
|
||||
view.context.components.core.store,
|
||||
view.context.components.useCases.tabsUseCases,
|
||||
{ true },
|
||||
{ it.content.private == isPrivate },
|
||||
{ })
|
||||
|
||||
(view.tabsTray as? BrowserTabsTray)?.also { tray ->
|
||||
|
@ -109,4 +120,4 @@ class TabTrayView(
|
|||
|
||||
tabsFeature.filterTabs(filter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue