aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/persistance
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-25 20:13:51 +0100
committerlookshe <github@lookshe.org>2016-03-25 20:13:51 +0100
commit711ab9f2b1b625373a7046774c7b78e59f826589 (patch)
treeadbfec9c7f9cac33351b1b09c4f5057c6ef674b5 /src/main/java/de/thedevstack/conversationsplus/persistance
parentd25ab854dae2be0d5286d46b5038494d503dd367 (diff)
parent27c16b4b9acaad33b36145d63f6bfd7e04a3b3f1 (diff)
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/persistance')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java b/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java
index 07537fe3..45510661 100644
--- a/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java
+++ b/src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java
@@ -1,5 +1,6 @@
package de.thedevstack.conversationsplus.persistance;
+import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Environment;
@@ -25,10 +26,40 @@ import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.entities.DownloadableFile;
import de.thedevstack.conversationsplus.entities.Message;
+import de.thedevstack.conversationsplus.services.XmppConnectionService;
public class FileBackend {
private static final SimpleDateFormat imageDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.US);
+ public static 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 static void updateMediaScanner(File file, XmppConnectionService xmppConnectionService) {
+ if (file.getAbsolutePath().startsWith(getConversationsImageDirectory())) {
+ Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ intent.setData(Uri.fromFile(file));
+ xmppConnectionService.sendBroadcast(intent);
+ }
+ }
+
+ public static boolean deleteFile(Message message, XmppConnectionService xmppConnectionService) {
+ File file = getFile(message);
+ if (file.delete()) {
+ updateMediaScanner(file, xmppConnectionService);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public static DownloadableFile getFile(Message message) {
return getFile(message, true);
}