Merge remote-tracking branch 'refs/remotes/origin/2.2.1_Working_Changes'

This commit is contained in:
Garth Vander Houwen 2023-08-22 11:15:56 -07:00
commit b4e4e3a7e8
5 changed files with 32 additions and 13 deletions

View file

@ -686,6 +686,7 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage
let content = UNMutableNotificationContent()
content.title = "Critically Low Battery!"
content.body = "Time to charge your radio, there is \(telemetry.batteryLevel)% battery remaining."
content.userInfo["target"] = "node"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
let uuidString = UUID().uuidString
let request = UNNotificationRequest(identifier: uuidString, content: content, trigger: trigger)
@ -748,6 +749,7 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM
newMessage.rssi = packet.rxRssi
newMessage.isEmoji = packet.decoded.emoji == 1
newMessage.channel = Int32(packet.channel)
newMessage.portNum = Int32(packet.decoded.portnum.rawValue)
if packet.decoded.replyID > 0 {
newMessage.replyID = Int64(packet.decoded.replyID)
@ -774,7 +776,6 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM
messageSaved = true
if messageSaved {
if newMessage.fromUser != nil && newMessage.toUser != nil && !(newMessage.fromUser?.mute ?? false) {
// Create an iOS Notification for the received DM message and schedule it immediately
let manager = LocalNotificationManager()
@ -783,7 +784,9 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM
id: ("notification.id.\(newMessage.messageId)"),
title: "\(newMessage.fromUser?.longName ?? "unknown".localized)",
subtitle: "AKA \(newMessage.fromUser?.shortName ?? "???")",
content: messageText)
content: messageText,
target: "message"
)
]
manager.schedule()
print("💬 iOS Notification Scheduled for text message from \(newMessage.fromUser?.longName ?? "unknown".localized)")
@ -810,7 +813,8 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM
id: ("notification.id.\(newMessage.messageId)"),
title: "\(newMessage.fromUser?.longName ?? "unknown".localized)",
subtitle: "AKA \(newMessage.fromUser?.shortName ?? "???")",
content: messageText)
content: messageText,
target: "message")
]
manager.schedule()
print("💬 iOS Notification Scheduled for text message from \(newMessage.fromUser?.longName ?? "unknown".localized)")
@ -876,7 +880,7 @@ func waypointPacket (packet: MeshPacket, context: NSManagedObjectContext) {
title: "New Waypoint Received",
subtitle: "\(icon) \(waypoint.name ?? "Dropped Pin")",
content: "\(waypoint.longDescription ?? "\(latitude), \(longitude)")",
target: "waypoint"
target: "map"
)
]
manager.schedule()

View file

@ -141,6 +141,7 @@
<attribute name="messagePayload" optional="YES" attributeType="String" defaultValueString=""/>
<attribute name="messagePayloadMarkdown" optional="YES" attributeType="String"/>
<attribute name="messageTimestamp" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="portNum" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="realACK" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="receivedACK" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="replyID" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>

View file

@ -22,16 +22,17 @@ class MeshtasticAppDelegate: NSObject, UIApplicationDelegate, UNUserNotification
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
{
let userInfo = response.notification.request.content.userInfo
if let targetValue = userInfo["target"] as? String, targetValue == "waypoint"
{
openWaypoint()
let targetValue = userInfo["target"] as? String
if targetValue == "map" {
AppState.shared.tabSelection = Tab.map
}
else if targetValue == "message" {
AppState.shared.tabSelection = Tab.messages
}
else if targetValue == "node" {
AppState.shared.tabSelection = Tab.nodes
}
completionHandler()
}
private func openWaypoint()
{
AppState.shared.tabSelection = Tab.map
}
}

View file

@ -63,12 +63,24 @@ struct ChannelMessageList: View {
VStack(alignment: currentUser ? .trailing : .leading) {
let markdownText: LocalizedStringKey = LocalizedStringKey.init(message.messagePayloadMarkdown ?? (message.messagePayload ?? "EMPTY MESSAGE"))
let linkBlue = Color(red: 0.4627, green: 0.8392, blue: 1) /* #76d6ff */
let isDetectionSensorMessage = message.portNum == Int32(PortNum.detectionSensorApp.rawValue)
Text(markdownText)
.tint(linkBlue)
.padding(10)
.foregroundColor(.white)
.background(currentUser ? .accentColor : Color(.gray))
.cornerRadius(15)
.overlay(
VStack {
isDetectionSensorMessage ? Image(systemName: "sensor.fill")
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
.foregroundStyle(Color.orange)
.offset(x: 20, y: -20)
: nil
}
)
.contextMenu {
VStack {
Text("channel")+Text(": \(message.channel)")

View file

@ -16,6 +16,7 @@ struct NodeMap: View {
@EnvironmentObject var bleManager: BLEManager
@ObservedObject var tileManager = OfflineTileManager.shared
@StateObject var appState = AppState.shared
@State var selectedMapLayer: MapLayer = UserDefaults.mapLayer
@State var enableMapRecentering: Bool = UserDefaults.enableMapRecentering