Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
53
gaia/apps/settings/js/panels/apn_editor/apn_editor.js
Executable file
53
gaia/apps/settings/js/panels/apn_editor/apn_editor.js
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* The apn editor module
|
||||
*/
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var ApnEditorConst = require('panels/apn_editor/apn_editor_const');
|
||||
var ApnEditorSession = require('panels/apn_editor/apn_editor_session');
|
||||
|
||||
var APN_PROPERTIES = ApnEditorConst.APN_PROPERTIES;
|
||||
var APN_PROPERTY_DEFAULTS = ApnEditorConst.APN_PROPERTY_DEFAULTS;
|
||||
var VALUE_CONVERTERS = ApnEditorConst.VALUE_CONVERTERS;
|
||||
|
||||
function ApnEditor(rootElement) {
|
||||
this._inputElements = {};
|
||||
APN_PROPERTIES.forEach(function(name) {
|
||||
this._inputElements[name] = rootElement.querySelector('.' + name);
|
||||
}, this);
|
||||
}
|
||||
|
||||
ApnEditor.prototype = {
|
||||
_convertValue: function ae_convertValue(value, converter) {
|
||||
if (converter) {
|
||||
return converter(value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
_fillInputElements: function ae_fillInputElements(inputElements, apn) {
|
||||
APN_PROPERTIES.forEach(function(name) {
|
||||
var inputElement = inputElements[name];
|
||||
if (inputElement) {
|
||||
var value = (apn && apn[name.toLowerCase()]) ||
|
||||
APN_PROPERTY_DEFAULTS[name];
|
||||
inputElement.value =
|
||||
this._convertValue(value, VALUE_CONVERTERS.TO_STRING[name]);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
createApn: function ae_createApn(serviceId, apnItem) {
|
||||
this._fillInputElements(this._inputElements, apnItem.apn);
|
||||
return ApnEditorSession(serviceId, 'new', this._inputElements, apnItem);
|
||||
},
|
||||
editApn: function ae_editApn(serviceId, apnItem) {
|
||||
this._fillInputElements(this._inputElements, apnItem.apn);
|
||||
return ApnEditorSession(serviceId, 'edit', this._inputElements, apnItem);
|
||||
}
|
||||
};
|
||||
|
||||
return function ctor_apn_editor(rootElement) {
|
||||
return new ApnEditor(rootElement);
|
||||
};
|
||||
});
|
||||
47
gaia/apps/settings/js/panels/apn_editor/apn_editor_const.js
Executable file
47
gaia/apps/settings/js/panels/apn_editor/apn_editor_const.js
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* The apn editor const
|
||||
*/
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var APN_PROPERTY_DEFAULTS = {
|
||||
'apn': '',
|
||||
'user': '',
|
||||
'password': '',
|
||||
'proxy': '',
|
||||
'port': '',
|
||||
'mmsc': '',
|
||||
'mmsproxy': '',
|
||||
'mmsport': '',
|
||||
'authtype': 'notDefined',
|
||||
'types': ['default'],
|
||||
'protocol': 'notDefined',
|
||||
'roaming_protocol': 'notDefined',
|
||||
'mtu' : ''
|
||||
};
|
||||
|
||||
var APN_PROPERTIES = Object.keys(APN_PROPERTY_DEFAULTS);
|
||||
|
||||
var VALUE_CONVERTERS = {
|
||||
'TO_STRING': {
|
||||
'types': function(types) {
|
||||
if (types && Array.isArray(types) && types.length) {
|
||||
return types.join(', ');
|
||||
} else {
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
},
|
||||
'TO_DATA': {
|
||||
'types': function(string) {
|
||||
return string.split(',').map((str) => str.trim());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
get APN_PROPERTIES() { return APN_PROPERTIES; },
|
||||
get APN_PROPERTY_DEFAULTS() { return APN_PROPERTY_DEFAULTS; },
|
||||
get VALUE_CONVERTERS() { return VALUE_CONVERTERS; }
|
||||
};
|
||||
});
|
||||
99
gaia/apps/settings/js/panels/apn_editor/apn_editor_session.js
Executable file
99
gaia/apps/settings/js/panels/apn_editor/apn_editor_session.js
Executable file
|
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* The apn editor session module
|
||||
*/
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var ApnSettingsManager = require('modules/apn/apn_settings_manager');
|
||||
var ApnEditorConst = require('panels/apn_editor/apn_editor_const');
|
||||
var ApnUtils = require('modules/apn/apn_utils');
|
||||
|
||||
var APN_PROPERTIES = ApnEditorConst.APN_PROPERTIES;
|
||||
var VALUE_CONVERTERS = ApnEditorConst.VALUE_CONVERTERS;
|
||||
|
||||
function ApnEditorSession(serviceId, mode, inputElements, apnItem) {
|
||||
this._serviceId = serviceId;
|
||||
this._mode = mode;
|
||||
this._inputElements = inputElements;
|
||||
this._apnItem = apnItem;
|
||||
}
|
||||
|
||||
ApnEditorSession.prototype = {
|
||||
_convertValue: function ae_convertValue(value, converter) {
|
||||
if (converter) {
|
||||
return converter(value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
_exportApnSetting: function aes_exportApnSetting(inputElements) {
|
||||
var newApnSetting = {};
|
||||
APN_PROPERTIES.forEach(function(name) {
|
||||
var inputElement = inputElements[name];
|
||||
if (inputElement && !inputElement.hidden && inputElement.value) {
|
||||
newApnSetting[name.toLowerCase()] = this._convertValue(
|
||||
inputElement.value, VALUE_CONVERTERS.TO_DATA[name]);
|
||||
}
|
||||
}, this);
|
||||
return newApnSetting;
|
||||
},
|
||||
_commitNew: function aes_commitNew() {
|
||||
var promises = [];
|
||||
var newApnSetting = this._exportApnSetting(this._inputElements);
|
||||
newApnSetting.types.slice().forEach(function(type) {
|
||||
// Clone new settings to make sure the promises do not all
|
||||
// point to the very last one
|
||||
var settingClone = ApnUtils.clone(newApnSetting);
|
||||
settingClone.types = [type];
|
||||
promises.push(
|
||||
ApnSettingsManager.addApn(this._serviceId, settingClone));
|
||||
}, this);
|
||||
return Promise.all(promises);
|
||||
},
|
||||
_commitEdit: function aes_commitEdit() {
|
||||
var promises = [];
|
||||
var newApnSetting = this._exportApnSetting(this._inputElements);
|
||||
if (newApnSetting.types.length === 1) {
|
||||
promises.push(ApnSettingsManager.updateApn(this._serviceId,
|
||||
this._apnItem.id, newApnSetting));
|
||||
} else {
|
||||
newApnSetting.types.forEach(function(type) {
|
||||
var settingClone = ApnUtils.clone(newApnSetting);
|
||||
settingClone.types = [type];
|
||||
if (type === this._apnItem.apn.types[0]) {
|
||||
promises.push(ApnSettingsManager.updateApn(this._serviceId,
|
||||
this._apnItem.id, settingClone));
|
||||
} else {
|
||||
promises.push(ApnSettingsManager.addApn(this._serviceId,
|
||||
settingClone));
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
return Promise.all(promises);
|
||||
},
|
||||
commit: function aes_commit() {
|
||||
switch (this._mode) {
|
||||
case 'new':
|
||||
return this._commitNew();
|
||||
case 'edit':
|
||||
return this._commitEdit();
|
||||
default:
|
||||
console.error('invalid mode');
|
||||
return Promise.resolve();
|
||||
}
|
||||
},
|
||||
cancel: function aes_cancel() {
|
||||
APN_PROPERTIES.forEach(function(name) {
|
||||
this._inputElements[name].value = '';
|
||||
}, this);
|
||||
this._apnItem = null;
|
||||
},
|
||||
get mode() {
|
||||
return this._mode;
|
||||
}
|
||||
};
|
||||
|
||||
return function ctor_apnESession(serviceId, mode, inputElements, apnItem) {
|
||||
return new ApnEditorSession(serviceId, mode, inputElements, apnItem);
|
||||
};
|
||||
});
|
||||
155
gaia/apps/settings/js/panels/apn_editor/panel.js
Executable file
155
gaia/apps/settings/js/panels/apn_editor/panel.js
Executable file
|
|
@ -0,0 +1,155 @@
|
|||
/**
|
||||
* The apn editor panel
|
||||
*/
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var SettingsService = require('modules/settings_service');
|
||||
var SettingsPanel = require('modules/settings_panel');
|
||||
var SettingsCache = require('modules/settings_cache');
|
||||
var ApnSettingsManager = require('modules/apn/apn_settings_manager');
|
||||
var ApnEditor = require('panels/apn_editor/apn_editor');
|
||||
|
||||
var _back = function() {
|
||||
SettingsService.navigate('apn-list');
|
||||
};
|
||||
|
||||
var _getDialogService = function() {
|
||||
return new Promise(function(resolve) {
|
||||
require(['modules/dialog_service'], resolve);
|
||||
});
|
||||
};
|
||||
|
||||
var _showChangeApnWarning = function() {
|
||||
return _getDialogService().then((DialogService) => {
|
||||
return DialogService.confirm('change-apn-warning-message1', {
|
||||
title: 'apnSettings',
|
||||
submitButton: {
|
||||
id: 'yes',
|
||||
style: 'recommend'
|
||||
},
|
||||
cancelButton: 'cancel'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var _showDeleteApnWarning = function() {
|
||||
return _getDialogService().then((DialogService) => {
|
||||
return DialogService.confirm('delete-apn-confirm', {
|
||||
title: 'confirmation',
|
||||
submitButton: {
|
||||
id: 'delete-apn',
|
||||
style: 'danger'
|
||||
},
|
||||
cancelButton: 'cancel'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return function ctor_apnEditorPanel() {
|
||||
var _rootElement;
|
||||
var _elements;
|
||||
|
||||
var _apnEditor;
|
||||
var _editorSession;
|
||||
|
||||
var _apnItem;
|
||||
var _apnType;
|
||||
var _serviceId;
|
||||
|
||||
var _leftApp = false;
|
||||
|
||||
return SettingsPanel({
|
||||
onInit: function ae_onInit(rootElement) {
|
||||
_rootElement = rootElement;
|
||||
_apnEditor = new ApnEditor(rootElement);
|
||||
_elements = {
|
||||
panel: rootElement.querySelector('.panel'),
|
||||
okBtn: rootElement.querySelector('button.ok'),
|
||||
deteleItem: rootElement.querySelector('.apnSettings-btns li.delete'),
|
||||
deleteBtn:
|
||||
rootElement.querySelector('.apnSettings-btns li.delete button')
|
||||
};
|
||||
|
||||
_elements.okBtn.onclick = function() {
|
||||
if (!_editorSession) {
|
||||
_back();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_editorSession.mode === 'new') {
|
||||
_editorSession.commit().then(_back);
|
||||
_editorSession = null;
|
||||
} else if (_editorSession.mode === 'edit') {
|
||||
// Display the warning only when Data roaming is turned on and it is
|
||||
// the current APN in use that’s being edited.
|
||||
Promise.all([
|
||||
ApnSettingsManager.getActiveApnId(_serviceId, _apnType),
|
||||
new Promise((resolve) => {
|
||||
SettingsCache.getSettings(function(results) {
|
||||
resolve(results['ril.data.roaming_enabled']);
|
||||
});
|
||||
})
|
||||
]).then(function(results) {
|
||||
var activeApnId = results[0];
|
||||
var dataRoamingEnabled = results[1];
|
||||
if (activeApnId === _apnItem.id && dataRoamingEnabled) {
|
||||
return _showChangeApnWarning();
|
||||
}
|
||||
}).then(function(result) {
|
||||
if (!result || (result && result.type === 'submit')) {
|
||||
_editorSession.commit().then(_back);
|
||||
_editorSession = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_elements.deleteBtn.onclick = function() {
|
||||
_showDeleteApnWarning().then((result) => {
|
||||
if (result.type === 'submit') {
|
||||
ApnSettingsManager.removeApn(_serviceId, _apnItem.id).then(_back);
|
||||
}
|
||||
});
|
||||
};
|
||||
},
|
||||
onBeforeShow: function ae_onBeforeShow(rootElement, options) {
|
||||
// If this flag has been set, which means that users have been left
|
||||
// the app before so we should keep the original state instead of
|
||||
// refreshing it.
|
||||
if (_leftApp) {
|
||||
_leftApp = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var mode = options.mode || 'new';
|
||||
_apnItem = options.item || {};
|
||||
_apnType = options.type || 'default';
|
||||
_serviceId = options.serviceId;
|
||||
|
||||
switch (mode) {
|
||||
case 'new':
|
||||
_elements.deteleItem.hidden = true;
|
||||
var defaultApnItem = {
|
||||
apn: {
|
||||
types: [_apnType]
|
||||
}
|
||||
};
|
||||
_editorSession = _apnEditor.createApn(_serviceId, defaultApnItem);
|
||||
break;
|
||||
case 'edit':
|
||||
_elements.deteleItem.hidden = false;
|
||||
_editorSession = _apnEditor.editApn(_serviceId, _apnItem);
|
||||
break;
|
||||
}
|
||||
_elements.panel.scrollTop = 0;
|
||||
},
|
||||
onHide: function ae_onHide() {
|
||||
_leftApp = document.hidden;
|
||||
if (!_leftApp && _editorSession) {
|
||||
_editorSession.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
Loading…
Reference in a new issue