Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gutenberg Embed WebView Activity #18383

Merged
merged 14 commits into from
May 10, 2023
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 = '5743-56b47861ca8d9ea1816bd364784aba1d915b1786'
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