From d23e68be6b0589dd290a0e29d8545f67ec3b9383 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Mon, 18 Jan 2016 18:46:23 +1100 Subject: [PATCH] Finish main activity after navigating to AppDetails activity. This is what used to happen before the recent refactor to the search UI. Finishing the main activity means that it never comes back to handle the "View this app" intent again. Instead, the main Activity just becomes an entry point for redirecting the UI to the correct place. Incidentally, I don't particularly like the current solution even though it should work, and hope to come up with a better one in the future. The reason is because the behaviour of some methods (`onCreate()` + `handleIntent()`) is what defines the behaviour of other methods (`checkForAddRepoIntent()`). This means it is hard to reason about the state of the activity at any point in time. Developers need to be careful when making changes to the `onCreate()` method because modifying it has unintended consequences. That is what caused the problem in issue #541. Fixes #541. --- F-Droid/src/org/fdroid/fdroid/FDroid.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/F-Droid/src/org/fdroid/fdroid/FDroid.java b/F-Droid/src/org/fdroid/fdroid/FDroid.java index 37ae1d41f..157ac7e24 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroid.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroid.java @@ -243,6 +243,7 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL Intent intentToInvoke = new Intent(this, AppDetails.class); intentToInvoke.putExtra(AppDetails.EXTRA_APPID, packageName); startActivity(intentToInvoke); + finish(); } else if (!TextUtils.isEmpty(query)) { Utils.debugLog(TAG, "FDroid launched via search link for '" + query + "'"); performSearch(query); @@ -253,9 +254,9 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL // Don't handle the intent after coming back to this view (e.g. after hitting the back button) // http://stackoverflow.com/a/14820849 if (!intent.hasExtra(ADD_REPO_INTENT_HANDLED)) { + intent.putExtra(ADD_REPO_INTENT_HANDLED, true); NewRepoConfig parser = new NewRepoConfig(this, intent); if (parser.isValidRepo()) { - intent.putExtra(ADD_REPO_INTENT_HANDLED, true); if (parser.isFromSwap()) { Intent confirmIntent = new Intent(this, SwapWorkflowActivity.class); confirmIntent.putExtra(SwapWorkflowActivity.EXTRA_CONFIRM, true);