forked from ccavazos/titanium-alternate-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathti.alternateicons.js
40 lines (35 loc) · 1.16 KB
/
ti.alternateicons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Titanium Alternate Icons (Hyperloop)
* @version 1.0.1
* @author ccavazos
*/
var UIApplication = require('UIKit/UIApplication');
var UIDevice = require('UIKit/UIDevice');
var NSNumericSearch = require('Foundation').NSNumericSearch;
var NSOrderedAscending = require('Foundation').NSOrderedAscending;
exports.isSupported = function() {
return UIDevice.currentDevice.systemVersion.compareOptions('10.3', NSNumericSearch) != NSOrderedAscending;
};
exports.supportsAlternateIcons = function() {
return !!UIApplication.sharedApplication.supportsAlternateIcons;
};
exports.alternateIconName = function() {
var iconName = String(UIApplication.sharedApplication.alternateIconName);
if (iconName == null) {
return null;
} else {
return iconName;
}
};
exports.setAlternateIconName = function(iconName) {
UIApplication.sharedApplication.setAlternateIconNameCompletionHandler(iconName, function(error){
if (error) {
console.error('Ti.AlternateIcons', error);
} else {
console.log('Ti.AlternateIcons: Icon has been changed to', (iconName) ? iconName : 'Default');
}
});
};
exports.setDefaultIconName = function() {
exports.setAlternateIconName(null);
};