Exclude EditPostActivity from handling orientation change for alpha #8800
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 wordpress-mobile/gutenberg-mobile#377, #8739, and load time issues mentioned in #8739 (comment) and elsewhere
This PR adds a specific
AndroidManifest.xml
merge forEditPostActivity
, declaring the following attributes:keyboard|keyboardHidden|orientation|screenSize
. What this effectively means is thatEditPostActivity
now does not handle orientation changes, and lets the changes in configuration be listened to and handled by the underlying RN implementation.Been looking into this and trying different approaches:
GutenbergEditorFragment
as a host, a first idea was to usesetRetainInstance(true)
(see Avoid Gutenberg reload times on rotation #8790 and Keeps reference to mReactInstanceManager to avoid re-creating on rotation gutenberg-mobile#382) and keep the fragment's instance alive with the RN code alive as well. Unfortunately, even by doing this meant the re-wiring needed was not trivial, and even if so, the RN lifecycle relies heavily on listening to the host's Activity lifecycle # #, apparently re-initializing things internally as the Activity lifecycle wired events were run (so, keeping the Fragment instance wasn't really helping here).orientation|screenSize
modifiers in theorientation
attribute, which indicates the Activity is in charge of handling orientation changes (and thus it not going to be destroyed for this reason). Also searching a bit for it found out most of the work is handled by RN itself on one activity, so it makes sense generally speaking to keep the Activity instance as well #.Given the situation in which the user is writing has the
EditPostActivity
on the foreground most of the time, an orientation change losing the focus / scroll position or making the user wait to reload seems less than ideal. On the contrary, if the user is writing and switches the app to do something else, then it perfectly makes sense for it to occasionally need to re-load the content.This seems a good solution for the situation we're trying to handle, which aims at recognizing the orientaiton change (which RN does well and adjusts the contents to fit the new screen size after rotation) while not affecting the writing flow (which until this PR meant waiting for reload, losing scroll position and undo/redo history among other hurdles).
Note: this PR makes the
EditPostActivity
not be killed on screen orientation changes also for Aztec and Visual Editors as the implementation for each is done by means of Fragments, but I chose to keep the PR simple foralpha
only as opposed to making a newEditPostActivity
class only for Gutenberg. We'll have to create one though, once we get into Beta.To test:
Update release notes:
RELEASE-NOTES.txt
.