From 34f168280e862e3a23db8b2c35463ff501979182 Mon Sep 17 00:00:00 2001 From: nicofrand Date: Fri, 29 Mar 2024 13:52:08 +0100 Subject: [PATCH] Reload rich document edition on reload event from webview (triggered on session expiration) Signed-off-by: tobiasKaminsky --- .../android/ui/activity/EditorWebView.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java b/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java index 44cc583d5ee1..d1f75389a8cd 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/EditorWebView.java @@ -31,6 +31,7 @@ import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.SyncedFolderProvider; import com.owncloud.android.datamodel.ThumbnailsCacheManager; +import com.owncloud.android.ui.asynctasks.TextEditorLoadUrlTask; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.MimeTypeUtil; import com.owncloud.android.utils.WebViewUtil; @@ -99,6 +100,23 @@ public void closeView() { finish(); } + public void reload() { + if (getWebView().getVisibility() != View.VISIBLE) { + return; + } + + Optional user = getUser(); + if (!user.isPresent()) { + return; + } + + OCFile file = getFile(); + if (file != null) { + TextEditorLoadUrlTask task = new TextEditorLoadUrlTask(this, user.get(), file, editorUtils); + task.execute(); + } + } + @Override protected void bindView() { binding = RichdocumentsWebviewBinding.inflate(getLayoutInflater()); @@ -281,6 +299,11 @@ public void share() { public void loaded() { runOnUiThread(EditorWebView.this::hideLoading); } + + @JavascriptInterface + public void reload() { + EditorWebView.this.reload(); + } } }