Coder Social home page Coder Social logo

halysongoncalves / pugnotification Goto Github PK

View Code? Open in Web Editor NEW
862.0 862.0 135.0 3.39 MB

A powerful library for creating notifications in android platform.

Home Page: http://halysongoncalves.github.io/Pugnotification

License: Apache License 2.0

Java 100.00%

pugnotification's People

Contributors

aminelaadhari avatar halysongoncalves avatar joaogouveia avatar r4md4c avatar rafaeltoledo avatar robertoestivill avatar seato avatar walmyrcarvalho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pugnotification's Issues

Buttons not showing in custom notification

This works fine and show the buttons:
PugNotification.with(this)
.load()
.title(...)
.message(...)
.smallIcon(...)
.largeIcon(..)
.button(...),
.button(...)
.simple()
.build();

This doesn't:
PugNotification.with(this)
.load()
.title(...)
.message(...)
.smallIcon(...)
.largeIcon(..)
.button(...),
.button(...)
.custom()
.build();

Handle resource ID in Load.color() properly

Load#color(int) throws an exception if the provided resource ID is less than or equal to 0. If it isn't, it propagates the input as-is to NotificationCompat.Builder#setColor(int). However, the latter method requires a resolved color, not a color resource ID!

Please handle color resources correctly, just like in Load#ticket(int). I'm proposing to change this:

public Load color(int color) {
    if (color <= 0) {
        throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!");
    }

    this.builder.setColor(color);
    return this;
}

to this:

public Load color(@ColorRes int color) {
    if (color <= 0) {
        throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!");
    }

    this.builder.setColor(PugNotification.mSingleton.mContext.getResources().getColor(color));
    return this;
}

"Notify Custom" in sample doesn't work

It seems the "Big Text" box is looking for a particular big text style and one is not provided by default so we'll see a crash "Big Text Style Must Not Be Empty!". It's not immediately clear what style should be referenced, but working code or a default value would be great.

Is it possible to use an image loading library other than Picasso ?

I'm using UIL in my application, and I don't want to add Picasso as a dependency.

Perhaps it is a good idea to add an interface for customizing the image loading operations ?

Something like

interface ImageLoader {
      public void load(String url, Drawable placeholder, Notification target);
}

Access to underlying notification

Hi,

Thanks for this useful library.

I have an IntentService which needs to be started in foreground. I could not find a way to get access to the underlying notification object. If I could have it, I can just pass it to the startForeground of my IntentService. Not having access to the same seems a bit limiting.

-Ankit

Support for Android N?

It'd be great to add support for features of notifications introduced in Android N .
Namely, RemoteInputs-quick reply and quick actions.

start a service on click

When passing activity to click it works without an issue, but if I pass an service class to it, it just doesn't fire.

Any ideas?

here's my code:

PugNotification.with(this)
                .load()
                .largeIcon(R.drawable.ic_notif)
                .smallIcon(R.drawable.ic_notif_small)
                .title("Start Service")
                .message("in background")
                .click(MyService.class)
                .simple()
                .build();

Manifest:

<service
            android:name=".MyService"
            android:enabled="true"
            android:exported="true"/>

Can I add FLAG_NO_CLEAR

Can I write this with pugnotification library ?

Notification noti = new NotificationCompat.Builder(this).setContentTitle("Title").setSmallIcon(R.drawable.icon).build();
noti.flags |= Notification.FLAG_NO_CLEAR;
nm.notify(MAIN_NOTIFICATION, noti);

Handle notifications

I have a question:

Is possible handle the notifications, for example if the user touch one notification, open or continue with another process?

I was reading your code, but I can't found how I could handle the notification

:)

Use custom loader for largeIcon

Is it possible to use a custom loader with the largeIcon option?
I want to load my image from the backend with a custom loader for the icon, but I could not find a way of doing it with custom loader.

Repeating notification

Is there any method to set repeating to the AlarmManager, so the notification can be displayed each week on a specific day for example ?

How to play a custom sound ?

I put a mp3 in a res/raw directory

Then

         PugNotification.with(getApplicationContext())
                        .load()
                        .title(item.getBottle().getName())
                        .message("Encore un vin dégusté par " + item.getUser().getName())//" + "\n" + item.getBottle().getName()) +"de "+item.getBottle().getVintage() +" en "+ new WineColor(Integer.parseInt(item.getBottle().getColor())).getColorToString() +
                        .bigTextStyle(item.getUser().getName() + " à dégusté un " + new WineColor(Integer.parseInt(item.getBottle().getColor())).getColorToString() + " nommé " + item.getBottle().getName() + " et lui à donné la note de " + item.getTasting().getRate())
                        .smallIcon(R.drawable.icon_notif)
                        .largeIcon(b)
                        .color(R.color.interaction)
                        .flags(Notification.DEFAULT_SOUND)
                        .sound(Uri.parse("android.resource://" + App.getContext().getPackageName() + "/" + R.raw.tire_bouchon3))
                        .custom()
                        .setImageLoader(NotificationService.this)
                        .background(item.getBottle().getLabelPicturePath())
                        .setPlaceholder(R.drawable.pugnotification_ic_placeholder)
                        .build();

Did I miss something ?

Working sample for clickable notification.

There's nothing in the library showing the correct way to use the API to pass the intent for clicks. It seems there's more to just calling Load.click(someActivity.class) since I've tried calling that in the sample code to no avail:

PugNotification.with(mContext).load()
                        .title(title)
                        .message(message)
                        .bigTextStyle(bigtext)
                        .smallIcon(R.drawable.pugnotification_ic_launcher)
                        .largeIcon(R.drawable.pugnotification_ic_launcher)
                        .color(android.R.color.background_dark)
                        .click(SampleActivity.class)
                        .custom()
                        .setImageLoader(SamplePugNotification.this)
                        .background(url)
                        .setPlaceholder(R.drawable.pugnotification_ic_placeholder)
                        .build();

