|
@@ -127,13 +127,26 @@ angular.module('odoo')
|
|
|
})
|
|
|
|
|
|
/**
|
|
|
- * -----------------------------------------------------------------------------
|
|
|
- * Description: Native camera manager
|
|
|
- * -----------------------------------------------------------------------------
|
|
|
- */
|
|
|
- .factory('cameraFactory', function ($cordovaCamera) {
|
|
|
+ * -----------------------------------------------------------------------------
|
|
|
+ * Description: Native device functions manager
|
|
|
+ * -----------------------------------------------------------------------------
|
|
|
+ */
|
|
|
+ .factory('deviceFactory', function (
|
|
|
+ $timeout,
|
|
|
+ $rootScope,
|
|
|
+ $cordovaCamera,
|
|
|
+ $cordovaContacts,
|
|
|
+ $cordovaGeolocation,
|
|
|
+ $cordovaDeviceMotion,
|
|
|
+ $cordovaLaunchNavigator,
|
|
|
+ $cordovaToast,
|
|
|
+ $cordovaVibration
|
|
|
+ ) {
|
|
|
+ var vibrateDuration = 100;
|
|
|
|
|
|
- // Take a picture using native camera
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
var takePicture = function (success, error) {
|
|
|
var options = {
|
|
|
quality: 75,
|
|
@@ -153,27 +166,67 @@ angular.module('odoo')
|
|
|
}, function (err) {
|
|
|
error(err);
|
|
|
});
|
|
|
- };
|
|
|
-
|
|
|
- return {
|
|
|
- takePicture: takePicture
|
|
|
}
|
|
|
- })
|
|
|
|
|
|
- /**
|
|
|
- * -----------------------------------------------------------------------------
|
|
|
- * Description: Native device functions manager
|
|
|
- * -----------------------------------------------------------------------------
|
|
|
- */
|
|
|
- .factory('deviceFactory', function (
|
|
|
- $timeout,
|
|
|
- $rootScope,
|
|
|
- $cordovaGeolocation,
|
|
|
- $cordovaDeviceMotion,
|
|
|
- $cordovaToast,
|
|
|
- $cordovaVibration
|
|
|
- ) {
|
|
|
- var vibrateDuration = 100;
|
|
|
+ var saveContact = function (contact, success, error) {
|
|
|
+ if (!contact.mobile && !contact.phone && !contact.email) {
|
|
|
+ error();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var info = {
|
|
|
+ name: {
|
|
|
+ givenName: contact.name,
|
|
|
+ familyName: '',
|
|
|
+ formatted: ''
|
|
|
+ },
|
|
|
+ nickname: '',
|
|
|
+ phoneNumbers: [
|
|
|
+ {
|
|
|
+ value: contact.phone,
|
|
|
+ type: 'phone'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: contact.mobile,
|
|
|
+ type: 'mobile'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ emails: [
|
|
|
+ {
|
|
|
+ value: contact.email,
|
|
|
+ type: 'home'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ addresses: [
|
|
|
+ {
|
|
|
+ type: 'home',
|
|
|
+ formatted: '',
|
|
|
+ streetAddress: contact.street,
|
|
|
+ locality: contact.city,
|
|
|
+ region: '',
|
|
|
+ postalCode: '',
|
|
|
+ country: 'Paraguay'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ ims: null,
|
|
|
+ organizations: null,
|
|
|
+ birthday: null,
|
|
|
+ note: null,
|
|
|
+ photos: null,
|
|
|
+ categories: null,
|
|
|
+ urls: null
|
|
|
+ };
|
|
|
+
|
|
|
+ $cordovaContacts.save(info).then(function (result) {
|
|
|
+ $cordovaVibration.vibrate(vibrateDuration);
|
|
|
+
|
|
|
+ success(result);
|
|
|
+ }, function (err) {
|
|
|
+ $cordovaVibration.vibrate(vibrateDuration);
|
|
|
+
|
|
|
+ error(err);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -200,6 +253,21 @@ angular.module('odoo')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ var navigate = function (destination, success, error) {
|
|
|
+ // if (!destination.latitude || !destination.longitude) {
|
|
|
+ // return error('Invalid destination');
|
|
|
+ // }
|
|
|
+
|
|
|
+ $cordovaLaunchNavigator.navigate(destination).then(function () {
|
|
|
+ success('Navigator launched');
|
|
|
+ }, function (err) {
|
|
|
+ error(err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
@@ -254,76 +322,9 @@ angular.module('odoo')
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
+ takePicture: takePicture,
|
|
|
getCurrentPosition: getCurrentPosition,
|
|
|
+ navigate: navigate,
|
|
|
detectShake: detectShake
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
- /**
|
|
|
- * -----------------------------------------------------------------------------
|
|
|
- * Description: Native contacts manager
|
|
|
- * -----------------------------------------------------------------------------
|
|
|
- */
|
|
|
- .factory('contactFactory', function ($cordovaContacts) {
|
|
|
-
|
|
|
- // Save customer information to device contacts
|
|
|
- var save = function (customer, success, error) {
|
|
|
- if (!customer.mobile && !customer.phone && !customer.email) {
|
|
|
- error();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var contact = {
|
|
|
- name: {
|
|
|
- givenName: customer.name,
|
|
|
- familyName: '',
|
|
|
- formatted: ''
|
|
|
- },
|
|
|
- nickname: '',
|
|
|
- phoneNumbers: [
|
|
|
- {
|
|
|
- value: customer.phone,
|
|
|
- type: 'phone'
|
|
|
- },
|
|
|
- {
|
|
|
- value: customer.mobile,
|
|
|
- type: 'mobile'
|
|
|
- }
|
|
|
- ],
|
|
|
- emails: [
|
|
|
- {
|
|
|
- value: customer.email,
|
|
|
- type: 'home'
|
|
|
- }
|
|
|
- ],
|
|
|
- addresses: [
|
|
|
- {
|
|
|
- type: 'home',
|
|
|
- formatted: '',
|
|
|
- streetAddress: customer.street,
|
|
|
- locality: customer.city,
|
|
|
- region: '',
|
|
|
- postalCode: '',
|
|
|
- country: 'Paraguay'
|
|
|
- }
|
|
|
- ],
|
|
|
- ims: null,
|
|
|
- organizations: null,
|
|
|
- birthday: null,
|
|
|
- note: null,
|
|
|
- photos: null,
|
|
|
- categories: null,
|
|
|
- urls: null
|
|
|
- };
|
|
|
-
|
|
|
- $cordovaContacts.save(contact).then(function (result) {
|
|
|
- success(result);
|
|
|
- }, function (err) {
|
|
|
- error(err);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- return {
|
|
|
- save: save
|
|
|
- }
|
|
|
});
|