From b4a0e122d1258ab9b0c4ceeb6ed3575a46a9b5c3 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Fri, 24 Jul 2020 10:43:53 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/10997: Remove scrolling from home (https://github.com/mozilla-mobile/fenix/pull/12866) --- .../org/mozilla/fenix/home/HomeFragment.kt | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 9297026aaa..56c66641c5 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -42,7 +42,6 @@ import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE -import com.google.android.material.appbar.AppBarLayout import com.google.android.material.snackbar.Snackbar import kotlinx.android.synthetic.main.fragment_home.* import kotlinx.android.synthetic.main.fragment_home.view.* @@ -107,7 +106,6 @@ import org.mozilla.fenix.utils.FragmentPreDrawManager import org.mozilla.fenix.utils.allowUndo import org.mozilla.fenix.whatsnew.WhatsNew import java.lang.ref.WeakReference -import kotlin.math.abs import kotlin.math.min @ExperimentalCoroutinesApi @@ -127,7 +125,6 @@ class HomeFragment : Fragment() { } private val browsingModeManager get() = (activity as HomeActivity).browsingModeManager - private var homeAppBarOffset = 0 private val collectionStorageObserver = object : TabCollectionStorage.Observer { override fun onCollectionCreated(title: String, sessions: List) { @@ -148,7 +145,6 @@ class HomeFragment : Fragment() { private val store: BrowserStore get() = requireComponents.core.store - private lateinit var homeAppBarOffSetListener: AppBarLayout.OnOffsetChangedListener private val onboarding by lazy { FenixOnboarding(requireContext()) } private lateinit var homeFragmentStore: HomeFragmentStore private var _sessionControlInteractor: SessionControlInteractor? = null @@ -218,7 +214,6 @@ class HomeFragment : Fragment() { ) ) updateLayout(view) - setOffset(view) sessionControlView = SessionControlView( view.sessionControlRecyclerView, sessionControlInteractor, @@ -280,17 +275,8 @@ class HomeFragment : Fragment() { view.homeAppBar.updateLayoutParams { topMargin = HEADER_MARGIN.dpToPx(resources.displayMetrics) } - - createNewAppBarListener(HEADER_MARGIN.dpToPx(resources.displayMetrics).toFloat()) - view.homeAppBar.addOnOffsetChangedListener( - homeAppBarOffSetListener - ) } ToolbarPosition.BOTTOM -> { - createNewAppBarListener(0F) - view.homeAppBar.addOnOffsetChangedListener( - homeAppBarOffSetListener - ) } } } @@ -446,7 +432,6 @@ class HomeFragment : Fragment() { _sessionControlInteractor = null sessionControlView = null bundleArgs.clear() - requireView().homeAppBar.removeOnOffsetChangedListener(homeAppBarOffSetListener) requireActivity().window.clearFlags(FLAG_SECURE) } @@ -561,7 +546,6 @@ class HomeFragment : Fragment() { ) ) } - calculateNewOffset() } private fun recommendPrivateBrowsingShortcut() { @@ -888,30 +872,6 @@ class HomeFragment : Fragment() { } } - private fun calculateNewOffset() { - homeAppBarOffset = ((homeAppBar.layoutParams as CoordinatorLayout.LayoutParams) - .behavior as AppBarLayout.Behavior).topAndBottomOffset - } - - private fun setOffset(currentView: View) { - if (homeAppBarOffset <= 0) { - (currentView.homeAppBar.layoutParams as CoordinatorLayout.LayoutParams) - .behavior = AppBarLayout.Behavior().apply { - topAndBottomOffset = this@HomeFragment.homeAppBarOffset - } - } else { - currentView.homeAppBar.setExpanded(false) - } - } - - private fun createNewAppBarListener(margin: Float) { - homeAppBarOffSetListener = - AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> - val reduceScrollRanged = appBarLayout.totalScrollRange.toFloat() - margin - appBarLayout.alpha = 1.0f - abs(verticalOffset / reduceScrollRanged) - } - } - private fun openTabTray() { TabTrayDialogFragment.show(parentFragmentManager) }