set divider for image meta information to '|' to not conflict with URL. breaks images downloaded in between 0.7.3 and now
This commit is contained in:
parent
d86b7f3192
commit
b045dea549
|
@ -8,6 +8,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpError;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
|
@ -101,14 +102,25 @@ public class PgpEngine {
|
|||
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
|
||||
OpenPgpApi.RESULT_CODE_ERROR)) {
|
||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||
URL url = message.getImageParams().url;
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(
|
||||
outputFile.getAbsolutePath(), options);
|
||||
int imageHeight = options.outHeight;
|
||||
int imageWidth = options.outWidth;
|
||||
message.setBody(Long.toString(outputFile.getSize())
|
||||
+ ',' + imageWidth + ',' + imageHeight);
|
||||
if (url == null) {
|
||||
message.setBody(Long.toString(outputFile
|
||||
.getSize())
|
||||
+ '|'
|
||||
+ imageWidth
|
||||
+ '|'
|
||||
+ imageHeight);
|
||||
} else {
|
||||
message.setBody(url.toString() + "|"
|
||||
+ Long.toString(outputFile.getSize())
|
||||
+ '|' + imageWidth + '|' + imageHeight);
|
||||
}
|
||||
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||
PgpEngine.this.mXmppConnectionService
|
||||
.updateMessage(message);
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Arrays;
|
|||
import eu.siacs.conversations.Config;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
|
||||
public class Message extends AbstractEntity {
|
||||
|
||||
|
@ -405,14 +406,18 @@ public class Message extends AbstractEntity {
|
|||
}
|
||||
|
||||
public ImageParams getImageParams() {
|
||||
ImageParams params = new ImageParams();
|
||||
ImageParams params = getLegacyImageParams();
|
||||
if (params!=null) {
|
||||
return params;
|
||||
}
|
||||
params = new ImageParams();
|
||||
if (this.downloadable != null) {
|
||||
params.size = this.downloadable.getFileSize();
|
||||
}
|
||||
if (body == null) {
|
||||
return params;
|
||||
}
|
||||
String parts[] = body.split(",");
|
||||
String parts[] = body.split("\\|");
|
||||
if (parts.length == 1) {
|
||||
try {
|
||||
params.size = Long.parseLong(parts[0]);
|
||||
|
@ -466,6 +471,34 @@ public class Message extends AbstractEntity {
|
|||
return params;
|
||||
}
|
||||
|
||||
public ImageParams getLegacyImageParams() {
|
||||
ImageParams params = new ImageParams();
|
||||
if (body == null) {
|
||||
return params;
|
||||
}
|
||||
String parts[] = body.split(",");
|
||||
if (parts.length == 3) {
|
||||
try {
|
||||
params.size = Long.parseLong(parts[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
params.width = Integer.parseInt(parts[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
params.height = Integer.parseInt(parts[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
return params;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ImageParams {
|
||||
public URL url;
|
||||
public long size = 0;
|
||||
|
|
|
@ -244,8 +244,8 @@ public class HttpConnection implements Downloadable {
|
|||
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||
int imageHeight = options.outHeight;
|
||||
int imageWidth = options.outWidth;
|
||||
message.setBody(mUrl.toString() + "," + file.getSize() + ','
|
||||
+ imageWidth + ',' + imageHeight);
|
||||
message.setBody(mUrl.toString() + "|" + file.getSize() + '|'
|
||||
+ imageWidth + '|' + imageHeight);
|
||||
message.setType(Message.TYPE_IMAGE);
|
||||
mXmppConnectionService.updateMessage(message);
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ public class JingleConnection implements Downloadable {
|
|||
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||
int imageHeight = options.outHeight;
|
||||
int imageWidth = options.outWidth;
|
||||
message.setBody(Long.toString(file.getSize()) + ','
|
||||
+ imageWidth + ',' + imageHeight);
|
||||
message.setBody(Long.toString(file.getSize()) + '|'
|
||||
+ imageWidth + '|' + imageHeight);
|
||||
mXmppConnectionService.databaseBackend.createMessage(message);
|
||||
mXmppConnectionService.markMessage(message,
|
||||
Message.STATUS_RECEIVED);
|
||||
|
|
Loading…
Reference in New Issue