Skip to content
Browse files

Bug 803533 - [Settings] Need call forwarding settings UI r=kaze r=tim…

…dream
  • Loading branch information...
1 parent c815b2d commit 9cc083a6cd4a90823ec9fd7a07e7b0b008b7ff48 @jaoo jaoo committed with julienw Dec 4, 2012
View
153 apps/settings/index.html
@@ -336,6 +336,148 @@ <h2 data-l10n-id="advancedSettings"> Advanced Settings </h2>
-->
</section>
+ <!-- Connectivity :: Call :: Call Forwarding Not Reachable -->
+ <section role="region" hidden id="call-cf-notReachableSettings">
+ <!--
+ <header>
+ <a href="#call"><span class="icon icon-back">back</span></a>
+ <h1 data-l10n-id="callForwarding"> Call forwarding </h1>
+ </header>
+
+ <ul id="cf-notreachable-advanced">
+ <li>
+ <p data-l10n-id="cf-numberWhenUnreachable">Number when unreachable</p>
+ <input type="text" data-setting="ril.cf.notreachable.number" />
+ </li>
+ <li>
+ <label>
+ <input type="checkbox" data-type="switch" name="ril.cf.notreachable.enabled"/>
+ <span></span>
+ </label>
+ <a data-l10n-id="callForwardingNotReachable"> Forward when unreachable </a>
+ </li>
+ </ul>
+
+ -->
+ </section>
+
+ <!-- Connectivity :: Call :: Call Forwarding No Reply -->
+ <section role="region" hidden id="call-cf-noReplySettings">
+ <!--
+ <header>
+ <a href="#call"><span class="icon icon-back">back</span></a>
+ <h1 data-l10n-id="callForwarding"> Call forwarding </h1>
+ </header>
+
+ <ul id="cf-noreply-advanced">
+ <li>
+ <p data-l10n-id="cf-numberWhenUnanswered">Number when unanswered</p>
+ <input type="text" data-setting="ril.cf.noreply.number" />
+ </li>
+ <li>
+ <label>
+ <input type="checkbox" data-type="switch" name="ril.cf.noreply.enabled"/>
+ <span></span>
+ </label>
+ <a data-l10n-id="callForwardingNoReply"> Forward when unanswered </a>
+ </li>
+ </ul>
+
+ -->
+ </section>
+
+ <!-- Connectivity :: Call :: Call Forwarding Mobile Busy -->
+ <section role="region" hidden id="call-cf-mobileBusySettings">
+ <!--
+ <header>
+ <a href="#call"><span class="icon icon-back">back</span></a>
+ <h1 data-l10n-id="callForwarding"> Call forwarding </h1>
+ </header>
+
+ <ul id="cf-mobilebusy-advanced">
+ <li>
+ <p data-l10n-id="cf-numberWhenBusy">Number when busy</p>
+ <input type="text" data-setting="ril.cf.mobilebusy.number" />
+ </li>
+ <li>
+ <label>
+ <input type="checkbox" data-type="switch" name="ril.cf.mobilebusy.enabled"/>
+ <span></span>
+ </label>
+ <a data-l10n-id="callForwardingMobileBusy"> Forward when busy </a>
+ </li>
+ </ul>
+
+ -->
+ </section>
+
+ <!-- Connectivity :: Call :: Call Forwarding Unconditional -->
+ <section role="region" hidden id="call-cf-unconditionalSettings">
+ <!--
+ <header>
+ <a href="#call"><span class="icon icon-back">back</span></a>
+ <h1 data-l10n-id="callForwarding"> Call forwarding </h1>
+ </header>
+
+ <ul id="cf-unconditional-advanced">
+ <li>
+ <p data-l10n-id="cf-alwaysUseThisNumber">Always use this number</p>
+ <input type="text" data-setting="ril.cf.unconditional.number"/>
+ </li>
+ <li>
+ <label>
+ <input type="checkbox" data-type="switch" name="ril.cf.unconditional.enabled"/>
+ <span></span>
+ </label>
+ <a data-l10n-id="callForwardingUnconditional">Always forward</a>
+ </li>
+ </ul>
+
+ -->
+ </section>
+
+ <!-- Connectivity :: Call -->
+ <section role="region" hidden id="call">
+ <!--
+ <header>
+ <a href="#root"><span class="icon icon-back">back</span></a>
+ <h1 data-l10n-id="call"> Call Settings </h1>
+ </header>
+ <ul>
+ <li>
+ <label>
+ <input type="checkbox" data-type="switch" name="ril.callwaiting.enabled"/>
+ <span></span>
+ </label>
+ <a data-l10n-id="callWaiting">Call Waiting</a>
+ </li>
+ </ul>
+ <header>
+ <h2 data-l10n-id="callForwarding"> Call Forwarding </h2>
+ </header>
+ <ul>
+ <li>
+ <small id="cfu-desc"></small>
+ <a id="menuItem-callForwardingUnconditional" href="#call-cf-unconditionalSettings" data-l10n-id="callForwardingUnconditional">Always forward</a>
+ </li>
+ <li>
+ <small id="cfmb-desc"></small>
+ <a id="menuItem-callForwardingMobileBusy" href="#call-cf-mobileBusySettings" data-l10n-id="callForwardingMobileBusy">Forward when busy</a>
+ </li>
+ <li>
+ <small id="cfnrep-desc"></small>
+ <a id="menuItem-callForwardingNoReply" href="#call-cf-noReplySettings" data-l10n-id="callForwardingNoReply">Forward when unanswered</a>
+ </li>
+ <li>
+ <small id="cfnrea-desc"></small>
+ <a id="menuItem-callForwardingNotReachable" href="#call-cf-notReachableSettings" data-l10n-id="callForwardingNotReachable">Forward when unreachable</a>
+ </li>
+ </ul>
+
+ <script type="application/javascript" src="js/call.js"></script>
+ -->
+ </section>
+
<!-- Connectivity :: Cellular & Data :: Network Operator -->
<section role="region" hidden id="carrier-operatorSettings">
<!--
@@ -555,13 +697,6 @@ <h1 data-l10n-id="cellularAndData"> Cellular &amp; Data </h1>
<small id="dataNetwork-desc"></small>
<a data-l10n-id="dataNetwork">Carrier</a>
</li>
- <li>
- <label>
- <input type="checkbox" data-type="switch" name="ril.callwaiting.enabled"/>
- <span></span>
- </label>
- <a data-l10n-id="callWaiting">Call Waiting</a>
- </li>
</ul>
<header>
@@ -2202,6 +2337,10 @@ <h2 data-l10n-id="networkAndConnectivity">Network &amp; Connectivity</h2>
<a id="menuItem-wifi" class="menu-item" href="#wifi" data-l10n-id="wifi">Wi-Fi</a>
</li>
<li>
+ <small id="call-desc" class="menu-item-desc"></small>
+ <a id="menuItem-call" class="menu-item" href="#call" data-l10n-id="call">Call</a>
+ </li>
+ <li>
<small id="data-desc" class="menu-item-desc"></small>
<a id="menuItem-cellularAndData" class="menu-item" href="#carrier" data-l10n-id="cellularAndData">Cellular &amp; Data</a>
</li>
View
171 apps/settings/js/call.js
@@ -0,0 +1,171 @@
+/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+
+'use strict';
+
+// Handle call settings.
+var Calls = (function(window, document, undefined) {
+ var _ = navigator.mozL10n.get;
+
+ // Must be in sync with nsIDOMMozMobileCFInfo interface.
+ var _cfReason = {
+ CALL_FORWARD_REASON_UNCONDITIONAL: 0,
+ CALL_FORWARD_REASON_MOBILE_BUSY: 1,
+ CALL_FORWARD_REASON_NO_REPLY: 2,
+ CALL_FORWARD_REASON_NOT_REACHABLE: 3
+ };
+ var _cfAction = {
+ CALL_FORWARD_ACTION_DISABLE: 0,
+ CALL_FORWARD_ACTION_ENABLE: 1,
+ CALL_FORWARD_ACTION_QUERY_STATUS: 2,
+ CALL_FORWARD_ACTION_REGISTRATION: 3,
+ CALL_FORWARD_ACTION_ERASURE: 4
+ };
+
+ var _voiceServiceClassMask = gMobileConnection.ICC_SERVICE_CLASS_VOICE;
+
+ // Display rule info.
+ function displayRule(rules, elementId, settingKey) {
+ var textInput = document.querySelector('input[data-setting="ril.cf.' + settingKey + '.number"]');
+ var switchInput = document.querySelector('input[name="ril.cf.' + settingKey + '.enabled"]');
+
+ for (var i = 0; i < rules.length; i++) {
+ if (rules[i].active &&
+ ((_voiceServiceClassMask & rules[i].serviceClass) != 0)) {
+ document.getElementById(elementId).textContent =
+ _('callForwardingForwardingVoiceTo') + ' ' + rules[i].number;
+ textInput.value = rules[i].number;
+ switchInput.checked = true;
+ return;
+ }
+ }
+
+ document.getElementById(elementId).textContent =
+ _('callForwardingNotForwarding');
+ textInput.value = '';
+ switchInput.checked = false;
+ };
+
+ // Display what's happening while getting call forwarding info.
+ function displayInfoForAll(what) {
+ document.getElementById('cfu-desc').textContent =
+ document.getElementById('cfmb-desc').textContent =
+ document.getElementById('cfnrep-desc').textContent =
+ document.getElementById('cfnrea-desc').textContent =
+ what;
+ };
+
+ // Get current call forwarding rules.
+ function getCallForwardingOption() {
+ displayInfoForAll(_('callForwardingGetting'));
+
+ // Queries rules for unconditional call forwarding.
+ var unconditional = gMobileConnection.getCallForwardingOption(
+ _cfReason.CALL_FORWARD_REASON_UNCONDITIONAL);
+
+ unconditional.onsuccess = function() {
+ var unconditionalRules = unconditional.result;
+ displayRule(unconditionalRules, 'cfu-desc', 'unconditional');
+
+ // Queries rules for call forwarding when device busy.
+ var mobileBusy = gMobileConnection.getCallForwardingOption(
+ _cfReason.CALL_FORWARD_REASON_MOBILE_BUSY);
+
+ mobileBusy.onsuccess = function() {
+ var mobileBusyRules = mobileBusy.result;
+ displayRule(mobileBusyRules, 'cfmb-desc', 'mobilebusy');
+
+ // Queries rules for call forwarding when device does not reply.
+ var noReply = gMobileConnection.getCallForwardingOption(
+ _cfReason.CALL_FORWARD_REASON_NO_REPLY);
+
+ noReply.onsuccess = function() {
+ var noReplyRules = noReply.result;
+ displayRule(noReplyRules, 'cfnrep-desc', 'noreply');
+
+ // Queries rules for call forwarding when device is not reachable.
+ var notReachable = gMobileConnection.getCallForwardingOption(
+ _cfReason.CALL_FORWARD_REASON_NOT_REACHABLE);
+
+ notReachable.onsuccess = function() {
+ var notReachableRules = notReachable.result;
+ displayRule(notReachableRules, 'cfnrea-desc', 'notreachable');
+ };
+ notReachable.onerror = function () {
+ displayInfoForAll(_('callForwardingQueryError'));
+ };
+ };
+ noReply.onerror = function () {
+ displayInfoForAll(_('callForwardingQueryError'));
+ };
+ };
+ mobileBusy.onerror = function () {
+ displayInfoForAll(_('callForwardingQueryError'));
+ };
+ };
+ unconditional.onerror = function () {
+ displayInfoForAll(_('callForwardingQueryError'));
+ };
+ };
+
+ // Public API.
+ return {
+ // Startup.
+ init: function calls_init() {
+ var settings = window.navigator.mozSettings;
+ if (!settings) {
+ // TODO: Update UI with some error info.
+ return;
+ }
+ getCallForwardingOption();
+ var settingKeys = ['unconditional',
+ 'mobilebusy',
+ 'noreply',
+ 'notreachable'];
+ settingKeys.forEach(function(key) {
+ settings.addObserver('ril.cf.' + key + '.enabled', function(event) {
+ var textInput = document.querySelector('input[data-setting="ril.cf.' + key + '.number"]');
+ var mozMobileCFInfo = {};
+
+ mozMobileCFInfo['action'] = event.settingValue ?
+ _cfAction.CALL_FORWARD_ACTION_REGISTRATION :
+ _cfAction.CALL_FORWARD_ACTION_DISABLE;
+ switch (key) {
+ case 'unconditional':
+ mozMobileCFInfo['reason'] = _cfReason.CALL_FORWARD_REASON_UNCONDITIONAL;
+ break;
+ case 'mobilebusy':
+ mozMobileCFInfo['reason'] = _cfReason.CALL_FORWARD_REASON_MOBILE_BUSY;
+ break;
+ case 'noreply':
+ mozMobileCFInfo['reason'] = _cfReason.CALL_FORWARD_REASON_NO_REPLY;
+ break;
+ case 'notreachable':
+ mozMobileCFInfo['reason'] = _cfReason.CALL_FORWARD_REASON_NOT_REACHABLE;
+ break;
+ }
+ mozMobileCFInfo['serviceClass'] = gMobileConnection.ICC_SERVICE_CLASS_VOICE;
+ // TODO: Check number.
+ mozMobileCFInfo['number'] = textInput.value;
+ mozMobileCFInfo['timeSecond'] =
+ mozMobileCFInfo['reason'] != _cfReason.CALL_FORWARD_REASON_NO_REPLY ?
+ 0 : 20;
+ console.log(JSON.stringify(mozMobileCFInfo));
+
+ var req = gMobileConnection.setCallForwardingOption(mozMobileCFInfo);
+ req.onsuccess = function() {
+ console.log("Success");
+ getCallForwardingOption();
+ };
+ req.onerror = function() {
+ console.log("Error");
+ getCallForwardingOption();
+ };
+ });
+ });
+ }
+ };
+})(this, document);
+
+// Startup.
+onLocalized(Calls.init.bind(Calls));
View
1 apps/settings/js/connectivity.js
@@ -244,6 +244,7 @@ var Connectivity = (function(window, document, undefined) {
var data = gMobileConnection.data ? gMobileConnection.data.network : null;
var name = data ? (data.shortName || data.longName) : '';
document.getElementById('data-desc').textContent = name;
+ document.getElementById('call-desc').textContent = name;
}
function updateBluetooth() {
View
19 apps/settings/locales/settings.en-US.properties
@@ -86,10 +86,27 @@ wpsPinInput=Input {{pin}} to opposite device
wpsCancelMessage=Cancel WPS
wpsCancelFailedMessage=Failed to cancel WPS
+# Connectivity :: Call
+call=Call
+callWaiting=Call waiting
+callForwarding=Call forwarding
+callForwardingUnconditional=Always forward
+callForwardingMobileBusy=Forward when busy
+callForwardingNoReply=Forward when unanswered
+callForwardingNotReachable=Forward when unreachable
+callForwardingGetting=Getting network info...
+callForwardingQueryError=Error in query
+callForwardingForwardingVoiceTo=Voice calls to
+callForwardingNotForwarding=Disabled
+
+cf-alwaysUseThisNumber=Always use this number
+cf-numberWhenUnreachable=Number when unreachable
+cf-numberWhenUnanswered=Number when unanswered
+cf-numberWhenBusy=Number when busy
+
# Connectivity :: Cellular & Data
cellularAndData=Cellular & Data
dataNetwork=Carrier
-callWaiting=Call waiting
dataConnectivity=Data
dataConnection=Data connection
dataRoaming=Data roaming
View
1 apps/system/index.html
@@ -281,6 +281,7 @@
<div id="statusbar-sms" class="sb-icon sb-icon-sms" hidden></div>
<div id="statusbar-geolocation" class="sb-icon sb-icon-geolocation" hidden></div>
<div id="statusbar-usb" class="sb-icon sb-icon-usb" hidden></div>
+ <div id="statusbar-call-forwarding" class="sb-icon sb-icon-call-forwarding" hidden></div>
</div>
<div id="utility-tray" data-z-index-level="utility-tray">
View
11 apps/system/js/statusbar.js
@@ -8,7 +8,8 @@ var StatusBar = {
ELEMENTS: ['notification', 'time',
'battery', 'wifi', 'data', 'flight-mode', 'signal', 'network-activity',
'tethering', 'alarm', 'bluetooth', 'mute', 'headphones',
- 'recording', 'sms', 'geolocation', 'usb', 'label', 'system-downloads'],
+ 'recording', 'sms', 'geolocation', 'usb', 'label', 'system-downloads',
+ 'call-forwarding'],
/* Timeout for 'recently active' indicators */
kActiveIndicatorTimeout: 60 * 1000,
@@ -77,7 +78,8 @@ var StatusBar = {
'tethering.wifi.connectedClients': ['tethering'],
'tethering.usb.connectedClients': ['tethering'],
'audio.volume.master': ['mute'],
- 'alarm.enabled': ['alarm']
+ 'alarm.enabled': ['alarm'],
+ 'ril.cf.unconditional.enabled': ['callForwarding']
};
var self = this;
@@ -510,6 +512,11 @@ var StatusBar = {
systemDownloads: function sb_updatesystemDownloads() {
var icon = this.icons.systemDownloads;
icon.hidden = (this.systemDownloadsCount === 0);
+ },
+
+ callForwarding: function sb_updateCallForwarding() {
+ var icon = this.icons.callForwarding;
+ icon.hidden = !this.settingValues['ril.cf.unconditional.enabled'];
}
},
View
BIN apps/system/style/statusbar/images/call-forwarding.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 apps/system/style/statusbar/statusbar.css
@@ -392,3 +392,9 @@ body, html {
background: url('images/system-downloads.gif') no-repeat;
background-position: 0 0;
}
+
+.sb-icon-call-forwarding {
+ /* Waiting for the correct icon. In the mean time We use this one. */
+ background: url('images/call-forwarding.png') no-repeat;
+ background-position: 0 0;
+}

0 comments on commit 9cc083a

Please sign in to comment.
Something went wrong with that request. Please try again.