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

Introduce the gutenberg mobile editor #8701

Merged
merged 104 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
63ebace
Able to load the RN view and reach the Metro server
hypest Oct 12, 2018
edd713a
Able to load the RN view and its contents (issue: flickering)
hypest Oct 12, 2018
3a7f59a
Fix flickering by removing the parent ScrollView
hypest Oct 12, 2018
5cd6a2e
Feeding GB with the proper post content
hypest Oct 12, 2018
9189b17
Prop name is now `initialData`
hypest Oct 16, 2018
7ed96cd
Use a bridge to trigger JS and get html back up
hypest Oct 26, 2018
5a7143d
Do the latch wait in the parent
hypest Oct 26, 2018
f6f978e
Merge from gutenberg-mobile master
hypest Oct 26, 2018
c875ad8
Update gutenberg mobile ref
hypest Oct 27, 2018
9710a6c
RN Debug menu via a toolbar action
hypest Oct 27, 2018
b885b0e
Update gutenberg mobile ref
hypest Oct 27, 2018
bc24abb
Install Node, Gutenberg mobile packages
hypest Oct 27, 2018
771cf4d
Fix checkstyle issues
hypest Oct 28, 2018
e6bc828
Exclude the Gutenberg mobile symlink dirs
hypest Oct 28, 2018
98cee07
Fix: set the Gutenberg mobile RN app root directory
hypest Oct 28, 2018
5fb3bc9
Fix release build
hypest Oct 28, 2018
45e3116
Exclude wpandroidlink symlink that runs grep in circles
hypest Oct 28, 2018
3309863
DEBUG: enable Travis extra logging
hypest Oct 28, 2018
2b021f8
Add the google() repo as first option
hypest Oct 28, 2018
76b92f6
Revert "DEBUG: enable Travis extra logging"
hypest Oct 28, 2018
e5de1ee
DEBUG: Separate Travis line to try pinpoint the error
hypest Oct 28, 2018
01fddfa
DEBUG: Type in Travis config
hypest Oct 28, 2018
96b3b68
Install API 26, build tools 26.0.3 in Travis
hypest Oct 28, 2018
7e32ff9
Install API 23, build tools 23.0.1 in Travis
hypest Oct 28, 2018
05a3753
Install API 28 in Travis
hypest Oct 28, 2018
8f88568
Gutenberg mobile matching Android API levels
hypest Oct 29, 2018
32d55f6
Only need API 27 from Travis again
hypest Oct 29, 2018
092a3d5
Ignore some of the lint errors reported in GB mobile
hypest Oct 29, 2018
7c63f10
react-native-svg still needs its API 26 tooling
hypest Oct 29, 2018
4f5b8ee
Update to latest mobile gutenberg branch ref
hypest Oct 29, 2018
9f08168
Update to recent mobile gutenberg integration branch
hypest Oct 31, 2018
7b70fc1
No need for those .idea changes
hypest Oct 31, 2018
d3eda52
No need to change this file
hypest Nov 1, 2018
7b336b6
No need for modifying util lib's build script
hypest Nov 1, 2018
1d27be6
Update to latest gutenberg-mobile master
hypest Nov 2, 2018
738b170
Wire up basic media library image set
hypest Oct 28, 2018
fe9379f
Update the Image url by calling a callback into RN
hypest Nov 5, 2018
74e0385
Merge pull request #8522 from wordpress-mobile/feature/integrate-gute…
hypest Nov 6, 2018
981b4a8
Update gb-mobile ref to fix undefined caption issue
hypest Nov 6, 2018
1f6f1e7
Update to latest submodule ref
hypest Nov 6, 2018
535246c
Point to gutenberg mobile master
hypest Nov 6, 2018
a0f3a2b
Merge branch 'feature/integrate-gutenberg-image-set' into feature/gut…
hypest Nov 7, 2018
849f0ad
More cases where we treat Gutenberg as Aztec
hypest Nov 7, 2018
2463583
Able to detect changed content
hypest Nov 7, 2018
1047ab0
Shorthand method to know if legacy editor or not
hypest Nov 7, 2018
fbe5fa9
Merge pull request #8567 from wordpress-mobile/gb/detect-content-change
mzorz Nov 7, 2018
d8d8d96
Update to latest gb-mobile master
hypest Nov 8, 2018
4dfd911
Merge pull request #8571 from wordpress-mobile/gb/update-to-gb-mobile…
hypest Nov 8, 2018
3a9348e
Only the media library is integrated with gb-mobile
hypest Nov 8, 2018
1404a82
Pass empty string on init, allowing for new (empty) post
hypest Nov 13, 2018
3c4eafb
Merge pull request #8595 from wordpress-mobile/gb/able-to-start-new-post
daniloercoli Nov 14, 2018
22726e7
Merge pull request #8573 from wordpress-mobile/gb/limit-to-media-libr…
mzorz Nov 15, 2018
1a26a60
Point to latest gb-mobile master
hypest Nov 15, 2018
bb9686f
Merge pull request #8612 from wordpress-mobile/gb/update-to-latest-ma…
hypest Nov 15, 2018
4058b33
Merge branch 'develop' into gb/update-from-develop
hypest Nov 17, 2018
8314f5d
Merge pull request #8625 from wordpress-mobile/gb/update-from-develop
hypest Nov 17, 2018
a3e7036
WIP: trying to have wasabi build GB-free
hypest Nov 16, 2018
5be9ae9
Wasabi build without RN at all
hypest Nov 17, 2018
6491e9e
Reinstate the RN subprojects in settings
hypest Nov 17, 2018
454d10d
Introducing the `gutenberg` build flavor
hypest Nov 17, 2018
91411e2
Fix checkstyle issues
hypest Nov 17, 2018
f8fb49e
Hardcode Gutenberg-mobile for vanilla gutenberg flavors only
hypest Nov 17, 2018
b501218
Update the lint-baseline snapshot
hypest Nov 17, 2018
a2d819d
Include a JS bundle directly in the assets
hypest Nov 23, 2018
a59ccc8
Build vanilla release only via binary deps, including Gutenberg
hypest Nov 23, 2018
6a667a6
Point to refs that don't crash the app
hypest Nov 25, 2018
d159c27
Update to latest gutenberg-mobile master
hypest Nov 25, 2018
216f2cb
Remove gutenberg flavor, GB for all, gradle switch to use sources
hypest Nov 26, 2018
483b66c
Update the lint-baseline.xml
hypest Nov 26, 2018
98cb7d9
No need for the gutenberg flavor resources
hypest Nov 26, 2018
e138108
Minimize diff to base branch
hypest Nov 26, 2018
0f15b20
No need for EditPostActivity to implement DefaultHardwareBackBtnHandler
hypest Nov 26, 2018
4105951
Gutenberg-mobile as a single dependency
hypest Nov 26, 2018
35994ac
No need to directly depend on RN
hypest Nov 26, 2018
34875a3
Remove dependency on ReactRootView
hypest Nov 26, 2018
6bc48f9
Point to latest ref of gutenberg-mobile branch
hypest Nov 26, 2018
e38e21b
Binary build using the submodule referenced hash
hypest Nov 27, 2018
0f5e875
The symbolic link lives in $TMPDIR anyway
hypest Nov 27, 2018
1a398f2
Only include the GB subprojects if building from source
hypest Nov 27, 2018
8279bc4
No need for RN related setup in Travis anymore
hypest Nov 27, 2018
fe33572
No need for API 26 tools on Travis anymore
hypest Nov 27, 2018
472d2a3
Don't pull submodules, not needed for building
hypest Nov 27, 2018
9b23324
Update the bridge subnodule ref
hypest Nov 27, 2018
370be94
Fork out the submoduleGitHash function so it can be shared
hypest Nov 27, 2018
4d62861
Update the bridge submodule ref
hypest Nov 27, 2018
d386dfe
Update the gutenberg-mobile ref
hypest Nov 28, 2018
3ce2fd0
Remove unused comment
hypest Nov 28, 2018
67133c6
No need for the abiFilter in WordPressEditor's build.gradle
hypest Nov 28, 2018
08899b6
Clean up, no need for undo/redo menu buttons in GB
hypest Nov 28, 2018
930fcaa
Revert "Clean up, no need for undo/redo menu buttons in GB"
hypest Nov 28, 2018
5364315
Remove the appbar undor/redo for GB
hypest Nov 28, 2018
d2fce95
Update the gutenberg-mobile ref
hypest Nov 28, 2018
c232f75
Point to gutenberg-mobile master
hypest Nov 28, 2018
924c9c9
Update JS bundle to match gutenberg-mobile ref
hypest Nov 28, 2018
c3590e7
Use bridge ref that auto-includes the JS bundle
hypest Nov 28, 2018
b356abc
No need for the JS bundle, it's in the bridge now
hypest Nov 28, 2018
07b1f80
Include the fix for the JS bundle name definition
hypest Nov 29, 2018
20b85b3
Merge pull request #8664 from wordpress-mobile/gb/binary-deps-and-a-f…
hypest Nov 29, 2018
15974e0
Merge branch 'develop' into feature/gutenberg-mobile
hypest Nov 29, 2018
4185a2e
Reinstate packaging the GB JS bundle in wpandroid directly
hypest Nov 29, 2018
bb381c9
Disable Gutenberg in UI, in preparation to merge to develop
hypest Nov 29, 2018
7f1f9f3
No need for the JS bundle to be committed
hypest Nov 29, 2018
a0ba021
Merge pull request #8696 from wordpress-mobile/gb/js-bundle-in-wpandr…
hypest Nov 29, 2018
a229aad
Remove unused code and commented out code
hypest Nov 29, 2018
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ fastlane/screenshots_orig
# Bundler
/.bundle
/vendor

