-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.xml
133 lines (116 loc) · 3.23 KB
/
module.xml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<module>
<User f="nodata">
<User>
<Users t="list" f="user" l="Control"/>
</User>
</User>
<Control f="nodata">
<Control>
<Create_New_Document l="Document"/>
</Control>
<search/>
</Control>
<Document>
<Document>
<Title f="id"/>
<Author/>
<Year_of_Publication b="decimal"/>
<Scan_Barcode t="button"/>
<Barcode/>
<Notes/>
</Document>
<Attach_Photos>
<Guide t="webview" f="nolabel">
<markdown>
## Guide: Attaching Recent Photos From Open Camera
1. Take one or more photos:
1. With this record still open, start the Open Camera app.
1. Ensure that photos are being taken as .jpg files:
1. Take a photo using the camera icon.
1. Attach the photos to this record:
1. Return to the currently open record.
1. Tap the "Attach New Photos" button (below). A dialogue box which lists the photos taken in Step 2 will be displayed. These files are now attached to this record.
</markdown>
</Guide>
<Attach_New_Photos t="camera"/>
</Attach_Photos>
</Document>
<logic><![CDATA[
/***************************** PHOTO ATTACHMENTS ******************************/
delOnEvent(
"Document/Attach_Photos/Attach_New_Photos_Button_1",
"click",
"attachPictureTo(\"Document/Attach_Photos/Attach_New_Photos\")"
);
addOnEvent(
"Document/Attach_Photos/Attach_New_Photos_Button_1",
"click",
"attachNewFiles()"
);
addOnEvent(
"Document",
"show",
"lastFileList = getFileList()"
);
List getFileList() {
String dirPath = "/sdcard/DCIM/OpenCamera";
File dir = new File(dirPath);
if (!dir.exists()) {
return new ArrayList();
}
File[] fileArray = dir.listFiles();
List files = Arrays.asList(fileArray);
files = new ArrayList(files); // This makes `files` mutable
// Sort the list of files by date modified
Comparator compareModDate = new Comparator() {
public int compare(File a, File b) {
long aMod = a.lastModified();
long bMod = b.lastModified();
if (aMod > bMod) return +1;
if (aMod < bMod) return -1;
return 0;
}
};
Collections.sort(files, compareModDate);
return files;
}
String fileListToString(List files) {
String s = "";
for (i = 0; i < files.size(); i++)
s += files.get(i).getName() + "\n";
return s;
}
void attachAll(List files) {
for (i = 0; i < files.size(); i++) {
ref = "Document/Attach_Photos/Attach_New_Photos";
filePath = files.get(i).getAbsolutePath();
addPicture(ref, filePath);
}
}
List attachNewFiles() {
thisFileList = getFileList();
newFiles = new ArrayList(thisFileList);
newFiles = getFileList();
newFiles.removeAll(lastFileList);
lastFileList = thisFileList;
if (newFiles.size() == 0) {
showWarning("No new files found", "");
} else {
attachAll(newFiles);
s = fileListToString(newFiles);
showWarning("New files found", s);
}
return newFiles;
}
/********************************** BARCODE ***********************************/
addOnEvent("Document/Document/Scan_Barcode", "click", "scanCode()");
void scanCode() {
scanCode("updateBarcode()");
}
void updateBarcode() {
String ref = "Document/Document/Barcode";
String lsc = getLastScanContents();
setFieldValue(ref, lsc);
}
]]></logic>
</module>