Filter out typing indicators from ourself.

fork-5.53.8
Greyson Parrelli 2018-12-01 09:51:28 -08:00
rodzic dd55fe90bc
commit d6abf89a7a
2 zmienionych plików z 16 dodań i 6 usunięć

Wyświetl plik

@ -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<Typist> 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<Typist> typists = Util.getOrDefault(typistMap, threadId, new LinkedHashSet<>());
Typist typist = new Typist(author, device, threadId);

Wyświetl plik

@ -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);
}
}