Reader: Fix deeplink activity disable/enable - #13012
Merged
malinajirka merged 3 commits intoSep 24, 2020
Merged
Conversation
The alias is necessary so that the system doesn't try to destroy ReaderPostPagerActivity when we disable the deeplinking component via PackageManager#setComponentEnabledSetting. We instead disable the alias, which leaves the real activity alone but disables the intent-filter deeplinking behavior as intended. This especially matters when ReaderPostPagerActivity is the current activity, for example when an external URL is opened from the Reader, as this ends up closing the app.
This call is needed when the user navigates away from the app after ActivityLauncher#openUrlExternal has disabled deeplinks, so that we can still catch appropriate links visited before the user re-opens the app.
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
3 tasks
|
You can test the changes on this Pull Request by downloading the APK here. |
malinajirka
approved these changes
Sep 24, 2020
malinajirka
left a comment
Contributor
There was a problem hiding this comment.
TIL about activity-aliases ;).
The changes look good to me. Great job on figuring it out!!!
SideNote: I found one super minor issue, but I personally wouldn't worry about it. When you open the "choose app" dialog and rotate the device, the app appears in the dialog.
malinajirka
deleted the
issue/13010-fix-reader-deeplink-registration
branch
September 24, 2020 09:28
Contributor
Author
😀 yeah agreed, let's just stop here, good thinking though 😉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13010. Adjusts the way we disable/re-enable the Reader deeplink activity when opening an external URL so that it works correctly on all devices.
Relies on #13002 since that's where the issue was noticed, but I didn't want to bury this deep change in an apparently unrelated PR. That one should be mergable independent of this fix.
The first step to address the issue was to remove the re-enabling logic from this
finallyblock, which it seems is too soon for some devices, and we end up with the deeplink activity being re-enabled before the intent is handled and appearing when it was supposed to be removed. (My best guess is that this has been happening for a while and we just didn't notice, and/or that perhaps behavior changed in recent Android API levels so thatstartActivityunblocks the main thread earlier than before.)However, this introduced a different issue: as soon as the chooser menu was shown, the app would close. This is because the
pm.setComponentEnabledSetting()withCOMPONENT_ENABLED_STATE_DISABLEDcall causes the system to close the activity in question (ReaderPostPagerActivity) in some cases. If the external URL was opened from the reader detail view, that's actually the current activity, and the app closes.You may be able to confirm this by checking out fb58104.
To address this, I moved the
intent-filterrules forReaderPostPagerActivityto an activity-alias. That way we enable/disable the alias activity for deeplinking instead, and the system never tries to force finish the realReaderPostPagerActivity.Finally, I also added a new call to re-enable deeplinking, when the app is backgrounded (we already do this when
WPMainActivityis created or resumed). This should replace the work thefinallyblock was doing, ensuring that deeplinks are re-enabled as the user leaves the app. This way links visited outside the app can still be picked up by the WordPress app and open the Reader, as before.To test:
Note that if you have multiple different builds of the WordPress app installed, the other builds will always show - that's expected and not something a regular user will experience.
PR submission checklist:
RELEASE-NOTES.txtif necessary.