diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-04-06 15:34:08 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-04-06 15:34:08 +0200 |
commit | c30bf75a5d77fab21480e04ce18b46d6b2826295 (patch) | |
tree | b0eed8c7cf56483c90047eb92f53e18d9a1a6f51 /src/eu/siacs/conversations/persistance | |
parent | 9fc7a1b980863955a139193ded0fef5edfbad296 (diff) |
gui for images
Diffstat (limited to 'src/eu/siacs/conversations/persistance')
-rw-r--r-- | src/eu/siacs/conversations/persistance/DatabaseBackend.java | 8 | ||||
-rw-r--r-- | src/eu/siacs/conversations/persistance/FileBackend.java | 20 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java index 4c0d62163..852a93156 100644 --- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -23,7 +23,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { private static DatabaseBackend instance = null; private static final String DATABASE_NAME = "history"; - private static final int DATABASE_VERSION = 2; + private static final int DATABASE_VERSION = 3; public DatabaseBackend(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); @@ -50,7 +50,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { + " TEXT PRIMARY KEY, " + Message.CONVERSATION + " TEXT, " + Message.TIME_SENT + " NUMBER, " + Message.COUNTERPART + " TEXT, " + Message.BODY + " TEXT, " + Message.ENCRYPTION - + " NUMBER, " + Message.STATUS + " NUMBER," + "FOREIGN KEY(" + + " NUMBER, " + Message.STATUS + " NUMBER," +Message.TYPE +" NUMBER, FOREIGN KEY(" + Message.CONVERSATION + ") REFERENCES " + Conversation.TABLENAME + "(" + Conversation.UUID + ") ON DELETE CASCADE);"); @@ -72,6 +72,10 @@ public class DatabaseBackend extends SQLiteOpenHelper { db.execSQL("update " + Account.TABLENAME + " set " + Account.OPTIONS + " = " + Account.OPTIONS + " | 8"); } + if (oldVersion < 3 && newVersion >= 3) { + //add field type to message + db.execSQL("ALTER TABLE "+Message.TABLENAME+" ADD COLUMN "+Message.TYPE+" NUMBER");; + } } public static synchronized DatabaseBackend getInstance(Context context) { diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java index 05c505308..9ae406452 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()); + } } |