Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
66d6e54
Add additional properties to gutenberg_enabled , and gutenberg_disab…
daniloercoli Jul 30, 2019
5da815e
Bump analytics on new site creation
daniloercoli Jul 30, 2019
e3375bd
Introduce enum to track `source` property of the events enable/disabl…
daniloercoli Jul 30, 2019
5809aa7
Add utils method in Enum declaration that helped a bit on cleaning th…
daniloercoli Jul 30, 2019
c29d280
Merge branch 'develop' of https://github.com/wordpress-mobile/WordPre…
daniloercoli Jul 30, 2019
6c2f05a
Do not bump editor analytics just after login phase, when the editor(…
daniloercoli Jul 30, 2019
e07d3a7
Fix Lint
daniloercoli Jul 30, 2019
b59bd91
Make sure to add the `gutenberg_enabled` properties to the user_prope…
daniloercoli Jul 31, 2019
2cfbd0b
Use the tagged version of FluxC
jkmassel Jul 31, 2019
f27ae01
Update release notes for 13.0
jkmassel Jul 31, 2019
1f59fa2
Make sure to migrate the current selected site first. Also changed th…
daniloercoli Aug 2, 2019
f9df9b0
Remove unnecessary UI refresh
daniloercoli Aug 2, 2019
192257e
Do not fetch editors for the current selected site during the migrati…
daniloercoli Aug 2, 2019
fb3cc05
Update the 12.9 release notes to add a note about the block editor
jkmassel Aug 4, 2019
4db8228
Clean up the code in `setGutenbergEnabledIfNeeded` and make easy to …
daniloercoli Aug 5, 2019
e42aa02
Merge branch 'add/analitycs-to-GB-editor-flip' of https://github.com/…
daniloercoli Aug 5, 2019
32c9374
Merge pull request #10300 from wordpress-mobile/add/analitycs-to-GB-e…
hypest Aug 5, 2019
7d3bd40
Make sure to proper handle the new `OnAllSitesMobileEditorChanged` ev…
daniloercoli Aug 6, 2019
25712a2
Use the new API Endpoint to set the editor option on migration from v…
daniloercoli Aug 6, 2019
f66d22e
Update FluxC Hash
daniloercoli Aug 6, 2019
9a7a6b9
Merge branch 'fix/editor-opt-in-strategy-with-backend-support' of htt…
daniloercoli Aug 6, 2019
adfe95a
Merge branch 'release/13.0' of https://github.com/wordpress-mobile/Wo…
daniloercoli Aug 6, 2019
e02aacf
Update FluxC hash
daniloercoli Aug 6, 2019
f278080
Mark `isGutenbergDefaultForNewPosts` deprecated
daniloercoli Aug 6, 2019
599580d
Remove SiteStore method parameter that is not being used anymore
daniloercoli Aug 6, 2019
dfe29a9
Make sure to remove the "old" global app setting only when the migrat…
daniloercoli Aug 6, 2019
1e0edd9
Make sure to delete the local app-wide pref when it's a response from…
daniloercoli Aug 6, 2019
2379640
Update fluxC hash
daniloercoli Aug 6, 2019
871a30e
Use tagged version of FluxC
daniloercoli Aug 7, 2019
2508421
Merge pull request #10332 from wordpress-mobile/fix/editor-opt-in-str…
daniloercoli Aug 7, 2019
71b5bc8
Update FluxC hash to include the latest version that uses the paramet…
daniloercoli Aug 7, 2019
2adecc7
Upgrade FluxC version to the 1.1.2 tagged version
daniloercoli Aug 7, 2019
b939231
Merge pull request #10339 from wordpress-mobile/fix/do-not-override-e…
daniloercoli Aug 7, 2019
d8746ea
Bump version number
loremattei Aug 7, 2019
efa0436
Update FluxC hash
daniloercoli Aug 7, 2019
ed12d44
Use the new tagged 1.1.3 version of FluxC
daniloercoli Aug 7, 2019
036f0da
using Activity context instead of application global context
mzorz Aug 8, 2019
34257d6
changed creating new Resources object for new Context based on existi…
mzorz Aug 8, 2019
e29ec6f
removed unused import
mzorz Aug 8, 2019
44cc7d8
removed unnecessary spaces
mzorz Aug 8, 2019
9309ce2
Merge pull request #10345 from wordpress-mobile/fix/do-not-override-e…
hypest Aug 8, 2019
4663ec6
Merge pull request #10347 from wordpress-mobile/fix/gb-editor-transla…
daniloercoli Aug 8, 2019
4569642
Bump version to 13.0-rc-3/alpha-185
loremattei Aug 8, 2019
554abcb
Update fluxC to get latest fixes from the beta
loremattei Aug 8, 2019
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
8 changes: 4 additions & 4 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ android {

defaultConfig {
applicationId "org.wordpress.android"
versionName "alpha-183"
versionCode 762
versionName "alpha-185"
versionCode 766
minSdkVersion 21
targetSdkVersion 28

Expand All @@ -74,8 +74,8 @@ android {
productFlavors {
vanilla { // used for release and beta
dimension "buildType"
versionName "13.0-rc-1"
versionCode 761
versionName "13.0-rc-3"
versionCode 765
}

zalpha { // alpha version - enable experimental features
Expand Down
10 changes: 10 additions & 0 deletions WordPress/metadata/PlayStoreStrings.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ msgstr ""
"X-Generator: VsCode\n"
"Project-Id-Version: Release Notes & Play Store Descriptions\n"

#. translators: Release notes for this version to be displayed in the Play Store. Limit to 500 characters including spaces and commas!
msgctxt "release_note_130"
msgid ""
"13.0:\n"
"* Block editor improvements: the editor is auto-enabled when you open a block post (unless you opted out in v12.9), or you can enable it on a per-site basis.\n"
"* Accessibility improvements: screen readers can now read more of the stats screen.\n"
"* General usability improvements: logging in is speedier, colors are more consistent across screens, and bug fixes put an end to some crashes.\n"
msgstr ""

#. translators: Release notes for this version to be displayed in the Play Store. Limit to 500 characters including spaces and commas!
msgctxt "release_note_129"
msgid ""
"12.9:\n"
"* Customers with unclaimed domain credits can register domains in the app.\n"
"* You can expand the Comment Editor to Full Screen for more space while editing.\n"
"* The Block editor has a few improvements: Video blocks are available, and a some issues that led to content loss when using unsupported blocks have been resolved.\n"
"* The block editor is now the default for new posts after you open a block-based post for the first time.\n"
msgstr ""

msgctxt "release_note_128"
Expand Down
8 changes: 3 additions & 5 deletions WordPress/metadata/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
* Fixes a crash that could happen when viewing help from the login screen
* Allow setting which editor to use on a per-site basis
* Improves accessibility in stats
* Makes it easier to log in by validating the URL to your site more quickly.
* Some minor tweaks to the colour scheme
* Block editor improvements: the editor is auto-enabled when you open a block post (unless you opted out in v12.9), or you can enable it on a per-site basis.
* Accessibility improvements: screen readers can now read more of the stats screen.
* General usability improvements: logging in is speedier, colors are more consistent across screens, and bug fixes put an end to some crashes.
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ public void onAppComesFromBackground() {
sDeleteExpiredStats.runIfNotLimited();

// Let's migrate the old editor preference if available in AppPrefs to the remote backend
SiteUtils.migrateAppWideMobileEditorPreferenceToRemote(mContext, mDispatcher, mSiteStore);
SiteUtils.migrateAppWideMobileEditorPreferenceToRemote(mContext, mDispatcher);

if (mFirstActivityResumed) {
deferredInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
case RequestCodes.CREATE_SITE:
if (data != null) {
int newSiteLocalID = data.getIntExtra(SitePickerActivity.KEY_LOCAL_ID, -1);
SiteUtils.enableBlockEditor(mDispatcher, mSiteStore, newSiteLocalID);
SiteUtils.enableBlockEditorOnSiteCreation(mDispatcher, mSiteStore, newSiteLocalID);
// Mark the site to show the GB popup at first editor run
SiteModel newSiteModel = mSiteStore.getSiteByLocalId(newSiteLocalID);
if (newSiteModel != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.wordpress.android.fluxc.store.QuickStartStore.QuickStartTask;
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.fluxc.store.SiteStore.CompleteQuickStartPayload;
import org.wordpress.android.fluxc.store.SiteStore.OnAllSitesMobileEditorChanged;
import org.wordpress.android.fluxc.store.SiteStore.OnQuickStartCompleted;
import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged;
import org.wordpress.android.fluxc.store.SiteStore.OnSiteEditorsChanged;
Expand Down Expand Up @@ -775,7 +776,7 @@ public void onClick(View v) {
// Enable the block editor on sites created on mobile
if (data != null) {
int newSiteLocalID = data.getIntExtra(SitePickerActivity.KEY_LOCAL_ID, -1);
SiteUtils.enableBlockEditor(mDispatcher, mSiteStore, newSiteLocalID);
SiteUtils.enableBlockEditorOnSiteCreation(mDispatcher, mSiteStore, newSiteLocalID);
// Mark the site to show the GB popup at first editor run
SiteModel newSiteModel = mSiteStore.getSiteByLocalId(newSiteLocalID);
if (newSiteModel != null) {
Expand Down Expand Up @@ -1157,6 +1158,26 @@ public void onSiteEditorsChanged(OnSiteEditorsChanged event) {
return;
}

refreshCurrentSelectedSiteAfterEditorChanges(false, event.site.getId());
}

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onAllSitesMobileEditorChanged(OnAllSitesMobileEditorChanged event) {
if (event.isError()) {
return;
}
if (event.isNetworkResponse) {
// We can remove the global app setting now, since we're sure the migration ended with success.
AppPrefs.removeAppWideEditorPreference();
}
refreshCurrentSelectedSiteAfterEditorChanges(true, -1);
}

private void refreshCurrentSelectedSiteAfterEditorChanges(boolean alwaysRefreshUI, int localSiteID) {
// Need to update the user property about GB enabled on any of the sites
AnalyticsUtils.refreshMetadata(mAccountStore, mSiteStore);

// "Reload" selected site from the db
// It would be better if the OnSiteChanged provided the list of changed sites.
if (getSelectedSite() == null && mSiteStore.hasSite()) {
Expand All @@ -1166,6 +1187,15 @@ public void onSiteEditorsChanged(OnSiteEditorsChanged event) {
return;
}

// When alwaysRefreshUI is `true` we need to refresh the UI regardless of the current site
if (!alwaysRefreshUI) {
// we need to refresh the UI only when the site IDs matches
if (getSelectedSite().getId() != localSiteID) {
// No need to refresh the UI, since the current selected site is another site
return;
}
}

SiteModel site = mSiteStore.getSiteByLocalId(getSelectedSite().getId());
if (site != null) {
mSelectedSite = site;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
import org.wordpress.android.util.WPPermissionUtils;
import org.wordpress.android.util.WPUrlUtils;
import org.wordpress.android.util.analytics.AnalyticsUtils;
import org.wordpress.android.util.analytics.AnalyticsUtils.BlockEditorEnabledSource;
import org.wordpress.android.util.helpers.MediaFile;
import org.wordpress.android.util.helpers.MediaGallery;
import org.wordpress.android.util.helpers.MediaGalleryImageSpan;
Expand Down Expand Up @@ -1558,10 +1559,16 @@ private void showGutenbergInformativeDialog() {
}

private void setGutenbergEnabledIfNeeded() {
if ((TextUtils.isEmpty(mSite.getMobileEditor()) && !mIsNewPost)
|| AppPrefs.shouldShowGutenbergInfoPopup(mSite.getUrl())) {
boolean showPopup = AppPrefs.shouldShowGutenbergInfoPopup(mSite.getUrl());

if (TextUtils.isEmpty(mSite.getMobileEditor()) && !mIsNewPost) {
SiteUtils.enableBlockEditor(mDispatcher, mSite);
AnalyticsUtils.trackWithSiteDetails(Stat.EDITOR_GUTENBERG_ENABLED, mSite);
AnalyticsUtils.trackWithSiteDetails(Stat.EDITOR_GUTENBERG_ENABLED, mSite,
BlockEditorEnabledSource.ON_BLOCK_POST_OPENING.asPropertyMap());
showPopup = true;
}

if (showPopup) {
showGutenbergInformativeDialog();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ public static boolean isGutenbergEditorEnabled() {
return true;
}

/**
* @deprecated As of release 13.0, replaced by SiteSettings mobile editor value
*/
@Deprecated
public static boolean isGutenbergDefaultForNewPosts() {
return getBoolean(DeletablePrefKey.GUTENBERG_DEFAULT_FOR_NEW_POSTS, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import org.wordpress.android.util.WPActivityUtils;
import org.wordpress.android.util.WPPrefUtils;
import org.wordpress.android.util.analytics.AnalyticsUtils;
import org.wordpress.android.util.analytics.AnalyticsUtils.BlockEditorEnabledSource;
import org.wordpress.android.widgets.WPSnackbar;

import java.util.HashMap;
Expand Down Expand Up @@ -743,7 +744,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
AnalyticsUtils.trackWithSiteDetails(
((Boolean) newValue) ? Stat.EDITOR_GUTENBERG_ENABLED : Stat.EDITOR_GUTENBERG_DISABLED,
mSite);
mSite, BlockEditorEnabledSource.VIA_SITE_SETTINGS.asPropertyMap());
// we need to refresh metadata as gutenberg_enabled is now part of the user data
AnalyticsUtils.refreshMetadata(mAccountStore, mSiteStore);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import org.wordpress.android.fluxc.generated.SiteActionBuilder;
import org.wordpress.android.fluxc.model.PostFormatModel;
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.fluxc.store.SiteStore.OnAllSitesMobileEditorChanged;
import org.wordpress.android.fluxc.store.SiteStore.OnPostFormatsChanged;
import org.wordpress.android.fluxc.store.SiteStore.OnSiteEditorsChanged;
import org.wordpress.android.models.CategoryModel;
Expand All @@ -31,6 +33,7 @@
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.util.analytics.AnalyticsUtils;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -171,6 +174,7 @@ public interface SiteSettingsListener {

@Inject SiteStore mSiteStore;
@Inject Dispatcher mDispatcher;
@Inject AccountStore mAccountStore;

protected SiteSettingsInterface(Context host, SiteModel site, SiteSettingsListener listener) {
((WordPress) host.getApplicationContext()).component().inject(this);
Expand Down Expand Up @@ -949,7 +953,11 @@ public SiteSettingsInterface init(boolean fetchRemote) {
if (fetchRemote) {
fetchRemoteData();
mDispatcher.dispatch(SiteActionBuilder.newFetchPostFormatsAction(mSite));
mDispatcher.dispatch(SiteActionBuilder.newFetchSiteEditorsAction(mSite));
if (!AppPrefs.isDefaultAppWideEditorPreferenceSet()) {
// Check if the migration from app-wide to per-site setting has already happened - v12.9->13.0
// before fetching site editors from the remote
mDispatcher.dispatch(SiteActionBuilder.newFetchSiteEditorsAction(mSite));
}
}

return this;
Expand Down Expand Up @@ -1136,6 +1144,25 @@ public void onSiteEditorsChanged(OnSiteEditorsChanged event) {
if (event.isError()) {
return;
}
updateAnalyticsAndUI();
}

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onAllSitesMobileEditorChanged(OnAllSitesMobileEditorChanged event) {
if (event.isError()) {
return;
}
if (event.isNetworkResponse) {
// We can remove the global app setting now, since we're sure the migration ended with success.
AppPrefs.removeAppWideEditorPreference();
}
updateAnalyticsAndUI();
}

private void updateAnalyticsAndUI() {
// Need to update the user property about GB enabled on any of the sites
AnalyticsUtils.refreshMetadata(mAccountStore, mSiteStore);

notifyUpdatedOnUiThread();
}
Expand Down
52 changes: 19 additions & 33 deletions WordPress/src/main/java/org/wordpress/android/util/SiteUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.wordpress.android.analytics.AnalyticsTracker.Stat;
import org.wordpress.android.fluxc.Dispatcher;
import org.wordpress.android.fluxc.generated.SiteActionBuilder;
import org.wordpress.android.fluxc.model.SiteModel;
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.fluxc.store.SiteStore.DesignateMobileEditorForAllSitesPayload;
import org.wordpress.android.fluxc.store.SiteStore.DesignateMobileEditorPayload;
import org.wordpress.android.ui.plans.PlansConstants;
import org.wordpress.android.ui.prefs.AppPrefs;
import org.wordpress.android.util.analytics.AnalyticsUtils;
import org.wordpress.android.util.analytics.AnalyticsUtils.BlockEditorEnabledSource;
import org.wordpress.android.util.helpers.Version;

import java.util.ArrayList;
Expand All @@ -25,53 +29,35 @@ public class SiteUtils {
/**
* Migrate the old app-wide editor preference value to per-site setting. wpcom sites will make a network call
* and store the value on the backend. selfHosted sites just store the value in the local DB in FluxC
*
* <p>
* Strategy: Check if there is the old app-wide preference still available (v12.9 and before used it).
* -- 12.9 ON -> turn all sites ON in 13.0
* -- 12.9 OPTED OUT (were auto-opted in but turned it OFF) -> turn all sites OFF in 13.0
*
* @param dispatcher FluxC dispatcher
* @param siteStore SiteStore
*/
public static void migrateAppWideMobileEditorPreferenceToRemote(final Context context,
final Dispatcher dispatcher,
final SiteStore siteStore) {
final Dispatcher dispatcher) {
if (!AppPrefs.isDefaultAppWideEditorPreferenceSet()) {
return;
}
final boolean oldAppWidePreferenceValue = AppPrefs.isGutenbergDefaultForNewPosts();
final List<SiteModel> sites = siteStore.getSites();
final boolean setDelay = sites.size() > 5;
new Thread(new Runnable() {
@Override
public void run() {
// Be optimistic and remove the old app-wide preference before we start the calls
// Only do this when the network connection is available
if (NetworkUtils.isNetworkAvailable(context)) {
AppPrefs.removeAppWideEditorPreference();
}
for (SiteModel currentSite : sites) {
if (oldAppWidePreferenceValue) {
enableBlockEditor(dispatcher, currentSite);
} else {
disableBlockEditor(dispatcher, currentSite);
}
if (setDelay) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// no-op
}
}
}
}
}).start();

if (oldAppWidePreferenceValue) {
dispatcher.dispatch(SiteActionBuilder.newDesignateMobileEditorForAllSitesAction(
new DesignateMobileEditorForAllSitesPayload(SiteUtils.GB_EDITOR_NAME)));
} else {
dispatcher.dispatch(SiteActionBuilder.newDesignateMobileEditorForAllSitesAction(
new DesignateMobileEditorForAllSitesPayload(SiteUtils.AZTEC_EDITOR_NAME)));
}
}

public static boolean enableBlockEditor(Dispatcher dispatcher, SiteStore siteStore, int siteLocalSiteID) {
public static boolean enableBlockEditorOnSiteCreation(Dispatcher dispatcher, SiteStore siteStore,
int siteLocalSiteID) {
SiteModel newSiteModel = siteStore.getSiteByLocalId(siteLocalSiteID);
if (newSiteModel != null) {
enableBlockEditor(dispatcher, newSiteModel);
enableBlockEditor(dispatcher, newSiteModel);
AnalyticsUtils.trackWithSiteDetails(Stat.EDITOR_GUTENBERG_ENABLED, newSiteModel,
BlockEditorEnabledSource.ON_SITE_CREATION.asPropertyMap());
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.models.ReaderPost;
import org.wordpress.android.ui.posts.PostListViewLayoutType;
import org.wordpress.android.ui.prefs.AppPrefs;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.FluxCUtils;
import org.wordpress.android.util.ImageUtils;
Expand Down Expand Up @@ -70,6 +69,18 @@ public class AnalyticsUtils {

public static final String HAS_GUTENBERG_BLOCKS_KEY = "has_gutenberg_blocks";

public enum BlockEditorEnabledSource {
VIA_SITE_SETTINGS,
ON_SITE_CREATION,
ON_BLOCK_POST_OPENING;

public Map<String, Object> asPropertyMap() {
Map<String, Object> properties = new HashMap<>();
properties.put("source", name().toLowerCase(Locale.ROOT));
return properties;
}
}

public static void updateAnalyticsPreference(Context ctx,
Dispatcher mDispatcher,
AccountStore mAccountStore,
Expand Down Expand Up @@ -105,15 +116,10 @@ public static void refreshMetadata(AccountStore accountStore, SiteStore siteStor
metadata.setNumBlogs(siteStore.getSitesCount());
metadata.setUsername(accountStore.getAccount().getUserName());
metadata.setEmail(accountStore.getAccount().getEmail());

int siteLocalId = AppPrefs.getSelectedSite();
if (siteLocalId != -1) {
// Site previously selected, use it
SiteModel selectedSite = siteStore.getSiteByLocalId(siteLocalId);
// If saved site exist, then add info
if (selectedSite != null) {
metadata.setGutenbergEnabled(
SiteUtils.isBlockEditorDefaultForNewPost(selectedSite));
for (SiteModel currentSite : siteStore.getSites()) {
if (SiteUtils.GB_EDITOR_NAME.equals(currentSite.getMobileEditor())) {
metadata.setGutenbergEnabled(true);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ buildScan {

ext {
daggerVersion = '2.22.1'
fluxCVersion = '1.2.0-beta-1'
fluxCVersion = '1.2.0-beta-3'
}
Loading