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

Remove Jetpack Lazy Images setting #21575

Merged
merged 6 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class JetpackSettingsModel {
// Modules
public boolean serveImagesFromOurServers;
public boolean serveStaticFilesFromOurServers;
public boolean lazyLoadImages;
public boolean commentLikes;
public boolean sharingEnabled = true;
public boolean improvedSearch;
Expand Down Expand Up @@ -47,7 +46,6 @@ public JetpackSettingsModel(final JetpackSettingsModel other) {
jetpackProtectAllowlist.addAll(other.jetpackProtectAllowlist);
serveImagesFromOurServers = other.serveImagesFromOurServers;
serveStaticFilesFromOurServers = other.serveStaticFilesFromOurServers;
lazyLoadImages = other.lazyLoadImages;
sharingEnabled = other.sharingEnabled;
improvedSearch = other.improvedSearch;
adFreeVideoHosting = other.adFreeVideoHosting;
Expand All @@ -66,7 +64,6 @@ public boolean equals(Object other) {
&& ssoRequireTwoFactor == otherModel.ssoRequireTwoFactor
&& serveImagesFromOurServers == otherModel.serveImagesFromOurServers
&& serveStaticFilesFromOurServers == otherModel.serveStaticFilesFromOurServers
&& lazyLoadImages == otherModel.lazyLoadImages
&& commentLikes == otherModel.commentLikes
&& sharingEnabled == otherModel.sharingEnabled
&& improvedSearch == otherModel.improvedSearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ public class SiteSettingsFragment extends PreferenceFragment
private WPSwitchPreference mJpMatchEmailPref;
private WPSwitchPreference mJpUseTwoFactorPref;

// Speed up settings
private WPSwitchPreference mLazyLoadImages;
private WPSwitchPreference mLazyLoadImagesNested;

// Jetpack media settings
private WPSwitchPreference mAdFreeVideoHosting;
private WPSwitchPreference mAdFreeVideoHostingNested;
Expand Down Expand Up @@ -720,8 +716,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
} else if (preference == mJpUseTwoFactorPref) {
mJpUseTwoFactorPref.setChecked((Boolean) newValue);
mSiteSettings.enableJetpackSsoTwoFactor((Boolean) newValue);
} else if (preference == mLazyLoadImages || preference == mLazyLoadImagesNested) {
setLazyLoadImagesChecked((Boolean) newValue);
} else if (preference == mAdFreeVideoHosting || preference == mAdFreeVideoHostingNested) {
setAdFreeHostingChecked((Boolean) newValue);
} else if (preference == mImprovedSearch) {
Expand Down Expand Up @@ -1045,9 +1039,6 @@ public void initPreferences() {
mServeStaticFilesFromOurServersNested =
(WPSwitchPreference) getChangePref(R.string.pref_key_serve_static_files_from_our_servers_nested);

mLazyLoadImages = (WPSwitchPreference) getChangePref(R.string.pref_key_lazy_load_images);
mLazyLoadImagesNested = (WPSwitchPreference) getChangePref(R.string.pref_key_lazy_load_images_nested);

mAdFreeVideoHosting = (WPSwitchPreference) getChangePref(R.string.pref_key_ad_free_video_hosting);
mAdFreeVideoHostingNested = (WPSwitchPreference) getChangePref(R.string.pref_key_ad_free_video_hosting_nested);

Expand Down Expand Up @@ -1499,7 +1490,6 @@ public void setPreferencesFromSiteSettings() {
mWeekStartPref.setValue(mSiteSettings.getStartOfWeek());
mWeekStartPref.setSummary(mWeekStartPref.getEntry());
mGutenbergDefaultForNewPosts.setChecked(SiteUtils.isBlockEditorDefaultForNewPost(mSite));
setLazyLoadImagesChecked(mSiteSettings.isLazyLoadImagesEnabled());
setAdFreeHostingChecked(mSiteSettings.isAdFreeHostingEnabled());
boolean checked = mSiteSettings.isImprovedSearchEnabled() || mSiteSettings.getJetpackSearchEnabled();
mImprovedSearch.setChecked(checked);
Expand Down Expand Up @@ -1560,12 +1550,6 @@ private void setSiteAcceleratorChecked(boolean checked) {
mSiteAcceleratorNested.setChecked(checked);
}

private void setLazyLoadImagesChecked(boolean checked) {
mSiteSettings.enableLazyLoadImages(checked);
mLazyLoadImages.setChecked(checked);
mLazyLoadImagesNested.setChecked(checked);
}

private void setAdFreeHostingChecked(boolean checked) {
mSiteSettings.enableAdFreeHosting(checked);
mAdFreeVideoHosting.setChecked(checked);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,14 +701,6 @@ boolean isServeStaticFilesFromOurServersEnabled() {
return mJpSettings.serveStaticFilesFromOurServers;
}

void enableLazyLoadImages(boolean enabled) {
mJpSettings.lazyLoadImages = enabled;
}

boolean isLazyLoadImagesEnabled() {
return mJpSettings.lazyLoadImages;
}

void enableAdFreeHosting(boolean enabled) {
mJpSettings.adFreeVideoHosting = enabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class WPComSiteSettings extends SiteSettingsInterface {
// Jetpack modules
private static final String SERVE_IMAGES_FROM_OUR_SERVERS = "photon";
private static final String SERVE_STATIC_FILES_FROM_OUR_SERVERS = "photon-cdn";
private static final String LAZY_LOAD_IMAGES = "lazy-images";
private static final String SHARING_MODULE = "sharedaddy";

private static final String AD_FREE_VIDEO_HOSTING_MODULE = "videopress";
Expand Down Expand Up @@ -135,7 +134,6 @@ public void saveSettings() {
if (supportsJetpackSiteAcceleratorSettings(mSite)) {
pushServeImagesFromOurServersModuleSettings();
pushServeStaticFilesFromOurServersModuleSettings();
pushLazyLoadModule();
}
pushImprovedSearchModule();
pushAdFreeVideoHostingModule();
Expand Down Expand Up @@ -347,9 +345,6 @@ public void onResponse(JSONObject response) {
case SERVE_STATIC_FILES_FROM_OUR_SERVERS:
mRemoteJpSettings.serveStaticFilesFromOurServers = isActive;
break;
case LAZY_LOAD_IMAGES:
mRemoteJpSettings.lazyLoadImages = isActive;
break;
case SHARING_MODULE:
mRemoteJpSettings.sharingEnabled = isActive;
break;
Expand All @@ -364,7 +359,6 @@ public void onResponse(JSONObject response) {
mJpSettings.serveImagesFromOurServers = mRemoteJpSettings.serveImagesFromOurServers;
mJpSettings.serveStaticFilesFromOurServers =
mRemoteJpSettings.serveStaticFilesFromOurServers;
mJpSettings.lazyLoadImages = mRemoteJpSettings.lazyLoadImages;
mJpSettings.sharingEnabled = mRemoteJpSettings.sharingEnabled;
mJpSettings.improvedSearch = mRemoteJpSettings.improvedSearch;
mJpSettings.adFreeVideoHosting = mRemoteJpSettings.adFreeVideoHosting;
Expand Down Expand Up @@ -540,31 +534,6 @@ public void onErrorResponse(VolleyError error) {
}
}

private void pushLazyLoadModule() {
++mSaveRequestCount;
// The API returns 400 if we try to sync the same value twice so we need to keep it locally.
if (mJpSettings.lazyLoadImages != mRemoteJpSettings.lazyLoadImages) {
final boolean fallbackValue = mRemoteJpSettings.lazyLoadImages;
mRemoteJpSettings.lazyLoadImages = mJpSettings.lazyLoadImages;
WordPress.getRestClientUtilsV1_1().setJetpackModuleSettings(
mSite.getSiteId(), LAZY_LOAD_IMAGES, mJpSettings.lazyLoadImages, new RestRequest.Listener() {
@Override
public void onResponse(JSONObject response) {
AppLog.d(AppLog.T.API, "Jetpack module updated - Lazy load images");
onSaveResponseReceived(null);
}
}, new RestRequest.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mRemoteJpSettings.lazyLoadImages = fallbackValue;
error.printStackTrace();
AppLog.w(AppLog.T.API, "Error updating Jetpack module - Lazy load images: " + error);
onSaveResponseReceived(error);
}
});
}
}

private void pushImprovedSearchModule() {
++mSaveRequestCount;
// The API returns 400 if we try to sync the same value twice so we need to keep it locally.
Expand Down Expand Up @@ -700,7 +669,7 @@ private void deserializeWpComRestResponse(SiteModel site, JSONObject response) {
String remoteGmtOffset = settingsObject.optString(GMT_OFFSET_KEY, "");
// UTC-7 comes back as gmt_offset: -7, UTC+7 as just gmt_offset: 7 without the +, hence adding prefix
String remoteGmtTimezone = remoteGmtOffset.startsWith("-") ? "UTC" + remoteGmtOffset : "UTC+" + remoteGmtOffset;

mRemoteSettings.timezone = !TextUtils.isEmpty(remoteTimezone) ? remoteTimezone : remoteGmtTimezone;

mRemoteSettings.postsPerPage = settingsObject.optInt(POSTS_PER_PAGE_KEY, 0);
Expand Down
3 changes: 0 additions & 3 deletions WordPress/src/main/res/values/key_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
<!-- Front page settings -->
<string name="pref_key_homepage" translatable="false">wp_pref_key_homepage</string>
<string name="pref_key_homepage_settings" translatable="false">wp_pref_key_homepage_settings</string>
<!-- Speed up your site -->
<string name="pref_key_lazy_load_images" translatable="false">wp_pref_lazy_load_images</string>
<string name="pref_key_lazy_load_images_nested" translatable="false">wp_pref_lazy_load_images_nested</string>
<!-- Jetpack performance settings -->
<string name="pref_key_jetpack_performance_settings" translatable="false">wp_pref_jetpack_performance_settings</string>
<string name="pref_key_site_accelerator" translatable="false">wp_pref_site_accelerator</string>
Expand Down
4 changes: 0 additions & 4 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,10 @@
<string name="file_size_in_gigabytes">%s GB</string>
<string name="file_size_in_terabytes">%s TB</string>

<!-- Speed up your site -->
<string name="site_settings_lazy_load_images_summary">Improve your site\'s speed by only loading images visible on the screen.</string>

<!-- Site accelerator -->
<string name="site_settings_site_accelerator">Site Accelerator</string>
<string name="site_settings_site_accelerator_on">On</string>
<string name="site_settings_site_accelerator_off">Off</string>
<string name="site_settings_lazy_load_images">Lazy load images</string>
<string name="site_settings_faster_images">Faster images</string>
<string name="site_settings_faster_static_files">Faster static files</string>
<string name="site_settings_site_accelerator_summary">Load pages faster by allowing Jetpack to optimize your images and static files (like CSS and JavaScript).</string>
Expand Down
11 changes: 0 additions & 11 deletions WordPress/src/main/res/xml/site_settings.xml
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,6 @@

</PreferenceScreen>

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_lazy_load_images"
android:key="@string/pref_key_lazy_load_images"
android:summary="@string/site_settings_lazy_load_images_summary"
android:title="@string/site_settings_lazy_load_images" />

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_ad_free_video_hosting"
android:key="@string/pref_key_ad_free_video_hosting"
Expand Down Expand Up @@ -306,11 +300,6 @@

</PreferenceScreen>

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_lazy_load_images_nested"
android:key="@string/pref_key_lazy_load_images_nested"
android:summary="@string/site_settings_lazy_load_images_summary"
android:title="@string/site_settings_lazy_load_images" />
</PreferenceCategory>

<PreferenceCategory
Expand Down
Loading