B4A Library [Lib] BetterDialogs

I tried to improve the most useful dialogs of the Dialogs library. In my version, HTML tags are interpreted (even in the text of buttons), the InputBox uses a Masked EditText and has more options, you can check if the input is valid before closing the dialog, and the CustomDialog is fully customizable. I also solved an issue with the virtual keyboard.

MsgBox (under Gingerbread and JellyBean):

msgbox.png


InputBox (under Gingerbread and JellyBean):

inputbox.png


CustomDialog (under Gingerbread and JellyBean):

cd1.jpg


Another CustomDialog (under Gingerbread and JellyBean):

cd2.png


v1.1:
- I added a CloseDialog function;
- I added a margin parameter to the custom dialog.

v1.2:
- I fixed a bug in InputBox when there's a default value;
- I added the BackKeyPressed event for custom dialogs.

v1.3:
- I added a PasswordMode option to the InputBox;
- I added a CancelOnTouchOutside option.

v1.4:
- I added a CursorPosition option to the InputBox.

v2.0:
- I moved the CustomDialog parameters to the BD_CustomDlgParams class.
- I added two new parameters: Duration and DialogGravity.
- I removed the Margin parameter and added the MarginHeight parameter (to be used when Gravity is set to TOP).
- The BodyWidth and BodyHeight parameters defines now accurately the size of the dialog body.

v2.1:
- I added a "closing" event raised just before a custom dialog is dismissed. You can cancel the closure by returning False.

v2.11:
- I added the "DlgResponse" parameter to the Closing event.

This library does not work with Android versions < 2.
It requires another library: Masked EditText
 

Attachments

  • BetterDialogs v2.11.zip
    55.6 KB · Views: 2,390
  • Java source - BetterDialogs.zip
    8.5 KB · Views: 766
Last edited:

Dario126

Member
Licensed User
Longtime User
How would I implement countdown timer for your's custom dialogs?

I tried to start timer before calling dialog.
Then load prepared layout into dialog, there is one label.
In timer event I try to change text on that label, and close dialog after 10 sec, but timer event is not happening while dialog is on screen?

I have notice only GPS change events happening while dialog is on ..
 

Informatix

Expert
Licensed User
Longtime User
How would I implement countdown timer for your's custom dialogs?

I tried to start timer before calling dialog.
Then load prepared layout into dialog, there is one label.
In timer event I try to change text on that label, and close dialog after 10 sec, but timer event is not happening while dialog is on screen?
I have notice only GPS change events happening while dialog is on ..
When the dialog is displayed, all B4A events (the events raised and processed by B4A, not all the events) cannot be properly handled. You have to write your own timer library in Java to get rid of this limitation.
 

Dario126

Member
Licensed User
Longtime User
When the dialog is displayed, all B4A events (the events raised and processed by B4A, not all the events) cannot be properly handled. You have to write your own timer library in Java to get rid of this limitation.

just got some idea (can not test until tomorrow) .. if I have separate background process, and put timer into that process, can I then change text of label which is loaded into better dialog (custom panel is designed as layout, label defined in global) from that background service?
 

Informatix

Expert
Licensed User
Longtime User
just got some idea (can not test until tomorrow) .. if I have separate background process, and put timer into that process, can I then change text of label which is loaded into better dialog (custom panel is designed as layout, label defined in global) from that background service?
I don't know exactly how you want to implement this, but it looks to me a bit complicated. If you want to use a very simple workaround (but not elegant at all), add an Accelerated Surface in your BetterDialogs, then call StartRegularUpdateAndDraw to raise the Update event regularly.
 

Dario126

Member
Licensed User
Longtime User
I don't know exactly how you want to implement this, but it looks to me a bit complicated. If you want to use a very simple workaround (but not elegant at all), add an Accelerated Surface in your BetterDialogs, then call StartRegularUpdateAndDraw to raise the Update event regularly.


Unbelievable, I was avoiding this as last resort, but it really works and it's not complicated to implement.
Also, this library look very powerful. Congrats on Your good work ..
 

Oswald

Member
Licensed User
Longtime User
hello Informatix
thanx for this great lib. I have a question,
how can I add one more line in two the below code.
first one for the name second one for the lastname?

Dim IP As BD_InputBoxParams
IP.Initialize
IP.Question = "<I>Your name ? </I>"
IP.QuestionTextSize = 18
IP.SpaceBetween = 4dip
IP.InputTextSize = 24
IP.InputType = IP.INPUT_TYPE_TEXT_WITH_CAPS
IP.Gravity = Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
IP.ValidationCallback = "Input_Validation"
IP.WithSuggestions = True
DR = BD.InputBox("Profile", IP, "OK", "","", LoadDrawable("ic_menu_edit"))
Log("DR=" & DR)
If DR = DialogResponse.POSITIVE Then
Log(IP.Answer)
ToastMessageShow(IP.Answer,True)
Log(IP.CompactAnswer)
ToastMessageShow(IP.CompactAnswer,True)
End If
 

