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 @@ -509,39 +509,40 @@ final class TravelArticleDialogViewController: OABaseWebViewController, TravelAr
}
}

// override func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping @MainActor @Sendable (WKNavigationActionPolicy) -> Void) {
// let newUrl = OATravelGuidesHelper.normalizeFileUrl(navigationAction.request.url?.absoluteString) ?? ""
// let isWebPage = newUrl.hasPrefix(PAGE_PREFIX_HTTP) || newUrl.hasPrefix(PAGE_PREFIX_HTTPS)
// let isPhoneNumber = newUrl.hasPrefix("tel:") || newUrl.rangeOfCharacter(from: CharacterSet(charactersIn: "-+()% 0123456789").inverted) == nil
// let isEmail = newUrl.isValidEmail()
//
// if newUrl.hasSuffix("showNavigation") {
// // Clicked on Breadcrumbs navigation pannel
// showNavigation()
// decisionHandler(.cancel)
// } else if isPhoneNumber || isEmail {
// decisionHandler(.allow)
// } else if newUrl == blankUrl {
// // On open new TravelGuides page via code
// decisionHandler(.allow)
// } else if newUrl.contains(WIKIVOYAGE_DOMAIN) && isWebPage {
// TravelGuidesUtils.processWikivoyageDomain(url: newUrl, delegate: self)
// decisionHandler(.cancel)
// } else if newUrl.contains(WIKI_DOMAIN) && isWebPage && article != nil {
// self.webView.addSpinner()
// let defaultCoordinates = CLLocation(latitude: article!.lat, longitude: article!.lon)
// TravelGuidesUtils.processWikipediaDomain(defaultLocation: defaultCoordinates, url: newUrl, delegate: self)
// decisionHandler(.cancel)
// } else if isWebPage {
// OAWikiArticleHelper.warnAboutExternalLoad(newUrl, sourceView: self.webView)
// decisionHandler(.cancel)
// } else if newUrl.contains(PREFIX_GEO) {
// handleGeoUrl(newUrl)
// decisionHandler(.cancel)
// } else {
// decisionHandler(.allow)
// }
// }
override func webView(_ webView: WKWebView,
decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy {
let newUrl = OATravelGuidesHelper.normalizeFileUrl(navigationAction.request.url?.absoluteString) ?? ""
let isWebPage = newUrl.hasPrefix(PAGE_PREFIX_HTTP) || newUrl.hasPrefix(PAGE_PREFIX_HTTPS)
let isPhoneNumber = newUrl.hasPrefix("tel:") || newUrl.rangeOfCharacter(from: CharacterSet(charactersIn: "-+()% 0123456789").inverted) == nil
let isEmail = newUrl.isValidEmail()

if newUrl.hasSuffix("showNavigation") {
// Clicked on Breadcrumbs navigation panel
showNavigation()
return .cancel
} else if isPhoneNumber || isEmail {
return .allow
} else if newUrl == blankUrl {
// On open new TravelGuides page via code
return .allow
} else if newUrl.contains(WIKIVOYAGE_DOMAIN) && isWebPage {
TravelGuidesUtils.processWikivoyageDomain(url: newUrl, delegate: self)
return .cancel
} else if newUrl.contains(WIKI_DOMAIN) && isWebPage && article != nil {
self.webView.addSpinner()
let defaultCoordinates = CLLocation(latitude: article!.lat, longitude: article!.lon)
TravelGuidesUtils.processWikipediaDomain(defaultLocation: defaultCoordinates, url: newUrl, delegate: self)
return .cancel
} else if isWebPage {
OAWikiArticleHelper.warnAboutExternalLoad(newUrl, sourceView: self.webView)
return .cancel
} else if newUrl.contains(PREFIX_GEO) {
handleGeoUrl(newUrl)
return .cancel
} else {
return .allow
}
}

override func getImagesDownloadMode() -> OADownloadMode! {
OsmAndApp.swiftInstance().data.travelGuidesImagesDownloadMode
Expand Down