From 9dc579df155f7eb3ac51e54063786a3e05dd6585 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 26 Jul 2022 15:14:13 -0500 Subject: [PATCH] Allow oob webview to move the execution forward --- .../siacs/conversations/entities/Conversation.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index e7104f0f5135c535f3ef1d94c59beecc99570712..bb7dee1ad9bd66a9217d2b092930b137b9c5ac83 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -22,6 +22,7 @@ import android.widget.CompoundButton; import android.widget.TextView; import android.widget.Toast; import android.widget.Spinner; +import android.webkit.JavascriptInterface; import android.webkit.WebView; import android.webkit.WebViewClient; import android.webkit.WebChromeClient; @@ -1713,8 +1714,21 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl ConversationPagerAdapter.this.notifyDataSetChanged(); } }); + binding.webview.addJavascriptInterface(new JsObject(), "xmpp_xep0050"); binding.webview.loadUrl(oob.el.findChildContent("url", "jabber:x:oob")); } + + class JsObject { + @JavascriptInterface + public void execute() { execute("execute"); } + public void execute(String action) { + getView().post(() -> { + if(CommandSession.this.execute(action)) { + removeSession(CommandSession.this); + } + }); + } + } } class ProgressBarViewHolder extends ViewHolder {