From d11ff41fc7d6cf655f89cbfeb5b892de25f74e54 Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Tue, 19 May 2020 18:13:44 -0400 Subject: [PATCH 1/5] Provide exception logger for gutenberg --- RELEASE-NOTES.txt | 1 + .../org/wordpress/android/ui/posts/EditPostActivity.java | 9 ++++++++- .../org/wordpress/android/editor/ExceptionLogger.java | 7 +++++++ .../android/editor/GutenbergContainerFragment.java | 9 ++++++++- libs/gutenberg-mobile | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 27f84a523b46..533a2196b4b9 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -3,6 +3,7 @@ 14.9 ----- +* [**] Block editor: Avoid crash when editor gets into invalid state * [*] Fix issue with Preview post not working after switching to classic editor from inside the post * [***] Block Editor: New block: Pullquote * [**] Block Editor: Add support for changing background and text color in Buttons block 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 7fd1637d5541..91230f54e862 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 @@ -63,6 +63,7 @@ import org.wordpress.android.editor.EditorImageSettingsListener; import org.wordpress.android.editor.EditorMediaUploadListener; import org.wordpress.android.editor.EditorMediaUtils; +import org.wordpress.android.editor.ExceptionLogger; import org.wordpress.android.editor.GutenbergEditorFragment; import org.wordpress.android.editor.ImageSettingsDialogFragment; import org.wordpress.android.fluxc.Dispatcher; @@ -226,7 +227,8 @@ public class EditPostActivity extends LocaleAwareActivity implements PostSettingsListDialogFragment.OnPostSettingsDialogFragmentListener, HistoryListFragment.HistoryItemClickInterface, EditPostSettingsCallback, - PrivateAtCookieProgressDialogOnDismissListener { + PrivateAtCookieProgressDialogOnDismissListener, + ExceptionLogger { public static final String ACTION_REBLOG = "reblogAction"; public static final String EXTRA_POST_LOCAL_ID = "postModelLocalId"; public static final String EXTRA_LOAD_AUTO_SAVE_REVISION = "loadAutosaveRevision"; @@ -3087,6 +3089,11 @@ public void syncPostObjectWithUiAndSaveIt(@Nullable OnPostUpdatedFromUIListener WPMediaUtils.advertiseImageOptimization(this, listener::invoke); } + @Override + public Consumer getExceptionLogger() { + return (Exception e) -> CrashLoggingUtils.logException(e, T.EDITOR); + } + private void updateAddingMediaToEditorProgressDialogState(ProgressDialogUiState uiState) { mAddingMediaToEditorProgressDialog = mProgressDialogHelper .updateProgressDialogState(this, mAddingMediaToEditorProgressDialog, uiState, mUiHelpers); diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java new file mode 100644 index 000000000000..9ad7cf810f7f --- /dev/null +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java @@ -0,0 +1,7 @@ +package org.wordpress.android.editor; + +import androidx.core.util.Consumer; + +public interface ExceptionLogger { + Consumer getExceptionLogger(); +} diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java index 14df597555be..a3ab05b2100e 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java @@ -3,6 +3,7 @@ import android.os.Bundle; import android.view.ViewGroup; +import androidx.core.util.Consumer; import androidx.fragment.app.Fragment; import org.wordpress.mobile.WPAndroidGlue.RequestExecutor; @@ -88,6 +89,11 @@ public void onCreate(Bundle savedInstanceState) { Bundle translations = getArguments().getBundle(ARG_TRANSLATIONS); boolean isDarkMode = getArguments().getBoolean(ARG_PREFERRED_COLOR_SCHEME); + Consumer exceptionLogger = null; + if (getActivity() instanceof ExceptionLogger) { + exceptionLogger = ((ExceptionLogger) getActivity()).getExceptionLogger(); + } + mWPAndroidGlueCode = new WPAndroidGlueCode(); mWPAndroidGlueCode.onCreate(getContext()); mWPAndroidGlueCode.onCreateView( @@ -101,7 +107,8 @@ public void onCreate(Bundle savedInstanceState) { localeString, translations, getContext().getResources().getColor(R.color.background_color), - isDarkMode); + isDarkMode, + exceptionLogger); // clear the content initialization flag since a new ReactRootView has been created; mHasReceivedAnyContent = false; diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index fe0b27e85f1d..63af45506a36 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit fe0b27e85f1d8f460c2a36d88f8b6aa248f88c13 +Subproject commit 63af45506a36ddd2c54a28f1655a8c31014da2ba From 757f22846b66ca07ba06838e1ef1a69bf87ba1c1 Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Fri, 22 May 2020 14:39:31 -0400 Subject: [PATCH 2/5] Provide breadcrumb logger to Gutenberg --- .../org/wordpress/android/ui/posts/EditPostActivity.java | 5 +++++ .../org/wordpress/android/editor/ExceptionLogger.java | 1 + .../android/editor/GutenbergContainerFragment.java | 8 ++++++-- libs/gutenberg-mobile | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) 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 91230f54e862..bd48207b3374 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 @@ -3094,6 +3094,11 @@ public Consumer getExceptionLogger() { return (Exception e) -> CrashLoggingUtils.logException(e, T.EDITOR); } + @Override + public Consumer getBreadcrumbLogger() { + return CrashLoggingUtils::log; + } + private void updateAddingMediaToEditorProgressDialogState(ProgressDialogUiState uiState) { mAddingMediaToEditorProgressDialog = mProgressDialogHelper .updateProgressDialogState(this, mAddingMediaToEditorProgressDialog, uiState, mUiHelpers); diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java index 9ad7cf810f7f..384216394c45 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ExceptionLogger.java @@ -4,4 +4,5 @@ public interface ExceptionLogger { Consumer getExceptionLogger(); + Consumer getBreadcrumbLogger(); } diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java index a3ab05b2100e..62e1b3b86fd1 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java @@ -90,8 +90,11 @@ public void onCreate(Bundle savedInstanceState) { boolean isDarkMode = getArguments().getBoolean(ARG_PREFERRED_COLOR_SCHEME); Consumer exceptionLogger = null; + Consumer breadcrumbLogger = null; if (getActivity() instanceof ExceptionLogger) { - exceptionLogger = ((ExceptionLogger) getActivity()).getExceptionLogger(); + ExceptionLogger exceptionLoggingActivity = ((ExceptionLogger) getActivity()); + exceptionLogger = exceptionLoggingActivity.getExceptionLogger(); + breadcrumbLogger = exceptionLoggingActivity.getBreadcrumbLogger(); } mWPAndroidGlueCode = new WPAndroidGlueCode(); @@ -108,7 +111,8 @@ public void onCreate(Bundle savedInstanceState) { translations, getContext().getResources().getColor(R.color.background_color), isDarkMode, - exceptionLogger); + exceptionLogger, + breadcrumbLogger); // clear the content initialization flag since a new ReactRootView has been created; mHasReceivedAnyContent = false; diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 63af45506a36..999672feb296 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 63af45506a36ddd2c54a28f1655a8c31014da2ba +Subproject commit 999672feb29660666d5ef27e79c1f0d42d1e1692 From 5bd50c5bcc7687481e06933a813f069894a54ded Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Mon, 25 May 2020 10:54:33 -0400 Subject: [PATCH 3/5] Remove release note --- RELEASE-NOTES.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 533a2196b4b9..27f84a523b46 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -3,7 +3,6 @@ 14.9 ----- -* [**] Block editor: Avoid crash when editor gets into invalid state * [*] Fix issue with Preview post not working after switching to classic editor from inside the post * [***] Block Editor: New block: Pullquote * [**] Block Editor: Add support for changing background and text color in Buttons block From 170b413c03dedb9e6f5401b553eb758d09faaf44 Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Mon, 25 May 2020 10:54:42 -0400 Subject: [PATCH 4/5] Update gutenberg-mobile submodule ref --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 999672feb296..7028268567f8 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 999672feb29660666d5ef27e79c1f0d42d1e1692 +Subproject commit 7028268567f8136044c5de50df00add3913d5350 From b7515f03882683e4a713793bff5abd2ac1ed9640 Mon Sep 17 00:00:00 2001 From: Matt Chowning Date: Mon, 25 May 2020 16:15:18 -0400 Subject: [PATCH 5/5] Update gutenberg submodule ref to 1.28.1 --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 7028268567f8..c175973ca5cd 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 7028268567f8136044c5de50df00add3913d5350 +Subproject commit c175973ca5cd52873bbf6045be6635492ad165c8