Skip to content

Commit

Permalink
Added auto inserting caption to cloud GIF if EditField has text.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Apr 23, 2022
1 parent 79f711c commit 18c603f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,16 @@ public void sendScreenshotMessage(TLRPC.User user, int messageId, TLRPC.Message
performSendMessageRequest(req, newMsgObj, null, null, null, null, false);
}

public void sendGifWithCaption(TLRPC.Document document, String query, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, Object parentObject, MessageObject.SendAnimationData sendAnimationData, boolean notify, int scheduleDate, String caption) {
if (caption.startsWith("@gif")) caption = "";
sendSticker(document, query, peer, replyToMsg, replyToTopMsg, parentObject, sendAnimationData, notify, scheduleDate, caption);
}

public void sendSticker(TLRPC.Document document, String query, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, Object parentObject, MessageObject.SendAnimationData sendAnimationData, boolean notify, int scheduleDate) {
sendSticker(document, query, peer, replyToMsg, replyToTopMsg, parentObject, sendAnimationData, notify, scheduleDate, null);
}

public void sendSticker(TLRPC.Document document, String query, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, Object parentObject, MessageObject.SendAnimationData sendAnimationData, boolean notify, int scheduleDate, String caption) {
if (document == null) {
return;
}
Expand Down Expand Up @@ -1617,7 +1626,7 @@ public void sendSticker(TLRPC.Document document, String query, long peer, Messag
if (bitmapFinal[0] != null && keyFinal[0] != null) {
ImageLoader.getInstance().putImageToCache(new BitmapDrawable(bitmapFinal[0]), keyFinal[0], false);
}
sendMessage((TLRPC.TL_document) finalDocument, null, null, peer, replyToMsg, replyToTopMsg, null, null, null, null, notify, scheduleDate, 0, parentObject, sendAnimationData);
sendMessage((TLRPC.TL_document) finalDocument, null, null, peer, replyToMsg, replyToTopMsg, caption, null, null, null, notify, scheduleDate, 0, parentObject, sendAnimationData);
});
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7331,8 +7331,9 @@ public void onGifSelected(View view, Object gif, String query, Object parent, bo
}
if (gif instanceof TLRPC.Document) {
TLRPC.Document document = (TLRPC.Document) gif;
SendMessagesHelper.getInstance(currentAccount).sendSticker(document, query, dialog_id, replyingMessageObject, getThreadMessage(), parent, null, notify, scheduleDate);
SendMessagesHelper.getInstance(currentAccount).sendGifWithCaption(document, query, dialog_id, replyingMessageObject, getThreadMessage(), parent, null, notify, scheduleDate, messageEditText.getText().toString());
MediaDataController.getInstance(currentAccount).addRecentGif(document, (int) (System.currentTimeMillis() / 1000));
messageEditText.setText("");
if (DialogObject.isEncryptedDialog(dialog_id)) {
accountInstance.getMessagesController().saveGif(parent, document);
}
Expand Down

0 comments on commit 18c603f

Please sign in to comment.