Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#7132 from sriramkrish85/hide_captive_n…
Browse files Browse the repository at this point in the history
…otification

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 Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand All @@ -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;
});
})();
2 changes: 1 addition & 1 deletion apps/system/locales/system.en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.