Skip to content

Commit 83bc03f

Browse files
committed
Merge branch 'release/2022.3'
2 parents f8bd8c0 + eb1ecb0 commit 83bc03f

21 files changed

+394
-128
lines changed

AbnormalMouse.xcworkspace/xcshareddata/swiftpm/Package.resolved

-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
{
22
"object": {
33
"pins": [
4-
{
5-
"package": "License",
6-
"repositoryURL": "https://github.com/intitni/AbnormalMouseLicense",
7-
"state": {
8-
"branch": "master",
9-
"revision": "fe24110147e1317536d049c1071ee4e3306ef856",
10-
"version": null
11-
}
12-
},
134
{
145
"package": "CGEventOverride",
156
"repositoryURL": "https://github.com/intitni/CGEventOverride.git",

AbnormalMouse/AbnormalMouse.xcodeproj/project.pbxproj

+6-6
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@
10801080
CODE_SIGN_IDENTITY = "Apple Development";
10811081
CODE_SIGN_STYLE = Automatic;
10821082
COMBINE_HIDPI_IMAGES = YES;
1083-
CURRENT_PROJECT_VERSION = 60;
1083+
CURRENT_PROJECT_VERSION = 67;
10841084
DEVELOPMENT_ASSET_PATHS = "\"AbnormalMouse/Preview Content\"";
10851085
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
10861086
ENABLE_HARDENED_RUNTIME = YES;
@@ -1095,7 +1095,7 @@
10951095
"@executable_path/../Frameworks",
10961096
);
10971097
MACOSX_DEPLOYMENT_TARGET = 10.15;
1098-
MARKETING_VERSION = 2022.2;
1098+
MARKETING_VERSION = 2022.3;
10991099
OTHER_CODE_SIGN_FLAGS = "--timestamp --deep --options runtime";
11001100
PRODUCT_BUNDLE_IDENTIFIER = com.intii.AbnormalMouse;
11011101
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1116,7 +1116,7 @@
11161116
CODE_SIGN_IDENTITY = "Apple Development";
11171117
CODE_SIGN_STYLE = Automatic;
11181118
COMBINE_HIDPI_IMAGES = YES;
1119-
CURRENT_PROJECT_VERSION = 60;
1119+
CURRENT_PROJECT_VERSION = 67;
11201120
DEVELOPMENT_ASSET_PATHS = "\"AbnormalMouse/Preview Content\"";
11211121
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
11221122
ENABLE_HARDENED_RUNTIME = YES;
@@ -1131,7 +1131,7 @@
11311131
"@executable_path/../Frameworks",
11321132
);
11331133
MACOSX_DEPLOYMENT_TARGET = 10.15;
1134-
MARKETING_VERSION = 2022.2;
1134+
MARKETING_VERSION = 2022.3;
11351135
OTHER_CODE_SIGN_FLAGS = "--timestamp --deep --options runtime";
11361136
PRODUCT_BUNDLE_IDENTIFIER = com.intii.AbnormalMouse;
11371137
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1261,7 +1261,7 @@
12611261
CODE_SIGN_IDENTITY = "Apple Development";
12621262
CODE_SIGN_STYLE = Automatic;
12631263
COMBINE_HIDPI_IMAGES = YES;
1264-
CURRENT_PROJECT_VERSION = 60;
1264+
CURRENT_PROJECT_VERSION = 67;
12651265
DEVELOPMENT_ASSET_PATHS = "\"AbnormalMouse/Preview Content\"";
12661266
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
12671267
ENABLE_HARDENED_RUNTIME = YES;
@@ -1276,7 +1276,7 @@
12761276
"@executable_path/../Frameworks",
12771277
);
12781278
MACOSX_DEPLOYMENT_TARGET = 10.15;
1279-
MARKETING_VERSION = 2022.2;
1279+
MARKETING_VERSION = 2022.3;
12801280
OTHER_CODE_SIGN_FLAGS = "--timestamp --deep --options runtime";
12811281
PRODUCT_BUNDLE_IDENTIFIER = com.intii.AbnormalMouse;
12821282
PRODUCT_NAME = "$(TARGET_NAME)";

AbnormalMouse/AbnormalMouse/AppDelegate.swift

+9
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,17 @@ private let store = TheApp.Store(
5151
overrideControllers: [
5252
MoveToScrollController(
5353
persisted: Readonly(persisted.moveToScroll),
54+
sharedPersisted: Readonly(persisted.advanced),
5455
hook: eventHook
5556
),
5657
ZoomAndRotateController(
5758
persisted: Readonly(persisted.zoomAndRotate),
59+
sharedPersisted: Readonly(persisted.advanced),
5860
hook: eventHook
5961
),
6062
DockSwipeController(
6163
persisted: Readonly(persisted.dockSwipe),
64+
sharedPersisted: Readonly(persisted.advanced),
6265
hook: eventHook
6366
),
6467
]
@@ -106,6 +109,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
106109
purchaseManager.updatePurchaseState()
107110
#endif
108111
}
112+
113+
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows: Bool) -> Bool {
114+
guard !hasVisibleWindows else { return false }
115+
showSettingsWindow()
116+
return true
117+
}
109118
}
110119

