|
|
|
@ -14,6 +14,7 @@ import android.view.View
|
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import androidx.annotation.VisibleForTesting
|
|
|
|
|
import androidx.appcompat.app.AppCompatDialogFragment
|
|
|
|
|
import androidx.compose.ui.platform.ComposeView
|
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
|
import androidx.fragment.app.activityViewModels
|
|
|
|
|
import androidx.fragment.app.setFragmentResultListener
|
|
|
|
@ -59,6 +60,7 @@ import org.mozilla.fenix.tabstray.ext.collectionMessage
|
|
|
|
|
import org.mozilla.fenix.tabstray.ext.make
|
|
|
|
|
import org.mozilla.fenix.tabstray.ext.showWithTheme
|
|
|
|
|
import org.mozilla.fenix.tabstray.syncedtabs.SyncedTabsIntegration
|
|
|
|
|
import org.mozilla.fenix.theme.FirefoxTheme
|
|
|
|
|
import org.mozilla.fenix.theme.ThemeManager
|
|
|
|
|
import org.mozilla.fenix.utils.allowUndo
|
|
|
|
|
import kotlin.math.max
|
|
|
|
@ -115,27 +117,12 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
override fun onCreateDialog(savedInstanceState: Bundle?) =
|
|
|
|
|
TabsTrayDialog(requireContext(), theme) { tabsTrayInteractor }
|
|
|
|
|
|
|
|
|
|
@Suppress("LongMethod")
|
|
|
|
|
override fun onCreateView(
|
|
|
|
|
inflater: LayoutInflater,
|
|
|
|
|
container: ViewGroup?,
|
|
|
|
|
savedInstanceState: Bundle?,
|
|
|
|
|
): View {
|
|
|
|
|
_tabsTrayDialogBinding = FragmentTabTrayDialogBinding.inflate(
|
|
|
|
|
inflater,
|
|
|
|
|
container,
|
|
|
|
|
false,
|
|
|
|
|
)
|
|
|
|
|
_tabsTrayBinding = ComponentTabstray2Binding.inflate(
|
|
|
|
|
inflater,
|
|
|
|
|
tabsTrayDialogBinding.root,
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
_fabButtonBinding = ComponentTabstrayFabBinding.inflate(
|
|
|
|
|
LayoutInflater.from(tabsTrayDialogBinding.root.context),
|
|
|
|
|
tabsTrayDialogBinding.root,
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val args by navArgs<TabsTrayFragmentArgs>()
|
|
|
|
|
args.accessPoint.takeIf { it != TabsTrayAccessPoint.None }?.let {
|
|
|
|
|
TabsTray.accessPoint[it.name.lowercase()].add()
|
|
|
|
@ -146,6 +133,7 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
TabsTrayState.Mode.Normal
|
|
|
|
|
}
|
|
|
|
|
val initialPage = args.page
|
|
|
|
|
val activity = activity as HomeActivity
|
|
|
|
|
|
|
|
|
|
tabsTrayStore = StoreProvider.get(this) {
|
|
|
|
|
TabsTrayStore(
|
|
|
|
@ -159,34 +147,6 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tabsTrayDialogBinding.root
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onStart() {
|
|
|
|
|
super.onStart()
|
|
|
|
|
findPreviousDialogFragment()?.let { dialog ->
|
|
|
|
|
dialog.onAcceptClicked = ::onCancelDownloadWarningAccepted
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
|
|
super.onDestroyView()
|
|
|
|
|
_tabsTrayBinding = null
|
|
|
|
|
_tabsTrayDialogBinding = null
|
|
|
|
|
_fabButtonBinding = null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Suppress("LongMethod")
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
val activity = activity as HomeActivity
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
|
|
fabButtonBinding.newTabButton.accessibilityTraversalAfter =
|
|
|
|
|
tabsTrayBinding.tabLayout.id
|
|
|
|
|
}
|
|
|
|
|
TabsTray.opened.record(NoExtras())
|
|
|
|
|
|
|
|
|
|
navigationInteractor =
|
|
|
|
|
DefaultNavigationInteractor(
|
|
|
|
|
context = requireContext(),
|
|
|
|
@ -226,6 +186,62 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
controller = tabsTrayController,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return if (requireContext().settings().enableTabsTrayToCompose) {
|
|
|
|
|
ComposeView(requireContext()).apply {
|
|
|
|
|
setContent {
|
|
|
|
|
FirefoxTheme {
|
|
|
|
|
TabsTray()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
_tabsTrayDialogBinding = FragmentTabTrayDialogBinding.inflate(
|
|
|
|
|
inflater,
|
|
|
|
|
container,
|
|
|
|
|
false,
|
|
|
|
|
)
|
|
|
|
|
_tabsTrayBinding = ComponentTabstray2Binding.inflate(
|
|
|
|
|
inflater,
|
|
|
|
|
tabsTrayDialogBinding.root,
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
_fabButtonBinding = ComponentTabstrayFabBinding.inflate(
|
|
|
|
|
LayoutInflater.from(tabsTrayDialogBinding.root.context),
|
|
|
|
|
tabsTrayDialogBinding.root,
|
|
|
|
|
true,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tabsTrayDialogBinding.root
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onStart() {
|
|
|
|
|
super.onStart()
|
|
|
|
|
findPreviousDialogFragment()?.let { dialog ->
|
|
|
|
|
dialog.onAcceptClicked = ::onCancelDownloadWarningAccepted
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
|
|
super.onDestroyView()
|
|
|
|
|
_tabsTrayBinding = null
|
|
|
|
|
_tabsTrayDialogBinding = null
|
|
|
|
|
_fabButtonBinding = null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Suppress("LongMethod")
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
TabsTray.opened.record(NoExtras())
|
|
|
|
|
|
|
|
|
|
if (!requireContext().settings().enableTabsTrayToCompose) {
|
|
|
|
|
val activity = activity as HomeActivity
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
|
|
fabButtonBinding.newTabButton.accessibilityTraversalAfter =
|
|
|
|
|
tabsTrayBinding.tabLayout.id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setupMenu(navigationInteractor)
|
|
|
|
|
setupPager(
|
|
|
|
|
context = view.context,
|
|
|
|
@ -255,18 +271,6 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
displayMetrics = requireContext().resources.displayMetrics,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tabsFeature.set(
|
|
|
|
|
feature = TabsFeature(
|
|
|
|
|
tabsTray = TabSorter(
|
|
|
|
|
requireContext().settings(),
|
|
|
|
|
tabsTrayStore,
|
|
|
|
|
),
|
|
|
|
|
store = requireContext().components.core.store,
|
|
|
|
|
),
|
|
|
|
|
owner = this,
|
|
|
|
|
view = view,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tabsTrayCtaBinding.set(
|
|
|
|
|
feature = TabsTrayInfoBannerBinding(
|
|
|
|
|
context = view.context,
|
|
|
|
@ -353,17 +357,6 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
view = view,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
secureTabsTrayBinding.set(
|
|
|
|
|
feature = SecureTabsTrayBinding(
|
|
|
|
|
store = tabsTrayStore,
|
|
|
|
|
settings = requireComponents.settings,
|
|
|
|
|
fragment = this,
|
|
|
|
|
dialog = dialog as TabsTrayDialog,
|
|
|
|
|
),
|
|
|
|
|
owner = this,
|
|
|
|
|
view = view,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
tabsTrayInactiveTabsOnboardingBinding.set(
|
|
|
|
|
feature = TabsTrayInactiveTabsOnboardingBinding(
|
|
|
|
|
context = requireContext(),
|
|
|
|
@ -375,6 +368,30 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
owner = this,
|
|
|
|
|
view = view,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tabsFeature.set(
|
|
|
|
|
feature = TabsFeature(
|
|
|
|
|
tabsTray = TabSorter(
|
|
|
|
|
requireContext().settings(),
|
|
|
|
|
tabsTrayStore,
|
|
|
|
|
),
|
|
|
|
|
store = requireContext().components.core.store,
|
|
|
|
|
),
|
|
|
|
|
owner = this,
|
|
|
|
|
view = view,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
secureTabsTrayBinding.set(
|
|
|
|
|
feature = SecureTabsTrayBinding(
|
|
|
|
|
store = tabsTrayStore,
|
|
|
|
|
settings = requireComponents.settings,
|
|
|
|
|
fragment = this,
|
|
|
|
|
dialog = dialog as TabsTrayDialog,
|
|
|
|
|
),
|
|
|
|
|
owner = this,
|
|
|
|
|
view = view,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
syncedTabsIntegration.set(
|
|
|
|
|
feature = SyncedTabsIntegration(
|
|
|
|
@ -397,12 +414,14 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|
|
|
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
|
|
|
|
super.onConfigurationChanged(newConfig)
|
|
|
|
|
|
|
|
|
|
if (!requireContext().settings().enableTabsTrayToCompose) {
|
|
|
|
|
trayBehaviorManager.updateDependingOnOrientation(newConfig.orientation)
|
|
|
|
|
|
|
|
|
|
if (requireContext().settings().gridTabView) {
|
|
|
|
|
tabsTrayBinding.tabsTray.adapter?.notifyDataSetChanged()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@VisibleForTesting
|
|
|
|
|
internal fun onCancelDownloadWarningAccepted(tabId: String?, source: String?) {
|
|
|
|
|