# Gutenberg
WordPress/src/main/assets/index.android.bundle
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libs/gutenberg-mobile"]
path = libs/gutenberg-mobile
url = ../../wordpress-mobile/gutenberg-mobile.git
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ jdk: oraclejdk8
sudo: required
rvm: 2.0.0

# disable the default submodule logic so the gutenberg-mobile submodule is not pulled. No need to pull it.
git:
submodules: false

notifications:
# Slack notification on failure (secured token).
slack:
Expand Down
7 changes: 7 additions & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'

apply from: 'gutenberg-tasks.gradle'

android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true

android {
Expand All @@ -47,6 +49,11 @@ android {
targetSdkVersion 26

multiDexEnabled true

ndk {
abiFilters 'armeabi-v7a', 'x86'
}

vectorDrawables.useSupportLibrary = true
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'

Expand Down
28 changes: 28 additions & 0 deletions WordPress/gutenberg-tasks.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// import the `submoduleGitHash()` function
apply from: 'https://gist.githubusercontent.com/hypest/e06f6097065728b6db7b7c462f8fef1a/raw/38557f55d0a3be9605c82b1df9ced4c846fd3aea/submoduleGitHash.gradle'

// define the filename to use for the JS bundle. This will "bubble" up to the Java code via a BuildConfig constant
def gutenbergMobileJsBundleFilename = 'index.android.bundle'

task downloadJSBundle {
doLast {
def assetsFolderName = "${project.projectDir}/src/main/assets"
File assetsFolder = new File(assetsFolderName)
if (! assetsFolder.exists()){
assetsFolder.mkdirs();
}

def targetFile = new File("${assetsFolderName}/${gutenbergMobileJsBundleFilename}")
def hash = submoduleGitHash("${project.projectDir}/../", 'libs/gutenberg-mobile')
def url = new URL("https://s3-us-west-1.amazonaws.com/gutenberg-mobile-js-bundle/wordpress-mobile/gutenberg-mobile/${hash}/android/App.js")

println "Downloading JS bundle from ${url}"
url.withInputStream{ i -> targetFile.withOutputStream{ it << i }}
}
}

if (!rootProject.ext.buildGutenbergFromSource) {
// Download the JS bundle if we're not building from source.
// Usually happens when compiling this project as standalone or via jitpack
preBuild.dependsOn(downloadJSBundle)
}
77 changes: 77 additions & 0 deletions WordPress/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="4" by="lint 3.1.3">

<issue
id="DefaultLocale"
message="Implicitly using the default locale is a common source of bugs: Use `toUpperCase(Locale)` instead. For strings meant to be internal use `Locale.ROOT`, otherwise `Locale.getDefault()`."
errorLine1=" matched.appendReplacement(sb, matched.group(1).toUpperCase());"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/com/horcrux/svg/RenderableShadowNode.java"
line="400"
column="60"/>
</issue>

<issue
id="WrongCall"
message="Suspicious method call; should probably call &quot;`layout`&quot; rather than &quot;`onLayout`&quot;"
errorLine1=" onLayout(false, getLeft(), getTop(), getRight(), getBottom());"
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/com/github/godness84/RNRecyclerViewList/RecyclerViewBackedScrollView.java"
line="364"
column="21"/>
</issue>

<issue
id="ClickableViewAccessibility"
message="Custom view ``EditTextWithKeyBackListener`` has `setOnTouchListener` called on it but does not override `performClick`"
errorLine1=" mTitle.setOnTouchListener(this);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java"
line="282"
column="9"/>
</issue>

<issue
id="ClickableViewAccessibility"
message="Custom view ``SourceViewEditText`` has `setOnTouchListener` called on it but does not override `performClick`"
errorLine1=" mSource.setOnTouchListener(this);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java"
line="284"
column="9"/>
</issue>

<issue
id="ClickableViewAccessibility"
message="`GutenbergEditorFragment#onTouch` should call `View#performClick` when a click is detected"
errorLine1=" public boolean onTouch(View view, MotionEvent event) {"
errorLine2=" ~~~~~~~">
<location
file="src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java"
line="1478"
column="20"/>
</issue>

<issue
id="ClickableViewAccessibility"
message="Custom view `RecyclableWrapperViewGroup` overrides `onTouchEvent` but not `performClick`"
errorLine1=" public boolean onTouchEvent(MotionEvent event) {"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/com/github/godness84/RNRecyclerViewList/RecyclerViewBackedScrollView.java"
line="146"
column="24"/>
</issue>

<issue
id="ClickableViewAccessibility"
message="Custom view `RecyclerViewBackedScrollView` overrides `onTouchEvent` but not `performClick`"
errorLine1=" public boolean onTouchEvent(MotionEvent ev) {"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/com/github/godness84/RNRecyclerViewList/RecyclerViewBackedScrollView.java"
line="330"
column="20"/>
</issue>

<issue
id="ExifInterface"
severity="Warning"
Expand Down
8 changes: 8 additions & 0 deletions WordPress/proguard.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@
-keep class retrofit2.** { *; }
-keep class uk.co.senab.photoview.** { *; }
###### Zendesk - end

###### React Native - begin

# XXX: not sure why it needs the aztec related dontwarn but, release build breaks without it
-dontwarn org.wordpress.aztec.glideloader.**

-dontwarn com.github.godness84.RNRecyclerViewList.**
###### React Native - end
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.wordpress.android.editor.EditorWebViewAbstract.ErrorListener;
import org.wordpress.android.editor.EditorWebViewCompatibility;
import org.wordpress.android.editor.EditorWebViewCompatibility.ReflectionException;
import org.wordpress.android.editor.GutenbergEditorFragment;
import org.wordpress.android.editor.ImageSettingsDialogFragment;
import org.wordpress.android.editor.LegacyEditorFragment;
import org.wordpress.android.editor.MediaToolbarAction;
Expand Down Expand Up @@ -248,6 +249,7 @@ enum AddExistingdMediaSource {

private Handler mHandler;
private int mDebounceCounter = 0;
private boolean mShowGutenbergEditor;
private boolean mShowAztecEditor;
private boolean mShowNewEditor;
private boolean mMediaInsertedOnCreation;
Expand Down Expand Up @@ -319,6 +321,10 @@ enum AddExistingdMediaSource {
// for keeping the media uri while asking for permissions
private ArrayList<Uri> mDroppedMediaUris;

private boolean isModernEditor() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to get rid of this if we use the enum approach for the editor selection. It might be worth adding some capabilities to the editors instead of having a general check like isModernEditor, so it's both easier to understand why we are checking for a modern editor and easier to customize them if the need arises.

return mShowNewEditor || mShowAztecEditor || mShowGutenbergEditor;
}

private Runnable mFetchMediaRunnable = new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -353,6 +359,8 @@ protected void onCreate(Bundle savedInstanceState) {
PreferenceManager.setDefaultValues(this, R.xml.account_settings, false);
// AppPrefs.setAztecEditorAvailable(true);
// AppPrefs.setAztecEditorEnabled(true);
mShowGutenbergEditor = false; // hardcode to disabled for now.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great if we can introduce an enum for the currently selected editor. It's very hard to tell what each of these combinations of showXEditor does in the code.

Also, I realize that this is following the current pattern, but it'd be good to set these flags (or the enum) in the property declaration and preferably set it to final. If these values are not being changed, we shouldn't have to look into onCreate to find the value for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, it has gotten out of hand now that there are 4 editors in place. There's already some good consensus to try to remove 2 of the for by the way. See #8611.

I think I'll create a ticket to revise the flag situation to an enum and tackle it in a separate PR if that's OK.

// Manually set it to true (and the flags below to false) to force Gutenberg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't fully understand what this comment means at the current state of the code, most likely because I don't have the context for it. If this is not actually in reference to the current code, I'd suggest either removing it or making it a // TODO instead so we don't get confused. I prefer creating an issue for this, or adding it as an item to an existing issue, but I don't mind the TODO either.

If we go with the enum approach, I don't think this comment will be necessary anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it wasn't clear, the comment is just an attempt to give instructions to someone that would like to try out Gutenberg today by manually enabling it in the code.

There's already work in progress to surface a UI switch to enable/disable the block editor so, I think we could just leave it as is as it's a matter of days to land the proper code. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good! 👍

mShowAztecEditor = AppPrefs.isAztecEditorEnabled();
mShowNewEditor = AppPrefs.isVisualEditorEnabled();

Expand Down Expand Up @@ -996,7 +1004,7 @@ public void onPhotoPickerIconClicked(@NonNull PhotoPickerIcon icon) {
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
if (mShowNewEditor || mShowAztecEditor) {
if (isModernEditor()) {
inflater.inflate(R.menu.edit_post, menu);
} else {
inflater.inflate(R.menu.edit_post_legacy, menu);
Expand Down Expand Up @@ -1150,7 +1158,8 @@ public boolean onOptionsItemSelected(final MenuItem item) {
} else {
// Disable other action bar buttons while a media upload is in progress
// (unnecessary for Aztec since it supports progress reattachment)
if (!mShowAztecEditor && (mEditorFragment.isUploadingMedia() || mEditorFragment.isActionInProgress())) {
if (!(mShowAztecEditor || mShowGutenbergEditor)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with an enum approach, can we add a property in it for this check, so the logic is easier to follow. It could be something like hasCapabilityX. These minor improvements will help us make an even bigger step later and making the editor selection a sealed class so we can extract all the logic from this fragment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kinda falls out of the intent of this PR so I won't answer with either yes or no. It sounds like a good thing to have in mind for when we refactor this part of the code 👍

&& (mEditorFragment.isUploadingMedia() || mEditorFragment.isActionInProgress())) {
ToastUtils.showToast(this, R.string.editor_toast_uploading_please_wait, Duration.SHORT);
return false;
}
Expand Down Expand Up @@ -1380,7 +1389,7 @@ private synchronized void updatePostObject(boolean isAutosave) throws EditorFrag
// Update post object from fragment fields
boolean postTitleOrContentChanged = false;
if (mEditorFragment != null) {
if (mShowNewEditor || mShowAztecEditor) {
if (isModernEditor()) {
postTitleOrContentChanged =
updatePostContentNewEditor(isAutosave, (String) mEditorFragment.getTitle(),
(String) mEditorFragment.getContent(mPost.getContent()));
Expand Down Expand Up @@ -1655,7 +1664,7 @@ protected Void doInBackground(Void... params) {
savePostToDb();
PostUtils.trackSavePostAnalytics(mPost, mSiteStore.getSiteByLocalId(mPost.getLocalSiteId()));

UploadService.setLegacyMode(!mShowNewEditor && !mShowAztecEditor);
UploadService.setLegacyMode(!isModernEditor());
if (mIsFirstTimePublish) {
UploadService.uploadPostAndTrackAnalytics(EditPostActivity.this, mPost);
} else {
Expand Down Expand Up @@ -1694,7 +1703,7 @@ protected Boolean doInBackground(Void... params) {
// Changes have been made - save the post and ask for the post list to refresh
// We consider this being "manual save", it will replace some Android "spans" by an html
// or a shortcode replacement (for instance for images and galleries)
if (mShowNewEditor || mShowAztecEditor) {
if (isModernEditor()) {
// Update the post object directly, without re-fetching the fields from the EditorFragment
updatePostContentNewEditor(false, mPost.getTitle(), mPost.getContent());
}
Expand Down Expand Up @@ -1979,7 +1988,10 @@ public Fragment getItem(int position) {
switch (position) {
case 0:
// TODO: Remove editor options after testing.
if (mShowAztecEditor) {
if (mShowGutenbergEditor) {
return GutenbergEditorFragment.newInstance("", "",
AppPrefs.isAztecEditorToolbarExpanded());
} else if (mShowAztecEditor) {
return AztecEditorFragment.newInstance("", "",
AppPrefs.isAztecEditorToolbarExpanded());
} else if (mShowNewEditor) {
Expand Down Expand Up @@ -2150,7 +2162,7 @@ private void fillContentEditorFields() {
if (mPost != null) {
if (!TextUtils.isEmpty(mPost.getContent()) && !mHasSetPostContent) {
mHasSetPostContent = true;
if (mPost.isLocalDraft() && !mShowNewEditor && !mShowAztecEditor) {
if (mPost.isLocalDraft() && !isModernEditor()) {
// TODO: Unnecessary for new editor, as all images are uploaded right away, even for local drafts
// Load local post content in the background, as it may take time to generate images
new LoadPostContentTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
Expand Down Expand Up @@ -2580,7 +2592,7 @@ private boolean processMedia(Uri mediaUri) {
Uri optimizedMedia = WPMediaUtils.getOptimizedMedia(activity, path, isVideo);
if (optimizedMedia != null) {
mediaUri = optimizedMedia;
} else if (mShowNewEditor || mShowAztecEditor) {
} else if (isModernEditor()) {
// Fix for the rotation issue https://github.com/wordpress-mobile/WordPress-Android/issues/5737
if (!mSite.isWPCom()) {
// If it's not wpcom we must rotate the picture locally
Expand Down Expand Up @@ -2615,7 +2627,7 @@ private void postProcessMedia(final Uri mediaUri, final String path, final boole
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mShowNewEditor || mShowAztecEditor) {
if (isModernEditor()) {
addMediaVisualEditor(mediaUri, path);
} else {
addMediaLegacyEditor(mediaUri, isVideo);
Expand Down Expand Up @@ -3071,6 +3083,9 @@ public void onSettingsClicked() {
public void onAddMediaClicked() {
if (isPhotoPickerShowing()) {
hidePhotoPicker();
} else if (mShowGutenbergEditor) {
// show the WP media library only since that's the only mode integrated currently from Gutenberg-mobile
ActivityLauncher.viewMediaPickerForResult(this, mSite, MediaBrowserType.EDITOR_PICKER);
} else if (WPMediaUtils.currentUserCanUploadMedia(mSite)) {
showPhotoPicker();
} else {
Expand Down
1 change: 1 addition & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@

<string name="menu_undo">Undo</string>
<string name="menu_redo">Redo</string>
<string name="menu_debug">Debug Menu</string>

<string name="post_title">Title</string>

Expand Down
27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ buildscript {
apply plugin: 'com.automattic.android.fetchstyle'

project.ext.preDexLibs = !project.hasProperty('disablePreDex')
project.ext.buildGutenbergFromSource = project.properties.getOrDefault('wp.BUILD_GUTENBERG_FROM_SOURCE', false)

allprojects {
apply plugin: 'checkstyle'
Expand All @@ -24,6 +25,32 @@ allprojects {
google()
jcenter()
maven { url "https://dl.bintray.com/wordpress-mobile/maven" }

if (rootProject.ext.buildGutenbergFromSource) {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/libs/gutenberg-mobile/node_modules/react-native/android"
}
maven {
// Local Maven repo containing AARs with JSC library built for Android
url "$rootDir/libs/gutenberg-mobile/node_modules/jsc-android/dist"
}
} else {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "https://unpkg.com/[email protected]/android"
}
maven {
// Local Maven repo containing AARs with JSC library built for Android
url "https://unpkg.com/[email protected]/dist/"
}
}
}

configurations.all {
resolutionStrategy {
force 'org.webkit:android-jsc:r224109'
}
}

task checkstyle(type: Checkstyle) {
Expand Down
2 changes: 1 addition & 1 deletion config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- Excludes given file patterns from scan. -->
<!-- See http://checkstyle.sf.net/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="[/\\]gen[/\\]"/>
<property name="fileNamePattern" value="[/\\]gen[/\\]|[/\\]node_modules[/\\]|[/\\]react-native-aztec[/\\]"/>
</module>

<!-- Checks whether files end with a new line. -->
Expand Down
12 changes: 11 additions & 1 deletion libs/editor/WordPressEditor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ repositories {
maven { url "https://jitpack.io" }
}

// import the `submoduleGitHash()` function
apply from: 'https://gist.githubusercontent.com/hypest/e06f6097065728b6db7b7c462f8fef1a/raw/38557f55d0a3be9605c82b1df9ced4c846fd3aea/submoduleGitHash.gradle'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
versionCode 13
versionName "1.3"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 26
buildConfigField "boolean", "BUILD_GUTENBERG_FROM_SOURCE", rootProject.ext.buildGutenbergFromSource.toString()
}
buildTypes {
release {
Expand Down Expand Up @@ -56,6 +60,12 @@ dependencies {
api ('com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-shortcodes:v1.3.12')
api ('com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-comments:v1.3.12')

if (rootProject.ext.buildGutenbergFromSource) {
implementation project(':react-native-gutenberg-bridge')
} else {
implementation ('com.github.wordpress-mobile:gutenberg-mobile:' + submoduleGitHash('../../../', 'libs/gutenberg-mobile'))
}

// Required Aztec dependencies (they should be included but Jitpack seems to be stripping these out)
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.1.4"
implementation "org.jsoup:jsoup:1.10.3"
Expand Down
Loading