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.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import org.openintents.openpgp.OpenPgpError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
|
@ -101,14 +102,25 @@ public class PgpEngine {
|
||||||
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
|
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
|
||||||
OpenPgpApi.RESULT_CODE_ERROR)) {
|
OpenPgpApi.RESULT_CODE_ERROR)) {
|
||||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||||
|
URL url = message.getImageParams().url;
|
||||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
options.inJustDecodeBounds = true;
|
options.inJustDecodeBounds = true;
|
||||||
BitmapFactory.decodeFile(
|
BitmapFactory.decodeFile(
|
||||||
outputFile.getAbsolutePath(), options);
|
outputFile.getAbsolutePath(), options);
|
||||||
int imageHeight = options.outHeight;
|
int imageHeight = options.outHeight;
|
||||||
int imageWidth = options.outWidth;
|
int imageWidth = options.outWidth;
|
||||||
message.setBody(Long.toString(outputFile.getSize())
|
if (url == null) {
|
||||||
+ ',' + imageWidth + ',' + imageHeight);
|
message.setBody(Long.toString(outputFile
|
||||||
|
.getSize())
|
||||||
|
+ '|'
|
||||||
|
+ imageWidth
|
||||||
|
+ '|'
|
||||||
|
+ imageHeight);
|
||||||
|
} else {
|
||||||
|
message.setBody(url.toString() + "|"
|
||||||
|
+ Long.toString(outputFile.getSize())
|
||||||
|
+ '|' + imageWidth + '|' + imageHeight);
|
||||||
|
}
|
||||||
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||||
PgpEngine.this.mXmppConnectionService
|
PgpEngine.this.mXmppConnectionService
|
||||||
.updateMessage(message);
|
.updateMessage(message);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Arrays;
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
public class Message extends AbstractEntity {
|
public class Message extends AbstractEntity {
|
||||||
|
|
||||||
|
@ -405,14 +406,18 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageParams getImageParams() {
|
public ImageParams getImageParams() {
|
||||||
ImageParams params = new ImageParams();
|
ImageParams params = getLegacyImageParams();
|
||||||
|
if (params!=null) {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
params = new ImageParams();
|
||||||
if (this.downloadable != null) {
|
if (this.downloadable != null) {
|
||||||
params.size = this.downloadable.getFileSize();
|
params.size = this.downloadable.getFileSize();
|
||||||
}
|
}
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
String parts[] = body.split(",");
|
String parts[] = body.split("\\|");
|
||||||
if (parts.length == 1) {
|
if (parts.length == 1) {
|
||||||
try {
|
try {
|
||||||
params.size = Long.parseLong(parts[0]);
|
params.size = Long.parseLong(parts[0]);
|
||||||
|
@ -465,6 +470,34 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
return params;
|
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 class ImageParams {
|
||||||
public URL url;
|
public URL url;
|
||||||
|
|
|
@ -244,8 +244,8 @@ public class HttpConnection implements Downloadable {
|
||||||
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||||
int imageHeight = options.outHeight;
|
int imageHeight = options.outHeight;
|
||||||
int imageWidth = options.outWidth;
|
int imageWidth = options.outWidth;
|
||||||
message.setBody(mUrl.toString() + "," + file.getSize() + ','
|
message.setBody(mUrl.toString() + "|" + file.getSize() + '|'
|
||||||
+ imageWidth + ',' + imageHeight);
|
+ imageWidth + '|' + imageHeight);
|
||||||
message.setType(Message.TYPE_IMAGE);
|
message.setType(Message.TYPE_IMAGE);
|
||||||
mXmppConnectionService.updateMessage(message);
|
mXmppConnectionService.updateMessage(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ public class JingleConnection implements Downloadable {
|
||||||
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||||
int imageHeight = options.outHeight;
|
int imageHeight = options.outHeight;
|
||||||
int imageWidth = options.outWidth;
|
int imageWidth = options.outWidth;
|
||||||
message.setBody(Long.toString(file.getSize()) + ','
|
message.setBody(Long.toString(file.getSize()) + '|'
|
||||||
+ imageWidth + ',' + imageHeight);
|
+ imageWidth + '|' + imageHeight);
|
||||||
mXmppConnectionService.databaseBackend.createMessage(message);
|
mXmppConnectionService.databaseBackend.createMessage(message);
|
||||||
mXmppConnectionService.markMessage(message,
|
mXmppConnectionService.markMessage(message,
|
||||||
Message.STATUS_RECEIVED);
|
Message.STATUS_RECEIVED);
|
||||||
|
|
Loading…
Reference in a new issue