Merge lp:~ken-vandine/webapps-core/facebook-userscript into lp:webapps-core
- facebook-userscript
- Merge into trunk
Proposed by
Ken VanDine
Status: | Merged |
---|---|
Merged at revision: | 52 |
Proposed branch: | lp:~ken-vandine/webapps-core/facebook-userscript |
Merge into: | lp:webapps-core |
Diff against target: |
604 lines (+518/-6) 8 files modified
webapp-facebook/content-hub/webapp-facebook.json (+5/-0) webapp-facebook/manifest.json (+4/-4) webapp-facebook/unity-webapps-facebook/HubSharer.qml (+65/-0) webapp-facebook/unity-webapps-facebook/Share.qml (+383/-0) webapp-facebook/unity-webapps-facebook/facebook.user.js (+51/-0) webapp-facebook/unity-webapps-facebook/manifest.json (+7/-0) webapp-facebook/webapp-facebook.desktop (+1/-1) webapp-facebook/webapp-facebook.json (+2/-1) |
To merge this branch: | bzr merge lp:~ken-vandine/webapps-core/facebook-userscript |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Barth | Pending | ||
Review via email: mp+223991@code.launchpad.net |
Commit message
Implements a share handler in the facebook webapp.
Description of the change
Implements a share handler in the facebook webapp. This requires updates[1] to unity-webapps-qml to be fully functional.
[1] https:/
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'webapp-facebook/content-hub' | |||
2 | === added file 'webapp-facebook/content-hub/webapp-facebook.json' | |||
3 | --- webapp-facebook/content-hub/webapp-facebook.json 1970-01-01 00:00:00 +0000 | |||
4 | +++ webapp-facebook/content-hub/webapp-facebook.json 2014-06-20 21:39:29 +0000 | |||
5 | @@ -0,0 +1,5 @@ | |||
6 | 1 | { | ||
7 | 2 | "share": [ | ||
8 | 3 | "pictures" | ||
9 | 4 | ] | ||
10 | 5 | } | ||
11 | 0 | 6 | ||
12 | === modified file 'webapp-facebook/manifest.json' | |||
13 | --- webapp-facebook/manifest.json 2014-06-20 13:54:52 +0000 | |||
14 | +++ webapp-facebook/manifest.json 2014-06-20 21:39:29 +0000 | |||
15 | @@ -1,11 +1,12 @@ | |||
16 | 1 | { | 1 | { |
17 | 2 | "description": "Facebook (webapp version)", | 2 | "description": "Facebook (webapp version)", |
19 | 3 | "framework": "ubuntu-sdk-14.04-dev1", | 3 | "framework": "ubuntu-sdk-14.10-dev1", |
20 | 4 | "architecture": "all", | 4 | "architecture": "all", |
21 | 5 | "hooks": { | 5 | "hooks": { |
22 | 6 | "webapp-facebook": { | 6 | "webapp-facebook": { |
23 | 7 | "account-application": "webapp-facebook.application", | 7 | "account-application": "webapp-facebook.application", |
25 | 8 | "account-service": "facebook-webapp.service", | 8 | "content-hub": "content-hub/webapp-facebook.json", |
26 | 9 | "account-service": "webapp-facebook.service", | ||
27 | 9 | "apparmor": "webapp-facebook.json", | 10 | "apparmor": "webapp-facebook.json", |
28 | 10 | "desktop": "webapp-facebook.desktop" | 11 | "desktop": "webapp-facebook.desktop" |
29 | 11 | } | 12 | } |
30 | @@ -13,6 +14,5 @@ | |||
31 | 13 | "maintainer": "Webapps Team <webapps@lists.launchpad.net>", | 14 | "maintainer": "Webapps Team <webapps@lists.launchpad.net>", |
32 | 14 | "name": "com.ubuntu.developer.webapps.webapp-facebook", | 15 | "name": "com.ubuntu.developer.webapps.webapp-facebook", |
33 | 15 | "title": "webapp-facebook", | 16 | "title": "webapp-facebook", |
35 | 16 | "version": "1.0.13" | 17 | "version": "1.0.13.2" |
36 | 17 | } | 18 | } |
37 | 18 | |||
38 | 19 | 19 | ||
39 | === added directory 'webapp-facebook/unity-webapps-facebook' | |||
40 | === added file 'webapp-facebook/unity-webapps-facebook/HubSharer.qml' | |||
41 | --- webapp-facebook/unity-webapps-facebook/HubSharer.qml 1970-01-01 00:00:00 +0000 | |||
42 | +++ webapp-facebook/unity-webapps-facebook/HubSharer.qml 2014-06-20 21:39:29 +0000 | |||
43 | @@ -0,0 +1,65 @@ | |||
44 | 1 | import QtQuick 2.0 | ||
45 | 2 | import Ubuntu.Components 0.1 | ||
46 | 3 | import Ubuntu.Content 0.1 | ||
47 | 4 | |||
48 | 5 | Item { | ||
49 | 6 | id: main | ||
50 | 7 | anchors.fill: parent | ||
51 | 8 | |||
52 | 9 | signal completed(string result, var uploadCompletedCallback) | ||
53 | 10 | |||
54 | 11 | property string fileToShare | ||
55 | 12 | |||
56 | 13 | function _callback(accessToken, fileToShare, message, uploadCompletedCallback) { | ||
57 | 14 | |||
58 | 15 | itemComp.url = fileToShare; | ||
59 | 16 | var dataUri = itemComp.toDataURI(); | ||
60 | 17 | var result = {accessToken: accessToken, | ||
61 | 18 | fileToShare: dataUri.toString(), | ||
62 | 19 | message: message}; | ||
63 | 20 | |||
64 | 21 | completed(JSON.stringify(result), uploadCompletedCallback); | ||
65 | 22 | } | ||
66 | 23 | |||
67 | 24 | ContentItem { | ||
68 | 25 | id: itemComp | ||
69 | 26 | } | ||
70 | 27 | |||
71 | 28 | Rectangle { | ||
72 | 29 | anchors.fill: parent | ||
73 | 30 | color: UbuntuColors.lightGrey | ||
74 | 31 | |||
75 | 32 | Image { | ||
76 | 33 | id: background | ||
77 | 34 | anchors { | ||
78 | 35 | left: parent.left | ||
79 | 36 | right: parent.right | ||
80 | 37 | bottom: parent.bottom | ||
81 | 38 | } | ||
82 | 39 | source: Qt.resolvedUrl("assets/background_full.png") | ||
83 | 40 | } | ||
84 | 41 | } | ||
85 | 42 | |||
86 | 43 | Share { | ||
87 | 44 | id: share | ||
88 | 45 | anchors.fill: parent | ||
89 | 46 | visible: true | ||
90 | 47 | fileToShare: main.fileToShare | ||
91 | 48 | callback: _callback | ||
92 | 49 | provider: "facebook" | ||
93 | 50 | onCanceled: { | ||
94 | 51 | completed(JSON.stringify({status: "cancelled"}), uploadCompleted); | ||
95 | 52 | parent.destroy(); | ||
96 | 53 | } | ||
97 | 54 | onUploadCompleted: { | ||
98 | 55 | console.log (success); | ||
99 | 56 | /* if the upload was successful, we need to destroy the parent */ | ||
100 | 57 | if (success) { | ||
101 | 58 | parent.destroy(); | ||
102 | 59 | } else { | ||
103 | 60 | console.error ("Upload failed"); | ||
104 | 61 | /* FIXME: Display a message to the user */ | ||
105 | 62 | } | ||
106 | 63 | } | ||
107 | 64 | } | ||
108 | 65 | } | ||
109 | 0 | 66 | ||
110 | === added file 'webapp-facebook/unity-webapps-facebook/Share.qml' | |||
111 | --- webapp-facebook/unity-webapps-facebook/Share.qml 1970-01-01 00:00:00 +0000 | |||
112 | +++ webapp-facebook/unity-webapps-facebook/Share.qml 2014-06-20 21:39:29 +0000 | |||
113 | @@ -0,0 +1,383 @@ | |||
114 | 1 | /* | ||
115 | 2 | * Copyright (C) 2012-2013 Canonical, Ltd. | ||
116 | 3 | * | ||
117 | 4 | * This program is free software; you can redistribute it and/or modify | ||
118 | 5 | * it under the terms of the GNU General Public License as published by | ||
119 | 6 | * the Free Software Foundation; version 3. | ||
120 | 7 | * | ||
121 | 8 | * This program is distributed in the hope that it will be useful, | ||
122 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
123 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
124 | 11 | * GNU General Public License for more details. | ||
125 | 12 | * | ||
126 | 13 | * You should have received a copy of the GNU General Public License | ||
127 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
128 | 15 | */ | ||
129 | 16 | |||
130 | 17 | import QtQuick 2.0 | ||
131 | 18 | import QtQuick.Window 2.0 | ||
132 | 19 | import Ubuntu.Components 0.1 | ||
133 | 20 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
134 | 21 | import Ubuntu.OnlineAccounts 0.1 | ||
135 | 22 | import Ubuntu.OnlineAccounts.Client 0.1 | ||
136 | 23 | |||
137 | 24 | Item { | ||
138 | 25 | id: root | ||
139 | 26 | anchors.fill: parent | ||
140 | 27 | property string fileToShare | ||
141 | 28 | property var callback | ||
142 | 29 | property string serviceType: "webapps" | ||
143 | 30 | property string provider: "facebook" | ||
144 | 31 | property string userAccountId | ||
145 | 32 | property string accessToken | ||
146 | 33 | property var account | ||
147 | 34 | signal accountSelected | ||
148 | 35 | signal canceled | ||
149 | 36 | signal uploadCompleted(bool success) | ||
150 | 37 | |||
151 | 38 | onUploadCompleted: { | ||
152 | 39 | activitySpinner.visible = false; | ||
153 | 40 | if (success) | ||
154 | 41 | print ("Successfully posted"); | ||
155 | 42 | else | ||
156 | 43 | print ("Failed to post"); | ||
157 | 44 | } | ||
158 | 45 | |||
159 | 46 | AccountServiceModel { | ||
160 | 47 | id: accounts | ||
161 | 48 | serviceType: root.serviceType | ||
162 | 49 | provider: root.provider | ||
163 | 50 | Component.onCompleted: { | ||
164 | 51 | if (count == 1) { | ||
165 | 52 | srv.objectHandle = get(0, "accountServiceHandle"); | ||
166 | 53 | } | ||
167 | 54 | } | ||
168 | 55 | } | ||
169 | 56 | |||
170 | 57 | AccountService { | ||
171 | 58 | id: srv | ||
172 | 59 | onObjectHandleChanged: { | ||
173 | 60 | root.account = srv; | ||
174 | 61 | root.account.authenticate(null); | ||
175 | 62 | } | ||
176 | 63 | onAuthenticated: { | ||
177 | 64 | root.userAccountId = accountId; | ||
178 | 65 | root.accessToken = reply.AccessToken; | ||
179 | 66 | shareComponent.visible = true; | ||
180 | 67 | sharemenu.visible = false; | ||
181 | 68 | } | ||
182 | 69 | } | ||
183 | 70 | |||
184 | 71 | Item { | ||
185 | 72 | id: shareComponent | ||
186 | 73 | objectName: "shareComponent" | ||
187 | 74 | anchors { | ||
188 | 75 | left: parent.left | ||
189 | 76 | right: parent.right | ||
190 | 77 | } | ||
191 | 78 | visible: false | ||
192 | 79 | |||
193 | 80 | Column { | ||
194 | 81 | anchors.fill: parent | ||
195 | 82 | spacing: units.gu(1) | ||
196 | 83 | |||
197 | 84 | Item { | ||
198 | 85 | id: serviceHeader | ||
199 | 86 | y: 0 | ||
200 | 87 | anchors.left: parent.left | ||
201 | 88 | anchors.right: parent.right | ||
202 | 89 | anchors.topMargin: units.gu(1) | ||
203 | 90 | anchors.leftMargin: units.gu(1) | ||
204 | 91 | anchors.rightMargin: units.gu(1) | ||
205 | 92 | height: childrenRect.height | ||
206 | 93 | |||
207 | 94 | ListItem.Subtitled { | ||
208 | 95 | anchors { | ||
209 | 96 | left: parent.left | ||
210 | 97 | right: parent.right | ||
211 | 98 | } | ||
212 | 99 | iconName: root.account.provider.iconName | ||
213 | 100 | text: root.account.provider.displayName | ||
214 | 101 | subText: root.account.displayName | ||
215 | 102 | showDivider: false | ||
216 | 103 | } | ||
217 | 104 | } | ||
218 | 105 | |||
219 | 106 | ListItem.ThinDivider {} | ||
220 | 107 | |||
221 | 108 | UbuntuShape { | ||
222 | 109 | id: messageArea | ||
223 | 110 | objectName: "messageArea" | ||
224 | 111 | anchors.left: parent.left | ||
225 | 112 | anchors.right: parent.right | ||
226 | 113 | anchors.topMargin: units.gu(1) | ||
227 | 114 | anchors.leftMargin: units.gu(1) | ||
228 | 115 | anchors.rightMargin: units.gu(1) | ||
229 | 116 | height: units.gu(20) | ||
230 | 117 | color: "#f2f2f2" | ||
231 | 118 | |||
232 | 119 | TextArea { | ||
233 | 120 | id: message | ||
234 | 121 | //color: "#333333" | ||
235 | 122 | anchors.top: parent.top | ||
236 | 123 | anchors.left: snapshot.right | ||
237 | 124 | anchors.bottom: parent.bottom | ||
238 | 125 | anchors.margins: units.gu(1) | ||
239 | 126 | wrapMode: Text.Wrap | ||
240 | 127 | width: parent.width - snapshot.width - | ||
241 | 128 | snapshot.anchors.margins * 2 - | ||
242 | 129 | message.anchors.leftMargin - message.anchors.rightMargin | ||
243 | 130 | clip: true | ||
244 | 131 | font.pixelSize: FontUtils.sizeToPixels("medium") | ||
245 | 132 | font.weight: Font.Light | ||
246 | 133 | focus: true | ||
247 | 134 | } | ||
248 | 135 | |||
249 | 136 | ActivityIndicator { | ||
250 | 137 | id: activitySpinner | ||
251 | 138 | anchors.centerIn: message | ||
252 | 139 | visible: false | ||
253 | 140 | running: visible | ||
254 | 141 | } | ||
255 | 142 | |||
256 | 143 | UbuntuShape { | ||
257 | 144 | id: snapshot | ||
258 | 145 | anchors.top: parent.top | ||
259 | 146 | anchors.left: parent.left | ||
260 | 147 | anchors.margins: units.gu(1) | ||
261 | 148 | width: units.gu(10) | ||
262 | 149 | height: units.gu(10) | ||
263 | 150 | |||
264 | 151 | image: Image { | ||
265 | 152 | source: fileToShare | ||
266 | 153 | sourceSize.height: snapshot.height | ||
267 | 154 | sourceSize.width: snapshot.width | ||
268 | 155 | fillMode: Image.PreserveAspectCrop | ||
269 | 156 | } | ||
270 | 157 | } | ||
271 | 158 | } | ||
272 | 159 | |||
273 | 160 | Item { | ||
274 | 161 | id: actionsBar | ||
275 | 162 | anchors.left: parent.left | ||
276 | 163 | anchors.right: parent.right | ||
277 | 164 | anchors.topMargin: units.gu(2) | ||
278 | 165 | anchors.leftMargin: units.gu(1) | ||
279 | 166 | anchors.rightMargin: units.gu(1) | ||
280 | 167 | height: childrenRect.height | ||
281 | 168 | |||
282 | 169 | Button { | ||
283 | 170 | objectName: "cancelButton" | ||
284 | 171 | anchors.left: parent.left | ||
285 | 172 | text: i18n.dtr("ubuntu-ui-extras", "Cancel") | ||
286 | 173 | color: "#cccccc" | ||
287 | 174 | width: units.gu(10) | ||
288 | 175 | height: units.gu(4) | ||
289 | 176 | onClicked: canceled() | ||
290 | 177 | } | ||
291 | 178 | |||
292 | 179 | Button { | ||
293 | 180 | objectName: "postButton" | ||
294 | 181 | anchors.right: parent.right | ||
295 | 182 | anchors.top: parent.top | ||
296 | 183 | text: i18n.dtr("ubuntu-ui-extras", "Post") | ||
297 | 184 | color: "#dd4814" | ||
298 | 185 | width: units.gu(10) | ||
299 | 186 | height: units.gu(4) | ||
300 | 187 | enabled: !activitySpinner.visible | ||
301 | 188 | onClicked: { | ||
302 | 189 | activitySpinner.visible = true; | ||
303 | 190 | callback(accessToken, fileToShare, message.text, uploadCompleted); | ||
304 | 191 | } | ||
305 | 192 | } | ||
306 | 193 | } | ||
307 | 194 | |||
308 | 195 | // toggle to enable including location - Not implemented yet | ||
309 | 196 | /* | ||
310 | 197 | UbuntuShape { | ||
311 | 198 | id: useLocation | ||
312 | 199 | anchors { | ||
313 | 200 | left: parent.left | ||
314 | 201 | leftMargin: units.gu(1) | ||
315 | 202 | topMargin: units.gu(1) | ||
316 | 203 | } | ||
317 | 204 | color: selected ? "#cccccc" : "transparent" | ||
318 | 205 | property bool selected: false | ||
319 | 206 | width: units.gu(4.5) | ||
320 | 207 | height: units.gu(4) | ||
321 | 208 | |||
322 | 209 | AbstractButton { | ||
323 | 210 | anchors.fill: parent | ||
324 | 211 | onClicked: parent.selected = !parent.selected | ||
325 | 212 | Image { | ||
326 | 213 | source: "assets/icon_location.png" | ||
327 | 214 | anchors.centerIn: parent | ||
328 | 215 | height: parent.height * 0.75 | ||
329 | 216 | fillMode: Image.PreserveAspectFit | ||
330 | 217 | smooth: true | ||
331 | 218 | } | ||
332 | 219 | } | ||
333 | 220 | } | ||
334 | 221 | |||
335 | 222 | Label { | ||
336 | 223 | anchors.left: useLocation.right | ||
337 | 224 | anchors.baseline: useLocation.top | ||
338 | 225 | anchors.baselineOffset: units.gu(3) | ||
339 | 226 | anchors.leftMargin: units.gu(1) | ||
340 | 227 | text: i18n.dtr("ubuntu-ui-extras", "Include location") | ||
341 | 228 | fontSize: "small" | ||
342 | 229 | } | ||
343 | 230 | */ | ||
344 | 231 | // End location toggle | ||
345 | 232 | |||
346 | 233 | } | ||
347 | 234 | |||
348 | 235 | states: [ | ||
349 | 236 | State { | ||
350 | 237 | name: "landscape-with-keyborad" | ||
351 | 238 | PropertyChanges { | ||
352 | 239 | target: serviceHeader | ||
353 | 240 | y: - serviceHeader.height | ||
354 | 241 | } | ||
355 | 242 | PropertyChanges { | ||
356 | 243 | target: messageArea | ||
357 | 244 | height: units.gu(12) | ||
358 | 245 | } | ||
359 | 246 | } | ||
360 | 247 | ] | ||
361 | 248 | |||
362 | 249 | state: ((Screen.orientation === Qt.LandscapeOrientation) || | ||
363 | 250 | (Screen.orientation === Qt.InvertedLandscapeOrientation)) && | ||
364 | 251 | Qt.inputMethod.visible ? "landscape-with-keyborad" : "" | ||
365 | 252 | } | ||
366 | 253 | |||
367 | 254 | /* Menu listing online accounts */ | ||
368 | 255 | Item { | ||
369 | 256 | id: sharemenu | ||
370 | 257 | anchors.fill: parent | ||
371 | 258 | visible: true | ||
372 | 259 | |||
373 | 260 | signal selected(string accountId, string token) | ||
374 | 261 | |||
375 | 262 | Component.onCompleted: { | ||
376 | 263 | visible = true; | ||
377 | 264 | } | ||
378 | 265 | onSelected: { | ||
379 | 266 | root.userAccountId = accountId; | ||
380 | 267 | root.accessToken = token; | ||
381 | 268 | shareComponent.visible = true; | ||
382 | 269 | sharemenu.visible = false; | ||
383 | 270 | } | ||
384 | 271 | |||
385 | 272 | Component { | ||
386 | 273 | id: acctDelegate | ||
387 | 274 | Item { | ||
388 | 275 | anchors { | ||
389 | 276 | left: parent.left | ||
390 | 277 | right: parent.right | ||
391 | 278 | } | ||
392 | 279 | AccountService { | ||
393 | 280 | id: service | ||
394 | 281 | objectHandle: accountServiceHandle | ||
395 | 282 | onAuthenticated: { | ||
396 | 283 | sharemenu.selected(accountId, reply.AccessToken); | ||
397 | 284 | } | ||
398 | 285 | } | ||
399 | 286 | |||
400 | 287 | height: childrenRect.height | ||
401 | 288 | |||
402 | 289 | ListItem.Subtitled { | ||
403 | 290 | anchors { | ||
404 | 291 | left: parent.left | ||
405 | 292 | right: parent.right | ||
406 | 293 | } | ||
407 | 294 | text: service.provider.displayName | ||
408 | 295 | subText: displayName | ||
409 | 296 | iconName: service.provider.iconName | ||
410 | 297 | __iconHeight: units.gu(5) | ||
411 | 298 | __iconWidth: units.gu(5) | ||
412 | 299 | |||
413 | 300 | onClicked: { | ||
414 | 301 | root.account = service; | ||
415 | 302 | root.account.authenticate(null); | ||
416 | 303 | } | ||
417 | 304 | } | ||
418 | 305 | } | ||
419 | 306 | } | ||
420 | 307 | |||
421 | 308 | ListView { | ||
422 | 309 | anchors { | ||
423 | 310 | top: parent.top | ||
424 | 311 | left: parent.left | ||
425 | 312 | right: parent.right | ||
426 | 313 | } | ||
427 | 314 | height: childrenRect.height | ||
428 | 315 | interactive: false | ||
429 | 316 | visible: !listView.visible | ||
430 | 317 | model: accounts | ||
431 | 318 | header: ListItem.Header { | ||
432 | 319 | anchors { | ||
433 | 320 | left: parent.left | ||
434 | 321 | right: parent.right | ||
435 | 322 | } | ||
436 | 323 | text: i18n.tr("Select account") | ||
437 | 324 | } | ||
438 | 325 | delegate: acctDelegate | ||
439 | 326 | } | ||
440 | 327 | |||
441 | 328 | ListView { | ||
442 | 329 | id: listView | ||
443 | 330 | anchors { | ||
444 | 331 | top: parent.top | ||
445 | 332 | left: parent.left | ||
446 | 333 | right: parent.right | ||
447 | 334 | } | ||
448 | 335 | height: childrenRect.height | ||
449 | 336 | header: headerComponent | ||
450 | 337 | model: providerModel | ||
451 | 338 | visible: accounts.count === 0 | ||
452 | 339 | delegate: providerDelegate | ||
453 | 340 | |||
454 | 341 | Component { | ||
455 | 342 | id: headerComponent | ||
456 | 343 | ListItem.Header { | ||
457 | 344 | anchors { | ||
458 | 345 | left: parent.left | ||
459 | 346 | right: parent.right | ||
460 | 347 | } | ||
461 | 348 | text: i18n.tr("No online accounts configured") | ||
462 | 349 | } | ||
463 | 350 | } | ||
464 | 351 | |||
465 | 352 | Component { | ||
466 | 353 | id: providerDelegate | ||
467 | 354 | Item { | ||
468 | 355 | anchors { | ||
469 | 356 | left: parent.left | ||
470 | 357 | right: parent.right | ||
471 | 358 | } | ||
472 | 359 | height: childrenRect.height | ||
473 | 360 | ListItem.Standard { | ||
474 | 361 | text: model.displayName | ||
475 | 362 | iconName: model.iconName | ||
476 | 363 | onClicked: { | ||
477 | 364 | setup.providerId = providerId | ||
478 | 365 | setup.exec() | ||
479 | 366 | } | ||
480 | 367 | } | ||
481 | 368 | } | ||
482 | 369 | } | ||
483 | 370 | |||
484 | 371 | |||
485 | 372 | ProviderModel { | ||
486 | 373 | id: providerModel | ||
487 | 374 | applicationId: "com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook" | ||
488 | 375 | } | ||
489 | 376 | |||
490 | 377 | Setup { | ||
491 | 378 | id: setup | ||
492 | 379 | applicationId: "com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook" | ||
493 | 380 | } | ||
494 | 381 | } | ||
495 | 382 | } | ||
496 | 383 | } | ||
497 | 0 | 384 | ||
498 | === added directory 'webapp-facebook/unity-webapps-facebook/assets' | |||
499 | === added file 'webapp-facebook/unity-webapps-facebook/assets/avatar_image.jpg' | |||
500 | 1 | Binary files webapp-facebook/unity-webapps-facebook/assets/avatar_image.jpg 1970-01-01 00:00:00 +0000 and webapp-facebook/unity-webapps-facebook/assets/avatar_image.jpg 2014-06-20 21:39:29 +0000 differ | 385 | Binary files webapp-facebook/unity-webapps-facebook/assets/avatar_image.jpg 1970-01-01 00:00:00 +0000 and webapp-facebook/unity-webapps-facebook/assets/avatar_image.jpg 2014-06-20 21:39:29 +0000 differ |
501 | === added file 'webapp-facebook/unity-webapps-facebook/assets/background_full@27.png' | |||
502 | 2 | Binary files webapp-facebook/unity-webapps-facebook/assets/background_full@27.png 1970-01-01 00:00:00 +0000 and webapp-facebook/unity-webapps-facebook/assets/background_full@27.png 2014-06-20 21:39:29 +0000 differ | 386 | Binary files webapp-facebook/unity-webapps-facebook/assets/background_full@27.png 1970-01-01 00:00:00 +0000 and webapp-facebook/unity-webapps-facebook/assets/background_full@27.png 2014-06-20 21:39:29 +0000 differ |
503 | === added file 'webapp-facebook/unity-webapps-facebook/assets/icon_location.png' | |||
504 | 3 | Binary files webapp-facebook/unity-webapps-facebook/assets/icon_location.png 1970-01-01 00:00:00 +0000 and webapp-facebook/unity-webapps-facebook/assets/icon_location.png 2014-06-20 21:39:29 +0000 differ | 387 | Binary files webapp-facebook/unity-webapps-facebook/assets/icon_location.png 1970-01-01 00:00:00 +0000 and webapp-facebook/unity-webapps-facebook/assets/icon_location.png 2014-06-20 21:39:29 +0000 differ |
505 | === added file 'webapp-facebook/unity-webapps-facebook/facebook.user.js' | |||
506 | --- webapp-facebook/unity-webapps-facebook/facebook.user.js 1970-01-01 00:00:00 +0000 | |||
507 | +++ webapp-facebook/unity-webapps-facebook/facebook.user.js 2014-06-20 21:39:29 +0000 | |||
508 | @@ -0,0 +1,51 @@ | |||
509 | 1 | var api = external.getUnityObject('1.0'); | ||
510 | 2 | var hub = api.ContentHub; | ||
511 | 3 | var activeTransfer; | ||
512 | 4 | |||
513 | 5 | function _shareRequested(transfer) { | ||
514 | 6 | activeTransfer = transfer; | ||
515 | 7 | transfer.items(function(items) { | ||
516 | 8 | api.launchEmbeddedUI("HubSharer", upload, {"fileToShare": items[0]}); | ||
517 | 9 | }); | ||
518 | 10 | }; | ||
519 | 11 | |||
520 | 12 | hub.onShareRequested(_shareRequested); | ||
521 | 13 | |||
522 | 14 | function upload(res, uploadCompletedCallback) { | ||
523 | 15 | var results = JSON.parse(res); | ||
524 | 16 | if (results.status == "cancelled") | ||
525 | 17 | activeTransfer.setState(hub.ContentTransfer.State.Aborted); | ||
526 | 18 | |||
527 | 19 | var xhr = new XMLHttpRequest(); | ||
528 | 20 | xhr.open( 'POST', 'https://graph.facebook.com/me/photos?access_token=' + results.accessToken, true ); | ||
529 | 21 | xhr.onload = xhr.onerror = function() { | ||
530 | 22 | if ( xhr.status == 200 ) { | ||
531 | 23 | uploadCompletedCallback(true); | ||
532 | 24 | window.location.reload(); | ||
533 | 25 | } else { | ||
534 | 26 | uploadCompletedCallback(false); | ||
535 | 27 | } | ||
536 | 28 | }; | ||
537 | 29 | |||
538 | 30 | var contentType = results.fileToShare.split(',')[0].split(':')[1]; | ||
539 | 31 | var b64data = results.fileToShare.split(',')[1]; | ||
540 | 32 | |||
541 | 33 | var byteCharacters = atob(b64data); | ||
542 | 34 | var byteNumbers = new Array(byteCharacters.length); | ||
543 | 35 | for (var i = 0; i < byteCharacters.length; i++) { | ||
544 | 36 | byteNumbers[i] = byteCharacters.charCodeAt(i); | ||
545 | 37 | } | ||
546 | 38 | var byteArray = new Uint8Array(byteNumbers); | ||
547 | 39 | |||
548 | 40 | var div = document.createElement('div'); | ||
549 | 41 | div.innerHTML = '<form enctype="multipart/form-data" method="post" id="uploadForm"><textarea id="message" name="message"></textarea></form>'; | ||
550 | 42 | document.getElementsByTagName('body')[0].appendChild(div); | ||
551 | 43 | |||
552 | 44 | var blob = new Blob([byteArray], {type: contentType}); | ||
553 | 45 | |||
554 | 46 | var uploadForm = document.forms.namedItem("uploadForm"); | ||
555 | 47 | var formData = new FormData(uploadForm); | ||
556 | 48 | formData.append('source', blob); | ||
557 | 49 | formData.append('message', results.message); | ||
558 | 50 | xhr.send(formData); | ||
559 | 51 | } | ||
560 | 0 | 52 | ||
561 | === added file 'webapp-facebook/unity-webapps-facebook/manifest.json' | |||
562 | --- webapp-facebook/unity-webapps-facebook/manifest.json 1970-01-01 00:00:00 +0000 | |||
563 | +++ webapp-facebook/unity-webapps-facebook/manifest.json 2014-06-20 21:39:29 +0000 | |||
564 | @@ -0,0 +1,7 @@ | |||
565 | 1 | { | ||
566 | 2 | "name": "facebook", | ||
567 | 3 | "includes": ["https://*.facebook.com/*"], | ||
568 | 4 | "homepage": "https://m.facebook.com/", | ||
569 | 5 | "domain": "facebook.com", | ||
570 | 6 | "scripts": ["facebook.user.js"] | ||
571 | 7 | } | ||
572 | 0 | 8 | ||
573 | === modified file 'webapp-facebook/webapp-facebook.desktop' | |||
574 | --- webapp-facebook/webapp-facebook.desktop 2014-06-20 13:54:52 +0000 | |||
575 | +++ webapp-facebook/webapp-facebook.desktop 2014-06-20 21:39:29 +0000 | |||
576 | @@ -1,7 +1,7 @@ | |||
577 | 1 | [Desktop Entry] | 1 | [Desktop Entry] |
578 | 2 | Type=Application | 2 | Type=Application |
579 | 3 | Terminal=false | 3 | Terminal=false |
581 | 4 | Exec=webapp-container --enable-back-forward --popup-redirection-url-prefix=http://lm.facebook.com/l.php?u= --webappUrlPatterns=https?://*.facebook.com/* https://m.facebook.com/ | 4 | Exec=webapp-container --enable-back-forward --popup-redirection-url-prefix=http://lm.facebook.com/l.php?u= --webapp='ZmFjZWJvb2s=' --webappModelSearchPath=. --webappUrlPatterns=https?://*.facebook.com/* https://m.facebook.com/ |
582 | 5 | Name=Facebook | 5 | Name=Facebook |
583 | 6 | Icon=./facebook.png | 6 | Icon=./facebook.png |
584 | 7 | X-Ubuntu-Touch=true | 7 | X-Ubuntu-Touch=true |
585 | 8 | 8 | ||
586 | === modified file 'webapp-facebook/webapp-facebook.json' | |||
587 | --- webapp-facebook/webapp-facebook.json 2014-04-10 21:52:56 +0000 | |||
588 | +++ webapp-facebook/webapp-facebook.json 2014-06-20 21:39:29 +0000 | |||
589 | @@ -2,11 +2,12 @@ | |||
590 | 2 | "template": "ubuntu-webapp", | 2 | "template": "ubuntu-webapp", |
591 | 3 | "policy_groups": [ | 3 | "policy_groups": [ |
592 | 4 | "networking", | 4 | "networking", |
593 | 5 | "accounts", | ||
594 | 5 | "audio", | 6 | "audio", |
595 | 6 | "video", | 7 | "video", |
596 | 7 | "webview", | 8 | "webview", |
597 | 8 | "location", | 9 | "location", |
598 | 9 | "content_exchange" | 10 | "content_exchange" |
599 | 10 | ], | 11 | ], |
601 | 11 | "policy_version": 1.1 | 12 | "policy_version": 1.2 |
602 | 12 | } | 13 | } |
603 | 13 | 14 | ||
604 | === renamed file 'webapp-facebook/facebook-webapp.service' => 'webapp-facebook/webapp-facebook.service' |