Skip to content

Commit

Permalink
fix(ios): check view changes during device rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
sgschantz committed Dec 2, 2024
1 parent 221ba7b commit 3e54255
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class KeyboardHeightViewController: UIViewController {
}

private func determineOrientation(screenSize: CGSize) {
self.isPortrait = UIScreen.main.bounds.height > UIScreen.main.bounds.width
self.isPortrait = screenSize.height > screenSize.width
let message = "determineOrientation, isPortrait: \(self.isPortrait)"
os_log("%{public}s", log:KeymanEngineLogger.ui, type: .debug, message)
}
Expand All @@ -78,6 +78,8 @@ class KeyboardHeightViewController: UIViewController {
}

private func applyKeyboardHeight() {
let introMessage = "applyKeyboardHeight, with self.isPortrait: \(self.isPortrait)"
os_log("%{public}s", log:KeymanEngineLogger.ui, type: .info, introMessage)
if (self.isPortrait) {
if (Storage.active.userDefaults.object(forKey: Key.portraitKeyboardHeight) != nil) {
self.keyboardHeight = Storage.active.userDefaults.portraitKeyboardHeight
Expand Down Expand Up @@ -255,8 +257,8 @@ class KeyboardHeightViewController: UIViewController {
self.keyboardConstraintsArray = [
keyboardImage.leftAnchor.constraint(equalTo: contentView.leftAnchor),
keyboardImage.rightAnchor.constraint(equalTo: contentView.rightAnchor),
keyboardImage.topAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -keyboardHeight),
keyboardImage.heightAnchor.constraint(equalToConstant: keyboardHeight)
keyboardImage.topAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -self.keyboardHeight),
keyboardImage.heightAnchor.constraint(equalToConstant: self.keyboardHeight)
]
NSLayoutConstraint.activate(self.keyboardConstraintsArray)

Expand Down Expand Up @@ -398,9 +400,9 @@ class KeyboardHeightViewController: UIViewController {
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
let rotateMessage = "viewWillTransition called"
let rotateMessage = "viewWillTransition to size \(size) with current UIScreen.main.bounds.size size = \(UIScreen.main.bounds.size)"
os_log("%{public}s", log:KeymanEngineLogger.ui, type: .info, rotateMessage)
super.viewWillTransition(to: size, with: coordinator)

/**
using the specified size, determine which orientation the device is moving to and adjust content as necessary
Expand Down
4 changes: 2 additions & 2 deletions ios/engine/KMEI/KeymanEngine/Classes/Manager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ public class Manager: NSObject, UIGestureRecognizerDelegate {
func keyboardHeightChanged() {
let message = "keyboardHeightChanged)"
os_log("%{public}s", log:KeymanEngineLogger.settings, type: .default, message)
currentResponder?.dismissKeyboard()
self.inputViewController.resetKeyboardState()
//currentResponder?.dismissKeyboard()
//self.inputViewController.resetKeyboardState()
}

var vibrationSupportLevel: VibrationSupport {
Expand Down
4 changes: 2 additions & 2 deletions ios/engine/KMEI/KeymanEngine/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@
"keyboard-drag-instructions" = "Drag arrow control to adjust keyboard height.";

/* Instruction to rotate to adjust landscape keyboard height (displayed when device is portrait) */
"portrait-keyboard-rotate-instructions" = "Rotate device to adjust for portrait.";
"portrait-keyboard-rotate-instructions" = "Rotate device to adjust for landscape.";

/* Instruction to rotate to adjust portrait keyboard height (displayed when device is landscape) */
"landscape-keyboard-rotate-instructions" = "Rotate device to adjust for landscape.";
"landscape-keyboard-rotate-instructions" = "Rotate device to adjust for portrait.";

/* Short text for notification: download failure for keyboard */
"notification-download-failure-keyboard" = "Keyboard download failed";
Expand Down

0 comments on commit 3e54255

Please sign in to comment.