Skip to content

Commit

Permalink
fix(ios): check for existence of UserDefault setting before read
Browse files Browse the repository at this point in the history
  • Loading branch information
sgschantz committed Nov 15, 2024
1 parent b620e17 commit a8949ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ extension KeymanWebViewController {
var defaultHeight = KeyboardScaleMap.getDeviceDefaultKeyboardScale(forPortrait: isPortrait)?.keyboardHeight ?? 216 // default for ancient devices

if (isPortrait) {
if let portraitHeight = Storage.active.userDefaults.portraitKeyboardHeight as Double? {
keyboardHeight = portraitHeight
if (Storage.active.userDefaults.object(forKey: Key.portraitKeyboardHeight) != nil) {
let portraitHeight = Storage.active.userDefaults.portraitKeyboardHeight
let message = "constraintTargetHeight, from UserDefaults loaded portrait value \(portraitHeight)"
os_log("%{public}s", log:KeymanEngineLogger.migration, type: .info, message)
} else {
Expand All @@ -720,8 +720,8 @@ extension KeymanWebViewController {
keyboardHeight = defaultHeight
}
} else {
if let landscapeHeight = Storage.active.userDefaults.landscapeKeyboardHeight as Double? {
keyboardHeight = landscapeHeight
if (Storage.active.userDefaults.object(forKey: Key.portraitKeyboardHeight) != nil) {
let landscapeHeight = Storage.active.userDefaults.landscapeKeyboardHeight
let message = "constraintTargetHeight, from UserDefaults loaded landscape value \(landscapeHeight)"
os_log("%{public}s", log:KeymanEngineLogger.migration, type: .info, message)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ class KeyboardHeightViewController: UIViewController {

private func applyKeyboardHeight() {
if (self.isPortrait) {
if let portraitHeight = Storage.active.userDefaults.portraitKeyboardHeight as Double? {
self.keyboardHeight = portraitHeight
let message = "applyKeyboardHeight, from UserDefaults loaded portrait value \(portraitHeight)"
if (Storage.active.userDefaults.object(forKey: Key.portraitKeyboardHeight) != nil) {
self.keyboardHeight = Storage.active.userDefaults.portraitKeyboardHeight
let message = "applyKeyboardHeight, from UserDefaults loaded portrait value \(self.keyboardHeight)"
os_log("%{public}s", log:KeymanEngineLogger.migration, type: .info, message)
} else {
self.keyboardHeight = self.defaultPortraitHeight
let message = "applyKeyboardHeight, portraitHeight not found in UserDefaults, using default value \(self.keyboardHeight)"
os_log("%{public}s", log:KeymanEngineLogger.migration, type: .info, message)
}
} else {
if let landscapeHeight = Storage.active.userDefaults.landscapeKeyboardHeight as Double? {
self.keyboardHeight = landscapeHeight
let message = "applyKeyboardHeight, from UserDefaults loaded landscape value \(landscapeHeight)"
if (Storage.active.userDefaults.object(forKey: Key.portraitKeyboardHeight) != nil) {
self.keyboardHeight = Storage.active.userDefaults.landscapeKeyboardHeight
let message = "applyKeyboardHeight, from UserDefaults loaded landscape value \(self.keyboardHeight)"
os_log("%{public}s", log:KeymanEngineLogger.migration, type: .info, message)
} else {
self.keyboardHeight = self.defaultLandscapeHeight
Expand Down

0 comments on commit a8949ef

Please sign in to comment.