Skip to content

Commit

Permalink
Merge pull request #3485 from deltachat/adb/issue-3481
Browse files Browse the repository at this point in the history
add missing webxdc api
  • Loading branch information
adbenitez authored Dec 13, 2024
2 parents 41579de + c5cb79d commit a93c8ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -199,7 +201,9 @@ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> 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);

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/main/res/raw/webxdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ window.webxdc = (() => {
}

return {
sendUpdateMaxSize: InternalJSApi.sendUpdateMaxSize(),

sendUpdateInterval: InternalJSApi.sendUpdateInterval(),

selfAddr: InternalJSApi.selfAddr(),

selfName: InternalJSApi.selfName(),
Expand Down

0 comments on commit a93c8ab

Please sign in to comment.