aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-04-23 23:22:57 +0200
committersteckbrief <steckbrief@chefmail.de>2016-04-23 23:22:57 +0200
commitb5abdd1b6ddf73cc9da49e3213d0d44e4b29ff5c (patch)
treeb1d28cc2b00622d7feeff4569aa2a054d3a82b80 /src/main/java/de/thedevstack/conversationsplus/utils
parent52fec558adb2b4d9bb3df314fd919570e7198e26 (diff)
parentb789ace386ef3cfe6e0c3834b2a425813f702f43 (diff)
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Conflicts: src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java src/main/java/eu/siacs/conversations/generator/MessageGenerator.java src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java14
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/XmppConnectionServiceAccessor.java32
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java16
3 files changed, 62 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 f8310206..afb8387d 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java
@@ -6,8 +6,11 @@ import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
+
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
+import eu.siacs.conversations.persistance.DatabaseBackend;
import eu.siacs.conversations.persistance.FileBackend;
/**
@@ -15,6 +18,17 @@ import eu.siacs.conversations.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..20cd7361
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/XmppConnectionServiceAccessor.java
@@ -0,0 +1,32 @@
+package de.thedevstack.conversationsplus.utils;
+
+import de.thedevstack.android.logcat.Logging;
+
+import eu.siacs.conversations.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
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java
index bb08014b..a775dad6 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/ui/TextViewUtil.java
@@ -1,12 +1,28 @@
package de.thedevstack.conversationsplus.utils.ui;
import android.support.annotation.StringRes;
+import android.view.View;
import android.widget.TextView;
/**
* Created by steckbrief on 29.03.2016.
*/
public final class TextViewUtil {
+
+ public static void setText(View parentView, int textViewId, CharSequence text) {
+ TextView tv = (TextView) parentView.findViewById(textViewId);
+ if (null != tv) {
+ tv.setText(text);
+ }
+ }
+
+ public static void setText(View parentView, int textViewId, int textResId) {
+ TextView tv = (TextView) parentView.findViewById(textViewId);
+ if (null != tv) {
+ tv.setText(textResId);
+ }
+ }
+
public static void enable(TextView tv) {
setColorEnabledAndTextResId(tv, null, true, null);
}