From f82e6fc49c053b2a819f9712d92235f95e459508 Mon Sep 17 00:00:00 2001 From: Emily Kager Date: Mon, 22 Apr 2019 17:06:58 -0700 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/1912 - Quick action bottom sheet should fade in --- .../quickactionsheet/QuickActionUIView.kt | 11 +- .../res/layout/layout_quick_action_sheet.xml | 161 ++++++++++-------- 2 files changed, 96 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionUIView.kt b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionUIView.kt index 7a7d26a334..88e8084a9f 100644 --- a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionUIView.kt +++ b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionUIView.kt @@ -14,6 +14,7 @@ import io.reactivex.Observable import io.reactivex.Observer import io.reactivex.functions.Consumer import kotlinx.android.synthetic.main.fragment_browser.* +import kotlinx.android.synthetic.main.layout_quick_action_sheet.* import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.* import org.mozilla.fenix.R import org.mozilla.fenix.components.metrics.Event @@ -45,7 +46,8 @@ class QuickActionUIView( } } - override fun onSlide(p0: View, p1: Float) { + override fun onSlide(bottomSheet: View, slideOffset: Float) { + animateOverlay(slideOffset) } }) @@ -69,6 +71,13 @@ class QuickActionUIView( } } + /** + * Changes alpha of overlay based on new offset of this sheet within [-1,1] range. + */ + private fun animateOverlay(offset: Float) { + overlay.alpha = (1 - offset) + } + private fun updateImportantForAccessibility(state: Int) { view.findViewById(R.id.quick_action_buttons_layout).importantForAccessibility = if (state == BottomSheetBehavior.STATE_COLLAPSED || state == BottomSheetBehavior.STATE_HIDDEN) diff --git a/app/src/main/res/layout/layout_quick_action_sheet.xml b/app/src/main/res/layout/layout_quick_action_sheet.xml index 283135e724..1abfb0a2ff 100644 --- a/app/src/main/res/layout/layout_quick_action_sheet.xml +++ b/app/src/main/res/layout/layout_quick_action_sheet.xml @@ -2,90 +2,101 @@ - - - - - + android:layout_height="wrap_content"> + android:background="?foundation" + android:orientation="vertical"> -