Bug 787188 - Allow for no promo to be shown r=wesj
authorMark Finkle <mfinkle@mozilla.com>
Wed, 26 Sep 2012 08:24:27 -0400
changeset 108241 bb07e91c012dcb85d4ec2979ea23832e0cce7268
parent 108240 3688310dce700703f60668e9a98c33c2f87d1a72
child 108242 c6dab1c5387cd4867720cd06b5397b7855e6d118
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerswesj
bugs787188
milestone18.0a1
Bug 787188 - Allow for no promo to be shown r=wesj
mobile/android/base/AboutHomeContent.java
mobile/android/base/AboutHomePromoBox.java
--- a/mobile/android/base/AboutHomeContent.java
+++ b/mobile/android/base/AboutHomeContent.java
@@ -209,31 +209,24 @@ public class AboutHomeContent extends Sc
     private void setTopSitesVisibility(boolean hasTopSites) {
         int visibility = hasTopSites ? View.VISIBLE : View.GONE;
 
         findViewById(R.id.top_sites_title).setVisibility(visibility);
         findViewById(R.id.top_sites_grid).setVisibility(visibility);
         findViewById(R.id.all_top_sites_text).setVisibility(visibility);
     }
 
-    private void setPromoBoxVisibility(boolean visible, AboutHomePromoBox.Type type) {
-        if (visible)
-            mPromoBox.show(type);
-        else
-            mPromoBox.hide();
-    }
-
     private void updateLayout(boolean syncIsSetup) {
         boolean hasTopSites = mTopSitesAdapter.getCount() > 0;
+        setTopSitesVisibility(hasTopSites);
 
-        setTopSitesVisibility(hasTopSites);
-        if (!syncIsSetup && mPrelimPromoBoxType == AboutHomePromoBox.Type.SYNC)
-            setPromoBoxVisibility(true, AboutHomePromoBox.Type.SYNC);
-        else
-            setPromoBoxVisibility(true, AboutHomePromoBox.Type.APPS);
+        AboutHomePromoBox.Type type = mPrelimPromoBoxType;
+        if (syncIsSetup && type == AboutHomePromoBox.Type.SYNC)
+            type = AboutHomePromoBox.Type.APPS;
+        mPromoBox.show(type);
     }
 
     private void updateLayoutForSync() {
         final GeckoApp.StartupMode startupMode = mActivity.getStartupMode();
         final boolean syncIsSetup = SyncAccounts.syncAccountsExist(mContext);
 
         post(new Runnable() {
             public void run() {
--- a/mobile/android/base/AboutHomePromoBox.java
+++ b/mobile/android/base/AboutHomePromoBox.java
@@ -25,17 +25,17 @@ import android.widget.TextView;
  * A promotional box for the about:home page. The layout contains an ImageView to the left of a
  * TextView whose resources may be overidden to display custom values for a new type of promo box.
  * To do this, add a new Type value and update show() to call setResources() for your values -
  * including a set[Box Type]Resources() helper method is recommended.
  */
 public class AboutHomePromoBox extends LinearLayout implements View.OnClickListener {
     private static final String LOGTAG = "AboutHomePromoBox";
 
-    public enum Type { SYNC, APPS };
+    public enum Type { NONE, SYNC, APPS };
 
     private Type mType;
 
     private final Context mContext;
     private final TextView mTextView;
     private final ImageView mImageView;
 
     // Use setResources() to set these variables for each PromoBox type.
@@ -96,17 +96,18 @@ public class AboutHomePromoBox extends L
                 break;
 
             case APPS:
                 setAppsResources();
                 break;
 
             default:
                 Log.e(LOGTAG, "show() - Invalid AboutHomePromoBox.Type specified.");
-                break;
+                hide();
+                return;
         }
         updateViewResources();
         setVisibility(View.VISIBLE);
     }
 
     public void hide() {
         setVisibility(View.GONE);
         mType = null;