mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-07 17:36:00 +00:00
Handle deleting current keyboard in Manager
This commit is contained in:
parent
5b8591c2e1
commit
75fd393735
3 changed files with 5 additions and 17 deletions
|
|
@ -118,11 +118,6 @@ class KeyboardInfoViewController: UITableViewController, UIAlertViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private var isCurrentKeyboard: Bool {
|
||||
return Manager.shared.keyboardID == keyboardID &&
|
||||
Manager.shared.languageID == languageID
|
||||
}
|
||||
|
||||
private var canDeleteKeyboard: Bool {
|
||||
if !Manager.shared.canRemoveKeyboards {
|
||||
return false
|
||||
|
|
@ -156,14 +151,8 @@ class KeyboardInfoViewController: UITableViewController, UIAlertViewDelegate {
|
|||
if alertView.tag == 1 {
|
||||
let userData = Manager.shared.activeUserDefaults()
|
||||
let userKeyboards = userData.userKeyboards!
|
||||
let kb = userKeyboards[keyboardIndex]
|
||||
|
||||
if Manager.shared.removeKeyboard(at: keyboardIndex) {
|
||||
if isCurrentKeyboard {
|
||||
// Select default keyboard
|
||||
Manager.shared.setKeyboard(kb)
|
||||
}
|
||||
NotificationCenter.default.post(name: Notifications.keyboardRemoved, object: self, value: kb)
|
||||
navigationController?.popToRootViewController(animated: true)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,12 +128,6 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
}
|
||||
|
||||
if Manager.shared.removeKeyboard(at: indexPath.row) {
|
||||
let kb = userKeyboards[indexPath.row]
|
||||
if isCurrentKeyboard(languageID: kb.id, keyboardID: kb.languageID) {
|
||||
let userData = Manager.shared.activeUserDefaults()
|
||||
userKeyboards = userData.userKeyboards!
|
||||
Manager.shared.setKeyboard(userKeyboards[0])
|
||||
}
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
setIsDoneButtonEnabled(true)
|
||||
|
|
|
|||
|
|
@ -377,6 +377,11 @@ UIGestureRecognizerDelegate {
|
|||
userData.set([Date()], forKey: Key.synchronizeSWKeyboard)
|
||||
userData.synchronize()
|
||||
|
||||
// Set a new keyboard if deleting the current one
|
||||
if kb.id == keyboardID && kb.languageID == languageID {
|
||||
setKeyboard(userKeyboards[0])
|
||||
}
|
||||
|
||||
NotificationCenter.default.post(name: Notifications.keyboardRemoved, object: self, value: kb)
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue