-
Notifications
You must be signed in to change notification settings - Fork 59
Decorator Plugin Development
Decorator plug-in is responsible for tweaking the notification to provider better experience, such as design polishing, additional functionality and even Android Wear/Auto specific support.
Decorators from different developers may work in a pipeline to processing the notification one by one, ordered by "priority" attribute, which provide the hint for final ordering. (User will be allowed to re-order the decorators in settings in a future version)
Decorator is implemented by extending NevoDecoratorService
class. It has two basic methods:
-
apply() receives notification to be processed and applies modifications via various APIs on the
MutableStatusBarNotification
class, whosegetNotification()
will return aMutableNotification
instance with convenient APIs to assist notification tweaking. -
onNotificationRemoved() receives the event of notification removal. Nothing can be applied here except for invoking notification operation APIs on
NevoDecoratorService
. It's commonly used to keep internal state synchronized with notification visibility state.
Decorator with UI can request itself to be added to formula of specific app, with this activity API:
startActivityForResult(new Intent("com.oasisfeng.nevo.action.ACTIVATE_DECORATOR")
.putExtra("nevo.decorator", new ComponentName(this, MyDecorator.class))
.putExtra("nevo.target", "com.example.target.app"), requestCode);
To request removal from formula, use action com.oasisfeng.nevo.action.DEACTIVATE_DECORATOR
instead.
-
A sample project for app-specific decorator.
-
A sample project to take advantage of notification content as input to implement functionality supposedly impossible without root.
-
A collection of general-purpose decorators, which can be applied to various apps.
-
Notification sound and vibration may not be changed if the whole evolving procedure is too slow. So keep your decorator as efficient as possible.
-
Evolved notifications are not automatically removed by the originating app (e.g. when app is opened). This is an mechanism limitation in Android system, we have no proper solution yet for this at present.
-
On Android prior to 8.0, if the original notification has delete intent, it is triggered when the notification is evolved (due to the removal for substitution). This may have side effect on the notification behaviors of the originating app. Please test it carefully in decorator development.
-
Notification can only be altered, but not removed by 3rd-party decorators at present. It's a design choice to prevent notification loss caused by bugs or mis-configured settings in decorators. If you have different opinion on this decision, please feel free to discuss with us in issue tracker.
TODO