From 66dae0ccbc23f4df612711a2e61fadd9b15feb91 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Wed, 06 Feb 2013 16:36:20 +0000 Subject: Empty the system plugin --- diff --git a/Makefile b/Makefile index acb2d98..451ffdc 100644 --- a/Makefile +++ b/Makefile @@ -477,5 +477,8 @@ install-settings-defaults: profile/settings.json # clean out build products clean: + rm -rf profile install: + rm -rf $(SUGAR_HTML_PATH) && \ + cp -r profile $(SUGAR_HTML_PATH) diff --git a/apps/system/blank.html b/apps/system/blank.html deleted file mode 100644 index 946ffa7..0000000 --- a/apps/system/blank.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/apps/system/emergency-call/index.html b/apps/system/emergency-call/index.html deleted file mode 100644 index 534c05e..0000000 --- a/apps/system/emergency-call/index.html +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - Emergency Call Dialer - - - - - - - - - - - - -
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1 -
-
-
-
-
-
- 4 - GHI -
-
-
-
-
-
- 7 - PQRS -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- 2 - ABC -
-
-
-
-
-
- 5 - JKL -
-
-
-
-
-
- 8 - TUV -
-
-
-
-
-
- 0 - + -
-
-
-
-
-
-
-
- 3 - DEF -
-
-
-
-
-
- 6 - MNO -
-
-
-
-
-
- 9 - WXYZ -
-
-
-
-
-
- -
-
-
-
-
-
-
-
- -
Cancel
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Emergency call -
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
- - - -
-
-
-
- -
-
-
-
-
-
-
-
-
-
- - diff --git a/apps/system/emergency-call/js/dialer.js b/apps/system/emergency-call/js/dialer.js deleted file mode 100644 index ff93009..0000000 --- a/apps/system/emergency-call/js/dialer.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -var CallHandler = { - _call: null, - _telephony: window.navigator.mozTelephony, - - call: function ch_call(number) { - var sanitizedNumber = number.replace(/-/g, ''); - var telephony = this._telephony; - if (telephony) { - this._call = telephony.dialEmergency(sanitizedNumber); - var call = this._call; - if (call) { - var cb = function clearPhoneView() { - KeypadManager.updatePhoneNumber(''); - }; - call.onconnected = cb; - - call.ondisconnected = function callEnded() { - cb(); - CallScreen.hide(); - }; - - CallScreen.number = call.number; - CallScreen.show(); - } - } - }, - - end: function ch_end() { - if (!this._call) { - CallScreen.hide(); - return; - } - - this._call.hangUp(); - this._call = null; - }, - - toggleSpeaker: function ch_toggleSpeaker() { - this._telephony.speakerEnabled = !this._telephony.speakerEnabled; - } -}; - -var CallScreen = { - screen: document.getElementById('call-screen'), - numberView: document.getElementById('emergency-number'), - - hangUpButton: document.getElementById('callbar-hang-up'), - speakerButton: document.getElementById('speaker'), - - set number(value) { - this.numberView.textContent = value; - }, - - init: function cs_init() { - this.hangUpButton.addEventListener('mouseup', - CallHandler.end.bind(CallHandler)); - this.speakerButton.addEventListener('click', this.toggleSpeaker.bind(this)); - }, - - show: function cs_show() { - this.screen.classList.add('displayed'); - }, - - hide: function cs_hide() { - this.screen.classList.remove('displayed'); - }, - - toggleSpeaker: function cs_toggleSpeaker() { - this.speakerButton.classList.toggle('speak'); - CallHandler.toggleSpeaker(); - } -}; - -window.addEventListener('load', function onload() { - window.removeEventListener('load', onload); - KeypadManager.init(); - CallScreen.init(); -}); diff --git a/apps/system/emergency-call/js/keypad.js b/apps/system/emergency-call/js/keypad.js deleted file mode 100644 index 6163ecf..0000000 --- a/apps/system/emergency-call/js/keypad.js +++ /dev/null @@ -1,461 +0,0 @@ -/* - * The code is being shared between system/emergency-call/js/keypad.js - * and dialer/js/keypad.js. Be sure to update both file when you commit! - * - */ - -'use strict'; - -var kFontStep = 4; -var minFontSize = 12; - -// Frequencies comming from http://en.wikipedia.org/wiki/Telephone_keypad -var gTonesFrequencies = { - '1': [697, 1209], '2': [697, 1336], '3': [697, 1477], - '4': [770, 1209], '5': [770, 1336], '6': [770, 1477], - '7': [852, 1209], '8': [852, 1336], '9': [852, 1477], - '*': [941, 1209], '0': [941, 1336], '#': [941, 1477] -}; - -var keypadSoundIsEnabled = true; -SettingsListener.observe('phone.ring.keypad', true, function(value) { - keypadSoundIsEnabled = !!value; -}); - -var TonePlayer = { - _sampleRate: 4000, - - init: function tp_init() { - document.addEventListener('mozvisibilitychange', - this.visibilityChange.bind(this)); - this.ensureAudio(); - }, - - ensureAudio: function tp_ensureAudio() { - if (this._audio) - return; - - this._audio = new Audio(); - this._audio.volume = 0.5; - this._audio.mozSetup(2, this._sampleRate); - }, - - generateFrames: function tp_generateFrames(soundData, freqRow, freqCol) { - var currentSoundSample = 0; - var kr = 2 * Math.PI * freqRow / this._sampleRate; - var kc = 2 * Math.PI * freqCol / this._sampleRate; - for (var i = 0; i < soundData.length; i += 2) { - var smoother = 0.5 + (Math.sin((i * Math.PI) / soundData.length)) / 2; - - soundData[i] = Math.sin(kr * currentSoundSample) * smoother; - soundData[i + 1] = Math.sin(kc * currentSoundSample) * smoother; - - currentSoundSample++; - } - }, - - play: function tp_play(frequencies) { - var soundDataSize = this._sampleRate / 4; - var soundData = new Float32Array(soundDataSize); - this.generateFrames(soundData, frequencies[0], frequencies[1]); - this._audio.mozWriteAudio(soundData); - }, - - // If the app loses focus, close the audio stream. This works around an - // issue in Gecko where the Audio Data API causes gfx performance problems, - // in particular when scrolling the homescreen. - // See: https://bugzilla.mozilla.org/show_bug.cgi?id=779914 - visibilityChange: function tp_visibilityChange(e) { - if (!document.mozHidden) { - this.ensureAudio(); - } else { - // Reset the audio stream. This ensures that the stream is shutdown - // *immediately*. - this._audio.src = ''; - delete this._audio; - } - } - -}; - -var KeypadManager = { - _phoneNumber: '', - _onCall: false, - - get phoneNumberView() { - delete this.phoneNumberView; - return this.phoneNumberView = document.getElementById('phone-number-view'); - }, - - get fakePhoneNumberView() { - delete this.fakePhoneNumberView; - return this.fakePhoneNumberView = - document.getElementById('fake-phone-number-view'); - }, - - get phoneNumberViewContainer() { - delete this.phoneNumberViewContainer; - return this.phoneNumberViewContainer = - document.getElementById('phone-number-view-container'); - }, - - get keypad() { - delete this.keypad; - return this.keypad = document.getElementById('keypad'); - }, - - get callBar() { - delete this.callBar; - return this.callBar = - document.getElementById('keypad-callbar'); - }, - - get hideBar() { - delete this.hideBar; - return this.hideBar = document.getElementById('keypad-hidebar'); - }, - - get callBarAddContact() { - delete this.callBarAddContact; - return this.callBarAddContact = - document.getElementById('keypad-callbar-add-contact'); - }, - - get callBarCallAction() { - delete this.callBarCallAction; - return this.callBarCallAction = - document.getElementById('keypad-callbar-call-action'); - }, - - get callBarCancelAction() { - delete this.callBarCancelAction; - return this.callBarCancelAction = - document.getElementById('keypad-callbar-cancel'); - }, - - get deleteButton() { - delete this.deleteButton; - return this.deleteButton = document.getElementById('keypad-delete'); - }, - - get hideBarHangUpAction() { - delete this.hideBarHangUpAction; - return this.hideBarHangUpAction = - document.getElementById('keypad-hidebar-hang-up-action-wrapper'); - }, - - get hideBarHideAction() { - delete this.hideBarHideAction; - return this.hideBarHideAction = - document.getElementById('keypad-hidebar-hide-keypad-action'); - }, - - init: function kh_init() { - // Update the minimum phone number phone size. - // The UX team states that the minimum font size should be - // 10pt. First off, we convert it to px multiplying it 0.226 times, - // then we convert it to rem multiplying it a number of times equal - // to the font-size property of the body element. - var defaultFontSize = window.getComputedStyle(document.body, null) - .getPropertyValue('font-size'); - minFontSize = parseInt(parseInt(defaultFontSize) * 10 * 0.226); - - this.phoneNumberView.value = ''; - this._phoneNumber = ''; - - var keyHandler = this.keyHandler.bind(this); - this.keypad.addEventListener('mousedown', keyHandler, true); - this.keypad.addEventListener('mouseup', keyHandler, true); - this.deleteButton.addEventListener('mousedown', keyHandler); - this.deleteButton.addEventListener('mouseup', keyHandler); - - // The keypad add contact bar is only included in the normal version of - // the keypad. - if (this.callBarAddContact) { - this.callBarAddContact.addEventListener('mouseup', - this.addContact.bind(this)); - } - - // The keypad add contact bar is only included in the normal version and - // the emergency call version of the keypad. - if (this.callBarCallAction) { - this.callBarCallAction.addEventListener('mouseup', - this.makeCall.bind(this)); - } - - // The keypad cancel bar is only the emergency call version of the keypad. - if (this.callBarCancelAction) { - this.callBarCancelAction.addEventListener('mouseup', function() { - window.parent.LockScreen.switchPanel(); - }); - } - - // The keypad hide bar is only included in the on call version of the - // keypad. - if (this.hideBarHideAction) { - this.hideBarHideAction.addEventListener('mouseup', - this.callbarBackAction); - } - - if (this.hideBarHangUpAction) { - this.hideBarHangUpAction.addEventListener('mouseup', - this.hangUpCallFromKeypad); - } - - TonePlayer.init(); - - this.render(); - }, - - moveCaretToEnd: function hk_util_moveCaretToEnd(el) { - if (typeof el.selectionStart == 'number') { - el.selectionStart = el.selectionEnd = el.value.length; - } else if (typeof el.createTextRange != 'undefined') { - el.focus(); - var range = el.createTextRange(); - range.collapse(false); - range.select(); - } - }, - - render: function hk_render(layoutType) { - if (layoutType == 'oncall') { - this._onCall = true; - var numberNode = CallScreen.activeCall.querySelector('.number'); - this._phoneNumber = numberNode.textContent; - this.phoneNumberViewContainer.classList.add('keypad-visible'); - if (this.callBar) { - this.callBar.classList.add('hide'); - } - - if (this.hideBar) { - this.hideBar.classList.remove('hide'); - } - - this.deleteButton.classList.add('hide'); - } else { - this.phoneNumberViewContainer.classList.remove('keypad-visible'); - if (this.callBar) { - this.callBar.classList.remove('hide'); - } - - if (this.hideBar) { - this.hideBar.classList.add('hide'); - } - - this.deleteButton.classList.remove('hide'); - } - }, - - makeCall: function hk_makeCall(event) { - event.stopPropagation(); - - if (this._phoneNumber != '') { - CallHandler.call(KeypadManager._phoneNumber); - } - }, - - addContact: function hk_addContact(event) { - var number = this._phoneNumber; - if (!number) - return; - - try { - var activity = new MozActivity({ - name: 'new', - data: { - type: 'webcontacts/contact', - params: { - 'tel': number - } - } - }); - } catch (e) { - console.log('WebActivities unavailable? : ' + e); - } - }, - - callbarBackAction: function hk_callbarBackAction(event) { - CallScreen.hideKeypad(); - }, - - hangUpCallFromKeypad: function hk_hangUpCallFromKeypad(event) { - CallScreen.views.classList.remove('show'); - OnCallHandler.end(); - }, - - formatPhoneNumber: function kh_formatPhoneNumber(mode) { - switch (mode) { - case 'dialpad': - var fakeView = this.fakePhoneNumberView; - var view = this.phoneNumberView; - - // We consider the case where the delete button may have - // been used to delete the whole phone number. - if (view.value == '') { - view.style.fontSize = view.dataset.size; - return; - } - break; - - case 'on-call': - var fakeView = CallScreen.activeCall.querySelector('.fake-number'); - var view = CallScreen.activeCall.querySelector('.number'); - break; - } - - var computedStyle = window.getComputedStyle(view, null); - var currentFontSize = computedStyle.getPropertyValue('font-size'); - if (!('size' in view.dataset)) { - view.dataset.size = currentFontSize; - } - - var newFontSize = this.getNextFontSize(view, fakeView, - parseInt(view.dataset.size), - parseInt(currentFontSize)); - view.style.fontSize = newFontSize + 'px'; - this.addEllipsis(view, fakeView, newFontSize); - }, - - addEllipsis: function kh_addEllipsis(view, fakeView, currentFontSize) { - var viewWidth = view.getBoundingClientRect().width; - fakeView.style.fontSize = currentFontSize + 'px'; - fakeView.innerHTML = view.value; - - var counter = 1; - var value = view.value; - - var newPhoneNumber; - while (fakeView.getBoundingClientRect().width > viewWidth) { - newPhoneNumber = '\u2026' + value.substr(-value.length + counter); - fakeView.innerHTML = newPhoneNumber; - counter++; - } - - if (newPhoneNumber) { - view.value = newPhoneNumber; - } - }, - - getNextFontSize: function kh_getNextFontSize(view, fakeView, - fontSize, initialFontSize) { - var viewWidth = view.getBoundingClientRect().width; - fakeView.style.fontSize = fontSize + 'px'; - fakeView.innerHTML = view.value; - - var rect = fakeView.getBoundingClientRect(); - while ((rect.width > viewWidth) && (fontSize > minFontSize)) { - fontSize = Math.max(fontSize - kFontStep, minFontSize); - fakeView.style.fontSize = fontSize + 'px'; - rect = fakeView.getBoundingClientRect(); - } - - if ((rect.width < viewWidth) && (fontSize < initialFontSize)) { - fakeView.style.fontSize = (fontSize + kFontStep) + 'px'; - rect = fakeView.getBoundingClientRect(); - if (rect.width <= viewWidth) { - fontSize += kFontStep; - } - } - return fontSize; - }, - - keyHandler: function kh_keyHandler(event) { - var key = event.target.dataset.value; - - if (!key) - return; - - event.stopPropagation(); - if (event.type == 'mousedown') { - this._longPress = false; - - if (key != 'delete') { - if (keypadSoundIsEnabled) { - TonePlayer.play(gTonesFrequencies[key]); - } - - // Sending the DTMF tone if on a call - var telephony = navigator.mozTelephony; - if (telephony && telephony.active && - telephony.active.state == 'connected') { - - telephony.startTone(key); - window.setTimeout(function ch_stopTone() { - telephony.stopTone(); - }, 100); - - } - } - - // Manage long press - if (key == '0' || key == 'delete') { - this._holdTimer = setTimeout(function(self) { - if (key == 'delete') { - self._phoneNumber = ''; - } else { - self._phoneNumber += '+'; - } - - self._longPress = true; - self._updatePhoneNumberView(); - }, 400, this); - } - - // Voicemail long press (needs to be longer since it actually dials) - if (event.target.dataset.voicemail) { - this._holdTimer = setTimeout(function vm_call(self) { - self._longPress = true; - self._callVoicemail(); - }, 3000, this); - } - } else if (event.type == 'mouseup') { - // If it was a long press our work is already done - if (this._longPress) { - this._longPress = false; - this._holdTimer = null; - return; - } - if (key == 'delete') { - this._phoneNumber = this._phoneNumber.slice(0, -1); - } else { - this._phoneNumber += key; - } - - if (this._holdTimer) - clearTimeout(this._holdTimer); - - this._updatePhoneNumberView(); - } - }, - - updatePhoneNumber: function kh_updatePhoneNumber(number) { - this._phoneNumber = number; - this._updatePhoneNumberView(); - }, - - _updatePhoneNumberView: function kh_updatePhoneNumberview() { - var phoneNumber = this._phoneNumber; - - // If there are digits in the phone number, show the delete button. - var visibility = (phoneNumber.length > 0) ? 'visible' : 'hidden'; - this.deleteButton.style.visibility = visibility; - - if (this._onCall) { - var view = CallScreen.activeCall.querySelector('.number'); - view.textContent = phoneNumber; - this.formatPhoneNumber('on-call'); - } else { - this.phoneNumberView.value = phoneNumber; - this.moveCaretToEnd(this.phoneNumberView); - this.formatPhoneNumber('dialpad'); - } - }, - - _callVoicemail: function kh_callVoicemail() { - var voicemail = navigator.mozVoicemail; - if (voicemail && voicemail.number) { - CallHandler.call(voicemail.number); - } - } -}; diff --git a/apps/system/emergency-call/style/dialer.css b/apps/system/emergency-call/style/dialer.css deleted file mode 100644 index 7a3519a..0000000 --- a/apps/system/emergency-call/style/dialer.css +++ /dev/null @@ -1,250 +0,0 @@ -html, body { - width: 100%; - height: 100%; - overflow: hidden; - margin: 0; - color: white; - font-family: 'MozTT', sans-serif; - font-size: 10px; - background: black; -} - -a { - outline: 0; -} - -a:hover, a:active, a:focus { - outline: 0; -} - -html * { - overflow: hidden; -} - -.font-regular { - font-family: 'MozTT'; -} - -.font-semibold { - font-family: 'MozTT'; - font-weight: 600; -} - -.font-light { - font-family: 'MozTT'; -} - -.contact-primary-info { - font-size: -moz-calc(15*0.226rem); - color: black; -} - -.contact-secondary-info { - font-size: -moz-calc(6*0.226rem); - color: white; -} - -.grid-wrapper { - width: 100%; - height: 100%; -} - -.grid-v-align { - vertical-align: middle; -} - -.grid-row { - display: table-row; -} - -.grid-cell { - display: table-cell; -} - -.grid { - display: table; - table-layout: fixed; -} - -.center { - text-align: center; -} - -#views { - top: 0; - height: 100%; - width: 100%; -} - -#views > *[role=tabpanel] { - height: 100%; - width: 100%; -} - -body.hidden *[data-l10n-id] { - visibility: hidden; -} - -/* Call screen */ -#call-screen { - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 100%; - margin: 0; - border: 0; - border-radius: 10px; - background: black; - -moz-transform: translateY(-100%); - z-index: 100; - - -moz-transition: -moz-transform 0.5s ease; -} - -#call-screen.displayed { - -moz-transform: translateY(0); -} - -#main-container { - position: relative; - height: 100%; - background: transparent; -} - -#actions-container { - position: absolute; - bottom: 0; - width: 100%; - height: 15.5rem; -} - -#call-options { - height:9.5rem; -} - -#co-advanced { - opacity: 1.0; - height: 9.5rem; -} - -.co-advanced-option { - background: rgba(0,0,0,.8); - height: 9.5rem; - width: 100%; - border: 0; - border-top: 1px solid #3A3A3A; - border-bottom: 1px solid #3A3A3A; - border-right: 1px solid #3A3A3A; -} - -#co-advanced span.grid-cell:last-child .co-advanced-option { - border-right: 0px; -} - -#speaker span { - display:inline-block; - background-color: #DDD; - background:url('images/ActionIcon_40x40_bluetooth.png') ; - background-size: 4rem 4rem; - width:4rem; - height:4rem; - opacity: 1.0; -} - -#speaker.speak > span { - background:url('images/ActionIcon_40x40_bluetooth_active.png'); -} - -#callbar { - background:rgba(0,0,0,.8); - opacity: 1.0; -} - -#callbar-hang-up { - float: left; - height: 6.5rem; - width: 100%; -} - -.callbar-button { - height: 4rem; - border:0; - border-radius:.3rem; - display: block; -} - -#callbar-hang-up-action { - background: -moz-linear-gradient(top, #ff0000 1%, #ce0000 100%); - opacity: 1.0; - margin: 1rem .5rem 1.5rem 1.5rem; -} - -#callbar-hang-up.full-space > #callbar-hang-up-action { - margin: 1rem 1.5rem 1.5rem 1.5rem; -} - -#callbar-hang-up-action > div { - margin: 0 auto; - background-image: url('images/ActionIcon_40x40_hangup.png'); - background-repeat: no-repeat; - background-size: 4rem 4rem; - background-position: center; - width: 4rem; - height: 4rem; -} - -#calls { - position: absolute; - top: 0; - width: 100%; - height: 22rem; - - z-index: 500; -} - -#calls > section { - position: relative; - height: 9rem; - - font-size: 1.8em; - line-height: 7rem; - background-color: #01c5ed; - - transition: opacity 0.3s linear; - opacity: 1; -} - -#calls > section div { - padding-left: 2rem; - padding-right: 1.5rem; -} - -#calls > section .number { - height: 4rem; - padding: 2rem 2rem 0 2rem; - background: #01c5ed; - font-size: 1.6em; - line-height: 4rem; - color: black; -} - -#calls > section .additionalContactInfo { - height: 2rem; - padding: 0 2rem 2rem 2rem; - background: #01c5ed; - font-size: 1.4rem; - line-height: 2rem; - color: white; -} - -#calls > section .duration { - position: absolute; - top: 12rem; - left: 0; - height: 8rem; - padding: 2rem; - font-size: 2.6em; - font-weight: 300; - line-height: 8rem; -} diff --git a/apps/system/emergency-call/style/images/ActionIcon_40x40_bluetooth.png b/apps/system/emergency-call/style/images/ActionIcon_40x40_bluetooth.png deleted file mode 100644 index a946ff2..0000000 --- a/apps/system/emergency-call/style/images/ActionIcon_40x40_bluetooth.png +++ /dev/null Binary files differ diff --git a/apps/system/emergency-call/style/images/ActionIcon_40x40_bluetooth_active.png b/apps/system/emergency-call/style/images/ActionIcon_40x40_bluetooth_active.png deleted file mode 100644 index 86abf23..0000000 --- a/apps/system/emergency-call/style/images/ActionIcon_40x40_bluetooth_active.png +++ /dev/null Binary files differ diff --git a/apps/system/emergency-call/style/images/ActionIcon_40x40_hangup.png b/apps/system/emergency-call/style/images/ActionIcon_40x40_hangup.png deleted file mode 100644 index f955956..0000000 --- a/apps/system/emergency-call/style/images/ActionIcon_40x40_hangup.png +++ /dev/null Binary files differ diff --git a/apps/system/emergency-call/style/images/ActionIcon_40x40_pickup.png b/apps/system/emergency-call/style/images/ActionIcon_40x40_pickup.png deleted file mode 100644 index ad8423e..0000000 --- a/apps/system/emergency-call/style/images/ActionIcon_40x40_pickup.png +++ /dev/null Binary files differ diff --git a/apps/system/emergency-call/style/images/asterisk.png b/apps/system/emergency-call/style/images/asterisk.png deleted file mode 100644 index 4199485..0000000 --- a/apps/system/emergency-call/style/images/asterisk.png +++ /dev/null Binary files differ diff --git a/apps/system/emergency-call/style/images/dialer_icon_delete.png b/apps/system/emergency-call/style/images/dialer_icon_delete.png deleted file mode 100644 index 8e842cd..0000000 --- a/apps/system/emergency-call/style/images/dialer_icon_delete.png +++ /dev/null Binary files differ diff --git a/apps/system/emergency-call/style/images/sharp.png b/apps/system/emergency-call/style/images/sharp.png deleted file mode 100644 index 36033bf..0000000 --- a/apps/system/emergency-call/style/images/sharp.png +++ /dev/null Binary files differ diff --git a/apps/system/emergency-call/style/keypad.css b/apps/system/emergency-call/style/keypad.css deleted file mode 100644 index ea9fb90..0000000 --- a/apps/system/emergency-call/style/keypad.css +++ /dev/null @@ -1,301 +0,0 @@ -/* - * The code is being shared between system/emergency-call/js/keypad.js - * and dialer/js/keypad.js. Be sure to update both file when you commit! - * - */ - -.keypad-text { - font-size: -moz-calc(6*0.226rem); - color: #96AAB4; -} - -#keyboard-view { - width: 100%; - height: 100%; -} - -#fake-phone-number-view { - position: absolute; - line-height: 0; - visibility: hidden; -} - -#phone-number-view-container { - width: 100%; - height: -moz-calc(100% - 34.5rem); - background: #242B36; - text-align: center; - display: table; - table-layout: fixed; - border-spacing: 1.5rem 0rem; - font-family: 'MozTT'; - font-weight: 300; -} - -#phone-number-view-container.keypad-visible { - height: -moz-calc(100% - 35rem); - visibility: hidden; -} - -#phone-number-view { - width: 100%; - border: 0; - background: transparent; - text-align: left; - cursor: none; - -moz-user-select: none; -} - -#keypad-delete { - text-align: center; - width: 4rem; - visibility: hidden; -} - -#keypad-delete:active { - opacity: 0.7; -} - -#keypad-delete > div { - width: 3.8rem; - height: 2.8rem; - background: url('images/dialer_icon_delete.png') ; - background-size: 3.8rem 2.8rem; - background-repeat: no-repeat; -} - -#keyboard-container { - width: 100%; - height: 34.5rem; -} - -#keypad { - background: -moz-linear-gradient(top, #191E25 0%, #080B0D 100%); - height: -moz-calc(100% - 10rem); - width: 100%; - display: table; - table-layout: fixed; -} - -.keypad-cell { - display: table-cell; - border-right: 1px solid #6F6F6F; - border-top: 1px solid #6F6F6F;; -} - -.keypad-cell:last-child { - border-right: 0; -} - -.keypad-key { - border: 0; - border-bottom: 1px solid #6F6F6F; - height: 7rem; - vertical-align: middle; - position: relative; -} - -.keypad-key:active { - background: black; - opacity: 0.7; -} - -.keypad-key-label-container { - width: 100%; - height: 100%; - display: table; -} - -.keypad-key-label { - display: table-cell; - padding-left: 1.5rem; - vertical-align: middle; -} - -.keypad-key-label *, -#keypad-delete * { - pointer-events: none; -} - -.keypad-key-label-centered { - padding-left: 0; - text-align: center; -} - -.font-size-plus { - font-size: 2rem; -} - -.keypad-subicon { - background-repeat: no-repeat; - background-position: center bottom; - - -moz-user-select: none; - pointer-events: none; - - position: absolute; - left: 3.75rem; - bottom: 0.75rem; - - width: 3rem; - height: 3rem; -} - -.voicemail { - background-image: url('images/voicemail.png'); -} - -.asterisk { - background-image: url('images/asterisk.png'); - background-repeat: no-repeat; - height: 3rem; - width: 3rem; - background-size: 3rem 3rem; - background-position: center; - margin: auto; - pointer-events: none; -} - -.sharp { - background-image: url('images/sharp.png'); - background-repeat: no-repeat; - height: 3rem; - width: 3rem; - background-size: 3rem 3rem; - background-position: center; - margin: auto; - pointer-events: none; -} - -#keypad-callbar { - background: black; - height: 6.5rem; - width: 100%; - display: table; - table-layout: fixed; - border-spacing: 1rem 1rem; -} - -#keypad-callbar-add-contact, -#keypad-callbar-cancel { - display: table-cell; - width: 9rem; - background: -moz-linear-gradient(top, #242b36 0%, #19191a 100%); - border: .1rem solid #242B36; - border-radius: .2rem; - vertical-align: middle; -} - -#keypad-callbar-cancel { - width: 10rem; -} - -#keypad-callbar-cancel:active { - opacity: 0.7; -} - -#keypad-callbar-cancel > div { - text-align: center; - font: 2rem 'MozTT'; -} - -#keypad-callbar-call-action { - display: table-cell; - width: 100%; - background: #84c82c; - border: 0; - border-radius: .2rem; - background: -moz-linear-gradient(top, #84c82c 0%, #5f9b0a 100%); - vertical-align: middle; -} - -#keypad-callbar-call-action:active { - opacity: 0.7; -} - -.icon-add-contact { - margin: auto; - width: 4rem; - height: 4rem; - background-image: url("images/ActionIcon_40x40_addcontact.png"); - background-repeat: no-repeat; - background-size: 4rem 4rem; - background-position: center; -} - -#keypad-callbar-call-action > div { - margin: auto; - width: 4rem; - height: 4rem; - background-image: url("images/ActionIcon_40x40_pickup.png"); - background-repeat: no-repeat; - background-size: 4rem 4rem; - background-position: center; -} - -#keypad-hidebar { - background: rgba(0,0,0,.8); - opacity: 1.0; -} - -#keypad-hidebar-hang-up-action-wrapper { - float: left; - height: 6.5rem; - width: 50%; -} - -#keypad-hidebar-hide-keypad-action-wrapper { - height: 6.5rem; - width: 50%; -} - -.keypad-hidebar-button { - height: 4rem; - border: 0; - border-radius:.3rem; - display: block; -} - -#keypad-hidebar-hang-up-action { - background: -moz-linear-gradient(top, #ff0000 0%, #ce0000 100%); - opacity: 1.0; - margin: 1rem .5rem 1.5rem 1.5rem; -} - -#keypad-hidebar-hang-up-action > div { - margin: 0 auto; - background-image: url('images/ActionIcon_40x40_hangup.png'); - background-repeat: no-repeat; - background-size: 4rem 4rem; - background-position: center; - width: 4rem; - height: 4rem; -} - -#keypad-hidebar-hide-keypad-action { - background: -moz-linear-gradient(top, #6A6A6A 0%, #3E3E3E 100%); - opacity: 1.0; - margin: 1rem 1.5rem 1.5rem .5rem; -} - -#keypad-hidebar-hide-keypad-action > div { - margin: -moz-calc((4rem - 3rem)/2) auto; - background-image: url('images/ActionIcons_30x30_dismiss_keyboard.png'); - background-repeat: no-repeat; - background-size: 3rem 3rem; - background-position: center; - width: 3rem; - height: 3rem; -} - -.phone-number-font { - font-size:-moz-calc(18*0.226rem); - color: white; - font-family:'MozTT'; -} - -.keypad-number { - font-size: -moz-calc(25*0.226rem); - color: white; -} - diff --git a/apps/system/index.html b/apps/system/index.html index 731a3f3..eba4dc5 100644 --- a/apps/system/index.html +++ b/apps/system/index.html @@ -1,896 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- Notifications - -
- -
- -
-
-
-
-
-
-
-
- -
-
- -
-
- -
-
-
- - -
- - -
- -
- -
- -
- -
- -
- -
-
-
- -
- -
-
-
- - - - - - - -
-
- -
- - - - -
-
-
-

