From e7b0bf6b14b4f05daaf148ab5243967521f128bb Mon Sep 17 00:00:00 2001 From: Sparky93 Date: Tue, 4 Feb 2020 17:32:54 +0200 Subject: [PATCH] Fix for #7980 - MigrationStore's COMPLETE action now redirects to MigrationProgressActivity In order to ensure that the user's migration screen is not being bypassed by mistake, we handle the migration's store COMPLETED state the same way we handle the MIGRATING state. We can do this because we can treat the initial state (NONE) as being either a fresh start of the app, either the user's intention of starting the home activity. Before this change, if the app was being open from the shortcut after the migration was complete, the user would have been encountered the home activity instead of the migration one. --- .../org/mozilla/fenix/migration/MigrationProgressActivity.kt | 2 ++ .../java/org/mozilla/fenix/MigrationDecisionActivity.kt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt b/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt index ca2da1fabb63..e38c258d51e7 100644 --- a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt @@ -22,6 +22,7 @@ import mozilla.components.support.migration.Migration.History import mozilla.components.support.migration.Migration.Logins import mozilla.components.support.migration.Migration.Settings import mozilla.components.support.migration.MigrationResults +import mozilla.components.support.migration.state.MigrationAction import mozilla.components.support.migration.state.MigrationProgress import mozilla.components.support.migration.state.MigrationStore import org.mozilla.fenix.HomeActivity @@ -62,6 +63,7 @@ class MigrationProgressActivity : AbstractMigrationProgressActivity() { // If we received a user-initiated intent, throw this back to the intent receiver. if (intent.hasExtra(HomeActivity.OPEN_TO_BROWSER)) { + store.dispatch(MigrationAction.Clear) intent.setClassName(applicationContext, IntentReceiverActivity::class.java.name) startActivity(intent) } diff --git a/app/src/migration/java/org/mozilla/fenix/MigrationDecisionActivity.kt b/app/src/migration/java/org/mozilla/fenix/MigrationDecisionActivity.kt index e0951b323760..108320df3778 100644 --- a/app/src/migration/java/org/mozilla/fenix/MigrationDecisionActivity.kt +++ b/app/src/migration/java/org/mozilla/fenix/MigrationDecisionActivity.kt @@ -24,8 +24,8 @@ class MigrationDecisionActivity : Activity() { val intent = if (intent != null) intent else Intent() val activity = when (store.state.progress) { - MigrationProgress.COMPLETED, MigrationProgress.NONE -> HomeActivity::class.java - MigrationProgress.MIGRATING -> MigrationProgressActivity::class.java + MigrationProgress.NONE -> HomeActivity::class.java + MigrationProgress.MIGRATING, MigrationProgress.COMPLETED -> MigrationProgressActivity::class.java } intent.setClass(applicationContext, activity)