From c5cb79d116d3d47a46fd4c03600f8b530a99eb78 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 13 Dec 2024 13:42:39 +0100 Subject: [PATCH] add missing webxdc api --- .../thoughtcrime/securesms/WebxdcActivity.java | 18 ++++++++++++++++-- src/main/res/raw/webxdc.js | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java index 682ea6151..dc8589999 100644 --- a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java @@ -74,7 +74,9 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE private DcMsg dcAppMsg; private String baseURL; private String sourceCodeUrl = ""; - private String selfAddr = ""; + private String selfAddr; + private int sendUpdateMaxSize; + private int sendUpdateInterval; private boolean internetAccess = false; private boolean hideActionBar = false; @@ -199,7 +201,9 @@ public boolean onShowFileChooser(WebView webView, ValueCallback filePathC final JSONObject info = this.dcAppMsg.getWebxdcInfo(); internetAccess = JsonUtils.optBoolean(info, "internet_access"); - selfAddr = JsonUtils.optString(info, "self_addr"); + selfAddr = info.optString("self_addr"); + sendUpdateMaxSize = info.optInt("send_update_max_size"); + sendUpdateInterval = info.optInt("send_update_interval"); toggleFakeProxy(!internetAccess); @@ -494,6 +498,16 @@ private void leaveRealtimeChannel() { } class InternalJSApi { + @JavascriptInterface + public int sendUpdateMaxSize() { + return WebxdcActivity.this.sendUpdateMaxSize; + } + + @JavascriptInterface + public int sendUpdateInterval() { + return WebxdcActivity.this.sendUpdateInterval; + } + @JavascriptInterface public String selfAddr() { return WebxdcActivity.this.selfAddr; diff --git a/src/main/res/raw/webxdc.js b/src/main/res/raw/webxdc.js index 921597bd3..a68bdda8e 100644 --- a/src/main/res/raw/webxdc.js +++ b/src/main/res/raw/webxdc.js @@ -42,6 +42,10 @@ window.webxdc = (() => { } return { + sendUpdateMaxSize: InternalJSApi.sendUpdateMaxSize(), + + sendUpdateInterval: InternalJSApi.sendUpdateInterval(), + selfAddr: InternalJSApi.selfAddr(), selfName: InternalJSApi.selfName(),