Bug 872556 - Add check for missing learnmoreURL in recommended-addons.json. r=mfinkle, a=lsblakk
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 20 May 2013 12:04:54 -0700
changeset 142752 37d012e97d79a6d62c2e8186e006b2818fb18b58
parent 142751 a334c5088d0d566955b680a9aedfa9e68b45cbab
child 142753 f4ee591fb02fbd178be815a0d702223d5783784b
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, lsblakk
bugs872556
milestone23.0a2
Bug 872556 - Add check for missing learnmoreURL in recommended-addons.json. r=mfinkle, a=lsblakk
mobile/android/base/widget/AddonsSection.java
--- a/mobile/android/base/widget/AddonsSection.java
+++ b/mobile/android/base/widget/AddonsSection.java
@@ -17,16 +17,17 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Rect;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.text.SpannableString;
+import android.text.TextUtils;
 import android.text.style.TextAppearanceSpan;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;
 
@@ -201,22 +202,26 @@ public class AddonsSection extends About
         drawable.setBounds(sIconBounds);
         row.setCompoundDrawables(drawable, null, null, null);
 
         String iconUrl = addonJSON.getString("iconURL");
         String pageUrl = getPageUrlFromIconUrl(iconUrl);
 
         // homepageURL may point to non-AMO installs. For now we use learnmoreURL instead
         // which is more likely to point to a mobile AMO page
-        final String homepageUrl = addonJSON.getString("learnmoreURL");
+        String homepageUrl = addonJSON.optString("learnmoreURL");
+        if (TextUtils.isEmpty(homepageUrl)) {
+            homepageUrl = addonJSON.getString("homepageURL");
+        }
+        final String addonUrl = homepageUrl;
         row.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 if (mUriLoadListener != null)
-                    mUriLoadListener.onAboutHomeUriLoad(homepageUrl);
+                    mUriLoadListener.onAboutHomeUriLoad(addonUrl);
             }
         });
         row.setOnKeyListener(GamepadUtils.getClickDispatcher());
 
         Favicons favicons = Favicons.getInstance();
         favicons.loadFavicon(pageUrl, iconUrl, true,
                 new Favicons.OnFaviconLoadedListener() {
             @Override