Skip to content

Commit

Permalink
Merge pull request #14965 from wordpress-mobile/task/editor-onboardin…
Browse files Browse the repository at this point in the history
…g-basic-help

Editor Onboarding: "The Basics" help section - Menu option and base RN bridge handling
  • Loading branch information
AmandaRiu authored Jul 3, 2021
2 parents 7c64af2 + 492dd08 commit 4afcc44
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem viewHtmlModeMenuItem = menu.findItem(R.id.menu_html_mode);
MenuItem historyMenuItem = menu.findItem(R.id.menu_history);
MenuItem settingsMenuItem = menu.findItem(R.id.menu_post_settings);
MenuItem helpMenuItem = menu.findItem(R.id.menu_editor_help);

if (secondaryAction != null && mEditPostRepository.hasPost()) {
secondaryAction.setVisible(showMenuItems && getSecondaryAction().isVisible());
Expand Down Expand Up @@ -1269,6 +1270,17 @@ public boolean onPrepareOptionsMenu(Menu menu) {
contentInfo.setVisible(false); // only show the menu item when for Gutenberg
}

if (helpMenuItem != null) {
if (mEditorFragment instanceof GutenbergEditorFragment
&& BuildConfig.DEBUG
&& showMenuItems
) {
helpMenuItem.setVisible(true);
} else {
helpMenuItem.setVisible(false);
}
}

return super.onPrepareOptionsMenu(menu);
}

Expand Down Expand Up @@ -1452,6 +1464,11 @@ public boolean onOptionsItemSelected(final MenuItem item) {
} else {
logWrongMenuState("Wrong state in menu_switch_to_gutenberg: menu should not be visible.");
}
} else if (itemId == R.id.menu_editor_help) {
// Display the editor help page -- option should only be available in the GutenbergEditor
if (mEditorFragment instanceof GutenbergEditorFragment) {
((GutenbergEditorFragment) mEditorFragment).showEditorHelp();
}
}
}
return false;
Expand Down
5 changes: 5 additions & 0 deletions WordPress/src/main/res/menu/edit_post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@
android:title="@string/post_settings" >
</item>

<item
android:id="@+id/menu_editor_help"
android:title="@string/help" >
</item>

</group>
</menu>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
ext.wordPressUtilsVersion = 'develop-bb54ee34c5fec5fa7375ce90a356adb5adbdcae0'
ext.wordPressLoginVersion = '0.0.2'
ext.detektVersion = '1.15.0'
ext.gutenbergMobileVersion = 'develop-976e2830586f1679fabc297ebab5fac5b1f5fadf'
ext.gutenbergMobileVersion = 'v1.57.0-alpha2'

repositories {
maven {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,9 @@ public void showNotice(String message) {
ToastUtils.showToast(getActivity(), message).show();
}

@Override public void showEditorHelp() {
}

private void onMediaTapped(@NonNull final AztecAttributes attrs, int naturalWidth, int naturalHeight,
final MediaType mediaType) {
if (mediaType == null || !isAdded()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class EditorFragmentNotAddedException extends Exception {
public abstract void removeMedia(String mediaId);
// Called from EditPostActivity to let the block editor know when a media selection is cancelled
public abstract void mediaSelectionCancelled();
public abstract void showEditorHelp();


public enum MediaType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ public void showNotice(String message) {
mWPAndroidGlueCode.showNotice(message);
}

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

public void updateCapabilities(GutenbergPropsBuilder gutenbergPropsBuilder) {
// We want to make sure that activity isn't null
// as it can make this crash to happen: https://github.com/wordpress-mobile/WordPress-Android/issues/13248
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,11 @@ public void showNotice(String message) {
getGutenbergContainerFragment().showNotice(message);
}

@Override
public void showEditorHelp() {
getGutenbergContainerFragment().showEditorHelp();
}

@Override
public void onGutenbergDialogPositiveClicked(@NotNull String instanceTag, int mediaId) {
switch (instanceTag) {
Expand Down

0 comments on commit 4afcc44

Please sign in to comment.