Bug 1390203: Only get highlight images on wifi. r=sebastian draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 22 Aug 2017 10:59:12 -0700
changeset 650871 186637c333da09e2619338d0ad3135418694d50d
parent 650870 4a42a080b37104fb49f1f1cfbec884edbab52ba2
child 727522 5f97242c75717b0cc4611380cfbf1870c4d211dd
push id75522
push usermichael.l.comella@gmail.com
push dateWed, 23 Aug 2017 00:30:00 +0000
reviewerssebastian
bugs1390203
milestone57.0a1
Bug 1390203: Only get highlight images on wifi. r=sebastian MozReview-Commit-ID: FtSDZ6Yu5Ql
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
@@ -14,16 +14,17 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import com.squareup.picasso.Picasso;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.icons.IconCallback;
 import org.mozilla.gecko.icons.IconResponse;
 import org.mozilla.gecko.icons.Icons;
+import org.mozilla.gecko.util.NetworkUtils;
 import org.mozilla.gecko.widget.FaviconView;
 
 import java.util.concurrent.Future;
 
 /**
  * A layout that represents page icons in Activity Stream, which can be overridden with a custom URL.
  *
  * Under the hood, it switches between multiple icon views because favicons (in FaviconView)
@@ -53,17 +54,20 @@ public class StreamOverridablePageIconLa
 
     /**
      * Updates the icon for the view. If a non-null overrideImageURL is provided, this image will be shown.
      * Otherwise, a favicon will be retrieved for the given pageURL.
      */
     public void updateIcon(@NonNull final String pageURL, @Nullable final String overrideImageURL) {
         cancelPendingRequests();
 
-        if (!TextUtils.isEmpty(overrideImageURL)) {
+        // We don't know how the large the non-favicon images could be (bug 1388415) so for now we're only going
+        // to download them on wifi. Alternatively, we could get these from the Gecko cache (see below).
+        if (NetworkUtils.isWifi(getContext()) &&
+                !TextUtils.isEmpty(overrideImageURL)) {
             setUIMode(UIMode.NONFAVICON_IMAGE);
 
             // TODO (bug 1322501): Optimization: since we've already navigated to these pages, there's a chance
             // Gecko has the image in its cache: we should try to get it first before making this network request.
             Picasso.with(getContext())
                     .load(Uri.parse(overrideImageURL))
                     .fit()
                     .centerCrop()