Send stickers regular as images

(cherry picked from commit 103ff1b5d6)
This commit is contained in:
Arne 2024-04-06 21:29:37 +02:00
parent 12237527e6
commit ebaf0804fd
2 changed files with 4 additions and 23 deletions

View file

@ -639,9 +639,6 @@ public class FileBackend {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
for (Cid cid : calculateCids(uri)) {
if (mXmppConnectionService.getUrlForCid(cid) != null) return true;
}
final InputStream inputStream = mXmppConnectionService.getContentResolver().openInputStream(uri);
BitmapFactory.decodeStream(inputStream, null, options);
close(inputStream);
@ -649,7 +646,7 @@ public class FileBackend {
return false;
}
return (options.outWidth <= mXmppConnectionService.getCompressImageResolutionPreference() && options.outHeight <= mXmppConnectionService.getCompressImageResolutionPreference() && options.outMimeType.contains(Config.IMAGE_FORMAT.name().toLowerCase()));
} catch (final IOException e) {
} catch (FileNotFoundException e) {
Log.d(Config.LOGTAG, "unable to get image dimensions", e);
return false;
}
@ -1838,20 +1835,7 @@ public class FileBackend {
*/
Message.FileParams fileParams = message.getFileParams();
if (fileParams == null) fileParams = new Message.FileParams();
Cid[] cids = new Cid[0];
try {
cids = calculateCids(new FileInputStream(file));
fileParams.setCids(List.of(cids));
} catch (final IOException | NoSuchAlgorithmException e) { }
if (url == null) {
for (Cid cid : cids) {
url = mXmppConnectionService.getUrlForCid(cid);
if (url != null) {
fileParams.url = url;
break;
}
}
} else {
if (url != null) {
fileParams.url = url;
}
fileParams.setName(file.getName());
@ -1928,10 +1912,11 @@ public class FileBackend {
message.setType(privateMessage ? Message.TYPE_PRIVATE_FILE : (image ? Message.TYPE_IMAGE : Message.TYPE_FILE));
if (updateCids) {
try {
Cid[] cids = calculateCids(new FileInputStream(getFile(message)));
for (int i = 0; i < cids.length; i++) {
mXmppConnectionService.saveCid(cids[i], file);
}
} catch (XmppConnectionService.BlockedMediaException e) { }
} catch (final IOException | XmppConnectionService.BlockedMediaException e) { }
}
}

View file

@ -2156,10 +2156,6 @@ public class XmppConnectionService extends Service {
final boolean inProgressJoin = isJoinInProgress(conversation);
if (message.getCounterpart() == null && !message.isPrivateMessage()) {
message.setCounterpart(message.getConversation().getJid().asBareJid());
}
boolean waitForPreview = false;
if (getPreferences().getBoolean("send_link_previews", true) && !previewedLinks && !message.needsUploading()) {
final List<URI> links = message.getLinks();