From e66c02e89c9c8369eb53061e1fec6ba4d54a11b4 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 2 Oct 2015 15:01:28 +0300 Subject: [PATCH] Fixed lots of mobile issues Moved all user / group photos to rounded with initials placeholder --- app/js/controllers.js | 17 +++--- app/js/directives.js | 31 ----------- app/js/messages_manager.js | 5 +- app/js/services.js | 54 +++++++++---------- app/less/app.less | 13 ++++- app/less/mobile.less | 21 ++++++++ app/partials/mobile/channel_modal.html | 11 +--- app/partials/mobile/chat_modal.html | 11 +--- app/partials/mobile/contacts_modal.html | 2 +- app/partials/mobile/dialog.html | 9 +--- app/partials/mobile/head.html | 9 +--- app/partials/mobile/im.html | 4 +- .../mobile/message_attach_contact.html | 2 +- app/partials/mobile/peer_select.html | 8 +-- app/partials/mobile/settings_modal.html | 9 +--- app/partials/mobile/user_modal.html | 8 +-- 16 files changed, 81 insertions(+), 133 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 9c5db6aa..fd9ea8cc 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1153,13 +1153,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) safeReplaceObject($scope.historyPeer, { id: peerID, - data: peerData, - photo: AppPeersManager.getPeerPhoto(peerID, 'User', 'Group') + data: peerData }); MtpApiManager.getUserID().then(function (id) { $scope.ownID = id; - $scope.ownPhoto = AppUsersManager.getUserPhoto(id, 'User'); }); if (preload) { @@ -2916,7 +2914,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) var peerString = AppUsersManager.getUserString($scope.userID); $scope.user = AppUsersManager.getUser($scope.userID); - $scope.userPhoto = AppUsersManager.getUserPhoto($scope.userID, 'User'); $scope.blocked = false; $scope.settings = {notifications: true}; @@ -3333,7 +3330,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) MtpApiManager.getUserID().then(function (id) { $scope.profile = AppUsersManager.getUser(id); - $scope.photo = AppUsersManager.getUserPhoto(id, 'User'); }); MtpApiManager.invokeApi('users.getFullUser', { @@ -3427,7 +3423,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) previous: true } }); - $scope.photo = AppUsersManager.getUserPhoto(id, 'User'); + $scope.photo = {}; }); }); })['finally'](function () { @@ -3452,7 +3448,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) previous: true } }); - $scope.photo = AppUsersManager.getUserPhoto(id, 'User'); + $scope.photo = {}; }); })['finally'](function () { delete $scope.photo.updating; @@ -3969,8 +3965,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) angular.forEach(contactsList, function(userID) { var contact = { userID: userID, - user: AppUsersManager.getUser(userID), - userPhoto: AppUsersManager.getUserPhoto(userID, 'User') + user: AppUsersManager.getUser(userID) } doneIDs.push(userID); $scope.contacts.push(contact); @@ -4238,7 +4233,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) } }) - .controller('ChatInviteLinkModalController', function (_, $scope, $timeout, $modalInstance, AppChatsManager, ErrorService) { + .controller('ChatInviteLinkModalController', function (_, $scope, $timeout, $modalInstance, AppChatsManager, AppProfileManager, ErrorService) { $scope.exportedInvite = {link: _('group_invite_link_loading_raw')}; @@ -4260,7 +4255,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) if (force) { $scope.exportedInvite.revoking = true; } - AppChatsManager.getChatInviteLink($scope.chatID, force).then(function (link) { + AppProfileManager.getChatInviteLink($scope.chatID, force).then(function (link) { $scope.exportedInvite = {link: link, canRevoke: true}; selectLink(); diff --git a/app/js/directives.js b/app/js/directives.js index e5c145e8..754c4960 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -2608,37 +2608,6 @@ angular.module('myApp.directives', ['myApp.filters']) } }) - - .directive('myUserPhotolink', function (AppUsersManager) { - - return { - link: link, - template: '' - }; - - function link($scope, element, attrs) { - - var userID = $scope.$eval(attrs.myUserPhotolink); - - $scope.photo = AppUsersManager.getUserPhoto(userID, 'User'); - - if ($scope.showStatus = attrs.status && $scope.$eval(attrs.status)) { - $scope.user = AppUsersManager.getUser(userID); - } - - if (element[0].tagName == 'A') { - element.on('click', function (e) { - AppUsersManager.openUser(userID, attrs.userOverride && $scope.$eval(attrs.userOverride)); - }); - } - - if (attrs.imgClass) { - $(element[0].firstChild).addClass(attrs.imgClass) - } - - } - }) - .directive('myPeerLink', function (AppChatsManager, AppUsersManager) { return { diff --git a/app/js/messages_manager.js b/app/js/messages_manager.js index 9c5fb0fb..5a62793c 100644 --- a/app/js/messages_manager.js +++ b/app/js/messages_manager.js @@ -1670,7 +1670,6 @@ angular.module('myApp.services') message.peerID = getMessagePeer(message); message.peerData = AppPeersManager.getPeer(message.peerID); message.peerString = AppPeersManager.getPeerString(message.peerID); - message.peerPhoto = AppPeersManager.getPeerPhoto(message.peerID, 'User', 'Group'); message.unreadCount = unreadCount; if (message._ == 'messageService' && message.action.user_id) { @@ -2056,7 +2055,7 @@ angular.module('myApp.services') if (peerID > 0) { var fromUser = AppUsersManager.getUser(message.from_id); - var fromPhoto = AppUsersManager.getUserPhoto(message.from_id, 'User'); + var fromPhoto = AppUsersManager.getUserPhoto(message.from_id); notification.title = (fromUser.first_name || '') + (fromUser.first_name && fromUser.last_name ? ' ' : '') + @@ -2079,7 +2078,7 @@ angular.module('myApp.services') notification.title; } - notificationPhoto = AppChatsManager.getChatPhoto(-peerID, 'Group'); + notificationPhoto = AppChatsManager.getChatPhoto(-peerID); peerString = AppChatsManager.getChatString(-peerID); } diff --git a/app/js/services.js b/app/js/services.js index 9e2e3508..a0102f7b 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -188,7 +188,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return angular.isObject(users[id]); } - function getUserPhoto(id, placeholder) { + function getUserPhoto(id) { var user = getUser(id); if (id == 333000) { @@ -203,7 +203,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return { num: user.num, - placeholder: 'img/placeholders/' + placeholder + 'Avatar' + user.num + '@2x.png', + placeholder: 'img/placeholders/UserAvatar' + user.num + '@2x.png', location: cachedPhotoLocations[id] }; } @@ -591,7 +591,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) var lastWord = titleWords.pop(); apiChat.initials = firstWord.charAt(0) + (lastWord ? lastWord.charAt(0) : firstWord.charAt(1)); - apiChat.num = (Math.abs(apiChat.id >> 1) % (Config.Mobile ? 4 : 8)) + 1; + apiChat.num = (Math.abs(apiChat.id >> 1) % 8) + 1; if (apiChat.username) { var searchUsername = SearchIndexManager.cleanUsername(apiChat.username); @@ -646,29 +646,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } } - function getChatInviteLink (id, force) { - return getChatFull(id).then(function (chatFull) { - if (!force && - chatFull.exported_invite && - chatFull.exported_invite._ == 'chatInviteExported') { - return chatFull.exported_invite.link; - } - return MtpApiManager.invokeApi('messages.exportChatInvite', { - chat_id: getChatInput(id) - }).then(function (exportedInvite) { - if (chatsFull[id] !== undefined) { - chatsFull[id].exported_invite = exportedInvite; - } - return exportedInvite.link; - }); - }); - } - function hasChat (id) { return angular.isObject(chats[id]); } - function getChatPhoto(id, placeholder) { + function getChatPhoto(id) { var chat = getChat(id); if (cachedPhotoLocations[id] === undefined) { @@ -676,7 +658,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } return { - placeholder: 'img/placeholders/' + placeholder + 'Avatar' + (Config.Mobile ? chat.num : Math.ceil(chat.num / 2)) + '@2x.png', + placeholder: 'img/placeholders/GroupAvatar' + Math.ceil(chat.num / 2) + '@2x.png', location: cachedPhotoLocations[id] }; } @@ -767,7 +749,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) getChannelInput: getChannelInput, getChatPhoto: getChatPhoto, getChatString: getChatString, - getChatInviteLink: getChatInviteLink, resolveUsername: resolveUsername, hasChat: hasChat, wrapForFull: wrapForFull, @@ -897,10 +878,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) : AppChatsManager.getChat(-peerID); } - function getPeerPhoto (peerID, userPlaceholder, chatPlaceholder) { + function getPeerPhoto (peerID) { return peerID > 0 - ? AppUsersManager.getUserPhoto(peerID, userPlaceholder) - : AppChatsManager.getChatPhoto(-peerID, chatPlaceholder) + ? AppUsersManager.getUserPhoto(peerID) + : AppChatsManager.getChatPhoto(-peerID) } function isChannel (peerID) { @@ -1035,6 +1016,24 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) }); } + function getChatInviteLink (id, force) { + return getChatFull(id).then(function (chatFull) { + if (!force && + chatFull.exported_invite && + chatFull.exported_invite._ == 'chatInviteExported') { + return chatFull.exported_invite.link; + } + return MtpApiManager.invokeApi('messages.exportChatInvite', { + chat_id: getChatInput(id) + }).then(function (exportedInvite) { + if (chatsFull[id] !== undefined) { + chatsFull[id].exported_invite = exportedInvite; + } + return exportedInvite.link; + }); + }); + } + function getChannelParticipants (id) { return MtpApiManager.invokeApi('channels.getParticipants', { channel: AppChatsManager.getChannelInput(id), @@ -1162,6 +1161,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return { getPeerBots: getPeerBots, getProfile: getProfile, + getChatInviteLink: getChatInviteLink, getChatFull: getChatFull, getChannelFull: getChannelFull } diff --git a/app/less/app.less b/app/less/app.less index fff9f99b..eb12dec5 100644 --- a/app/less/app.less +++ b/app/less/app.less @@ -3027,7 +3027,12 @@ a.contacts_modal_search_clear { height: 40px; margin-right: 10px; overflow: hidden; - border-radius: 2px; + border-radius: 20px; + + .peer_initials { + line-height: 40px; + font-size: 15px; + } } .contacts_modal_contact_status { color: #999; @@ -3073,13 +3078,17 @@ a.contacts_modal_contact:hover .md_modal_list_peer_description, width: 40px; height: 40px; margin-right: 10px; - border-radius: 2px; + border-radius: 20px; overflow: hidden; } img& { width: 40px; height: 40px; } + .peer_initials { + line-height: 40px; + font-size: 15px; + } } .chat_modal_members_forbidden { diff --git a/app/less/mobile.less b/app/less/mobile.less index 30849607..fcc3f3c2 100644 --- a/app/less/mobile.less +++ b/app/less/mobile.less @@ -405,6 +405,13 @@ html { overflow: hidden; } + .peer_initials { + line-height: 36px; + font-size: 15px; + border-radius: 18px; + overflow: hidden; + } + .navbar_peer_not_selected & { display: none; } @@ -1010,6 +1017,11 @@ a.im_dialog { div& { margin: 0 12px 0 0; + + .peer_initials { + line-height: 54px; + font-size: 18px; + } } } @@ -1104,6 +1116,10 @@ a.im_message_fwd_author { padding: 0; } + &.md_simple_modal_window .modal-dialog { + max-width: none; + } + .modal-content { border-radius: 0; box-shadow: none; @@ -1141,6 +1157,11 @@ a.im_message_fwd_author { width: 64px; height: 64px; margin-right: 14px; + + .peer_initials { + line-height: 64px; + font-size: 18px; + } } &_chat_modal_image { diff --git a/app/partials/mobile/channel_modal.html b/app/partials/mobile/channel_modal.html index a6df864d..900a56e8 100644 --- a/app/partials/mobile/channel_modal.html +++ b/app/partials/mobile/channel_modal.html @@ -49,14 +49,7 @@
- - - +

@@ -122,7 +115,7 @@ - +
diff --git a/app/partials/mobile/chat_modal.html b/app/partials/mobile/chat_modal.html index e4c67f37..c9f58e1d 100644 --- a/app/partials/mobile/chat_modal.html +++ b/app/partials/mobile/chat_modal.html @@ -46,14 +46,7 @@
- - - +

@@ -109,7 +102,7 @@ - +
diff --git a/app/partials/mobile/contacts_modal.html b/app/partials/mobile/contacts_modal.html index 5ecd0b37..4b122580 100644 --- a/app/partials/mobile/contacts_modal.html +++ b/app/partials/mobile/contacts_modal.html @@ -81,7 +81,7 @@ -
+
diff --git a/app/partials/mobile/dialog.html b/app/partials/mobile/dialog.html index 32f70fbd..f7842de5 100644 --- a/app/partials/mobile/dialog.html +++ b/app/partials/mobile/dialog.html @@ -13,14 +13,7 @@ >
-
- -
+
diff --git a/app/partials/mobile/head.html b/app/partials/mobile/head.html index cd05bbe8..69673b50 100644 --- a/app/partials/mobile/head.html +++ b/app/partials/mobile/head.html @@ -2,13 +2,8 @@