aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/persistance/FileBackend.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/persistance/FileBackend.java')
-rw-r--r--src/eu/siacs/conversations/persistance/FileBackend.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java
index 05c50530..9ae40645 100644
--- a/src/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/eu/siacs/conversations/persistance/FileBackend.java
@@ -15,6 +15,7 @@ import android.net.Uri;
import android.util.Log;
import eu.siacs.conversations.entities.Conversation;
+import eu.siacs.conversations.entities.Message;
public class FileBackend {
@@ -27,14 +28,18 @@ public class FileBackend {
this.context = context;
}
+ private File getImageFile(Message message) {
+ Conversation conversation = message.getConversation();
+ String prefix = context.getFilesDir().getAbsolutePath();
+ String path = prefix+"/"+conversation.getAccount().getJid()+"/"+conversation.getContactJid();
+ String filename = message.getUuid() + ".webp";
+ return new File(path+"/"+filename);
+ }
- public File copyImageToPrivateStorage(Conversation conversation, Uri image) {
+ public File copyImageToPrivateStorage(Message message, Uri image) {
try {
InputStream is = context.getContentResolver().openInputStream(image);
- String prefix = context.getFilesDir().getAbsolutePath();
- String path = prefix+"/"+conversation.getAccount().getJid()+"/"+conversation.getContactJid();
- String filename =new BigInteger(""+System.currentTimeMillis()).toString(32) + ".webp";
- File file = new File(path+"/"+filename);
+ File file = getImageFile(message);
file.getParentFile().mkdirs();
file.createNewFile();
OutputStream os = new FileOutputStream(file);
@@ -73,4 +78,9 @@ public class FileBackend {
return null;
}
+
+
+ public Bitmap getImageFromMessage(Message message) {
+ return BitmapFactory.decodeFile(getImageFile(message).getAbsolutePath());
+ }
}