111120
extension AppDelegate {

AbnormalMouse/AbnormalMouse/Features/Advanced/AdvancedDomain.swift

+33
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ import Foundation
55
import ServiceManagement
66

77
enum AdvancedDomain: Domain {
8+
typealias ExcludedApplication = Persisted.Advanced.ExcludedApplication
9+
810
struct State: Equatable {
911
var listenToKeyboardEvent: Bool = false
12+
var excludedApps: [ExcludedApplication] = []
13+
var availableApplications: [ExcludedApplication] = []
14+
var selectedExcludedApp: ExcludedApplication?
1015
}
1116

1217
enum Action {
1318
case appear
1419
case toggleListenToKeyboardEvents
20+
case addExcludedApp(ExcludedApplication)
21+
case selectExcludedApp(ExcludedApplication)
22+
case removeSelectedExcludedApp
1523
}
1624

1725
typealias Environment = SystemEnvironment<_Environment>
@@ -34,13 +42,38 @@ enum AdvancedDomain: Domain {
3442
return .fireAndForget {
3543
environment.persisted.listenToKeyboardEvent = result
3644
}
45+
case let .addExcludedApp(app):
46+
if state.excludedApps.contains(app) { return .none }
47+
state.excludedApps.append(app)
48+
let list = state.excludedApps
49+
return .fireAndForget {
50+
environment.persisted.gloablExcludedApplications = list
51+
}
52+
case .removeSelectedExcludedApp:
53+
guard let selected = state.selectedExcludedApp else { return .none }
54+
state.excludedApps.removeAll { selected.bundleIdentifier == $0.bundleIdentifier }
55+
let list = state.excludedApps
56+
state.selectedExcludedApp = nil
57+
return .fireAndForget {
58+
environment.persisted.gloablExcludedApplications = list
59+
}
60+
case let .selectExcludedApp(app):
61+
state.selectedExcludedApp = app
62+
return .none
3763
}
3864
}
3965
}
4066

4167
extension AdvancedDomain.State {
4268
init(from persisted: Persisted.Advanced) {
4369
listenToKeyboardEvent = persisted.listenToKeyboardEvent
70+
excludedApps = persisted.gloablExcludedApplications
71+
availableApplications = NSWorkspace.shared.runningApplications.compactMap {
72+
guard let name = $0.localizedName,
73+
let identifier = $0.bundleIdentifier,
74+
$0.activationPolicy == .regular else { return nil }
75+
return .init(appName: name, bundleIdentifier: identifier)
76+
}
4477
}
4578
}
4679

AbnormalMouse/AbnormalMouse/Features/Advanced/AdvancedView.swift

