1
0
Fork 0

For #1072: Fixes lint errors

master
Sawyer Blatz 2019-03-20 08:29:04 -07:00 committed by Colin Lee
parent c0ceeb8cb6
commit 7accf07d48
4 changed files with 21 additions and 47 deletions

View File

@ -18,7 +18,7 @@ class SessionBottomSheetFragment : BottomSheetDialogFragment(), LayoutContainer
sealed class SessionType {
data class Current(val titles: List<String>) : SessionType()
data class Archived(val archivedSession: ArchivedSession) : SessionType()
data class Private(val titles: List <String>) : SessionType()
data class Private(val titles: List<String>) : SessionType()
}
private var sessionType: SessionType? = null

View File

@ -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<AppCompatImageButton>(R.id.quick_action_sheet_handle)
val linearLayout = findViewById<LinearLayout>(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()
}
}
}

View File

@ -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<FindInPageBar>(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()
}
}

View File

@ -32,7 +32,6 @@
android:layout_gravity="bottom"/>
</androidx.core.widget.NestedScrollView>
<mozilla.components.feature.findinpage.view.FindInPageBar
android:id="@+id/findInPageView"
android:layout_width="match_parent"