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 0f97b75b17..9a1dc41ee6 100644
--- a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt
+++ b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt
@@ -17,6 +17,7 @@ import org.mozilla.fenix.R
import android.animation.ValueAnimator
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import org.mozilla.fenix.ext.increaseTapArea
+import org.mozilla.fenix.utils.Settings
class QuickActionSheet @JvmOverloads constructor(
context: Context,
@@ -42,16 +43,24 @@ class QuickActionSheet @JvmOverloads constructor(
bounceSheet(quickActionSheetBehavior)
}
- bounceSheet(quickActionSheetBehavior, bounceAnimationLength)
+ val settings = Settings.getInstance(context)
+ if (settings.shouldAutoBounceQuickActionSheet) {
+ settings.incrementAutomaticBounceQuickActionSheetCount()
+ bounceSheet(quickActionSheetBehavior, demoBounceAnimationLength)
+ }
}
private fun bounceSheet(
quickActionSheetBehavior: QuickActionSheetBehavior,
- duration: Long = quickBounceAnimationLength
+ duration: Long = bounceAnimationLength
) {
val normalPeekHeight = quickActionSheetBehavior.peekHeight
+
+ val peakHeightMultiplier = if (duration == demoBounceAnimationLength)
+ demoBounceAnimationPeekHeightMultiplier else bounceAnimationPeekHeightMultiplier
+
val valueAnimator = ValueAnimator.ofFloat(normalPeekHeight.toFloat(),
- normalPeekHeight * bounceAnimationPeekHeightMultiplier)
+ normalPeekHeight * peakHeightMultiplier)
valueAnimator.addUpdateListener {
quickActionSheetBehavior.peekHeight = (it.animatedValue as Float).toInt()
@@ -66,8 +75,9 @@ class QuickActionSheet @JvmOverloads constructor(
companion object {
const val grabHandleIncreasedTapArea = 50
- const val bounceAnimationLength = 500L
- const val quickBounceAnimationLength = 400L
+ const val demoBounceAnimationLength = 600L
+ const val bounceAnimationLength = 400L
+ const val demoBounceAnimationPeekHeightMultiplier = 4.5f
const val bounceAnimationPeekHeightMultiplier = 3f
}
}
diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
index 93c2786518..050d17022f 100644
--- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
+++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
@@ -39,6 +39,16 @@ class Settings private constructor(context: Context) {
val isTelemetryEnabled: Boolean
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_telemetry), true)
+ val shouldAutoBounceQuickActionSheet: Boolean
+ get() = autoBounceQuickActionSheetCount < 2
+
+ private val autoBounceQuickActionSheetCount: Int
+ get() = (preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_bounce_quick_action), 0))
+
+ fun incrementAutomaticBounceQuickActionSheetCount() {
+ preferences.edit().putInt(appContext.getPreferenceKey(R.string.pref_key_bounce_quick_action),
+ autoBounceQuickActionSheetCount + 1).apply()
+ }
fun setDefaultSearchEngineByName(name: String) {
preferences.edit()
.putString(appContext.getPreferenceKey(R.string.pref_key_search_engine), name)
diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml
index 733c12d2b9..f1ca42d3bc 100644
--- a/app/src/main/res/values/preference_keys.xml
+++ b/app/src/main/res/values/preference_keys.xml
@@ -36,4 +36,5 @@
pref_key_show_search_suggestions
+ pref_key_bounce_quick_action