diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2014-05-13 16:48:39 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2014-05-13 16:48:39 +0200 |
commit | 9492e2890208ed8527504d692cfdb07d36d2fa30 (patch) | |
tree | 3638889168dc1bffdba605dcce01f1689f5fc773 /src/eu/siacs/conversations/persistance/FileBackend.java | |
parent | a8010e71335daab3dfc3d6d523fd51755c9d6427 (diff) |
takeing pictures over intent
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/persistance/FileBackend.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java index becb1ee3..0b26049e 100644 --- a/src/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/eu/siacs/conversations/persistance/FileBackend.java @@ -1,6 +1,7 @@ package eu.siacs.conversations.persistance; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -17,7 +18,6 @@ import android.util.LruCache; import android.view.View; import android.widget.ImageView; import android.widget.TextView; - import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; @@ -89,15 +89,25 @@ public class FileBackend { public JingleFile copyImageToPrivateStorage(Message message, Uri image) { try { - Log.d("xmppService","copying file: "+image.toString()+ " to internal storage"); - InputStream is = context.getContentResolver() + InputStream is; + if (image!=null) { + Log.d("xmppService","copying file: "+image.toString()+ " to internal storage"); + is = context.getContentResolver() .openInputStream(image); + } else { + Log.d("xmppService","copying file from incoming to internal storage"); + is = new FileInputStream(getIncomingFile()); + } JingleFile file = getJingleFile(message); file.getParentFile().mkdirs(); file.createNewFile(); OutputStream os = new FileOutputStream(file); Bitmap originalBitmap = BitmapFactory.decodeStream(is); is.close(); + if (image==null) { + Log.d("xmppService","delete incoming file"); + getIncomingFile().delete(); + } Bitmap scalledBitmap = resize(originalBitmap, IMAGE_SIZE); boolean success = scalledBitmap.compress( Bitmap.CompressFormat.WEBP, 75, os); @@ -160,4 +170,8 @@ public class FileBackend { } f.delete(); } + + public File getIncomingFile() { + return new File(context.getFilesDir().getAbsolutePath()+"/incoming"); + } } |