From 3380001c4753f38695899b4e8a12fa43510104a3 Mon Sep 17 00:00:00 2001 From: Cameron Voell Date: Mon, 28 Sep 2020 11:29:04 -0700 Subject: [PATCH 01/13] Release script: Update react-native-editor version to 1.38.0 --- packages/react-native-aztec/package.json | 2 +- packages/react-native-bridge/package.json | 2 +- packages/react-native-editor/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-aztec/package.json b/packages/react-native-aztec/package.json index 92e18aa66fdb7..264f337c5bf6b 100644 --- a/packages/react-native-aztec/package.json +++ b/packages/react-native-aztec/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-aztec", - "version": "1.37.1", + "version": "1.38.0", "description": "Aztec view for react-native.", "private": true, "author": "The WordPress Contributors", diff --git a/packages/react-native-bridge/package.json b/packages/react-native-bridge/package.json index be5e28db61cee..631c0a869b128 100644 --- a/packages/react-native-bridge/package.json +++ b/packages/react-native-bridge/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-bridge", - "version": "1.37.1", + "version": "1.38.0", "description": "Native bridge library used to integrate the block editor into a native App.", "private": true, "author": "The WordPress Contributors", diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index 72568ed60b7e4..4cb3af389e577 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-editor", - "version": "1.37.1", + "version": "1.38.0", "description": "Mobile WordPress gutenberg editor.", "author": "The WordPress Contributors", "license": "GPL-2.0-or-later", From 7bbeb3bbd95f6c658e6e5cbc0991917404d33422 Mon Sep 17 00:00:00 2001 From: Cameron Voell Date: Mon, 28 Sep 2020 11:29:18 -0700 Subject: [PATCH 02/13] Release script: Update with changes from 'npm run core preios' --- packages/react-native-editor/ios/Podfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-native-editor/ios/Podfile.lock b/packages/react-native-editor/ios/Podfile.lock index 3b6872d351f4d..afa8a1ebeec78 100644 --- a/packages/react-native-editor/ios/Podfile.lock +++ b/packages/react-native-editor/ios/Podfile.lock @@ -21,7 +21,7 @@ PODS: - DoubleConversion - glog - glog (0.3.5) - - Gutenberg (1.37.1): + - Gutenberg (1.38.0): - React (= 0.61.5) - React-CoreModules (= 0.61.5) - React-RCTImage (= 0.61.5) @@ -253,7 +253,7 @@ PODS: - React - RNSVG (9.13.6-gb): - React - - RNTAztecView (1.37.1): + - RNTAztecView (1.38.0): - React-Core - WordPress-Aztec-iOS (~> 1.19.3) - WordPress-Aztec-iOS (1.19.3) @@ -402,7 +402,7 @@ SPEC CHECKSUMS: FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75 Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 glog: 1f3da668190260b06b429bb211bfbee5cd790c28 - Gutenberg: af33e34fe17d58eff688914531e28b21e79fc8a3 + Gutenberg: 16995dc909ddd0ca483ac12178b207afb4be8dab RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1 RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320 React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78 @@ -435,7 +435,7 @@ SPEC CHECKSUMS: RNReanimated: b5ccb50650ba06f6e749c7c329a1bc3ae0c88b43 RNScreens: c526239bbe0e957b988dacc8d75ac94ec9cb19da RNSVG: 68a534a5db06dcbdaebfd5079349191598caef7b - RNTAztecView: 38857b9da561bc604665ae22b5e8745ba0197e7c + RNTAztecView: 2da38646865bbec1df987a1bbcad55e0cabf08fd WordPress-Aztec-iOS: b7ac8b30f746992e85d9668453ac87c2cdcecf4f Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b From 6c1ebae80ba5ffd4911d31e40aa7323b28389673 Mon Sep 17 00:00:00 2001 From: Cameron Voell Date: Tue, 29 Sep 2020 09:47:22 -0700 Subject: [PATCH 03/13] Update aztec reference to tagged release 1.3.45 --- packages/react-native-aztec/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-aztec/android/build.gradle b/packages/react-native-aztec/android/build.gradle index 987dcb784bd3f..6209efe5141b1 100644 --- a/packages/react-native-aztec/android/build.gradle +++ b/packages/react-native-aztec/android/build.gradle @@ -11,7 +11,7 @@ buildscript { jSoupVersion = '1.10.3' wordpressUtilsVersion = '1.22' espressoVersion = '3.0.1' - aztecVersion = 'b8fa76f10346f6e8b979697154d3680f96cb79ff' + aztecVersion = 'v1.3.45' } repositories { From cbf445895816a6fe8c2d0d79c9c5cc4ae8c66475 Mon Sep 17 00:00:00 2001 From: Luke Walczak Date: Wed, 30 Sep 2020 18:37:35 +0200 Subject: [PATCH 04/13] Correct BottomSheet in ModalLinkUI (#25740) --- packages/format-library/src/link/modal.native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index bc287fc2b4942..fe9261933c7ae 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -22,6 +22,7 @@ const ModalLinkUI = ( { isVisible, ...restProps } ) => { isChildrenScrollable isVisible={ isVisible } hideHeader + onClose={ restProps.onClose } > From 10abc01fa28560a823417858c3934f7848d97507 Mon Sep 17 00:00:00 2001 From: Luke Walczak Date: Wed, 30 Sep 2020 18:59:18 +0200 Subject: [PATCH 05/13] Pass shouldEnableBottomSheetScroll into ColorPalette (#25734) --- .../block-library/src/cover/edit.native.js | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/cover/edit.native.js b/packages/block-library/src/cover/edit.native.js index 6c8e14c33feba..ee9f7c86e7f03 100644 --- a/packages/block-library/src/cover/edit.native.js +++ b/packages/block-library/src/cover/edit.native.js @@ -455,19 +455,26 @@ const Cover = ( { onFocus={ onFocus } > - + + { ( { shouldEnableBottomSheetScroll } ) => ( + + ) } + From c5ace9e56be03561754cb7c438000667f0899547 Mon Sep 17 00:00:00 2001 From: Ceyhun Ozugur Date: Mon, 12 Oct 2020 19:58:07 +0200 Subject: [PATCH 06/13] Release script: Update react-native-editor version to 1.38.1 --- packages/react-native-aztec/package.json | 2 +- packages/react-native-bridge/package.json | 2 +- packages/react-native-editor/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-aztec/package.json b/packages/react-native-aztec/package.json index 264f337c5bf6b..0737831cff924 100644 --- a/packages/react-native-aztec/package.json +++ b/packages/react-native-aztec/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-aztec", - "version": "1.38.0", + "version": "1.38.1", "description": "Aztec view for react-native.", "private": true, "author": "The WordPress Contributors", diff --git a/packages/react-native-bridge/package.json b/packages/react-native-bridge/package.json index 631c0a869b128..69610b85fb75e 100644 --- a/packages/react-native-bridge/package.json +++ b/packages/react-native-bridge/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-bridge", - "version": "1.38.0", + "version": "1.38.1", "description": "Native bridge library used to integrate the block editor into a native App.", "private": true, "author": "The WordPress Contributors", diff --git a/packages/react-native-editor/package.json b/packages/react-native-editor/package.json index 4cb3af389e577..c00c162221ad8 100644 --- a/packages/react-native-editor/package.json +++ b/packages/react-native-editor/package.json @@ -1,6 +1,6 @@ { "name": "@wordpress/react-native-editor", - "version": "1.38.0", + "version": "1.38.1", "description": "Mobile WordPress gutenberg editor.", "author": "The WordPress Contributors", "license": "GPL-2.0-or-later", From f09c6adc5e8451583ad13d604cdb6d03f75a809d Mon Sep 17 00:00:00 2001 From: Ceyhun Ozugur Date: Mon, 12 Oct 2020 20:00:04 +0200 Subject: [PATCH 07/13] Release script: Update with changes from 'npm run core preios' --- packages/react-native-editor/ios/Podfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-native-editor/ios/Podfile.lock b/packages/react-native-editor/ios/Podfile.lock index afa8a1ebeec78..505d997ca06b5 100644 --- a/packages/react-native-editor/ios/Podfile.lock +++ b/packages/react-native-editor/ios/Podfile.lock @@ -21,7 +21,7 @@ PODS: - DoubleConversion - glog - glog (0.3.5) - - Gutenberg (1.38.0): + - Gutenberg (1.38.1): - React (= 0.61.5) - React-CoreModules (= 0.61.5) - React-RCTImage (= 0.61.5) @@ -253,7 +253,7 @@ PODS: - React - RNSVG (9.13.6-gb): - React - - RNTAztecView (1.38.0): + - RNTAztecView (1.38.1): - React-Core - WordPress-Aztec-iOS (~> 1.19.3) - WordPress-Aztec-iOS (1.19.3) @@ -402,7 +402,7 @@ SPEC CHECKSUMS: FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75 Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 glog: 1f3da668190260b06b429bb211bfbee5cd790c28 - Gutenberg: 16995dc909ddd0ca483ac12178b207afb4be8dab + Gutenberg: cd59990946ff2a1ccf5e3c200ed29dad03674650 RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1 RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320 React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78 @@ -435,7 +435,7 @@ SPEC CHECKSUMS: RNReanimated: b5ccb50650ba06f6e749c7c329a1bc3ae0c88b43 RNScreens: c526239bbe0e957b988dacc8d75ac94ec9cb19da RNSVG: 68a534a5db06dcbdaebfd5079349191598caef7b - RNTAztecView: 2da38646865bbec1df987a1bbcad55e0cabf08fd + RNTAztecView: 396adafbdeba07cd1badc39bffa0cf87d277bfb6 WordPress-Aztec-iOS: b7ac8b30f746992e85d9668453ac87c2cdcecf4f Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b From 9121a18eecb61789f76af4f46a1b0cea95e63928 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 12 Oct 2020 14:10:32 -0400 Subject: [PATCH 08/13] Fix UBE issue: cannot view or interact with the classic block on Jetpack sites (#26006) --- .../ReactNativeGutenbergBridge/GutenbergWebViewActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java index f9667dc54fa33..f8e00e60211b0 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java @@ -226,12 +226,13 @@ private void evaluateJavaScript(String script) { private void onGutenbergReady() { preventAutoSavesScript(); - insertBlockScript(); final Handler handler = new Handler(); handler.postDelayed(() -> { // We want to make sure that page is loaded // with all elements before executing external JS injectOnGutenbergReadyExternalSources(); + // Inject block content + insertBlockScript(); // We need some extra time to hide all unwanted html elements // like NUX (new user experience) modal is. mForegroundView.postDelayed(() -> mForegroundView.setVisibility(View.INVISIBLE), 1500); From 037f0c56ba78fe0895da51286dc187e7b1958b44 Mon Sep 17 00:00:00 2001 From: Ceyhun Ozugur Date: Mon, 12 Oct 2020 20:57:32 +0200 Subject: [PATCH 09/13] Update CHANGELOG.md --- packages/react-native-editor/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 0da95114186f8..64c7b10f58d6a 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -11,6 +11,10 @@ For each user feature we should also add a importance categorization label to i ## Unreleased +## 1.38.1 +------ +* [***] Unsupported Block Editor: Fixed issue when cannot view or interact with the classic block on Jetpack sites + ## 1.38.0 [***] Add support for selecting user's post when configuring the link From 0b11e6b0f7cdf9e813ddf926404e06f1b49a8bdb Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 12 Oct 2020 16:26:01 -0400 Subject: [PATCH 10/13] Fix rotation issue (#25873) --- packages/block-library/src/missing/edit.native.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/missing/edit.native.js b/packages/block-library/src/missing/edit.native.js index b6fa3a4415e4c..b2f1c60cbf014 100644 --- a/packages/block-library/src/missing/edit.native.js +++ b/packages/block-library/src/missing/edit.native.js @@ -30,6 +30,7 @@ export class UnsupportedBlockEdit extends Component { super( props ); this.state = { showHelp: false }; this.toggleSheet = this.toggleSheet.bind( this ); + this.closeSheet = this.closeSheet.bind( this ); this.requestFallback = this.requestFallback.bind( this ); } @@ -39,6 +40,12 @@ export class UnsupportedBlockEdit extends Component { } ); } + closeSheet() { + this.setState( { + showHelp: false, + } ); + } + componentWillUnmount() { if ( this.timeout ) { clearTimeout( this.timeout ); @@ -114,7 +121,7 @@ export class UnsupportedBlockEdit extends Component { { if ( this.state.sendFallbackMessage ) { // On iOS, onModalHide is called when the controller is still part of the hierarchy. From c771f2ea36ed816e31e72dc9b93cfed9784642d6 Mon Sep 17 00:00:00 2001 From: Ceyhun Ozugur Date: Tue, 13 Oct 2020 18:11:17 +0200 Subject: [PATCH 11/13] Update changelog --- packages/react-native-editor/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 64c7b10f58d6a..4b9dbeb868f07 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -12,8 +12,9 @@ For each user feature we should also add a importance categorization label to i ## Unreleased ## 1.38.1 ------- -* [***] Unsupported Block Editor: Fixed issue when cannot view or interact with the classic block on Jetpack sites + +* [***] Fix unsupported block bottom sheet is triggered when device is rotated +* [***] Unsupported Block Editor: Fixed issue when cannot view or interact with the classic block on Jetpack site ## 1.38.0 From a68eb7480597aa293a02d8235f0a88e5a7c131c3 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Wed, 14 Oct 2020 12:21:06 -0400 Subject: [PATCH 12/13] [RN Mobile] UBE - Inject css on both page visible and page started (#26071) --- .../GutenbergWebViewActivity.java | 84 ++++++++++++++----- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java index f8e00e60211b0..78b4882666fc6 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java @@ -10,22 +10,24 @@ import android.view.View; import android.webkit.CookieManager; import android.webkit.JavascriptInterface; +import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; +import android.widget.ProgressBar; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; -import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.helpers.WPWebChromeClient; +import org.wordpress.android.util.AppLog;; import org.wordpress.mobile.FileUtils; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.concurrent.atomic.AtomicBoolean; public class GutenbergWebViewActivity extends AppCompatActivity { @@ -42,6 +44,11 @@ public class GutenbergWebViewActivity extends AppCompatActivity { protected View mForegroundView; protected boolean mIsRedirected; + private ProgressBar mProgressBar; + private boolean mIsGutenbergReady; + private AtomicBoolean mIsWebPageLoaded = new AtomicBoolean(false); + private AtomicBoolean mIsBlockContentInserted = new AtomicBoolean(false); + @SuppressLint("SetJavaScriptEnabled") protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -51,6 +58,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { mWebView = findViewById(R.id.gutenberg_web_view); mForegroundView = findViewById(R.id.foreground_view); + mProgressBar = findViewById(R.id.progress_bar); // Set settings WebSettings settings = mWebView.getSettings(); @@ -64,7 +72,31 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { // Setup WebView client setupWebViewClient(); - mWebView.setWebChromeClient(new WPWebChromeClient(null, findViewById(R.id.progress_bar))); + + // Setup Web Chrome client + mWebView.setWebChromeClient(new WebChromeClient() { + @Override + public void onProgressChanged(WebView view, int progress) { + if (progress == 100 && !mIsWebPageLoaded.getAndSet(true)) { + // We want to insert block content + // only if gutenberg is ready + if (mIsGutenbergReady) { + mProgressBar.setVisibility(View.GONE); + final Handler handler = new Handler(); + handler.postDelayed(() -> { + // Insert block content + insertBlockScript(); + }, 200); + } + } + else { + if (progress < 100) { + mIsWebPageLoaded.compareAndSet(true, false); + } + mProgressBar.setProgress(progress); + } + } + }); loadUrl(); } @@ -167,9 +199,6 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { @Override public void onPageCommitVisible(WebView view, String url) { - String injectCssScript = getFileContentFromAssets("gutenberg-web-single-block/inject-css.js"); - evaluateJavaScript(injectCssScript); - long userId = getUserId(); if (userId != 0) { String injectLocalStorageScript = getFileContentFromAssets("gutenberg-web-single-block/local-storage-overrides.json"); @@ -205,14 +234,6 @@ public void onPageFinished(WebView view, String url) { String contentFunctions = getFileContentFromAssets("gutenberg-web-single-block/content-functions.js"); evaluateJavaScript(contentFunctions); - String editorStyle = getFileContentFromAssets("gutenberg-web-single-block/editor-style-overrides.css"); - editorStyle = removeWhiteSpace(removeNewLines(editorStyle)); - evaluateJavaScript(String.format(INJECT_CSS_SCRIPT_TEMPLATE, editorStyle)); - - String injectWPBarsCssScript = getFileContentFromAssets("gutenberg-web-single-block/wp-bar-override.css"); - injectWPBarsCssScript = removeWhiteSpace(removeNewLines(injectWPBarsCssScript)); - evaluateJavaScript(String.format(INJECT_CSS_SCRIPT_TEMPLATE, injectWPBarsCssScript)); - String injectGutenbergObserver = getFileContentFromAssets("gutenberg-web-single-block/gutenberg-observer.js"); evaluateJavaScript(injectGutenbergObserver); } @@ -226,19 +247,40 @@ private void evaluateJavaScript(String script) { private void onGutenbergReady() { preventAutoSavesScript(); + // Inject css when Gutenberg is ready + injectCssScript(); final Handler handler = new Handler(); handler.postDelayed(() -> { + mIsGutenbergReady = true; // We want to make sure that page is loaded // with all elements before executing external JS injectOnGutenbergReadyExternalSources(); - // Inject block content - insertBlockScript(); + // If page is loaded try to insert block content + if (mIsWebPageLoaded.get()) { + // Insert block content + insertBlockScript(); + } // We need some extra time to hide all unwanted html elements // like NUX (new user experience) modal is. mForegroundView.postDelayed(() -> mForegroundView.setVisibility(View.INVISIBLE), 1500); }, 2000); } + private void injectCssScript() { + String injectCssScript = getFileContentFromAssets("gutenberg-web-single-block/inject-css.js"); + mWebView.evaluateJavascript(injectCssScript, message -> { + if (message != null) { + String editorStyle = getFileContentFromAssets("gutenberg-web-single-block/editor-style-overrides.css"); + editorStyle = removeWhiteSpace(removeNewLines(editorStyle)); + evaluateJavaScript(String.format(INJECT_CSS_SCRIPT_TEMPLATE, editorStyle)); + + String injectWPBarsCssScript = getFileContentFromAssets("gutenberg-web-single-block/wp-bar-override.css"); + injectWPBarsCssScript = removeWhiteSpace(removeNewLines(injectWPBarsCssScript)); + evaluateJavaScript(String.format(INJECT_CSS_SCRIPT_TEMPLATE, injectWPBarsCssScript)); + } + }); + } + private void injectOnGutenbergReadyExternalSources() { List list = getOnGutenbergReadyExternalSources(); for (String file : list) { @@ -267,10 +309,12 @@ private void preventAutoSavesScript() { } private void insertBlockScript() { - String insertBlock = getFileContentFromAssets("gutenberg-web-single-block/insert-block.js").replace("%@","%s"); - String blockContent = getIntent().getExtras().getString(ARG_BLOCK_CONTENT); - insertBlock = String.format(insertBlock, blockContent); - evaluateJavaScript(removeNewLines(insertBlock.replace("\\n", "\\\\n"))); + if (!mIsBlockContentInserted.getAndSet(true)) { + String insertBlock = getFileContentFromAssets("gutenberg-web-single-block/insert-block.js").replace("%@","%s"); + String blockContent = getIntent().getExtras().getString(ARG_BLOCK_CONTENT); + insertBlock = String.format(insertBlock, blockContent); + evaluateJavaScript(removeNewLines(insertBlock.replace("\\n", "\\\\n"))); + } } @Override From 63f135417c99cee272e994b4cc1bbfb2ee89e222 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Thu, 15 Oct 2020 17:21:46 -0400 Subject: [PATCH 13/13] [RN Mobile] Ube cannot view or interact with the classic block on jetpack sites (#26168) --- .../GutenbergWebViewActivity.java | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java index 78b4882666fc6..f89df4562b42d 100644 --- a/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java +++ b/packages/react-native-bridge/android/src/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergWebViewActivity.java @@ -4,6 +4,7 @@ import android.graphics.Bitmap; import android.os.Bundle; import android.os.Handler; +import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -48,6 +49,23 @@ public class GutenbergWebViewActivity extends AppCompatActivity { private boolean mIsGutenbergReady; private AtomicBoolean mIsWebPageLoaded = new AtomicBoolean(false); private AtomicBoolean mIsBlockContentInserted = new AtomicBoolean(false); + private final Handler mWebPageLoadedHandler = new Handler(); + private final Runnable mWebPageLoadedRunnable = new Runnable() { + @Override public void run() { + if (!mIsWebPageLoaded.getAndSet(true)) { + mProgressBar.setVisibility(View.GONE); + // We want to insert block content + // only if gutenberg is ready + if (mIsGutenbergReady) { + final Handler handler = new Handler(); + handler.postDelayed(() -> { + // Insert block content + insertBlockScript(); + }, 200); + } + } + } + }; @SuppressLint("SetJavaScriptEnabled") protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -77,21 +95,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { - if (progress == 100 && !mIsWebPageLoaded.getAndSet(true)) { - // We want to insert block content - // only if gutenberg is ready - if (mIsGutenbergReady) { - mProgressBar.setVisibility(View.GONE); - final Handler handler = new Handler(); - handler.postDelayed(() -> { - // Insert block content - insertBlockScript(); - }, 200); - } - } - else { - if (progress < 100) { - mIsWebPageLoaded.compareAndSet(true, false); + if (progress == 100) { + mWebPageLoadedHandler.removeCallbacks(mWebPageLoadedRunnable); + mWebPageLoadedHandler.postDelayed(mWebPageLoadedRunnable, 1500); + } else { + mIsWebPageLoaded.compareAndSet(true, false); + if (mProgressBar.getVisibility() == View.GONE) { + mProgressBar.setVisibility(View.VISIBLE); } mProgressBar.setProgress(progress); } @@ -351,6 +361,12 @@ public void finish() { super.finish(); } + @Override + protected void onDestroy() { + mWebPageLoadedHandler.removeCallbacks(mWebPageLoadedRunnable); + super.onDestroy(); + } + public class WPWebKit { @JavascriptInterface public void postMessage(String content) {