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,369
  • Java source - BetterDialogs.zip
    8.5 KB · Views: 749
Last edited:

peacemaker

Expert
Licensed User
Longtime User
HI,
But how to setup the editing text color ? Sometimes the text is invisible over the same background color :(
 

peacemaker

Expert
Licensed User
Longtime User
InputBox uses the default colors for its EditText. If you don't like these colors, create a custom dialog with your favourite ones. You can see such a dialog with an EditText in the demo.
Thanks. Is default color always OK for background color that can be changed by device user color scheme ?
 

elombert

New Member
Licensed User
Longtime User
Hi Informatix,
I am using a customdialog using your Betterdialogs library and I added a Customview to use the AnotherDatePicker to a layout which I show on the customdialog.
All works fine but when I tap on the customview, the AnotherDatePicker dialog shows behind the customdialog from Betterdialogs.

Any idea on how can I change that?
Please, find attached a modified version of the TestDialog demo that shows the exposed situation.

Thanks a lot in advance,

Ellis Lombert
 

Attachments

  • TestDialogs_modified.zip
    45.4 KB · Views: 265

Informatix

Expert
Licensed User
Longtime User
Hi Informatix,
I am using a customdialog using your Betterdialogs library and I added a Customview to use the AnotherDatePicker to a layout which I show on the customdialog.
All works fine but when I tap on the customview, the AnotherDatePicker dialog shows behind the customdialog from Betterdialogs.

Any idea on how can I change that?
Please, find attached a modified version of the TestDialog demo that shows the exposed situation.

Thanks a lot in advance,

Ellis Lombert
Obviously, your AnotherDatePicker panel is added to the activity behind the modal dialog, and not to the panel of the dialog. You should ask why to his author. There's maybe a bug to identify the right parent or you did not set this AnotherDatePicker properly.
 

JdV

Active Member
Licensed User
Longtime User
Hi

I have a small issue with adding a scrollview to a custom dialog box. The scrollview's panel loads a file containing 12 check boxes. (See zip file for full program.)

When the BodyHeight and BodyWidth options are set to 50% the list can be scrolled all the way down to expose the last check box.
50pct.png
When the BodyHeight and BodyWidth options are set to 80% the panel containing the buttons at the bottom of the dialog box partially cover the last options in the list.
80pct.png

Regards

Joe
 

Attachments

  • BDScroll.zip
    9 KB · Views: 260

Informatix

Expert
Licensed User
Longtime User
Hi

I have a small issue with adding a scrollview to a custom dialog box. The scrollview's panel loads a file containing 12 check boxes. (See zip file for full program.)

When the BodyHeight and BodyWidth options are set to 50% the list can be scrolled all the way down to expose the last check box.
View attachment 42204
When the BodyHeight and BodyWidth options are set to 80% the panel containing the buttons at the bottom of the dialog box partially cover the last options in the list.
View attachment 42205

Regards

Joe
The explanation is rather simple: 80%y is too much for you screen. The title and the buttons at the bottom have also a height and it must be taken into account. So 100%y - title height - buttons height > 80%y. The scrollview cannot be displayed entirely. Set the body height to 100%y - 100dip and that should be fine.
 

JdV

Active Member
Licensed User
Longtime User
The explanation is rather simple: 80%y is too much for you screen. The title and the buttons at the bottom have also a height and it must be taken into account. So 100%y - title height - buttons height > 80%y. The scrollview cannot be displayed entirely. Set the body height to 100%y - 100dip and that should be fine.

Thanks for the info.

Is there a way of finding out the height of the title and button panels?

For example: If I wanted to have the entire dialog box occupy 90%x and 90%y of the available screen, how would I size the scroll view accordingly?

Joe
 

padvou

Active Member
Licensed User
Longtime User
If you mean "to the EditText of the InputBox", then it's not needed. "Done" is what's expected. Why would you want to change it to Next?
I have a textbox in the same activity which needs "Done" and runs some code when Done is pressed.
However this code must not run when Done is pressed in the BD InputBox.
 

Informatix

Expert
Licensed User
Longtime User
I have a textbox in the same activity which needs "Done" and runs some code when Done is pressed.
However this code must not run when Done is pressed in the BD InputBox.
??? The BD is modal so when it is displayed, you cannot select an EditText outside of it. The soft keyboard will work only with the BD EditText while it's on screen. No confusion is possible.
 

Dave O

Well-Known Member
Licensed User
Longtime User
In custom dialogs, is it possible to validate fields at the field level (e.g. lost focus) or before clicking OK?

Related question: Is it possible to enable/disable OK programmatically (e.g. if a field value is missing or not valid)?

Merci!
 

Informatix

Expert
Licensed User
Longtime User
In custom dialogs, is it possible to validate fields at the field level (e.g. lost focus) or before clicking OK?
This question is related to the view that you use in your custom dialog, not the dialog itself, so I cannot give an answer.

Related question: Is it possible to enable/disable OK programmatically (e.g. if a field value is missing or not valid)?
Idem. That concerns the IME or the view, not the dialog.
 
Top