From 776ef05e72907f3c2899e5c54c3ed78ea9571008 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 16 Sep 2023 18:30:07 -0700 Subject: [PATCH] Hide number of nodes online markup, set live activity time back to 60 seconds --- Meshtastic.xcodeproj/project.pbxproj | 4 -- Meshtastic/Helpers/MeshPackets.swift | 6 +-- Widgets/Widgets.swift | 66 ---------------------------- Widgets/WidgetsLiveActivity.swift | 14 +++--- 4 files changed, 10 insertions(+), 80 deletions(-) delete mode 100644 Widgets/Widgets.swift diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index d2f91d02..181d0bd8 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -159,7 +159,6 @@ DDDE59F629AF163D00490C6C /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41A61E29AE7E8F003C5A37 /* SwiftUI.framework */; }; DDDE59F929AF163D00490C6C /* WidgetsBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */; }; DDDE59FB29AF163D00490C6C /* WidgetsLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE59FA29AF163D00490C6C /* WidgetsLiveActivity.swift */; }; - DDDE59FD29AF163D00490C6C /* Widgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE59FC29AF163D00490C6C /* Widgets.swift */; }; DDDE5A0329AF163E00490C6C /* WidgetsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; DDDE5A1029AFE69700490C6C /* MeshActivityAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE5A0F29AFE69700490C6C /* MeshActivityAttributes.swift */; }; DDDE5A1129AFE69700490C6C /* MeshActivityAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDE5A0F29AFE69700490C6C /* MeshActivityAttributes.swift */; }; @@ -382,7 +381,6 @@ DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsBundle.swift; sourceTree = ""; }; DDDE59FA29AF163D00490C6C /* WidgetsLiveActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsLiveActivity.swift; sourceTree = ""; }; - DDDE59FC29AF163D00490C6C /* Widgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Widgets.swift; sourceTree = ""; }; DDDE5A0029AF163E00490C6C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DDDE5A0429AF163E00490C6C /* WidgetsExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WidgetsExtension.entitlements; sourceTree = ""; }; DDDE5A0F29AFE69700490C6C /* MeshActivityAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshActivityAttributes.swift; sourceTree = ""; }; @@ -854,7 +852,6 @@ DDDE5A1229AFEAB900490C6C /* Assets.xcassets */, DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */, DDDE59FA29AF163D00490C6C /* WidgetsLiveActivity.swift */, - DDDE59FC29AF163D00490C6C /* Widgets.swift */, DDDE5A0029AF163E00490C6C /* Info.plist */, DDDE5A0F29AFE69700490C6C /* MeshActivityAttributes.swift */, DDC94FC029CE063B0082EA6E /* BatteryLevel.swift */, @@ -1230,7 +1227,6 @@ DDC94FC229CE063B0082EA6E /* BatteryLevel.swift in Sources */, DDDE5A1129AFE69700490C6C /* MeshActivityAttributes.swift in Sources */, DDDE59FB29AF163D00490C6C /* WidgetsLiveActivity.swift in Sources */, - DDDE59FD29AF163D00490C6C /* Widgets.swift in Sources */, DDDE59F929AF163D00490C6C /* WidgetsBundle.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 18fd6aa9..de34943b 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -688,10 +688,10 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage // Update our live activity if there is one running, not available on mac iOS >= 16.2 #if !targetEnvironment(macCatalyst) - let oneHourLater = Calendar.current.date(byAdding: .minute, value: (Int(60) ), to: Date())! - let date = Date.now...oneHourLater + let oneMinuteLater = Calendar.current.date(byAdding: .minute, value: (Int(1) ), to: Date())! + let date = Date.now...oneMinuteLater let updatedMeshStatus = MeshActivityAttributes.MeshActivityStatus(timerRange: date, connected: true, channelUtilization: telemetry.channelUtilization, airtime: telemetry.airUtilTx, batteryLevel: UInt32(telemetry.batteryLevel), nodes: 17, nodesOnline: 9) - let alertConfiguration = AlertConfiguration(title: "Mesh activity update", body: "Updated Device Metrics Data.", sound: .default) + let alertConfiguration = AlertConfiguration(title: "Mesh activity update", body: "Updated Device Metrics Data.", sound: .default) let updatedContent = ActivityContent(state: updatedMeshStatus, staleDate: nil) let meshActivity = Activity.activities.first(where: { $0.attributes.nodeNum == connectedNode }) diff --git a/Widgets/Widgets.swift b/Widgets/Widgets.swift deleted file mode 100644 index 07354ffd..00000000 --- a/Widgets/Widgets.swift +++ /dev/null @@ -1,66 +0,0 @@ -//// -//// Widgets.swift -//// Widgets -//// -//// Created by Garth Vander Houwen on 2/28/23. -//// -// -// import WidgetKit -// import SwiftUI -// -// struct Provider: TimelineProvider { -// func placeholder(in context: Context) -> SimpleEntry { -// SimpleEntry(date: Date()) -// } -// -// func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { -// let entry = SimpleEntry(date: Date()) -// completion(entry) -// } -// -// func getTimeline(in context: Context, completion: @escaping (Timeline) -> ()) { -// var entries: [SimpleEntry] = [] -// -// // Generate a timeline consisting of five entries an hour apart, starting from the current date. -// let currentDate = Date() -// for hourOffset in 0 ..< 5 { -// let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! -// let entry = SimpleEntry(date: entryDate) -// entries.append(entry) -// } -// -// let timeline = Timeline(entries: entries, policy: .atEnd) -// completion(timeline) -// } -// } -// -// struct SimpleEntry: TimelineEntry { -// let date: Date -// } -// -// struct WidgetsEntryView : View { -// var entry: Provider.Entry -// -// var body: some View { -// Text(entry.date, style: .time) -// } -// } -// -// struct Widgets: Widget { -// let kind: String = "Widgets" -// -// var body: some WidgetConfiguration { -// StaticConfiguration(kind: kind, provider: Provider()) { entry in -// WidgetsEntryView(entry: entry) -// } -// .configurationDisplayName("My Widget") -// .description("This is an example widget.") -// } -// } -// -// struct Widgets_Previews: PreviewProvider { -// static var previews: some View { -// WidgetsEntryView(entry: SimpleEntry(date: Date())) -// .previewContext(WidgetPreviewContext(family: .systemSmall)) -// } -// } diff --git a/Widgets/WidgetsLiveActivity.swift b/Widgets/WidgetsLiveActivity.swift index 43f3b52c..95230354 100644 --- a/Widgets/WidgetsLiveActivity.swift +++ b/Widgets/WidgetsLiveActivity.swift @@ -105,7 +105,7 @@ struct WidgetsLiveActivity: Widget { struct WidgetsLiveActivity_Previews: PreviewProvider { static let attributes = MeshActivityAttributes(nodeNum: 123456789, name: "RAK Compact Rotary Handset Gray 8E6G") static let state = MeshActivityAttributes.ContentState( - timerRange: Date.now...Date(timeIntervalSinceNow: 3600), connected: true, channelUtilization: 25.84, airtime: 10.01, batteryLevel: 39, nodes: 17, nodesOnline: 9) + timerRange: Date.now...Date(timeIntervalSinceNow: 60), connected: true, channelUtilization: 25.84, airtime: 10.01, batteryLevel: 39, nodes: 17, nodesOnline: 9) static var previews: some View { attributes @@ -211,12 +211,12 @@ struct NodeInfoView: View { .foregroundStyle(.secondary) .opacity(isLuminanceReduced ? 0.8 : 1.0) .fixedSize() - Text("\(String(format: "Connected: %d of %d online", nodesOnline, nodes))") - .font(.callout) - .fontWeight(.medium) - .foregroundStyle(.secondary) - .opacity(isLuminanceReduced ? 0.8 : 1.0) - .fixedSize() +// Text("\(String(format: "Connected: %d of %d online", nodesOnline, nodes))") +// .font(.callout) +// .fontWeight(.medium) +// .foregroundStyle(.secondary) +// .opacity(isLuminanceReduced ? 0.8 : 1.0) +// .fixedSize() let now = Date() Text("Last Heard: \(now.formatted())") .font(.caption)