mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Filter out typing indicators from ourself.
This commit is contained in:
parent
dd55fe90bc
commit
d6abf89a7a
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.arch.lifecycle.LiveData;
|
import android.arch.lifecycle.LiveData;
|
||||||
import android.arch.lifecycle.MutableLiveData;
|
import android.arch.lifecycle.MutableLiveData;
|
||||||
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.annimon.stream.Collectors;
|
import com.annimon.stream.Collectors;
|
||||||
@ -10,6 +11,7 @@ import com.annimon.stream.Stream;
|
|||||||
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -40,7 +42,11 @@ public class TypingStatusRepository {
|
|||||||
this.threadsNotifier = new MutableLiveData<>();
|
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<>());
|
Set<Typist> typists = Util.getOrDefault(typistMap, threadId, new LinkedHashSet<>());
|
||||||
Typist typist = new Typist(author, device, threadId);
|
Typist typist = new Typist(author, device, threadId);
|
||||||
|
|
||||||
@ -55,12 +61,16 @@ public class TypingStatusRepository {
|
|||||||
Util.cancelRunnableOnMain(timer);
|
Util.cancelRunnableOnMain(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = () -> onTypingStopped(threadId, author, device, false);
|
timer = () -> onTypingStopped(context, threadId, author, device, false);
|
||||||
Util.runOnMainDelayed(timer, RECIPIENT_TYPING_TIMEOUT);
|
Util.runOnMainDelayed(timer, RECIPIENT_TYPING_TIMEOUT);
|
||||||
timers.put(typist, timer);
|
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<>());
|
Set<Typist> typists = Util.getOrDefault(typistMap, threadId, new LinkedHashSet<>());
|
||||||
Typist typist = new Typist(author, device, threadId);
|
Typist typist = new Typist(author, device, threadId);
|
||||||
|
|
||||||
|
@ -974,10 +974,10 @@ public class PushDecryptJob extends ContextJob {
|
|||||||
|
|
||||||
if (typingMessage.isTypingStarted()) {
|
if (typingMessage.isTypingStarted()) {
|
||||||
Log.d(TAG, "Typing started on thread " + threadId);
|
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 {
|
} else {
|
||||||
Log.d(TAG, "Typing stopped on thread " + threadId);
|
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) {
|
if (threadId > 0) {
|
||||||
Log.d(TAG, "Typing stopped on thread " + threadId + " due to an incoming message.");
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user