Merge pull request #399 from meshtastic/iOS17_Working_Changes

Hide number of nodes online markup, set live activity time back to 60 Seconds and avoid release of the beast
This commit is contained in:
Garth Vander Houwen 2023-09-16 18:31:27 -07:00 committed by GitHub
commit f3d7678130
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 80 deletions

View file

@ -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 = "<group>"; };
DDDE59FA29AF163D00490C6C /* WidgetsLiveActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsLiveActivity.swift; sourceTree = "<group>"; };
DDDE59FC29AF163D00490C6C /* Widgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Widgets.swift; sourceTree = "<group>"; };
DDDE5A0029AF163E00490C6C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DDDE5A0429AF163E00490C6C /* WidgetsExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WidgetsExtension.entitlements; sourceTree = "<group>"; };
DDDE5A0F29AFE69700490C6C /* MeshActivityAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshActivityAttributes.swift; sourceTree = "<group>"; };
@ -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;

View file

@ -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<MeshActivityAttributes>.activities.first(where: { $0.attributes.nodeNum == connectedNode })

View file

@ -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<Entry>) -> ()) {
// 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))
// }
// }

View file

@ -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)