kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix bug where missing media keys would not always be shown on time.
rodzic
e845fba8b3
commit
84f1da76ad
|
@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.mms.GlideApp;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
import org.thoughtcrime.securesms.util.AvatarUtil;
|
import org.thoughtcrime.securesms.util.AvatarUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
import org.webrtc.RendererCommon;
|
import org.webrtc.RendererCommon;
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ public class CallParticipantView extends ConstraintLayout {
|
||||||
|
|
||||||
private RecipientId recipientId;
|
private RecipientId recipientId;
|
||||||
private boolean infoMode;
|
private boolean infoMode;
|
||||||
|
private Runnable missingMediaKeysUpdater;
|
||||||
|
|
||||||
private AppCompatImageView backgroundAvatar;
|
private AppCompatImageView backgroundAvatar;
|
||||||
private AvatarImageView avatar;
|
private AvatarImageView avatar;
|
||||||
|
@ -77,6 +79,7 @@ public class CallParticipantView extends ConstraintLayout {
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
backgroundAvatar = findViewById(R.id.call_participant_background_avatar);
|
backgroundAvatar = findViewById(R.id.call_participant_background_avatar);
|
||||||
avatar = findViewById(R.id.call_participant_item_avatar);
|
avatar = findViewById(R.id.call_participant_item_avatar);
|
||||||
pipAvatar = findViewById(R.id.call_participant_item_pip_avatar);
|
pipAvatar = findViewById(R.id.call_participant_item_pip_avatar);
|
||||||
|
@ -102,7 +105,7 @@ public class CallParticipantView extends ConstraintLayout {
|
||||||
void setCallParticipant(@NonNull CallParticipant participant) {
|
void setCallParticipant(@NonNull CallParticipant participant) {
|
||||||
boolean participantChanged = recipientId == null || !recipientId.equals(participant.getRecipient().getId());
|
boolean participantChanged = recipientId == null || !recipientId.equals(participant.getRecipient().getId());
|
||||||
recipientId = participant.getRecipient().getId();
|
recipientId = participant.getRecipient().getId();
|
||||||
infoMode = participant.getRecipient().isBlocked() || (!participant.isMediaKeysReceived() && (System.currentTimeMillis() - participant.getAddedToCallTime()) > DELAY_SHOWING_MISSING_MEDIA_KEYS);
|
infoMode = participant.getRecipient().isBlocked() || isMissingMediaKeys(participant);
|
||||||
|
|
||||||
if (infoMode) {
|
if (infoMode) {
|
||||||
renderer.setVisibility(View.GONE);
|
renderer.setVisibility(View.GONE);
|
||||||
|
@ -149,6 +152,28 @@ public class CallParticipantView extends ConstraintLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMissingMediaKeys(@NonNull CallParticipant participant) {
|
||||||
|
if (missingMediaKeysUpdater != null) {
|
||||||
|
Util.cancelRunnableOnMain(missingMediaKeysUpdater);
|
||||||
|
missingMediaKeysUpdater = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!participant.isMediaKeysReceived()) {
|
||||||
|
long time = System.currentTimeMillis() - participant.getAddedToCallTime();
|
||||||
|
if (time > DELAY_SHOWING_MISSING_MEDIA_KEYS) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
missingMediaKeysUpdater = () -> {
|
||||||
|
if (recipientId.equals(participant.getRecipient().getId())) {
|
||||||
|
setCallParticipant(participant);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Util.runOnMainDelayed(missingMediaKeysUpdater, DELAY_SHOWING_MISSING_MEDIA_KEYS - time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void setRenderInPip(boolean shouldRenderInPip) {
|
void setRenderInPip(boolean shouldRenderInPip) {
|
||||||
if (infoMode) {
|
if (infoMode) {
|
||||||
infoMessage.setVisibility(shouldRenderInPip ? View.GONE : View.VISIBLE);
|
infoMessage.setVisibility(shouldRenderInPip ? View.GONE : View.VISIBLE);
|
||||||
|
|
Ładowanie…
Reference in New Issue