android :: Notification :: _id
android :: Notification :: _number
Number to display on the bottom right part of the notificationandroid :: Notification :: _ongoing
Is this notification ongoing? Not user dismissable.android :: Notification :: _small_icon
Name of a resource found in theres/drawable-*
folders to use for the small icon
android :: Notification :: _tag
android :: Notification :: _ticker
Text to show in the bar as the notification appearsandroid :: Notification :: cancel
Cancel this notification and hide it if it is currently displayedandroid :: Notification :: defaultinit
android :: Notification :: id
android :: Notification :: id=
android :: Notification :: number
Number to display on the bottom right part of the notificationandroid :: Notification :: number=
Number to display on the bottom right part of the notificationandroid :: Notification :: ongoing
Is this notification ongoing? Not user dismissable.android :: Notification :: ongoing=
Is this notification ongoing? Not user dismissable.android :: Notification :: small_icon
Name of a resource found in theres/drawable-*
folders to use for the small icon
android :: Notification :: small_icon=
Name of a resource found in theres/drawable-*
folders to use for the small icon
android :: Notification :: tag
android :: Notification :: tag=
android :: Notification :: ticker
Text to show in the bar as the notification appearsandroid :: Notification :: ticker=
Text to show in the bar as the notification appearsandroid :: Notification :: was_shown
Was this notification shown withshow
?
android $ Notification :: SELF
Type of this instance, automatically specialized in every classandroid :: Notification :: _id
android :: Notification :: _number
Number to display on the bottom right part of the notificationandroid :: Notification :: _ongoing
Is this notification ongoing? Not user dismissable.android :: Notification :: _small_icon
Name of a resource found in theres/drawable-*
folders to use for the small icon
android :: Notification :: _tag
android :: Notification :: _ticker
Text to show in the bar as the notification appearsandroid :: Notification :: cancel
Cancel this notification and hide it if it is currently displayedcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
android :: Notification :: defaultinit
core :: Object :: defaultinit
android :: Notification :: id
android :: Notification :: id=
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.android :: Notification :: number
Number to display on the bottom right part of the notificationandroid :: Notification :: number=
Number to display on the bottom right part of the notificationandroid :: Notification :: ongoing
Is this notification ongoing? Not user dismissable.android :: Notification :: ongoing=
Is this notification ongoing? Not user dismissable.core :: Object :: output_class_name
Display class name on stdout (debug only).android :: Notification :: small_icon
Name of a resource found in theres/drawable-*
folders to use for the small icon
android :: Notification :: small_icon=
Name of a resource found in theres/drawable-*
folders to use for the small icon
android :: Notification :: tag
android :: Notification :: tag=
android :: Notification :: ticker
Text to show in the bar as the notification appearsandroid :: Notification :: ticker=
Text to show in the bar as the notification appearsandroid :: Notification :: was_shown
Was this notification shown withshow
?
# An Android notification, shown at the top of the screen
class Notification
# Title of this notification
var title: nullable Text is writable
# Text content of this notification
var text: nullable Text is writable
# Text to show in the bar as the notification appears
var ticker: nullable Text = null is writable
# Name of a resource found in the `res/drawable-*` folders to use for the small icon
#
# By default, we use the app's icon, named "icon". A valid icon must be used
# to display notifications.
var small_icon: nullable Text = null is writable
# Number to display on the bottom right part of the notification
var number: nullable Int = null is writable
# Is this notification ongoing? Not user dismissable.
var ongoing: Bool = false is writable
private var id: nullable Int = null
private var tag = "app.nit notification"
# Show the notification
fun show
do
sys.jni_env.push_local_frame(8)
var context = app.native_activity
var builder = new NativeNotificationBuilder(context)
# If no custom icon is specified, use app's
var small_icon = self.small_icon
if small_icon == null then small_icon = "icon"
var small_icon_id = app.resource_manager.other_id(small_icon.to_s, "drawable")
builder.small_icon = small_icon_id
# Other options
if title != null then builder.title = title.to_java_string
if text != null then builder.text = text.to_java_string
if ticker != null then builder.ticker = ticker.to_java_string
builder.ongoing = ongoing
var notif = builder.create
var manager = context.notification_manager
var id = self.id
if id == null then id = sys.next_notification_id
manager.notify(tag.to_java_string, id, notif)
self.id = id
sys.jni_env.pop_local_frame
end
# Was this notification shown with `show`?
#
# This does not indicates whether is has been dismissed or not. Only that
# it was shown at least once.
private fun was_shown: Bool do return id != null
# Cancel this notification and hide it if it is currently displayed
fun cancel
do
var id = self.id
if id != null then
sys.jni_env.push_local_frame(8)
var manager = app.native_context.notification_manager
manager.cancel(tag.to_java_string, id)
self.id = null
sys.jni_env.pop_local_frame
end
end
end
lib/android/notification/notification.nit:41,1--120,3