B4A Library ToastMessageShow v2.10

ToastMessageShow
Author:
Giuseppe Salvi
Version: 2.0
 

Attachments

  • ToastMessageShow v1.80.zip
    293 KB · Views: 1,473
  • Normal toast from  xml.png
    Normal toast from xml.png
    24.2 KB · Views: 2,392
  • Normal toast with nine-patch.png
    Normal toast with nine-patch.png
    27.4 KB · Views: 2,306
  • standard toast.png
    standard toast.png
    22.7 KB · Views: 2,123
  • Toast with button and bacckground image.png
    Toast with button and bacckground image.png
    117.4 KB · Views: 2,056
  • Toast with button background color and text shadow.png
    Toast with button background color and text shadow.png
    42.2 KB · Views: 2,045
  • Toast with buttton and resources nine-patch.png
    Toast with buttton and resources nine-patch.png
    81.7 KB · Views: 2,032
  • Toast with buttton and with background resources.png
    Toast with buttton and with background resources.png
    77.8 KB · Views: 2,108
  • Toast with buttton gradient and custom font.png
    Toast with buttton gradient and custom font.png
    190.4 KB · Views: 2,078
  • ToastMessageShowv2.10.zip
    50.2 KB · Views: 1,298
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi guys, toastmessageshow is updated to v2. What's new:

I have entirely rewritten the code. Now It is not just a simple toast but much more and with many news.

Now can customize it to your liking. for example: can be used as a toast or as message box.

Manages the life of a ToastMessageShow. Initially copied from the [ John Persano ] and adapted for ToastMessageShow.

Rounded Class initially copied from [ Vincent Mi ] and adapted for ToastMessageShow.


The zip contains a demo, the library, the license and a little explanation in pdf.

The res folder in the demo contains some examples of nine-patch and xml.

It can be created programmatically or via xml.

Added a new event DismissOnTouch

How to use it:

toast.create("Any Text Here") _ - At first
.WithTitle("Any Title Here") _
.
.
.
.
.
.withBackGroundColor("#246688FF").Show - At last
or
.withBackGroundGradientArray(arrays).Show - At last
or
.withBackGroundGradient("#FF1c71d3","#FF1c62d3").Show - At last
or
.withBackGroundResources("toast_green_circle").Show - At last
or
.withBackGroundImage(LoadBitmap(File.DirAssets,"a.jpg")).Show - At last
 
Last edited:

wes58

