Sub GetIconColor As Int
Dim p As Phone
If p.SdkVersion >= 21 Then
Dim jo As JavaObject
jo.InitializeContext
Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
window.RunMethod("addFlags", Array (0x80000000))
window.RunMethod("clearFlags", Array (0x04000000))
Return ContrastColor(window.RunMethod("getStatusBarColor", Null))
End If
Return Colors.Gray
End Sub
Public Sub ContrastColor(Color As Int) As Int
'From https://stackoverflow.com/a/41335343
'Counting the perceptive luminance - human eye favors green color...
' Red Green Blue
Dim A As Double = 1 - (0.299 * Bit.And(Bit.ShiftRight(Color,16),0xFF) + 0.587 * Bit.And(Bit.ShiftRight(Color,8),0XFF) + 0.114 * Bit.And(Color,0xFF)) / 255
If A < 0.5 Then
Return Colors.Black
Else
Return Colors.White
End If
End Sub