Installer // Reenable certain features for macOS 13.

This commit is contained in:
ShikiSuen 2023-05-01 18:44:32 +08:00
parent cd5977e18f
commit 1e19a9e384
2 changed files with 17 additions and 17 deletions

View File

@ -34,6 +34,12 @@ public let kTargetFullBinPartialPath = urlTargetFullBinPartial.path
public let kTranslocationRemovalTickInterval: TimeInterval = 0.5
public let kTranslocationRemovalDeadline: TimeInterval = 60.0
public var isMonterey: Bool {
guard #unavailable(macOS 13) else { return false }
guard #available(macOS 12, *) else { return false }
return true
}
@NSApplicationMain
@objc(AppDelegate)
class AppDelegate: NSWindowController, NSApplicationDelegate {

View File

@ -156,28 +156,22 @@ extension AppDelegate {
}
}
var isMacOS12OrAbove = false
if #available(macOS 12.0, *) {
NSLog("macOS 12 or later detected.")
isMacOS12OrAbove = true
} else {
NSLog("Installer runs with the pre-macOS 12 flow.")
}
// Unconditionally enable the IME on macOS 12.0+,
// as the kTISPropertyInputSourceIsEnabled can still be true even if the IME is *not*
// enabled in the user's current set of IMEs (which means the IME does not show up in
// the user's input menu).
var mainInputSourceEnabled = false
allRegisteredInstancesOfThisInputMethod.forEach {
if $0.activate() {
allRegisteredInstancesOfThisInputMethod.forEach { neta in
let isActivated = neta.isActivated
defer {
// 使
// 使使使
mainInputSourceEnabled = mainInputSourceEnabled || isActivated
}
if isActivated, !isMonterey { return }
// WARNING: macOS 12 may return false positives, hence forced activation.
if neta.activate() {
NSLog("Input method enabled: \(imeIdentifier)")
} else {
NSLog("Failed to enable input method: \(imeIdentifier)")
}
mainInputSourceEnabled = $0.isActivated
}
// Alert Panel
@ -190,7 +184,7 @@ extension AppDelegate {
)
ntfPostInstall.addButton(withTitle: NSLocalizedString("OK", comment: ""))
} else {
if !mainInputSourceEnabled, !isMacOS12OrAbove {
if !mainInputSourceEnabled, !isMonterey {
ntfPostInstall.messageText = NSLocalizedString("Warning", comment: "")
ntfPostInstall.informativeText = NSLocalizedString(
"Input method may not be fully enabled. Please enable it through System Preferences > Keyboard > Input Sources.",