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
|
PgpEngine.this.mXmppConnectionService
|
||||||
.updateMessage(message);
|
.updateMessage(message);
|
||||||
inputFile.delete();
|
inputFile.delete();
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
mXmppConnectionService.getFileBackend().addImageFileToMedia(outputFile);
|
||||||
intent.setData(Uri.fromFile(outputFile));
|
|
||||||
mXmppConnectionService.sendBroadcast(intent);
|
|
||||||
callback.success(message);
|
callback.success(message);
|
||||||
return;
|
return;
|
||||||
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
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.utils.Xmlns;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.forms.Data;
|
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.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.pep.Avatar;
|
import eu.siacs.conversations.xmpp.pep.Avatar;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
|
|
|
@ -129,9 +129,7 @@ public class HttpDownloadConnection implements Transferable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finish() {
|
private void finish() {
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
mXmppConnectionService.getFileBackend().addImageFileToMedia(file);
|
||||||
intent.setData(Uri.fromFile(file));
|
|
||||||
mXmppConnectionService.sendBroadcast(intent);
|
|
||||||
message.setTransferable(null);
|
message.setTransferable(null);
|
||||||
mHttpConnectionManager.finishConnection(this);
|
mHttpConnectionManager.finishConnection(this);
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
|
|
|
@ -196,9 +196,7 @@ public class HttpUploadConnection implements Transferable {
|
||||||
mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key));
|
mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key));
|
||||||
}
|
}
|
||||||
mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl);
|
mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl);
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
mXmppConnectionService.getFileBackend().addImageFileToMedia(file);
|
||||||
intent.setData(Uri.fromFile(file));
|
|
||||||
mXmppConnectionService.sendBroadcast(intent);
|
|
||||||
message.setTransferable(null);
|
message.setTransferable(null);
|
||||||
message.setCounterpart(message.getConversation().getJid().toBareJid());
|
message.setCounterpart(message.getConversation().getJid().toBareJid());
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.siacs.conversations.persistance;
|
package eu.siacs.conversations.persistance;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
@ -50,6 +51,27 @@ public class FileBackend {
|
||||||
this.mXmppConnectionService = service;
|
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) {
|
public DownloadableFile getFile(Message message) {
|
||||||
return getFile(message, true);
|
return getFile(message, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,7 @@ public class JingleConnection implements Transferable {
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG,"successfully transmitted file:" + file.getAbsolutePath()+" ("+file.getSha1Sum()+")");
|
Log.d(Config.LOGTAG,"successfully transmitted file:" + file.getAbsolutePath()+" ("+file.getSha1Sum()+")");
|
||||||
if (message.getEncryption() != Message.ENCRYPTION_PGP) {
|
if (message.getEncryption() != Message.ENCRYPTION_PGP) {
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
mXmppConnectionService.getFileBackend().addImageFileToMedia(file);
|
||||||
intent.setData(Uri.fromFile(file));
|
|
||||||
mXmppConnectionService.sendBroadcast(intent);
|
|
||||||
} else {
|
} else {
|
||||||
account.getPgpDecryptionService().add(message);
|
account.getPgpDecryptionService().add(message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue