diff --git a/WordPress/build.gradle b/WordPress/build.gradle index ef921c21a2c0..1272b17f278b 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -57,6 +57,7 @@ android { buildConfigField "boolean", "REVISIONS_ENABLED", "false" buildConfigField "boolean", "NEW_SITE_CREATION_ENABLED", "false" + buildConfigField "boolean", "OFFER_GUTENBERG", "true" } flavorDimensions "buildType" @@ -64,20 +65,17 @@ android { productFlavors { vanilla { // used for release and beta dimension "buildType" - buildConfigField "boolean", "OFFER_GUTENBERG", "false" } zalpha { // alpha version - enable experimental features applicationId "org.wordpress.android" dimension "buildType" buildConfigField "boolean", "VIDEO_OPTIMIZATION_AVAILABLE", "true" - buildConfigField "boolean", "OFFER_GUTENBERG", "true" } wasabi { // "hot" version, can be installed along release, alpha or beta versions applicationId "org.wordpress.android.beta" dimension "buildType" - buildConfigField "boolean", "OFFER_GUTENBERG", "true" } } diff --git a/WordPress/src/main/java/org/wordpress/android/support/ZendeskHelper.kt b/WordPress/src/main/java/org/wordpress/android/support/ZendeskHelper.kt index 9025343e02c8..ac316f2a9e23 100644 --- a/WordPress/src/main/java/org/wordpress/android/support/ZendeskHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/support/ZendeskHelper.kt @@ -498,4 +498,5 @@ private object TicketFieldIds { object ZendeskExtraTags { const val connectingJetpack = "connecting_jetpack" + const val gutenbergIsDefault = "mobile_gutenberg_is_default" } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt index f6ffafd4e15a..fe6bc95328d9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt @@ -14,6 +14,7 @@ import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.store.AccountStore import org.wordpress.android.fluxc.store.SiteStore import org.wordpress.android.support.SupportHelper +import org.wordpress.android.support.ZendeskExtraTags import org.wordpress.android.support.ZendeskHelper import org.wordpress.android.ui.ActivityId import org.wordpress.android.ui.AppLogViewerActivity @@ -177,9 +178,27 @@ class HelpActivity : AppCompatActivity() { if (selectedSite != null) { intent.putExtra(WordPress.SITE, selectedSite) } - if (extraSupportTags != null && !extraSupportTags.isEmpty()) { - intent.putStringArrayListExtra(HelpActivity.EXTRA_TAGS_KEY, extraSupportTags as ArrayList?) + + val tagsList: ArrayList? = if (AppPrefs.isGutenbergDefaultForNewPosts()) { + // construct a mutable list to add the Gutenberg related extra tag + val list = ArrayList() + + // add the provided list of tags if any + extraSupportTags?.let { + list.addAll(extraSupportTags) + } + + // Append the "mobile_gutenberg_is_default" tag if gutenberg is set to default for new posts + list.add(ZendeskExtraTags.gutenbergIsDefault) + list // "return" the list + } else { + extraSupportTags as ArrayList? } + + if (tagsList != null && !tagsList.isEmpty()) { + intent.putStringArrayListExtra(HelpActivity.EXTRA_TAGS_KEY, tagsList) + } + return intent } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java index 71b517bb1ec8..6b458da57a5a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java @@ -378,10 +378,15 @@ public static void trackGutenbergDialogEvent(AnalyticsTracker.Stat stat, PostMod } public static boolean shouldShowGutenbergEditor(boolean isNewPost, PostModel post) { - return AppPrefs.isGutenbergEditorEnabled() - && (isNewPost - || contentContainsGutenbergBlocks(post.getContent()) - || TextUtils.isEmpty(post.getContent())); + // Default to Gutenberg + + if (isNewPost || TextUtils.isEmpty(post.getContent())) { + // for a new post, use Gutenberg if the "use for new posts" switch is set + return AppPrefs.isGutenbergDefaultForNewPosts(); + } else { + // for already existing (and non-empty) posts, open Gutenberg only if the post contains blocks + return contentContainsGutenbergBlocks(post.getContent()); + } } public static String replaceMediaFileWithUrlInGutenbergPost(@NonNull String postContent, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java index dedc3d485d1b..f7602d3fd5e7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java @@ -111,6 +111,7 @@ public enum DeletablePrefKey implements PrefKey { NEWS_CARD_SHOWN_VERSION, AVATAR_VERSION, GUTENBERG_EDITOR_ENABLED, + GUTENBERG_DEAFULT_FOR_NEW_POSTS, IS_QUICK_START_NOTICE_REQUIRED } @@ -451,7 +452,8 @@ public static void setAztecEditorEnabled(boolean isEnabled) { } public static boolean isAztecEditorEnabled() { - return getBoolean(UndeletablePrefKey.AZTEC_EDITOR_ENABLED, false); + // hardcode Aztec enabled to "true". It's Aztec and Gutenberg that we're going to expose to the user now. + return true; } public static boolean isAztecEditorToolbarExpanded() { @@ -476,12 +478,13 @@ public static void setVisualEditorAvailable(boolean visualEditorAvailable) { } public static boolean isVisualEditorAvailable() { + // hardcode the Visual editor availability to "false". Aztec and Gutenberg are the only ones supported now. return getBoolean(UndeletablePrefKey.VISUAL_EDITOR_AVAILABLE, true); } public static boolean isVisualEditorEnabled() { - return isVisualEditorAvailable() && getBoolean(UndeletablePrefKey.VISUAL_EDITOR_ENABLED, - !isAztecEditorEnabled()); + // hardcode the Visual editor enable to "false". Aztec and Gutenberg are the only ones supported now. + return false; } public static boolean isAsyncPromoRequired() { @@ -633,13 +636,22 @@ public static void setVideoOptimize(boolean optimize) { } public static boolean isGutenbergEditorEnabled() { - return getBoolean(DeletablePrefKey.GUTENBERG_EDITOR_ENABLED, false); + // hardcode Gutenberg enabled to "true". It's Aztec and Gutenberg that we're going to expose to the user now. + return true; } public static void enableGutenbergEditor(boolean enabled) { setBoolean(DeletablePrefKey.GUTENBERG_EDITOR_ENABLED, enabled); } + public static boolean isGutenbergDefaultForNewPosts() { + return getBoolean(DeletablePrefKey.GUTENBERG_DEAFULT_FOR_NEW_POSTS, true); + } + + public static void setGutenbergDefaultForNewPosts(boolean defaultForNewPosts) { + setBoolean(DeletablePrefKey.GUTENBERG_DEAFULT_FOR_NEW_POSTS, defaultForNewPosts); + } + public static void setVideoOptimizeWidth(int width) { setInt(DeletablePrefKey.VIDEO_OPTIMIZE_WIDTH, width); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index 037175085eb1..087400e3a571 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -65,7 +65,7 @@ public class AppSettingsFragment extends PreferenceFragment private DetailListPreference mImageMaxSizePref; private DetailListPreference mImageQualityPref; private WPSwitchPreference mOptimizedVideo; - private WPSwitchPreference mEnableGutenberg; + private WPSwitchPreference mGutenbergDefaultForNewPosts; private DetailListPreference mVideoWidthPref; private DetailListPreference mVideoEncorderBitratePref; private PreferenceScreen mPrivacySettings; @@ -135,9 +135,9 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { (WPSwitchPreference) WPPrefUtils .getPrefAndSetChangeListener(this, R.string.pref_key_optimize_video, this); - mEnableGutenberg = + mGutenbergDefaultForNewPosts = (WPSwitchPreference) WPPrefUtils - .getPrefAndSetChangeListener(this, R.string.pref_key_enable_gutenberg, this); + .getPrefAndSetChangeListener(this, R.string.pref_key_gutenberg_default_for_new_posts, this); mVideoWidthPref = (DetailListPreference) WPPrefUtils .getPrefAndSetChangeListener(this, R.string.pref_key_site_video_width, this); @@ -168,14 +168,12 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { String.valueOf(AppPrefs.getVideoOptimizeQuality()), getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality())); - mEnableGutenberg.setChecked(AppPrefs.isGutenbergEditorEnabled()); + mGutenbergDefaultForNewPosts.setChecked(AppPrefs.isGutenbergDefaultForNewPosts()); mStripImageLocation.setChecked(AppPrefs.isStripImageLocation()); if (!BuildConfig.OFFER_GUTENBERG) { removeExperimentalCategory(); } - - updateEditorSettings(); } private void removeExperimentalCategory() { @@ -307,8 +305,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { setDetailListPreferenceValue(mVideoEncorderBitratePref, newValue.toString(), getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality())); - } else if (preference == mEnableGutenberg) { - AppPrefs.enableGutenbergEditor((Boolean) newValue); + } else if (preference == mGutenbergDefaultForNewPosts) { + AppPrefs.setGutenbergDefaultForNewPosts((Boolean) newValue); } else if (preference == mStripImageLocation) { AppPrefs.setStripImageLocation((Boolean) newValue); } diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListViewModel.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListViewModel.kt index ad3d9a2bf7fe..8e7f23b14add 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListViewModel.kt @@ -51,7 +51,6 @@ import org.wordpress.android.ui.posts.PostAdapterItemData import org.wordpress.android.ui.posts.PostAdapterItemUploadStatus import org.wordpress.android.ui.posts.PostListAction import org.wordpress.android.ui.posts.PostListAction.DismissPendingNotification -import org.wordpress.android.ui.posts.PostListAction.ShowGutenbergWarningDialog import org.wordpress.android.ui.posts.PostUploadAction import org.wordpress.android.ui.posts.PostUploadAction.CancelPostAndMediaUpload import org.wordpress.android.ui.posts.PostUploadAction.EditPostResult @@ -360,18 +359,7 @@ class PostListViewModel @Inject constructor( return } - checkGutenbergOrEdit(site, post) - } - - private fun checkGutenbergOrEdit(site: SiteModel, post: PostModel) { - // Show Gutenberg Warning Dialog if post contains GB blocks and it's not disabled - if (!isGutenbergEnabled() && - PostUtils.contentContainsGutenbergBlocks(post.content) && - !AppPrefs.isGutenbergWarningDialogDisabled()) { - _postListAction.postValue(ShowGutenbergWarningDialog(site, post)) - } else { - editPost(site, post) - } + editPost(site, post) } private fun editPost(site: SiteModel, post: PostModel) { diff --git a/WordPress/src/main/res/values/key_strings.xml b/WordPress/src/main/res/values/key_strings.xml index 62f351c12ab1..e0d446a8a163 100644 --- a/WordPress/src/main/res/values/key_strings.xml +++ b/WordPress/src/main/res/values/key_strings.xml @@ -59,7 +59,7 @@ wp_pref_site_default_image_width wp_pref_site_default_image_quality wp_pref_key_optimize_video - wp_pref_key_enable_gutenberg + wp_pref_key_gutenberg_default_for_new_posts wp_pref_site_default_video_width wp_pref_site_default_encoder_bitrate wp_pref_site_discussion @@ -206,13 +206,6 @@ Custom - - - 0 - 1 - 2 - - en_US diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 6fffffff1f06..f62bdafdd773 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -574,7 +574,7 @@ Unable to load timezones Accelerated Mobile Pages (AMP) Your WordPress.com site supports the use of Accelerated Mobile Pages, a Google-led initiative that dramatically speeds up loading times on mobile devices - Enable Gutenberg + Use block editor for new posts Media @@ -630,7 +630,6 @@ @string/none Enable to resize and compress pictures Enable to resize and compress videos - This is still an experimental version of Gutenberg Require manual approval for everyone\'s comments. Automatically approve if the user has a previously approved comment @@ -771,20 +770,8 @@ We use other tracking tools, including some from third parties. Read about these and how to control them. Read privacy policy Editor - Set editor type - *EXPERIMENTAL* Remove location from media - Beta - Legacy - Visual - - - @string/preference_editor_legacy - @string/preference_editor_visual - @string/preference_editor_beta - - Stats Stats for %s diff --git a/WordPress/src/main/res/xml/app_settings.xml b/WordPress/src/main/res/xml/app_settings.xml index c6d386b3a2fc..cda70329bcf4 100644 --- a/WordPress/src/main/res/xml/app_settings.xml +++ b/WordPress/src/main/res/xml/app_settings.xml @@ -6,20 +6,6 @@ xmlns:tools="http://schemas.android.com/tools" android:key="@string/pref_key_app_settings_root"> - - - - - - - + android:title="@string/site_settings_gutenberg_default_for_new_posts"/>