Bug 1159718 - Remove notification when 'quick open' is activated in Tab Queue (r=mcomella)
authorMartyn Haigh <martyn.haigh@gmail.com>
Tue, 05 May 2015 17:04:00 +0100
changeset 273757 3b908ec52d4e3d8a15ac384e6d0571939e12d5fa
parent 273756 ba9bb4a353b49c94071ce7bb7a9eedaf926cbf25
child 273758 604006b0845484f556149275e35aa489f2a3dbe5
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1159718
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1159718 - Remove notification when 'quick open' is activated in Tab Queue (r=mcomella)
mobile/android/base/tabqueue/TabQueueHelper.java
mobile/android/base/tabqueue/TabQueueService.java
--- a/mobile/android/base/tabqueue/TabQueueHelper.java
+++ b/mobile/android/base/tabqueue/TabQueueHelper.java
@@ -196,19 +196,17 @@ public class TabQueueHelper {
         // TODO: Use profile shared prefs when bug 1147925 gets fixed.
         final SharedPreferences prefs = GeckoSharedPrefs.forApp(context);
         return prefs.getInt(PREF_TAB_QUEUE_COUNT, 0);
     }
 
     public static void openQueuedUrls(final Context context, final GeckoProfile profile, final String filename, boolean shouldPerformJavaScriptCallback) {
         ThreadUtils.assertNotOnUiThread();
 
-        // Remove the notification.
-        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
-        notificationManager.cancel(TAB_QUEUE_NOTIFICATION_ID);
+        removeNotification(context);
 
         // exit early if we don't have any tabs queued
         if (getTabQueueLength(context) < 1) {
             return;
         }
 
         JSONArray jsonArray = profile.readJSONArrayFromFile(filename);
 
@@ -230,16 +228,21 @@ public class TabQueueHelper {
             Log.e(LOGTAG, "Error deleting Tab Queue data file.", e);
         }
 
         // TODO: Use profile shared prefs when bug 1147925 gets fixed.
         final SharedPreferences prefs = GeckoSharedPrefs.forApp(context);
         prefs.edit().remove(PREF_TAB_QUEUE_COUNT).apply();
     }
 
+    protected static void removeNotification(Context context) {
+        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+        notificationManager.cancel(TAB_QUEUE_NOTIFICATION_ID);
+    }
+
     public static void processTabQueuePromptResponse(int resultCode, Context context) {
         final SharedPreferences prefs = GeckoSharedPrefs.forApp(context);
         final SharedPreferences.Editor editor = prefs.edit();
 
         switch (resultCode) {
             case TAB_QUEUE_YES:
                 editor.putBoolean(GeckoPreferences.PREFS_TAB_QUEUE, true);
 
--- a/mobile/android/base/tabqueue/TabQueueService.java
+++ b/mobile/android/base/tabqueue/TabQueueService.java
@@ -189,16 +189,18 @@ public class TabQueueService extends Ser
     }
 
     private void openNow(Intent intent) {
         Intent forwardIntent = new Intent(intent);
         forwardIntent.setClassName(getApplicationContext(), AppConstants.BROWSER_INTENT_CLASS_NAME);
         forwardIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(forwardIntent);
 
+        TabQueueHelper.removeNotification(getApplicationContext());
+
         GeckoSharedPrefs.forApp(getApplicationContext()).edit().remove(GeckoPreferences.PREFS_TAB_QUEUE_LAST_SITE)
                                                                .remove(GeckoPreferences.PREFS_TAB_QUEUE_LAST_TIME)
                                                                .apply();
     }
 
     private void removeView() {
         windowManager.removeView(toastLayout);
     }