update to new calls-app's API

This commit is contained in:
adbenitez 2025-09-12 18:59:34 +02:00
parent 6b1c6b37ac
commit bee804e095
5 changed files with 50 additions and 28 deletions

@ -1 +1 @@
Subproject commit 75bcf8660bca5b80bea7835bd85df11518a0f7e4
Subproject commit 5d9b887624f8c1641e40e009727b977de1c62bee

File diff suppressed because one or more lines are too long

View file

@ -17,6 +17,7 @@ import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import androidx.annotation.NonNull;
@ -50,7 +51,10 @@ import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.videochat.VideochatActivity;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
@ -166,7 +170,14 @@ public class NotificationCenter {
.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatData.chatId)
.setAction(Intent.ACTION_VIEW);
String hash = "#offer=" + payload;
String base64 = Base64.encodeToString(payload.getBytes(StandardCharsets.UTF_8), Base64.NO_WRAP);
String hash = "";
try {
hash = "#acceptCall=" + URLEncoder.encode(base64, "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Error", e);
}
Intent intent = new Intent(context, VideochatActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(VideochatActivity.EXTRA_ACCOUNT_ID, chatData.accountId);

View file

@ -4,6 +4,8 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.Menu;
import android.webkit.JavascriptInterface;
import android.webkit.PermissionRequest;
@ -23,9 +25,13 @@ import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.AvatarUtil;
import org.thoughtcrime.securesms.util.Util;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
public class VideochatActivity extends WebViewActivity implements DcEventCenter.DcEventDelegate {
private static final String TAG = VideochatActivity.class.getSimpleName();
public static final String EXTRA_ACCOUNT_ID = "acc_id";
public static final String EXTRA_CHAT_ID = "chat_id";
@ -101,8 +107,13 @@ public class VideochatActivity extends WebViewActivity implements DcEventCenter.
switch (event.getId()) {
case DcContext.DC_EVENT_OUTGOING_CALL_ACCEPTED:
if (event.getData1Int() == callId) {
String hash = "#answer=" + event.getData2Str();
try {
String base64 = Base64.encodeToString(event.getData2Str().getBytes(StandardCharsets.UTF_8), Base64.NO_WRAP);
String hash = "#onAnswer=" + URLEncoder.encode(base64, "UTF-8");
webView.evaluateJavascript("window.location.hash = `"+hash+"`", null);
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Error", e);
}
}
break;
case DcContext.DC_EVENT_CALL_ENDED:

View file

@ -21,7 +21,7 @@ public class VideochatUtil {
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(VideochatActivity.EXTRA_ACCOUNT_ID, accId);
intent.putExtra(VideochatActivity.EXTRA_CHAT_ID, chatId);
intent.putExtra(VideochatActivity.EXTRA_HASH, "#call");
intent.putExtra(VideochatActivity.EXTRA_HASH, "#startCall");
activity.startActivity(intent);
})
.execute();