Browse Source

Added sticker view support

master
Igor Zhukov 10 years ago
parent
commit
e8331354f0
  1. 13
      app/css/mobile.css
  2. 4
      app/js/lib/config.js
  3. 8
      app/js/lib/mtproto_wrapper.js
  4. 29
      app/js/lib/schema.tl.txt
  5. 1
      app/js/locales/en-us.json
  6. 95
      app/js/services.js
  7. 5
      app/partials/desktop/dialog.html
  8. 8
      app/partials/desktop/message_attach_document.html
  9. 5
      app/partials/mobile/dialog.html
  10. 8
      app/partials/mobile/message_attach_document.html

13
app/css/mobile.css

@ -211,12 +211,15 @@ html { @@ -211,12 +211,15 @@ html {
.tg_page_head .navbar > .container .navbar-brand {
display: none;
}
.tg_page_head .navbar {
min-height: 46px;
}
.tg_page_head .navbar_peer_not_selected > .container .navbar-brand {
display: block;
}
.tg_page_head .navbar_offline > .container .navbar-brand.tg_logo_wrap {
display: none;
}
.tg_page_head .navbar {
min-height: 46px;
}
.tg_page_head .navbar-inverse .navbar-quick-nav > li > a {
padding-left: 16px;
@ -277,16 +280,12 @@ html { @@ -277,16 +280,12 @@ html {
float: left;
margin: 0;
}
.navbar_offline .tg_logo_wrap {
display: none;
}
.navbar-offline > li > a {
padding-right: 0;
padding-left: 0;
}
.navbar-offline-text {
color: #FFF;
padding-left: 0px;
font-size: 15px;
}
.tg_page_head .navbar-inverse .navbar-offline > li > a {

4
app/js/lib/config.js

File diff suppressed because one or more lines are too long

8
app/js/lib/mtproto_wrapper.js

@ -374,11 +374,15 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto']) @@ -374,11 +374,15 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto'])
return cachedDownloads[fileName] = blob;
}, function () {
var downloadPromise = downloadRequest(location.dc_id, function () {
var inputLocation = location;
if (!inputLocation._ || inputLocation._ == 'fileLocation') {
inputLocation = angular.extend({}, location, {_: 'inputFileLocation'});
}
// console.log('next small promise');
return MtpApiManager.invokeApi('upload.getFile', {
location: angular.extend({}, location, {_: 'inputFileLocation'}),
location: inputLocation,
offset: 0,
limit: 0
limit: 1024 * 1024
}, {
dcID: location.dc_id,
fileDownload: true,

29
app/js/lib/schema.tl.txt

@ -156,6 +156,8 @@ peerNotifyEventsAll#6d1ded88 = PeerNotifyEvents; @@ -156,6 +156,8 @@ peerNotifyEventsAll#6d1ded88 = PeerNotifyEvents;
peerNotifySettingsEmpty#70a68512 = PeerNotifySettings;
peerNotifySettings#8d5e11ee mute_until:int sound:string show_previews:Bool events_mask:int = PeerNotifySettings;
globalPrivacySettings#40f5c53a no_suggestions:Bool hide_contacts:Bool hide_located:Bool hide_last_visit:Bool = GlobalPrivacySettings;
wallPaper#ccb03657 id:int title:string sizes:Vector<PhotoSize> color:int = WallPaper;
userFull#771095da user:User link:contacts.Link profile_photo:Photo notify_settings:PeerNotifySettings blocked:Bool real_first_name:string real_last_name:string = UserFull;
@ -182,8 +184,8 @@ contacts.myLinkContact#c240ebd9 = contacts.MyLink; @@ -182,8 +184,8 @@ contacts.myLinkContact#c240ebd9 = contacts.MyLink;
contacts.link#eccea3f5 my_link:contacts.MyLink foreign_link:contacts.ForeignLink user:User = contacts.Link;
contacts.contacts#6f8b8cb2 contacts:Vector<Contact> users:Vector<User> = contacts.Contacts;
contacts.contactsNotModified#b74ba9d2 = contacts.Contacts;
contacts.contacts#6f8b8cb2 contacts:Vector<Contact> users:Vector<User> = contacts.Contacts;
contacts.importedContacts#ad524315 imported:Vector<ImportedContact> retry_contacts:Vector<long> users:Vector<User> = contacts.ImportedContacts;
@ -340,8 +342,8 @@ updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update; @@ -340,8 +342,8 @@ updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update;
inputMediaUploadedAudio#4e498cab file:InputFile duration:int mime_type:string = InputMedia;
inputMediaAudio#89938781 id:InputAudio = InputMedia;
inputMediaUploadedDocument#34e794bd file:InputFile file_name:string mime_type:string = InputMedia;
inputMediaUploadedThumbDocument#3e46de5d file:InputFile thumb:InputFile file_name:string mime_type:string = InputMedia;
inputMediaUploadedDocument#ffe76b78 file:InputFile mime_type:string attributes:Vector<DocumentAttribute> = InputMedia;
inputMediaUploadedThumbDocument#41481486 file:InputFile thumb:InputFile mime_type:string attributes:Vector<DocumentAttribute> = InputMedia;
inputMediaDocument#d184e841 id:InputDocument = InputMedia;
messageMediaDocument#2fda2204 document:Document = MessageMedia;
@ -360,7 +362,7 @@ audioEmpty#586988d8 id:long = Audio; @@ -360,7 +362,7 @@ audioEmpty#586988d8 id:long = Audio;
audio#c7ac6496 id:long access_hash:long user_id:int date:int duration:int mime_type:string size:int dc_id:int = Audio;
documentEmpty#36f8c871 id:long = Document;
document#9efc6326 id:long access_hash:long user_id:int date:int file_name:string mime_type:string size:int thumb:PhotoSize dc_id:int = Document;
document#f9a39f4f id:long access_hash:long date:int mime_type:string size:int thumb:PhotoSize dc_id:int attributes:Vector<DocumentAttribute> = Document;
help.support#17c6b5f6 phone_number:string user:User = help.Support;
@ -423,6 +425,19 @@ account.sentChangePhoneCode#a4f58c4c phone_code_hash:string send_call_timeout:in @@ -423,6 +425,19 @@ account.sentChangePhoneCode#a4f58c4c phone_code_hash:string send_call_timeout:in
updateUserPhone#12b9417b user_id:int phone:string = Update;
account.noPassword#5770e7a9 new_salt:bytes = account.Password;
account.password#739e5f72 current_salt:bytes new_salt:bytes hint:string = account.Password;
documentAttributeImageSize#6c37c15c w:int h:int = DocumentAttribute;
documentAttributeAnimated#11b58939 = DocumentAttribute;
documentAttributeSticker#fb0a5727 = DocumentAttribute;
documentAttributeVideo#5910cccb duration:int w:int h:int = DocumentAttribute;
documentAttributeAudio#51448e5 duration:int = DocumentAttribute;
documentAttributeFilename#15590068 file_name:string = DocumentAttribute;
messages.stickersNotModified#f1749a22 = messages.Stickers;
messages.stickers#8a8ecd32 hash:string stickers:Vector<Document> = messages.Stickers;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -558,3 +573,9 @@ contacts.resolveUsername#bf0131c username:string = User; @@ -558,3 +573,9 @@ contacts.resolveUsername#bf0131c username:string = User;
account.sendChangePhoneCode#a407a8f4 phone_number:string = account.SentChangePhoneCode;
account.changePhone#70c32edb phone_number:string phone_code_hash:string phone_code:string = User;
account.getPassword#548a30f5 = account.Password;
account.setPassword#dd2a4d8f current_password_hash:bytes new_salt:bytes new_password_hash:bytes hint:string = Bool;
auth.checkPassword#a63011e password_hash:bytes = auth.Authorization;
messages.getStickers#ae22e045 emoticon:string hash:string = messages.Stickers;

1
app/js/locales/en-us.json

@ -187,6 +187,7 @@ @@ -187,6 +187,7 @@
"conversation_media_photo": "Photo",
"conversation_media_video": "Video",
"conversation_media_document": "Document",
"conversation_media_sticker": "Sticker",
"conversation_media_audio": "Audio",
"conversation_media_location": "Location",
"conversation_media_contact": "Contact",

95
app/js/services.js

@ -1436,7 +1436,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -1436,7 +1436,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
case 'document':
default:
inputMedia = {_: 'inputMediaUploadedDocument', file: inputFile, file_name: file.name, mime_type: file.type};
inputMedia = {_: 'inputMediaUploadedDocument', file: inputFile, mime_type: file.type, attributes: [
{_: 'documentAttributeFilename', file_name: file.name}
]};
}
MtpApiManager.invokeApi('messages.sendMedia', {
peer: inputPeer,
@ -1930,7 +1932,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -1930,7 +1932,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
switch (message.media._) {
case 'messageMediaPhoto': notificationMessage = _('conversation_media_photo_raw'); break;
case 'messageMediaVideo': notificationMessage = _('conversation_media_video_raw'); break;
case 'messageMediaDocument': notificationMessage = message.media.document.file_name || _('conversation_media_document_raw'); break;
case 'messageMediaDocument':
if (message.media.document.sticker) {
notificationMessage = _('conversation_media_sticker');
} else {
notificationMessage = message.media.document.file_name || _('conversation_media_document_raw');
}
break;
case 'messageMediaAudio': notificationMessage = _('conversation_media_audio_raw'); break;
case 'messageMediaGeo': notificationMessage = _('conversation_media_location_raw'); break;
case 'messageMediaContact': notificationMessage = _('conversation_media_contact_raw'); break;
@ -2350,17 +2358,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2350,17 +2358,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
// console.log('chosen photo size', photoID, thumbPhotoSize);
if (thumbPhotoSize && thumbPhotoSize._ != 'photoSizeEmpty') {
if ((thumbPhotoSize.w / thumbPhotoSize.h) > (width / height)) {
thumb.height = parseInt(thumbPhotoSize.h * width / thumbPhotoSize.w);
}
else {
thumb.width = parseInt(thumbPhotoSize.w * height / thumbPhotoSize.h);
if (thumb.width > width) {
thumb.height = parseInt(thumb.height * width / thumb.width);
thumb.width = width;
}
}
var dim = calcImageInBox(thumbPhotoSize.w, thumbPhotoSize.h, width, height);
thumb.width = dim.w;
thumb.height = dim.h;
thumb.location = thumbPhotoSize.location;
thumb.size = thumbPhotoSize.size;
} else {
@ -2692,6 +2692,24 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2692,6 +2692,24 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
delete apiDoc.thumb.bytes;
apiDoc.thumb._ = 'photoSize';
}
angular.forEach(apiDoc.attributes, function (attribute) {
switch (attribute._) {
case 'documentAttributeFilename':
apiDoc.file_name = attribute.file_name;
break;
case 'documentAttributeVideo':
case 'documentAttributeAudio':
apiDoc.duration = attribute.duration;
break;
case 'documentAttributeSticker':
apiDoc.sticker = true;
break;
case 'documentAttributeImageSize':
apiDoc.w = attribute.w;
apiDoc.h = attribute.h;
break;
}
});
};
function wrapForHistory (docID) {
@ -2701,28 +2719,42 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2701,28 +2719,42 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var doc = angular.copy(docs[docID]),
isGif = doc.mime_type == 'image/gif',
isAudio = doc.mime_type.substr(0, 6) == 'audio/',
width = isGif ? Math.min(windowW - 80, 260) : 100,
height = isGif ? Math.min(windowH - 100, 260) : 100,
isSticker = doc.mime_type == 'image/webp' || doc.mime_type.substr(0, 6) == 'image/' && doc.sticker,
thumbPhotoSize = doc.thumb,
thumb = {
width, height;
if (isGif) {
width = Math.min(windowW - 80, 260);
height = Math.min(windowH - 100, 260);
}
else if (isSticker) {
width = Math.min(windowW - 80, Config.Mobile ? 210 : 260);
height = Math.min(windowH - 100, Config.Mobile ? 210 : 260);
thumbPhotoSize = {
_: 'photoSize',
type: 'x',
location: {
_: 'inputDocumentFileLocation',
id: doc.id,
access_hash: doc.access_hash
},
w: doc.w,
h: doc.h,
size: doc.size
};
} else {
width = height = 100;
}
var thumb = {
width: width,
height: height
};
if (thumbPhotoSize && thumbPhotoSize._ != 'photoSizeEmpty') {
if ((thumbPhotoSize.w / thumbPhotoSize.h) > (width / height)) {
thumb.height = parseInt(thumbPhotoSize.h * width / thumbPhotoSize.w);
}
else {
thumb.width = parseInt(thumbPhotoSize.w * height / thumbPhotoSize.h);
if (thumb.width > width) {
thumb.height = parseInt(thumb.height * width / thumb.width);
thumb.width = width;
}
}
var dim = calcImageInBox(thumbPhotoSize.w, thumbPhotoSize.h, width, height);
thumb.width = dim.w;
thumb.height = dim.h;
thumb.location = thumbPhotoSize.location;
thumb.size = thumbPhotoSize.size;
} else {
@ -2735,7 +2767,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2735,7 +2767,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (isGif && doc.thumb) {
doc.isSpecial = 'gif';
}
else if (isAudio) {
else if (isSticker) {
doc.isSpecial = 'sticker';
}
else if (doc.mime_type.substr(0, 6) == 'audio/') {
doc.isSpecial = 'audio';
}

5
app/partials/desktop/dialog.html

@ -44,7 +44,10 @@ @@ -44,7 +44,10 @@
<span class="im_dialog_message_media" ng-if="dialogMessage.media" ng-switch="dialogMessage.media._">
<span ng-switch-when="messageMediaPhoto" my-i18n="conversation_media_photo"></span>
<span ng-switch-when="messageMediaVideo" my-i18n="conversation_media_video"></span>
<span ng-switch-when="messageMediaDocument" ng-bind="dialogMessage.media.document.file_name"></span>
<span ng-switch-when="messageMediaDocument" ng-switch="::dialogMessage.media.document.sticker || false">
<span ng-switch-when="true" my-i18n="conversation_media_sticker"></span>
<span ng-switch-default ng-bind="dialogMessage.media.document.file_name"></span>
</span>
<span ng-switch-when="messageMediaAudio" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="messageMediaGeo" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaContact" my-i18n="conversation_media_contact"></span>

8
app/partials/desktop/message_attach_document.html

@ -2,6 +2,14 @@ @@ -2,6 +2,14 @@
<div ng-switch-when="gif" my-load-gif document="document"></div>
<div ng-switch-when="sticker">
<img
class="im_message_sticker"
my-load-thumb
thumb="document.thumb"
/>
</div>
<div ng-switch-when="audio" class="im_message_audio">
<div my-audio-player audio="document"></div>
</div>

5
app/partials/mobile/dialog.html

@ -51,7 +51,10 @@ @@ -51,7 +51,10 @@
<span class="im_dialog_message_media" ng-if="dialogMessage.media" ng-switch="dialogMessage.media._">
<span ng-switch-when="messageMediaPhoto" my-i18n="conversation_media_photo"></span>
<span ng-switch-when="messageMediaVideo" my-i18n="conversation_media_video"></span>
<span ng-switch-when="messageMediaDocument" ng-bind="dialogMessage.media.document.file_name"></span>
<span ng-switch-when="messageMediaDocument" ng-switch="::dialogMessage.media.document.sticker || false">
<span ng-switch-when="true" my-i18n="conversation_media_sticker"></span>
<span ng-switch-default ng-bind="dialogMessage.media.document.file_name"></span>
</span>
<span ng-switch-when="messageMediaAudio" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="messageMediaGeo" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaContact" my-i18n="conversation_media_contact"></span>

8
app/partials/mobile/message_attach_document.html

@ -2,6 +2,14 @@ @@ -2,6 +2,14 @@
<div ng-switch-when="gif" my-load-gif document="document"></div>
<div ng-switch-when="sticker">
<img
class="im_message_sticker"
my-load-thumb
thumb="document.thumb"
/>
</div>
<div ng-switch-when="audio" class="im_message_audio">
<div my-audio-player audio="document"></div>
</div>

Loading…
Cancel
Save