Renamed more-icons-per-row-5x4-flare576
[webos-internals:adamrmcd-modifications.git] / camera / capture_with_volume_keys.patch
1 This patch will allow you capture a picture using the volume keys.
2
3 Tested on: 1.2
4
5 Index: /usr/palm/applications/com.palm.app.camera/app/controllers/capture-assistant.js
6 --- .orig/usr/palm/applications/com.palm.app.camera/app/controllers/capture-assistant.js
7 +++ /usr/palm/applications/com.palm.app.camera/app/controllers/capture-assistant.js
8 @@ -34,6 +34,7 @@ CaptureAssistant = Class.create({
9                         this.sublaunch = false;
10                         this.defaultFilename = null;
11                 }
12 +               this.volumeKeySubscription = undefined;         
13                 
14         },
15  
16 @@ -87,6 +88,15 @@ CaptureAssistant = Class.create({
17                         var elemC = this.controller.get('sagar_console');
18                         elemC.style.display = '';
19                 }
20 +               // listen to volume key events
21 +               this.volumeKeySubscription = new Mojo.Service.Request(
22 +                       'palm://com.palm.keys/audio', 
23 +                       {
24 +                               method: 'status',
25 +                               parameters: {'subscribe': true},
26 +                               onFailure: function() { Mojo.Log.error("Could not subscribe to volume key events"); },
27 +                               onSuccess: this.handleVolumeKeys.bind(this), 
28 +                       });
29                 
30                 llog("CaptureAssistant::setup() finished");
31         },
32 @@ -174,6 +184,11 @@ CaptureAssistant = Class.create({
33                 }
34                 
35                 this.cameraControl.closeCamera();
36 +               
37 +               // clean up listener for volume keys
38 +               if(this.volumeKeySubscription) {
39 +                       this.volumeKeySubscription.cancel();
40 +               }
41         },
42         
43         handleCommand: function(event){
44 @@ -210,6 +225,13 @@ CaptureAssistant = Class.create({
45  
46         },
47    
48 +       // capture on release of volume keys
49 +       handleVolumeKeys: function(payload) {
50 +               // capture when either volume up or down buttons are released
51 +               if(payload.state === 'up' && (payload.key === 'volume_up' || payload.key === 'volume_down')) {
52 +                       this.cameraControl.capture();
53 +               }
54 +       },
55         
56         /**
57          * Called by Mojo when the orientation of the device changes.