diff --git a/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt b/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt index 2cf6750f6..2b3f99730 100644 --- a/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt @@ -18,7 +18,7 @@ class SessionBottomSheetFragment : BottomSheetDialogFragment(), LayoutContainer sealed class SessionType { data class Current(val titles: List) : SessionType() data class Archived(val archivedSession: ArchivedSession) : SessionType() - data class Private(val titles: List ) : SessionType() + data class Private(val titles: List) : SessionType() } private var sessionType: SessionType? = null diff --git a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt index 9db2c4599..0f97b75b1 100644 --- a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt +++ b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + package org.mozilla.fenix.quickactionsheet import android.content.Context @@ -33,17 +37,21 @@ class QuickActionSheet @JvmOverloads constructor( val handle = findViewById(R.id.quick_action_sheet_handle) val linearLayout = findViewById(R.id.quick_action_sheet) val quickActionSheetBehavior = BottomSheetBehavior.from(linearLayout.parent as View) as QuickActionSheetBehavior - handle.increaseTapArea(100) + handle.increaseTapArea(grabHandleIncreasedTapArea) handle.setOnClickListener { bounceSheet(quickActionSheetBehavior) } - bounceSheet(quickActionSheetBehavior, 500L) + bounceSheet(quickActionSheetBehavior, bounceAnimationLength) } - private fun bounceSheet(quickActionSheetBehavior: QuickActionSheetBehavior, duration: Long = 400L) { + private fun bounceSheet( + quickActionSheetBehavior: QuickActionSheetBehavior, + duration: Long = quickBounceAnimationLength + ) { val normalPeekHeight = quickActionSheetBehavior.peekHeight - val valueAnimator = ValueAnimator.ofFloat(normalPeekHeight.toFloat(), normalPeekHeight*3f) + val valueAnimator = ValueAnimator.ofFloat(normalPeekHeight.toFloat(), + normalPeekHeight * bounceAnimationPeekHeightMultiplier) valueAnimator.addUpdateListener { quickActionSheetBehavior.peekHeight = (it.animatedValue as Float).toInt() @@ -51,11 +59,17 @@ class QuickActionSheet @JvmOverloads constructor( valueAnimator.repeatMode = ValueAnimator.REVERSE valueAnimator.repeatCount = 1 - // Fast out slow in looks best so far valueAnimator.interpolator = FastOutSlowInInterpolator() valueAnimator.duration = duration valueAnimator.start() } + + companion object { + const val grabHandleIncreasedTapArea = 50 + const val bounceAnimationLength = 500L + const val quickBounceAnimationLength = 400L + const val bounceAnimationPeekHeightMultiplier = 3f + } } @Suppress("unused") // Referenced from XML @@ -88,4 +102,4 @@ class QuickActionSheetBehavior( state = BottomSheetBehavior.STATE_COLLAPSED quickActionSheetContainer.translationY = (toolbar.translationY + toolbar.height * -1.0).toFloat() } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheetIntegration.kt b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheetIntegration.kt deleted file mode 100644 index 74cb8b97a..000000000 --- a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheetIntegration.kt +++ /dev/null @@ -1,39 +0,0 @@ -package org.mozilla.fenix.quickactionsheet - -import android.content.Context -import android.util.AttributeSet -import android.view.View -import androidx.coordinatorlayout.widget.CoordinatorLayout -import mozilla.components.browser.toolbar.BrowserToolbar -import mozilla.components.feature.findinpage.view.FindInPageBar - -/** - * [CoordinatorLayout.Behavior] that will always position the [QuickActionSheetBar] above the [BrowserToolbar] (including - * when the browser toolbar is scrolling or performing a snap animation). - */ -@Suppress("unused") // Referenced from XML -class QuickActionSheetIntegration( - context: Context, - attrs: AttributeSet -) : CoordinatorLayout.Behavior(context, attrs) { - override fun layoutDependsOn(parent: CoordinatorLayout, child: FindInPageBar, dependency: View): Boolean { - if (dependency is BrowserToolbar) { - return true - } - - return super.layoutDependsOn(parent, child, dependency) - } - - override fun onDependentViewChanged(parent: CoordinatorLayout, child: FindInPageBar, dependency: View): Boolean { - return if (dependency is BrowserToolbar) { - repositionFindInPageBar(child, dependency) - true - } else { - false - } - } - - private fun repositionFindInPageBar(findInPageView: FindInPageBar, toolbar: BrowserToolbar) { - findInPageView.translationY = (toolbar.translationY + toolbar.height * -1.0).toFloat() - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_browser.xml b/app/src/main/res/layout/fragment_browser.xml index c7672f3c0..d20ff559d 100644 --- a/app/src/main/res/layout/fragment_browser.xml +++ b/app/src/main/res/layout/fragment_browser.xml @@ -32,7 +32,6 @@ android:layout_gravity="bottom"/> -