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/utils | |
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/utils')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java | 13 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/XmppConnectionServiceAccessor.java | 31 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java index 6a668938..7fbc2d94 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java @@ -6,8 +6,10 @@ import java.net.URL; import java.util.regex.Matcher; import java.util.regex.Pattern; +import de.thedevstack.conversationsplus.ConversationsPlusApplication; import de.thedevstack.conversationsplus.entities.DownloadableFile; import de.thedevstack.conversationsplus.entities.Message; +import de.thedevstack.conversationsplus.persistance.DatabaseBackend; import de.thedevstack.conversationsplus.persistance.FileBackend; /** @@ -15,6 +17,17 @@ import de.thedevstack.conversationsplus.persistance.FileBackend; */ public final class MessageUtil { + public static 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.getInstance(ConversationsPlusApplication.getAppContext()).updateMessage(message); + UiUpdateHelper.updateConversationUi(); + } + public static boolean wasHighlightedOrPrivate(final Message message) { final String nick = message.getConversation().getMucOptions().getActualNick(); final Pattern highlight = generateNickHighlightPattern(nick); diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/XmppConnectionServiceAccessor.java b/src/main/java/de/thedevstack/conversationsplus/utils/XmppConnectionServiceAccessor.java new file mode 100644 index 00000000..1f1d7cf4 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/utils/XmppConnectionServiceAccessor.java @@ -0,0 +1,31 @@ +package de.thedevstack.conversationsplus.utils; + +import de.thedevstack.android.logcat.Logging; +import de.thedevstack.conversationsplus.services.XmppConnectionService; + +/** + * Accessor utility to access XmppConnectionService without having to pass the XmppConnectionService every time. + */ +public final class XmppConnectionServiceAccessor { + public static XmppConnectionService xmppConnectionService; + + /** + * Initializes the XmppConnectionService. + * This method needs to be called once in XmppConnectionService#onCreate. + * @param xmppConnectionService + */ + public static void initXmppConnectionService(XmppConnectionService xmppConnectionService) { + if (null == XmppConnectionServiceAccessor.xmppConnectionService) { + XmppConnectionServiceAccessor.xmppConnectionService = xmppConnectionService; + } else { + Logging.e("XmppConnectionServiceAccessor", "XMPP Connection Service already instantiated."); + } + } + + /** + * Avoid instantiation + */ + private XmppConnectionServiceAccessor() { + // avoid instantiation + } +} |