B4A Library ChatHead wrapper + GIF overlay

Discussion in 'Additional libraries, classes and official updates' started by JordiCP, Jan 5, 2016.

  1. JordiCP

    JordiCP Well-Known Member Licensed User

    (2017/07/01)

    Based on this wrapper, I also built some strange things on it, with different purposes. I am not working on most of them anymore, so I decided to share.

    This one is funny. Similar to the video but with added elements
    It combines several overlay elements and brings them into life simulating GIF animation (based on some previously converted GIF files to PNG) and sequencing them with a timer. In this version there are some xmas stars, a Santa and a spider skull

    I publish it here since the thread already exists and is related to it... As always, perhaps the code style is not the best in the world to learn from, but I have tried to comment a bit and delete unneeded things so that it will be more easy to follow.

    Important: in most recent android versions, you must grant directly to the app the permission to show elements on top of others (it is not enough with the declared manifest permissions). So, if nothing appears on your screen you should check it.

    Hope you enjoy it :)
    -----------------------------------

    I'm happy to share this chatHead wrapper made with B4A and Inline Java. :) The original project is taken from here . I wrapped and modified it "a bit" for my purposes.



    These views are not "normal" views in the sense that they don't need to be in an activity, but are added diectly to the WindowManager.
    This allows for special uses, such as pop-up notifications which the user can interact with or simply discard. But also special care must be taken.

    The attached zip is itself a small demo. All the "important" things are in the inline Java part in "oService", and how are they created and destroyed. The rest is just for the demo itself

    Possibly many things can be improved, such as adding animations (I think in this case they are a bit tricky and still struggling with them)

    Important: These views are not automatically destroyed when you destroy your app. Please pay attention at Service_Destroy

    Also: the sound example in Files folder is from http://www.freesfx.co.uk/. It is free, but if you use it, they need to be mentioned



    Enjoy!

    (I am preparing the drop option as in facebook messenger, but will take a while ;))
     

    Attached Files:

    Last edited: Jul 1, 2017
  2. JordiCP

    JordiCP Well-Known Member Licensed User

    (RFU)
     
  3. Daniel-White

    Daniel-White Active Member Licensed User

    Hi Jordi, I download it, but perhaps, I missing something.


    upload_2016-1-5_17-46-42.png
     
  4. JordiCP

    JordiCP Well-Known Member Licensed User

    Hi,

    I suppose that you need SDK 21 or higher since this method was introduced in that API

    But the good news is that this last function ( isMyScreenOn() ) isn't needed in this demo, I simply left it here from another project.

    So try to remove the function and see if it works :)
     
    Daniel-White likes this.
  5. Daniel-White

    Daniel-White Active Member Licensed User

    Yes, you right, it is running now. my SDK is 19
     
  6. JordiCP

    JordiCP Well-Known Member Licensed User

    Great! If it works for you can you please tell me phone model/Android version? :)
     
  7. Daniel-White

    Daniel-White Active Member Licensed User

    LG-G2 / 4.4.2
     
    JordiCP likes this.
  8. walterf25

    walterf25 Well-Known Member Licensed User

    Impressive, wow, very nice.

    Walter
     
  9. JordiCP

    JordiCP Well-Known Member Licensed User

    Chathead Evolution. Expanding possibilities for a new app. Still a Frankenstein, but it breaths and moves!!!:D

     
  10. walterf25

    walterf25 Well-Known Member Licensed User

    Wow, this is pretty cool Jodi, great work!
     
  11. moster67

    moster67 Expert Licensed User

    It's really a nice library. Thank you.
    I tried your demo-app on my Nexus4 and it works fine. However, when trying it on an Genymotion emulator I got the following error "System.UI has stopped". The error continues to show. The trace is:
    Code:
    Process: com.android.systemui, PID: 6287
    java.lang.NullPointerException: Attempt 
    to invoke virtual method 'android.graphics.ColorFilter android.graphics.drawable.Drawable.getColorFilter()' on a null object reference
        at com.android.systemui.statusbar.NotificationTemplateViewWrapper.resolveViews(NotificationTemplateViewWrapper.java:82)
        at com.android.systemui.statusbar.NotificationTemplateViewWrapper.<init>(NotificationTemplateViewWrapper.java:
    66)
        at com.android.systemui.statusbar.NotificationViewWrapper.wrap(NotificationViewWrapper.java:
    38)
        at com.android.systemui.statusbar.NotificationContentView.setContractedChild(NotificationContentView.java:
    125)
        at com.android.systemui.statusbar.BaseStatusBar.inflateViews(BaseStatusBar.java:
    1389)
        at com.android.systemui.statusbar.BaseStatusBar.inflateViews(BaseStatusBar.java:
    1288)
        at com.android.systemui.statusbar.BaseStatusBar.createNotificationViews(BaseStatusBar.java:
    1713)
        at com.android.systemui.statusbar.phone.PhoneStatusBar.addNotification(PhoneStatusBar.java:
    1326)
        at com.android.systemui.statusbar.BaseStatusBar$
    5$1.run(BaseStatusBar.java:416)
        at android.os.Handler.handleCallback(Handler.java:
    739)
        at android.os.Handler.dispatchMessage(Handler.java:
    95)
        at android.os.Looper.loop(Looper.java:
    135)
        at android.app.ActivityThread.main(ActivityThread.java:
    5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:
    372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
    903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    698)
    Process com.android.systemui has crashed too many times: killing!
    I saw that in your other thread (Fly overlay) @Cableguy reported the same error and in this post, you mentioned that you fixed it. I am unsure if you needed to/did fix it also in your library/code you posted here...
    If not, I will try to track it down and see if I can find the solution.

    Edit: maybe the problem is because it is being run on the Genymotion emulator but in this moment I can only test on one physical device so it is hard to tell.
    Edit2: tested it on a Google emulator and it works...( am bit confused)

    Thank you.
     
    Last edited: Nov 2, 2016
  12. JordiCP

    JordiCP Well-Known Member Licensed User

    Hi Moster67,

    I think that it could be related, although not sure. The error seems to occur when setting up the notification icon. Try changing the line order where this notification is created, in oService-> Service_Created

    Code:
    '...
      'Notif needed for foreground service
       Snotif.Initialize
       Snotif.Icon=
    "icon"     '<----- MOVE THIS LINE HERE
       Snotif.SetInfo("ChatHead demo""Press to change settings", Main)
       
    'Snotif.Icon="icon"     '<----- AND REMOVE IT FROM HERE
       Snotif.Vibrate=False
       Snotif.Sound=
    False
       
    Service.StartForeground(1, Snotif)
    This happened with only some android version (5.1.1?) and/or a limited number of devices, still don't know why. Changing the line order, worked ok.

    Please tell me if this solves your issue and I will upload a version with this modification
     
  13. moster67

    moster67 Expert Licensed User

    Many thanks! Now it works also on the Genymotion emulator (which is running indeed Lollipop).
     
    cambopad likes this.
  14. cambopad

    cambopad Active Member Licensed User

    I tried to combine this with B4A Screen Recorder to allow user to record the screen from overlay button, but I always fail. :( Have you ever tried getting B4A Screen Recorder with this chat head function???
     
  15. peacemaker

    peacemaker Well-Known Member Licensed User

    Very good topic !
    Some suggestions:

    Code:
    Sub action_down(instance As Int)
    'Your code here
    Log("instance=" & instance)
    End Sub

    .....
    'in Java
    processBA.raiseEvent(null"action_down", index);
     
  16. Carlos marin

    Carlos marin Active Member Licensed User

    hola jordi. amigo eres un genio!!!... tengo una pregunta ya que veo que trabajas con esto, es que estoy haciendo un tipo de foro y necesito que cuando mando las cadenas de texto el label y panel se redimensione para mostrarme todo lo escrito. alguna idea?, por ejemplo en visual estudio utilizo el autosize, pero aqui no se como, me puedes dar una idea. muchas gracias.

    por cierto ami tambien me corrio sin problemas. tengo un azumi A55T
     
  17. JordiCP

    JordiCP Well-Known Member Licensed User

    Hola Carlos! Te envío un correo, pues este post es de un ChatHead pero nada que ver con la pregunta ;)
     
  18. panagiotisden2

    panagiotisden2 Member Licensed User

    hello jordi,

    is it possible to make something like facebook messenger chat heads?
    i want it to expand in full screen and contain a webview,a textbox and some buttons in it, can you help me?

    Thank you,
    Panos
     
  19. JordiCP

    JordiCP Well-Known Member Licensed User

    Hi,

    In fact this is just a wrapper-example for the chathead button only. It could be expanded to place whatever you want in it, but I don't think it is necessary. It can be made much simpler.

    If you want a whole screen with whatever you want inside it, I would do it in an activity. When you click the button, just launch this activity. And for instance, when you pause the activity, show the button again.
     
  20. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    And how can it be realized as shown in the video?

    And can the "X" as in the example, which was announced as comming soon was realized?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice