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

feat: Provide Gutenberg editor network connection status #19692

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
import org.wordpress.android.fluxc.store.bloggingprompts.BloggingPromptsStore;
import org.wordpress.android.fluxc.tools.FluxCImageLoader;
import org.wordpress.android.imageeditor.preview.PreviewImageFragment.Companion.EditImageData;
import org.wordpress.android.networking.ConnectionChangeReceiver;
import org.wordpress.android.support.ZendeskHelper;
import org.wordpress.android.ui.ActivityId;
import org.wordpress.android.ui.ActivityLauncher;
Expand Down Expand Up @@ -3823,6 +3824,11 @@ public void onEventMainThread(UploadService.UploadMediaRetryEvent event) {
}
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(ConnectionChangeReceiver.ConnectionChangeEvent event) {
((GutenbergEditorFragment) mEditorFragment).onConnectionStatusChange(event.isConnected());
}

private void refreshEditorTheme() {
FetchEditorThemePayload payload =
new FetchEditorThemePayload(mSite, mGlobalStyleSupportFeatureConfig.isEnabled());
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ext {
automatticRestVersion = '1.0.8'
automatticStoriesVersion = '2.4.0'
automatticTracksVersion = '3.3.0'
gutenbergMobileVersion = 'v1.109.2'
gutenbergMobileVersion = 'v1.110.0-alpha1'
wordPressAztecVersion = 'v1.9.0'
wordPressFluxCVersion = '2.59.0'
wordPressLoginVersion = '1.10.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnAuthHeaderRequestedListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnBlockTypeImpressionsEventListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnConnectionStatusEventListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnContentInfoReceivedListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnCustomerSupportOptionsListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnEditorAutosaveListener;
Expand Down Expand Up @@ -95,6 +96,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
OnSendEventToHostListener onSendEventToHostListener,
OnToggleUndoButtonListener onToggleUndoButtonListener,
OnToggleRedoButtonListener onToggleRedoButtonListener,
OnConnectionStatusEventListener onConnectionStatusEventListener,
boolean isDarkMode) {
mWPAndroidGlueCode.attachToContainer(
viewGroup,
Expand All @@ -120,6 +122,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener
onSendEventToHostListener,
onToggleUndoButtonListener,
onToggleRedoButtonListener,
onConnectionStatusEventListener,
isDarkMode);
}

Expand Down Expand Up @@ -320,4 +323,8 @@ public void onMediaModelCreatedForFile(String oldId, String newId, String oldUrl
public void sendToJSFeaturedImageId(int mediaId) {
mWPAndroidGlueCode.sendToJSFeaturedImageId(mediaId);
}

public void onConnectionStatusChange(boolean isConnected) {
mWPAndroidGlueCode.connectionStatusChange(isConnected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.DateTimeUtils;
import org.wordpress.android.util.NetworkUtils;
import org.wordpress.android.util.PermissionUtils;
import org.wordpress.android.util.ProfilingUtils;
import org.wordpress.android.util.StringUtils;
Expand All @@ -68,6 +69,7 @@
import org.wordpress.mobile.WPAndroidGlue.ShowSuggestionsUtil;
import org.wordpress.mobile.WPAndroidGlue.UnsupportedBlock;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnBlockTypeImpressionsEventListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnConnectionStatusEventListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnContentInfoReceivedListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnCustomerSupportOptionsListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnEditorMountListener;
Expand Down Expand Up @@ -99,7 +101,8 @@ public class GutenbergEditorFragment extends EditorFragmentAbstract implements
EditorThemeUpdateListener,
StorySaveMediaListener,
GutenbergDialogPositiveClickInterface,
GutenbergDialogNegativeClickInterface {
GutenbergDialogNegativeClickInterface,
GutenbergNetworkConnectionListener {
private static final String GUTENBERG_EDITOR_NAME = "gutenberg";
private static final String KEY_HTML_MODE_ENABLED = "KEY_HTML_MODE_ENABLED";
private static final String KEY_EDITOR_DID_MOUNT = "KEY_EDITOR_DID_MOUNT";
Expand Down Expand Up @@ -424,6 +427,7 @@ public void performGetRequest(String path, boolean enableCaching, Consumer<Strin
Consumer<Bundle> onError) {
mEditorFragmentListener.onPerformFetch(path, enableCaching, onSuccess, onError);
}

@Override
public void performPostRequest(
String path,
Expand Down Expand Up @@ -586,6 +590,12 @@ public void onGotoCustomerSupportOptions() {

mEditorFragmentListener::onToggleRedo,

new OnConnectionStatusEventListener() {
@Override public boolean onRequestConnectionStatus() {
return NetworkUtils.isNetworkAvailable(getActivity());
}
},

GutenbergUtils.isDarkMode(getActivity()));

// request dependency injection. Do this after setting min/max dimensions
Expand Down Expand Up @@ -1569,4 +1579,9 @@ public void onGutenbergDialogNegativeClicked(@NonNull String instanceTag) {
break;
}
}

@Override
public void onConnectionStatusChange(boolean isConnected) {
getGutenbergContainerFragment().onConnectionStatusChange(isConnected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.wordpress.android.editor.gutenberg

interface GutenbergNetworkConnectionListener {
fun onConnectionStatusChange(isConnected: Boolean)
}
Loading