diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index c039bbb31b97..55ce3fc9bb22 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -2,6 +2,7 @@ 18.9 ----- +* [*] Block editor: Fixed an issue causing the editor to load indefinitely when sharing text from other apps or reblogging a post [https://github.com/wordpress-mobile/WordPress-Android/pull/15697] * [*] Added new About screen where the user can rate and share the app, visit our Twitter profile and blog, view other apps, and more. [https://github.com/wordpress-mobile/WordPress-Android/pull/15631] * [**] Block editor: Fix undo/redo functionality in links when applying text format. [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4290] * [*] Block editor: Preformatted block: Fix an issue where the background color is not showing up for standard themes. [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4292] diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 6fd432518487..a3ca056f22f3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -448,7 +448,32 @@ private void newPostSetup() { mShortcutUtils.reportShortcutUsed(Shortcut.CREATE_NEW_POST); } + private void newPostFromShareAction() { + Intent intent = getIntent(); + final String title = intent.getStringExtra(Intent.EXTRA_SUBJECT); + final String text = intent.getStringExtra(Intent.EXTRA_TEXT); + String content = migrateToGutenbergEditor(AutolinkUtils.autoCreateLinks(text)); + + newPostSetup(title, content); + } + + private void newReblogPostSetup() { + Intent intent = getIntent(); + final String title = intent.getStringExtra(EXTRA_REBLOG_POST_TITLE); + final String quote = intent.getStringExtra(EXTRA_REBLOG_POST_QUOTE); + final String citation = intent.getStringExtra(EXTRA_REBLOG_POST_CITATION); + final String image = intent.getStringExtra(EXTRA_REBLOG_POST_IMAGE); + String content = mReblogUtils.reblogContent(image, quote, title, citation); + + newPostSetup(title, content); + } + private void newPageFromLayoutPickerSetup(String title, String layoutSlug) { + String content = mSiteStore.getBlockLayoutContent(mSite, layoutSlug); + newPostSetup(title, content); + } + + private void newPostSetup(String title, String content) { mIsNewPost = true; if (mSite == null) { @@ -459,7 +484,6 @@ private void newPageFromLayoutPickerSetup(String title, String layoutSlug) { showErrorAndFinish(R.string.error_blog_hidden); return; } - String content = mSiteStore.getBlockLayoutContent(mSite, layoutSlug); // Create a new post mEditPostRepository.set(() -> { PostModel post = mPostStore.instantiatePostModel(mSite, mIsPage, title, content, @@ -552,6 +576,10 @@ protected void onCreate(Bundle savedInstanceState) { if (mIsPage && !TextUtils.isEmpty(extras.getString(EXTRA_PAGE_TITLE))) { newPageFromLayoutPickerSetup(extras.getString(EXTRA_PAGE_TITLE), extras.getString(EXTRA_PAGE_TEMPLATE)); + } else if (Intent.ACTION_SEND.equals(action)) { + newPostFromShareAction(); + } else if (ACTION_REBLOG.equals(action)) { + newReblogPostSetup(); } else { newPostSetup(); } @@ -2357,13 +2385,11 @@ private void fillContentEditorFields() { // Special actions - these only make sense for empty posts that are going to be populated now if (TextUtils.isEmpty(mEditPostRepository.getContent())) { String action = getIntent().getAction(); - if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { + if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { setPostContentFromShareAction(); } else if (NEW_MEDIA_POST.equals(action)) { mEditorMedia.addExistingMediaToEditorAsync(AddExistingMediaSource.WP_MEDIA_LIBRARY, getIntent().getLongArrayExtra(NEW_MEDIA_POST_EXTRA_IDS)); - } else if (ACTION_REBLOG.equals(action)) { - setPostContentFromReblogAction(); } } @@ -2494,33 +2520,6 @@ private void setFeaturedImageId(final long mediaId, final boolean imagePicked, f } } - /** - * Sets the content of the reblogged post - */ - private void setPostContentFromReblogAction() { - Intent intent = getIntent(); - final String title = intent.getStringExtra(EXTRA_REBLOG_POST_TITLE); - final String quote = intent.getStringExtra(EXTRA_REBLOG_POST_QUOTE); - final String citation = intent.getStringExtra(EXTRA_REBLOG_POST_CITATION); - final String image = intent.getStringExtra(EXTRA_REBLOG_POST_IMAGE); - if (title != null && quote != null) { - mHasSetPostContent = true; - mEditPostRepository.updateAsync(postModel -> { - postModel.setTitle(title); - String content = mReblogUtils.reblogContent(image, quote, title, citation, mShowGutenbergEditor); - postModel.setContent(content); - mEditPostRepository.updatePublishDateIfShouldBePublishedImmediately(postModel); - return true; - }, (postModel, result) -> { - if (result == UpdatePostResult.Updated.INSTANCE) { - mEditorFragment.setTitle(postModel.getTitle()); - mEditorFragment.setContent(postModel.getContent()); - } - return null; - }); - } - } - /** * Sets the page content */