Bug 975469 - Remove sync promo banner from rotation after it has been tapped. r=bnicholson
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 07 Mar 2014 11:23:27 -0800
changeset 172504 b4fd23f69cefa422371f503892ad5b6c406f984c
parent 172503 b940770772d29df495f918081d50dbdedf005d30
child 172597 2b52871312f49abf468ecc31c896643d513cf8c1
child 172606 3bb690f96b9250e9470c9614b05d7d1c6353ebaf
push id5538
push usermleibovic@mozilla.com
push dateFri, 07 Mar 2014 19:23:39 +0000
treeherderfx-team@b4fd23f69cef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson
bugs975469
milestone30.0a1
Bug 975469 - Remove sync promo banner from rotation after it has been tapped. r=bnicholson
mobile/android/base/home/HomeBanner.java
mobile/android/components/Snippets.js
--- a/mobile/android/base/home/HomeBanner.java
+++ b/mobile/android/base/home/HomeBanner.java
@@ -99,16 +99,20 @@ public class HomeBanner extends LinearLa
                     mOnDismissListener.onDismiss();
                 }
             }
         });
 
         setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                // Hide the banner. This does not remove the message from the rotation, so it may appear
+                // again if the JS onclick handler doesn't choose to remove it.
+                HomeBanner.this.setVisibility(View.GONE);
+
                 // Send the current message id back to JS.
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HomeBanner:Click", (String) getTag()));
             }
         });
 
         GeckoAppShell.getEventDispatcher().registerEventListener("HomeBanner:Data", this);
     }
 
--- a/mobile/android/components/Snippets.js
+++ b/mobile/android/components/Snippets.js
@@ -346,16 +346,18 @@ function loadSyncPromoBanner() {
       let stringBundle = Services.strings.createBundle("chrome://browser/locale/sync.properties");
       let text = stringBundle.GetStringFromName("promoBanner.message.text");
       let link = stringBundle.GetStringFromName("promoBanner.message.link");
 
       let id = Home.banner.add({
         text: text + "<a href=\"#\">" + link + "</a>",
         icon: "drawable://sync_promo",
         onclick: function() {
+          // Remove the message, so that it won't show again for the rest of the app lifetime.
+          Home.banner.remove(id);
           Accounts.launchSetup();
         },
         ondismiss: function() {
           // Remove the sync promo message from the banner and never try to show it again.
           Home.banner.remove(id);
           Services.prefs.setBoolPref("browser.snippets.syncPromo.enabled", false);
         }
       });