-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
107 lines (81 loc) · 1.89 KB
/
app.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var androidutils = require('com.crossbits.androidutils');
// UIs
var win = Ti.UI.createWindow({
exitOnClose: true,
backgroundColor: '#fff',
layout: 'vertical'
});
var button_1 = Ti.UI.createButton({
top: 20,
title: 'isRingerModeSilent'
});
win.add(button_1);
var button_2 = Ti.UI.createButton({
top: 20,
title: 'isRingerModeVibrate'
});
win.add(button_2);
var button_3 = Ti.UI.createButton({
top: 20,
title: 'isRingerModeNormal'
});
win.add(button_3);
var button_4 = Ti.UI.createButton({
top: 20,
title: 'getRingerMode'
});
win.add(button_4);
var button_5 = Ti.UI.createButton({
top: 20,
title: 'getSimCountryIso'
});
win.add(button_5);
win.open();
// listeners
button_1.addEventListener('click', function(e) {
var result = androidutils.isRingerModeSilent();
Ti.UI.createAlertDialog({
title: e.source.title,
message: result
}).show();
});
button_2.addEventListener('click', function(e) {
var result = androidutils.isRingerModeVibrate();
Ti.UI.createAlertDialog({
title: e.source.title,
message: result
}).show();
});
button_3.addEventListener('click', function(e) {
var result = androidutils.isRingerModeNormal();
Ti.UI.createAlertDialog({
title: e.source.title,
message: result
}).show();
});
button_4.addEventListener('click', function(e) {
var result = androidutils.getRingerMode();
var msg = 'unknown';
switch(result) {
case androidutils.RINGER_MODE_SILENT:
msg = 'RINGER_MODE_SILENT';
break;
case androidutils.RINGER_MODE_VIBRATE:
msg = 'RINGER_MODE_VIBRATE';
break;
case androidutils.RINGER_MODE_NORMAL:
msg = 'RINGER_MODE_NORMAL';
break;
}
Ti.UI.createAlertDialog({
title: e.source.title,
message: msg + ' (' + result + ')'
}).show();
});
button_5.addEventListener('click', function(e) {
var result = androidutils.getSimCountryIso();
Ti.UI.createAlertDialog({
title: e.source.title,
message: result
}).show();
});