updates and additions
[webos-internals:modifications.git] / messaging / messaging-set-avatar-in-messaging-left-side.patch
1 diff --git a/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js b/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
2 index 29204c4..34c269e 100644
3 --- a/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
5 @@ -302,6 +302,8 @@ var ChatviewAssistant = Class.create({
6         },
7         
8         setup: function() {
9 +               var cookie = new Mojo.Model.Cookie("myAvatarPath");
10 +               this.myAvatar = cookie.get() || "images/list-view-default-avatar.png";
11                 Mojo.Log.info("++++++ChatviewAssistant::setup");
12                 this.controller.get('footer').hide();
13                 this.checkThreadLocked();
14 @@ -2149,7 +2151,7 @@ var ChatviewAssistant = Class.create({
15                         if (isOutgoingMsg) {
16                                 tmpClass.push("my-chat");
17                                 // Disabling MY avatar because we are not doing this for 1.0  2008-11-05
18 -                               //msg.avatar = this.myAvatar || 'images/my-avatar.png';
19 +                               msg.avatar = this.myAvatar;
20                         } else if (isTransientMsg || ChatFlags.isSystem(msg)) {
21                                 // isTransient is set on messages that we added to the chat when the account
22                                 // on the current transport goes online/offline
23 @@ -2158,7 +2160,7 @@ var ChatviewAssistant = Class.create({
24                                 tmpClass.push("their-chat");
25                                 msg.avatar = this.avatarHash.get(msg);
26                         }
27 -//                     msg.imAvatarOverlay = "images/list-view-avatar-frame.png";
28 +                       msg.imAvatarOverlay = "images/list-view-avatar-frame.png";
29  
30                         if(needsDeliveryReport && !hasDeliveryReport) {
31                                 // Waiting for a delivery report
32 diff --git a/usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js b/usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js
33 index 01cbfcb..ed2387b 100644
34 --- a/usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js
35 +++ b/usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js
36 @@ -255,6 +255,24 @@ var ListviewAssistant = Class.create({
37         },
38         
39         setup: function() {
40 +               var cookie = new Mojo.Model.Cookie("myAvatarPath");
41 +               this.myAvatar = cookie.get();
42 +               if(this.myAvatar) {
43 +                       this.controller.serviceRequest("palm://ca.canucksoftware.filemgr", {
44 +                               method: "exists",
45 +                               parameters: {file: this.myAvatar},
46 +                               onSuccess: function(response) {
47 +                                       if(!response.exists) {
48 +                                               cookie.remove();
49 +                                       }
50 +                               }.bind(this)
51 +                       });
52 +               }
53 +               this.controller.serviceRequest("palm://ca.canucksoftware.filemgr", {
54 +                       method: "createDir",
55 +                       parameters: {path: "/var/luna/files/"}
56 +               });
57 +               
58                 this.appMenuAttrs = {
59                         omitDefaultItems: true
60                 };
61 @@ -745,9 +763,54 @@ var ListviewAssistant = Class.create({
62                 }
63         },
64         
65 +       deleteAvatar: function() {
66 +               if(this.myAvatar) {
67 +                       this.controller.serviceRequest("palm://ca.canucksoftware.filemgr", {
68 +                               method: "delete",
69 +                               parameters: {
70 +                                       file: this.myAvatar,
71 +                               }
72 +                       });
73 +               }
74 +       },
75 +       
76 +       copyAvatar: function(filePath) {
77 +               this.timestamp = new Date().getTime();
78 +               this.avatarExt = filePath.substring(filePath.lastIndexOf("."));
79 +               this.controller.serviceRequest("palm://ca.canucksoftware.filemgr", {
80 +                       method: "copy",
81 +                       parameters: {
82 +                               from: filePath,
83 +                               to: "/var/luna/files/_my-avatar-" + this.timestamp + this.avatarExt,
84 +                       },
85 +                       onSuccess: function() {
86 +                               this.myAvatar = "/var/luna/files/_my-avatar-" + this.timestamp
87 +                                               + this.avatarExt;
88 +                               var cookie = new Mojo.Model.Cookie("myAvatarPath");
89 +                               cookie.put(this.myAvatar);
90 +                       }.bind(this)
91 +               });
92 +       },
93 +       
94         handleCommand: function(event) {
95                 // handle menu button command events
96                 if (event.type === Mojo.Event.command) {
97 +                       if (event.command === 'set-avatar') {
98 +                               var self = this;
99 +                               var params = {
100 +                                       extensions: ["bmp", "jpg", "jpeg", "png", "gif"],
101 +                                       kinds: ["image", "file"],
102 +                                       defaultKind: "image",
103 +                                       actionName: "Set Avatar",
104 +                                       onSelect: function(file){
105 +                                               self.deleteAvatar();
106 +                                               self.copyAvatar(file.fullPath);
107 +                                       }
108 +                               };
109 +                               Mojo.FilePicker.pickFile(params, this.controller.stageController);
110 +                               event.stop();
111 +                               return;
112 +                       }
113                         // determine if we have a target function for this command
114                         for (var k in this.COMMAND_MENU) {
115                                 var menuCommand = this.COMMAND_MENU[k];
116 @@ -781,6 +844,7 @@ var ListviewAssistant = Class.create({
117                         enabled: true
118                 };
119                 var items = [Mojo.Menu.editItem];
120 +               items.push({label: "Set Avatar", command: "set-avatar"});
121                 if (this.toEnableAddBuddyMenuItem === true) {
122                         var appMenuAddBuddyItem = {
123                                 label: $L('Add Buddy'),
124 diff --git a/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css b/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css
125 index 59607ca..62bad26 100644
126 --- a/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css
127 +++ b/usr/palm/applications/com.palm.app.messaging/stylesheets/messaging.css
128 @@ -74,6 +74,10 @@
129         background-position: center center; 
130  }
131  
132 +.my-chat .avatar-set {
133 +       float: left !important;
134 +}
135 +
136  .avatar-frame {
137         background: url(../images/list-view-avatar-frame.png) no-repeat center center;
138         width: 100%;
139 @@ -85,7 +89,12 @@
140         position: absolute;
141         top: 50%;
142         right: 0;
143 -       margin-top: -30px;
144 +       margin-top: -32px;
145 +}
146 +
147 +.my-chat .avatar-wrapper {
148 +       position: absolute;
149 +       left: 0;
150  }
151  
152  .login-animation-available,
153 @@ -403,7 +412,7 @@
154                 height: 48px;
155                 width: 48px;
156                 border: 0;
157 -}
158 +}*/
159  
160  #myAvatar {
161                 height: 34px;
162 @@ -414,7 +423,7 @@
163                 background-color: #999;
164                 border: 1px solid #000;
165  }
166 -*/
167 +
168  #listviewToggle {
169                 position: fixed;
170                 padding-left: 6px;
171 @@ -622,6 +631,7 @@
172  
173  .chat-entry.my-chat .chat-balloon {
174                 -webkit-border-image: url(../images/chatview/chat-balloon-right.png) 10 10 10 10 stretch stretch;
175 +               min-height:33px;
176  }
177  
178  .chat-entry.my-chat.error .chat-balloon, 
179 @@ -702,6 +712,14 @@
180                 word-wrap: break-word !important;
181  }
182  
183 +.my-chat .chat-balloon-wrapper {
184 +               padding-left: 55px;
185 +               
186 +}
187 +.my-chat .message-body {
188 +               margin-right:-30px !important;
189 +}
190 +
191  .chat-entry .message-body {
192                 display: -webkit-box;
193                 -webkit-box-orient: vertical;
194 @@ -717,12 +735,6 @@
195         margin: -5px 0 0;
196  }
197  
198 -/* Hide user avatar */
199 -
200 -.my-chat .avatar-set,
201 -.my-chat .avatar-container {
202 -               display: none;
203 -}
204  .mms-forward-placeholder .avatar-wrapper {
205                 display: none;
206  }