1
0
Fork 0

For 11031 - Fix landscape mode for tab tray (#11084)

master
David Walsh 2020-05-30 19:27:59 -05:00 committed by GitHub
parent c71638a9c9
commit 84d9e5b1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -4,6 +4,7 @@
package org.mozilla.fenix.tabtray
import android.content.res.Configuration
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -44,12 +45,21 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_tab_tray_dialog, container, false)
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
tabTrayView.expand()
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
tabTrayView = TabTrayView(
view.tabLayout,
this,
(activity as HomeActivity).browsingModeManager.mode.isPrivate
(activity as HomeActivity).browsingModeManager.mode.isPrivate,
requireContext().resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
)
tabLayout.setOnClickListener {

View File

@ -45,7 +45,8 @@ interface TabTrayInteractor {
class TabTrayView(
private val container: ViewGroup,
private val interactor: TabTrayInteractor,
private val isPrivate: Boolean
private val isPrivate: Boolean,
private val startingInLandscape: Boolean
) : LayoutContainer, TabsTray.Observer, TabLayout.OnTabSelectedListener {
val fabView = LayoutInflater.from(container.context)
.inflate(R.layout.component_tabstray_fab, container, true)
@ -113,8 +114,8 @@ class TabTrayView(
val selectedBrowserTabIndex = tabs
.indexOfFirst { it.id == view.context.components.core.store.state.selectedTabId }
if (tabs.size > EXPAND_AT_SIZE) {
behavior.state = BottomSheetBehavior.STATE_EXPANDED
if (tabs.size > EXPAND_AT_SIZE || startingInLandscape) {
expand()
}
(view.tabsTray as? BrowserTabsTray)?.also { tray ->
@ -161,6 +162,10 @@ class TabTrayView(
tabsFeature.start()
}
fun expand() {
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
override fun onTabSelected(tab: Tab) {
interactor.onTabSelected(tab)
}