From 0400d12e527b68d9e63a028a2d5c284287b6b568 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 4 Dec 2021 22:05:22 +0100 Subject: [PATCH] Support for animated emoji --- harbour-fernschreiber.pro | 1 + .../messageContent/MessageAnimatedEmoji.qml | 27 +++++++++++++++++++ .../messageContent/MessageSticker.qml | 3 ++- qml/js/functions.js | 2 ++ qml/pages/AboutPage.qml | 2 +- qml/pages/ChatPage.qml | 3 +++ rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/fernschreiberutils.cpp | 3 +++ src/tdlibwrapper.cpp | 2 +- translations/harbour-fernschreiber-de.ts | 8 ++++++ translations/harbour-fernschreiber-en.ts | 8 ++++++ translations/harbour-fernschreiber-es.ts | 8 ++++++ translations/harbour-fernschreiber-fi.ts | 8 ++++++ translations/harbour-fernschreiber-fr.ts | 8 ++++++ translations/harbour-fernschreiber-hu.ts | 8 ++++++ translations/harbour-fernschreiber-it.ts | 8 ++++++ translations/harbour-fernschreiber-pl.ts | 8 ++++++ translations/harbour-fernschreiber-ru.ts | 8 ++++++ translations/harbour-fernschreiber-sk.ts | 8 ++++++ translations/harbour-fernschreiber-sv.ts | 8 ++++++ translations/harbour-fernschreiber-zh_CN.ts | 8 ++++++ translations/harbour-fernschreiber.ts | 8 ++++++ 23 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 qml/components/messageContent/MessageAnimatedEmoji.qml diff --git a/harbour-fernschreiber.pro b/harbour-fernschreiber.pro index ec873f9..62bb2f0 100644 --- a/harbour-fernschreiber.pro +++ b/harbour-fernschreiber.pro @@ -93,6 +93,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/components/inlineQueryResults/InlineQueryResultVenue.qml \ qml/components/inlineQueryResults/InlineQueryResultVideo.qml \ qml/components/inlineQueryResults/InlineQueryResultVoiceNote.qml \ + qml/components/messageContent/MessageAnimatedEmoji.qml \ qml/components/messageContent/MessageAnimation.qml \ qml/components/messageContent/MessageAudio.qml \ qml/components/messageContent/MessageContentBase.qml \ diff --git a/qml/components/messageContent/MessageAnimatedEmoji.qml b/qml/components/messageContent/MessageAnimatedEmoji.qml new file mode 100644 index 0000000..dd6c21a --- /dev/null +++ b/qml/components/messageContent/MessageAnimatedEmoji.qml @@ -0,0 +1,27 @@ +/* + Copyright (C) 2020-21 Sebastian J. Wolf and other contributors + + This file is part of Fernschreiber. + + Fernschreiber is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Fernschreiber is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Fernschreiber. If not, see . +*/ +import QtQuick 2.6 +import Sailfish.Silica 1.0 +import WerkWolf.Fernschreiber 1.0 +import "../" +import "../../js/twemoji.js" as Emoji + +MessageSticker { + stickerData: messageListItem ? messageListItem.myMessage.content.animated_emoji.sticker : overlayFlickable.overlayMessage.content.animated_emoji.sticker; +} diff --git a/qml/components/messageContent/MessageSticker.qml b/qml/components/messageContent/MessageSticker.qml index 773185a..3f57261 100644 --- a/qml/components/messageContent/MessageSticker.qml +++ b/qml/components/messageContent/MessageSticker.qml @@ -25,7 +25,7 @@ import "../../js/twemoji.js" as Emoji MessageContentBase { id: thisItem - readonly property var stickerData: messageListItem ? messageListItem.myMessage.content.sticker : overlayFlickable.overlayMessage.content.sticker; + property var stickerData: messageListItem ? messageListItem.myMessage.content.sticker : overlayFlickable.overlayMessage.content.sticker; readonly property bool asEmoji: appSettings.showStickersAsEmojis readonly property bool animated: stickerData.is_animated && appSettings.animateStickers readonly property bool stickerVisible: staticStickerLoader.item ? staticStickerLoader.item.visible : @@ -44,6 +44,7 @@ MessageContentBase { } Item { + width: Math.min( stickerData.width, parent.width ) height: width * aspectRatio // (centered in image mode, text-like in sticker mode) diff --git a/qml/js/functions.js b/qml/js/functions.js index 972f05f..686ca2d 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -45,6 +45,8 @@ function getMessageText(message, simple, currentUserId, ignoreEntities) { } case 'messageSticker': return simple ? qsTr("Sticker: %1").arg(message.content.sticker.emoji) : ""; + case 'messageAnimatedEmoji': + return simple ? qsTr("Animated Emoji: %1").arg(message.content.animated_emoji.sticker.emoji) : ""; case 'messagePhoto': if (message.content.caption.text !== "") { return simple ? qsTr("Picture: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption, ignoreEntities) diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index b53cf2c..0ae1d4a 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -59,7 +59,7 @@ Page { } Label { - text: "Fernschreiber 0.10.1" + text: "Fernschreiber 0.11" horizontalAlignment: Text.AlignHCenter font.pixelSize: Theme.fontSizeExtraLarge anchors { diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index a7cbdde..3967df5 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1220,6 +1220,8 @@ Page { function getContentComponentHeight(contentType, content, parentWidth) { switch(contentType) { + case "messageAnimatedEmoji": + return content.animated_emoji.sticker.height; case "messageAnimation": return Functions.getVideoHeight(parentWidth, content.animation); case "messageAudio": @@ -1247,6 +1249,7 @@ Page { } readonly property var delegateMessagesContent: [ + "messageAnimatedEmoji", "messageAnimation", "messageAudio", // "messageContact", diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 1f7dd19..1857c92 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -11,7 +11,7 @@ Name: harbour-fernschreiber # << macros Summary: Fernschreiber is a Telegram client for Sailfish OS -Version: 0.10.1 +Version: 0.11 Release: 1 Group: Qt/Qt License: LICENSE diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 0c425c8..65356a7 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,6 +1,6 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS -Version: 0.10.1 +Version: 0.11 Release: 1 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS diff --git a/src/fernschreiberutils.cpp b/src/fernschreiberutils.cpp index 4f5c568..96ac648 100644 --- a/src/fernschreiberutils.cpp +++ b/src/fernschreiberutils.cpp @@ -93,6 +93,9 @@ QString FernschreiberUtils::getMessageShortText(TDLibWrapper *tdLibWrapper, cons if (contentType == "messageSticker") { return tr("Sticker: %1").arg(messageContent.value("sticker").toMap().value("emoji").toString()); } + if (contentType == "messageAnimatedEmoji") { + return tr("Animated Emoji: %1").arg(messageContent.value("animated_emoji").toMap().value("sticker").toMap().value("emoji").toString()); + } if (contentType == "messagePhoto") { return myself ? tr("sent a picture", "myself") : tr("sent a picture"); } diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 6a6b62d..b9873be 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1853,7 +1853,7 @@ void TDLibWrapper::setInitialParameters() QSettings hardwareSettings("/etc/hw-release", QSettings::NativeFormat); initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString()); initialParameters.insert("system_version", QSysInfo::prettyProductName()); - initialParameters.insert("application_version", "0.10.1"); + initialParameters.insert("application_version", "0.11"); initialParameters.insert("enable_storage_optimizer", appSettings->storageOptimizer()); // initialParameters.insert("use_test_dc", true); requestObject.insert("parameters", initialParameters); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 70ced0b..8d9c609 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -934,6 +934,10 @@ sent a video note hat eine Videonachricht geschickt + + Animated Emoji: %1 + Animiertes Emoji: %1 + ImagePage @@ -2255,5 +2259,9 @@ sent a game hat ein Spiel gesendet + + Animated Emoji: %1 + Animiertes Emoji: %1 + diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index aca08b4..5bc0772 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -936,6 +936,10 @@ messages sent a video note sent a video note + + Animated Emoji: %1 + Animated Emoji: %1 + ImagePage @@ -2257,5 +2261,9 @@ messages sent a game sent a game + + Animated Emoji: %1 + Animated Emoji: %1 + diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index fe7de69..75cc421 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -934,6 +934,10 @@ sent a video note envió una nota de video + + Animated Emoji: %1 + + ImagePage @@ -2255,5 +2259,9 @@ sent a game envió un juego + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index eb6c5cf..e663d84 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -935,6 +935,10 @@ sent a video note lähetti videoviestin + + Animated Emoji: %1 + + ImagePage @@ -2256,5 +2260,9 @@ sent a game lähetti pelin + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index affb39e..f30339a 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -934,6 +934,10 @@ sent a video note a envoyé une note vidéo + + Animated Emoji: %1 + + ImagePage @@ -2255,5 +2259,9 @@ sent a game a envoyé un jeu + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index b217643..b47950a 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -920,6 +920,10 @@ sent a video note + + Animated Emoji: %1 + + ImagePage @@ -2227,5 +2231,9 @@ sent a game + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index cf3d994..934de15 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -934,6 +934,10 @@ sent a video note ha inviato un videomessaggio + + Animated Emoji: %1 + + ImagePage @@ -2255,5 +2259,9 @@ sent a game ha inviato un gioco + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index d7528d8..d36a2b6 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -948,6 +948,10 @@ sent a video note wysłał notatkę video + + Animated Emoji: %1 + + ImagePage @@ -2283,5 +2287,9 @@ sent a game wysłał grę + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 6549fee..da9b317 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -951,6 +951,10 @@ sent a video note отправил(а) видео заметку + + Animated Emoji: %1 + + ImagePage @@ -2286,5 +2290,9 @@ sent a game отправил(а) игру + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 18fa61c..960b3d2 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -948,6 +948,10 @@ sent a video note poslal video-poznámku + + Animated Emoji: %1 + + ImagePage @@ -2283,5 +2287,9 @@ sent a game poslal hru + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 20c7557..da29cb6 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -934,6 +934,10 @@ sent a video note skickade ett videomeddelande + + Animated Emoji: %1 + + ImagePage @@ -2255,5 +2259,9 @@ sent a game skickade ett spel + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 9500bb7..f1c2125 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -921,6 +921,10 @@ sent a video note 发送视频消息 + + Animated Emoji: %1 + + ImagePage @@ -2228,5 +2232,9 @@ sent a game 发送游戏 + + Animated Emoji: %1 + + diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 6b751c7..13df3ed 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -934,6 +934,10 @@ sent a video note sent a video note + + Animated Emoji: %1 + + ImagePage @@ -2255,5 +2259,9 @@ sent a game + + Animated Emoji: %1 + +