B4A Library [Lib, transparent] A dialog that closes automatically after a few seconds

Hello All!
Example, of use my the test version library: DialogMessage version 1.1


B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim dms As DialogMessages
    Dim bmp As Bitmap = LoadBitmapSample(File.DirAssets,"app_ico.png",48,48)
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    dms.Initialize
    dms.InputDialog(Me,Activity,30,"Message 1","Do you want to close the application?","Positive","Cancel","Negative",bmp,"mnuDialogResponse")
    dms.Show
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub mnuDialogResponse(result As Object)
    Try
        Select result
          Case DialogResponse.POSITIVE
              ToastMessageShow("Positive: " & result, True)
            ExitApplication
          Case DialogResponse.CANCEL
              ToastMessageShow("Cancel: "   & result, True)
            ExitApplication
          Case DialogResponse.NEGATIVE
              ToastMessageShow("Negative: " & result, True)
            dms.InputDialog(Me,Activity,0,"Message 5","THE END","","","",bmp,"mnuDialogResponse")
            dms.Show
        End Select
    Catch
        Log(LastException)
    End Try
End Sub
 

Attachments

  • Screenshot_1.png
    Screenshot_1.png
    476.1 KB · Views: 317
  • Screenshot_2.png
    Screenshot_2.png
    493.3 KB · Views: 287
  • DialogMessage Library 1.1.zip
    6.3 KB · Views: 203
Last edited:

Claudio Oliveira

Active Member
Licensed User
Longtime User
Looks really nice, @T201016!
I wasn't able to compile or run an example though...
Compilation claims for circleprogressmaster-3 lib, which is missing.
I copied circleprogressmaster.lib and xml to circleprogressmaster-3.lib and xml, so this issue was momentarily solved.
But after compiling, the app raises an error, saying there's a layout file missing: dialogmessagetransparent_01.bal

upload_2018-3-24_13-1-26.png


Please, take a look at it and if it's the case, include the missing files in post #1 or give us more details on how to use it.

In spite of that, it's a very nice and useful lib!
 

T201016

Active Member
Licensed User
Longtime User
Hi, Claudio!
that's exactly what I missed for my own applications,
especially with a transparent background,
and that the message window would be displayed for a period of time.
I hope that it will also be useful to your projects.

I attach the missing things ....
Regards
 

Attachments

  • dialog_messagetransparent_01.zip
    27.2 KB · Views: 167
Last edited:

Claudio Oliveira

Active Member
Licensed User
Longtime User
Hi, Claudio!
that's exactly what I missed for my own applications,
especially with a transparent background,
and that the message window would be displayed for a period of time.
I hope that it will also be useful to your projects.

I attach the missing things ....
Regards

Hey @T201016 !
Yeah, it's gonna be useful for me indeed.
I'm not home right now, but I'll give it a try when I get back home later on.
Thanks again, pal.
 

Claudio Oliveira

Active Member
Licensed User
Longtime User
Hi @T201016

I've just tried your lib, and it works pretty fine.
But I'd like to make some comments about it and give you a feedback.
- The countdown text size is too small. In fact it's almost unreadable on small screens. Besides, the countdown circle doesn't update. It starts at some point and stays the same to the end of countdown. Have you made any modifications to Johan Schoeman's CircleProgressMaster lib to create your own CircleProgressMaster-3 lib?

- The dialog isn't modal. I mean, I've called it from an activity with a listview, and the listview keeps capturing touch events behind the dialog. If DialogMessage is supposed to be modal, this shouldn't happen.
Here an important remark: making dialogs modal should be avoided.
Take a look at this post.

Now for some suggestions:
- Change the name of your response sub. Add an underscore (_) to it.
In your sample code, it would look like this:
B4X:
dms.InputDialog(Me,Activity,30,"Message 1","Do you want to close the application?","Positive","Cancel","Negative",bmp,"dms")

sub dms_Response(Response as int)

    <whichever code>

End Sub
This is due to the fact that in apps compiled with obfuscation, every sub without an underscore in its name will be obfuscated, and this will eventually lead to runtime error and app crash.

- Maybe you could implement this as a custom view instead of a library, so we wouldn't have to include an additional layout file in the app.

- You could expose the CircleProgressMaster object, so we would be able to customize its properties, like TextColor, TextSize and stuff...

You're in a good path.
I'm quite certain you'll end up with a very nice lib! (or Custom View ;))

Keep up the good work! :)
 
Last edited:

T201016

Active Member
Licensed User
Longtime User
Yes, of course you're right. The library is fresh and I will complement everything in subsequent versions. Your comments will also help me in the implementation. As for Johan Schoeman's CircleProgressMaster library - I have not improved anything yet.

I am glad that the fruit of my work as well as others also serves others ... I wish you a pleasant day!

Thank you for advice.
 
Last edited:

T201016

Active Member
Licensed User
Longtime User
----- update 2018.03.28 13:48 PM
Hello! @Claudio Oliveira
Here is the revised version of the v1.10 library according to several suggestions, see above.
I hope I have corrected all the mistakes I noticed. Probably not.;)

Additional recommended libraries:
circleprogressmaster (version: 1.00 lent from Johan Schoeman's - super lib!)
core (version: 4.92 or higher)
reflection (version: 2.40 or higher)
stringutils (version: 1.02 or higher)

Regards, good day.
 

Attachments

  • DialogMessage Libs 1.1.zip
    34.2 KB · Views: 180
  • Example.zip
    307.9 KB · Views: 171
Top