Informatix

Expert
Licensed User
Longtime User
hello Informatix
thanx for this great lib. I have a question,
how can I add one more line in two the below code.
first one for the name second one for the lastname?

Dim IP As BD_InputBoxParams
IP.Initialize
IP.Question = "<I>Your name ? </I>"
IP.QuestionTextSize = 18
IP.SpaceBetween = 4dip
IP.InputTextSize = 24
IP.InputType = IP.INPUT_TYPE_TEXT_WITH_CAPS
IP.Gravity = Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
IP.ValidationCallback = "Input_Validation"
IP.WithSuggestions = True
DR = BD.InputBox("Profile", IP, "OK", "","", LoadDrawable("ic_menu_edit"))
Log("DR=" & DR)
If DR = DialogResponse.POSITIVE Then
Log(IP.Answer)
ToastMessageShow(IP.Answer,True)
Log(IP.CompactAnswer)
ToastMessageShow(IP.CompactAnswer,True)
End If

Create a custom dialog with two Masked EditTexts.
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Hi:

Having a few problems with your BetterDialogs - CustomDialog

1st, I downloaded the 1.41 zip but I am only seeing it as 1.40 in my Libs area? Any reason for this?

2nd, If I use 0dip for Margin my Panel is being truncated. By 10dip. If I use 10dip my whole panel is shown (I am passing the Width and Height of the Panel as show in Designer)

3rd, There is a 1 (guessing) pixel frame all around my dialog panel. My panels have rounded corners and I can see the square edges of this 1 pixel border.
I have tried using Null as the color and tried Colors.Transparent as well but this 1 pixel border still shows.

4th, I am getting a warning: (aInputData, 823) Panel.LoadLayout should only be called after the panel was added to its parent. (warning #1001)
Get this warning every time I am setting up for a CustomDialog call

Can you help with any of these? Everything is working fine, the 1 pixel (dotted border) is a little ugly

Thanks, very nice library

BobVal
 

Informatix

Expert
Licensed User
Longtime User
Having a few problems with your BetterDialogs - CustomDialog

1st, I downloaded the 1.41 zip but I am only seeing it as 1.40 in my Libs area? Any reason for this?

2nd, If I use 0dip for Margin my Panel is being truncated. By 10dip. If I use 10dip my whole panel is shown (I am passing the Width and Height of the Panel as show in Designer)

3rd, There is a 1 (guessing) pixel frame all around my dialog panel. My panels have rounded corners and I can see the square edges of this 1 pixel border.
I have tried using Null as the color and tried Colors.Transparent as well but this 1 pixel border still shows.

4th, I am getting a warning: (aInputData, 823) Panel.LoadLayout should only be called after the panel was added to its parent. (warning #1001)
Get this warning every time I am setting up for a CustomDialog call

Can you help with any of these? Everything is working fine, the 1 pixel (dotted border) is a little ugly

1) I don't know where you found the version 1.41. The last one is 1.40.
2) To avoid a visual issue with some versions of Android, you should keep a margin of at least 10dip.
3) Don't try to adjust things only for your device and run your dialog under different versions of Android. You may be surprised by some results.
4) You can ignore it.
 

RVP

Active Member
Licensed User
Longtime User
I am using this and setting the PasswordMode = True. However there is a security issue here in that the spell helper adds the password you have typed in to its list after a couple of times entering it. Anyway you can think of to stop the spell helper from showing?
 

RVP

Active Member
Licensed User
Longtime User
Nope, never saw that, or saw it and didn't think it meant speller

I will do that, thanks
 

pesquera

Active Member
Licensed User
Longtime User
Hi Informatrix, your job is brillant!
I did a form for filling a listview. Used labels, textboxs, buttons and checkboxs.. no need to créate another activity.. awesome!
But, when the device goes to sleep mode this form is closed because it is modal
Is there any trick to force that modal window not to close?
Else, how can I prevent the device going to sleep mode while I'm editing on that window?
Thanks in advance
 

GMan

Well-Known Member
Licensed User
Longtime User
Hoi,

preventing the phone to go to sleep is like this with the PHONE lib:

B4X:
Sub Globals
Dim Wakemaster As PhoneWakeState

' Call anywhere:
Wakemaster.KeepAlive(True)
 
Top