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

Star-Dust

Expert
Licensed User
Longtime User
I will in the future.
Thanks four your great work.
The version is too old the framework has received many updates over time, the most important and with the introduction of resumable sub.
Since then we have lost a lot of compatibility with the past, we need to update and recompile with the new versions.

Even if they were available the old recompiled sources would not be compatible with your version. It would be necessary to compile it with your own version.
Also your version is not compatible with Android 6 specifications, runtime permission requests etc.
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, friends, I do not know if this message should go here.
Please, have a moderator move it, if he thinks it necessary. Thank you.

I am using this code and it works fine almost always. In some devices the keyboard is not always hidden. Sometimes yes, sometimes not.
What am I doing wrong?
B4X:
Sub InputBoxStringNew( cTitulo As String, cPregunta As String, cHintDefecto As String, cValorDefecto As String, cTxPos As String, cTxCan As String, bIsPassword As String ) As String
   Dim iRes As Int
   Dim id As BD_InputBoxParams
   id.Initialize
   id.Question = cPregunta
'''   id.QuestionTextSize = 18
'''   id.SpaceBetween = 4dip
   id.Hint = cHintDefecto
   id.Default = cValorDefecto
   id.InputTextSize = 24
   id.InputType = id.INPUT_TYPE_TEXT
   id.PasswordMode = bIsPassword   
'''   id.Gravity = Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
'''   id.ValidationCallback = "Input_Validation"
   id.WithSuggestions = True
   iRes = BD.InputBox(cTitulo,id,cTxPos,cTxCan,"",funciones.LoadDrawable("ic_menu_edit"))
   If iRes = DialogResponse.POSITIVE Then
       Return id.Answer
   Else
       Return funciones.RETURNCANCEL
   End If
End Sub
 

imbault

Well-Known Member
Licensed User
Longtime User
Hi Fred,
BD_InputBoxParams :
Is it possible to limit the length of the string in the BetterDialogs.InputBox, it should be usefull

Thanks
Patrick
 

brunnlechner

Member
Licensed User
Longtime User
Hello, is it possible under Android 10 that the dialog from the BetterDialogs example is filled out to the far right?
Thank You
Franz

1590186005936.png
 

brunnlechner

Member
Licensed User
Longtime User
BetterDialogs (Version: 2.11)
The Screenshot comes from the original example, only changes:
dlgParams.Background = Colors.RGB(50, 250, 50)
android:targetSdkVersion="29"
 

brunnlechner

Member
Licensed User
Longtime User
Thanks for the answer.

Original Example with Manifest: <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="28"/>

Samsung Galaxy S10

Screenshot_20200530-130529.jpg
 

artsoft

Active Member
Licensed User
Longtime User
Hi!

Short question:
I use my own customer font in my app together with BetterDialogs.

Sorry, if there is already asked this question, but:
Is there a way to set a typeface or a font-family or font-face command within a BD dialog?

Currently the complete font is set to my own font - but when a BD dialog appears, the font difference is very striking.

Thanks and regards
ARTsoft
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Thanks for the answer.

Original Example with Manifest: <uses-sdk android:minSdkVersion="7" android:I took the original example, I modified the targetSdkVersion of the manifesto and here is the result on a Samsung S10 emulated by Genymotion:="28"/>

Samsung Galaxy S10

View attachment 94938
I took the original example, I modified the targetSdkVersion of the manifest and here is the result on a Samsung S10 emulated by Genymotion:

2020-06-03_211841.png


I can't help you with your problem because I'm getting a result as expected. It really looks like you're using different code or different design (check the .bal file).
 

Informatix

Expert
Licensed User
Longtime User
Hi!

Short question:
I use my own customer font in my app together with BetterDialogs.

Sorry, if there is already asked this question, but:
Is there a way to set a typeface or a font-family or font-face command within a BD dialog?

Currently the complete font is set to my own font - but when a BD dialog appears, the font difference is very striking.

Thanks and regards
ARTsoft
Create a custom dialog. There's an example of custom dialog provided with the library.
 
Top