-

Would you like to send Mozilla a report about the crash to help us fix the problem? (Reports are sent over Wi-Fi only)

-

What's in a crash report?

-

- - -

-

- - - - -
- - -
-
- - - -

Crash Reports

-
-

-

-

- -

-
-
- - - -
-
-
-
- -

-
-
-
-
-
-
- -
- - -
- - - -
- - - - -
- -
- - - - - - - - - - - -
- -
-
-
-
- - -
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-

Enter Security Code

-

-
- 1. - 2ABC - 3DEF - 4GHI - 5JKL - 6MNO - 7PQRS - 8TUV - 9WXYZ - Emergency Call - 0 - Cancel - -
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
- -
-
-
- - - - -
- -
-
    -
-
- -
-
-

Device menu

-
    -
-
- - - -
- - - -
-
- - Battery almost empty -
- -
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
- -
+ + Screen diff --git a/apps/system/js/accessibility.js b/apps/system/js/accessibility.js deleted file mode 100644 index c2fa111..0000000 --- a/apps/system/js/accessibility.js +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -SettingsListener.observe('accessibility.invert', false, function(value) { - var screen = document.getElementById('screen'); - if (value) - screen.classList.add('accessibility-invert'); - else - screen.classList.remove('accessibility-invert'); -}); - -SettingsListener.observe('accessibility.screenreader', false, function(value) { - var event = document.createEvent('CustomEvent'); - event.initCustomEvent('mozContentEvent', true, true, - {type: 'accessibility-screenreader', enabled: value}); - window.dispatchEvent(event); -}); diff --git a/apps/system/js/activities.js b/apps/system/js/activities.js deleted file mode 100644 index f4db861..0000000 --- a/apps/system/js/activities.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -var Activities = { - init: function act_init() { - window.addEventListener('mozChromeEvent', this); - }, - - handleEvent: function act_handleEvent(evt) { - switch (evt.type) { - case 'mozChromeEvent': - var detail = evt.detail; - switch (detail.type) { - case 'activity-choice': - this.chooseActivity(detail); - break; - } - break; - } - }, - - chooseActivity: function chooseActivity(detail) { - this._id = detail.id; - - var choices = detail.choices; - if (choices.length === 1) { - this.choose('0'); - } else { - // Since the mozChromeEvent could be triggered by a 'click', and gecko - // event are synchronous make sure to exit the event loop before - // showing the list. - setTimeout((function nextTick() { - var activityName = navigator.mozL10n.get('activity-' + detail.name); - ListMenu.request(this._listItems(choices), activityName, - this.choose.bind(this), this.cancel.bind(this)); - }).bind(this)); - } - }, - - choose: function act_choose(choice) { - var returnedChoice = { - id: this._id, - type: 'activity-choice', - value: choice - }; - - this._sendEvent(returnedChoice); - delete this._id; - }, - - cancel: function act_cancel(value) { - var returnedChoice = { - id: this._id, - type: 'activity-choice', - value: -1 - }; - - this._sendEvent(returnedChoice); - delete this._id; - }, - - _sendEvent: function act_sendEvent(value) { - var event = document.createEvent('CustomEvent'); - event.initCustomEvent('mozContentEvent', true, true, value); - window.dispatchEvent(event); - }, - - _listItems: function act_listItems(choices) { - var items = []; - - choices.forEach(function(choice, index) { - var app = Applications.getByManifestURL(choice.manifest); - items.push({ - label: new ManifestHelper(app.manifest).name, - icon: choice.icon, - value: index - }); - }); - - return items; - } -}; - -Activities.init(); diff --git a/apps/system/js/airplane_mode.js b/apps/system/js/airplane_mode.js deleted file mode 100644 index 781a53f..0000000 --- a/apps/system/js/airplane_mode.js +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -var AirplaneMode = { - enabled: false, - - init: function apm_init() { - if (!window.navigator.mozSettings) - return; - - var mobileDataEnabled = false; - SettingsListener.observe('ril.data.enabled', false, function(value) { - mobileDataEnabled = value; - }); - - var bluetoothEnabled = false; - SettingsListener.observe('bluetooth.enabled', false, function(value) { - bluetoothEnabled = value; - }); - - var wifiEnabled = false; - SettingsListener.observe('wifi.enabled', false, function(value) { - wifiEnabled = value; - }); - - var geolocationEnabled = false; - SettingsListener.observe('geolocation.enabled', false, function(value) { - geolocationEnabled = value; - }); - - var bluetooth = window.navigator.mozBluetooth; - var wifiManager = window.navigator.mozWifiManager; - var mobileData = window.navigator.mozMobileConnection && - window.navigator.mozMobileConnection.data; - var fmRadio = window.navigator.mozFMRadio; - - var restoreMobileData = false; - var restoreBluetooth = false; - var restoreWifi = false; - var restoreGeolocation = false; - // Note that we don't restore Wifi tethering when leaving airplane mode - // because Wifi tethering can't be switched on before data connection is - // established. - - var self = this; - SettingsListener.observe('ril.radio.disabled', false, function(value) { - if (value) { - // Entering airplane mode. - self.enabled = true; - - // Turn off mobile data - // We toggle the mozSettings value here just for the sake of UI, - // platform ril disconnects mobile data when - // 'ril.radio.disabled' is true. - if (mobileData) { - restoreMobileData = mobileDataEnabled; - if (mobileDataEnabled) { - SettingsListener.getSettingsLock().set({ - 'ril.data.enabled': false - }); - } - } - - // Turn off Bluetooth. - if (bluetooth) { - restoreBluetooth = bluetoothEnabled; - if (bluetoothEnabled) { - SettingsListener.getSettingsLock().set({ - 'bluetooth.enabled': false - }); - } - } - - // Turn off Wifi. - if (wifiManager) { - restoreWifi = wifiEnabled; - if (wifiEnabled) { - SettingsListener.getSettingsLock().set({ - 'wifi.enabled': false - }); - } - - // Turn off Wifi tethering. - SettingsListener.getSettingsLock().set({ - 'tethering.wifi.enabled': false - }); - } - - // Turn off Geolocation. - restoreGeolocation = geolocationEnabled; - if (geolocationEnabled) { - SettingsListener.getSettingsLock().set({ - 'geolocation.enabled': false - }); - } - - // Turn off FM Radio. - if (fmRadio && fmRadio.enabled) - fmRadio.disable(); - - } else { - self.enabled = false; - // Don't attempt to turn on mobile data if it's already on - if (mobileData && !mobileDataEnabled && restoreMobileData) { - SettingsListener.getSettingsLock().set({ - 'ril.data.enabled': true - }); - } - - // Don't attempt to turn on Bluetooth if it's already on - if (bluetooth && !bluetooth.enabled && restoreBluetooth) { - SettingsListener.getSettingsLock().set({ - 'bluetooth.enabled': true - }); - } - - // Don't attempt to turn on Wifi if it's already on - if (wifiManager && !wifiManager.enabled && restoreWifi) { - SettingsListener.getSettingsLock().set({ - 'wifi.enabled': true - }); - } - - // Don't attempt to turn on Geolocation if it's already on - if (!geolocationEnabled && restoreGeolocation) { - SettingsListener.getSettingsLock().set({ - 'geolocation.enabled': true - }); - } - } - }); - } -}; - -AirplaneMode.init(); - diff --git a/apps/system/js/app_install_manager.js b/apps/system/js/app_install_manager.js deleted file mode 100644 index 146a01b..0000000 --- a/apps/system/js/app_install_manager.js +++ /dev/null @@ -1,443 +0,0 @@ -'use strict'; - -var AppInstallManager = { - mapDownloadErrorsToMessage: { - 'NETWORK_ERROR': 'download-failed', - 'DOWNLOAD_ERROR': 'download-failed', - 'MISSING_MANIFEST': 'install-failed', - 'INVALID_MANIFEST': 'install-failed', - 'INSTALL_FROM_DENIED': 'install-failed', - 'INVALID_SECURITY_LEVEL': 'install-failed', - 'INVALID_PACKAGE': 'install-failed', - 'APP_CACHE_DOWNLOAD_ERROR': 'download-failed' - }, - - init: function ai_init() { - this.dialog = document.getElementById('app-install-dialog'); - this.msg = document.getElementById('app-install-message'); - this.size = document.getElementById('app-install-size'); - this.authorName = document.getElementById('app-install-author-name'); - this.authorUrl = document.getElementById('app-install-author-url'); - this.installButton = document.getElementById('app-install-install-button'); - this.cancelButton = document.getElementById('app-install-cancel-button'); - this.installCancelDialog = - document.getElementById('app-install-cancel-dialog'); - this.downloadCancelDialog = - document.getElementById('app-download-cancel-dialog'); - this.confirmCancelButton = - document.getElementById('app-install-confirm-cancel-button'); - this.resumeButton = document.getElementById('app-install-resume-button'); - - this.notifContainer = - document.getElementById('install-manager-notification-container'); - this.appInfos = {}; - - window.addEventListener('mozChromeEvent', - (function ai_handleChromeEvent(e) { - if (e.detail.type == 'webapps-ask-install') { - this.handleAppInstallPrompt(e.detail); - } - }).bind(this)); - - window.addEventListener('applicationinstall', - this.handleApplicationInstall.bind(this)); - - - this.installButton.onclick = this.handleInstall.bind(this); - this.cancelButton.onclick = this.showInstallCancelDialog.bind(this); - this.confirmCancelButton.onclick = this.handleInstallCancel.bind(this); - this.resumeButton.onclick = this.hideInstallCancelDialog.bind(this); - this.notifContainer.onclick = this.showDownloadCancelDialog.bind(this); - - this.downloadCancelDialog.querySelector('.confirm').onclick = - this.handleConfirmDownloadCancel.bind(this); - this.downloadCancelDialog.querySelector('.cancel').onclick = - this.handleCancelDownloadCancel.bind(this); - - // bind these handlers so that we can have only one instance and check - // them later on - ['handleDownloadSuccess', - 'handleDownloadError', - 'handleProgress', - 'handleApplicationReady' - ].forEach(function(name) { - this[name] = this[name].bind(this); - }, this); - - window.addEventListener('applicationready', - this.handleApplicationReady); - }, - - handleApplicationReady: function ai_handleApplicationReady(e) { - window.removeEventListener('applicationready', - this.handleApplicationReady); - - var apps = e.detail.applications; - - Object.keys(apps) - .filter(function(key) { return apps[key].installState === 'pending'; }) - .map(function(key) { return apps[key]; }) - .forEach(this.prepareForDownload, this); - }, - - handleApplicationInstall: function ai_handleApplicationInstallEvent(e) { - var app = e.detail.application; - - if (app.installState === 'installed') { - this.showInstallSuccess(app); - return; - } - - this.prepareForDownload(app); - }, - - handleAppInstallPrompt: function ai_handleInstallPrompt(detail) { - var _ = navigator.mozL10n.get; - var app = detail.app; - // updateManifest is used by packaged apps until they are installed - var manifest = app.manifest ? app.manifest : app.updateManifest; - - if (!manifest) - return; - - this.dialog.classList.add('visible'); - - var id = detail.id; - - if (manifest.size) { - this.size.textContent = this.humanizeSize(manifest.size); - } else { - this.size.textContent = _('unknown'); - } - - // Wrap manifest to get localized properties - manifest = new ManifestHelper(manifest); - var msg = _('install-app', {'name': manifest.name}); - this.msg.textContent = msg; - - if (manifest.developer) { - this.authorName.textContent = manifest.developer.name || _('unknown'); - this.authorUrl.textContent = manifest.developer.url || ''; - } else { - this.authorName.textContent = _('unknown'); - this.authorUrl.textContent = ''; - } - - this.installCallback = (function ai_installCallback() { - this.dispatchResponse(id, 'webapps-install-granted'); - }).bind(this); - - this.installCancelCallback = (function ai_cancelCallback() { - this.dispatchResponse(id, 'webapps-install-denied'); - }).bind(this); - - }, - - handleInstall: function ai_handleInstall(evt) { - if (evt) - evt.preventDefault(); - if (this.installCallback) - this.installCallback(); - this.installCallback = null; - this.dialog.classList.remove('visible'); - }, - - prepareForDownload: function ai_prepareForDownload(app) { - var manifestURL = app.manifestURL; - this.appInfos[manifestURL] = {}; - - // these methods are already bound to |this| - app.ondownloadsuccess = this.handleDownloadSuccess; - app.ondownloaderror = this.handleDownloadError; - app.onprogress = this.handleProgress; - }, - - showInstallSuccess: function ai_showInstallSuccess(app) { - var manifest = app.manifest || app.updateManifest; - var name = new ManifestHelper(manifest).name; - var _ = navigator.mozL10n.get; - var msg = _('app-install-success', { appName: name }); - SystemBanner.show(msg); - }, - - handleDownloadSuccess: function ai_handleDownloadSuccess(evt) { - var app = evt.application; - this.showInstallSuccess(app); - this.onDownloadStop(app); - this.onDownloadFinish(app); - }, - - handleDownloadError: function ai_handleDownloadError(evt) { - var app = evt.application; - var _ = navigator.mozL10n.get; - var manifest = app.manifest || app.updateManifest; - var name = new ManifestHelper(manifest).name; - - var errorName = app.downloadError.name; - - switch (errorName) { - case 'INSUFFICIENT_STORAGE': - var title = _('not-enough-space'), - buttonText = _('ok'), - message = _('not-enough-space-message'); - - ModalDialog.alert(title, message, {title: buttonText}); - break; - default: - // showing the real error to a potential developer - console.info('downloadError event, error code is', errorName); - - var key = this.mapDownloadErrorsToMessage[errorName] || 'generic-error'; - var msg = _('app-install-' + key, { appName: name }); - SystemBanner.show(msg); - } - - this.onDownloadStop(app); - }, - - onDownloadStart: function ai_onDownloadStart(app) { - if (! this.hasNotification(app)) { - StatusBar.incSystemDownloads(); - this.addNotification(app); - this.requestWifiLock(app); - } - }, - - onDownloadStop: function ai_onDownloadStop(app) { - if (this.hasNotification(app)) { - StatusBar.decSystemDownloads(); - this.removeNotification(app); - this.releaseWifiLock(app); - } - }, - - hasNotification: function ai_hasNotification(app) { - var appInfo = this.appInfos[app.manifestURL]; - return appInfo && !!appInfo.installNotification; - }, - - onDownloadFinish: function ai_onDownloadFinish(app) { - delete this.appInfos[app.manifestURL]; - - // check if these are our handlers before removing them - if (app.ondownloadsuccess === this.handleDownloadSuccess) { - app.ondownloadsuccess = null; - } - - if (app.ondownloaderror === this.handleDownloadError) { - app.ondownloaderror = null; - } - - if (app.onprogress === this.handleProgress) { - app.onprogress = null; - } - }, - - addNotification: function ai_addNotification(app) { - // should be unique (this is used already in applications.js) - var manifestURL = app.manifestURL, - manifest = app.manifest || app.updateManifest, - appInfo = this.appInfos[manifestURL]; - - if (appInfo.installNotification) { - return; - } - - var newNotif = - '
' + - '
' + - '' + - '
'; - - this.notifContainer.insertAdjacentHTML('afterbegin', newNotif); - - var newNode = this.notifContainer.firstElementChild; - newNode.dataset.manifest = manifestURL; - - var _ = navigator.mozL10n.get; - - var message = _('downloadingAppMessage', { - appName: new ManifestHelper(manifest).name - }); - - newNode.querySelector('.message').textContent = message; - - var size = manifest.size, - progressNode = newNode.querySelector('progress'); - if (size) { - progressNode.max = size; - appInfo.hasMax = true; - } - - appInfo.installNotification = newNode; - NotificationScreen.incExternalNotifications(); - }, - - getNotificationProgressNode: function ai_getNotificationProgressNode(app) { - var appInfo = this.appInfos[app.manifestURL]; - var progressNode = appInfo && - appInfo.installNotification && - appInfo.installNotification.querySelector('progress'); - return progressNode || null; - }, - - handleProgress: function ai_handleProgress(evt) { - var app = evt.application, - appInfo = this.appInfos[app.manifestURL]; - - this.onDownloadStart(app); - - - var progressNode = this.getNotificationProgressNode(app); - var message; - var _ = navigator.mozL10n.get; - - if (isNaN(app.progress) || app.progress == null) { - // now we get NaN if there is no progress information but let's - // handle the null and undefined cases as well - message = _('downloadingAppProgressIndeterminate'); - progressNode.value = undefined; // switch to indeterminate state - } else if (appInfo.hasMax) { - message = _('downloadingAppProgress', - { - progress: this.humanizeSize(app.progress), - max: this.humanizeSize(progressNode.max) - }); - progressNode.value = app.progress; - } else { - message = _('downloadingAppProgressNoMax', - { progress: this.humanizeSize(app.progress) }); - } - progressNode.textContent = message; - }, - - removeNotification: function ai_removeNotification(app) { - var manifestURL = app.manifestURL, - appInfo = this.appInfos[manifestURL], - node = appInfo.installNotification; - - if (!node) { - return; - } - - node.parentNode.removeChild(node); - delete appInfo.installNotification; - NotificationScreen.decExternalNotifications(); - }, - - requestWifiLock: function ai_requestWifiLock(app) { - var appInfo = this.appInfos[app.manifestURL]; - if (! appInfo.wifiLock) { - // we don't want 2 locks for the same app - appInfo.wifiLock = navigator.requestWakeLock('wifi'); - } - }, - - releaseWifiLock: function ai_releaseWifiLock(app) { - var appInfo = this.appInfos[app.manifestURL]; - - if (appInfo.wifiLock) { - try { - appInfo.wifiLock.unlock(); - } catch (e) { - // this can happen if the lock is already unlocked - console.error('error during unlock', e); - } - - delete appInfo.wifiLock; - } - }, - - dispatchResponse: function ai_dispatchResponse(id, type) { - var event = document.createEvent('CustomEvent'); - - event.initCustomEvent('mozContentEvent', true, true, { - id: id, - type: type - }); - - window.dispatchEvent(event); - }, - - humanizeSize: function ai_humanizeSize(bytes) { - var _ = navigator.mozL10n.get; - var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB']; - - if (!bytes) - return '0.00 ' + _(units[0]); - - var e = Math.floor(Math.log(bytes) / Math.log(1024)); - return (bytes / Math.pow(1024, Math.floor(e))).toFixed(2) + ' ' + - _(units[e]); - }, - - showInstallCancelDialog: function ai_showInstallCancelDialog(evt) { - if (evt) - evt.preventDefault(); - this.installCancelDialog.classList.add('visible'); - this.dialog.classList.remove('visible'); - }, - - hideInstallCancelDialog: function ai_hideInstallCancelDialog(evt) { - if (evt) - evt.preventDefault(); - this.dialog.classList.add('visible'); - this.installCancelDialog.classList.remove('visible'); - }, - - showDownloadCancelDialog: function ai_showDownloadCancelDialog(e) { - var currentNode = e.target; - - if (!currentNode.classList.contains('fake-notification')) { - // tapped outside of a notification - return; - } - - var manifestURL = currentNode.dataset.manifest, - app = Applications.getByManifestURL(manifestURL), - manifest = app.manifest || app.updateManifest, - dialog = this.downloadCancelDialog; - - var title = dialog.querySelector('h1'); - - title.textContent = navigator.mozL10n.get('stopDownloading', { - app: new ManifestHelper(manifest).name - }); - - dialog.classList.add('visible'); - dialog.dataset.manifest = manifestURL; - UtilityTray.hide(); - }, - - handleInstallCancel: function ai_handleInstallCancel() { - if (this.installCancelCallback) - this.installCancelCallback(); - this.installCancelCallback = null; - this.installCancelDialog.classList.remove('visible'); - }, - - handleConfirmDownloadCancel: function ai_handleConfirmDownloadCancel(e) { - e && e.preventDefault(); - var dialog = this.downloadCancelDialog, - manifestURL = dialog.dataset.manifest; - if (manifestURL) { - var app = Applications.getByManifestURL(manifestURL); - app && app.cancelDownload(); - } - - this.hideDownloadCancelDialog(); - }, - - handleCancelDownloadCancel: function ai_handleCancelDownloadCancel(e) { - e && e.preventDefault(); - this.hideDownloadCancelDialog(); - }, - - hideDownloadCancelDialog: function() { - var dialog = this.downloadCancelDialog; - dialog.classList.remove('visible'); - delete dialog.dataset.manifest; - } -}; - -AppInstallManager.init(); diff --git a/apps/system/js/applications.js b/apps/system/js/applications.js deleted file mode 100644 index f1e286f..0000000 --- a/apps/system/js/applications.js +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -// Application module handles the information of apps on behalf of other -// modules. - -var Applications = { - installedApps: {}, - ready: false, - init: function a_init() { - var self = this; - var apps = navigator.mozApps; - - var getAllApps = function getAllApps() { - navigator.mozApps.mgmt.getAll().onsuccess = function mozAppGotAll(evt) { - var apps = evt.target.result; - apps.forEach(function(app) { - self.installedApps[app.manifestURL] = app; - // TODO Followup for retrieving homescreen & comms app - }); - - self.ready = true; - self.fireApplicationReadyEvent(); - }; - }; - - // We need to wait for the chrome shell to let us know when it's ok to - // launch activities. This prevents race conditions. - // The event does not fire again when we reload System app in on - // B2G Desktop, so we save the information into sessionStorage. - if (window.sessionStorage.getItem('webapps-registry-ready')) { - getAllApps(); - } else { - window.addEventListener('mozChromeEvent', function mozAppReady(event) { - if (event.detail.type != 'webapps-registry-ready') - return; - - window.sessionStorage.setItem('webapps-registry-ready', 'yes'); - window.removeEventListener('mozChromeEvent', mozAppReady); - - getAllApps(); - }); - } - - apps.mgmt.oninstall = function a_install(evt) { - var newapp = evt.application; - self.installedApps[newapp.manifestURL] = newapp; - - self.fireApplicationInstallEvent(newapp); - }; - - apps.mgmt.onuninstall = function a_uninstall(evt) { - var deletedapp = evt.application; - delete self.installedApps[deletedapp.manifestURL]; - - self.fireApplicationUninstallEvent(deletedapp); - }; - }, - - getByManifestURL: function a_getByManifestURL(manifestURL) { - if (manifestURL in this.installedApps) { - return this.installedApps[manifestURL]; - } - - return null; - }, - - fireApplicationReadyEvent: function a_fireAppReadyEvent() { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('applicationready', - /* canBubble */ true, /* cancelable */ false, - { applications: this.installedApps }); - window.dispatchEvent(evt); - }, - - // We need to dispatch the following events because - // mozApps is not doing so right now. - // ref: https://bugzilla.mozilla.org/show_bug.cgi?id=731746 - - fireApplicationInstallEvent: function a_fireApplicationInstallEvent(app) { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('applicationinstall', - /* canBubble */ true, /* cancelable */ false, - { application: app }); - window.dispatchEvent(evt); - }, - - fireApplicationUninstallEvent: function a_fireApplicationUninstallEvent(app) { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('applicationuninstall', - /* canBubble */ true, /* cancelable */ false, - { application: app }); - window.dispatchEvent(evt); - } -}; - -Applications.init(); diff --git a/apps/system/js/attention_screen.js b/apps/system/js/attention_screen.js deleted file mode 100644 index c14dbe8..0000000 --- a/apps/system/js/attention_screen.js +++ /dev/null @@ -1,289 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -'use strict'; - -var AttentionScreen = { - get mainScreen() { - delete this.mainScreen; - return this.mainScreen = document.getElementById('screen'); - }, - - get attentionScreen() { - delete this.attentionScreen; - return this.attentionScreen = document.getElementById('attention-screen'); - }, - - get bar() { - delete this.bar; - return this.bar = document.getElementById('attention-bar'); - }, - - isVisible: function as_isVisible() { - return this.attentionScreen.classList.contains('displayed'); - }, - - isFullyVisible: function as_isFullyVisible() { - return (this.isVisible() && - !this.mainScreen.classList.contains('active-statusbar')); - }, - - init: function as_init() { - window.addEventListener('mozbrowseropenwindow', this.open.bind(this), true); - window.addEventListener('mozbrowserclose', this.close.bind(this), true); - window.addEventListener('mozbrowsererror', this.close.bind(this), true); - window.addEventListener('keyboardchange', this.resize.bind(this), true); - window.addEventListener('keyboardhide', this.resize.bind(this), true); - - this.bar.addEventListener('click', this.show.bind(this)); - window.addEventListener('home', this.hide.bind(this)); - window.addEventListener('holdhome', this.hide.bind(this)); - window.addEventListener('appwillopen', this.hide.bind(this)); - }, - - resize: function as_resize(evt) { - if (evt.type == 'keyboardchange') { - if (!this.isFullyVisible()) - return; - - this.attentionScreen.style.height = - window.innerHeight - evt.detail.height + 'px'; - } else if (evt.type == 'keyboardhide') { - // We still need to reset the height property even when the attention - // screen is not fully visible, or it will overrides the height - // we defined with #attention-screen.status-mode - this.attentionScreen.style.height = ''; - } - }, - - // show the attention screen overlay with newly created frame - open: function as_open(evt) { - if (evt.detail.features != 'attention') - return; - - // stopPropagation means we are not allowing - // Popup Manager to handle this event - evt.stopPropagation(); - - // Canceling any full screen web content - if (document.mozFullScreen) - document.mozCancelFullScreen(); - - // Check if the app has the permission to open attention screens - var manifestURL = evt.target.getAttribute('mozapp'); - var app = Applications.getByManifestURL(manifestURL); - - if (!app || !this._hasAttentionPermission(app)) - return; - - // Hide sleep menu/list menu if it is shown now - ListMenu.hide(); - SleepMenu.hide(); - - // We want the user attention, so we need to turn the screen on - // if it's off. The lockscreen will grab the focus when we do that - // so we need to do it before adding the new iframe to the dom - if (!ScreenManager.screenEnabled) - ScreenManager.turnScreenOn(); - - var attentionFrame = evt.detail.frameElement; - attentionFrame.dataset.frameType = 'attention'; - attentionFrame.dataset.frameName = evt.detail.name; - attentionFrame.dataset.frameOrigin = evt.target.dataset.frameOrigin; - - // We would like to put the dialer call screen on top of all other - // attention screens by ensure it is the last iframe in the DOM tree - if (this._hasTelephonyPermission(app)) { - this.attentionScreen.appendChild(attentionFrame); - } else { - this.attentionScreen.insertBefore(attentionFrame, - this.bar.nextElementSibling); - } - - this._updateAttentionFrameVisibility(); - - // Make the overlay visible if we are not displayed yet. - // alternatively, if the newly appended frame is the visible frame - // and we are in the status bar mode, expend to full screen mode. - if (!this.isVisible()) { - this.attentionScreen.classList.add('displayed'); - this.mainScreen.classList.add('attention'); - this.dispatchEvent('attentionscreenshow', { - origin: attentionFrame.dataset.frameOrigin - }); - } else if (!this.isFullyVisible() && - this.attentionScreen.lastElementChild === attentionFrame) { - this.show(); - } - }, - - // Make sure visibililty state of all attention screens are set correctly - _updateAttentionFrameVisibility: function as_updateAtteFrameVisibility() { - var frames = this.attentionScreen.querySelectorAll('iframe'); - var i = frames.length - 1; - - // In case someone call this function w/o checking for frame first - if (i < 0) - return; - - // set the last one in the DOM to visible - // The setTimeout() and the closure is used to workaround - // https://bugzilla.mozilla.org/show_bug.cgi?id=810431 - setTimeout(function(frame) { - frame.setVisible(true); - frame.focus(); - }, 0, frames[i]); - - while (i--) { - // The setTimeout() and the closure is used to workaround - // https://bugzilla.mozilla.org/show_bug.cgi?id=810431 - setTimeout(function(frame) { - frame.setVisible(false); - frame.blur(); - }, 0, frames[i]); - } - }, - - // close the attention screen overlay - close: function as_close(evt) { - if (!'frameType' in evt.target.dataset || - evt.target.dataset.frameType !== 'attention' || - (evt.type === 'mozbrowsererror' && evt.detail.type !== 'fatal')) - return; - - // Remove the frame - var origin = evt.target.dataset.frameOrigin; - this.attentionScreen.removeChild(evt.target); - - // We've just removed the focused window leaving the system - // without any focused window, let's fix this. - window.focus(); - - // if there are other attention frames, - // we need to update the visibility and show() the overlay. - if (this.attentionScreen.querySelectorAll('iframe').length) { - this._updateAttentionFrameVisibility(); - - this.dispatchEvent('attentionscreenclose', { origin: origin }); - - if (!this.isFullyVisible()) - this.show(); - - return; - } - - // There is no iframes left; - // we should close the attention screen overlay. - - // If the the attention screen is closed during active-statusbar - // mode, we would need to leave that mode. - if (!this.isFullyVisible()) { - this.mainScreen.classList.remove('active-statusbar'); - this.attentionScreen.classList.remove('status-mode'); - this.dispatchEvent('status-inactive', - { origin: this.attentionScreen.lastElementChild.dataset.frameOrigin }); - } - - this.attentionScreen.classList.remove('displayed'); - this.mainScreen.classList.remove('attention'); - this.dispatchEvent('attentionscreenhide', { origin: origin }); - }, - - // expend the attention screen overlay to full screen - show: function as_show() { - // leaving "status-mode". - this.attentionScreen.classList.remove('status-mode'); - // there shouldn't be a transition from "status-mode" to "active-statusbar" - this.attentionScreen.style.transition = 'none'; - - var self = this; - setTimeout(function nextTick() { - self.attentionScreen.style.transition = ''; - - // leaving "active-statusbar" mode, - // with a transform: translateY() slide down transition. - self.mainScreen.classList.remove('active-statusbar'); - self.dispatchEvent('status-inactive', { - origin: self.attentionScreen.lastElementChild.dataset.frameOrigin - }); - }); - }, - - // shrink the attention screen overlay to status bar - // invoked when we get a "home" event - hide: function as_hide() { - if (!this.isFullyVisible()) - return; - - // entering "active-statusbar" mode, - // with a transform: translateY() slide up transition. - this.mainScreen.classList.add('active-statusbar'); - - // The only way to hide attention screen is the home/holdhome event. - // So we don't fire any origin information here. - // The expected behavior is restore homescreen visibility to 'true' - // in the Window Manager. - this.dispatchEvent('status-active'); - - var attentionScreen = this.attentionScreen; - attentionScreen.addEventListener('transitionend', function trWait() { - attentionScreen.removeEventListener('transitionend', trWait); - - // transition completed, entering "status-mode" (40px height iframe) - attentionScreen.classList.add('status-mode'); - }); - }, - - dispatchEvent: function as_dispatchEvent(name, detail) { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent(name, true, true, detail); - window.dispatchEvent(evt); - }, - - // If an app with an active attention screen is switched to, - // we would need to cover it with it's attention screen. - // Invoked when displayedApp in Window Manager changes - // XXX should be replaced with a call that listens to appwillopen - // TBD: display the attention screen underneath other attention screens. - showForOrigin: function as_showForOrigin(origin) { - if (!this.isVisible() || this.isFullyVisible()) - return; - - var attentionFrame = this.attentionScreen.lastElementChild; - var frameOrigin = attentionFrame.dataset.frameOrigin; - if (origin === frameOrigin) { - this.show(); - } - }, - - getAttentionScreenOrigins: function as_getAttentionScreenOrigins() { - var attentionScreen = this.attentionScreen; - var frames = this.attentionScreen.querySelectorAll('iframe'); - var attentiveApps = []; - Array.prototype.forEach.call(frames, function pushFrame(frame) { - attentiveApps.push(frame.dataset.frameOrigin); - }); - return attentiveApps; - }, - - _hasAttentionPermission: function as_hasAttentionPermission(app) { - var mozPerms = navigator.mozPermissionSettings; - if (!mozPerms) - return false; - - var value = mozPerms.get('attention', app.manifestURL, app.origin, false); - - return (value === 'allow'); - }, - - _hasTelephonyPermission: function as_hasAttentionPermission(app) { - var mozPerms = navigator.mozPermissionSettings; - if (!mozPerms) - return false; - - var value = mozPerms.get('telephony', app.manifestURL, app.origin, false); - - return (value === 'allow'); - } -}; - -AttentionScreen.init(); diff --git a/apps/system/js/authentication_dialog.js b/apps/system/js/authentication_dialog.js deleted file mode 100644 index 3a893ee..0000000 --- a/apps/system/js/authentication_dialog.js +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -// This module listens to mozbrowserusernameandpasswordrequired event. -// It's for http authentication only. -// XXX: ftp authentication will be implemented here but not supported yet. - -var AuthenticationDialog = { - // Used for element id access. - // e.g., 'authentication-dialog-alert-ok' - prefix: 'authentication-dialog-', - - // DOM - elements: {}, - - // Get all elements when inited. - getAllElements: function ad_getAllElements() { - var elementsID = [ - 'http-authentication', 'http-username-input', 'http-password-input', - 'http-authentication-message', 'http-authentication-ok', - 'http-authentication-cancel', 'title' - ]; - - var toCamelCase = function toCamelCase(str) { - return str.replace(/\-(.)/g, function replacer(str, p1) { - return p1.toUpperCase(); - }); - }; - - elementsID.forEach(function createElementRef(name) { - this.elements[toCamelCase(name)] = - document.getElementById(this.prefix + name); - }, this); - - this.screen = document.getElementById('screen'); - this.overlay = document.getElementById('dialog-overlay'); - }, - - // Save the events returned by - // mozbrowserusernameandpasswordrequired for later use. - // The events are stored according to webapp origin - // e.g., 'http://uitest.gaiamobile.org': evt - currentEvents: {}, - - init: function ad_init() { - // Get all elements initially. - this.getAllElements(); - var elements = this.elements; - - // Bind events - window.addEventListener('mozbrowserusernameandpasswordrequired', this); - window.addEventListener('appopen', this); - window.addEventListener('appwillclose', this); - window.addEventListener('appterminated', this); - window.addEventListener('resize', this); - window.addEventListener('keyboardchange', this); - window.addEventListener('keyboardhide', this); - - for (var id in elements) { - if (elements[id].tagName.toLowerCase() == 'button') { - elements[id].addEventListener('click', this); - } - } - }, - - // Default event handler - handleEvent: function ad_handleEvent(evt) { - var elements = this.elements; - switch (evt.type) { - case 'mozbrowserusernameandpasswordrequired': - if (evt.target.dataset.frameType != 'window') - return; - - evt.preventDefault(); - var origin = evt.target.dataset.frameOrigin; - this.currentEvents[origin] = evt; - - if (origin == WindowManager.getDisplayedApp()) - this.show(origin); - break; - - case 'click': - if (evt.currentTarget === elements.httpAuthenticationCancel) { - this.cancelHandler(); - } else { - this.confirmHandler(); - } - break; - - case 'appopen': - if (this.currentEvents[evt.detail.origin]) - this.show(evt.detail.origin); - break; - - case 'appwillclose': - // Do nothing if the app is closed at background. - if (evt.detail.origin !== this.currentOrigin) - return; - - // Reset currentOrigin - this.hide(); - break; - - case 'appterminated': - if (this.currentEvents[evt.detail.origin]) - delete this.currentEvents[evt.detail.origin]; - - break; - - case 'resize': - case 'keyboardhide': - if (!this.currentOrigin) - return; - - this.setHeight(window.innerHeight - StatusBar.height); - break; - - case 'keyboardchange': - this.setHeight(window.innerHeight - - evt.detail.height - StatusBar.height); - break; - } - }, - - setHeight: function ad_setHeight(height) { - if (this.isVisible()) - this.overlay.style.height = height + 'px'; - }, - - show: function ad_show(origin) { - this.currentOrigin = origin; - var evt = this.currentEvents[origin]; - var elements = this.elements; - this.screen.classList.add('authentication-dialog'); - elements.httpAuthentication.classList.add('visible'); - elements.title.textContent = evt.detail.host; - elements.httpAuthenticationMessage.textContent = evt.detail.realm; - elements.httpUsernameInput.value = ''; - elements.httpPasswordInput.value = ''; - - this.setHeight(window.innerHeight - StatusBar.height); - }, - - hide: function ad_hide() { - this.elements.httpUsernameInput.blur(); - this.elements.httpPasswordInput.blur(); - this.currentOrigin = null; - this.elements.httpAuthentication.classList.remove('visible'); - this.screen.classList.remove('authentication-dialog'); - }, - - confirmHandler: function ad_confirmHandler() { - var elements = this.elements; - var evt = this.currentEvents[this.currentOrigin]; - evt.detail.authenticate(elements.httpUsernameInput.value, - elements.httpPasswordInput.value); - elements.httpAuthentication.classList.remove('visible'); - delete this.currentEvents[this.currentOrigin]; - this.screen.classList.remove('authentication-dialog'); - }, - - cancelHandler: function ad_cancelHandler() { - var evt = this.currentEvents[this.currentOrigin]; - var elements = this.elements; - evt.detail.cancel(); - elements.httpAuthentication.classList.remove('visible'); - delete this.currentEvents[this.currentOrigin]; - this.screen.classList.remove('authentication-dialog'); - }, - - isVisible: function ad_isVisible() { - return this.screen.classList.contains('authentication-dialog'); - } -}; - -AuthenticationDialog.init(); diff --git a/apps/system/js/background_service.js b/apps/system/js/background_service.js deleted file mode 100644 index 117b556..0000000 --- a/apps/system/js/background_service.js +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -/* - Allow web apps to inject a tiny persistent background iframe - as the phone starts. -*/ -var BackgroundServiceManager = (function bsm() { - /* We keep the references to background page iframes here. - The iframes will be append to body */ - var frames = {}; - - /* The name of the background window open by background_page in - manifest. */ - var AUTO_OPEN_BG_PAGE_NAME = 'background'; - - /* Init */ - var init = function bsm_init() { - var applications = Applications.installedApps; - Object.keys(applications).forEach(function bsm_each(manifestURL) { - var app = applications[manifestURL]; - if (!app.manifest.background_page) - return; - - // XXX: this work as if background_page is always a path not a full URL. - var url = app.origin + app.manifest.background_page; - open(manifestURL, AUTO_OPEN_BG_PAGE_NAME, url); - }); - }; - - /* mozbrowseropenwindow */ - window.addEventListener('mozbrowseropenwindow', function bsm_winopen(evt) { - if (evt.detail.features !== 'background') - return; - - // stopPropagation means we are not allowing - // Popup Manager to handle this event - evt.stopPropagation(); - - var manifestURL = evt.target.getAttribute('mozapp'); - var detail = evt.detail; - - open(manifestURL, detail.name, detail.url, detail.frameElement); - }, true); - - /* mozbrowserclose */ - window.addEventListener('mozbrowserclose', function bsm_winclose(evt) { - if (!'frameType' in evt.target.dataset || - evt.target.dataset.frameType !== 'background') - return; - - var manifestURL = evt.target.getAttribute('mozapp'); - - close(manifestURL, evt.target.dataset.frameName); - }, true); - - /* mozbrowsererror */ - window.addEventListener('mozbrowsererror', function bsm_winclose(evt) { - if (!'frameType' in evt.target.dataset || - evt.target.dataset.frameType !== 'background' || - evt.detail.type !== 'fatal') - return; - - var target = evt.target; - var manifestURL = target.getAttribute('mozapp'); - - // This bg service has just crashed, clean up the frame - var name = target.dataset.frameName; - close(manifestURL, name); - }, true); - - /* OnInstall */ - window.addEventListener('applicationinstall', function bsm_oninstall(evt) { - var app = evt.detail.application; - var origin = app.origin; - if (!app.manifest.background_page) - return; - - // XXX: this work as if background_page is always a path not a full URL. - var url = origin + app.manifest.background_page; - open(manifestURL, AUTO_OPEN_BG_PAGE_NAME, url); - }); - - /* OnUninstall */ - window.addEventListener('applicationuninstall', function bsm_oninstall(evt) { - var app = evt.detail.application; - close(app.manifestURL); - }); - - /* Check if the app has the permission to open a background page */ - var hasBackgroundPermission = function bsm_checkPermssion(app) { - var mozPerms = navigator.mozPermissionSettings; - if (!mozPerms) - return false; - - var value = mozPerms.get('backgroundservice', app.manifestURL, - app.origin, false); - - return (value === 'allow'); - }; - - /* The open function is responsible of containing the iframe */ - var open = function bsm_open(manifestURL, name, url, frame) { - var app = Applications.getByManifestURL(manifestURL); - if (!app || !hasBackgroundPermission(app)) - return false; - - if (frames[manifestURL] && frames[manifestURL][name]) { - console.error('Window with the same name is there but Gecko ' + - ' failed to use it. See bug 766873. origin: "' + origin + - '", name: "' + name + '".'); - return false; - } - - if (!frame) { - frame = document.createElement('iframe'); - - // If we have a frame element, it's provided by mozbrowseropenwindow, and - // it has the mozbrowser, mozapp, and src attributes set already. - frame.setAttribute('mozbrowser', 'mozbrowser'); - frame.setAttribute('mozapp', manifestURL); - frame.setAttribute('name', name); - - var appName = app.manifest.name; - frame.setAttribute('remote', 'true'); - console.info('%%%%% Launching', appName, 'bg service as remote (OOP)'); - frame.src = url; - } - frame.className = 'backgroundWindow'; - frame.dataset.frameType = 'background'; - frame.dataset.frameName = name; - - if (!frames[manifestURL]) - frames[manifestURL] = {}; - frames[manifestURL][name] = frame; - - document.body.appendChild(frame); - - // Background services should load in the background. - // - // (The funky setTimeout(0) is to work around - // https://bugzilla.mozilla.org/show_bug.cgi?id=810431 .) - setTimeout(function() { frame.setVisible(false) }, 0); - - return true; - }; - - /* The close function will remove the iframe from DOM and - delete the reference */ - var close = function bsm_close(manifestURL, name) { - if (!frames[manifestURL]) - return false; - - if (typeof name == 'undefined') { - // Close all windows - Object.keys(frames[manifestURL]).forEach(function closeEach(name) { - document.body.removeChild(frames[manifestURL][name]); - frames[manifestURL][name] = null; - }); - delete frames[manifestURL]; - return true; - } - - // Close one window - var frame = frames[manifestURL][name]; - if (!frame) - return false; - - document.body.removeChild(frame); - delete frames[manifestURL][name]; - - if (!Object.keys(frames[manifestURL]).length) - delete frames[manifestURL]; - return true; - }; - - /* start initialization */ - if (Applications.ready) { - init(); - } else { - window.addEventListener('applicationready', - function bsm_appListReady(event) { - window.removeEventListener('applicationready', bsm_appListReady); - init(); - }); - } - - /* Return the public APIs */ - return { - 'open': open, - 'close': close - }; -}()); - diff --git a/apps/system/js/battery_manager.js b/apps/system/js/battery_manager.js deleted file mode 100644 index d2eacf8..0000000 --- a/apps/system/js/battery_manager.js +++ /dev/null @@ -1,277 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -var BatteryManager = { - TOASTER_TIMEOUT: 5000, - TRANSITION_SPEED: 1.8, - TRANSITION_FRACTION: 0.30, - - AUTO_SHUTDOWN_LEVEL: 0.02, - EMPTY_BATTERY_LEVEL: 0.1, - - _battery: window.navigator.battery, - _notification: null, - - getAllElements: function bm_getAllElements() { - this.screen = document.getElementById('screen'); - this.overlay = document.getElementById('system-overlay'); - this.notification = document.getElementById('battery'); - }, - - checkBatteryDrainage: function bm_checkBatteryDrainage() { - var battery = this._battery; - if (!battery) - return; - - if (battery.level <= this.AUTO_SHUTDOWN_LEVEL) - SleepMenu.startPowerOff(false); - }, - - init: function bm_init() { - this.getAllElements(); - var battery = this._battery; - if (battery) { - // When the device is booted, check if the battery is drained. - // If so, SleepMenu.startPowerOff() would be called. - this.checkBatteryDrainage(); - - battery.addEventListener('levelchange', this); - battery.addEventListener('chargingchange', this); - } - window.addEventListener('screenchange', this); - this._toasterGD = new GestureDetector(this.notification); - ['mousedown', 'swipe'].forEach(function(evt) { - this.notification.addEventListener(evt, this); - }, this); - - this._screenOn = true; - this._wasEmptyBatteryNotificationDisplayed = false; - - this.displayIfNecessary(); - }, - - handleEvent: function bm_handleEvent(evt) { - switch (evt.type) { - case 'screenchange': - this._screenOn = evt.detail.screenEnabled; - this.displayIfNecessary(); - break; - - case 'levelchange': - var battery = this._battery; - if (!battery) - return; - - this.checkBatteryDrainage(); - this.displayIfNecessary(); - - PowerSaveHandler.onBatteryChange(); - break; - case 'chargingchange': - PowerSaveHandler.onBatteryChange(); - - var battery = this._battery; - // We turn the screen on if needed in order to let - // the user knows the device is charging - - if (battery && battery.charging) { - this.hide(); - this._wasEmptyBatteryNotificationDisplayed = false; - - if (!this._screenOn) { - ScreenManager.turnScreenOn(); - } - } else { - this.displayIfNecessary(); - } - break; - - case 'mousedown': - this.mousedown(evt); - break; - case 'swipe': - this.swipe(evt); - break; - } - }, - - _shouldWeDisplay: function bm_shouldWeDisplay() { - var battery = this._battery; - if (!battery) { - return false; - } - - return (!this._wasEmptyBatteryNotificationDisplayed && - !battery.charging && - battery.level <= this.EMPTY_BATTERY_LEVEL && - this._screenOn); - }, - - displayIfNecessary: function bm_display() { - if (! this._shouldWeDisplay()) { - return; - } - - // we know it's here, it's checked in shouldWeDisplay() - var level = this._battery.level; - - this.overlay.classList.add('battery'); - - this._toasterGD.startDetecting(); - this._wasEmptyBatteryNotificationDisplayed = true; - - if (this._toasterTimeout) { - clearTimeout(this._toasterTimeout); - } - - this._toasterTimeout = setTimeout(this.hide.bind(this), - this.TOASTER_TIMEOUT); - }, - - hide: function bm_hide() { - var overlayCss = this.overlay.classList; - if (overlayCss.contains('battery')) { - this.overlay.classList.remove('battery'); - this._toasterTimeout = null; - this._toasterGD.stopDetecting(); - } - }, - - // Swipe handling - mousedown: function bm_mousedown(evt) { - evt.preventDefault(); - this._containerWidth = this.overlay.clientWidth; - }, - - swipe: function bm_swipe(evt) { - var detail = evt.detail; - var distance = detail.start.screenX - detail.end.screenX; - var fastEnough = Math.abs(detail.vx) > this.TRANSITION_SPEED; - var farEnough = Math.abs(distance) > - this._containerWidth * this.TRANSITION_FRACTION; - - // If the swipe distance is too short or swipe speed is too slow, - // do nothing. - if (!(farEnough || fastEnough)) - return; - - var self = this; - this.notification.addEventListener('animationend', function animationend() { - self.notification.removeEventListener('animationend', animationend); - self.notification.classList.remove('disappearing'); - self.hide(); - }); - this.notification.classList.add('disappearing'); - } -}; - -var PowerSaveHandler = (function PowerSaveHandler() { - - var _powerSaveResume = {}; - var _powerSaveEnabled = false; - var _states = { - 'wifi.enabled' : false, - 'ril.data.enabled' : false, - 'bluetooth.enabled' : false, - 'geolocation.enabled' : false - }; - - function init() { - SettingsListener.observe('powersave.enabled', false, - function sl_getPowerSave(value) { - var enabled = value; - if (enabled) { - enablePowerSave(); - } else { - disablePowerSave(); - } - _powerSaveEnabled = enabled; - }); - - // Monitor the states of various modules - for (var j in _states) { - SettingsListener.observe(j, true, function getState(state, value) { - _states[state] = value; - }.bind(null, j)); - } - } - - // XXX Break down obj keys in a for each loop because mozSettings - // does not currently supports multiple keys in one set() - // https://bugzilla.mozilla.org/show_bug.cgi?id=779381 - function setMozSettings(keypairs) { - var setlock = SettingsListener.getSettingsLock(); - for (var key in keypairs) { - var obj = {}; - obj[key] = keypairs[key]; - setlock.set(obj); - } - } - - function enablePowerSave() { - // Keep the original states of various modules - for (var j in _states) { - _powerSaveResume[j] = _states[j]; - } - - var settingsToSet = { - // Turn off Wifi - 'wifi.enabled' : false, - // Turn off Data - 'ril.data.enabled' : false, - // Turn off Bluetooth - 'bluetooth.enabled' : false, - // Turn off Geolocation - 'geolocation.enabled' : false - }; - - setMozSettings(settingsToSet); - } - - function disablePowerSave() { - - var settingsToSet = {}; - - for (var state in _powerSaveResume) { - if (_powerSaveResume[state] == true) - settingsToSet[state] = true; - } - - setMozSettings(settingsToSet); - } - - function onBatteryChange() { - var battery = BatteryManager._battery; - - if (battery.charging) { - if (_powerSaveEnabled) - setMozSettings({'powersave.enabled' : false}); - - return; - } - - SettingsListener.observe('powersave.threshold', 0, - function getThreshold(value) { - if (battery.level <= value && !_powerSaveEnabled) { - setMozSettings({'powersave.enabled' : true}); - return; - } - - if (value != 0 && battery.level > value && _powerSaveEnabled) { - setMozSettings({'powersave.enabled' : false}); - return; - } - }); - } - - return { - init: init, - onBatteryChange: onBatteryChange - }; -})(); - -// init PowerSaveHandler first, since it will be used by BatteryManager -PowerSaveHandler.init(); -BatteryManager.init(); diff --git a/apps/system/js/bluetooth.js b/apps/system/js/bluetooth.js deleted file mode 100644 index 3a77cc7..0000000 --- a/apps/system/js/bluetooth.js +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -var Bluetooth = { - - /* this property store a reference of the default adapter */ - defaultAdapter: null, - - /* keep a global connected property here */ - connected: false, - - init: function bt_init() { - if (!window.navigator.mozSettings) - return; - - var bluetooth = window.navigator.mozBluetooth; - - SettingsListener.observe('bluetooth.enabled', true, function(value) { - if (!bluetooth) { - // roll back the setting value to notify the UIs - // that Bluetooth interface is not available - if (value) { - SettingsListener.getSettingsLock().set({ - 'bluetooth.enabled': false - }); - } - return; - } - }); - - var self = this; - // when bluetooth adapter is ready, emit event to notify QuickSettings - // and try to get defaultAdapter at this moment - bluetooth.onadapteradded = function bt_onAdapterAdded() { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('bluetooth-adapter-added', - /* canBubble */ true, /* cancelable */ false, null); - window.dispatchEvent(evt); - self.initDefaultAdapter(); - }; - // if bluetooth is enabled in booting time, try to get adapter now - this.initDefaultAdapter(); - - // when bluetooth is really disabled, emit event to notify QuickSettings - bluetooth.ondisabled = function bt_onDisabled() { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('bluetooth-disabled', - /* canBubble */ true, /* cancelable */ false, null); - window.dispatchEvent(evt); - }; - - /* for v1, we only support two use cases for bluetooth connection: - * 1. connecting with a headset - * 2. transfering a file to/from another device - * So we need to monitor their event messages to know we are (aren't) - * connected, then summarize to an event and dispatch to StatusBar - */ - - // In headset connected case: - navigator.mozSetMessageHandler('bluetooth-hfp-status-changed', - this.updateConnected.bind(this) - ); - - /* In file transfering case: - * since System Message can't be listened in two js files within a app, - * so we listen here but dispatch events to bluetooth_transfer.js - * when getting bluetooth file transfer start/complete system messages - */ - var self = this; - navigator.mozSetMessageHandler('bluetooth-opp-transfer-start', - function bt_fileTransferUpdate(transferInfo) { - self.updateConnected(); - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('bluetooth-opp-transfer-start', - /* canBubble */ true, /* cancelable */ false, - {transferInfo: transferInfo}); - window.dispatchEvent(evt); - } - ); - - navigator.mozSetMessageHandler('bluetooth-opp-transfer-complete', - function bt_fileTransferUpdate(transferInfo) { - self.updateConnected(); - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('bluetooth-opp-transfer-complete', - /* canBubble */ true, /* cancelable */ false, - {transferInfo: transferInfo}); - window.dispatchEvent(evt); - } - ); - - }, - - // Get adapter for BluetoothTransfer when everytime bluetooth is enabled - initDefaultAdapter: function bt_initDefaultAdapter() { - var bluetooth = window.navigator.mozBluetooth; - var self = this; - - if (!bluetooth || !bluetooth.enabled || - !('getDefaultAdapter' in bluetooth)) - return; - - var req = bluetooth.getDefaultAdapter(); - req.onsuccess = function bt_gotDefaultAdapter(evt) { - self.defaultAdapter = req.result; - }; - }, - - updateConnected: function bt_updateConnected() { - var bluetooth = window.navigator.mozBluetooth; - - if (!bluetooth || !('isConnected' in bluetooth)) - return; - - var wasConnected = this.connected; - this.connected = - bluetooth.isConnected(0x111E) || bluetooth.isConnected(0x1105); - - if (wasConnected !== this.connected) { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent('bluetoothconnectionchange', - /* canBubble */ true, /* cancelable */ false, - {deviceConnected: this.connected}); - window.dispatchEvent(evt); - } - }, - - // This function is called by external (BluetoothTransfer) for re-use adapter - getAdapter: function bt_getAdapter() { - return this.defaultAdapter; - } -}; - -Bluetooth.init(); diff --git a/apps/system/js/bluetooth_transfer.js b/apps/system/js/bluetooth_transfer.js deleted file mode 100644 index 47483f7..0000000 --- a/apps/system/js/bluetooth_transfer.js +++ /dev/null @@ -1,511 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -'use strict'; - -var BluetoothTransfer = { - bannerContainer: null, - pairList: { - index: [] - }, - _deviceStorage: navigator.getDeviceStorage('sdcard'), - _debug: false, - - get transferStatusList() { - delete this.transferStatusList; - return this.transferStatusList = - document.getElementById('bluetooth-transfer-status-list'); - }, - - get banner() { - delete this.banner; - return this.banner = document.getElementById('system-banner'); - }, - - init: function bt_init() { - // Bind message handler for transferring file callback - navigator.mozSetMessageHandler('bluetooth-opp-receiving-file-confirmation', - this.onReceivingFileConfirmation.bind(this) - ); - - // Listen to 'bluetooth-opp-transfer-start' from bluetooth.js - window.addEventListener('bluetooth-opp-transfer-start', - this.onUpdateProgress.bind(this, 'start') - ); - - navigator.mozSetMessageHandler('bluetooth-opp-update-progress', - this.onUpdateProgress.bind(this, 'progress') - ); - - // Listen to 'bluetooth-opp-transfer-complete' from bluetooth.js - window.addEventListener('bluetooth-opp-transfer-complete', - this.onTransferComplete.bind(this) - ); - this.bannerContainer = this.banner.firstElementChild; - }, - - getDeviceName: function bt_getDeviceName(address) { - var _ = navigator.mozL10n.get; - var length = this.pairList.index.length; - for (var i = 0; i < length; i++) { - if (this.pairList.index[i].address == address) - return this.pairList.index[i].name; - } - return _('unknown-device'); - }, - - getPairedDevice: function bt_getPairedDevice(callback) { - var adapter = Bluetooth.getAdapter(); - if (adapter == null) { - var msg = 'Cannot get Bluetooth adapter.'; - this.debug(msg); - return; - } - var self = this; - var req = adapter.getPairedDevices(); - req.onsuccess = function bt_getPairedSuccess() { - self.pairList.index = req.result; - var length = self.pairList.index.length; - if (length == 0) { - var msg = - 'There is no paired device! Please pair your bluetooth device first.'; - self.debug(msg); - return; - } - if (callback) { - callback(); - } - }; - req.onerror = function() { - var msg = 'Can not get paired devices from adapter.'; - self.debug(msg); - }; - }, - - debug: function bt_debug(msg) { - if (!this._debug) - return; - - console.log('[System Bluetooth Transfer]: ' + msg); - }, - - humanizeSize: function bt_humanizeSize(bytes) { - var _ = navigator.mozL10n.get; - var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - var size, e; - if (bytes) { - e = Math.floor(Math.log(bytes) / Math.log(1024)); - size = (bytes / Math.pow(1024, e)).toFixed(2); - } else { - e = 0; - size = '0.00'; - } - return _('fileSize', { - size: size, - unit: _('byteUnit-' + units[e]) - }); - }, - - onReceivingFileConfirmation: function bt_onReceivingFileConfirmation(evt) { - // Prompt appears when a transfer request from a paired device is received. - var _ = navigator.mozL10n.get; - - var fileSize = evt.fileLength; - var self = this; - var icon = 'style/bluetooth_transfer/images/icon_bluetooth.png'; - - // Check storage is available or not before the prompt. - this.checkStorageSpace(fileSize, - function checkStorageSpaceComplete(isStorageAvailable, errorMessage) { - if (isStorageAvailable) { - NotificationHelper.send(_('notification-fileTransfer-title'), - _('notification-fileTransfer-description'), - icon, - function() { - UtilityTray.hide(); - self.showReceivePrompt(evt); - }); - } else { - self.showStorageUnavaliablePrompt(errorMessage); - } - }); - }, - - showReceivePrompt: function bt_showReceivePrompt(evt) { - var _ = navigator.mozL10n.get; - - var address = evt.address; - var fileName = evt.fileName; - var fileSize = this.humanizeSize(evt.fileLength); - var cancel = { - title: _('deny'), - callback: this.declineReceive.bind(this, address) - }; - - var confirm = { - title: _('transfer'), - callback: this.acceptReceive.bind(this, address) - }; - - var deviceName = ''; - var self = this; - this.getPairedDevice(function getPairedDeviceComplete() { - deviceName = self.getDeviceName(address); - CustomDialog.show(_('acceptFileTransfer'), - _('wantToReceiveFile', - { deviceName: deviceName, - fileName: fileName, - fileSize: fileSize }), - cancel, confirm); - }); - }, - - declineReceive: function bt_declineReceive(address) { - CustomDialog.hide(); - var adapter = Bluetooth.getAdapter(); - if (adapter != null) { - adapter.confirmReceivingFile(address, false); - } else { - var msg = 'Cannot get adapter from system Bluetooth monitor.'; - this.debug(msg); - } - }, - - acceptReceive: function bt_acceptReceive(address, fileSize) { - CustomDialog.hide(); - var adapter = Bluetooth.getAdapter(); - if (adapter != null) { - adapter.confirmReceivingFile(address, true); - } else { - var msg = 'Cannot get adapter from system Bluetooth monitor.'; - this.debug(msg); - } - }, - - showStorageUnavaliablePrompt: function bt_showStorageUnavaliablePrompt(msg) { - var _ = navigator.mozL10n.get; - var confirm = { - title: _('confirm'), - callback: function() { - CustomDialog.hide(); - } - }; - - var body = msg; - CustomDialog.show(_('cannotReceiveFile'), body, confirm); - }, - - checkStorageSpace: function bt_checkStorageSpace(fileSize, callback) { - if (!callback) - return; - - var _ = navigator.mozL10n.get; - var storage = this._deviceStorage; - - var availreq = storage.available(); - availreq.onsuccess = function(e) { - switch (availreq.result) { - case 'available': - // skip down to the code below - break; - case 'unavailable': - callback(false, _('sdcard-not-exist')); - return; - case 'shared': - callback(false, _('sdcard-in-use')); - return; - default: - callback(false, _('unknown-error')); - return; - } - - // If we get here, then the sdcard is available, so we need to find out - // if there is enough free space on it - var freereq = storage.freeSpace(); - freereq.onsuccess = function() { - if (freereq.result >= fileSize) - callback(true, ''); - else - callback(false, _('sdcard-no-space2')); - }; - freereq.onerror = function() { - callback(false, _('cannotGetStorageState')); - }; - }; - - availreq.onerror = function(e) { - callback(false, _('cannotGetStorageState')); - }; - }, - - onUpdateProgress: function bt_onUpdateProgress(mode, evt) { - switch (mode) { - case 'start': - var transferInfo = evt.detail.transferInfo; - this.initProgress(transferInfo); - break; - - case 'progress': - var address = evt.address; - var processedLength = evt.processedLength; - var fileLength = evt.fileLength; - var progress = 0; - if (fileLength == 0) { - //XXX: May need to handle unknow progress - } else if (processedLength > fileLength) { - // According Bluetooth spec., - // the processed length is a referenced value only. - // XXX: If processed length is bigger than file length, - // show an unknown progress - } else { - progress = processedLength / fileLength; - } - this.updateProgress(progress, evt); - break; - } - }, - - initProgress: function bt_initProgress(evt) { - var _ = navigator.mozL10n.get; - // Create progress dynamically in notification center - var address = evt.address; - var transferMode = - (evt.received == true) ? - _('bluetooth-receiving-progress') : _('bluetooth-sending-progress'); - var content = - '' + - '
' + transferMode + '
' + - // XXX: Bug 804533 - [Bluetooth] - // Need sending/receiving icon for Bluetooth file transfer - ''; - - var transferTask = document.createElement('div'); - transferTask.id = 'bluetooth-transfer-status'; - transferTask.className = 'notification'; - transferTask.setAttribute('data-id', address); - transferTask.innerHTML = content; - transferTask.addEventListener('click', - this.onCancelTransferTask.bind(this)); - this.transferStatusList.appendChild(transferTask); - }, - - updateProgress: function bt_updateProgress(value, evt) { - var address = evt.address; - var id = 'div[data-id="' + address + '"] progress'; - var progressEl = this.transferStatusList.querySelector(id); - progressEl.value = value; - }, - - removeProgress: function bt_removeProgress(evt) { - var address = evt.address; - var id = 'div[data-id="' + address + '"]'; - var finishedTask = this.transferStatusList.querySelector(id); - finishedTask.removeEventListener('click', - this.onCancelTransferTask.bind(this)); - this.transferStatusList.removeChild(finishedTask); - }, - - showBanner: function bt_showBanner(isComplete) { - var _ = navigator.mozL10n.get; - var status = (isComplete) ? 'complete' : 'failed'; - this.banner.addEventListener('animationend', function animationend() { - this.banner.removeEventListener('animationend', animationend); - this.banner.classList.remove('visible'); - }.bind(this)); - this.bannerContainer.textContent = _('bluetooth-file-transfer-result', - { status: status }); - this.banner.classList.add('visible'); - }, - - onCancelTransferTask: function bt_onCancelTransferTask(evt) { - var id = evt.target.dataset.id; - // Show confirm dialog for user to cancel transferring task - UtilityTray.hide(); - this.showCancelTransferPrompt(id); - }, - - showCancelTransferPrompt: function bt_showCancelTransferPrompt(address) { - var _ = navigator.mozL10n.get; - - var cancel = { - title: _('continue'), - callback: this.continueTransfer.bind(this) - }; - - var confirm = { - title: _('cancel'), - callback: this.cancelTransfer.bind(this, address) - }; - - CustomDialog.show(_('cancelFileTransfer'), _('cancelFileTransfer'), - cancel, confirm); - }, - - continueTransfer: function bt_continueTransfer() { - CustomDialog.hide(); - }, - - cancelTransfer: function bt_cancelTransfer(address) { - CustomDialog.hide(); - var adapter = Bluetooth.getAdapter(); - if (adapter != null) { - adapter.stopSendingFile(address); - } else { - var msg = 'Cannot get adapter from system Bluetooth monitor.'; - this.debug(msg); - } - }, - - onTransferComplete: function bt_onTransferComplete(evt) { - var transferInfo = evt.detail.transferInfo; - var _ = navigator.mozL10n.get; - // Remove transferring progress - this.removeProgress(transferInfo); - var fileName = - (transferInfo.fileName) ? transferInfo.fileName : _('unknown-file'); - var icon = 'style/bluetooth_transfer/images/icon_bluetooth.png'; - // Show banner and notification - if (transferInfo.success == true) { - // Show completed message of transferred result on the banner - this.showBanner(true); - if (transferInfo.received) { - // Received file can be opened only - // TODO: Need to modify the icon after visual provide - NotificationHelper.send(_('transferFinished-receivedSuccessful-title'), - fileName, - icon, - this.openReceivedFile.bind(this, transferInfo)); - } else { - NotificationHelper.send(_('transferFinished-sentSuccessful-title'), - fileName, - icon); - } - } else { - // Show failed message of transferred result on the banner - this.showBanner(false); - if (transferInfo.received) { - NotificationHelper.send(_('transferFinished-receivedFailed-title'), - fileName, - icon); - } else { - NotificationHelper.send(_('transferFinished-sentFailed-title'), - fileName, - icon); - } - } - }, - - openReceivedFile: function bt_openReceivedFile(evt) { - // Launch the gallery with an open activity to view this specific photo - // XXX: The prefix file path should be refined when API is ready to provide - var filePath = 'downloads/bluetooth/' + evt.fileName; - var contentType = evt.contentType; - var storageType = 'sdcard'; - var self = this; - var storage = navigator.getDeviceStorage(storageType); - var getreq = storage.get(filePath); - - getreq.onerror = function() { - var msg = 'failed to get file:' + - filePath + getreq.error.name + - a.error.name; - self.debug(msg); - }; - - getreq.onsuccess = function() { - var file = getreq.result; - // When we got the file by storage type of "sdcard" - // use the file.type to replace the empty fileType which is given by API - var fileType = ''; - var fileName = file.name; - if (contentType != '' && contentType != 'image/*') { - fileType = contentType; - } else { - var fileNameExtension = - fileName.substring(fileName.lastIndexOf('.') + 1); - if (file.type != '') { - fileType = file.type; - // Refine the file type to "audio/ogg" when the file format is *.ogg - if (fileType == 'video/ogg' && - (fileNameExtension.indexOf('ogg') != -1)) { - fileType == 'audio/ogg'; - } - } else { - // Parse Filename Extension to find out MIMETYPE - // Following formats are supported by Gallery and Music APPs - var imageFormatList = ['jpg', 'jpeg', 'png']; - var audioFormatList = ['mp3', 'ogg', 'aac', 'mp4', 'm4a']; - var imageFormatIndex = imageFormatList.indexOf(fileNameExtension); - switch (imageFormatIndex) { - case 0: - case 1: - // The file type of format *.jpg, *.jpeg should be "image/jpeg" - fileType = 'image/jpeg'; - break; - case 2: - // The file type of format *.png should be "image/png" - fileType = 'image/png'; - break; - } - - var audioFormatIndex = audioFormatList.indexOf(fileNameExtension); - switch (audioFormatIndex) { - case 0: - // The file type of format *.mp3 should be "audio/mpeg" - fileType = 'audio/mpeg'; - break; - case 1: - // The file type of format *.ogg should be "audio/ogg" - fileType = 'audio/ogg'; - break; - case 2: - case 3: - case 4: - // The file type of format *.acc, *.mp4, *.m4a - // should be "audio/mp4" - fileType = 'audio/mp4'; - break; - } - } - } - - var a = new MozActivity({ - name: 'open', - data: { - type: fileType, - blob: file, - // XXX: https://bugzilla.mozilla.org/show_bug.cgi?id=812098 - // Pass the file name for Music APP since it can not open blob - filename: file.name - } - }); - - a.onerror = function(e) { - var msg = 'open activity error:' + a.error.name; - self.debug(msg); - // Cannot identify MIMETYPE - // So, show cannot open file dialog with unknow media type - UtilityTray.hide(); - self.showUnknownMediaPrompt(fileName); - }; - a.onsuccess = function(e) { - var msg = 'open activity onsuccess'; - self.debug(msg); - }; - }; - }, - - showUnknownMediaPrompt: function bt_showUnknownMediaPrompt(fileName) { - var _ = navigator.mozL10n.get; - var confirm = { - title: _('confirm'), - callback: function() { - CustomDialog.hide(); - } - }; - - var body = _('unknownMediaTypeToOpen') + ' ' + fileName; - CustomDialog.show(_('cannotOpenFile'), body, confirm); - } -}; - -BluetoothTransfer.init(); diff --git a/apps/system/js/bootstrap.js b/apps/system/js/bootstrap.js deleted file mode 100644 index 21e2238..0000000 --- a/apps/system/js/bootstrap.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -window.addEventListener('load', function startup() { - function safelyLaunchFTU() { - WindowManager.retrieveHomescreen(WindowManager.retrieveFTU); - } - - if (Applications.ready) { - safelyLaunchFTU(); - } else { - window.addEventListener('applicationready', function appListReady(event) { - window.removeEventListener('applicationready', appListReady); - safelyLaunchFTU(); - }); - } - - window.addEventListener('ftudone', function doneWithFTU() { - window.removeEventListener('ftudone', doneWithFTU); - - var lock = window.navigator.mozSettings.createLock(); - lock.set({ - 'gaia.system.checkForUpdates': true - }); - }); - - SourceView.init(); - Shortcuts.init(); - ScreenManager.turnScreenOn(); - - // We need to be sure to get the focus in order to wake up the screen - // if the phone goes to sleep before any user interaction. - // Apparently it works because no other window has the focus at this point. - window.focus(); - - // This is code copied from - // http://dl.dropbox.com/u/8727858/physical-events/index.html - // It appears to workaround the Nexus S bug where we're not - // getting orientation data. See: - // https://bugzilla.mozilla.org/show_bug.cgi?id=753245 - // It seems it needs to be in both window_manager.js and bootstrap.js. - function dumbListener2(event) {} - window.addEventListener('devicemotion', dumbListener2); - - window.setTimeout(function() { - window.removeEventListener('devicemotion', dumbListener2); - }, 2000); -}); - -/* === Shortcuts === */ -/* For hardware key handling that doesn't belong to anywhere */ -var Shortcuts = { - init: function rm_init() { - window.addEventListener('keyup', this); - }, - - handleEvent: function rm_handleEvent(evt) { - if (!ScreenManager.screenEnabled || evt.keyCode !== evt.DOM_VK_F6) - return; - - document.location.reload(); - } -}; - -/* === Localization === */ -/* set the 'lang' and 'dir' attributes to when the page is translated */ -window.addEventListener('localized', function onlocalized() { - document.documentElement.lang = navigator.mozL10n.language.code; - document.documentElement.dir = navigator.mozL10n.language.direction; -}); - -// Define the default background to use for all homescreens -SettingsListener.observe( - 'wallpaper.image', - 'resources/images/backgrounds/default.png', - function setWallpaper(value) { - document.getElementById('screen').style.backgroundImage = - 'url(' + value + ')'; - } -); diff --git a/apps/system/js/call_forwarding.js b/apps/system/js/call_forwarding.js deleted file mode 100644 index ee46def..0000000 --- a/apps/system/js/call_forwarding.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */ -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -(function() { - - // 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 settings = window.navigator.mozSettings; - if (!settings) { - return; - } - var mobileconnection = window.navigator.mozMobileConnection; - if (!mobileconnection) { - return; - } - - mobileconnection.addEventListener('cfstatechange', function(event) { - if (event && - event.reason == _cfReason.CALL_FORWARD_REASON_UNCONDITIONAL) { - var enabled = false; - if (event.success && - (event.action == _cfAction.CALL_FORWARD_ACTION_REGISTRATION || - event.action == _cfAction.CALL_FORWARD_ACTION_ENABLE)) { - enabled = true; - } - settings.createLock().set({'ril.cf.enabled': enabled}); - } - }); - -})(); diff --git a/apps/system/js/captive_portal.js b/apps/system/js/captive_portal.js deleted file mode 100644 index b23cb0d..0000000 --- a/apps/system/js/captive_portal.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*Mode: js; js-indent-level: 2; indent-tabs-mode: nil -**/ -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -'use strict'; - -var CaptivePortalLogin = (function() { - var eventId; - var isManualConnect = false; - var settings = window.navigator.mozSettings; - var notification = null; - var wifiManager = window.navigator.mozWifiManager; - 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 message = _('captive-wifi-available', { networkName: networkName}); - if (!isManualConnect) { - notification = NotificationScreen.addNotification({ - id: id, title: '', text: message, icon: null - }); - captiveNotification_onTap = function() { - notification.removeEventListener('tap', captiveNotification_onTap); - captiveNotification_onTap = null; - NotificationScreen.removeNotification(id); - new MozActivity({ - 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 } - }); - } - } - - function handleLoginAbort(id) { - if (id === eventId && notification) { - if (notification.parentNode) { - if (captiveNotification_onTap) { - notification.removeEventListener('tap', captiveNotification_onTap); - captiveNotification_onTap = null; - } - NotificationScreen.removeNotification(id); - notification = null; - } - } - } - - window.addEventListener('mozChromeEvent', function handleChromeEvent(e) { - switch (e.detail.type) { - case 'captive-portal-login': - handleLogin(e.detail.id, e.detail.url); - break; - case 'captive-portal-login-abort': - handleLoginAbort(e.detail.id); - break; - } - }); - - // 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; - }); -})(); diff --git a/apps/system/js/cards_view.js b/apps/system/js/cards_view.js deleted file mode 100644 index 8bce02b..0000000 --- a/apps/system/js/cards_view.js +++ /dev/null @@ -1,676 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -// -// CardsView is responsible for managing opened apps -// - -'use strict'; - -var CardsView = (function() { - - //display icon of an app on top of app's card - var DISPLAY_APP_ICON = false; - var USER_DEFINED_ORDERING = false; - // If 'true', scrolling moves the list one card - // at time, and snaps the list so the current card - // is centered in the view - // If 'false', use free, physics-based scrolling - // (Gaia default) - var SNAPPING_SCROLLING = true; - // if 'true' user can close the app - // by dragging it upwards - var MANUAL_CLOSING = true; - - var cardsView = document.getElementById('cards-view'); - var screenElement = document.getElementById('screen'); - var cardsList = cardsView.firstElementChild; - var displayedApp; - var runningApps; - // Unkillable apps which have attention screen now - var attentionScreenApps = []; - // Card which we are re-ordering now - var reorderedCard = null; - var currentDisplayed = 0; - // Timer between scrolling CardList further, - // when reordering Cards - var scrollWhileSortingTimer; - // We don't allow user to scroll CardList - // before the timer ticks while in reordering - // mode - var allowScrollingWhileSorting = false; - // Initial margin of the reordered card - var dragMargin = 0; - // Are we reordering or removing the card now? - var draggingCardUp = false; - // Are we moving card left or right? - var sortingDirection; - // List of sorted apps - var userSortedApps = []; - var HVGA = document.documentElement.clientWidth < 480; - var cardsViewShown = false; - - // init events - var gd = new GestureDetector(cardsView); - gd.startDetecting(); - - // A list of all the URLs we've created via URL.createObjectURL which we - // haven't yet revoked. - var screenshotObjectURLs = []; - - /* - * Returns an icon URI - * - * @param{String} the app's origin - */ - function getIconURI(origin) { - var icons = runningApps[origin].manifest.icons; - if (!icons) { - return null; - } - - var sizes = Object.keys(icons).map(function parse(str) { - return parseInt(str, 10); - }); - - sizes.sort(function(x, y) { return y - x; }); - - var index = sizes[(HVGA) ? sizes.length - 1 : 0]; - var iconPath = icons[index]; - - if (iconPath.indexOf('data:') !== 0) { - iconPath = origin + iconPath; - } - - return iconPath; - } - - // Build and display the card switcher overlay - // Note that we rebuild the switcher each time we need it rather - // than trying to keep it in sync with app launches. Performance is - // not an issue here given that the user has to hold the HOME button down - // for one second before the switcher will appear. - function showCardSwitcher() { - if (cardSwitcherIsShown()) - return; - - // events to handle - window.addEventListener('lock', CardsView); - - // Close utility tray if it is opened. - UtilityTray.hide(true); - - // Apps info from WindowManager - displayedApp = WindowManager.getDisplayedApp(); - currentDisplayed = 0; - runningApps = WindowManager.getRunningApps(); - - // Switch to homescreen - WindowManager.launch(null); - cardsViewShown = true; - - // If user is not able to sort apps manualy, - // display most recetly active apps on the far left - if (!USER_DEFINED_ORDERING) { - var sortable = []; - for (var origin in runningApps) - sortable.push({origin: origin, app: runningApps[origin]}); - - sortable.sort(function(a, b) { - return b.app.launchTime - a.app.launchTime; - }); - runningApps = {}; - - // I assume that object properties are enumerated in - // the same order they were defined. - // There is nothing about that in spec, but I've never - // seen any unexpected behavior. - sortable.forEach(function(element) { - runningApps[element.origin] = element.app; - }); - - // First add an item to the cardsList for each running app - for (var origin in runningApps) { - addCard(origin, runningApps[origin], function showCards() { - screenElement.classList.add('cards-view'); - cardsView.classList.add('active'); - }); - } - - } else { // user ordering - - // first run - if (userSortedApps.length === 0) { - for (var origin in runningApps) { - userSortedApps.push(origin); - } - } else { - for (var origin in runningApps) { - // if we have some new app opened - if (userSortedApps.indexOf(origin) === -1) { - userSortedApps.push(origin); - } - } - } - - userSortedApps.forEach(function(origin) { - addCard(origin, runningApps[origin], function showCards() { - screenElement.classList.add('cards-view'); - cardsView.classList.add('active'); - }); - }); - - cardsView.addEventListener('contextmenu', CardsView); - - } - - if (SNAPPING_SCROLLING) { - cardsView.style.overflow = 'hidden'; //disabling native scrolling - } - - if (SNAPPING_SCROLLING || MANUAL_CLOSING) { - cardsView.addEventListener('mousedown', CardsView); - } - - // Make sure we're in portrait mode - screen.mozLockOrientation('portrait-primary'); - - // If there is a displayed app, take keyboard focus away - if (displayedApp) - runningApps[displayedApp].frame.blur(); - - function addCard(origin, app, displayedAppCallback) { - // Display card switcher background first to make user focus on the - // frame closing animation without disturbing by homescreen display. - if (displayedApp == origin && displayedAppCallback) { - setTimeout(displayedAppCallback); - } - // Not showing homescreen - if (app.frame.classList.contains('homescreen')) { - return; - } - - // Build a card representation of each window. - // And add it to the card switcher - var card = document.createElement('li'); - card.classList.add('card'); - card.dataset.origin = origin; - - //display app icon on the tab - if (DISPLAY_APP_ICON) { - var iconURI = getIconURI(origin); - if (iconURI) { - var appIcon = document.createElement('img'); - appIcon.classList.add('appIcon'); - appIcon.src = iconURI; - card.appendChild(appIcon); - } - } - - var title = document.createElement('h1'); - title.textContent = app.name; - card.appendChild(title); - - var frameForScreenshot = app.iframe; - - if (PopupManager.getPopupFromOrigin(origin)) { - var popupFrame = PopupManager.getPopupFromOrigin(origin); - frameForScreenshot = popupFrame; - - var subtitle = document.createElement('p'); - subtitle.textContent = - PopupManager.getOpenedOriginFromOpener(origin); - card.appendChild(subtitle); - card.classList.add('popup'); - } else if (getOffOrigin(app.frame.dataset.url ? - app.frame.dataset.url : app.frame.src, origin)) { - var subtitle = document.createElement('p'); - subtitle.textContent = getOffOrigin(app.frame.dataset.url ? - app.frame.dataset.url : app.frame.src, origin); - card.appendChild(subtitle); - } - - if (TrustedUIManager.hasTrustedUI(origin)) { - var popupFrame = TrustedUIManager.getDialogFromOrigin(origin); - frameForScreenshot = popupFrame.frame; - var header = document.createElement('section'); - header.setAttribute('role', 'region'); - header.classList.add('skin-organic'); - header.innerHTML = '

' + popupFrame.name; - header.innerHTML += '

'; - card.appendChild(header); - card.classList.add('trustedui'); - } else if (attentionScreenApps.indexOf(origin) == -1) { - var closeButton = document.createElement('div'); - closeButton.classList.add('close-card'); - card.appendChild(closeButton); - } - - cardsList.appendChild(card); - // rect is the final size (considering CSS transform) of the card. - var rect = card.getBoundingClientRect(); - - // And then switch it with screenshots when one will be ready - // (instead of -moz-element backgrounds) - frameForScreenshot.getScreenshot(rect.width, rect.height).onsuccess = - function gotScreenshot(screenshot) { - if (screenshot.target.result) { - var objectURL = URL.createObjectURL(screenshot.target.result); - screenshotObjectURLs.push(objectURL); - card.style.backgroundImage = 'url(' + objectURL + ')'; - } - }; - - // Set up event handling - // A click elsewhere in the card switches to that task - card.addEventListener('tap', runApp); - } - } - - function runApp(e) { - // Handle close events - if (e.target.classList.contains('close-card')) { - var element = e.target.parentNode; - cardsList.removeChild(element); - closeApp(element, true); - return; - } - - var origin = this.dataset.origin; - alignCard(currentDisplayed, function cardAligned() { - WindowManager.launch(origin); - }); - } - - function closeApp(element, removeImmediately) { - // Stop the app itself - WindowManager.kill(element.dataset.origin); - - // Fix for non selectable cards when we remove the last card - // Described in https://bugzilla.mozilla.org/show_bug.cgi?id=825293 - if (cardsList.children.length === currentDisplayed) { - currentDisplayed--; - } - - // If there are no cards left, then dismiss the task switcher. - if (!cardsList.children.length) - hideCardSwitcher(removeImmediately); - } - - function getOriginObject(url) { - var parser = document.createElement('a'); - parser.href = url; - - return { - protocol: parser.protocol, - hostname: parser.hostname, - port: parser.port - }; - } - - function getOffOrigin(src, origin) { - // Use src and origin as cache key - var cacheKey = JSON.stringify(Array.prototype.slice.call(arguments)); - if (!getOffOrigin.cache[cacheKey]) { - var native = getOriginObject(origin); - var current = getOriginObject(src); - if (current.protocol == 'http:') { - // Display http:// protocol anyway - getOffOrigin.cache[cacheKey] = current.protocol + '//' + - current.hostname; - } else if (native.protocol == current.protocol && - native.hostname == current.hostname && - native.port == current.port) { - // Same origin policy - getOffOrigin.cache[cacheKey] = ''; - } else if (current.protocol == 'app:') { - // Avoid displaying app:// protocol - getOffOrigin.cache[cacheKey] = ''; - } else { - getOffOrigin.cache[cacheKey] = current.protocol + '//' + - current.hostname; - } - } - - return getOffOrigin.cache[cacheKey]; - } - - getOffOrigin.cache = {}; - - function hideCardSwitcher(removeImmediately) { - if (!cardSwitcherIsShown()) - return; - - // events to handle - window.removeEventListener('lock', CardsView); - - // Make the cardsView overlay inactive - cardsView.classList.remove('active'); - cardsViewShown = false; - - // Release our screenshot blobs. - screenshotObjectURLs.forEach(function(url) { - URL.revokeObjectURL(url); - }); - screenshotObjectURLs = []; - - // And remove all the cards from the document after the transition - function removeCards() { - cardsView.removeEventListener('transitionend', removeCards); - screenElement.classList.remove('cards-view'); - - while (cardsList.firstElementChild) { - cardsList.removeChild(cardsList.firstElementChild); - } - } - if (removeImmediately) { - removeCards(); - } else { - cardsView.addEventListener('transitionend', removeCards); - } - } - - function cardSwitcherIsShown() { - return cardsViewShown; - } - - //scrolling cards - var initialCardViewPosition; - var initialTouchPosition = {}; - var threshold = window.innerWidth / 4; - // Distance after which dragged card starts moving - var moveCardThreshold = window.innerHeight / 6; - var removeCardThreshold = window.innerHeight / 4; - - function alignCard(number, callback) { - if (!cardsList.children[number]) - return; - - var scrollLeft = cardsView.scrollLeft; - var targetScrollLeft = cardsList.children[number].offsetLeft; - - if (Math.abs(scrollLeft - targetScrollLeft) < 4) { - cardsView.scrollLeft = cardsList.children[number].offsetLeft; - if (callback) - callback(); - return; - } - - cardsView.scrollLeft = scrollLeft + (targetScrollLeft - scrollLeft) / 2; - - window.mozRequestAnimationFrame(function newFrameCallback() { - alignCard(number, callback); - }); - } - - function onStartEvent(evt) { - evt.stopPropagation(); - evt.target.setCapture(true); - cardsView.addEventListener('mousemove', CardsView); - cardsView.addEventListener('swipe', CardsView); - - initialCardViewPosition = cardsView.scrollLeft; - initialTouchPosition = { - x: evt.touches ? evt.touches[0].pageX : evt.pageX, - y: evt.touches ? evt.touches[0].pageY : evt.pageY - }; - } - - function onMoveEvent(evt) { - evt.stopPropagation(); - var touchPosition = { - x: evt.touches ? evt.touches[0].pageX : evt.pageX, - y: evt.touches ? evt.touches[0].pageY : evt.pageY - }; - - if (evt.target.classList.contains('card') && MANUAL_CLOSING) { - var differenceY = initialTouchPosition.y - touchPosition.y; - if (differenceY > moveCardThreshold) { - // We don't want user to scroll the CardsView when one of the card is - // already dragger upwards - draggingCardUp = true; - evt.target.style.MozTransform = 'scale(0.6) translate(0, -' + - differenceY + 'px)'; - } - } - - // If we are not reordering or removing Cards now - // and Snapping Scrolling is enabled, we want to scroll - // the CardList - if (SNAPPING_SCROLLING && reorderedCard === null && !draggingCardUp) { - var differenceX = initialTouchPosition.x - touchPosition.x; - cardsView.scrollLeft = initialCardViewPosition + differenceX; - } - - // If re are in reordering mode (there is a DOM element in) - // reorderedCard variable) we are able to put this element somewere - // among the others - if (USER_DEFINED_ORDERING && reorderedCard !== null) { - var differenceX = touchPosition.x - initialTouchPosition.x; - // Probably there is more clever solution for calculating - // position of transformed DOM element, but this was my - // first thought and it seems to work - var moveOffset = (cardsList.children[currentDisplayed].offsetLeft / 0.6) + - differenceX - (dragMargin / 0.6); - - reorderedCard.style.MozTransform = - 'scale(0.6) translate(' + moveOffset + 'px, 0)'; - - if (Math.abs(differenceX) > threshold) { - // We don't want to jump to the next page immediately, - // We are waiting half a second for user to decide if - // he wants to leave the Card here or scroll further - if (allowScrollingWhileSorting) { - allowScrollingWhileSorting = false; - - scrollWhileSortingTimer = setTimeout(function() { - allowScrollingWhileSorting = true; - }, 500); - - if (differenceX > 0 && - currentDisplayed <= cardsList.children.length) { - currentDisplayed++; - sortingDirection = 'right'; - alignCard(currentDisplayed); - } else if (differenceX < 0 && currentDisplayed > 0) { - currentDisplayed--; - sortingDirection = 'left'; - alignCard(currentDisplayed); - } - } - } - } - } - - function onEndEvent(evt) { - evt.stopPropagation(); - var element = evt.target; - var eventDetail = evt.detail; - var direction = eventDetail.direction; - - document.releaseCapture(); - cardsView.removeEventListener('mousemove', CardsView); - cardsView.removeEventListener('swipe', CardsView); - - var touchPosition = { - x: eventDetail.end.pageX, - y: eventDetail.end.pageY - }; - - if (SNAPPING_SCROLLING && !draggingCardUp && reorderedCard === null) { - if (Math.abs(eventDetail.dx) > threshold) { - if ( - direction === 'left' && - currentDisplayed < cardsList.children.length - 1 - ) { - currentDisplayed++; - alignCard(currentDisplayed); - } else if (direction === 'right' && currentDisplayed > 0) { - currentDisplayed--; - alignCard(currentDisplayed); - } - } else { - alignCard(currentDisplayed); - } - } - - // if the element we start dragging on - // is a card and we are not in reordering mode - if ( - element.classList.contains('card') && - MANUAL_CLOSING && - reorderedCard === null - ) { - - draggingCardUp = false; - // Prevent user from closing the app with a attention screen - if (-eventDetail.dy > removeCardThreshold && - attentionScreenApps.indexOf(element.dataset.origin) == -1 - ) { - - // remove the app also from the ordering list - if ( - userSortedApps.indexOf(element.dataset.origin) !== -1 && - USER_DEFINED_ORDERING - ) { - userSortedApps.splice( - userSortedApps.indexOf(element.dataset.origin), - 1 - ); - } - - // Without removing the listener before closing card - // sometimes the 'click' event fires, even if 'mouseup' - // uses stopPropagation() - element.removeEventListener('tap', runApp); - - // Remove the icon from the task list - cardsList.removeChild(element); - - closeApp(element); - - return; - } else { - element.style.MozTransform = ''; - } - } - - if (USER_DEFINED_ORDERING && reorderedCard !== null) { - // Position of the card depends on direction of scrolling - if (sortingDirection === 'right') { - if (currentDisplayed <= cardsList.children.length) { - cardsList.insertBefore( - reorderedCard, - cardsList.children[currentDisplayed + 1] - ); - } else { - cardsList.appendChild(reorderedCard); - } - } else if (sortingDirection === 'left') { - cardsList.insertBefore( - reorderedCard, - cardsList.children[currentDisplayed] - ); - } - reorderedCard.style.MozTransform = ''; - reorderedCard.dataset['edit'] = 'false'; - reorderedCard = null; - - alignCard(currentDisplayed); - - // remove the app origin from ordering array - userSortedApps.splice( - userSortedApps.indexOf(element.dataset.origin), - 1 - ); - // and put in on the new position - userSortedApps.splice(currentDisplayed, 0, element.dataset.origin); - } - } - - function manualOrderStart(evt) { - evt.preventDefault(); - reorderedCard = evt.target; - allowScrollingWhileSorting = true; - if (reorderedCard.classList.contains('card')) { - dragMargin = reorderedCard.offsetLeft; - reorderedCard.dataset['edit'] = true; - sortingDirection = 'left'; - } - } - - window.addEventListener('applicationuninstall', - function removeUninstaledApp(evt) { - var origin = evt.detail.application.origin; - if (userSortedApps.indexOf(origin) !== -1) { - userSortedApps.splice(userSortedApps.indexOf(origin), 1); - } - }, - false); - - function cv_handleEvent(evt) { - switch (evt.type) { - case 'mousedown': - onStartEvent(evt); - break; - - case 'mousemove': - onMoveEvent(evt); - break; - - case 'swipe': - onEndEvent(evt); - break; - - case 'contextmenu': - manualOrderStart(evt); - break; - - case 'home': - if (!cardSwitcherIsShown()) - return; - - evt.stopImmediatePropagation(); - hideCardSwitcher(); - break; - - case 'lock': - case 'attentionscreenshow': - attentionScreenApps = AttentionScreen.getAttentionScreenOrigins(); - hideCardSwitcher(); - break; - - case 'attentionscreenhide': - attentionScreenApps = AttentionScreen.getAttentionScreenOrigins(); - break; - - case 'holdhome': - if (LockScreen.locked) - return; - - SleepMenu.hide(); - showCardSwitcher(); - break; - - case 'appwillopen': - hideCardSwitcher(); - break; - } - } - - // Public API of CardsView - return { - showCardSwitcher: showCardSwitcher, - hideCardSwitcher: hideCardSwitcher, - cardSwitcherIsShown: cardSwitcherIsShown, - handleEvent: cv_handleEvent - }; -})(); - -window.addEventListener('attentionscreenshow', CardsView); -window.addEventListener('attentionscreenhide', CardsView); -window.addEventListener('holdhome', CardsView); -window.addEventListener('home', CardsView); -window.addEventListener('appwillopen', CardsView); - diff --git a/apps/system/js/context_menu.js b/apps/system/js/context_menu.js deleted file mode 100644 index 816ef71..0000000 --- a/apps/system/js/context_menu.js +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -var ContextMenu = { - init: function cm_init() { - window.addEventListener('mozbrowsercontextmenu', this, true); - }, - - handleEvent: function cm_handleEvent(evt) { - var detail = evt.detail; - if (detail.contextmenu.items.length == 0) - return; - - var onsuccess = function(action) { - detail.contextMenuItemSelected(action); - }; - - ListMenu.request(detail.contextmenu.items, '', onsuccess); - } -}; - -ContextMenu.init(); diff --git a/apps/system/js/cost_control.js b/apps/system/js/cost_control.js deleted file mode 100644 index 0f07962..0000000 --- a/apps/system/js/cost_control.js +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -(function() { - - 'use strict'; - - var host = document.location.host; - var domain = host.replace(/(^[\w\d]+\.)?([\w\d]+\.[a-z]+)/, '$2'); - var protocol = document.location.protocol + '//'; - var origin = protocol + 'costcontrol.' + domain; - - var widgetContainer = document.getElementById('cost-control-widget'); - - var widgetFrame; - function _ensureWidget() { - if (!Applications.ready) - return; - - // Check widget is there - widgetFrame = widgetContainer.querySelector('iframe'); - if (widgetFrame && !widgetFrame.dataset.killed) - return; - - // Create the widget - if (!widgetFrame) { - widgetFrame = document.createElement('iframe'); - widgetFrame.addEventListener('mozbrowsererror', - function ccdriver_onError(e) { - e.target.dataset.killed = true; - } - ); - } - - widgetFrame.dataset.frameType = 'widget'; - widgetFrame.dataset.frameOrigin = origin; - delete widgetFrame.dataset.killed; - - widgetFrame.setAttribute('mozbrowser', true); - widgetFrame.setAttribute('remote', 'true'); - widgetFrame.setAttribute('mozapp', origin + '/manifest.webapp'); - - widgetFrame.src = origin + '/widget.html'; - widgetContainer.appendChild(widgetFrame); - - _adjustWidgetPosition(); - } - - function _showWidget() { - _ensureWidget(); - widgetFrame.setVisible(true); - } - - function _hideWidget() { - if (widgetFrame) { - widgetFrame.setVisible(false); - } - } - - function _adjustWidgetPosition() { - // TODO: Remove this when weird bug #809031 (Bugzilla) is solved - // See cost_control.css as well to remove the last rule - var offsetY = document.getElementById('notification-bar').clientHeight; - offsetY += - document.getElementById('notifications-container').clientHeight; - widgetFrame.style.transform = 'translate(0, ' + offsetY + 'px)'; - } - - // Listen to utilitytray show - window.addEventListener('utilitytrayshow', _showWidget); - window.addEventListener('utilitytrayhide', _hideWidget); - - window.addEventListener('applicationready', function _onReady() { - asyncStorage.getItem('ftu.enabled', function _onValue(enabled) { - if (enabled !== false) { - window.addEventListener('ftudone', function ftudone(e) { - window.removeEventListener('ftudone', ftudone); - _ensureWidget(); - widgetFrame.setVisible(false); - }); - } else { - _ensureWidget(); - widgetFrame.setVisible(false); - } - }); - }); - - window.addEventListener('resize', _adjustWidgetPosition); -}()); diff --git a/apps/system/js/crash_reporter.js b/apps/system/js/crash_reporter.js deleted file mode 100644 index 4068291..0000000 --- a/apps/system/js/crash_reporter.js +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */ -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -// This file calls getElementById without waiting for an onload event, so it -// must have a defer attribute or be included at the end of the . - -var CrashReporter = (function() { - var _ = navigator.mozL10n.get; - var settings = navigator.mozSettings; - var screen = document.getElementById('screen'); - - // The name of the app that just crashed. - var crashedAppName = ''; - - // Whether or not to show a "Report" button in the banner. - var showReportButton = false; - - // Only show the "Report" button if the user hasn't set a preference to - // always/never report crashes. - SettingsListener.observe('app.reportCrashes', 'ask', - function handleCrashSetting(value) { - showReportButton = (value != 'always' && value != 'never'); - }); - - // This function should only ever be called once. - function showDialog(crashID, isChrome) { - var title = isChrome ? _('crash-dialog-os2') : - _('crash-dialog-app', { name: crashedAppName }); - document.getElementById('crash-dialog-title').textContent = title; - - // "Don't Send Report" button in dialog - var noButton = document.getElementById('dont-send-report'); - noButton.addEventListener('click', function onNoButtonClick() { - settings.createLock().set({'app.reportCrashes': 'never'}); - removeDialog(); - }); - - // "Send Report" button in dialog - var yesButton = document.getElementById('send-report'); - yesButton.addEventListener('click', function onYesButtonClick() { - submitCrash(crashID); - if (checkbox.checked) { - settings.createLock().set({'app.reportCrashes': 'always'}); - } - removeDialog(); - }); - - var checkbox = document.getElementById('always-send'); - checkbox.addEventListener('click', function onCheckboxClick() { - // Disable the "Don't Send Report" button if the "Always send..." - // checkbox is checked - noButton.disabled = this.checked; - }); - - // "What's in a crash report?" link - var crashInfoLink = document.getElementById('crash-info-link'); - crashInfoLink.addEventListener('click', function onLearnMoreClick() { - var dialog = document.getElementById('crash-dialog'); - document.getElementById('crash-reports-done'). - addEventListener('click', function onDoneClick() { - this.removeEventListener('click', onDoneClick); - dialog.classList.remove('learn-more'); - }); - dialog.classList.add('learn-more'); - }); - - screen.classList.add('crash-dialog'); - } - - // We can get rid of the dialog after it is shown once. - function removeDialog() { - screen.classList.remove('crash-dialog'); - var dialog = document.getElementById('crash-dialog'); - dialog.parentNode.removeChild(dialog); - } - - function showBanner(crashID, isChrome) { - var message = isChrome ? _('crash-banner-os2') : - _('crash-banner-app', { name: crashedAppName }); - - var button = null; - if (showReportButton) { - button = { - label: _('crash-banner-report'), - callback: function reportCrash() { - submitCrash(crashID); - } - }; - } - - SystemBanner.show(message, button); - } - - function submitCrash(crashID) { - var event = document.createEvent('CustomEvent'); - event.initCustomEvent('mozContentEvent', true, true, { - type: 'submit-crash', - crashID: crashID - }); - window.dispatchEvent(event); - } - - // - Show a dialog only the first time there's a crash to report. - // - On subsequent crashes, show a banner letting the user know there was a - // crash. - // - If the user hasn't set a pref, add a "Report" button to the banner. - function handleCrash(crashID, isChrome) { - // Check to see if we should show a dialog. - var dialogReq = settings.createLock().get('crashReporter.dialogShown'); - dialogReq.onsuccess = function dialogShownSuccess() { - var dialogShown = dialogReq.result['crashReporter.dialogShown']; - if (!dialogShown) { - settings.createLock().set({'crashReporter.dialogShown': true}); - showDialog(crashID, isChrome); - } else { - showBanner(crashID, isChrome); - } - }; - } - - // We depend on window_manager.js calling this function before - // we get a 'handle-crash' event from shell.js - function setAppName(name) { - crashedAppName = name; - } - - // We will be notified of system crashes from shell.js - window.addEventListener('mozChromeEvent', function handleChromeEvent(e) { - if (e.detail.type == 'handle-crash') { - handleCrash(e.detail.crashID, e.detail.chrome); - } - }); - - return { - setAppName: setAppName - }; -})(); - diff --git a/apps/system/js/gridview.js b/apps/system/js/gridview.js deleted file mode 100644 index 399bf3e..0000000 --- a/apps/system/js/gridview.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -var GridView = { - grid: null, - - get visible() { - return this.grid && this.grid.style.display === 'block'; - }, - - hide: function gv_hide() { - if (this.grid) - this.grid.style.visibility = 'hidden'; - }, - - show: function gv_show() { - var grid = this.grid; - if (!grid) { - grid = document.createElement('div'); - grid.id = 'debug-grid'; - grid.dataset.zIndexLevel = 'debug-grid'; - - this.grid = grid; - document.getElementById('screen').appendChild(grid); - } - - grid.style.visibility = 'visible'; - }, - - toggle: function gv_toggle() { - this.visible ? this.hide() : this.show(); - } -}; - -SettingsListener.observe('debug.grid.enabled', false, function(value) { - !!value ? GridView.show() : GridView.hide(); -}); - diff --git a/apps/system/js/hardware_buttons.js b/apps/system/js/hardware_buttons.js deleted file mode 100644 index 3363463..0000000 --- a/apps/system/js/hardware_buttons.js +++ /dev/null @@ -1,318 +0,0 @@ -// hardware_buttons.js: -// -// Gecko code in b2g/chrome/content/shell.js sends mozChromeEvents -// when the user presses or releases a hardware button such as Home, Sleep, -// and Volume Up and Down. -// -// This module listens for those low-level mozChromeEvents, processes them -// and generates higher-level events to handle autorepeat on the volume keys -// long presses on Home and Sleep, and the Home+Sleep key combination. -// -// Other system app modules should listen for the high-level button events -// generated by this module. -// -// The low-level input events processed by this module have type set -// to "mozChromeEvent" and detail.type set to one of: -// -// home-button-press -// home-button-release -// sleep-button-press -// sleep-button-release -// volume-up-button-press -// volume-up-button-release -// volume-down-button-press -// volume-down-button-release -// -// The high-level events generated by this module are simple Event objects -// that are not cancelable and do not bubble. The are dispatched at the -// window object. The type property is set to one of these: -// -// Event Type Meaning -// -------------------------------------------------------------- -// home short press and release of home button -// holdhome long press and hold of home button -// sleep short press and release of sleep button -// wake sleep or home pressed while sleeping -// holdsleep long press and hold of sleep button -// volumeup volume up pressed and released or autorepeated -// volumedown volume down pressed and released or autorepeated -// home+sleep home and sleep pressed at same time (used for screenshots) -// home+volume home and either volume key at the same time (view source) -// -// Because these events are fired at the window object, they cannot be -// captured. Many modules listen for the home event. Those that want -// to respond to it and prevent others from responding should call -// stopImmediatePropagation(). Overlays that want to prevent the window -// manager from showing the homescreen on the home event should call that -// method. Note, however, that this only works for scripts that run and -// register their event handlers before window_manager.js does. -// -'use strict'; - -(function() { - var HOLD_INTERVAL = 750; // How long for press and hold Home or Sleep - var REPEAT_DELAY = 700; // How long before volume autorepeat begins - var REPEAT_INTERVAL = 100; // How fast the autorepeat is. - - // Dispatch a high-level event of the specified type - function fire(type) { - window.dispatchEvent(new Event(type)); - } - - // We process events with a finite state machine. - // Each state object has a process() method for handling events. - // And optionally has enter() and exit() methods called when the FSM - // enters and exits that state - var state; - - // This function transitions to a new state - function setState(s, type) { - // Exit the current state() - if (state && state.exit) - state.exit(type); - state = s; - // Enter the new state - if (state && state.enter) - state.enter(type); - } - - // This event handler listens for hardware button events and passes the - // event type to the process() method of the current state for processing - window.addEventListener('mozChromeEvent', function(e) { - var type = e.detail.type; - switch (type) { - case 'home-button-press': - case 'home-button-release': - case 'sleep-button-press': - case 'sleep-button-release': - case 'volume-up-button-press': - case 'volume-up-button-release': - case 'volume-down-button-press': - case 'volume-down-button-release': - state.process(type); - break; - } - }); - - // The base state is the default, when no hardware buttons are pressed - var baseState = { - process: function(type) { - switch (type) { - case 'home-button-press': - // If the phone is sleeping, then pressing Home wakes it - // (on press, not release) - if (!ScreenManager.screenEnabled) { - fire('wake'); - setState(wakeState, type); - } else { - setState(homeState, type); - } - return; - case 'sleep-button-press': - // If the phone is sleeping, then pressing Sleep wakes it - // (on press, not release) - if (!ScreenManager.screenEnabled) { - fire('wake'); - setState(wakeState, type); - } else { - setState(sleepState, type); - } - return; - case 'volume-up-button-press': - case 'volume-down-button-press': - setState(volumeState, type); - return; - case 'home-button-release': - case 'sleep-button-release': - case 'volume-up-button-release': - case 'volume-down-button-release': - // Ignore button releases that occur in this state. - // These can happen after home+sleep and home+volume. - return; - } - console.error('Unexpected hardware key: ', type); - } - }; - - // We enter the home state when the user presses the Home button - // We can fire home, holdhome, or homesleep events from this state - var homeState = { - timer: null, - enter: function() { - this.timer = setTimeout(function() { - fire('holdhome'); - navigator.vibrate(50); - setState(baseState); - }, HOLD_INTERVAL); - }, - exit: function() { - if (this.timer) { - clearTimeout(this.timer); - this.timer = null; - } - }, - process: function(type) { - switch (type) { - case 'home-button-release': - fire('home'); - navigator.vibrate(50); - setState(baseState, type); - return; - case 'sleep-button-press': - fire('home+sleep'); - setState(baseState, type); - return; - case 'volume-up-button-press': - case 'volume-down-button-press': - fire('home+volume'); - setState(baseState, type); - return; - } - console.error('Unexpected hardware key: ', type); - setState(baseState, type); - } - }; - - // We enter the sleep state when the user presses the Sleep button - // We can fire sleep, holdsleep, or homesleep events from this state - var sleepState = { - timer: null, - enter: function() { - this.timer = setTimeout(function() { - fire('holdsleep'); - setState(baseState); - }, HOLD_INTERVAL); - }, - exit: function() { - if (this.timer) { - clearTimeout(this.timer); - this.timer = null; - } - }, - process: function(type) { - switch (type) { - case 'sleep-button-release': - fire('sleep'); - setState(baseState, type); - return; - case 'home-button-press': - fire('home+sleep'); - setState(baseState, type); - return; - case 'volume-up-button-press': - case 'volume-down-button-press': - setState(volumeState, type); - return; - } - console.error('Unexpected hardware key: ', type); - setState(baseState, type); - } - }; - - // We enter the volume state when the user presses the volume up or - // volume down buttons. - // We can fire volumeup and volumedown events from this state - var volumeState = { - direction: null, - timer: null, - repeating: false, - repeat: function() { - this.repeating = true; - if (this.direction === 'volume-up-button-press') - fire('volumeup'); - else - fire('volumedown'); - this.timer = setTimeout(this.repeat.bind(this), REPEAT_INTERVAL); - }, - enter: function(type) { - var self = this; - this.direction = type; // Is volume going up or down? - this.repeating = false; - this.timer = setTimeout(this.repeat.bind(this), REPEAT_DELAY); - }, - exit: function() { - if (this.timer) { - clearTimeout(this.timer); - this.timer = null; - } - }, - process: function(type) { - switch (type) { - case 'home-button-press': - fire('home+volume'); - setState(baseState, type); - return; - case 'sleep-button-press': - setState(sleepState, type); - return; - case 'volume-up-button-release': - if (this.direction === 'volume-up-button-press') { - if (!this.repeating) - fire('volumeup'); - setState(baseState, type); - return; - } - break; - case 'volume-down-button-release': - if (this.direction === 'volume-down-button-press') { - if (!this.repeating) - fire('volumedown'); - setState(baseState, type); - return; - } - break; - default: - // Ignore anything else (such as sleep button release) - return; - } - console.error('Unexpected hardware key: ', type); - setState(baseState, type); - } - }; - - // We enter this state when the user presses Home or Sleep on a sleeping - // phone. We give immediate feedback by waking the phone up on the press - // rather than waiting for the release, but this means we need a special - // state so that we don't actually send a home or sleep event on the - // key release. Note, however, that this state does set a timer so that - // it can send holdhome or holdsleep events. (This means that pressing and - // holding sleep will bring up the power menu, even on a sleeping phone.) - var wakeState = { - timer: null, - delegateState: null, - enter: function(type) { - if (type === 'home-button-press') - this.delegateState = homeState; - else - this.delegateState = sleepState; - this.timer = setTimeout(function() { - if (type === 'home-button-press') { - fire('holdhome'); - } else if (type === 'sleep-button-press') { - fire('holdsleep'); - } - setState(baseState, type); - }, HOLD_INTERVAL); - }, - exit: function() { - if (this.timer) { - clearTimeout(this.timer); - this.timer = null; - } - }, - process: function(type) { - switch (type) { - case 'home-button-release': - case 'sleep-button-release': - setState(baseState, type); - return; - default: - this.delegateState.process(type); - return; - } - } - }; - - // Kick off the FSM in the base state - setState(baseState); -}()); diff --git a/apps/system/js/icc_cache.js b/apps/system/js/icc_cache.js deleted file mode 100644 index 1f1d0df..0000000 --- a/apps/system/js/icc_cache.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: js; js-indent-level: 2; indent-tabs-mode: nil -*- */ -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -'use strict'; - -(function() { - /** - * Constants - */ - var DEBUG = false; - - /** - * Debug method - */ - function debug(msg, optObject) { - if (DEBUG) { - var output = '[DEBUG] STKCACHE: ' + msg; - if (optObject) { - output += JSON.stringify(optObject); - } - console.log(output); - } - } - - if (!window.navigator.mozMobileConnection) { - return; - } - - var icc = window.navigator.mozMobileConnection.icc; - // Remove previous menu - var resetApplications = window.navigator.mozSettings.createLock().set({ - 'icc.applications': '{}' - }); - resetApplications.onsuccess = function icc_resetApplications() { - debug('STK Cache Reseted'); - // Register to receive STK commands - window.navigator.mozSetMessageHandler('icc-stkcommand', - function handleSTKCommand(command) { - debug('STK Proactive Command:', command); - if (command.typeOfCommand == icc.STK_CMD_SET_UP_MENU) { - debug('STK_CMD_SET_UP_MENU:', command.options); - var reqApplications = window.navigator.mozSettings.createLock().set({ - 'icc.applications': JSON.stringify(command.options) - }); - reqApplications.onsuccess = function icc_getApplications() { - debug('Cached'); - icc.sendStkResponse(command, { - resultCode: icc.STK_RESULT_OK - }); - } - } else { - // Unsolicited command? -> Open settings - debug('CMD: ', command); - var application = document.location.protocol + '//' + - document.location.host.replace('system', 'settings'); - debug('application: ', application); - var reqIccData = window.navigator.mozSettings.createLock().set({ - 'icc.data': JSON.stringify(command) - }); - reqIccData.onsuccess = function icc_getIccData() { - if (WindowManager.getRunningApps()[application]) { - debug('Settings is running. Ignoring'); - return; // If settings is opened, we don't manage it - } - - debug('Locating settings . . .'); - navigator.mozApps.mgmt.getAll().onsuccess = function gotApps(evt) { - var apps = evt.target.result; - apps.forEach(function appIterator(app) { - if (app.origin != application) - return; - - var reqIccData = window.navigator.mozSettings.createLock().set({ - 'icc.data': JSON.stringify(command) - }); - reqIccData.onsuccess = function icc_getIccData() { - debug('Launching ', app.origin); - app.launch(); - } - }, this); - } - } - } - }); - } -})(); diff --git a/apps/system/js/identity.js b/apps/system/js/identity.js deleted file mode 100644 index 8030377..0000000 --- a/apps/system/js/identity.js +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ - -// When bug 794999 is resolved, switch to use the abstract Trusted UI Component - -'use strict'; - -const kIdentityScreen = 'https://login.native-persona.org/sign_in#NATIVE'; -const kIdentityFrame = - 'https://login.native-persona.org/communication_iframe'; - -var Identity = (function() { - var iframe; - - return { - trustedUILayers: {}, - - init: function() { - window.addEventListener('mozChromeEvent', this); - }, - - handleEvent: function onMozChromeEvent(e) { - var chromeEventId = e.detail.id; - var requestId = e.detail.requestId; - switch (e.detail.type) { - // Chrome asks Gaia to show the identity dialog. - case 'open-id-dialog': - if (!chromeEventId) - return; - - // When opening the dialog, we record the chrome event id, which - // we will need to send back to the TrustedUIManager when asking - // to close. - this.trustedUILayers[requestId] = chromeEventId; - - if (!e.detail.showUI && iframe) { - this._dispatchEvent({ - id: chromeEventId, - frame: iframe - }); - return; - } - var frame = document.createElement('iframe'); - frame.setAttribute('mozbrowser', 'true'); - frame.setAttribute('remote', true); - frame.classList.add('screen'); - frame.src = e.detail.showUI ? kIdentityScreen : kIdentityFrame; - frame.addEventListener('mozbrowserloadstart', - function loadStart(evt) { - // After creating the new frame containing the identity flow, we - // send it back to chrome so the identity callbacks can be injected. - this._dispatchEvent({ - id: chromeEventId, - frame: evt.target - }); - }.bind(this)); - - - if (e.detail.showUI) { - // The identity flow is shown within the trusted UI. - TrustedUIManager.open(navigator.mozL10n.get('persona-signin'), - frame, - this.trustedUILayers[requestId]); - } else { - var container = document.getElementById('screen'); - container.appendChild(frame); - frame.classList.add('communication-frame'); - iframe = frame; - } - break; - - case 'received-id-assertion': - if (e.detail.showUI) { - TrustedUIManager.close(this.trustedUILayers[requestId], - (function dialogClosed() { - delete this.trustedUILayers[requestId]; - }).bind(this)); - } - this._dispatchEvent({ id: chromeEventId }); - break; - } - }, - _dispatchEvent: function su_dispatchEvent(obj) { - var event = document.createEvent('CustomEvent'); - event.initCustomEvent('mozContentEvent', true, true, obj); - window.dispatchEvent(event); - } - }; -})(); - -// Make sure L10n is ready before init -if (navigator.mozL10n.readyState == 'complete' || - navigator.mozL10n.readyState == 'interactive') { - Identity.init(); -} else { - window.addEventListener('localized', Identity.init.bind(Identity)); -} - diff --git a/apps/system/js/keyboard_manager.js b/apps/system/js/keyboard_manager.js deleted file mode 100644 index 62aeca7..0000000 --- a/apps/system/js/keyboard_manager.js +++ /dev/null @@ -1,86 +0,0 @@ -'use strict'; - -var KeyboardManager = (function() { - function getKeyboardURL() { - // TODO: Retrieve it from Settings, allowing 3rd party keyboards - var host = document.location.host; - var domain = host.replace(/(^[\w\d]+\.)?([\w\d]+\.[a-z]+)/, '$2'); - var protocol = document.location.protocol; - - return protocol + '//keyboard.' + domain + '/'; - } - - function generateKeyboard(container, keyboardURL, manifestURL) { - var keyboard = document.createElement('iframe'); - keyboard.src = keyboardURL; - keyboard.setAttribute('mozbrowser', 'true'); - keyboard.setAttribute('mozpasspointerevents', 'true'); - keyboard.setAttribute('mozapp', manifestURL); - //keyboard.setAttribute('remote', 'true'); - - container.appendChild(keyboard); - return keyboard; - } - - // Generate a