-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathandroid.js
More file actions
66 lines (53 loc) · 1.95 KB
/
Copy pathandroid.js
File metadata and controls
66 lines (53 loc) · 1.95 KB
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
/**
* Called via the view to demonstrate the new Titanium Android themes
*/
function openWindowWithTheme(e) {
// The button's title is our theme name
var theme = e.source.title;
Alloy.createController('theme', {
// Ugly but effective hack into Alloy's data binding to use arguments in the view
// See the theme-view where {theme} makes Alloy expect the following argument:
$model: {
__transform: {
theme: e.source.title
}
}
}).getView().open();
}
function onSliderChange(e) {
$.elvView.elevation = e.value;
}
function notify(e) {
// You could hard-code the activity name found in build/android/Manifest.xml - but I don't
// From: https://github.com/appcelerator/titanium_mobile/blob/290969563132b3fe51c479267541bacdfe9b9844/android/cli/commands/_build.js#L1733-L1736
var activityName = Ti.App.name.split(/[^A-Za-z0-9_]/).map(function (word) {
return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase();
}).join('');
/^[0-9]/.test(activityName) && (activityName = '_' + activityName);
// Create an intent to open ourselves
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_MAIN,
className: Ti.App.id + '.' + activityName + 'Activity',
packageName: Ti.App.id
});
intent.flags |= Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_NEW_TASK;
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
// Create and show a notification
Ti.Android.NotificationManager.notify(1, Titanium.Android.createNotification({
contentTitle: 'Something Happened',
contentText: 'Click to return to the application.',
contentIntent: Titanium.Android.createPendingIntent({
intent: intent,
flags: Titanium.Android.FLAG_UPDATE_CURRENT
}),
// Use system rewind icon as default icon and fastforward as largeIcon
icon: Ti.Android.R.drawable.ic_media_rew,
largeIcon: Ti.Android.R.drawable.ic_media_ff
}));
}
function setSelectedRow() {
$.picker.setSelectedRow(0, 2);
}
function closeWindow(e) {
$.win.close();
}