Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

Commit 6914f8e

Browse files
authored
Dev next (#1284)
* added method to src,mocks, and respective tests (#1218) * update localNotification.ctrl.js (#1213) i think, to be able to calculate "_60_seconds_from_now", the "now" value has to be a number, so I added the "getTime()" method * $cordovaAppRate sets callbacks correctly (onButtonClicked, onRateDialogShow) (#1209) * Wrapper for 3d touch plugin (#1155) * Add wrapper for 3d plugin * Fixed JSHint warnings for undefined variable * added iosOptions to $cordovaSpinnerDialog.show() (#1224) * added iosOptions to $cordovaSpinnerDialog.show() * added missing comma * added additional test for options in spinnerDialog.show() method * Updated appVersion mocks and added tests (#1231) * Issue #1228 - google analytics (#1247) * Add key param check * Tests fix * Tests fix * Added shareWithOptions, which was introduced in 5.1.0 (#1263) See https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#using-the-share-sheet for usage details * added tts plugin wrapper (#1265) * added tts plugin wrapper * commit only tts.js * only commit plugin * Add serial plugin wrapper (#1274) * Add cordovaSerial plugin wrapper and unit tests * Update README with serial plugin * Add serial to jshint globals * added recents control plugin wrapper (#1264) * added recents control plugin * built added recents control plugin * added plugin to plugin list * added tts plugin wrapper * commit only tts.js * only commit plugin * only commit recents plugin * remove tts plugin * added plugin to list * added coma :|
1 parent e4d716e commit 6914f8e

22 files changed

+769
-20
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ $ bower install ngCordova
9292
- [Push Notifications](https://github.com/phonegap-build/PushPlugin) (**deprecated** - Will be removed in future release)
9393
- [Push Notifications - V5] (https://github.com/phonegap/phonegap-plugin-push)
9494
- [Screenshots](https://github.com/gitawego/cordova-screenshot)
95+
- [Serial](https://github.com/xseignard/cordovarduino)
9596
- [SMS](https://github.com/aharris88/phonegap-sms-plugin)
9697
- [Social Sharing](https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin)
9798
- [Spinner Dialog](https://github.com/Paldom/SpinnerDialog)

demo/www/app/localNotification/localNotification.ctrl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ angular.module('demo.localNotification.ctrl', [])
33
.controller('LocalNotificationCtrl', function ($scope, $rootScope, $cordovaLocalNotification) {
44

55
$scope.addNotification = function () {
6-
var now = new Date();
6+
var now = new Date().getTime();
77
var _60_seconds_from_now = new Date(now + 60 * 1000);
88
var event = {
99
id: 1,

dist/ng-cordova.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5579,6 +5579,7 @@ angular.module('ngCordova.plugins', [
55795579
'ngCordova.plugins.progressIndicator',
55805580
'ngCordova.plugins.push',
55815581
'ngCordova.plugins.push_v5',
5582+
'ngCordova.plugins.recentsControl',
55825583
'ngCordova.plugins.sms',
55835584
'ngCordova.plugins.socialSharing',
55845585
'ngCordova.plugins.spinnerDialog',
@@ -7058,4 +7059,4 @@ angular.module('ngCordova.plugins.zip', [])
70587059
};
70597060
}]);
70607061

7061-
})();
7062+
})();

src/mocks/appVersion.js

+23-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,29 @@ ngCordovaMocks.factory('$cordovaAppVersion', ['$q', function ($q) {
22
var throwsError = false;
33
return {
44
throwsError: throwsError,
5-
getAppVersion: function () {
6-
var defer = $q.defer();
7-
defer.resolve('mock v');
8-
return defer.promise;
5+
6+
getAppName: function () {
7+
var q = $q.defer();
8+
q.resolve('mock app name');
9+
return q.promise;
10+
},
11+
12+
getPackageName: function () {
13+
var q = $q.defer();
14+
q.resolve('com.package.mock');
15+
return q.promise;
16+
},
17+
18+
getVersionNumber: function () {
19+
var q = $q.defer();
20+
q.resolve('1.2.3');
21+
return q.promise;
22+
},
23+
24+
getVersionCode: function () {
25+
var q = $q.defer();
26+
q.resolve('4.5.6');
27+
return q.promise;
928
}
1029
};
1130
}]);

src/mocks/socialSharing.js

+15
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,21 @@ ngCordovaMocks.factory('$cordovaSocialSharing', ['$q', function ($q) {
258258
defer.resolve();
259259
}
260260
return defer.promise;
261+
},
262+
263+
shareWithOptions: function (options) {
264+
var defer = $q.defer();
265+
if (this.throwsError) {
266+
defer.reject('There was an error sharing via SMS.');
267+
} else {
268+
this.message = options.message;
269+
this.subject = options.subject;
270+
this.attachments = options.files;
271+
this.link = options.url;
272+
273+
defer.resolve();
274+
}
275+
return defer.promise;
261276
}
262277
};
263278
}]);

src/mocks/toast.js

+9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ ngCordovaMocks.factory('$cordovaToast', ['$q', function ($q) {
7777
}
7878
return defer.promise;
7979
},
80+
showWithOptions: function (options) {
81+
var defer = $q.defer();
82+
if (this.throwsError) {
83+
defer.reject('There was an error showing the toast.');
84+
} else {
85+
defer.resolve();
86+
}
87+
return defer.promise;
88+
},
8089
show: function (message, duration, position) {
8190
var defer = $q.defer();
8291
if (this.throwsError) {

src/plugins/3dtouch.js

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// install : cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-3dtouch.git
2+
// link : https://github.com/EddyVerbruggen/cordova-plugin-3dtouch
3+
4+
angular.module('ngCordova.plugins.3dtouch', [])
5+
6+
.factory('$cordova3DTouch', ['$q', function($q) {
7+
var quickActions = [];
8+
var quickActionHandler = {};
9+
10+
var createQuickActionHandler = function(quickActionHandler) {
11+
return function (payload) {
12+
for (var key in quickActionHandler) {
13+
if (payload.type === key) {
14+
quickActionHandler[key]();
15+
}
16+
}
17+
};
18+
};
19+
20+
return {
21+
/*
22+
* Checks if Cordova 3D touch is present and loaded
23+
*
24+
* @return promise
25+
*/
26+
isAvailable: function () {
27+
var deferred = $q.defer();
28+
if (!window.cordova) {
29+
deferred.reject('Not supported in browser');
30+
} else {
31+
if (!window.ThreeDeeTouch) {
32+
deferred.reject('Could not find 3D touch plugin');
33+
} else {
34+
window.ThreeDeeTouch.isAvailable(function (value) {
35+
deferred.resolve(value);
36+
}, function (err) {
37+
deferred.reject(err);
38+
});
39+
}
40+
}
41+
42+
return deferred.promise;
43+
},
44+
45+
/*
46+
* Add a quick action to menu
47+
*
48+
* @param string type
49+
* @param string title
50+
* @param string iconType (optional)
51+
* @param string subtitle (optional)
52+
* @param function callback (optional)
53+
* @return promise
54+
*/
55+
addQuickAction: function(type, title, iconType, iconTemplate, subtitle, callback) {
56+
var deferred = $q.defer();
57+
58+
var quickAction = {
59+
type: type,
60+
title: title,
61+
subtitle: subtitle
62+
};
63+
64+
if (iconType) {
65+
quickAction.iconType = iconType;
66+
}
67+
68+
if (iconTemplate) {
69+
quickAction.iconTemplate = iconTemplate;
70+
}
71+
72+
this.isAvailable().then(function() {
73+
quickActions.push(quickAction);
74+
quickActionHandler[type] = callback;
75+
window.ThreeDeeTouch.configureQuickActions(quickActions);
76+
window.ThreeDeeTouch.onHomeIconPressed = createQuickActionHandler(quickActionHandler);
77+
deferred.resolve(quickActions);
78+
},
79+
function(err) {
80+
deferred.reject(err);
81+
});
82+
83+
return deferred.promise;
84+
},
85+
86+
/*
87+
* Add a quick action handler. Used for static quick actions
88+
*
89+
* @param string type
90+
* @param function callback
91+
* @return promise
92+
*/
93+
addQuickActionHandler: function(type, callback) {
94+
var deferred = $q.defer();
95+
96+
this.isAvailable().then(function() {
97+
quickActionHandler[type] = callback;
98+
window.ThreeDeeTouch.onHomeIconPressed = createQuickActionHandler(quickActionHandler);
99+
deferred.resolve(true);
100+
},
101+
function(err) {
102+
deferred.reject(err);
103+
});
104+
105+
return deferred.promise;
106+
},
107+
108+
/*
109+
* Enable link preview popup when force touch is appled to link elements
110+
*
111+
* @return bool
112+
*/
113+
enableLinkPreview: function() {
114+
var deferred = $q.defer();
115+
116+
this.isAvailable().then(function() {
117+
window.ThreeDeeTouch.enableLinkPreview();
118+
deferred.resolve(true);
119+
},
120+
function(err) {
121+
deferred.reject(err);
122+
});
123+
124+
return deferred.promise;
125+
},
126+
127+
/*
128+
* Add a hanlder function for force touch events,
129+
*
130+
* @param function callback
131+
* @return promise
132+
*/
133+
addForceTouchHandler: function(callback) {
134+
var deferred = $q.defer();
135+
136+
this.isAvailable().then(function() {
137+
window.ThreeDeeTouch.watchForceTouches(callback);
138+
deferred.resolve(true);
139+
},
140+
function(err) {
141+
deferred.reject(err);
142+
});
143+
144+
return deferred.promise;
145+
}
146+
};
147+
}]);

src/plugins/appRate.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ angular.module('ngCordova.plugins.appRate', [])
4343
*
4444
* @param {Object} customObj
4545
* @param {string} customObj.title
46+
* @param {string} customObj.message
4647
* @param {string} customObj.cancelButtonLabel
4748
* @param {string} customObj.laterButtonLabel
4849
* @param {string} customObj.rateButtonLabel
@@ -80,13 +81,11 @@ angular.module('ngCordova.plugins.appRate', [])
8081
},
8182

8283
onButtonClicked: function (cb) {
83-
AppRate.onButtonClicked = function (buttonIndex) {
84-
cb.call(this, buttonIndex);
85-
};
84+
AppRate.preferences.callbacks.onButtonClicked = cb.bind(this);
8685
},
8786

8887
onRateDialogShow: function (cb) {
89-
AppRate.onRateDialogShow = cb();
88+
AppRate.preferences.callbacks.onRateDialogShow = cb.bind(this);
9089
}
9190
};
9291
}];

src/plugins/googleAnalytics.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ angular.module('ngCordova.plugins.googleAnalytics', [])
5656

5757
addCustomDimension: function (key, value) {
5858
var d = $q.defer();
59+
var parsedKey = parseInt(key, 10);
5960

60-
$window.analytics.addCustomDimension(key, value, function () {
61+
if (isNaN(parsedKey)) {
62+
d.reject('Parameter "key" must be an integer.');
63+
}
64+
65+
$window.analytics.addCustomDimension(parsedKey, value, function () {
6166
d.resolve();
6267
}, function (error) {
6368
d.reject(error);

src/plugins/module.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
angular.module('ngCordova.plugins', [
2+
'ngCordova.plugins.3dtouch',
23
'ngCordova.plugins.actionSheet',
34
'ngCordova.plugins.adMob',
45
'ngCordova.plugins.appAvailability',

src/plugins/recentsControl.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// install : cordova plugin add cordova-plugin-recentscontrol
2+
// link : https://github.com/smcpjames/cordova-plugin-recentscontrol
3+
4+
/* globals RecentsControl: true */
5+
angular.module('ngCordova.plugins.recentsControl', [])
6+
7+
.factory('$cordovaRecents', function () {
8+
return {
9+
setColor: function (color) {
10+
return RecentsControl.setColor(color);
11+
},
12+
13+
setDescription: function (desc) {
14+
return RecentsControl.setDescription(desc);
15+
},
16+
17+
setOptions: function (colorStr, desc) {
18+
return RecentsControl.setOptions(colorStr, desc);
19+
}
20+
};
21+
});

0 commit comments

Comments
 (0)