only add image files to media scanner
This commit is contained in:
parent
564113669e
commit
281cb65046
|
@ -106,9 +106,7 @@ public class PgpEngine {
|
|||
PgpEngine.this.mXmppConnectionService
|
||||
.updateMessage(message);
|
||||
inputFile.delete();
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(Uri.fromFile(outputFile));
|
||||
mXmppConnectionService.sendBroadcast(intent);
|
||||
mXmppConnectionService.getFileBackend().addImageFileToMedia(outputFile);
|
||||
callback.success(message);
|
||||
return;
|
||||
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
||||
|
|
|
@ -25,7 +25,6 @@ import eu.siacs.conversations.services.XmppConnectionService;
|
|||
import eu.siacs.conversations.utils.Xmlns;
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
import eu.siacs.conversations.xmpp.forms.Data;
|
||||
import eu.siacs.conversations.xmpp.forms.Field;
|
||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||
import eu.siacs.conversations.xmpp.pep.Avatar;
|
||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.siacs.conversations.persistance;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -50,6 +51,27 @@ public class FileBackend {
|
|||
this.mXmppConnectionService = service;
|
||||
}
|
||||
|
||||
private void createNoMedia() {
|
||||
final File nomedia = new File(getConversationsFileDirectory()+".nomedia");
|
||||
if (!nomedia.exists()) {
|
||||
try {
|
||||
nomedia.createNewFile();
|
||||
} catch (Exception e) {
|
||||
Log.d(Config.LOGTAG, "could not create nomedia file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addImageFileToMedia(File file) {
|
||||
if (file.getAbsolutePath().startsWith(getConversationsImageDirectory())) {
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(Uri.fromFile(file));
|
||||
mXmppConnectionService.sendBroadcast(intent);
|
||||
} else {
|
||||
createNoMedia();
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadableFile getFile(Message message) {
|
||||
return getFile(message, true);
|
||||
}
|
||||
|
|
|
@ -111,9 +111,7 @@ public class JingleConnection implements Transferable {
|
|||
}
|
||||
Log.d(Config.LOGTAG,"successfully transmitted file:" + file.getAbsolutePath()+" ("+file.getSha1Sum()+")");
|
||||
if (message.getEncryption() != Message.ENCRYPTION_PGP) {
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(Uri.fromFile(file));
|
||||
mXmppConnectionService.sendBroadcast(intent);
|
||||
mXmppConnectionService.getFileBackend().addImageFileToMedia(file);
|
||||
} else {
|
||||
account.getPgpDecryptionService().add(message);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue