B4A Library Custom Notification Library: Barx

monki

Active Member
Licensed User
Longtime User
@barx @ NJDUDE

I have installed sdk 15 and it works fine.

Many Thank´s

monki
 

barx

Well-Known Member
Licensed User
Longtime User
@barx @ NJDUDE

I have installed sdk 15 and it works fine.

Many Thank´s

monki

Brilliant, thank you for letting us know.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Not for your own layout

Clear,

So this one is not when you want to use your own layout, that's the other library called custom notifications
 

barx

Well-Known Member
Licensed User
Longtime User
Clear,

So this one is not when you want to use your own layout, that's the other library called custom notifications

You use this one

I'm sorry for causing the confusion, this lib can do everything the 'other' one does plus a bit more. Also this doesn't require a separate notification object to be created first.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Pretty confusing indeed

Indeed it is pretty confusing because I see two libraries and two authors.

So if I would add my own layout I should rename it to mylayout and initialize it by using number 5?

And then I should put it in both layout and layout-15 because of the ICS bug?

WebView isn't supported in notifications?

Cheers,
 

thedesolatesoul

Expert
Licensed User
Longtime User

Okay, I have depreciated my library :sign0148:. This one has more features.

No you cannot have a webview in notifications. Only certain views are supported in a remote view. (Buttons, Labels, Panels, ImageViews, Progresbars)
 

barx

Well-Known Member
Licensed User
Longtime User

Yes call it 'mylayout' and initialize using (5). OR if it is similar to one of the presets, just edit the preset.

The -v15 version of the layouts vary slightly so that things line up nicely on ICS. Also the background color is hard coded (until a fix id released or I find a better solution). So it's not a simple copy from one to other. If you compare the 'twotextplusimage' files in both folders you will get the idea. Any issues creating -v15 layouts lets me know and I'll ty to help.

Don't forget to clean project after tinkering with these res files.

See tds's reply about webview.
 

barx

Well-Known Member
Licensed User
Longtime User
Updated to v1.01. Edited original post with details...
 

Kevin

Well-Known Member
Licensed User
Longtime User
I'm getting around to experimenting with this after posting about my problems with the stock notifications on certain devices.

Unfortunately, I can't get this to work.

The code below vibrates twice (as set to do for my testing) but nothing shows up in the Notification tray. Worse, if I uncomment the line that sets the icon, it force closes my app. And there is definitely an icon named "icon.png" in the res\drawable folder.

Not sure what I am missing here. I tried using android-8 SDK as well as android-15 as mentioned earlier in this thread.

If it makes a difference, this sub is being called from an activity but the sub itself is in a code module.

B4X:
ToggleNotificationIcon2 (OnOff As Boolean)
  Dim n1 As CustomNotification
  Dim v() As Long
  v = Array As Long (0,150,50,150)
  n1.Initialize (1)
  n1.AlertOnce =  True
  n1.SetIntent (Main)
  n1.SetCustomVibrate (v)
  n1.DefaultVibrate = False
  n1.DefaultLED = False
  n1.DefaultSound = False   
  n1.OnGoingEvent = True
  n1.SetTextSize ("title",14)
  n1.SetTextSize ("text",12)
  'n1.setIcon ("icon")
 
 
  If OnOff = True Then
    n1.SetText ("title", "Test Title")
    n1.SetText ("text", "Test subtext")
    n1.Notify (1)
      Else
        Try
          n1.Cancel (1)
            Catch
        End Try
  End If
End Sub

:sign0085:
 
Last edited:

barx

Well-Known Member
Licensed User
Longtime User

barx

Well-Known Member
Licensed User
Longtime User

I'm just about to test your code Kevin any chance of a log?
 

barx

Well-Known Member
Licensed User
Longtime User
@kevin, your code seems to work fine. 3 things for you to try.

1) I'm sure it just got missed off the 'copy/paste' but your sub posted above is missing just that. The sub keyword at the beginning.

2) make sure you copied the 'res' folder to your projects folder and made the file read only as described in the installation instructions. If you have done this step, just double check the layout files are there in 'Objects/res/layout/'

3) whenever you manually add any resources to your project (i.e copying over the res folder in this case) be sure to clean your project. 'Tools', 'Clean Project'.

thanks for trying the lib and hope this gets it sorted for you. Any tips on improving the user experience are welcomed.
 

Kevin

Well-Known Member
Licensed User
Longtime User
Yes, the missing "Sub" was a pasting error... Had to fix the post several times, kept getting the weird html formatting codes when previewing.

Anyway, I'll try to post the error log later (didn't even think to look at that), but after reading the first post again, I think I am missing something. Either in my head or in the zip file with the library in post one. I see no "res" folder in the zip, so I accidentally missed that step during installation. Maybe it is because I just woke up, but I'm a bit confused now.

Update:
Can I get a copy of all of the missing res files? I saw the demo zip someone else posted but I don't know what he may have customized in it. I plan to just use the default style for now (no custom xml layouts for the notification). I assume I don't need to do anything special, and it will just work on all versions of Android? I am guessing I need to reference Android-15 SDK in order for it to work on newer Android versions, and that it will also work on all older ones? Sorry for the noob questions, but I don't want to break my notifications for a bunch of people in my effort to fix them for a few.
 
Last edited:

barx

Well-Known Member
Licensed User
Longtime User
Very sorry for that kevin. I forgot to add the res folder to the zip when I did the minor update. Not very pro of me.

I'm away from home for a good few hours but will get it added when I get back and reply so you know its done. Really sorry for the confusion and trouble.

Sent from my HTC Desire Z
 

Kevin

Well-Known Member
Licensed User
Longtime User
No big deal on the missing files. At least it wasn't me just doing something wrong in my code. Not that that ever happens.

I'll check in a bit later to see if you've updated the zip.

I assume that if I don't use any custom layouts that it will look exactly like the stock B4A notification? I don't want to upset the masses by changing its appearance.
 

barx

Well-Known Member
Licensed User
Longtime User
OK, I have added the 'res' files as a separate zip to the original post so that in future I won't forget them

Extract the res.zip
Copy the 'res' folder to your projects 'Objects' folder and make all files copied withing the res folder 'Read-Only'.

As you have done already, using layout '1' on the initialize uses a layout that mimics the standard notification.

Test it out and see if it looks exact enough, I think it is the same
If it is not quite right, give me a shout and I'm sure we can sort it out.

The best way to test it would be to create a copy of your project and work on that one, then if it isn't to your liking, you simple go back to the old one.

hope this helps
 

Kevin

Well-Known Member
Licensed User
Longtime User
Got it working now, thanks!

It does look a bit different. The icon is bigger than standard and the fonts sizes are a bit different, along with no time at the right.

I was going to play with the jar file but as it is not plain text, I don't really have a clue. Is there an easy way for me to use the custom settings (sounds, vibration, etc) but use non-custom / stock layouts? In other words, specifiy the other options but not a layout?

From the SDK, it appears you are always specifying a layout (which obviously is a big part of your library, to use custom notifications) as mentioned in the quote below? I guess what I would like to do is just use the standard layout if possible?


I really hate to sound so picky, but it does look a bit different from the others, at least on my phone.
 

Attachments

  • notification.jpg
    32 KB · Views: 350

barx

Well-Known Member
Licensed User
Longtime User
Ahh yes I can see the differences.

We have 2 options here. Either edit the layout files to try and make it match the default (Shouldn't be too hard) or I can have a go at a new library that will simply extend the standard notification object (So layout will be exact).

btw the layouts files are in res/layout/ and the file in use for you is 'twotextplusimage'. if you open it with notepad you will see the xml code. it may or may not make sense to you.

Let me know which way you wish to go and I'll try to get it complete this evening for you. UK Time.

NOTE: I will eventually do both these tasks but will do the one that suits you best first
 

Kevin

Well-Known Member
Licensed User
Longtime User
I definitely don't want to create more work for you. I thought about trying to edit the XML but my concern there was that even if I get it to look right on my device, would it look right on all of the others.

If I knew how to do it, what I would want to do is just add the customizable vibration patterns, etc to the stock B4A notification object. That would allow me to keep them identical in appearance but also attempt to work around the device-specific vibration issues I am seeing.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…