Collabora: click on hyperlink opens it in browser, not in webview

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-10-14 12:13:30 +02:00
parent baff5f2f64
commit 7edd1f22fa
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -74,6 +74,7 @@ public class RichDocumentsEditorWebView extends EditorWebView {
public static final int REQUEST_LOCAL_FILE = 101;
private static final int REQUEST_REMOTE_FILE = 100;
private static final String URL = "URL";
private static final String HYPERLINK = "Url";
private static final String TYPE = "Type";
private static final String PRINT = "print";
private static final String SLIDESHOW = "slideshow";
@ -287,7 +288,6 @@ public class RichDocumentsEditorWebView extends EditorWebView {
}
} catch (JSONException e) {
Log_OC.e(this, "Failed to parse download json message: " + e);
return;
}
}
@ -312,5 +312,17 @@ public class RichDocumentsEditorWebView extends EditorWebView {
webview.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_PASTE));
}
}
@JavascriptInterface
public void hyperlink(String hyperlink) {
try {
String url = new JSONObject(hyperlink).getString(HYPERLINK);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
} catch (JSONException e) {
Log_OC.e(this, "Failed to parse download json message: " + e);
}
}
}
}