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

welu1805

Active Member
Licensed User
You are right: FileDialog is also a modal dialog. It seems to be right, that from one modal dialog not could be opened another modal dialog.

There is another library for dialogs: XtraViews. From XtraViews it is possible to call FileDialog because XtraViews are NOT real modal dialogs. But XtraViews don't work on all devices. I have a tablet LenovoPad YOGA Tablet 2-1050F with Android 5.0.1 where EVERY attempt to start a XtraViews dialog creates an error: InputChannel is not opened.

So I need to build my own pseudo modal dialog, from which I can call modal dialogs like FileDialog.
 

Lee Ogley

Member
Licensed User
Just getting my head around both B4A and also BetterDialogs.

I have a simple dialog that prompts the user of a code, and pops up the virtual numeric keyboard. When the use starts to enter a code, after pressing 1 key the size of the buttons on the dialog change, not by much, but it's bugging me. Any help would be appreciated.

The code I'm using is is below. I've also added screenshots of the button size changes.

B4X:
                    BetterDialogue.Initialize
                    BetterDialogue.InputType = BetterDialogue.INPUT_TYPE_NUMBERS
                    inputCode.InputBox("Please enter Cancel Code", BetterDialogue, "OK", "Cancel", "",Null)
                    sInputCode = BetterDialogue.Answer
 

Attachments

  • Before.jpg
    Before.jpg
    28.4 KB · Views: 161
  • After.jpg
    After.jpg
    29.6 KB · Views: 158

Informatix

Expert
Licensed User
Just getting my head around both B4A and also BetterDialogs.

I have a simple dialog that prompts the user of a code, and pops up the virtual numeric keyboard. When the use starts to enter a code, after pressing 1 key the size of the buttons on the dialog change, not by much, but it's bugging me. Any help would be appreciated.

The code I'm using is is below. I've also added screenshots of the button size changes.

B4X:
                    BetterDialogue.Initialize
                    BetterDialogue.InputType = BetterDialogue.INPUT_TYPE_NUMBERS
                    inputCode.InputBox("Please enter Cancel Code", BetterDialogue, "OK", "Cancel", "",Null)
                    sInputCode = BetterDialogue.Answer
I'm unable to reproduce your case. It seems that you use an old version of Android. What's this version?
 

Erel

Administrator
Staff member
Licensed User
Manifest editor. The default code should be:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
  android:normalScreens="true"
  android:smallScreens="true"
  android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
 

Lee Ogley

Member
Licensed User
AddManifestText(
<uses-sdk android:minSdkVersion="3" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:windowSoftInputMode="stateHidden|adjustPan"
android:anyDensity="true"/>)
 

Lee Ogley

Member
Licensed User
It's the old G1, we are in the process of upgrading all engineers to the G4 Play, but not tested it on a Play yet.
 

Stern0m1

Member
Licensed User
trying to compile after I setup this library and im getting "Cannot find: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\maskededittext.jar"

I did not put this library over there I put it in the additional library's path.
 

jimmyF

Active Member
Licensed User
HI,
I am using appCompat toolbar with the following settings in the manifest (which I would rather not change):
B4X:
<item name="android:textColorPrimary">#fff</item>
        <item name="android:colorBackground">#0098FF</item>

My code is as follow:
B4X:
Dim IP As BD_InputBoxParams

IP.Initialize
                    'IP.Question = "<I>Your name ? </I>"
                    IP.Question = "<B><I>New Tag Name ? </I></B>"
                    IP.QuestionTextSize = 18
                    IP.SpaceBetween = 4dip
                    IP.InputTextSize = 24
                   
                    'IP.InputType = IP.INPUT_TYPE_TEXT_WITH_CAPS
                    IP.InputType = IP.INPUT_TYPE_TEXT
                    IP.Gravity = Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
                    IP.ValidationCallback = "Input_Validation"
                    IP.WithSuggestions = True
                   
                    SelectedTagID= lstTags.CheckedList.Get(0)
                    IP.Default=edtNote.Text

Because my theme specifies white text in its menus, the default text above is white on a white background.
I tried this:

B4X:
      IP.Default="<Font Color=#000000>" & edtNote.Text & "</Font>"
But it just shows the full string in white text.
Is there a trick to getting black text? I really wou;d not like to change my popupmenu text colour from white.

Thanks for a great product.
 

jimmyF

Active Member
Licensed User
False alarm. I just discovered that I can have more than one <Style> in the manifest file.
Wow! Something new every day.
 

Inman

Well-Known Member
Licensed User
Since there is support for HTML tags, I was wondering if it is possible to display lists (ordered or unordered). Like with this code
HTML:
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
to display
  • Coffee
  • Tea
  • Milk
I am trying to display a changelog msgbox after each update, so some form of listing will be helpful. Thanks.
 

Informatix

Expert
Licensed User
Since there is support for HTML tags, I was wondering if it is possible to display lists (ordered or unordered). Like with this code
HTML:
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
to display
  • Coffee
  • Tea
  • Milk
Try and you'll know. HTML is not handled by my code so if that doesn't work, I won't be able to add the missing tag support.
 
Top