+84-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ private struct AdvancedView: View {
1717

1818
var body: some View {
1919
ScrollView {
20-
self.settings
20+
settings
21+
if #available(macOS 11.0, *) {
22+
excludedApps
23+
}
2124
Spacer()
2225
}
2326
}
@@ -42,6 +45,75 @@ private struct AdvancedView: View {
4245
}
4346
)
4447
}
48+
49+
@available(macOS 11.0, *)
50+
private var excludedApps: some View {
51+
SettingsSectionView(showSeparator: false, content: {
52+
WithViewStore(store) { viewStore in
53+
Text(_L10n.View.excludeListTitle).asWidgetTitle()
54+
VStack(alignment: .leading, spacing: 0) {
55+
ScrollView {
56+
VStack(spacing: 4) {
57+
ForEach(viewStore.excludedApps) { app in
58+
Button(action: {
59+
viewStore.send(.selectExcludedApp(app))
60+
}) {
61+
HStack {
62+
Text("\(app.appName) (\(app.bundleIdentifier))")
63+
Spacer()
64+
}
65+
.contentShape(Rectangle())
66+
}
67+
.padding(EdgeInsets(top: 2, leading: 6, bottom: 2, trailing: 6))
68+
.roundedCornerBackground(
69+
cornerRadius: 4,
70+
fillColor: viewStore.state.selectedExcludedApp == app
71+
? Color(NSColor.selectedControlColor)
72+
: .clear,
73+
strokeColor: .clear,
74+
strokeWidth: 0,
75+
shadow: nil
76+
)
77+
.padding(EdgeInsets(top: 0, leading: 6, bottom: 0, trailing: 6))
78+
.frame(maxWidth: .infinity)
79+
.buttonStyle(PlainButtonStyle())
80+
}
81+
}
82+
}
83+
.padding(EdgeInsets(top: 6, leading: 0, bottom: 6, trailing: 0))
84+
.background(Color.clear)
85+
.frame(maxWidth: 320, minHeight: 120, maxHeight: 120)
86+
87+
HStack {
88+
Menu("+") {
89+
ForEach(viewStore.availableApplications) { app in
90+
Button(action: {
91+
viewStore.send(.addExcludedApp(app))
92+
}) {
93+
Text("\(app.appName) (\(app.bundleIdentifier))")
94+
}
95+
}
96+
}
97+
.frame(width: 40)
98+
99+
Button(action: {
100+
viewStore.send(.removeSelectedExcludedApp)
101+
}) {
102+
Image(nsImage: NSImage(named: NSImage.touchBarDeleteTemplateName)!)
103+
}.buttonStyle(.plain)
104+
}
105+
.padding(EdgeInsets(top: 0, leading: 6, bottom: 6, trailing: 6))
106+
}
107+
.roundedCornerBackground(
108+
cornerRadius: 2,
109+
fillColor: Color(NSColor.controlBackgroundColor),
110+
strokeColor: Color(NSColor.separatorColor),
111+
strokeWidth: 1,
112+
shadow: nil
113+
)
114+
}
115+
})
116+
}
45117
}
46118