I will be reading more about it, but it'd be nice to have a working example of this in the sample.

Load.bigTextStyle() API is misleading

The signature for Load.bigTextStyle() seems to have been copy pasted a few times to many and we have argument variables claiming to be bigTextStyle (as if a style resource) when it is in fact the big text.

Context being leaked?

Line 8 of PugNotification: public static PugNotification mSingleton = null; gives a warning:

Do not place Android context classes in static fields; this is a memory leak (and also breaks Instant Run)

A static field will leak contexts.

Any plans to address?

can't add a new flag

How to lock notification on status bar?
I using this configuration:

PugNotification.with(context).load()
.smallIcon(R.drawable.default_icon)
.title(push.title)
.autoCancel(true)
.message(push.alert)
.flags(Notification.DEFAULT_ALL | Notification.FLAG_AUTO_CANCEL)
.click(pIntent)
.simple().build();

But I can't to lock (fix) notification on status bar, so after swiping I can remove it.
This feature is working on my custom notification:

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder
            .setSmallIcon(R.drawable.status_bar_icon)
            .setWhen(System.currentTimeMillis())
            .setAutoCancel(true)
            .setContentTitle(appName)
            .setContentText(text)
            .setLights(0xffffffff, 1000, 3000)
            .setPriority(Notification.PRIORITY_HIGH)
            .setContentIntent(pIntent);

    builder.setVibrate(new long[]{500, 500, 250, 250, 250, 250, 250});
    Notification notification = builder.build();

    if (LOCK_MODE)
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(1, notification);

there are no specification or samples for advanced using

if the user click the notification, i want to do one of the following operations:
1,launch a activity;
2,open a url in the webview or browser outside;
......
how should i do?

i hope there is a sample for every case, thanks so much.

Custom Sound not playing

I'm using a custom sound and the sound doesn't seem to be playing. It's always defaulting to the default sound.

.sound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.letter_sent))

Why enforce main thread on Custom.build()?

Custom.build() checks that it's being called on the main thread while Simple.build() doesn't care for this. What's the purpose of this check? This makes it so that custom notifications cannot be called straightforwardly from services (if I'm listening for a push notification before shooting a notification).

How to send a daily notification - help

My goal is to show a notification daily on a user-chosen time. I tried Services and AlarmManager. Both failed because the service goes to sleep after a while and the AlarmManager has a bug in KitKat and I dont know how to handle it. Many tutorials are deprecated or simply wrong. So at the end I landed here. I can see that I can create a notification with your library very easy but I cant find an option to define when the notification shall get fired and in which interval.

Can you help me?

Priority doesn't accept negative values

An exception is thrown for br.com.goncalves.pugnotification.notification.Load#priority

Priority Should Not Be Less Than Or Equal To Zero!

The acceptable range for Notification priorities range from Acceptable values range from -2 (NotificationCompat.PRIORITY_MIN) to 2 (NotificationCompat.PRIORITY_MAX).

Vibrate

how to use .vibrate(vibrate)

Allow library to load large icon bitmap

What do you think about having the library taken care of the bitmap decoding for the large icon ?

I was thinking that maybe you can overload the method, something like the following:

public class Load {

    // Current method
    public Load largeIcon(Bitmap bitmap ) {
      ...
    }

    // New method
    public Load largeIcon(int largeIcon) {
        if (largeIcon <= 0) {
            throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!");
        }
        Bitmap bitmap = BitmapFactory.decodeResource( 
               mNotification.mContext.getResources(), largeIcon )
        this.mBuilder.setLargeIcon(bitmap);
        return this;
    }

Would you take a PR for this ?

String Charset

@halysongoncalves Is there any way to show native chars? Currently I'm using Turkish letters and they are not displayed correctly.

I've tried URLDecoder.decode("...", charset); but it's not fixing that problem.

Example without Picasso?

hi, I am trying to make this project work but with no luck so far. I tried for hours to do a hello world without Picasso but seems impossible. This is my code:

 PugNotification.with(this).load()
            .title("title")
            .message("message")
            .bigTextStyle("bigtext")
            .smallIcon(R.drawable.pugnotification_ic_launcher)
            .largeIcon(R.drawable.pugnotification_ic_launcher)
            .color(android.R.color.background_dark)
            .custom()
            .setImageLoader(new ImageLoader() {
                @Override
                public void load(String uri, OnImageLoadingCompleted onCompleted) {

                }

                @Override
                public void load(int imageResId, OnImageLoadingCompleted onCompleted) {

                }
            })
            .background(R.drawable.pugnotification_ic_launcher)
            .setPlaceholder(R.drawable.pugnotification_ic_placeholder)
            .build();

The result of this code is nothing shown after managing to create a dummy class to get rid of the continuous NullPointer. I do not understand why you need 3 images, a small icon, a large icon and a URL.

If you could provide a simpler example without Picasso would be very appreciated. Is this the reason that nothing is shown?

Regards

Image problem: drawable-nodpi\pugnotification_ic_placeholder.png

AAPT err(Facade for 1388311168): D:\Test\app\build\intermediates\exploded-aar\com.github.halysongoncalves\pugnotification\1.8.0\res\drawable-nodpi\pugnotification_ic_placeholder.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited.

Custom Font .

I have to use custom font in contentTitle And ContentText..
How can I use this in PugNotification ?

Add cancel(String, int) API to PugNotification

The PugNotification class doesn't provide a method that corresponds to NotificationManager#cancel(String, int) for tag-based cancelation of notifications:

public void cancel(String tag, int identifier) {
    NotificationManager notifyManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notifyManager.cancel(tag, identifier);
} 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.