Permalink
Browse files

Merge pull request #7132 from sriramkrish85/hide_captive_notification

Bug 820288 - [Captive Portal] Need the notification to disappear after b...
  • Loading branch information...
2 parents a86ee42 + 36ab2e0 commit c04da148f673ab6912c256a39f4a490844941895 @camelburrito camelburrito committed Jan 15, 2013
Showing with 28 additions and 18 deletions.
  1. +27 −17 apps/system/js/captive_portal.js
  2. +1 −1 apps/system/locales/system.en-US.properties
@@ -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;
});
})();
@@ -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?

0 comments on commit c04da14

Please sign in to comment.