mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-06 17:05:34 +00:00
fixed unused call warnings by using '_ =' or changing method signature to throw instead of return a bool
This commit is contained in:
parent
fa77f04b26
commit
30d7ffabc7
8 changed files with 23 additions and 21 deletions
|
|
@ -325,7 +325,7 @@ class KeyboardMenuView: UIView, UITableViewDelegate, UITableViewDataSource, UIGe
|
|||
guard let kb = tableList[index] as? InstallableKeyboard else {
|
||||
return
|
||||
}
|
||||
if Manager.shared.setKeyboard(kb) {
|
||||
if let _ = try? Manager.shared.setKeyboard(kb) {
|
||||
tableView?.reloadData()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class KeyboardInfoViewController: UITableViewController, UIAlertViewDelegate {
|
|||
if indexPath.row == 1 {
|
||||
let url = URL(string: "http://help.keyman.com/keyboard/\(keyboardID)/\(keyboardVersion)/")!
|
||||
if let openURL = Manager.shared.openURL {
|
||||
openURL(url)
|
||||
_ = openURL(url)
|
||||
} else {
|
||||
log.error("openURL not set in Manager. Failed to open \(url)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
// Add keyboard.
|
||||
for keyboard in keyboards {
|
||||
Manager.shared.addKeyboard(keyboard)
|
||||
Manager.shared.setKeyboard(keyboard)
|
||||
try? Manager.shared.setKeyboard(keyboard)
|
||||
}
|
||||
|
||||
navigationController?.popToRootViewController(animated: true)
|
||||
|
|
@ -263,7 +263,7 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
|
||||
private func switchKeyboard(_ index: Int) {
|
||||
// Switch keyboard and register to user defaults.
|
||||
if Manager.shared.setKeyboard(userKeyboards[index]) {
|
||||
if let _ = try? Manager.shared.setKeyboard(userKeyboards[index]) {
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,20 +191,23 @@ public class Manager: NSObject, HTTPDownloadDelegate, UIGestureRecognizerDelegat
|
|||
/// - SeeAlso:
|
||||
/// - addKeyboard()
|
||||
/// - Returns: Whether the keyboard was set successfully
|
||||
//TODO: this method appears unused, should we remove it?
|
||||
public func setKeyboard(withFullID fullID: FullKeyboardID) -> Bool {
|
||||
if let keyboard = Storage.active.userDefaults.userKeyboard(withFullID: fullID) {
|
||||
return setKeyboard(keyboard)
|
||||
if let keyboard = Storage.active.userDefaults.userKeyboard(withFullID: fullID),
|
||||
let _ = try? setKeyboard(keyboard) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
/// Set the current keyboard.
|
||||
///
|
||||
/// - Returns: Whether the keyboard was set successfully
|
||||
public func setKeyboard(_ kb: InstallableKeyboard) -> Bool {
|
||||
/// - Throws: error if the keyboard was unchanged
|
||||
public func setKeyboard(_ kb: InstallableKeyboard) throws {
|
||||
if kb.fullID == currentKeyboardID {
|
||||
log.info("Keyboard unchanged: \(kb.fullID)")
|
||||
return false
|
||||
throw KeyboardError.unchanged
|
||||
}
|
||||
|
||||
log.info("Setting language: \(kb.fullID)")
|
||||
|
|
@ -234,7 +237,6 @@ public class Manager: NSObject, HTTPDownloadDelegate, UIGestureRecognizerDelegat
|
|||
NotificationCenter.default.post(name: Notifications.keyboardChanged,
|
||||
object: self,
|
||||
value: kb)
|
||||
return true
|
||||
}
|
||||
|
||||
/// Adds a new keyboard to the list in the keyboard picker if it doesn't already exist.
|
||||
|
|
@ -297,7 +299,7 @@ public class Manager: NSObject, HTTPDownloadDelegate, UIGestureRecognizerDelegat
|
|||
|
||||
// Set a new keyboard if deleting the current one
|
||||
if kb.fullID == currentKeyboardID {
|
||||
setKeyboard(userKeyboards[0])
|
||||
try? setKeyboard(userKeyboards[0])
|
||||
}
|
||||
|
||||
if !userKeyboards.contains(where: { $0.id == kb.id }) {
|
||||
|
|
@ -332,7 +334,7 @@ public class Manager: NSObject, HTTPDownloadDelegate, UIGestureRecognizerDelegat
|
|||
return nil
|
||||
}
|
||||
let newIndex = (index + 1) % userKeyboards.count
|
||||
setKeyboard(userKeyboards[newIndex])
|
||||
try? setKeyboard(userKeyboards[newIndex])
|
||||
return newIndex
|
||||
}
|
||||
|
||||
|
|
@ -995,11 +997,11 @@ public class Manager: NSObject, HTTPDownloadDelegate, UIGestureRecognizerDelegat
|
|||
currentKeyboardID = nil
|
||||
|
||||
if let keyboard = keyboard {
|
||||
setKeyboard(keyboard)
|
||||
try? setKeyboard(keyboard)
|
||||
} else if let keyboard = Storage.active.userDefaults.userKeyboards?[safe: 0] {
|
||||
setKeyboard(keyboard)
|
||||
try? setKeyboard(keyboard)
|
||||
} else {
|
||||
setKeyboard(Defaults.keyboard)
|
||||
try? setKeyboard(Defaults.keyboard)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1145,7 +1147,7 @@ public class Manager: NSObject, HTTPDownloadDelegate, UIGestureRecognizerDelegat
|
|||
} else if let userKbs = Storage.active.userDefaults.userKeyboards, !userKbs.isEmpty {
|
||||
newKb = userKbs[0]
|
||||
}
|
||||
setKeyboard(newKb)
|
||||
try? setKeyboard(newKb)
|
||||
}
|
||||
|
||||
NotificationCenter.default.post(name: Notifications.keyboardLoaded, object: self, value: newKb)
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ extension TextField: KeymanWebDelegate {
|
|||
if let viewController = viewController {
|
||||
Manager.shared.showKeyboardPicker(in: viewController, shouldAddKeyboard: false)
|
||||
} else {
|
||||
Manager.shared.switchToNextKeyboard()
|
||||
_ = Manager.shared.switchToNextKeyboard()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ extension TextView: KeymanWebDelegate {
|
|||
if let viewController = viewController {
|
||||
Manager.shared.showKeyboardPicker(in: viewController, shouldAddKeyboard: false)
|
||||
} else {
|
||||
Manager.shared.switchToNextKeyboard()
|
||||
_ = Manager.shared.switchToNextKeyboard()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
} catch {
|
||||
self.showKMPError(error as! KMPError)
|
||||
}
|
||||
|
||||
|
||||
//this can fail gracefully and not show errors to users
|
||||
do {
|
||||
try FileManager.default.removeItem(at: adhocDir)
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg
|
|||
|
||||
for keyboard in keyboards {
|
||||
Manager.shared.addKeyboard(keyboard)
|
||||
Manager.shared.setKeyboard(keyboard)
|
||||
try? Manager.shared.setKeyboard(keyboard)
|
||||
}
|
||||
|
||||
launchUrl = nil
|
||||
|
|
@ -879,7 +879,7 @@ class MainViewController: UIViewController, TextViewDelegate, UIActionSheetDeleg
|
|||
cancelButtonTitle: "Cancel", otherButtonTitles: "Install", tag: 0)
|
||||
} else {
|
||||
Manager.shared.addKeyboard(keyboard)
|
||||
Manager.shared.setKeyboard(keyboard)
|
||||
try? Manager.shared.setKeyboard(keyboard)
|
||||
}
|
||||
} else {
|
||||
launchUrl = nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue