Skip to content

Commit

Permalink
Merge pull request #355 from ensan-hcl/develop
Browse files Browse the repository at this point in the history
[Release] Version 2.2
  • Loading branch information
ensan-hcl authored Nov 2, 2023
2 parents 6f64dec + cf2909e commit 8d7c8a1
Show file tree
Hide file tree
Showing 164 changed files with 13,492 additions and 2,241 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
runs-on: macos-latest

steps:
- uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf
- uses: swift-actions/setup-swift@150267bf6ba01f9d942a4bd55aa2f35ba586767d
with:
swift-version: "5.8"
swift-version: "5.9"
- uses: actions/checkout@v3
- name: Build
# TODO: add KeyboardViews
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
13 changes: 9 additions & 4 deletions AzooKeyCore/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -10,11 +10,13 @@ let swiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ImplicitOpenExistentials"),
.enableUpcomingFeature("StrictConcurrency"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableUpcomingFeature("ImportObjcForwardDeclarations"),
.unsafeFlags(["-strict-concurrency=complete"])
]
let package = Package(
name: "AzooKeyCore",
platforms: [.iOS(.v14), .macOS(.v11)],
platforms: [.iOS(.v15), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand All @@ -36,8 +38,11 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/ensan-hcl/AzooKeyKanaKanjiConverter", branch: "develop")
// MARK: You must specify version which results reproductive and stable result
// MARK: `_: .upToNextMinor(Version)` or `exact: Version` or `revision: Version`.
// MARK: For develop branch, you can use `revision:` specification.
// MARK: For main branch, you must use `upToNextMinor` specification.
.package(url: "https://github.com/ensan-hcl/AzooKeyKanaKanjiConverter", .upToNextMinor(from: "0.4.0"))
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ public enum AzooKeyKeyboardViewExtension: ApplicationSpecificKeyboardViewExtensi
HideResetButtonInOneHandedMode.value
}

public static var useBetaMoveCursorBar: Bool {
UseBetaMoveCursorBar.value
public static var useReflectStyleCursorBar: Bool {
UseReflectStyleCursorBar.value
}

public static var useShiftKey: Bool {
UseShiftKey.value
}

public static var displayCursorBarAutomatically: Bool {
DisplayCursorBarAutomatically.value
}

public static var canResetLearningForCandidate: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public extension AzooKeyTheme {
normalKeyFillColor: .color(Color(.displayP3, white: 1, opacity: 1)),
specialKeyFillColor: .color(Color(.displayP3, red: 0.804, green: 0.808, blue: 0.835)),
pushedKeyFillColor: .color(Color(.displayP3, red: 0.929, green: 0.929, blue: 0.945)),
suggestKeyFillColor: nil
suggestKeyFillColor: nil,
suggestLabelTextColor: .color(Color(.displayP3, white: 0, opacity: 1)),
keyShadow: nil
)
}

Expand All @@ -73,7 +75,9 @@ extension AzooKeySpecificTheme: ApplicationSpecificKeyboardViewExtensionLayoutDe
normalKeyFillColor: .system(layout == .qwerty ? .qwertyNormalKeyColor : .normalKeyColor),
specialKeyFillColor: .system(.specialKeyColor),
pushedKeyFillColor: .system(layout == .qwerty ? .qwertyHighlightedKeyColor : .highlightedKeyColor),
suggestKeyFillColor: nil
suggestKeyFillColor: nil,
suggestLabelTextColor: nil,
keyShadow: nil
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import SwiftUI

public struct AutomaticCompletionStrengthKey: KeyboardSettingKey, StoredInUserDefault {
public enum Value: Int {
public enum Value: Int, Sendable {
case disabled // 無効化
case weak // 弱い
case normal // 普通
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,38 @@ public extension KeyboardSettingKey where Self == DisplayTabBarButton {
static var displayTabBarButton: Self { .init() }
}

public struct UseBetaMoveCursorBar: BoolKeyboardSettingKey {
public static let title: LocalizedStringKey = "新しいカーソルバーを使う (試験版)"
public static let explanation: LocalizedStringKey = "新しいカーソルバーを有効化します。\n試験的機能のため、予告なく提供を終了する可能性があります"
public struct UseReflectStyleCursorBar: BoolKeyboardSettingKey {
public static let title: LocalizedStringKey = "新しいカーソルバーを使う"
public static let explanation: LocalizedStringKey = "操作性が向上した新しいカーソルバーを有効化します"
public static let defaultValue = false
// MARK: This setting is originally introduced as 'beta cursor bar'
public static let key: String = "use_move_cursor_bar_beta"
}

public extension KeyboardSettingKey where Self == UseBetaMoveCursorBar {
static var useBetaMoveCursorBar: Self { .init() }
public extension KeyboardSettingKey where Self == UseReflectStyleCursorBar {
static var useReflectStyleCursorBar: Self { .init() }
}

public struct DisplayCursorBarAutomatically: BoolKeyboardSettingKey {
public static let title: LocalizedStringKey = "カーソルバーを自動表示"
public static let explanation: LocalizedStringKey = "カーソル移動の際にカーソルバーを自動表示します"
public static let defaultValue = false
public static let key: String = "display_cursor_bar_automatically"
}

public extension KeyboardSettingKey where Self == DisplayCursorBarAutomatically {
static var displayCursorBarAutomatically: Self { .init() }
}

public struct UseShiftKey: BoolKeyboardSettingKey {
public static let title: LocalizedStringKey = "シフトキーを使う"
public static let explanation: LocalizedStringKey = "QwertyキーボードでAaキーの代わりにシフトキーを利用します。"
public static let defaultValue = false
public static let key: String = "use_shift_key"
}

public extension KeyboardSettingKey where Self == UseShiftKey {
static var useShiftKey: Self { .init() }
}

public struct HideResetButtonInOneHandedMode: BoolKeyboardSettingKey {
Expand Down Expand Up @@ -215,6 +238,20 @@ public extension KeyboardSettingKey where Self == EnablePasteButton {
static var enablePasteButton: Self { .init() }
}

/// 「連絡先」アプリの名前情報を読み込む設定
/// - note: この機能はフルアクセスがないと実現できない
public struct EnableContactImport: BoolKeyboardSettingKey {
public static let title: LocalizedStringKey = "変換に連絡先データを利用"
public static let explanation: LocalizedStringKey = "「連絡先」アプリに登録された氏名のデータを変換に利用します"
public static let defaultValue = false
public static let key: String = "enable_contact_import"
public static let requireFullAccess: Bool = true
}

public extension KeyboardSettingKey where Self == EnableContactImport {
static var enableContactImport: Self { .init() }
}

/// クリップボード履歴マネージャを有効化する設定
/// - note: この機能はフルアクセスがないと実現できない
public struct EnableClipboardHistoryManagerTab: BoolKeyboardSettingKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,25 @@ public struct KeyboardSetting<T: KeyboardSettingKey> {

/// 生の`SettingKey`の値を`@State`で宣言した場合、更新の反映ができない。
/// `SettingUpdater`で包むことで、設定の更新を行いつつUIの更新も行われるようにできる。
public struct SettingUpdater<Wrapped: KeyboardSettingKey> {
@MainActor public struct SettingUpdater<Wrapped: KeyboardSettingKey> {
public var value: Wrapped.Value {
didSet {
let newValue = value
Task.detached { @MainActor in
Wrapped.value = newValue
}
Wrapped.value = newValue
}
}

@MainActor public init() {
public init() {
self.value = Wrapped.value
}

@MainActor public mutating func reload() {
public mutating func reload() {
self.value = Wrapped.value
}
}

public protocol KeyboardSettingKey {
associatedtype Value
associatedtype Value: Sendable
static var defaultValue: Value { get }
static var title: LocalizedStringKey { get }
static var explanation: LocalizedStringKey { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct MarkedTextSettingKey: KeyboardSettingKey {
}
}

public enum Value: String {
public enum Value: String, Sendable {
case disabled
case enabled
case auto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct NumberTabCustomKeysSetting: QwertyCustomKeyKeyboardSetting {
public static let defaultValue: QwertyCustomKeysValue = .defaultValue
public static let title: LocalizedStringKey = "数字タブのカスタムキー機能"
public static let explanation: LocalizedStringKey = "数字タブの「、。!?…」部分に好きな記号や文字を割り当てて利用することができます。"
private static var key = "roman_number_custom_keys"
private static let key = "roman_number_custom_keys"
@MainActor public static var value: QwertyCustomKeysValue {
get {
if let value = SharedStore.userDefaults.value(forKey: key), let keys = QwertyCustomKeysValue.get(value) {
Expand Down
2 changes: 1 addition & 1 deletion AzooKeyCore/Sources/KeyboardThemes/ThemeColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Foundation
@preconcurrency import SwiftUI
import SwiftUI

public enum ThemeColor<SystemColor: ApplicationSpecificColor>: Sendable {
case color(Color)
Expand Down
25 changes: 24 additions & 1 deletion AzooKeyCore/Sources/KeyboardThemes/ThemeData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public struct ThemeData<ApplicationExtension: ApplicationSpecificTheme>: Codable
public var specialKeyFillColor: ColorData
public var pushedKeyFillColor: ColorData // 自動で設定する
public var suggestKeyFillColor: ColorData? // 自動で設定する
public var suggestLabelTextColor: ColorData? // 設定は露出させない
public var keyShadow: ThemeShadowData<ColorData>? // 設定は露出させない

public init(id: Int? = nil, backgroundColor: ColorData, picture: ThemePicture, textColor: ColorData, textFont: ThemeFontWeight, resultTextColor: ColorData, resultBackgroundColor: ColorData, borderColor: ColorData, borderWidth: Double, normalKeyFillColor: ColorData, specialKeyFillColor: ColorData, pushedKeyFillColor: ColorData, suggestKeyFillColor: ColorData? = nil) {
public init(id: Int? = nil, backgroundColor: ColorData, picture: ThemePicture, textColor: ColorData, textFont: ThemeFontWeight, resultTextColor: ColorData, resultBackgroundColor: ColorData, borderColor: ColorData, borderWidth: Double, normalKeyFillColor: ColorData, specialKeyFillColor: ColorData, pushedKeyFillColor: ColorData, suggestKeyFillColor: ColorData? = nil, suggestLabelTextColor: ColorData? = nil, keyShadow: ThemeShadowData<ColorData>? = nil) {
self.id = id
self.backgroundColor = backgroundColor
self.picture = picture
Expand All @@ -39,6 +41,8 @@ public struct ThemeData<ApplicationExtension: ApplicationSpecificTheme>: Codable
self.specialKeyFillColor = specialKeyFillColor
self.pushedKeyFillColor = pushedKeyFillColor
self.suggestKeyFillColor = suggestKeyFillColor
self.suggestLabelTextColor = suggestLabelTextColor
self.keyShadow = keyShadow
}

enum CodingKeys: CodingKey {
Expand All @@ -55,6 +59,8 @@ public struct ThemeData<ApplicationExtension: ApplicationSpecificTheme>: Codable
case specialKeyFillColor
case pushedKeyFillColor
case suggestKeyFillColor
case suggestLabelTextColor
case keyShadow
}

public init(from decoder: any Decoder) throws {
Expand All @@ -73,10 +79,27 @@ public struct ThemeData<ApplicationExtension: ApplicationSpecificTheme>: Codable
self.specialKeyFillColor = try container.decode(ColorData.self, forKey: .specialKeyFillColor)
self.pushedKeyFillColor = try container.decode(ColorData.self, forKey: .pushedKeyFillColor)
self.suggestKeyFillColor = try? container.decode(ColorData?.self, forKey: .suggestKeyFillColor)
/// エントリがない場合はデフォルトで黒にする
self.suggestLabelTextColor = (try? container.decode(ColorData?.self, forKey: .suggestLabelTextColor)) ?? .color(Color(white: 0))
self.keyShadow = try? container.decode(ThemeShadowData<ColorData>?.self, forKey: .keyShadow)
}

}

public struct ThemeShadowData<ColorData>: Codable, Equatable, Sendable where ColorData: Codable & Equatable & Sendable {
public init(color: ColorData, radius: CGFloat, x: CGFloat, y: CGFloat) {
self.color = color
self.radius = radius
self.x = x
self.y = y
}

public var color: ColorData
public var radius: CGFloat
public var x: CGFloat
public var y: CGFloat
}

public enum ThemeFontWeight: Int, Codable, Sendable {
case ultraLight = 1
case thin = 2
Expand Down
5 changes: 3 additions & 2 deletions AzooKeyCore/Sources/KeyboardViews/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public indirect enum ActionType: Equatable, Sendable {
/// - note: フルアクセスがない場合動作しない
case paste

case deselectAndUseAsInputting // 選択を解除して編集中とみなす

// カーソル関係
case moveCursor(Int)
case smartMoveCursor(ScanItem)
Expand Down Expand Up @@ -59,6 +57,9 @@ public indirect enum ActionType: Equatable, Sendable {

// 条件分岐アクション
case boolSwitch(CompiledExpression, trueAction: [ActionType], falseAction: [ActionType])

// 選択アクション
case selectCandidate(CandidateSelection)
}

public struct LongpressActionType: Equatable, Sendable {
Expand Down
6 changes: 4 additions & 2 deletions AzooKeyCore/Sources/KeyboardViews/ActionUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extension CodableActionData {
return .smoothDelete
case let .smartDelete(value):
return .smartDelete(value)
case .selectCandidate(let selection):
return .selectCandidate(selection)
case .complete:
return .enter
case let .moveCursor(value):
Expand Down Expand Up @@ -95,9 +97,9 @@ public extension ActionType {
KeyboardFeedback<Extension>.delete()
case .smoothDelete, .smartDelete, .smartMoveCursor:
KeyboardFeedback<Extension>.smoothDelete()
case .moveTab, .enter, .changeCharacterType, .setCursorBar, .moveCursor, .enableResizingMode, .replaceLastCharacters, .setTabBar, .setBoolState, .setUpsideComponent, .setSearchQuery/*, ._setBoolState*/:
case .moveTab, .enter, .changeCharacterType, .setCursorBar, .moveCursor, .enableResizingMode, .replaceLastCharacters, .setTabBar, .setBoolState, .setUpsideComponent, .setSearchQuery, .selectCandidate/*, ._setBoolState*/:
KeyboardFeedback<Extension>.tabOrOtherKey()
case .deselectAndUseAsInputting, .openApp, .dismissKeyboard, .hideLearningMemory:
case .openApp, .dismissKeyboard, .hideLearningMemory:
return
case let .boolSwitch(compiledExpression, trueAction, falseAction):
if let condition = variableStates.boolStates.evaluateExpression(compiledExpression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ import Foundation
static var enableSound: Bool { get }
static var enableHaptics: Bool { get }
static var enablePasteButton: Bool { get }
static var displayTabBarButton: Bool { get }
static var hideResetButtonInOneHandedMode: Bool { get }
static var useBetaMoveCursorBar: Bool { get }
static var useShiftKey: Bool { get }

/// タブバーボタンを表示する
/// - note: このオプションは一度削除を決めたが、ユーザから強い要望があったので維持することにした。
static var displayTabBarButton: Bool { get }
/// 反射スタイルのカーソルバーを利用する
static var useReflectStyleCursorBar: Bool { get }
/// カーソルバーを自動表示する(実験的機能)
/// - note: この機能は実験的に導入しているが、仕様に議論がある。[#346](https://github.com/ensan-hcl/azooKey/issues/346)も参照。
static var displayCursorBarAutomatically: Bool { get }

static var canResetLearningForCandidate: Bool { get }

Expand Down
Loading

0 comments on commit 8d7c8a1

Please sign in to comment.