Reorganized everything into new structure
[webos-internals:adamrmcd-modifications.git] / sounds-and-alerts / sounds-and-alerts-select-alert-and-notification-tones.patch
1 diff --git a/usr/palm/applications/com.palm.app.soundsandalerts/app/controllers/soundsalertsconfig-assistant.js b/usr/palm/applications/com.palm.app.soundsandalerts/app/controllers/soundsalertsconfig-assistant.js
2 index f24c16c..5330fe4 100644
3 --- a/usr/palm/applications/com.palm.app.soundsandalerts/app/controllers/soundsalertsconfig-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.soundsandalerts/app/controllers/soundsalertsconfig-assistant.js
5 @@ -94,9 +94,13 @@ var SoundsalertsconfigAssistant = Class.create({
6                 $('system_ui_sounds').observe('mojo-property-change', this.toggleSystemUISounds.bindAsEventListener(this));
7                 
8                 $('currentringtonerow').observe(Mojo.Event.tap, this.showAudioFilePicker.bindAsEventListener(this));
9 +               $('currentalertrow').observe(Mojo.Event.tap, this.showAlertFilePicker.bindAsEventListener(this));
10 +               $('currentnotificationrow').observe(Mojo.Event.tap, this.showNotificationFilePicker.bindAsEventListener(this));
11                                 
12                 this.getCurrentVolumes();
13                 this.getCurrentRingtone();
14 +               this.getCurrentAlert();
15 +               this.getCurrentNotification();
16                 this.getVibrateSettings();      
17                 this.getOtherSettings();
18                 
19 @@ -260,6 +264,58 @@ var SoundsalertsconfigAssistant = Class.create({
20                 $('currentringtone').innerHTML = file.name;
21         },
22         
23 +       // Alert Picking
24 +       getCurrentAlert: function() {
25 +       this.getCurrentAlertReq = SystemService.getAlerts(this.getCurrentAlertQuery.bind(this));
26 +       },
27 +       
28 +       getCurrentAlertQuery: function(payload) {
29 +       if (payload.alerttone) {
30 +       $('currentalert').innerHTML = payload.alerttone.name;
31 +       this.currAlertPath = payload.alerttone.fullPath;
32 +       }
33 +       else 
34 +       $('currentalert').innerHTML = $L("Pick an alert");
35 +       
36 +       },
37 +       
38 +       showAlertFilePicker: function(event) {
39 +       var params = {"kinds": ["ringtone"],"filePath":this.currAlertPath,"onSelect":this.selectedAlertFile.bind(this),actionType:"attach",actionName: $L("Done")};
40 +       Mojo.FilePicker.pickFile(params,Mojo.Controller.stageController);
41 +       },
42 +       
43 +       selectedAlertFile: function(file) {
44 +       //var params = {"fullPath": encodeURIComponent(file.fullPath), "name":file.name};
45 +       this.setAlertReq = SystemService.setAlerts(file);
46 +       $('currentalert').innerHTML = file.name;
47 +       },
48 +       
49 +       // Notification Picking
50 +       getCurrentNotification: function() {
51 +       this.getCurrentNotificationReq = SystemService.getNotifications(this.getCurrentNotificationQuery.bind(this));
52 +       },
53 +       
54 +       getCurrentNotificationQuery: function(payload) {
55 +       if (payload.notificationtone) {
56 +       $('currentnotification').innerHTML = payload.notificationtone.name;
57 +       this.currNotificationPath = payload.notificationtone.fullPath;
58 +       }
59 +       else 
60 +       $('currentnotification').innerHTML = $L("Pick a notification");
61 +       
62 +       },
63 +       
64 +       showNotificationFilePicker: function(event) {
65 +       var params = {"kinds": ["ringtone"],"filePath":this.currNotificationPath,"onSelect":this.selectedNotificationFile.bind(this),actionType:"attach",actionName: $L("Done")};
66 +       Mojo.FilePicker.pickFile(params,Mojo.Controller.stageController);
67 +       },
68 +       
69 +       selectedNotificationFile: function(file) {
70 +       //var params = {"fullPath": encodeURIComponent(file.fullPath), "name":file.name};
71 +       this.setNotificationReq = SystemService.setNotifications(file);
72 +       $('currentnotification').innerHTML = file.name;
73 +       },
74 +       
75         getVibrateSettings: function() {
76                 this.getVibrateSettingsReq = AudioService.getVibrateSettings(this.vibrateSettingsCB.bind(this),this);
77         },
78 diff --git a/usr/palm/applications/com.palm.app.soundsandalerts/app/models/SystemService.js b/usr/palm/applications/com.palm.app.soundsandalerts/app/models/SystemService.js
79 index c5babe5..68e70d0 100644
80 --- a/usr/palm/applications/com.palm.app.soundsandalerts/app/models/SystemService.js
81 +++ b/usr/palm/applications/com.palm.app.soundsandalerts/app/models/SystemService.js
82 @@ -28,6 +28,42 @@ SystemService.getRingtone = function(callback) {
83         return request;
84  }
85  
86 +SystemService.getAlerts = function(callback) {
87 +       var request = new Mojo.Service.Request(SystemService.identifier, {
88 +               method: 'getPreferences',
89 +               parameters: {"keys":["alerttone"]}, 
90 +               onSuccess: callback,
91 +               onFailure: callback
92 +       });
93 +       return request;
94 +}
95 +
96 +SystemService.setAlerts = function(value){
97 +       var request = new Mojo.Service.Request(SystemService.identifier, {
98 +               method: 'setPreferences',
99 +               parameters: {"alerttone":value}, 
100 +       });
101 +       return request;
102 +}
103 +
104 +SystemService.getNotifications = function(callback) {
105 +       var request = new Mojo.Service.Request(SystemService.identifier, {
106 +               method: 'getPreferences',
107 +               parameters: {"keys":["notificationtone"]}, 
108 +               onSuccess: callback,
109 +               onFailure: callback
110 +       });
111 +       return request;
112 +}
113 +
114 +SystemService.setNotifications = function(value){
115 +       var request = new Mojo.Service.Request(SystemService.identifier, {
116 +               method: 'setPreferences',
117 +               parameters: {"notificationtone":value}, 
118 +       });
119 +       return request;
120 +}
121 +
122  SystemService.getSystemUISounds = function(callback) {
123         var request = new Mojo.Service.Request(SystemService.identifier, {
124                         method: 'getPreferences',
125 diff --git a/usr/palm/applications/com.palm.app.soundsandalerts/app/views/soundsalertsconfig/soundsalertsconfig-scene.html b/usr/palm/applications/com.palm.app.soundsandalerts/app/views/soundsalertsconfig/soundsalertsconfig-scene.html
126 index b73157c..7ed29ab 100644
127 --- a/usr/palm/applications/com.palm.app.soundsandalerts/app/views/soundsalertsconfig/soundsalertsconfig-scene.html
128 +++ b/usr/palm/applications/com.palm.app.soundsandalerts/app/views/soundsalertsconfig/soundsalertsconfig-scene.html
129 @@ -52,9 +52,21 @@
130                         </div>
131                     </div>
132              </div>
133 +           <div id='currentalertrow' class="palm-row" x-mojo-tap-highlight="momentary">
134 +               <div class="palm-row-wrapper">
135 +                               <div class="label" x-mojo-loc=''>Alert</div>
136 +                       <div id='currentalert' class="title"></div> 
137 +               </div>
138 +           </div>
139 +           <div id='currentnotificationrow' class="palm-row" x-mojo-tap-highlight="momentary">
140 +                       <div class="palm-row-wrapper">
141 +                               <div class="label" x-mojo-loc=''>Notification</div>
142 +                       <div id='currentnotification' class="title"></div>  
143 +               </div>
144 +           </div>
145                         <div class="palm-row last">
146                                 <div class="palm-row-wrapper">
147 -                                       <div class="title" x-mojo-loc=''>Volume</div>
148 +                                       <div class="title" x-mojo-loc=''>System Volume</div>
149                                         <div x-mojo-element="Slider" id='systemvolume' class="palm-slider"></div>
150                     </div>
151              </div>