Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7132 from sriramkrish85/hide_captive_notification
Browse files Browse the repository at this point in the history
Bug 820288 - [Captive Portal] Need the notification to disappear after b...
  • Loading branch information
camelburrito committed Jan 15, 2013
2 parents a86ee42 + 36ab2e0 commit c04da14
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
44 changes: 27 additions & 17 deletions apps/system/js/captive_portal.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,42 +2,51 @@
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict'; 'use strict';


var CaptivePortalLogin = (function (){ var CaptivePortalLogin = (function() {
var eventId; var eventId;
var isManualConnect = false; var isManualConnect = false;
var settings = window.navigator.mozSettings; var settings = window.navigator.mozSettings;
var mozNotification = window.navigator.mozNotification;
var notification = null; var notification = null;
var wifiManager = window.navigator.mozWifiManager; var wifiManager = window.navigator.mozWifiManager;
var _ = window.navigator.mozL10n.get; var _ = window.navigator.mozL10n.get;
var captiveNotification_onTap = null;


function handleLogin(id, url) { function handleLogin(id, url) {
//captive portal login needed //captive portal login needed
eventId = id; eventId = id;
var currentNetwork = wifiManager.connection.network; var currentNetwork = wifiManager.connection.network;
var networkName = (currentNetwork && currentNetwork.ssid) ? currentNetwork.ssid : ''; var networkName = (currentNetwork && currentNetwork.ssid) ?
currentNetwork.ssid : '';
var message = _('captive-wifi-available', { networkName: networkName}); var message = _('captive-wifi-available', { networkName: networkName});
if(!isManualConnect) { if (!isManualConnect) {
notification = mozNotification.createNotification(null,message); notification = NotificationScreen.addNotification({
notification.show(); id: id, title: '', text: message, icon: null
notification.onclick = function () { });
captiveNotification_onTap = function() {
new MozActivity({ new MozActivity({
name: "view", name: 'view',
data: { type: "url", url: url} data: { type: 'url', url: url}
}); });
}; };
notification.addEventListener('tap', captiveNotification_onTap);
} else { } else {
settings.createLock().set({'wifi.connect_via_settings': false}); settings.createLock().set({'wifi.connect_via_settings': false});
new MozActivity({ new MozActivity({
name: "view", name: 'view',
data: { type: "url", url: url} data: { type: 'url', url: url}
}); });
} }
} }


function handleLoginAbort(id) { function handleLoginAbort(id) {
if (id === eventId) { if (id === eventId && notification) {
//TODO Close notification bug-820288 if (notification.parentNode) {
if (typeof(captiveNotification_onTap) == 'function') {
notification.removeEventListener('tap', captiveNotification_onTap);
}
NotificationScreen.removeNotification(id);
notification = null;
}
} }
} }


Expand All @@ -52,8 +61,9 @@ var CaptivePortalLogin = (function (){
} }
}); });


// Using settings API to know whether user is manually selecting wifi AP from settings app. // Using settings API to know whether user is manually selecting
SettingsListener.observe('wifi.connect_via_settings', true, function (value) { // wifi AP from settings app.
SettingsListener.observe('wifi.connect_via_settings', true, function(value) {
isManualConnect = value; isManualConnect = value;
}); });
})(); })();
2 changes: 1 addition & 1 deletion apps/system/locales/system.en-US.properties
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -240,4 +240,4 @@ confirmNewSimPinMsg=Confirm new PIN
newPinErrorMsg=PINs don’t match. newPinErrorMsg=PINs don’t match.


#captive wifi #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.