Skip to content

Commit

Permalink
Merge branch 'develop' into develop_iOS16_2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ensan-hcl authored Nov 13, 2023
2 parents 1566e89 + 46686c2 commit 7046e17
Show file tree
Hide file tree
Showing 95 changed files with 588 additions and 1,751 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KeyboardExtensionUtils"
BuildableName = "KeyboardExtensionUtils"
BlueprintName = "KeyboardExtensionUtils"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KeyboardExtensionUtilsTests"
BuildableName = "KeyboardExtensionUtilsTests"
BlueprintName = "KeyboardExtensionUtilsTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "KeyboardExtensionUtils"
BuildableName = "KeyboardExtensionUtils"
BlueprintName = "KeyboardExtensionUtils"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
21 changes: 20 additions & 1 deletion AzooKeyCore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let swiftSettings: [SwiftSetting] = [
]
let package = Package(
name: "AzooKeyCore",
platforms: [.iOS(.v15), .macOS(.v12)],
platforms: [.iOS(.v16), .macOS(.v13)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand All @@ -34,6 +34,10 @@ let package = Package(
.library(
name: "AzooKeyUtils",
targets: ["AzooKeyUtils"]
),
.library(
name: "KeyboardExtensionUtils",
targets: ["KeyboardExtensionUtils"]
)
],
dependencies: [
Expand Down Expand Up @@ -67,6 +71,7 @@ let package = Package(
name: "KeyboardViews",
dependencies: [
"KeyboardThemes",
"KeyboardExtensionUtils",
.product(name: "KanaKanjiConverterModule", package: "AzooKeyKanaKanjiConverter")
],
resources: [],
Expand All @@ -80,6 +85,20 @@ let package = Package(
],
resources: [],
swiftSettings: swiftSettings
),
.target(
name: "KeyboardExtensionUtils",
dependencies: [
.product(name: "KanaKanjiConverterModule", package: "AzooKeyKanaKanjiConverter")
],
resources: [],
swiftSettings: swiftSettings
),
.testTarget(
name: "KeyboardExtensionUtilsTests",
dependencies: [
"KeyboardExtensionUtils"
]
)
]
)
31 changes: 3 additions & 28 deletions AzooKeyCore/Sources/AzooKeyUtils/AzooKeyMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import KeyboardViews

public enum MessageIdentifier: String, CaseIterable, MessageIdentifierProtocol {
case mock = "mock_alert_2022_09_16_03"
case iOS15_4_new_emoji = "iOS_15_4_new_emoji" // MARK: frozen
case iOS16_4_new_emoji = "iOS_16_4_new_emoji_commit" // MARK: frozen
case ver1_9_user_dictionary_update = "ver1_9_user_dictionary_update_release" // MARK: frozen
case ver2_1_emoji_tab = "ver2_1_emoji_tab"

// MARK: 過去にプロダクションで用いていたメッセージID
// ver1_9_user_dictionary_updateが実行されれば不要になるので、この宣言は削除
// case ver1_5_update_loudstxt = "ver1_5_update_loudstxt" // MARK: frozen
// iOS15_4_new_emojiが実行されれば不要になるので、この宣言は削除
// iOS16_4_new_emojiが実行されれば不要になるので、これらの宣言は削除
// case iOS14_5_new_emoji = "iOS_14_5_new_emoji_fixed_ver_1_6_1" // MARK: frozen
// case iOS15_4_new_emoji = "iOS_15_4_new_emoji" // MARK: frozen
// 新機能の紹介も削除
// case liveconversion_introduction = "liveconversion_introduction" // MARK: frozen
// case ver1_8_autocomplete_introduction = "ver1_8_autocomplete_introduction" // MARK: frozen
Expand All @@ -33,7 +33,7 @@ public enum MessageIdentifier: String, CaseIterable, MessageIdentifierProtocol {
switch self {
case .ver1_9_user_dictionary_update, .ver2_1_emoji_tab:
return true
case .iOS15_4_new_emoji, .iOS16_4_new_emoji, .mock:
case .iOS16_4_new_emoji, .mock:
return false
}
}
Expand All @@ -50,31 +50,6 @@ public enum AzooKeyMessageProvider: ApplicationSpecificKeyboardViewMessageProvid

public static var messages: [MessageData<MessageIdentifier>] {
[
MessageData(
id: .iOS15_4_new_emoji,
title: "お知らせ",
description: "iOS15.4で新しい絵文字が追加されました。本体アプリを開き、データを更新しますか?",
button: .two(primary: .openContainer(text: "更新"), secondary: .later),
precondition: {
if #available(iOS 15.4, *) {
return true
} else {
return false
}
},
silentDoneCondition: {
// ダウンロードがv1.8以降の場合はDone
if (SharedStore.initialAppVersion ?? .azooKey_v1_7_1) >= .azooKey_v1_8 {
return true
}
// .iOS16_4の方が終わっていたらDone
if MessageManager<MessageID>.checkDone(.iOS16_4_new_emoji, userDefaults: userDefaults) {
return true
}
return false
},
containerAppShouldMakeItDone: { false }
),
MessageData(
id: .iOS16_4_new_emoji,
title: "お知らせ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,27 @@
// Copyright © 2022 ensan. All rights reserved.
//

import AzooKeyUtils
import KanaKanjiConverterModule
import KeyboardViews
import SwiftUtils
import UIKit

/// UI側の入力中のテキストの更新を受け持つクラス
@MainActor final class DisplayedTextManager {
init() {
@KeyboardSetting(.liveConversion) var enabled
self.isLiveConversionEnabled = enabled

@KeyboardSetting(.markedTextSetting) var markedTextEnabled
self.isMarkedTextEnabled = markedTextEnabled != .disabled
@MainActor final public class DisplayedTextManager {
public init(isLiveConversionEnabled: Bool, isMarkedTextEnabled: Bool) {
self.isLiveConversionEnabled = isLiveConversionEnabled
self.isMarkedTextEnabled = isMarkedTextEnabled
}
/// `convertTarget`に対応する文字列
private(set) var composingText: ComposingText = .init()
private(set) public var composingText: ComposingText = .init()
/// ライブ変換の有効化状態
private(set) var isLiveConversionEnabled: Bool
private(set) public var isLiveConversionEnabled: Bool
/// ライブ変換結果として表示されるべきテキスト
private(set) var displayedLiveConversionText: String?
private(set) public var displayedLiveConversionText: String?
/// テキストを変更するたびに増やす値
private var textChangedCount = 0

/// `textChangedCount`のgetter。
func getTextChangedCount() -> Int {
public func getTextChangedCount() -> Int {
self.textChangedCount
}

Expand All @@ -50,7 +45,7 @@ import UIKit
/// キーボード内テキストフィールドの`UITextDocumentProxy`
private var ikTextFieldProxy: (id: UUID, proxy: (any UITextDocumentProxy))?

func setTextDocumentProxy(_ proxy: AnyTextDocumentProxy) {
public func setTextDocumentProxy(_ proxy: AnyTextDocumentProxy) {
switch proxy {
case let .mainProxy(proxy):
self.displayedTextProxy = proxy
Expand All @@ -66,28 +61,29 @@ import UIKit
}
}

var documentContextAfterInput: String? {
public var documentContextAfterInput: String? {
self.proxy?.documentContextAfterInput
}

var selectedText: String? {
public var selectedText: String? {
self.proxy?.selectedText
}

var documentContextBeforeInput: String? {
public var documentContextBeforeInput: String? {
self.proxy?.documentContextBeforeInput
}

var shouldSkipMarkedTextChange: Bool {
public var shouldSkipMarkedTextChange: Bool {
self.isMarkedTextEnabled && preferredTextProxy == .ikTextField && ikTextFieldProxy != nil
}

func closeKeyboard() {
public func closeKeyboard() {
self.ikTextFieldProxy = nil
}

/// 入力を停止する
@MainActor func stopComposition() {
/// - note: この関数を呼んだ後に`updateSettings`を呼ぶと良い
@MainActor public func stopComposition() {
debug("DisplayedTextManager.stopComposition")
if self.isMarkedTextEnabled {
self.proxy?.unmarkText()
Expand All @@ -96,15 +92,12 @@ import UIKit
}
self.composingText = .init()
self.displayedLiveConversionText = nil
self.reloadSetting()
}

/// 設定を更新する
@MainActor private func reloadSetting() {
@KeyboardSetting(.liveConversion) var enabled
self.isLiveConversionEnabled = enabled
@KeyboardSetting(.markedTextSetting) var markedTextEnabled
self.isMarkedTextEnabled = markedTextEnabled != .disabled
@MainActor public func updateSettings(isLiveConversionEnabled: Bool, isMarkedTextEnabled: Bool) {
self.isLiveConversionEnabled = isLiveConversionEnabled
self.isMarkedTextEnabled = isMarkedTextEnabled
}

/// カーソルを何カウント分動かせばいいか計算する
Expand Down Expand Up @@ -140,7 +133,7 @@ import UIKit
self.proxy?.setMarkedText(text, selectedRange: NSRange(location: cursorPosition, length: 0))
}

func insertText(_ text: String) {
public func insertText(_ text: String) {
guard !text.isEmpty else {
return
}
Expand All @@ -149,15 +142,15 @@ import UIKit
}

/// In-Keyboard TextFiledが用いられていても、そちらではない方に強制的に入力を行う関数
func insertMainDisplayText(_ text: String) {
public func insertMainDisplayText(_ text: String) {
guard !text.isEmpty else {
return
}
self.displayedTextProxy?.insertText(text)
self.textChangedCount += 1
}

func moveCursor(count: Int) {
public func moveCursor(count: Int) {
guard count != 0 else {
return
}
Expand All @@ -179,7 +172,7 @@ import UIKit

// isComposingの場合、countはadjust済みであることを期待する
// されていなかった場合は例外を投げる
func deleteBackward(count: Int) {
public func deleteBackward(count: Int) {
if count == 0 {
return
}
Expand Down Expand Up @@ -212,7 +205,7 @@ import UIKit

// isComposingの場合、countはadjust済みであることを期待する
// されていなかった場合は例外を投げる
func deleteForward(count: Int = 1) {
public func deleteForward(count: Int = 1) {
if count == 0 {
return
}
Expand All @@ -224,7 +217,7 @@ import UIKit
}

/// `composingText`を更新する
func updateComposingText(composingText: ComposingText, newLiveConversionText: String?) {
public func updateComposingText(composingText: ComposingText, newLiveConversionText: String?) {
if isMarkedTextEnabled {
self.composingText = composingText
self.displayedLiveConversionText = newLiveConversionText
Expand All @@ -251,7 +244,7 @@ import UIKit
}
}

func updateComposingText(composingText: ComposingText, userMovedCount: Int, adjustedMovedCount: Int) -> Bool {
public func updateComposingText(composingText: ComposingText, userMovedCount: Int, adjustedMovedCount: Int) -> Bool {
let delta = adjustedMovedCount - userMovedCount
self.composingText = composingText
if delta != 0 {
Expand All @@ -262,7 +255,7 @@ import UIKit
return false
}

func updateComposingText(composingText: ComposingText, completedPrefix: String, isSelected: Bool) {
public func updateComposingText(composingText: ComposingText, completedPrefix: String, isSelected: Bool) {
if isMarkedTextEnabled {
self.insertText(completedPrefix)
self.composingText = composingText
Expand Down
1 change: 1 addition & 0 deletions AzooKeyCore/Sources/KeyboardViews/UserActionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import SwiftUI
import KeyboardExtensionUtils

/// キーボードの操作を管理するためのクラス
/// - finalにはできない
Expand Down
Loading

0 comments on commit 7046e17

Please sign in to comment.