From a096b5c695581aff55fe8fc42bd9608604310208 Mon Sep 17 00:00:00 2001 From: Sriram Krishnan Date: Fri, 21 Dec 2012 03:18:10 -0800 Subject: [PATCH 1/2] Bug 820288 - [Captive Portal] Need the notification to disappear --- apps/system/js/captive_portal.js | 44 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/apps/system/js/captive_portal.js b/apps/system/js/captive_portal.js index ecbaab410b14..277312777640 100644 --- a/apps/system/js/captive_portal.js +++ b/apps/system/js/captive_portal.js @@ -2,42 +2,51 @@ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ 'use strict'; -var CaptivePortalLogin = (function (){ +var CaptivePortalLogin = (function() { var eventId; var isManualConnect = false; var settings = window.navigator.mozSettings; - var mozNotification = window.navigator.mozNotification; var notification = null; var wifiManager = window.navigator.mozWifiManager; - var _ = window.navigator.mozL10n.get; + var _ = window.navigator.mozL10n.get; + var captiveNotification_onTap = null; function handleLogin(id, url) { //captive portal login needed eventId = id; - var currentNetwork = wifiManager.connection.network; - var networkName = (currentNetwork && currentNetwork.ssid) ? currentNetwork.ssid : ''; + var currentNetwork = wifiManager.connection.network; + var networkName = (currentNetwork && currentNetwork.ssid) ? + currentNetwork.ssid : ''; var message = _('captive-wifi-available', { networkName: networkName}); - if(!isManualConnect) { - notification = mozNotification.createNotification(null,message); - notification.show(); - notification.onclick = function () { + if (!isManualConnect) { + notification = NotificationScreen.addNotification({ + id: id, title: '', text: message, icon: null + }); + captiveNotification_onTap = function() { new MozActivity({ - name: "view", - data: { type: "url", url: url} + name: 'view', + data: { type: 'url', url: url} }); }; + notification.addEventListener('tap', captiveNotification_onTap); } else { settings.createLock().set({'wifi.connect_via_settings': false}); new MozActivity({ - name: "view", - data: { type: "url", url: url} + name: 'view', + data: { type: 'url', url: url} }); } } function handleLoginAbort(id) { - if (id === eventId) { - //TODO Close notification bug-820288 + if (id === eventId && notification) { + if (notification.parentNode) { + if (typeof(captiveNotification_onTap) == 'function') { + notification.removeEventListener('tap', captiveNotification_onTap); + } + NotificationScreen.removeNotification(id); + notification = null; + } } } @@ -52,8 +61,9 @@ var CaptivePortalLogin = (function (){ } }); - // Using settings API to know whether user is manually selecting wifi AP from settings app. - SettingsListener.observe('wifi.connect_via_settings', true, function (value) { + // Using settings API to know whether user is manually selecting + // wifi AP from settings app. + SettingsListener.observe('wifi.connect_via_settings', true, function(value) { isManualConnect = value; }); })(); From 36ab2e0bf4162b3d0b384e9f418c3d51dcf5ec15 Mon Sep 17 00:00:00 2001 From: Sriram Krishnan Date: Fri, 21 Dec 2012 08:32:50 -0800 Subject: [PATCH 2/2] Bug 820288 - [Captive Portal] Need the notification to disappear - fix typo --- apps/system/locales/system.en-US.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/system/locales/system.en-US.properties b/apps/system/locales/system.en-US.properties index 8abae2f8e9a9..2da971aba312 100644 --- a/apps/system/locales/system.en-US.properties +++ b/apps/system/locales/system.en-US.properties @@ -240,4 +240,4 @@ confirmNewSimPinMsg=Confirm new PIN newPinErrorMsg=PINs don’t match. #captive wifi -captive-wifi-available=The network {{neworkName}} was found. Join network? +captive-wifi-available=The network {{networkName}} was found. Join network?