Add shared calling intent system.

This commit is contained in:
Alex Hart
2024-09-03 15:22:44 -03:00
committed by Cody Henthorne
parent e5b482c7ad
commit 4d23f11f6e
12 changed files with 277 additions and 90 deletions

View File

@@ -15,10 +15,9 @@ import androidx.core.app.Person;
import org.signal.core.util.PendingIntentFlags;
import org.thoughtcrime.securesms.MainActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.WebRtcCallActivity;
import org.thoughtcrime.securesms.components.webrtc.v2.CallIntent;
import org.thoughtcrime.securesms.notifications.NotificationChannels;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.service.webrtc.ActiveCallManager;
import org.thoughtcrime.securesms.service.webrtc.WebRtcCallService;
import org.thoughtcrime.securesms.util.ConversationUtil;
@@ -49,13 +48,13 @@ public class CallNotificationBuilder {
private enum LaunchCallScreenIntentState {
CONTENT(null, 0),
AUDIO(WebRtcCallActivity.ANSWER_ACTION, 1),
VIDEO(WebRtcCallActivity.ANSWER_VIDEO_ACTION, 2);
AUDIO(CallIntent.Action.ANSWER_AUDIO, 1),
VIDEO(CallIntent.Action.ANSWER_VIDEO, 2);
final @Nullable String action;
final int requestCode;
final @Nullable CallIntent.Action action;
final int requestCode;
LaunchCallScreenIntentState(@Nullable String action, int requestCode) {
LaunchCallScreenIntentState(@Nullable CallIntent.Action action, int requestCode) {
this.action = action;
this.requestCode = requestCode;
}
@@ -219,17 +218,17 @@ public class CallNotificationBuilder {
}
private static PendingIntent getActivityPendingIntent(@NonNull Context context, @NonNull LaunchCallScreenIntentState launchCallScreenIntentState) {
Intent intent = new Intent(context, WebRtcCallActivity.class);
intent.setAction(launchCallScreenIntentState.action);
CallIntent.Builder builder = new CallIntent.Builder(context);
builder.withAction(launchCallScreenIntentState.action);
if (launchCallScreenIntentState == LaunchCallScreenIntentState.CONTENT) {
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
builder.withIntentFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
}
intent.putExtra(WebRtcCallActivity.EXTRA_STARTED_FROM_FULLSCREEN, launchCallScreenIntentState == LaunchCallScreenIntentState.CONTENT);
intent.putExtra(WebRtcCallActivity.EXTRA_ENABLE_VIDEO_IF_AVAILABLE, false);
builder.withStartedFromFullScreen(launchCallScreenIntentState == LaunchCallScreenIntentState.CONTENT);
builder.withEnableVideoIfAvailable(false);
return PendingIntent.getActivity(context, launchCallScreenIntentState.requestCode, intent, PendingIntentFlags.updateCurrent());
return PendingIntent.getActivity(context, launchCallScreenIntentState.requestCode, builder.build(), PendingIntentFlags.updateCurrent());
}
private static boolean deviceVersionSupportsIncomingCallStyle() {