Move calling management out of service.

This commit is contained in:
Cody Henthorne
2021-03-31 14:30:30 -04:00
committed by Alex Hart
parent d8dead82b6
commit 1dc3cf7824
32 changed files with 1355 additions and 2226 deletions

View File

@@ -571,7 +571,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
}
if (groupCallViewModel != null) {
groupCallViewModel.peekGroupCall(this);
groupCallViewModel.peekGroupCall();
}
setVisibleThread(threadId);
@@ -2210,7 +2210,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
groupCallViewModel = ViewModelProviders.of(this, new GroupCallViewModel.Factory()).get(GroupCallViewModel.class);
recipient.observe(this, r -> {
groupCallViewModel.onRecipientChange(this, r);
groupCallViewModel.onRecipientChange(r);
});
groupCallViewModel.hasActiveGroupCall().observe(this, hasActiveCall -> {
@@ -2361,7 +2361,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
}
if (groupCallViewModel != null) {
groupCallViewModel.onRecipientChange(this, recipient);
groupCallViewModel.onRecipientChange(recipient);
}
}

View File

@@ -1,7 +1,5 @@
package org.thoughtcrime.securesms.conversation.ui.groupcall;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.NonNull;
@@ -12,10 +10,9 @@ import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.events.GroupCallPeekEvent;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
import org.thoughtcrime.securesms.service.WebRtcCallService;
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
import java.util.Objects;
@@ -46,7 +43,7 @@ public class GroupCallViewModel extends ViewModel {
return groupCallHasCapacity;
}
public void onRecipientChange(@NonNull Context context, @Nullable Recipient recipient) {
public void onRecipientChange(@Nullable Recipient recipient) {
activeGroup.postValue(recipient != null && recipient.isActiveGroup());
if (Objects.equals(currentRecipient, recipient)) {
@@ -58,17 +55,13 @@ public class GroupCallViewModel extends ViewModel {
currentRecipient = recipient;
peekGroupCall(context);
peekGroupCall();
}
public void peekGroupCall(@NonNull Context context) {
public void peekGroupCall() {
if (isGroupCallCapable(currentRecipient)) {
Log.i(TAG, "peek call for " + currentRecipient.getId());
Intent intent = new Intent(context, WebRtcCallService.class);
intent.setAction(WebRtcCallService.ACTION_GROUP_CALL_PEEK)
.putExtra(WebRtcCallService.EXTRA_REMOTE_PEER, new RemotePeer(currentRecipient.getId()));
context.startService(intent);
ApplicationDependencies.getSignalCallManager().peekGroupCall(currentRecipient.getId());
}
}