Active Member
Licensed User
Longtime User
I finally tried to use version 2 of the library, and have noticed the following (using the example in post #1, with some modifications to check different functions):
1. If I remove the buttons on the toast message then toast_Click, toast_LongClick doesn't do anything - the toast is not dismissed. They work fine with the buttons defined.

2. with the buttons defined the toast message occupies the whole width of the screen. After I removed the buttons, the toast is no longer the full width of the screen.
How can I change/define the size of the toast so it is the full width of the screen?

3. if I remove the buttons, then ".withDividerToTitle(True)" doesn't do anything - i.e. divider between the title and the text doesn't show.

4. What does toast_DismissOnTouch do. I couldn't get it to work.

Could you please have a look at those issues (unless I was doing something wrong?). For now, I have to go to previous version.

Hi guys, toastmessageshow is updated to v2. What's new:

I have entirely rewritten the code. Now It is not just a simple toast but much more and with many news.
 

ecastelli201

Member
Licensed User
Longtime User
ToastMessageShow
Author:
Giuseppe Salvi
Version: 2.0
Buongiorno Giuseppe, forse non ho capito niente, ma non riesco a scatenare nessun evento del toast.
Anche i due esempi della versione 1.8 e della 2.0 non mi scatenano nessun evento.
ho provato a mettere dei breakpoint su tutte le sub (click, longclick, buttonclick....) ma il programma non li raggiunge mai.
Come se il nome della sub fosse sbagliato.
Dove sbaglio ?

enrico
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Buongiorno Giuseppe, forse non ho capito niente, ma non riesco a scatenare nessun evento del toast.
Anche i due esempi della versione 1.8 e della 2.0 non mi scatenano nessun evento.
ho provato a mettere dei breakpoint su tutte le sub (click, longclick, buttonclick....) ma il programma non li raggiunge mai.
Come se il nome della sub fosse sbagliato.
Dove sbaglio ?

enrico

Ciao Enrico tu non sbagli, l'ho appena installata sul tab2 7 con Android 4.1.2 e funziona bene.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
I finally tried to use version 2 of the library, and have noticed the following (using the example in post #1, with some modifications to check different functions):
1. If I remove the buttons on the toast message then toast_Click, toast_LongClick doesn't do anything - the toast is not dismissed. They work fine with the buttons defined.

2. with the buttons defined the toast message occupies the whole width of the screen. After I removed the buttons, the toast is no longer the full width of the screen.
How can I change/define the size of the toast so it is the full width of the screen?

3. if I remove the buttons, then ".withDividerToTitle(True)" doesn't do anything - i.e. divider between the title and the text doesn't show.

4. What does toast_DismissOnTouch do. I couldn't get it to work.

Could you please have a look at those issues (unless I was doing something wrong?). For now, I have to go to previous version.


Hi, it work fine from android 4.1.2 to 5.

the events works only with button

the DismissOnTouch work touch outside of the dialog
 

wes58

Active Member
Licensed User
Longtime User
Hi, it work fine from android 4.1.2 to 5.

the events works only with button

the DismissOnTouch work touch outside of the dialog

Hi,
In version 1.8, Toast_Click event works on Toast without the buttons.

How about the other two questions - divider between the title and the message without the buttons, and the size of toast without the buttons? I would like to have a toast full width of the screen.
 

ecastelli201

Member
Licensed User
Longtime User
Hi,
In version 1.8, Toast_Click event works on Toast without the buttons.

How about the other two questions - divider between the title and the message without the buttons, and the size of toast without the buttons? I would like to have a toast full width of the screen.

Mmmh, I think to forget something or to make any mistake.
I am working with B4A ver 4.30, a 7"tablet with Android 4.2.1, a smartphone Android 4.4 and a smartphone 4.2.0.
Java is jdk1.7.0_65
The sample included in "toastmessageshow v1.8.zip" never works (only click events).
The sample included in "toastmessageshow v2.0.zip" works fine only with Android 4.4 device.
Tapping on buttons or toast, nothing happens, but if the toast is over an activity button, activity button fires the event.
It seems toast and button toast to be "transparent".
The "toast_done" event fires always perfectly.
Anything needed in manifest ?
Thank you,
enrico
 

wes58

Active Member
Licensed User
Longtime User
Hi Giuseppe,
I was interested why the width and height of the toast can't be set so I looked in your library (ver1.8) and noticed that parameters toast.width, and toast.height are used for setting the padding (left, right) and (top, bottom) of the toast layout. But how does the padding relate to the width/height of the screen? I think, if you want to use them to set the width and height of the layout you could use layout.setMinimumWidth(width) and layout.setMinimumHeight(height).
 

ecastelli201

Member
Licensed User
Longtime User
Hi Giuseppe,
I made other tests on your 2.0 library:
- with Android 4.4, tapping on buttons they goes down and events fires.
- with other versions of Android events never fires, and buttons doesn't go down.
Buttons works as "disabled" (but color is true).
Thank you,
enrico
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Giuseppe,
I made other tests on your 2.0 library:
- with Android 4.4, tapping on buttons they goes down and events fires.
- with other versions of Android events never fires, and buttons doesn't go down.
Buttons works as "disabled" (but color is true).
Thank you,
enrico
Hi Enrico, I tested it on android 4.1 to android 5.0 and work fine .

P.S.
I dont know if it work on android before 4.1. I tried it with emulator and doesnt work.
 

Harris

Expert
Licensed User
Longtime User
Is it possible to make the message text even larger?
This is from a Galaxy TAB 4 8.4 (4.4 KitKat).

The default toastmessage on the bottom renders larger text.


toast2.png



B4X:
Sub CustMsg( tmsg As String )

    toast.create(tmsg) _
    .withGravity(toast.Gravity.TOAST_CENTER) _
    .withTextColor(Colors.Black) _       
    .withTextStyle(toast.Typeface.BOLD) _
    .withAnimation(toast.Animation.FLY) _
    .withTextSize(toast.TextSize.VERY_LARGE) _
    .withTextPadding(10) _
    .withDuration(toast.Duration.LONG_DELAY) _
    .withBackGroundResources("round_blue").Show                                                     

End Sub


I have tried .withTextSize(40) but it has no effect...
Seems like 20 is the max...

My user base are old fellows - like me! We need large text to read - especially when then the toast clears after x seconds.

Thanks
 
Last edited:

Harris

Expert
Licensed User
Longtime User
Not to bug... but is 20
(Dip or otherwise) the gratest value ww can usse for textsize.
?thanks
 

Harris

Expert
Licensed User
Longtime User
I love this lib due to light weight and functionality - however most of my audience can not see it (read it) due to it's restricted text size (20 dip).

Any response would be helpful so I may look for an alternative, if required.

Thanks
 

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
The Toast Message does not fire close event on Android 4.1.2, when I have a button. Tested to 28 identical devices.
So I have to close my app and open it again!
I've tested it to another device with Android 4.1.2 and it works!!!
Is there any dependency missing from those devices???

Thank you in advance!
 
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User
Hello!
The Toast Message does not fire close event on Android 4.1.2, when I have a button. Tested to 28 identical devices.
So I have to close my app and open it again!
I've tested it to another device with Android 4.1.2 and it works!!!
Is there any dependency missing from those devices???

Thank you in advance!

Hi, Sonday I fix my computer I had problems with the computer reseller.

Anyway I'm back and I'll fix all plugins.

Sorry for the inconvenience
 

Kapelis

Member
Licensed User
Longtime User
Thanks for sharing, I am a novice, I know how to use buttons with msgbox2:
"...IF DialogResponse.POSITIVE Then..."

How i can do this with your library?
Thanks.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Thanks for sharing, I am a novice, I know how to use buttons with msgbox2:
"...IF DialogResponse.POSITIVE Then..."

How i can do this with your library?
Thanks.


Hi, code below:

B4X:
Sub toast_ButtonClick(Id As Int,Tag As Object)

The Id  Rerturns -1, -2, -3

-1 = first button
-2 = second button
-3 = third button


The Tag  Rerturns BTN_ID_1, BTN_ID_2, BTN_ID_3

BTN_ID_1 = first button
BTN_ID_2 = second button
BTN_ID_3 = third button


if Id = -1 then
  ExitApplication
end if

If "BTN_ID_1" = Tag  Then
   ExitApplication
End If


End Sub

Sub toast_ButtonLongClick(Id As Int,Tag As Object)
    toast.Cancel
    toast.create("Button Long Click").Show
End Sub
 

Kapelis

Member
Licensed User
Longtime User
Thank you very much, I am trying your new library ver. 2.0. I entered a little piece of code in your example:
B4X:
Sub toast_ButtonClick(Id As Int,Tag As Object)
If Id = -1 Then
    Msgbox("-1","")
else If Id = -2 Then
    Msgbox("-2","")
Else
    Msgbox("-3","")
End If
    toast.Cancel

End Sub

but when I install your app-example the phone crashes and restarts. After reboot i can use the app, does not crash anymore. I have no problem with the 1.80 library version. I have a Galaxy Note 3 neo rooted with KitKat 4.4.2.
I would like to ask you too, what is the meaning of this string in "Region Project Attributes "?
#CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s

Regards.
 
Last edited:
Top