47119
private enum _L10n {
@@ -51,7 +123,17 @@ private enum _L10n {
51123
struct AdvancedView_Previews: PreviewProvider {
52124
static var previews: some View {
53125
AdvancedView(store: .init(
54-
initialState: .init(),
126+
initialState: .init(
127+
listenToKeyboardEvent: true,
128+
excludedApps: [
129+
.init(appName: "A", bundleIdentifier: "A"),
130+
.init(appName: "B", bundleIdentifier: "B"),
131+
],
132+
availableApplications: [
133+
.init(appName: "A", bundleIdentifier: "A"),
134+
.init(appName: "B", bundleIdentifier: "B"),
135+
]
136+
),
55137
reducer: AdvancedDomain.reducer,
56138
environment: .live(environment: .init(persisted: .init()))
57139
))

AbnormalMouse/AbnormalMouse/Features/Main/MainDomain.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ extension Store where Action == MainDomain.Action, State == MainDomain.State {
193193
moveToScrollSettings: .init(),
194194
zoomAndRotateSettings: .init(),
195195
needAccessibility: .init(),
196-
general: .init()
196+
general: .init(),
197+
activationStateDescription: "Hello"
197198
),
198199
reducer: MainDomain.reducer,
199200
environment: .live(environment: .init(

AbnormalMouse/AbnormalMouse/Features/Main/MainView.swift

+18-9
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,24 @@ private struct MainView: View {
234234
private func activationState(
235235
viewStore: ViewStore<MainDomain.State, MainDomain.Action>
236236
) -> some View {
237-
Text(viewStore.state.activationStateDescription ?? "")
238-
.padding([.top, .bottom], 8)
239-
.padding([.leading, .trailing], 16)
240-
.roundedCornerBackground(
241-
cornerRadius: 4,
242-
fillColor: Color(NSColor.controlBackgroundColor),
243-
shadow: .init()
244-
)
245-
.padding([.all], 8)
237+
HStack {
238+
Text(viewStore.state.activationStateDescription ?? "")
239+
Button(action: { viewStore.send(.purchase) }) {
240+
Text(L10n.Activation.Button.buyNow)
241+
.foregroundColor(Color(NSColor.controlAccentColor))
242+
.frame(minWidth: 70)
243+
}
244+
.buttonStyle(.plain)
245+
}
246+
.padding([.top, .bottom], 8)
247+
.padding(.leading, 16)
248+
.padding(.trailing, 4)
249+
.roundedCornerBackground(
250+
cornerRadius: 4,
251+
fillColor: Color(NSColor.controlBackgroundColor),
252+
shadow: .init()
253+
)
254+
.padding([.all], 8)
246255
}
247256
}
248257

AbnormalMouse/AbnormalMouse/Features/ZoomAndRotate/ZoomAndRotateDomain.swift

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ enum ZoomAndRotateDomain: Domain {
1515
var zoomAndRotateActivator = ZoomAndRotateActivator()
1616
var zoomGestureDirection = MoveMouseDirection.none
1717
var rotateGestureDirection = MoveMouseDirection.none
18+
var zoomSpeedMultiplier: Double = 0
19+
var rotateSpeedMultiplier: Double = 0
1820

1921
struct SmartZoomActivator: Equatable {
2022
var shouldUseZoomAndRotateKeyCombinationDoubleTap = true
@@ -39,6 +41,8 @@ enum ZoomAndRotateDomain: Domain {
3941

4042
case changeZoomGestureDirectionToOption(Int)
4143
case changeRotateGestureDirectionToOption(Int)
44+
case setZoomSpeedMultiplier(Double)
45+
case setRotateSpeedMultiplier(Double)
4246

4347
case smartZoom(SmartZoom)
4448
enum SmartZoom: Equatable {
@@ -149,6 +153,16 @@ enum ZoomAndRotateDomain: Domain {
149153
environment.persisted.zoomGestureDirection = anotherDirection
150154
environment.persisted.rotateGestureDirection = direction
151155
}
156+
case let .setZoomSpeedMultiplier(multiplier):
157+
state.zoomSpeedMultiplier = multiplier
158+
return .fireAndForget {
159+
environment.persisted.zoomSpeedMultiplier = multiplier
160+
}
161+
case let .setRotateSpeedMultiplier(multiplier):
162+
state.rotateSpeedMultiplier = multiplier
163+
return .fireAndForget {
164+
environment.persisted.rotateSpeedMultiplier = multiplier
165+
}
152166
case let .smartZoom(action):
153167
return .merge([
154168
.init(value: ._internal(.checkConflict)),
@@ -185,6 +199,8 @@ extension ZoomAndRotateDomain.State {
185199
),
186200
zoomGestureDirection: persisted.zoomGestureDirection,
187201
rotateGestureDirection: persisted.rotateGestureDirection,
202+
zoomSpeedMultiplier: persisted.zoomSpeedMultiplier,
203+
rotateSpeedMultiplier: persisted.rotateSpeedMultiplier,
188204
smartZoomActivator: .init(
189205
shouldUseZoomAndRotateKeyCombinationDoubleTap: persisted.smartZoom
190206
.useZoomAndRotateDoubleTap,

0 commit comments

Comments
 (0)