Skip to content

Commit

Permalink
Add Gutenberg Embed WebView Activity (#18383)
Browse files Browse the repository at this point in the history
* Add Gutenberg Embed WebView Activity

* Remove debugging setup

* Linting

* Update Gutenberg ref

* Update Gutenberg ref

* Update Gutenberg

* Update Gutenberg

* Trigger CI

* Remove class WPGutenbergEmbedWebViewActivity

* Update Gutenberg

* Trigger CI

* Point Gutenberg to v1.95.0-alpha1

* Trigger CI

* fix typo in gb source

---------

Co-authored-by: jhnstn <[email protected]>
  • Loading branch information
jhnstn and jhnstn authored May 10, 2023
1 parent c6ada15 commit f7cbb06
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ext {
automatticRestVersion = '1.0.8'
automatticStoriesVersion = '2.1.0'
automatticTracksVersion = '2.2.0'
gutenbergMobileVersion = 'v1.94.0'
gutenbergMobileVersion = 'v1.95.0-alpha1'
wordPressAztecVersion = 'v1.6.3'
wordPressFluxCVersion = 'trunk-2d2bf4a52d3d1bcc434529a3700213c376206f7f'
wordPressLoginVersion = '1.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnEditorAutosaveListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnEditorMountListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGetContentInterrupted;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidRequestEmbedFullscreenPreviewListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidRequestUnsupportedBlockFallbackListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidSendButtonPressedActionListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnImageFullscreenPreviewListener;
Expand Down Expand Up @@ -73,6 +74,8 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
OnMediaEditorListener onMediaEditorListener,
OnGutenbergDidRequestUnsupportedBlockFallbackListener
onGutenbergDidRequestUnsupportedBlockFallbackListener,
OnGutenbergDidRequestEmbedFullscreenPreviewListener
onGutenbergDidRequestEmbedFullscreenPreviewListener,
OnGutenbergDidSendButtonPressedActionListener
onGutenbergDidSendButtonPressedActionListener,
ShowSuggestionsUtil showSuggestionsUtil,
Expand All @@ -98,6 +101,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
onImageFullscreenPreviewListener,
onMediaEditorListener,
onGutenbergDidRequestUnsupportedBlockFallbackListener,
onGutenbergDidRequestEmbedFullscreenPreviewListener,
onGutenbergDidSendButtonPressedActionListener,
showSuggestionsUtil,
onMediaFilesCollectionBasedBlockEditorListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.wordpress.android.util.helpers.MediaFile;
import org.wordpress.android.util.helpers.MediaGallery;
import org.wordpress.aztec.IHistoryListener;
import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergEmbedWebViewActivity;
import org.wordpress.mobile.WPAndroidGlue.Media;
import org.wordpress.mobile.WPAndroidGlue.MediaOption;
import org.wordpress.mobile.WPAndroidGlue.RequestExecutor;
Expand All @@ -71,6 +72,7 @@
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnEditorMountListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnFocalPointPickerTooltipShownEventListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGetContentInterrupted;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidRequestEmbedFullscreenPreviewListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidRequestPreviewListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidRequestUnsupportedBlockFallbackListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidSendButtonPressedActionListener;
Expand Down Expand Up @@ -123,6 +125,8 @@ public class GutenbergEditorFragment extends EditorFragmentAbstract implements

private static final int UNSUPPORTED_BLOCK_REQUEST_CODE = 1001;

private static final int EMBED_FULLSCREEN_PREVIEW_CODE = 1002;

private static final String TAG_REPLACE_FEATURED_DIALOG = "REPLACE_FEATURED_DIALOG";

public static final int MEDIA_ID_NO_FEATURED_IMAGE_SET = 0;
Expand Down Expand Up @@ -427,6 +431,11 @@ public void gutenbergDidRequestUnsupportedBlockFallback(UnsupportedBlock unsuppo
);
}
},
new OnGutenbergDidRequestEmbedFullscreenPreviewListener() {
@Override public void gutenbergDidRequestEmbedFullscreenPreview(String html, String title) {
openGutenbergEmbedWebViewActivity(html, title);
}
},
new OnGutenbergDidSendButtonPressedActionListener() {
@Override
public void gutenbergDidSendButtonPressedAction(String buttonType) {
Expand Down Expand Up @@ -637,6 +646,15 @@ private void trackWebViewClosed(String action) {
properties);
}

private void openGutenbergEmbedWebViewActivity(String html, String title) {
Activity activity = getActivity();

Intent intent = new Intent(activity, GutenbergEmbedWebViewActivity.class);
intent.putExtra(GutenbergEmbedWebViewActivity.ARG_CONTENT, html);
intent.putExtra(GutenbergEmbedWebViewActivity.ARG_TITLE, title);
activity.startActivityForResult(intent, EMBED_FULLSCREEN_PREVIEW_CODE);
}

@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand Down

0 comments on commit f7cbb06

Please sign in to comment.