Skip to content

Commit 6446f42

Browse files
authored
Merge pull request #7 from Cizzuk/dev
v1.0 (13)
2 parents 7b069fa + a2da834 commit 6446f42

11 files changed

Lines changed: 128 additions & 14 deletions

File tree

Alare.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
318318
CODE_SIGN_ENTITLEMENTS = WidgetExtensionExtension.entitlements;
319319
CODE_SIGN_STYLE = Automatic;
320-
CURRENT_PROJECT_VERSION = 12;
320+
CURRENT_PROJECT_VERSION = 13;
321321
DEVELOPMENT_TEAM = Z8R89S24YT;
322322
GENERATE_INFOPLIST_FILE = YES;
323323
INFOPLIST_FILE = WidgetExtension/Info.plist;
@@ -328,7 +328,7 @@
328328
"@executable_path/Frameworks",
329329
"@executable_path/../../Frameworks",
330330
);
331-
MARKETING_VERSION = 0.3;
331+
MARKETING_VERSION = 1.0;
332332
PRODUCT_BUNDLE_IDENTIFIER = net.cizzuk.alare.WidgetExtension;
333333
PRODUCT_NAME = "$(TARGET_NAME)";
334334
SKIP_INSTALL = YES;
@@ -352,7 +352,7 @@
352352
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
353353
CODE_SIGN_ENTITLEMENTS = WidgetExtensionExtension.entitlements;
354354
CODE_SIGN_STYLE = Automatic;
355-
CURRENT_PROJECT_VERSION = 12;
355+
CURRENT_PROJECT_VERSION = 13;
356356
DEVELOPMENT_TEAM = Z8R89S24YT;
357357
GENERATE_INFOPLIST_FILE = YES;
358358
INFOPLIST_FILE = WidgetExtension/Info.plist;
@@ -363,7 +363,7 @@
363363
"@executable_path/Frameworks",
364364
"@executable_path/../../Frameworks",
365365
);
366-
MARKETING_VERSION = 0.3;
366+
MARKETING_VERSION = 1.0;
367367
PRODUCT_BUNDLE_IDENTIFIER = net.cizzuk.alare.WidgetExtension;
368368
PRODUCT_NAME = "$(TARGET_NAME)";
369369
SKIP_INSTALL = YES;
@@ -511,7 +511,7 @@
511511
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
512512
CODE_SIGN_ENTITLEMENTS = Alare/Alare.entitlements;
513513
CODE_SIGN_STYLE = Automatic;
514-
CURRENT_PROJECT_VERSION = 12;
514+
CURRENT_PROJECT_VERSION = 13;
515515
DEVELOPMENT_TEAM = Z8R89S24YT;
516516
ENABLE_PREVIEWS = YES;
517517
GENERATE_INFOPLIST_FILE = YES;
@@ -530,7 +530,7 @@
530530
"$(inherited)",
531531
"@executable_path/Frameworks",
532532
);
533-
MARKETING_VERSION = 0.3;
533+
MARKETING_VERSION = 1.0;
534534
PRODUCT_BUNDLE_IDENTIFIER = net.cizzuk.alare;
535535
PRODUCT_NAME = "$(TARGET_NAME)";
536536
STRING_CATALOG_GENERATE_SYMBOLS = YES;
@@ -555,7 +555,7 @@
555555
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
556556
CODE_SIGN_ENTITLEMENTS = Alare/Alare.entitlements;
557557
CODE_SIGN_STYLE = Automatic;
558-
CURRENT_PROJECT_VERSION = 12;
558+
CURRENT_PROJECT_VERSION = 13;
559559
DEVELOPMENT_TEAM = Z8R89S24YT;
560560
ENABLE_PREVIEWS = YES;
561561
GENERATE_INFOPLIST_FILE = YES;
@@ -574,7 +574,7 @@
574574
"$(inherited)",
575575
"@executable_path/Frameworks",
576576
);
577-
MARKETING_VERSION = 0.3;
577+
MARKETING_VERSION = 1.0;
578578
PRODUCT_BUNDLE_IDENTIFIER = net.cizzuk.alare;
579579
PRODUCT_NAME = "$(TARGET_NAME)";
580580
STRING_CATALOG_GENERATE_SYMBOLS = YES;

Alare/Alare.entitlements

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>com.apple.developer.associated-domains</key>
6+
<array>
7+
<string>applinks:cizz.uk</string>
8+
</array>
59
<key>com.apple.security.application-groups</key>
610
<array>
711
<string>group.net.cizzuk.alare</string>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "scancode-image.png",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
22.2 KB
Loading

Alare/Models/UserData/WakeupActionSettings.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct WakeupActionSettings: Codable {
1313

1414
// Wave Device Settings
1515
var waveDevice_pointsRequired: Int = 100
16+
var waveDevice_sensitivity: Double = 0.5
1617

1718
// Scan Code Settings
1819
var scanCode_code: String? // Required

Alare/ViewModels/MainViewModel.swift

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,25 @@ class MainViewModel: ObservableObject {
6464
}
6565
}
6666

