B4A Library SD: Floating Button StandOut

(No WRAP, but B4A)
I've been in a new challenge. I reworked a little release published by @JordiCP. Find Here

He entered the Java code taken by GitHub (see https://github.com/henrychuangtw/Android-ChatHead) and wrapped it with "#IF JAVA" inside a B4A module.

With his permission I extended a bit of the B4A code and retouched the Java code (for that little I remember Java) and I realized one thing I longed for: A flying button that always stands out even on other Apps On the Desktop.

You can get the full version by making a donation..

SD_FloatingStandOut

Author:
Star-Dust
Version: 0.08
  • FloatingStandOut
    Code module
    Subs in this code module will be accessible from all modules.
    • Fields:
      • ActiveService As Boolean
      • ENABLEDROP As Boolean
      • EventClick As String
      • EventDoubleClick As String
      • EventLongClick As String
      • EventMove As String
      • HALF_STICK_TO_BORDER As Boolean
      • HeightImage As Int
      • NameFileImage As String
      • NotificationBody As String
      • NotificationTitle As String
      • PathImage As String
      • StartActivity_OnClick As Boolean
      • StartActivity_OnDoubleClick As Boolean
      • StartActivity_OnLongClick As Boolean
      • STICK_TO_BORDER As Boolean
      • StopFloating_OnClick As Boolean
      • StopFloating_OnDoubleClick As Boolean
      • StopFloating_OnLongClick As Boolean
      • WhiteCircle As Boolean
      • WidthImage As Int
      • X As Int
      • Y As Int
    • Functions:
      • Process_Globals As String
      • SetEvent (EventName As String) As String
        SetEvent("FL")
        Sub FL_OnClick(X as int, Y as int)
        Sub FL_OnDoubleClick(X as int, Y as int)
        Sub FL_OnLongClick(X as int, Y as int)
        Sub FL_OnMove(X as int, Y as int)
      • SetImageBitmap (img As Bitmap) As String
      • SetStartActivity (OnClick As Boolean, OnDoubleClick As Boolean, OnLongClick As Boolean) As String
      • SetStopFloating (OnClick As Boolean, OnDoubleClick As Boolean, OnLongClick As Boolean) As String
      • Start (Me_CallBack As Object) As String
        Es. Start(Me,Application.PackageName)
      • Stop As String
  • SpecialPermission
    • Functions:
      • ActivatePermissionResumable As ResumableSub
      • Class_Globals As String
      • GetPermission As Boolean
      • Initialize As String
        Inizializza l'oggetto. Puoi aggiungere parametri a questo metodo,se necessario.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • OpenSettingPermission As String
      • SdkVersion As Int
  • chElement
    • Fields:
      • active As Boolean
      • id As Int
      • instance As JavaObject
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • ttype As chType
      • xpos As Int
      • ypos As Int
    • Functions:
      • Initialize
        Inizializza i campi al loro valore predefinito.
  • standout
    • Fields:
      • CallBack As Object
      • Snotif As Notification
    • Functions:
      • process_globals


N.B. Don't forget ADD to Manifest
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

request permission SDK 23+
B4X:
    Dim Permission As SpecialPermission
    Permission.Initialize
    If Permission.GetPermission Then
        FloatingStandOut.Start(Me)
    Else
        Permission.OpenSettingPermission
    End If

With resumable sub
B4X:
Sub RequestPermission
    Dim Permission As SpecialPermission
    Permission.Initialize
    Log(Permission.GetPermission)
    Wait For (Permission.ActivatePermissionResumable) Complete (Success As Boolean)
    If Success Then FloatingStandOut.Start(Me)
End Sub
 

Attachments

  • sample1.zip
    48.5 KB · Views: 569
  • sample2.zip
    26.8 KB · Views: 580
  • SD_FloatingStandOut 0.08.zip
    21.9 KB · Views: 136
Last edited:

peacemaker

Expert
Licensed User
How to change the icon size at runtime ? I have always the same size, cannot understand where it is inited, and how to update.
 

NeoTechni

Well-Known Member
Licensed User
How do you detect when the floating button is clicked, versus the app opening regularly?
 

Star-Dust

Expert
Licensed User
see the SetEvent method
 

Star-Dust

Expert
Licensed User
if you want to pass a canvas as an image of the floating icon after ver drawn on the canvas use the Cavas.Bitmap method. will return a bitmap that you can use as the image
 

incendio

Well-Known Member
Licensed User
Hi,
Thanks for this library.

I tried it with Andro 10 & B4A 10.5, it worked great, but notification info with empty message always shows when call FloatingStandOut.Start.

On Android 7, there was no notification info.

Can it set to set notification info always off?
 
Last edited:

Star-Dust

Expert
Licensed User
unfortunately not. With the latest versions of Android when you boot into special service to keep it alive you have to tie it to a notification
 

gainax00

Member
Hola!!
Hello!!
Cómo poner un GIF animado o APNG en lugar de una imagen estatica
How to put an animated GIF or APNG instead of an statist image
 

Johan Hormaza

Well-Known Member
Licensed User
in the example the click opens the activity

I mean the first example friend
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    FloatingStandOut.SetEvent("FL")
    FloatingStandOut.PathImage=File.DirAssets
    FloatingStandOut.NameFileImage="iniciologin.png"
    FloatingStandOut.X=50%x
    FloatingStandOut.Y=50%y
    FloatingStandOut.SetStartActivity(True,True,False)
'    FloatingStandOut.SetStopFloating(False,False,True)
End Sub

Sub Activity_Resume
'    FloatingStandOut.Stop
End Sub

Sub FL_OnClick(X As Int, Y As Int)
    Log("FL_OnClick")'<-----------------Here---------'
    StartActivity(Me)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
'    FloatingStandOut.Start(Me)
End Sub

Sub Button1_Click
    Dim Permission As SpecialPermission
    Permission.Initialize
    If Permission.GetPermission Then
        FloatingStandOut.Start(Me)
    Else
        Permission.OpenSettingPermission
    End If
    
    Activity.Finish
End Sub
 

Star-Dust

Expert
Licensed User
I mean the first example friend
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    FloatingStandOut.SetEvent("FL")
    FloatingStandOut.PathImage=File.DirAssets
    FloatingStandOut.NameFileImage="iniciologin.png"
    FloatingStandOut.X=50%x
    FloatingStandOut.Y=50%y
    FloatingStandOut.SetStartActivity(True,True,False)
'    FloatingStandOut.SetStopFloating(False,False,True)
End Sub

Sub Activity_Resume
'    FloatingStandOut.Stop
End Sub

Sub FL_OnClick(X As Int, Y As Int)
    Log("FL_OnClick")'<-----------------Here---------'
    StartActivity(Me)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
'    FloatingStandOut.Start(Me)
End Sub

Sub Button1_Click
    Dim Permission As SpecialPermission
    Permission.Initialize
    If Permission.GetPermission Then
        FloatingStandOut.Start(Me)
    Else
        Permission.OpenSettingPermission
    End If
   
    Activity.Finish
End Sub
B4X:
Sub FL_OnClick(X As Int, Y As Int)
    StartActivity(Me)
    ' or StartActivity(MainActivity)
End Sub
 

Star-Dust

Expert
Licensed User
Help me!!
How to put an animated GIF
see this
 

Star-Dust

Expert
Licensed User

Star-Dust

Expert
Licensed User
I'm not sure I understand the question
 

Star-Dust

Expert
Licensed User
Sure
B4X:
standout.Snotif.SetInfo("Hallo","Float",Me) ' Me is Main Activity
 
Top