diff --git a/src/org/thoughtcrime/securesms/components/TypingStatusRepository.java b/src/org/thoughtcrime/securesms/components/TypingStatusRepository.java index fb03fc0302..de34b3511c 100644 --- a/src/org/thoughtcrime/securesms/components/TypingStatusRepository.java +++ b/src/org/thoughtcrime/securesms/components/TypingStatusRepository.java @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components; import android.annotation.SuppressLint; import android.arch.lifecycle.LiveData; import android.arch.lifecycle.MutableLiveData; +import android.content.Context; import android.support.annotation.NonNull; import com.annimon.stream.Collectors; @@ -10,6 +11,7 @@ import com.annimon.stream.Stream; import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.recipients.Recipient; +import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.Util; import java.util.ArrayList; @@ -40,7 +42,11 @@ public class TypingStatusRepository { this.threadsNotifier = new MutableLiveData<>(); } - public synchronized void onTypingStarted(long threadId, Recipient author, int device) { + public synchronized void onTypingStarted(@NonNull Context context, long threadId, @NonNull Recipient author, int device) { + if (author.getAddress().serialize().equals(TextSecurePreferences.getLocalNumber(context))) { + return; + } + Set typists = Util.getOrDefault(typistMap, threadId, new LinkedHashSet<>()); Typist typist = new Typist(author, device, threadId); @@ -55,12 +61,16 @@ public class TypingStatusRepository { Util.cancelRunnableOnMain(timer); } - timer = () -> onTypingStopped(threadId, author, device, false); + timer = () -> onTypingStopped(context, threadId, author, device, false); Util.runOnMainDelayed(timer, RECIPIENT_TYPING_TIMEOUT); timers.put(typist, timer); } - public synchronized void onTypingStopped(long threadId, Recipient author, int device, boolean isReplacedByIncomingMessage) { + public synchronized void onTypingStopped(@NonNull Context context, long threadId, @NonNull Recipient author, int device, boolean isReplacedByIncomingMessage) { + if (author.getAddress().serialize().equals(TextSecurePreferences.getLocalNumber(context))) { + return; + } + Set typists = Util.getOrDefault(typistMap, threadId, new LinkedHashSet<>()); Typist typist = new Typist(author, device, threadId); diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 7c5d5c83f1..9f95d7d8b1 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -974,10 +974,10 @@ public class PushDecryptJob extends ContextJob { if (typingMessage.isTypingStarted()) { Log.d(TAG, "Typing started on thread " + threadId); - ApplicationContext.getInstance(context).getTypingStatusRepository().onTypingStarted(threadId, author, content.getSenderDevice()); + ApplicationContext.getInstance(context).getTypingStatusRepository().onTypingStarted(context,threadId, author, content.getSenderDevice()); } else { Log.d(TAG, "Typing stopped on thread " + threadId); - ApplicationContext.getInstance(context).getTypingStatusRepository().onTypingStopped(threadId, author, content.getSenderDevice(), false); + ApplicationContext.getInstance(context).getTypingStatusRepository().onTypingStopped(context, threadId, author, content.getSenderDevice(), false); } } @@ -1061,7 +1061,7 @@ public class PushDecryptJob extends ContextJob { if (threadId > 0) { Log.d(TAG, "Typing stopped on thread " + threadId + " due to an incoming message."); - ApplicationContext.getInstance(context).getTypingStatusRepository().onTypingStopped(threadId, author, device, true); + ApplicationContext.getInstance(context).getTypingStatusRepository().onTypingStopped(context, threadId, author, device, true); } }