67+
func handleContinueUserActivity(activity: NSUserActivity) {
68+
print("Continue user activity: ", activity.activityType)
69+
70+
// Handle Universal Link
71+
if let url = activity.webpageURL {
72+
print("URL opened: ", url)
73+
handleUniversalLink(url: url)
74+
}
75+
}
76+
6777
func handleOpenURL(url: URL) {
78+
print("URL opened: ", url)
79+
80+
// Handle Universal Link
81+
if url.scheme == "https" || url.scheme == "http" {
82+
handleUniversalLink(url: url)
83+
return
84+
}
85+
6886
// Get App URL Schemes
6987
let appURLSchemes = Bundle.main.object(forInfoDictionaryKey: "CFBundleURLTypes") as? [[String: Any]]
7088
let urlSchemes = appURLSchemes?.compactMap { $0["CFBundleURLSchemes"] as? [String] }.flatMap { $0 } ?? []
@@ -83,6 +101,12 @@ class MainViewModel: ObservableObject {
83101
}
84102
}
85103

104+
private func handleUniversalLink(url: URL) {
105+
if url == URL(string: completeWakeupActionURL) {
106+
completeWakeupAction()
107+
}
108+
}
109+
86110
// MARK: - Alarm Management
87111

88112
func syncAll() {
@@ -123,9 +147,11 @@ class MainViewModel: ObservableObject {
123147
}
124148

125149
func completeWakeupAction() {
126-
killAlarm()
127-
doingWakeupAction = nil
128-
HapticManager.shared.playHaptics(.success)
150+
if register.registereds.nextSnooze != nil {
151+
killAlarm()
152+
doingWakeupAction = nil
153+
HapticManager.shared.playHaptics(.success)
154+
}
129155
}
130156

131157
func killAlarm() {

Alare/Views/MainView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ struct MainView: View {
178178
.onReceive(NotificationCenter.default.publisher(for: .focusFilterDidChange)) { _ in
179179
vm.syncFocusFilter()
180180
}
181+
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { activity in
182+
vm.handleContinueUserActivity(activity: activity)
183+
}
181184
.onOpenURL { url in
182185
vm.handleOpenURL(url: url)
183186
}

Alare/Views/WakeupActions/ScanCode/ScanCodeWakeupActionView.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import VisionKit
1414
struct ScanCodeWakeupActionSettingsView: View {
1515
@ObservedObject private var manager = WakeupActionManager.shared
1616
@State private var isShowingScanner = false
17+
@State private var isShowingShareSheet = false
1718

1819
private let cameraAuthStatus = AVCaptureDevice.authorizationStatus(for: .video)
1920
private var isCameraAccessDenied: Bool {
@@ -71,6 +72,17 @@ struct ScanCodeWakeupActionSettingsView: View {
7172
}
7273
}
7374
}
75+
76+
if let image = UIImage(named: "scancode-image") {
77+
Section {
78+
ShareLink(
79+
item: Image(uiImage: image),
80+
preview: SharePreview("Alare Code", image: Image(uiImage: image))
81+
) {
82+
Label("Create New Code", systemImage: "qrcode")
83+
}
84+
}
85+
}
7486
}
7587
}
7688

@@ -80,7 +92,6 @@ struct ScanCodeWakeupActionExecutionView: View {
8092
@ObservedObject var vm: WakeupActionExecutionViewModel
8193
@State var incorrectCodeEntered = false
8294
private let expectedCode = WakeupActionManager.shared.settings.scanCode_code
83-
private let specialCode = "https://cizz.uk/alare"
8495

8596
var body: some View {
8697
VStack() {
@@ -101,7 +112,7 @@ struct ScanCodeWakeupActionExecutionView: View {
101112
}
102113

103114
BarcodeScannerView { code in
104-
if code == expectedCode || code == specialCode {
115+
if code == expectedCode || code == completeWakeupActionURL {
105116
vm.complete()
106117
} else {
107118
incorrectCodeEntered = true

Alare/Views/WakeupActions/WaveDevice/WaveDeviceWakeupActionView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ struct WaveDeviceWakeupActionSettingsView: View {
3737
}
3838
.pickerStyle(.wheel)
3939
}
40+
41+
Picker("Sensitivity", selection: $manager.settings.waveDevice_sensitivity) {
42+
Text("Medium").tag(0.5)
43+
Text("High").tag(0.3)
44+
}
4045
} footer: {
4146
Text("It's easier to earn points by making large, slow movements with your device rather than quick, small shakes.")
4247
}
@@ -59,7 +64,7 @@ struct WaveDeviceWakeupActionExecutionView: View {
5964

6065
private let updateInterval: TimeInterval = 0.1
6166
private let gyroCancelRate: Double = 15.0
62-
private let threshold: Double = 0.5
67+
private let threshold: Double = WakeupActionManager.shared.settings.waveDevice_sensitivity
6368

6469
private var remainingPoints: Int {
6570
max(pointsRequired - progress, 0)

Constants.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import SwiftUI
99

1010
let userDefaults = UserDefaults(suiteName: "group.net.cizzuk.alare")!
1111

12+
let completeWakeupActionURL = "https://cizz.uk/alare/sc"
13+
1214
let NightGradient = LinearGradient(
1315
gradient: Gradient(colors: [.dropblue.opacity(0.2), .black]),
1416
startPoint: .top,

0 commit comments

Comments
 (0)