diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-04-23 22:50:54 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-04-23 22:50:54 +0200 |
commit | b789ace386ef3cfe6e0c3834b2a425813f702f43 (patch) | |
tree | 7c9e3a28af017be1689648f4e27d2c08cea7a2dc /src/main/java/de/thedevstack/conversationsplus/services | |
parent | ab82801448ed2e89e1387235f74ff37818767e2b (diff) |
Fixes FS#204: Observe all used directories
- Implementing the FileObserver in a separate class, with mask to watch only deletions not everything
- Add observation of all directories which could contain a sent/received file
- Change observers if the folder names are changed via settings
- markMessage method moved from XmppConnectionService to MessageUtil
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java | 43 |
1 files changed, 3 insertions, 40 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java index b7b4db2c..cf587efe 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java @@ -7,7 +7,6 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.SharedPreferences; import android.database.ContentObserver; import android.graphics.Bitmap; import android.media.AudioManager; @@ -17,13 +16,11 @@ import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.Bundle; -import android.os.FileObserver; import android.os.IBinder; import android.os.Looper; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.SystemClock; -import android.preference.PreferenceManager; import android.provider.ContactsContract; import android.security.KeyChain; import android.util.DisplayMetrics; @@ -66,6 +63,7 @@ import de.thedevstack.conversationsplus.utils.FileUtils; import de.thedevstack.conversationsplus.utils.ImageUtil; import de.thedevstack.conversationsplus.utils.MessageUtil; import de.thedevstack.conversationsplus.utils.UiUpdateHelper; +import de.thedevstack.conversationsplus.utils.XmppConnectionServiceAccessor; import de.thedevstack.conversationsplus.utils.XmppSendUtil; import de.tzur.conversations.Settings; import de.thedevstack.conversationsplus.Config; @@ -204,16 +202,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa private MessageArchiveService mMessageArchiveService = new MessageArchiveService(this); private PushManagementService mPushManagementService = new PushManagementService(this); private OnConversationUpdate mOnConversationUpdate = null; - private final FileObserver fileObserver = new FileObserver( - FileBackend.getConversationsImageDirectory()) { - - @Override - public void onEvent(int event, String path) { - if (event == FileObserver.DELETE) { - markFileDeleted(path.split("\\.")[0]); - } - } - }; private final OnJinglePacketReceived jingleListener = new OnJinglePacketReceived() { @Override @@ -665,7 +653,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa restoreFromDatabase(); getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver); - this.fileObserver.startWatching(); if (Config.supportOpenPgp()) { this.pgpServiceConnection = new OpenPgpServiceConnection(getApplicationContext(), "org.sufficientlysecure.keychain", new OpenPgpServiceConnection.OnBound() { @@ -690,6 +677,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa toggleForegroundService(); updateUnreadCountBadge(); UiUpdateHelper.initXmppConnectionService(this); + XmppConnectionServiceAccessor.initXmppConnectionService(this); toggleScreenEventReceiver(); } @@ -1177,24 +1165,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa }); } - private void markFileDeleted(String uuid) { - for (Conversation conversation : getConversations()) { - Message message = conversation.findMessageWithFileAndUuid(uuid); - if (message != null) { - if (!FileBackend.isFileAvailable(message)) { - message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); - final int s = message.getStatus(); - if (s == Message.STATUS_WAITING || s == Message.STATUS_OFFERED || s == Message.STATUS_UNSEND) { - markMessage(message, Message.STATUS_SEND_FAILED); - } else { - updateConversationUi(); - } - } - return; - } - } - } - public void populateWithOrderedConversations(final List<Conversation> list) { populateWithOrderedConversations(list, true); } @@ -2412,14 +2382,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } public void markMessage(Message message, int status) { - if (status == Message.STATUS_SEND_FAILED - && (message.getStatus() == Message.STATUS_SEND_RECEIVED || message - .getStatus() == Message.STATUS_SEND_DISPLAYED)) { - return; - } - message.setStatus(status); - databaseBackend.updateMessage(message); - updateConversationUi(); + MessageUtil.markMessage(message, status); } public int unreadCount() { |