Skip to content

Commit

Permalink
Merge pull request #9208 from wordpress-mobile/feature/hide-legacy-ed…
Browse files Browse the repository at this point in the history
…itors-options

Enable Gutenberg for all and hide legacy editors options
  • Loading branch information
hypest authored Feb 12, 2019
2 parents f5d7546 + 4647aa7 commit 8812a1e
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 77 deletions.
4 changes: 1 addition & 3 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,25 @@ android {

buildConfigField "boolean", "REVISIONS_ENABLED", "false"
buildConfigField "boolean", "NEW_SITE_CREATION_ENABLED", "false"
buildConfigField "boolean", "OFFER_GUTENBERG", "true"
}

flavorDimensions "buildType"

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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,5 @@ private object TicketFieldIds {

object ZendeskExtraTags {
const val connectingJetpack = "connecting_jetpack"
const val gutenbergIsDefault = "mobile_gutenberg_is_default"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String>?)

val tagsList: ArrayList<String>? = if (AppPrefs.isGutenbergDefaultForNewPosts()) {
// construct a mutable list to add the Gutenberg related extra tag
val list = ArrayList<String>()

// 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<String>?
}

if (tagsList != null && !tagsList.isEmpty()) {
intent.putStringArrayListExtra(HelpActivity.EXTRA_TAGS_KEY, tagsList)
}

return intent
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 1 addition & 8 deletions WordPress/src/main/res/values/key_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<string name="pref_key_site_image_width" translatable="false">wp_pref_site_default_image_width</string>
<string name="pref_key_site_image_quality" translatable="false">wp_pref_site_default_image_quality</string>
<string name="pref_key_optimize_video" translatable="false">wp_pref_key_optimize_video</string>
<string name="pref_key_enable_gutenberg" translatable="false">wp_pref_key_enable_gutenberg</string>
<string name="pref_key_gutenberg_default_for_new_posts" translatable="false">wp_pref_key_gutenberg_default_for_new_posts</string>
<string name="pref_key_site_video_width" translatable="false">wp_pref_site_default_video_width</string>
<string name="pref_key_site_video_encoder_bitrate" translatable="false">wp_pref_site_default_encoder_bitrate</string>
<string name="pref_key_site_discussion" translatable="false">wp_pref_site_discussion</string>
Expand Down Expand Up @@ -206,13 +206,6 @@
<item>Custom</item>
</string-array>

<!-- App Settings - Editor -->
<string-array name="editor_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>

<!-- Used as values to a preference in Site Settings -->
<string-array name="language_codes" translatable="false">
<item>en_US</item>
Expand Down
15 changes: 1 addition & 14 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@
<string name="site_settings_timezones_error">Unable to load timezones</string>
<string name="site_settings_amp_title">Accelerated Mobile Pages (AMP)</string>
<string name="site_settings_amp_summary">Your WordPress.com site supports the use of Accelerated Mobile Pages, a Google-led initiative that dramatically speeds up loading times on mobile devices</string>
<string name="site_settings_enable_gutenberg">Enable Gutenberg</string>
<string name="site_settings_gutenberg_default_for_new_posts">Use block editor for new posts</string>

<!-- Media -->
<string name="site_settings_quota_header">Media</string>
Expand Down Expand Up @@ -630,7 +630,6 @@
<string name="site_settings_whitelist_none_summary" translatable="false">@string/none</string>
<string name="site_settings_optimize_images_summary">Enable to resize and compress pictures</string>
<string name="site_settings_optimize_video_summary">Enable to resize and compress videos</string>
<string name="site_settings_enable_gutenberg_summary">This is still an experimental version of Gutenberg</string>

<string name="detail_approve_manual">Require manual approval for everyone\'s comments.</string>
<string name="detail_approve_auto_if_previously_approved">Automatically approve if the user has a previously approved comment</string>
Expand Down Expand Up @@ -771,20 +770,8 @@
<string name="third_party_policy_learn_more_caption">We use other tracking tools, including some from third parties. Read about these and how to control them.</string>
<string name="privacy_policy_read">Read privacy policy</string>
<string name="preference_editor">Editor</string>
<string name="preference_editor_type">Set editor type</string>
<string name="preference_experimental">*EXPERIMENTAL*</string>
<string name="preference_strip_image_location">Remove location from media</string>

<string name="preference_editor_beta" translatable="false">Beta</string>
<string name="preference_editor_legacy">Legacy</string>
<string name="preference_editor_visual">Visual</string>

<string-array name="editor_entries" translatable="false">
<item>@string/preference_editor_legacy</item>
<item>@string/preference_editor_visual</item>
<item>@string/preference_editor_beta</item>
</string-array>

<!-- stats -->
<string name="stats">Stats</string>
<string name="stats_for">Stats for %s</string>
Expand Down
25 changes: 4 additions & 21 deletions WordPress/src/main/res/xml/app_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:key="@string/pref_key_app_settings_root">

<PreferenceCategory
android:key="@string/pref_key_experimental_section"
android:layout="@layout/wp_preference_category"
android:title="@string/preference_experimental">

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_enable_gutenberg"
android:key="@string/pref_key_enable_gutenberg"
android:layout="@layout/wp_preference_layout"
android:summary="@string/site_settings_enable_gutenberg_summary"
android:title="@string/site_settings_enable_gutenberg"/>

</PreferenceCategory>

<org.wordpress.android.ui.prefs.DetailListPreference
android:key="@string/pref_key_language"
android:layout="@layout/wp_preference_layout"
Expand Down Expand Up @@ -75,14 +61,11 @@
android:layout="@layout/wp_preference_category"
android:title="@string/preference_editor">

<org.wordpress.android.ui.prefs.DetailListPreference
android:defaultValue="1"
android:entries="@array/editor_entries"
android:entryValues="@array/editor_values"
android:key="@string/pref_key_editor_type"
<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_gutenberg_default_for_new_posts"
android:key="@string/pref_key_gutenberg_default_for_new_posts"
android:layout="@layout/wp_preference_layout"
android:title="@string/preference_editor_type"
tools:summary="Visual"/>
android:title="@string/site_settings_gutenberg_default_for_new_posts"/>
</PreferenceCategory>

<PreferenceCategory
Expand Down

0 comments on commit 8812a1e

Please sign in to comment.