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

Contain and retain GB on rotation #9030

Merged
merged 25 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
98940eb
Contain RN in retained child Fragment, re-attach on rotate
hypest Jan 20, 2019
d502dc6
Re-wire up the media selection callback
hypest Jan 20, 2019
1a8f5f2
Update the gutenberg-mobile ref
hypest Jan 23, 2019
1f5cb4c
Merge branch 'develop' into gb/contain-and-retain-gb
hypest Jan 23, 2019
62efc23
Remove unused import
hypest Jan 23, 2019
13da084
Merge branch 'develop' into gb/contain-and-retain-gb
hypest Jan 25, 2019
5772623
Fix code issues from merge from develop
hypest Jan 25, 2019
4cf21c8
Don't re-finish GB init if recreating Activity
hypest Jan 25, 2019
22fd283
Merge branch 'develop' into gb/contain-and-retain-gb
hypest Jan 25, 2019
8461ee7
Merge branch 'develop' into gb/contain-and-retain-gb
hypest Jan 26, 2019
f856965
Fix GB container after recent merge from develop
hypest Jan 26, 2019
0935d65
Merge branch 'develop' into gb/contain-and-retain-gb-updated
hypest Jan 30, 2019
031de3f
Use fix for new post backgrounding
hypest Jan 30, 2019
c1beff4
Move callbacks closer to Gutenberg fragment
hypest Jan 30, 2019
9dfbeae
Revert access modifiers to private
hypest Jan 30, 2019
0e2237f
Access the retained container directly
hypest Feb 1, 2019
487fe2b
Merge branch 'develop' into gb/contain-and-retain-gb
hypest Feb 1, 2019
2b852d4
Fix merge conflicts
hypest Feb 1, 2019
53c1fcf
Rename variable and add comment about it
hypest Feb 4, 2019
7013eaa
Update gutenberg-mobile ref
hypest Feb 5, 2019
c6dee6a
Use Aztec with no-autofocus option
hypest Feb 5, 2019
ea19f07
Merge branch 'develop' into gb/contain-and-retain-gb
hypest Feb 5, 2019
251e109
Update gutenberg-mobile ref
hypest Feb 5, 2019
0044147
Update to merged Aztec commit
hypest Feb 5, 2019
ec9f0a8
Update to merged gutenberg-mobile hash
hypest Feb 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2053,8 +2053,7 @@ public Fragment getItem(int position) {
case 0:
// TODO: Remove editor options after testing.
if (mShowGutenbergEditor) {
return GutenbergEditorFragment.newInstance("", "",
AppPrefs.isAztecEditorToolbarExpanded(), mIsNewPost);
return GutenbergEditorFragment.newInstance("", "", mIsNewPost);
} else if (mShowAztecEditor) {
return AztecEditorFragment.newInstance("", "",
AppPrefs.isAztecEditorToolbarExpanded());
Expand Down
2 changes: 1 addition & 1 deletion libs/editor/WordPressEditor/build.gradle
@@ -1,7 +1,7 @@
buildscript {

ext {
aztecVersion = 'v1.3.18'
aztecVersion = 'd2f24f4a7c21e2be77ef77cd646e67a3a2b9802a'
}

repositories {
Expand Down
@@ -0,0 +1,135 @@
package org.wordpress.android.editor;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.ViewGroup;

import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGetContentTimeout;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnMediaLibraryButtonListener;
import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnReattachQueryListener;

public class GutenbergContainerFragment extends Fragment {
public static final String TAG = "gutenberg_container_fragment_tag";

private static final String ARG_IS_NEW_POST = "param_is_new_post";

private boolean mHtmlModeEnabled;
private boolean mHasReceivedAnyContent;

private WPAndroidGlueCode mWPAndroidGlueCode;

public static GutenbergContainerFragment newInstance(boolean isNewPost) {
GutenbergContainerFragment fragment = new GutenbergContainerFragment();
Bundle args = new Bundle();
args.putBoolean(ARG_IS_NEW_POST, isNewPost);
fragment.setArguments(args);
return fragment;
}

public boolean hasReceivedAnyContent() {
return mHasReceivedAnyContent;
}

public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener onMediaLibraryButtonListener,
OnReattachQueryListener onReattachQueryListener) {
mWPAndroidGlueCode.attachToContainer(viewGroup, onMediaLibraryButtonListener, onReattachQueryListener);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

boolean isNewPost = getArguments() != null && getArguments().getBoolean(ARG_IS_NEW_POST);

mWPAndroidGlueCode = new WPAndroidGlueCode();
mWPAndroidGlueCode.onCreate(getContext());
mWPAndroidGlueCode.onCreateView(
getContext(),
mHtmlModeEnabled,
getActivity().getApplication(),
BuildConfig.DEBUG,
BuildConfig.BUILD_GUTENBERG_FROM_SOURCE,
isNewPost);

// clear the content initialization flag since a new ReactRootView has been created;
mHasReceivedAnyContent = false;
}

@Override
public void onPause() {
super.onPause();

mWPAndroidGlueCode.onPause(getActivity());
}

@Override
public void onResume() {
super.onResume();

mWPAndroidGlueCode.onResume(this, getActivity());
}

@Override
public void onDestroy() {
super.onDestroy();

mWPAndroidGlueCode.onDestroy(getActivity());
}

public void setTitle(String title) {
mWPAndroidGlueCode.setTitle(title);
mHasReceivedAnyContent = mWPAndroidGlueCode.hasReceivedInitialTitleAndContent();
}

public void setContent(String postContent) {
mWPAndroidGlueCode.setContent(postContent);
mHasReceivedAnyContent = mWPAndroidGlueCode.hasReceivedInitialTitleAndContent();
}

public void toggleHtmlMode() {
mHtmlModeEnabled = !mHtmlModeEnabled;

mWPAndroidGlueCode.toggleEditorMode();
}

/**
* Returns the contents of the content field from the JavaScript editor. Should be called from a background thread
* where possible.
*/
public CharSequence getContent(CharSequence originalContent, OnGetContentTimeout onGetContentTimeout) {
return mWPAndroidGlueCode.getContent(originalContent, onGetContentTimeout);
}

public CharSequence getTitle(OnGetContentTimeout onGetContentTimeout) {
return mWPAndroidGlueCode.getTitle(onGetContentTimeout);
}

public void appendMediaFile(int mediaId, final String mediaUrl) {
mWPAndroidGlueCode.appendMediaFile(mediaId, mediaUrl);
}

public void showDevOptionsDialog() {
mWPAndroidGlueCode.showDevOptionsDialog();
}

public void appendUploadMediaFile(final int mediaId, final String mediaUri) {
mWPAndroidGlueCode.appendUploadMediaFile(mediaId, mediaUri);
}

public void mediaFileUploadProgress(final int mediaId, final float progress) {
mWPAndroidGlueCode.mediaFileUploadProgress(mediaId, progress);
}

public void mediaFileUploadFailed(final int mediaId) {
mWPAndroidGlueCode.mediaFileUploadFailed(mediaId);
}

public void mediaFileUploadSucceeded(final int mediaId, final String mediaUrl, final int serverMediaId) {
mWPAndroidGlueCode.mediaFileUploadSucceeded(mediaId, mediaUrl, serverMediaId);
}

public void clearMediaFileURL(final int mediaId) {
mWPAndroidGlueCode.clearMediaFileURL(mediaId);
}
}