Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5226: EnableContinueButtonAnimation Feature Flag #5228

Merged
merged 11 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import org.oppia.android.app.utility.lifecycle.LifecycleSafeTimerFactory
import org.oppia.android.app.view.ViewComponentFactory
import org.oppia.android.app.view.ViewComponentImpl
import org.oppia.android.domain.oppialogger.OppiaLogger
import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation
import org.oppia.android.util.platformparameter.PlatformParameterValue
import org.oppia.android.util.system.OppiaClock
import javax.inject.Inject

Expand All @@ -25,12 +23,14 @@ class ContinueButtonView @JvmOverloads constructor(
defStyleAttr: Int = R.style.StateButtonActive
) : androidx.appcompat.widget.AppCompatButton(context, attrs, defStyleAttr) {

@field:[Inject EnableContinueButtonAnimation]
lateinit var enableContinueButtonAnimation: PlatformParameterValue<Boolean>
@Inject lateinit var fragment: Fragment
@Inject lateinit var oppiaClock: OppiaClock
@Inject lateinit var lifecycleSafeTimerFactory: LifecycleSafeTimerFactory
@Inject lateinit var oppiaLogger: OppiaLogger
@Inject
lateinit var fragment: Fragment
@Inject
lateinit var oppiaClock: OppiaClock
@Inject
lateinit var lifecycleSafeTimerFactory: LifecycleSafeTimerFactory
@Inject
lateinit var oppiaLogger: OppiaLogger

private var shouldAnimateContinueButtonLateinit: Boolean? = null
private val shouldAnimateContinueButton: Boolean
Expand Down Expand Up @@ -119,13 +119,11 @@ class ContinueButtonView @JvmOverloads constructor(

private fun startAnimating() {
val animation = AnimationUtils.loadAnimation(context, R.anim.wobble_button_animation)
if (enableContinueButtonAnimation.value) {
startAnimation(animation)
// Repeat the animation after a fixed interval.
lifecycleSafeTimerFactory.createTimer(INTERVAL_BETWEEN_CONTINUE_BUTTON_ANIM_MS)
.observe(fragment) {
startAnimating()
}
}
startAnimation(animation)
// Repeat the animation after a fixed interval.
lifecycleSafeTimerFactory.createTimer(INTERVAL_BETWEEN_CONTINUE_BUTTON_ANIM_MS)
.observe(fragment) {
startAnimating()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ class ExplorationActivityTest {
@Before
fun setUp() {
Intents.init()
TestPlatformParameterModule.forceEnableContinueButtonAnimation(false)
setUpTestApplicationComponent()
testCoroutineDispatchers.registerIdlingResource()
profileTestHelper.initializeProfiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4749,7 +4749,6 @@ class StateFragmentTest {
}

private fun setUpTest() {
TestPlatformParameterModule.forceEnableContinueButtonAnimation(false)
Intents.init()
setUpTestApplicationComponent()
testCoroutineDispatchers.registerIdlingResource()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ class StateFragmentLocalTest {

@Test
fun testContinueInteractionAnim_openPrototypeExp_checkContinueButtonAnimatesAfter45Seconds() {
TestPlatformParameterModule.forceEnableContinueButtonAnimation(true)
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()
testCoroutineDispatchers.runCurrent()
Expand Down Expand Up @@ -339,7 +338,6 @@ class StateFragmentLocalTest {

@Test
fun testConIntAnim_openProtExp_orientLandscapeAfter30Sec_checkAnimHasNotStarted() {
TestPlatformParameterModule.forceEnableContinueButtonAnimation(true)
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()

Expand All @@ -353,7 +351,6 @@ class StateFragmentLocalTest {

@Test
fun testConIntAnim_openProtExp_orientLandAfter30Sec_checkAnimStartsIn15SecAfterOrientChange() {
TestPlatformParameterModule.forceEnableContinueButtonAnimation(true)
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()

Expand All @@ -368,7 +365,6 @@ class StateFragmentLocalTest {

@Test
fun testContNavBtnAnim_openMathExp_checkContNavBtnAnimatesAfter45Seconds() {
TestPlatformParameterModule.forceEnableContinueButtonAnimation(true)
launchForExploration(TEST_EXPLORATION_ID_5).use {
startPlayingExploration()
onView(withId(R.id.state_recycler_view)).perform(
Expand All @@ -391,7 +387,6 @@ class StateFragmentLocalTest {
@Ignore("Continue navigation animation behavior fails during testing")
@Test
fun testContNavBtnAnim_openMathExp_playThroughSecondState_checkContBtnDoesNotAnimateAfter45Sec() {
TestPlatformParameterModule.forceEnableContinueButtonAnimation(true)
launchForExploration(TEST_EXPLORATION_ID_5).use {
startPlayingExploration()
onView(withId(R.id.state_recycler_view)).perform(
Expand Down Expand Up @@ -424,7 +419,6 @@ class StateFragmentLocalTest {
@Ignore("Continue navigation animation behavior fails during testing")
@Test
fun testConIntAnim_openFractions_expId1_checkButtonDoesNotAnimate() {
TestPlatformParameterModule.forceEnableContinueButtonAnimation(true)
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()
playThroughTestState1()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING
import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.CacheLatexRendering
import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE
Expand All @@ -18,7 +17,6 @@ import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLE
import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation
import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation
import org.oppia.android.util.platformparameter.EnableDownloadsSupport
import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi
import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi
Expand Down Expand Up @@ -215,14 +213,6 @@ class PlatformParameterAlphaKenyaModule {
)
}

@Provides
@EnableContinueButtonAnimation
fun provideEnableContinueButtonAnimation(): PlatformParameterValue<Boolean> {
return PlatformParameterValue.createDefaultParameter(
ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE
)
}

@Provides
@EnableSpotlightUi
fun enableSpotlightUi(): PlatformParameterValue<Boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING
import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.CacheLatexRendering
import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE
Expand All @@ -17,7 +16,6 @@ import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEF
import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION
import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation
import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation
import org.oppia.android.util.platformparameter.EnableDownloadsSupport
import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi
import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi
Expand Down Expand Up @@ -216,14 +214,6 @@ class PlatformParameterAlphaModule {
)
}

@Provides
@EnableContinueButtonAnimation
fun provideEnableContinueButtonAnimation(): PlatformParameterValue<Boolean> {
return PlatformParameterValue.createDefaultParameter(
ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE
)
}

@Provides
@EnableAppAndOsDeprecation
fun provideEnableAppAndOsDeprecation(): PlatformParameterValue<Boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING
import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.CacheLatexRendering
import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE
Expand All @@ -18,7 +17,6 @@ import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLE
import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation
import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation
import org.oppia.android.util.platformparameter.EnableDownloadsSupport
import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi
import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi
Expand Down Expand Up @@ -221,14 +219,6 @@ class PlatformParameterModule {
)
}

@Provides
@EnableContinueButtonAnimation
fun provideEnableContinueButtonAnimation(): PlatformParameterValue<Boolean> {
return PlatformParameterValue.createDefaultParameter(
ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE
)
}

@Provides
@EnableAppAndOsDeprecation
fun provideEnableAppAndOsDeprecation(): PlatformParameterValue<Boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING
import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.CacheLatexRendering
import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE
import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation
import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation
import org.oppia.android.util.platformparameter.EnableDownloadsSupport
import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi
import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi
Expand Down Expand Up @@ -206,14 +204,6 @@ class TestPlatformParameterModule {
fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue<Boolean> =
PlatformParameterValue.createDefaultParameter(enableInteractionConfigChangeStateRetention)

@Provides
@EnableContinueButtonAnimation
fun provideEnableContinueButtonAnimation(): PlatformParameterValue<Boolean> {
return PlatformParameterValue.createDefaultParameter(
enableContinueButtonAnimation
)
}

@Provides
@EnableSpotlightUi
fun provideEnableSpotlightUi(): PlatformParameterValue<Boolean> {
Expand Down Expand Up @@ -304,7 +294,6 @@ class TestPlatformParameterModule {
fun forceEnableDownloadsSupport(value: Boolean) {
enableDownloadsSupport = value
}
private var enableContinueButtonAnimation = ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE

/** Enables forcing [EnableLanguageSelectionUi] platform parameter flag from tests. */
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
Expand Down Expand Up @@ -354,12 +343,6 @@ class TestPlatformParameterModule {
enablePerformanceMetricsCollection = value
}

/** Enables forcing [EnableContinueButtonAnimation] platform parameter flag from tests. */
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun forceEnableContinueButtonAnimation(value: Boolean) {
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
enableContinueButtonAnimation = value
}

/** Enables forcing [EnableSpotlightUi] platform parameter flag from tests. */
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun forceEnableSpotlightUi(value: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,6 @@ const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "enable_performance_metrics_co
/** Default value for whether to record performance metrics. */
const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false

/**
* Qualifier for the platform parameter that controls whether to animate the continue button
* interaction and navigation items. This is used to disable the animation during testing because
* Espresso has known problems while testing views that contain animations.
*/
@Qualifier
annotation class EnableContinueButtonAnimation

/** Default value for whether to enable continue button animation. */
const val ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE = true

/**
* Qualifier for the platform parameter that controls the time interval in minutes of uploading
* previously recorded performance metrics to the remote service.
Expand Down
Loading