From 11bb6580809af10f28e1ff8a1b87c82e7b78635e Mon Sep 17 00:00:00 2001 From: dfperry5 Date: Thu, 2 Jan 2020 13:13:06 -0500 Subject: [PATCH] Fix mozilla-mobile#5190 - updating Add Search Engine screen's title box to use the default keyboard (#5927) --- .../Settings/CustomSearchViewController.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Client/Frontend/Settings/CustomSearchViewController.swift b/Client/Frontend/Settings/CustomSearchViewController.swift index 48cd4604323f..e56977e2f308 100644 --- a/Client/Frontend/Settings/CustomSearchViewController.swift +++ b/Client/Frontend/Settings/CustomSearchViewController.swift @@ -137,7 +137,8 @@ class CustomSearchViewController: SettingsTableViewController { }) titleField.textField.accessibilityIdentifier = "customEngineTitle" - let urlField = CustomSearchEngineTextView(placeholder: Strings.SettingsAddCustomEngineURLPlaceholder, height: 133, settingIsValid: { text in + let urlField = CustomSearchEngineTextView(placeholder: Strings.SettingsAddCustomEngineURLPlaceholder, height: 133, + keyboardType: .URL, settingIsValid: { text in //Can check url text text validity here. return true }, settingDidChange: {fieldText in @@ -180,13 +181,15 @@ class CustomSearchEngineTextView: Setting, UITextViewDelegate { let textField = UITextView() let placeholderLabel = UILabel() + var keyboardType: UIKeyboardType = .default - init(defaultValue: String? = nil, placeholder: String, height: CGFloat = 44, settingIsValid isValueValid: ((String?) -> Bool)? = nil, settingDidChange: ((String?) -> Void)? = nil) { + init(defaultValue: String? = nil, placeholder: String, height: CGFloat = 44, keyboardType: UIKeyboardType = .default, settingIsValid isValueValid: ((String?) -> Bool)? = nil, settingDidChange: ((String?) -> Void)? = nil) { self.defaultValue = defaultValue self.TextFieldHeight = height self.settingDidChange = settingDidChange self.settingIsValid = isValueValid self.placeholder = placeholder + self.keyboardType = keyboardType textField.addSubview(placeholderLabel) super.init(cellHeight: TextFieldHeight) } @@ -204,7 +207,10 @@ class CustomSearchEngineTextView: Setting, UITextViewDelegate { textField.font = placeholderLabel.font textField.textContainer.lineFragmentPadding = 0 - textField.keyboardType = .URL + textField.keyboardType = keyboardType + if (keyboardType == .default) { + textField.autocapitalizationType = .words + } textField.autocorrectionType = .no textField.delegate = self textField.backgroundColor = UIColor.theme.tableView.rowBackground