2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

For #10504 - Adds tabTrayDialogInteractor to browserfragment

This commit is contained in:
Jeff Boek 2020-05-20 21:38:24 -07:00
parent cc6a380d45
commit 4e499e7a48
4 changed files with 29 additions and 3 deletions

View File

@ -64,6 +64,7 @@ import mozilla.components.support.base.feature.UserInteractionHandler
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded
import mozilla.components.support.ktx.android.view.hideKeyboard import mozilla.components.support.ktx.android.view.hideKeyboard
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.FeatureFlags import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.IntentReceiverActivity import org.mozilla.fenix.IntentReceiverActivity
@ -213,6 +214,16 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
onTabCounterClicked = { onTabCounterClicked = {
val tabTrayDialog = TabTrayDialogFragment() val tabTrayDialog = TabTrayDialogFragment()
tabTrayDialog.show(parentFragmentManager, null) tabTrayDialog.show(parentFragmentManager, null)
tabTrayDialog.interactor = object : TabTrayDialogFragment.Interactor {
override fun onTabSelected(tab: mozilla.components.concept.tabstray.Tab) {
tabTrayDialog.dismiss()
}
override fun onNewTabTapped() {
tabTrayDialog.dismiss()
findNavController().navigate(BrowserFragmentDirections.actionGlobalHome())
}
}
} }
) )

View File

@ -360,6 +360,16 @@ class HomeFragment : Fragment() {
hideOnboardingIfNeeded() hideOnboardingIfNeeded()
val tabTrayDialog = TabTrayDialogFragment() val tabTrayDialog = TabTrayDialogFragment()
tabTrayDialog.show(parentFragmentManager, null) tabTrayDialog.show(parentFragmentManager, null)
tabTrayDialog.interactor = object : TabTrayDialogFragment.Interactor {
override fun onTabSelected(tab: mozilla.components.concept.tabstray.Tab) {
tabTrayDialog.dismiss()
(activity as HomeActivity).openToBrowser(BrowserDirection.FromHome)
}
override fun onNewTabTapped() {
tabTrayDialog.dismiss()
}
}
} }
PrivateBrowsingButtonView( PrivateBrowsingButtonView(

View File

@ -17,7 +17,13 @@ import mozilla.components.concept.tabstray.Tab
import org.mozilla.fenix.R import org.mozilla.fenix.R
class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor { class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
interface Interactor {
fun onTabSelected(tab: Tab)
fun onNewTabTapped()
}
private lateinit var tabTrayView: TabTrayView private lateinit var tabTrayView: TabTrayView
var interactor: Interactor? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -52,11 +58,11 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
} }
override fun onTabSelected(tab: Tab) { override fun onTabSelected(tab: Tab) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. interactor?.onTabSelected(tab)
} }
override fun onNewTabTapped(private: Boolean) { override fun onNewTabTapped(private: Boolean) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. interactor?.onNewTabTapped()
} }
override fun onTabTrayDismissed() { override fun onTabTrayDismissed() {

View File

@ -109,7 +109,6 @@ class TabTrayFragment : Fragment(R.layout.fragment_tab_tray), TabsTray.Observer,
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
onTabsChanged() onTabsChanged()
} }