From 281cb6504683ae2b8b957e18ff3f7f7f94941777 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Mar 2016 12:20:09 +0100 Subject: only add image files to media scanner --- src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java | 4 +--- src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/http') diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 84a44715b..161a73f6a 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -129,9 +129,7 @@ public class HttpDownloadConnection implements Transferable { } private void finish() { - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(file)); - mXmppConnectionService.sendBroadcast(intent); + mXmppConnectionService.getFileBackend().addImageFileToMedia(file); message.setTransferable(null); mHttpConnectionManager.finishConnection(this); if (message.getEncryption() == Message.ENCRYPTION_PGP) { diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java index 1e4b91021..4d880ffc5 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java @@ -196,9 +196,7 @@ public class HttpUploadConnection implements Transferable { mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key)); } mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl); - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(file)); - mXmppConnectionService.sendBroadcast(intent); + mXmppConnectionService.getFileBackend().addImageFileToMedia(file); message.setTransferable(null); message.setCounterpart(message.getConversation().getJid().toBareJid()); if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { -- cgit v1.2.3 From a9b66e3ea588a0e9e621d10ad15c9456b0312b60 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Mar 2016 19:23:22 +0100 Subject: allow to delete attachments. fixes #1539 --- .../eu/siacs/conversations/http/HttpDownloadConnection.java | 10 ++-------- .../java/eu/siacs/conversations/http/HttpUploadConnection.java | 7 +------ 2 files changed, 3 insertions(+), 14 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/http') diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 161a73f6a..d23cb71a3 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -1,7 +1,5 @@ package eu.siacs.conversations.http; -import android.content.Intent; -import android.net.Uri; import android.os.PowerManager; import android.util.Log; @@ -10,12 +8,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.MalformedURLException; -import java.net.Proxy; import java.net.URL; -import java.util.Arrays; import java.util.concurrent.CancellationException; import javax.net.ssl.HttpsURLConnection; @@ -94,7 +88,7 @@ public class HttpDownloadConnection implements Transferable { } else { extension = lastPart; } - message.setRelativeFilePath(message.getUuid()+"."+extension); + message.setRelativeFilePath(message.getUuid() + "." + extension); this.file = mXmppConnectionService.getFileBackend().getFile(message, false); String reference = mUrl.getRef(); if (reference != null && reference.length() == 96) { @@ -129,7 +123,7 @@ public class HttpDownloadConnection implements Transferable { } private void finish() { - mXmppConnectionService.getFileBackend().addImageFileToMedia(file); + mXmppConnectionService.getFileBackend().updateMediaScanner(file); message.setTransferable(null); mHttpConnectionManager.finishConnection(this); if (message.getEncryption() == Message.ENCRYPTION_PGP) { diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java index 4d880ffc5..e337509b5 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java @@ -1,8 +1,6 @@ package eu.siacs.conversations.http; import android.app.PendingIntent; -import android.content.Intent; -import android.net.Uri; import android.os.PowerManager; import android.util.Log; import android.util.Pair; @@ -12,10 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.MalformedURLException; -import java.net.Proxy; import java.net.URL; import javax.net.ssl.HttpsURLConnection; @@ -196,7 +191,7 @@ public class HttpUploadConnection implements Transferable { mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key)); } mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl); - mXmppConnectionService.getFileBackend().addImageFileToMedia(file); + mXmppConnectionService.getFileBackend().updateMediaScanner(file); message.setTransferable(null); message.setCounterpart(message.getConversation().getJid().toBareJid()); if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { -- cgit v1.2.3