Android Code Snippet SD: MsgBox re-stylized

Star-Dust

Expert
Licensed User
There are many libraries that update and modify MsgBox and all interesting, but no one meets my needs.
So I created someone I did. I hope someone else might be useful.

It's not a library. Only snippets of code. Does not require any additional library. You can include on your sources or you can wrap them into Class.

msgbox3.png msgbox4.png msgbox5.png msgbox6.png


MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int
The parameters are the same as MsgBox2

MsgBox4(Message As String, Title As String, Positive As String, Cancel As String,Negative As String, GraficStyle As Int) As Int

GraficStyle
0 = Trapeze
1 = Ellisse
2 = Fringe
 

Attachments

Last edited:

Star-Dust

Expert
Licensed User
UPDATE:

Created MsgBox class and variation management screen orientation

Use:
B4X:
    Dim MsBox As SDMsgBox

    MsBox.Initialize(Activity)

    If MsBox.MsgBox4("Message","MsgBox4 - Style 0","Yes","","No",0)=DialogResponse.POSITIVE Then
        ToastMessageShow("YES",False)
    Else
        ToastMessageShow("No",False)
    End If
Method
MsgBox3
(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int
MsgBox4(Message As String, Title As String, Positive As String, Cancel As String,Negative As String, GraficStyle As Int) As Int
GraficStyle
0 = Trapeze; 1 = Ellisse; 2 = Fringe

Proprietes
Response
As int
' as DialogResponse

 
Last edited:

jnjft

Member
Licensed User
Hello Star-Dust!
Thanks a lot for the MsgBox-enhancements!
I have the issue, that after tapping on Ok or Cancel or No the MsgBox disappears, but the Activity stays dimmed. It is not until I tap on the sreen that the activity shows up with the normal brightness again.
What could be wrong?

Thanks for your effort
 

Star-Dust

Expert
Licensed User
Hello Star-Dust!
Thanks a lot for the MsgBox-enhancements!
I have the issue, that after tapping on Ok or Cancel or No the MsgBox disappears, but the Activity stays dimmed. It is not until I tap on the sreen that the activity shows up with the normal brightness again.
What could be wrong?

Thanks for your effort
The screen is darkened, giving the impression that the activity is paused. It's just a trick.
I open a transparent gray panel under the box. See the code below.
B4X:
Sub MsgBox3(Message As String, Title As String, Positive As String, Cancel As String,Negative As String) As Int
    Dim P, Box As Panel
    '...
    '...
    P.Initialize("PanelMsgBox3")
    P.Color=Colors.ARGB(210,10,10,10)
When you click on a button the panelle is removed, as in the code you see below
B4X:
Do While Box.Tag=""
        DoEvents
        DoEvents
        If P.Width<>GetDeviceLayoutValues.Width  Then
            Activity.Width=GetDeviceLayoutValues.Width
            Activity.Height=GetDeviceLayoutValues.Height
            P.Width=GetDeviceLayoutValues.Width
            P.Height=GetDeviceLayoutValues.Height
            Box.Left=P.Width/2-180dip
            Box.Top=P.Height/2-150dip
        End If
    Loop

Ret=Box.Tag
P.RemoveView ' PANEL GRAY REMOVED
Return Ret
If you have not modified the code it should work.

In any case, I suggest changing the code to no longer use the modal MsgBox, but the event one
This would avoid creating problems with the DoEvents.

For example, removing the block that I pasted on and modifying the click event of the three options (Yes, Cancel, No)
B4X:
Sub BMsgBox3_Click
    Dim B As Button = Sender
    Dim P As Panel = B.Parent
 
    P.Tag=B.Tag
    P.RemoveView ' Remove Panel Gray
End Sub
With these changes you can use the MessageBox also with the Wait For

Regard
 

jnjft

Member
Licensed User
Thanks for the reply!
I didn't change the code and I understand what you mean - alas, P.RemoveView doesn't remove the gray panel at my place.
I've come so far with logs:
- The loop Do While Box.Tag = "" is exited and Ret gets the contents of Box.Tag, but the next statement (P.RemoveView) fails
- When I touch the gray panel actively I enter PanelMsgBox3_Touch, and the code there does exactly what I want - remove the panel. Although it only contains the two statements
B4X:
Sub PanelMsgBox3_Touch (Action As Int, X As Float, Y As Float)
Dim P as Panel = Sender
P.RemoveView
 

jnjft

Member
Licensed User
Is there a possibility to simulate the panel touch event? I had no success with calling PanelMsgBox3_Touch(0, 10, 10).

Regards
Johann
 

Star-Dust

Expert
Licensed User
Make Public a Sub.
 
Top