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

Jetpack performance settings #10468

Merged
merged 14 commits into from Sep 5, 2019
Expand Up @@ -22,7 +22,7 @@
import java.io.OutputStream;

public class WordPressDB {
private static final int DATABASE_VERSION = 66;
private static final int DATABASE_VERSION = 67;


// Warning renaming DATABASE_NAME could break previous App backups (see: xml/backup_scheme.xml)
Expand Down Expand Up @@ -174,6 +174,10 @@ public WordPressDB(Context ctx) {
case 65:
// add external users only to publicize services table
PublicizeTable.resetServicesTable(mDb);
case 66:
// add Jetpack search site setting
mDb.execSQL(SiteSettingsModel.ADD_JETPACK_SEARCH_SUPPORTED);
mDb.execSQL(SiteSettingsModel.ADD_JETPACK_SEARCH_ENABLED);
}
mDb.setVersion(DATABASE_VERSION);
}
Expand Down
Expand Up @@ -18,9 +18,12 @@ public class JetpackSettingsModel {
public boolean ssoRequireTwoFactor;
// Modules
public boolean serveImagesFromOurServers;
public boolean serveStaticFilesFromOurServers;
public boolean lazyLoadImages;
public boolean commentLikes;
public boolean sharingEnabled = true;
public boolean improvedSearch;
public boolean adFreeVideoHosting;

public JetpackSettingsModel() {
super();
Expand All @@ -43,8 +46,11 @@ public JetpackSettingsModel(final JetpackSettingsModel other) {
commentLikes = other.commentLikes;
jetpackProtectWhitelist.addAll(other.jetpackProtectWhitelist);
serveImagesFromOurServers = other.serveImagesFromOurServers;
serveStaticFilesFromOurServers = other.serveStaticFilesFromOurServers;
lazyLoadImages = other.lazyLoadImages;
sharingEnabled = other.sharingEnabled;
improvedSearch = other.improvedSearch;
adFreeVideoHosting = other.adFreeVideoHosting;
}

@Override
Expand All @@ -59,9 +65,12 @@ public boolean equals(Object other) {
&& ssoMatchEmail == otherModel.ssoMatchEmail
&& ssoRequireTwoFactor == otherModel.ssoRequireTwoFactor
&& serveImagesFromOurServers == otherModel.serveImagesFromOurServers
&& serveStaticFilesFromOurServers == otherModel.serveStaticFilesFromOurServers
&& lazyLoadImages == otherModel.lazyLoadImages
&& commentLikes == otherModel.commentLikes
&& sharingEnabled == otherModel.sharingEnabled
&& improvedSearch == otherModel.improvedSearch
&& adFreeVideoHosting == otherModel.adFreeVideoHosting
&& whitelistMatches(otherModel.jetpackProtectWhitelist);
}

Expand Down
Expand Up @@ -67,6 +67,8 @@ public class SiteSettingsModel {
private static final String POSTS_PER_PAGE_COLUMN_NAME = "postsPerPage";
private static final String AMP_SUPPORTED_COLUMN_NAME = "ampSupported";
private static final String AMP_ENABLED_COLUMN_NAME = "ampEnabled";
private static final String JETPACK_SEARCH_SUPPORTED_COLUMN_NAME = "jetpackSearchSupported";
private static final String JETPACK_SEARCH_ENABLED_COLUMN_NAME = "jetpackSearchEnabled";

public static final String SETTINGS_TABLE_NAME = "site_settings";

Expand Down Expand Up @@ -96,6 +98,10 @@ public class SiteSettingsModel {
+ " add " + AMP_ENABLED_COLUMN_NAME + " BOOLEAN;";
public static final String ADD_AMP_SUPPORTED = "alter table " + SETTINGS_TABLE_NAME
+ " add " + AMP_SUPPORTED_COLUMN_NAME + " BOOLEAN;";
public static final String ADD_JETPACK_SEARCH_ENABLED = "alter table " + SETTINGS_TABLE_NAME
+ " add " + JETPACK_SEARCH_ENABLED_COLUMN_NAME + " BOOLEAN;";
public static final String ADD_JETPACK_SEARCH_SUPPORTED = "alter table " + SETTINGS_TABLE_NAME
+ " add " + JETPACK_SEARCH_SUPPORTED_COLUMN_NAME + " BOOLEAN;";
public static final String ADD_SITE_ICON = "alter table " + SETTINGS_TABLE_NAME
+ " add " + SITE_ICON_COLUMN_NAME + " INTEGER;";

Expand Down Expand Up @@ -186,6 +192,8 @@ public class SiteSettingsModel {
public int postsPerPage;
public boolean ampSupported;
public boolean ampEnabled;
public boolean jetpackSearchSupported;
public boolean jetpackSearchEnabled;
public String quotaDiskSpace;

@Override
Expand Down Expand Up @@ -228,6 +236,8 @@ && equals(timezone, otherModel.timezone)
&& postsPerPage == otherModel.postsPerPage
&& ampEnabled == otherModel.ampEnabled
&& ampSupported == otherModel.ampSupported
&& jetpackSearchEnabled == otherModel.jetpackSearchEnabled
&& jetpackSearchSupported == otherModel.jetpackSearchSupported
&& maxLinks == otherModel.maxLinks
&& equals(defaultPostFormat, otherModel.defaultPostFormat)
&& holdForModeration != null
Expand Down Expand Up @@ -291,6 +301,8 @@ public void copyFrom(SiteSettingsModel other) {
postsPerPage = other.postsPerPage;
ampSupported = other.ampSupported;
ampEnabled = other.ampEnabled;
jetpackSearchSupported = other.jetpackSearchSupported;
jetpackSearchEnabled = other.jetpackSearchEnabled;
if (other.holdForModeration != null) {
holdForModeration = new ArrayList<>(other.holdForModeration);
}
Expand Down Expand Up @@ -353,6 +365,8 @@ public void deserializeOptionsDatabaseCursor(Cursor cursor, SparseArrayCompat<Ca
postsPerPage = getIntFromCursor(cursor, POSTS_PER_PAGE_COLUMN_NAME);
ampSupported = getBooleanFromCursor(cursor, AMP_SUPPORTED_COLUMN_NAME);
ampEnabled = getBooleanFromCursor(cursor, AMP_ENABLED_COLUMN_NAME);
jetpackSearchSupported = getBooleanFromCursor(cursor, JETPACK_SEARCH_SUPPORTED_COLUMN_NAME);
jetpackSearchEnabled = getBooleanFromCursor(cursor, JETPACK_SEARCH_ENABLED_COLUMN_NAME);

String moderationKeys = getStringFromCursor(cursor, MODERATION_KEYS_COLUMN_NAME);
String blacklistKeys = getStringFromCursor(cursor, BLACKLIST_KEYS_COLUMN_NAME);
Expand Down Expand Up @@ -443,6 +457,8 @@ public ContentValues serializeToDatabase() {
values.put(POSTS_PER_PAGE_COLUMN_NAME, postsPerPage);
values.put(AMP_SUPPORTED_COLUMN_NAME, ampSupported);
values.put(AMP_ENABLED_COLUMN_NAME, ampEnabled);
values.put(JETPACK_SEARCH_SUPPORTED_COLUMN_NAME, jetpackSearchSupported);
values.put(JETPACK_SEARCH_ENABLED_COLUMN_NAME, jetpackSearchEnabled);

String moderationKeys = "";
if (holdForModeration != null) {
Expand Down