Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
package it.niedermann.owncloud.notes.edit

import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.http.SslError
import android.os.Bundle
import android.util.Log
Expand Down Expand Up @@ -302,6 +304,30 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded {
super.onReceivedSslError(view, handler, error)
}
}

override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?,
): Boolean {
val url = request?.url ?: return false
val scheme = url.scheme?.lowercase()
val accountUrl = runCatching { account.url }.getOrNull()
if ((scheme == "http" || scheme == "https") &&
accountUrl != null && url.toString().startsWith(accountUrl)
) {
return false
}
return try {
val intent = Intent(Intent.ACTION_VIEW, url).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
startActivity(intent)
true
} catch (e: ActivityNotFoundException) {
Log.w(TAG, "No app available to open $url", e)
true
}
}
}
}

Expand Down