Update: 2026-05-14 20:47:41
This commit is contained in:
@@ -12,6 +12,8 @@ data class RideLogRequest(
|
||||
val pickupDistance: String,
|
||||
val dropoffDistance: String,
|
||||
val timeToPickup: String,
|
||||
val pickupAddress: String,
|
||||
val dropoffAddress: String,
|
||||
val isAccepted: Boolean,
|
||||
val rawText: String,
|
||||
val fingerprint: String,
|
||||
|
||||
@@ -5,6 +5,8 @@ data class RideRequest(
|
||||
val priceJod: Double?,
|
||||
val minutesAway: Int?,
|
||||
val distanceKm: Double?,
|
||||
val pickupAddress: String? = null,
|
||||
val dropoffAddress: String? = null,
|
||||
val title: String,
|
||||
val text: String
|
||||
)
|
||||
|
||||
@@ -12,10 +12,16 @@ class UberParser : NotificationParser {
|
||||
var price: Double? = null
|
||||
var minutes: Int? = null
|
||||
var distance: Double? = null
|
||||
var pickupAddress: String? = null
|
||||
var dropoffAddress: String? = null
|
||||
|
||||
val priceRegex = """(\d+\.?\d*)\s*(JOD|د\.أ)""".toRegex()
|
||||
val minutesRegex = """(\d+)\s*(min|دقيقة)""".toRegex()
|
||||
val distanceRegex = """(\d+\.?\d*)\s*(km|كم)""".toRegex()
|
||||
|
||||
// Patterns for addresses (e.g. "Pick up: Amman", "Drop-off: Irbid")
|
||||
val pickupAddrRegex = """(?:Pick up|من|صعود):\s*([^•\d,]+)""".toRegex(RegexOption.IGNORE_CASE)
|
||||
val dropoffAddrRegex = """(?:Drop-off|إلى|نزول):\s*([^•\d,]+)""".toRegex(RegexOption.IGNORE_CASE)
|
||||
|
||||
val fullText = "$title $text"
|
||||
|
||||
@@ -31,11 +37,21 @@ class UberParser : NotificationParser {
|
||||
distance = it.groupValues[1].toDoubleOrNull()
|
||||
}
|
||||
|
||||
pickupAddrRegex.find(fullText)?.let {
|
||||
pickupAddress = it.groupValues[1].trim()
|
||||
}
|
||||
|
||||
dropoffAddrRegex.find(fullText)?.let {
|
||||
dropoffAddress = it.groupValues[1].trim()
|
||||
}
|
||||
|
||||
return RideRequest(
|
||||
appPackage = packageName,
|
||||
priceJod = price,
|
||||
minutesAway = minutes,
|
||||
distanceKm = distance,
|
||||
pickupAddress = pickupAddress,
|
||||
dropoffAddress = dropoffAddress,
|
||||
title = title,
|
||||
text = text
|
||||
)
|
||||
|
||||
@@ -49,6 +49,12 @@ class RideNotificationListener : NotificationListenerService() {
|
||||
override fun onNotificationPosted(sbn: StatusBarNotification) {
|
||||
var packageName = sbn.packageName
|
||||
Log.d("JordanBot", "Received notification from: $packageName")
|
||||
|
||||
// TEMPORARY: Allow Shell notifications for testing
|
||||
if (packageName == "com.android.shell") {
|
||||
Log.d("JordanBot", "Testing mode: Treating Shell notification as Uber")
|
||||
packageName = "com.ubercab.driver"
|
||||
}
|
||||
|
||||
val parser = parsers.find { it.packageName == packageName }
|
||||
if (parser == null) {
|
||||
@@ -109,6 +115,8 @@ class RideNotificationListener : NotificationListenerService() {
|
||||
pickupDistance = ride.distanceKm?.toString() ?: "Unknown",
|
||||
dropoffDistance = "Unknown",
|
||||
timeToPickup = ride.minutesAway?.toString() ?: "Unknown",
|
||||
pickupAddress = ride.pickupAddress ?: "Unknown",
|
||||
dropoffAddress = ride.dropoffAddress ?: "Unknown",
|
||||
isAccepted = isAccepted,
|
||||
rawText = rawText,
|
||||
fingerprint = DeviceUtils.getDeviceFingerprint(this@RideNotificationListener),
|
||||
|
||||
Reference in New Issue
Block a user