diff --git a/App/Browser View/BrowserViewController.swift b/App/Browser View/BrowserViewController.swift index cc33d2b..120f697 100644 --- a/App/Browser View/BrowserViewController.swift +++ b/App/Browser View/BrowserViewController.swift @@ -9,8 +9,7 @@ import Combine import UIKit import UniformTypeIdentifiers -class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegate, - UITextFieldDelegate, ScriptPolicyViewControllerDelegate, +class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegate, ScriptPolicyViewControllerDelegate, UIPopoverPresentationControllerDelegate, TabDelegate, TabPickerViewControllerDelegate, AutocompleteViewControllerDelegate, ShortcutResponder { @@ -595,56 +594,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat completionHandler(menuConfig) } - - // MARK: UITextField Delegate - - func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - if let text = textField.text { - let matches = BrowserHistory.shared.visitedToplevelHistoryItems(matching: text) - autocompleteViewController.historyItems = matches - - autocompleteViewController.view.isHidden = matches.count == 0 - } - return true - } - - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - if let text = textField.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) { - - // Dumb rules for stuff that "looks like" a URL - if !text.contains(" "), - text.components(separatedBy: ".").count > 1, - var url = URL(string: text) - { - if url.scheme == nil { - let urlString = "http://\(text)" - if let fixedURL = URL(string: urlString) { - url = fixedURL - } - } - - tab.beginLoadingURL(url) - } else { - // Assume google search - let queryString = text - .replacingOccurrences(of: " ", with: "+") - .addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! - - let searchURL = URL(string: "https://google.com/search?q=\(queryString)&gbv=1")! // gbv=1: no JS - tab.beginLoadingURL(searchURL) - } - - textField.resignFirstResponder() - } - - return false - } - - func textFieldDidEndEditing(_ textField: UITextField) { - autocompleteViewController.view.isHidden = true - } - // MARK: Tab Delegate func didBlockScriptOrigin(_ origin: String, forTab: Tab) { @@ -750,6 +700,60 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat } } +extension BrowserViewController: UITextFieldDelegate +{ + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { + if let text = textField.text { + let matches = BrowserHistory.shared.visitedToplevelHistoryItems(matching: text) + autocompleteViewController.historyItems = matches + + autocompleteViewController.view.isHidden = matches.count == 0 + } + + return true + } + + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + if let text = textField.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) { + + // Dumb rules for stuff that "looks like" a URL + if !text.contains(" "), + text.components(separatedBy: ".").count > 1, + var url = URL(string: text) + { + if url.scheme == nil { + let urlString = "http://\(text)" + if let fixedURL = URL(string: urlString) { + url = fixedURL + } + } + + tab.beginLoadingURL(url) + } else { + // Assume google search + let queryString = text + .replacingOccurrences(of: " ", with: "+") + .addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! + + let searchURL = URL(string: "https://google.com/search?q=\(queryString)&gbv=1")! // gbv=1: no JS + tab.beginLoadingURL(searchURL) + } + + textField.resignFirstResponder() + } + + return false + } + + override func textFieldShouldEndEditing(_ textField: UITextField) -> Bool { + true + } + + func textFieldDidEndEditing(_ textField: UITextField) { + autocompleteViewController.view.isHidden = true + } +} + extension BrowserViewController: ReaderViewControllerDelegate { func readerViewController(_ reader: ReaderViewController, didRequestNavigationToURL navigationURL: URL) { diff --git a/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json b/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json index 6b96431..65482b0 100644 --- a/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -103,18 +103,10 @@ "size" : "83.5x83.5" }, { + "filename" : "iconios~marketing-1.png", "idiom" : "ios-marketing", "scale" : "1x", "size" : "1024x1024" - }, - { - "filename" : "icon@ios~marketing.png", - "scale" : "1x" - }, - { - "filename" : "iconios~marketing.png", - "scale" : "1x", - "unassigned" : true } ], "info" : { diff --git a/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/icon@ios~marketing.png b/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/iconios~marketing-1.png similarity index 100% rename from App/Supporting Files/Assets.xcassets/AppIcon.appiconset/icon@ios~marketing.png rename to App/Supporting Files/Assets.xcassets/AppIcon.appiconset/iconios~marketing-1.png diff --git a/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/iconios~marketing.png b/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/iconios~marketing.png deleted file mode 100644 index 47f0ed4..0000000 Binary files a/App/Supporting Files/Assets.xcassets/AppIcon.appiconset/iconios~marketing.png and /dev/null differ