From 3abd3091ac6aa01b76bca5c6b17023d45fb084b8 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 3 May 2019 23:25:34 +0200 Subject: introduced type private_file_message to handle attachments in PMs --- .../java/de/pixart/messenger/persistance/DatabaseBackend.java | 10 +++++----- .../java/de/pixart/messenger/persistance/FileBackend.java | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src/main/java/de/pixart/messenger/persistance') diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index e2c83321d..37f577079 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -841,14 +841,14 @@ public class DatabaseBackend extends SQLiteOpenHelper { if (internal) { final String name = file.getName(); if (name.endsWith(".pgp")) { - selection = "(" + Message.RELATIVE_FILE_PATH + " IN(?,?) OR (" + Message.RELATIVE_FILE_PATH + "=? and encryption in(1,4))) and type in (1,2)"; + selection = "(" + Message.RELATIVE_FILE_PATH + " IN(?,?) OR (" + Message.RELATIVE_FILE_PATH + "=? and encryption in(1,4))) and type in (1,2,5)"; selectionArgs = new String[]{file.getAbsolutePath(), name, name.substring(0, name.length() - 4)}; } else { - selection = Message.RELATIVE_FILE_PATH + " IN(?,?) and type in (1,2)"; + selection = Message.RELATIVE_FILE_PATH + " IN(?,?) and type in (1,2,5)"; selectionArgs = new String[]{file.getAbsolutePath(), name}; } } else { - selection = Message.RELATIVE_FILE_PATH + "=? and type in (1,2)"; + selection = Message.RELATIVE_FILE_PATH + "=? and type in (1,2,5)"; selectionArgs = new String[]{file.getAbsolutePath()}; } final List uuids = new ArrayList<>(); @@ -891,7 +891,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { public List getFilePathInfo() { final SQLiteDatabase db = this.getReadableDatabase(); - final Cursor cursor = db.query(Message.TABLENAME, new String[]{Message.UUID, Message.RELATIVE_FILE_PATH, Message.FILE_DELETED}, "type in (1,2) and " + Message.RELATIVE_FILE_PATH + " is not null", null, null, null, null); + final Cursor cursor = db.query(Message.TABLENAME, new String[]{Message.UUID, Message.RELATIVE_FILE_PATH, Message.DELETED}, "type in (1,2,5) and "+Message.RELATIVE_FILE_PATH+" is not null", null, null, null, null); final List list = new ArrayList<>(); while (cursor != null && cursor.moveToNext()) { list.add(new FilePathInfo(cursor.getString(0), cursor.getString(1), cursor.getInt(2) > 0)); @@ -904,7 +904,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { public List getRelativeFilePaths(String account, Jid jid, int limit) { SQLiteDatabase db = this.getReadableDatabase(); - final String SQL = "select uuid,relativeFilePath from messages where type in (1,2) and file_deleted=0 and " + Message.RELATIVE_FILE_PATH + " is not null and conversationUuid=(select uuid from conversations where accountUuid=? and (contactJid=? or contactJid like ?)) order by timeSent desc"; + final String SQL = "select uuid,relativeFilePath from messages where type in (1,2,5) and deleted=0 and " + Message.RELATIVE_FILE_PATH + " is not null and conversationUuid=(select uuid from conversations where accountUuid=? and (contactJid=? or contactJid like ?)) order by timeSent desc"; final String[] args = {account, jid.toEscapedString(), jid.toEscapedString() + "/%"}; Cursor cursor = db.rawQuery(SQL + (limit > 0 ? " limit " + String.valueOf(limit) : ""), args); List filesPaths = new ArrayList<>(); diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index e255ff225..3eaa9e406 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -350,7 +350,7 @@ public class FileBackend { if ((size == 0 || size >= mXmppConnectionService.getCompressImageSizePreference()) && mXmppConnectionService.getCompressImageSizePreference() != 0) { return false; } - if (mXmppConnectionService.getCompressImageResolutionPreference() == 0 && mXmppConnectionService.getCompressImageSizePreference() == 0 ) { + if (mXmppConnectionService.getCompressImageResolutionPreference() == 0 && mXmppConnectionService.getCompressImageSizePreference() == 0) { return true; } BitmapFactory.Options options = new BitmapFactory.Options(); @@ -679,7 +679,7 @@ public class FileBackend { frame = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); frame.eraseColor(0xff000000); } - drawOverlay(frame,R.drawable.play_video,0.75f); + drawOverlay(frame, R.drawable.play_video, 0.75f); return frame; } @@ -1036,6 +1036,7 @@ public class FileBackend { public void updateFileParams(Message message, URL url) { DownloadableFile file = getFile(message); final String mime = file.getMimeType(); + final boolean privateMessage = message.isPrivateMessage(); final boolean image = message.getType() == Message.TYPE_IMAGE || (mime != null && mime.startsWith("image/")); final boolean video = mime != null && mime.startsWith("video/"); final boolean audio = mime != null && mime.startsWith("audio/"); @@ -1065,7 +1066,7 @@ public class FileBackend { } message.setBody(body.toString()); message.setFileDeleted(false); - message.setType(image ? Message.TYPE_IMAGE : Message.TYPE_FILE); + message.setType(privateMessage ? Message.TYPE_PRIVATE_FILE : (image ? Message.TYPE_IMAGE : Message.TYPE_FILE)); } private int getMediaRuntime(File file) { @@ -1078,7 +1079,7 @@ public class FileBackend { } } - private String getAPK (File file, Context context) { + private String getAPK(File file, Context context) { String APKName; final PackageManager pm = context.getPackageManager(); final PackageInfo pi = pm.getPackageArchiveInfo(file.toString(), 0); @@ -1107,7 +1108,7 @@ public class FileBackend { return APKName; } - private String getVCard (File file) { + private String getVCard(File file) { VCard VCard = new VCard(); String VCardName = ""; try { -- cgit v1.2.3