Fixed camera-improved-filename-format
[webos-internals:adamrmcd-modifications.git] / camera / camera-improved-filename-format.patch
1 diff --git a/usr/palm/applications/com.palm.app.camera/camera-prefs-defaults.json b/usr/palm/applications/com.palm.app.camera/camera-prefs-defaults.json
2 index 9b13336..6bf1ccc 100644
3 --- a/usr/palm/applications/com.palm.app.camera/camera-prefs-defaults.json
4 +++ b/usr/palm/applications/com.palm.app.camera/camera-prefs-defaults.json
5 @@ -7,7 +7,7 @@ CameraPrefsDefaultPrefs = {
6         'CAMERA-MAKE': 'Palm',
7         'CAMERA-MODEL': 'Pre ',
8         'COUNT': '1',
9 -       'FILE-PREFIX': 'CIMG',
10 +       'FILE-PREFIX': 'PRE_',
11         'GEOTAGGING': 'enabled',
12         'GPS-ACCURACY-METER': 'disabled',
13         'GPS-FIX-MAX-AGE': '120',
14 diff --git a/usr/palm/applications/com.palm.app.camera/javascripts/camera-control.js b/usr/palm/applications/com.palm.app.camera/javascripts/camera-control.js
15 index 951d7ce..746e54f 100644
16 --- a/usr/palm/applications/com.palm.app.camera/javascripts/camera-control.js
17 +++ b/usr/palm/applications/com.palm.app.camera/javascripts/camera-control.js
18 @@ -70,8 +70,14 @@ CameraControl = Class.create({
19                         
20                         // Create a filename using the image count and path info stored in preferences.
21                         var imgNum = this.prefs[CameraControl.PREFS.COUNT];
22 -                       var imgNumStr = "000"+imgNum;
23 -                       imgNumStr = imgNumStr.substring(imgNumStr.length-4);  
24 +                       var date = new Date();
25 +                       var YYYY = date.getFullYear();
26 +                       var MM = (1+date.getMonth()); if (MM<10) { MM = "0"+MM; }
27 +                       var DD = (0+date.getDate()); if (DD<10) { DD = "0"+DD; }
28 +                       var hh = date.getHours(); if (hh < 10) { hh = "0"+hh; }
29 +                       var mm = date.getMinutes(); if (mm < 10) { mm = "0"+mm; }
30 +                       var ss = date.getSeconds(); if (ss < 10) { ss = "0"+ss; }
31 +                       var fileBase = YYYY + "-" +  MM + "-" + DD + "-" + hh + mm + ss;
32         
33                         // Set file destination image
34                         cam.dst = this.prefs[CameraControl.PREFS.PATH]
35 @@ -79,25 +85,11 @@ CameraControl = Class.create({
36                                                                 + this.prefs[CameraControl.PREFS.MAKE].toUpperCase().substring(0,4)
37                                                                 + "/"
38                                                                 + this.prefs[CameraControl.PREFS.FILE]
39 -                                                               + imgNumStr
40 +                                                               + fileBase
41                                                                 +".jpg";
42  
43                         // Increment image count, but wrap at 10000, then save back to preferences
44                         ++imgNum;
45 -                       if (imgNum > 9999){
46 -                               imgNum = 1;
47 -       
48 -                               // Increment the album number (directory) so we don't overwrite the previous CIMG0001.jpg 
49 -                               var album = (+this.prefs[CameraControl.PREFS.ALBUM]);
50 -                               if (album == 900) {
51 -                                       album = 100;
52 -                               }
53 -                               else {
54 -                                       ++album;
55 -                               }
56 -                               CameraPrefs.updatePref(this.prefs, CameraControl.PREFS.ALBUM, album);
57 -                       }
58 -       
59                         CameraPrefs.updatePref(this.prefs, CameraControl.PREFS.COUNT, imgNum);
60                 }
61  
62 @@ -215,19 +207,6 @@ CameraControl = Class.create({
63                 
64                 // Increment image count - after all, the image we got from the adapter was the LAST CAPTURED
65                 ++image;
66 -               if (image > 9999) {
67 -                       image = 1;
68 -                       
69 -                       // Increment the album number (directory) so we don't overwrite the previous CIMG0001.jpg 
70 -                       if (album == 900) {
71 -                               album = 100;
72 -                       }
73 -                       else {
74 -                               ++album;
75 -                       }
76 -                       CameraPrefs.updatePref(this.prefs, CameraControl.PREFS.ALBUM, album);
77 -               }
78 -               
79                 CameraPrefs.updatePref(this.prefs, CameraControl.PREFS.COUNT, image);
80                 
81                 llog("ALBUM: " + album);