Merge branch 'fix-541--ignoring-malformed-uri' into 'master'

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.

See merge request !195
This commit is contained in:
Daniel Martí 2016-01-19 11:32:13 +00:00
commit 31e99a1331

View File

@ -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);