Patches.
[webos-internals:modifications.git] / camera / camera-capture-with-volume-keys.patch
1 diff --git a/usr/palm/applications/com.palm.app.camera/app/controllers/capture-assistant.js b/usr/palm/applications/com.palm.app.camera/app/controllers/capture-assistant.js
2 index 52ad9da..4193ea2 100644
3 --- a/usr/palm/applications/com.palm.app.camera/app/controllers/capture-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.camera/app/controllers/capture-assistant.js
5 @@ -134,7 +134,7 @@ CaptureAssistant = Class.create({
6                                 this._handleCaptureToggle();
7                         }.bind(this));
8                 }
9 -               
10 +               this.volumeKeySubscription = null;
11                 
12                 
13                 this.onKeyPressHandler = this.onKeyPress.bindAsEventListener(this);
14 @@ -164,7 +164,16 @@ CaptureAssistant = Class.create({
15                         AppAssistant.photoRollVideoLoader = AppAssistant.libraries["metascene.videos"];
16  
17                 }
18 -               
19 +               // listen to volume key events
20 +               this.volumeKeySubscription = new Mojo.Service.Request(
21 +                       'palm://com.palm.keys/audio', 
22 +                       {
23 +                               method: 'status',
24 +                               parameters: {'subscribe': true},
25 +                               onFailure: function() { Mojo.Log.error("Could not subscribe to volume key events"); },
26 +                               onSuccess: this.handleVolumeKeys.bind(this), 
27 +                       });
28 +                       
29                 llog("CaptureAssistant::setup() finished");
30         }catch(e){llog("setup threw: "+Object.toJSON(e));}},
31         
32 @@ -332,6 +341,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 @@ -382,6 +396,14 @@ CaptureAssistant = Class.create({
45                         this.cameraControl.stillCapture();
46                 }
47         },
48 +       
49 +       // capture on release of volume keys
50 +       handleVolumeKeys: function(payload) {
51 +               // capture when either volume up or down buttons are released
52 +               if(payload.state === 'up' && (payload.key === 'volume_up' || payload.key === 'volume_down')) {
53 +                       this.cameraControl.stillCapture();
54 +               }
55 +       },
56    
57         
58         /**