Browse Source

Supported FxOS 'share' activity

Closes #377
master
Igor Zhukov 10 years ago
parent
commit
925e48f04a
  1. 19
      app/js/services.js
  2. 8
      app/manifest.webapp
  3. 5
      app/partials/confirm_modal.html

19
app/js/services.js

@ -719,7 +719,7 @@ angular.module('myApp.services', []) @@ -719,7 +719,7 @@ angular.module('myApp.services', [])
}
})
.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppAudioManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, SearchIndexManager, Storage) {
.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppAudioManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, SearchIndexManager, PeersSelectService, Storage) {
var messagesStorage = {};
var messagesForHistory = {};
@ -1961,6 +1961,23 @@ angular.module('myApp.services', []) @@ -1961,6 +1961,23 @@ angular.module('myApp.services', [])
}
}
if (window.navigator.mozSetMessageHandler) {
window.navigator.mozSetMessageHandler('activity', function(activityRequest) {
var source = activityRequest.source;
console.log(dT(), 'Received activity', source.name, source.data);
if (source.name === 'share' && source.data.blobs.length > 0) {
PeersSelectService.selectPeer({confirm_type: 'EXT_SHARE_PEER'}).then(function (peerString) {
var peerID = AppPeersManager.getPeerID(peerString);
angular.forEach(source.data.blobs, function (blob) {
sendFile(peerID, blob, {isMedia: true});
});
$rootScope.$broadcast('history_focus', {peerString: peerString});
});
}
});
}
$rootScope.$on('apiUpdate', function (e, update) {
// if (update._ != 'updateUserStatus') {
// console.log('on apiUpdate', update);

8
app/manifest.webapp

@ -30,6 +30,14 @@ @@ -30,6 +30,14 @@
"description": "Required for notifications"
}
},
"activities": {
"share": {
"href": "/index.html",
"disposition": "window",
"filters": {},
"returnValue": false
}
},
"orientation": "portrait-primary",
"icons": {
"16": "/img/icons/icon16.png",

5
app/partials/confirm_modal.html

@ -34,6 +34,10 @@ @@ -34,6 +34,10 @@
<span ng-switch-when="true" ng-bind-html="peer_data.rFullName"></span>
<span ng-switch-default ng-bind-html="peer_data.rTitle"></span>
</strong>?</span>
<span ng-switch-when="EXT_SHARE_PEER">Share with <strong ng-switch="peer_id > 0">
<span ng-switch-when="true" ng-bind-html="peer_data.rFullName"></span>
<span ng-switch-default ng-bind-html="peer_data.rTitle"></span>
</strong>?</span>
<span ng-switch-default ng-bind="message || 'Are you sure?'"></span>
</div>
@ -53,6 +57,7 @@ @@ -53,6 +57,7 @@
<span ng-switch-when="PHOTO_SHARE_PEER">Forward photo</span>
<span ng-switch-when="VIDEO_SHARE_PEER">Forward video</span>
<span ng-switch-when="SHARE_CONTACT_PEER">Send contact</span>
<span ng-switch-when="EXT_SHARE_PEER">Share file</span>
<span ng-switch-default>OK</span>
</button>
</div>

Loading…
Cancel
Save