Sub Process_Globals
Private listener As NotificationListener
Type NOTI(id As Long, PackageName As String, TickerText As String, title As String, subText As String, showChronometer As Boolean, icon As Long, text As String, textLines As String, progress As Int, progressMax As Int, showWhen As Boolean, largeIcon As Bitmap, infoText As String, progressIndeterminate As Boolean, scoreModified As Boolean )
Dim SDKversion As Int, Notifications As List
End Sub
Sub Listener_NotificationPosted (SBN As StatusBarNotification)
Notifications.Add(SBNSurrogate(SBN))
'Log("NotificationPosted, package = " & SBN.PackageName & ", id = " & SBN.Id & ", text = " & SBN.TickerText)
End Sub
Sub SBNSurrogate(SBN As StatusBarNotification) As NOTI
Dim temp As NOTI, Extras As JavaObject = GetExtras(SBN)
temp.Initialize
temp.id = SBN.id
temp.PackageName=SBN.PackageName
temp.TickerText= SBN.TickerText
temp.title = GetExtra(Extras, "title")
temp.subText = GetExtra(Extras, "subText")
temp.showChronometer = GetBoolean(Extras, "showChronometer")
temp.icon = GetDouble(Extras, "icon")
temp.text = GetExtra(Extras, "text")
temp.textLines = GetExtra(Extras, "textLines")
temp.progress = GetDouble(Extras, "progress")
temp.progressMax = GetDouble(Extras, "progressMax")
temp.showWhen = GetBoolean(Extras, "showWhen")
temp.infoText = GetExtra(Extras, "infoText")
temp.progressIndeterminate = GetBoolean(Extras, "progressIndeterminate")
temp.scoreModified = GetBoolean(Extras, "scoreModified")
'temp.largeIcon = GetLargeIcon(Extras)
Log("NOTI: " & temp)
Return temp
End Sub
Public Sub GetExtras(SBN As StatusBarNotification) As JavaObject
If SDKversion >= 19 AND SBN.IsInitialized Then
Dim jno As JavaObject = SBN.Notification
If jno.IsInitialized Then
Dim Extras As JavaObject = jno.GetField("extras")
Extras.RunMethod("size", Null)
Return Extras
End If
End If
End Sub
'Available extras: title, subText, showChronometer(bool), icon(long), text textLines progress(int) progressMax(int) showWhen(bool) largeIcon(bmp) infoText progressIndeterminate(bool) scoreModified(bool)
Public Sub GetExtra(Extras As JavaObject, Name As String) As String
Return Extras.RunMethod("getString", Array As Object("android." & Name))
End Sub
Public Sub GetString(Extras As JavaObject, Name As String) As String
Dim temp As String = GetExtra(Extras, Name)
If temp = Null Then Return "" 'Isn't working for some reason, I still get null strings
Return temp
End Sub
Public Sub GetBoolean(Extras As JavaObject, Name As String) As Boolean
Dim temp As String = GetExtra(Extras, Name)
Return temp.ToLowerCase = "true"
End Sub
Public Sub GetDouble(Extras As JavaObject, Name As String) As Long
Return Extras.RunMethod("getInt", Array As Object("android." & Name))
End Sub
Public Sub GetLargeIcon(Extras As JavaObject) As Bitmap
Dim r As Reflector, temp As Bitmap 'doesn't work yet
r.Target = Extras
temp = r.RunMethod2("getParcelableExtra", "android.largeIcon", "java.lang.String")
Return temp
End Sub