android-notify 0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of android-notify might be problematic. Click here for more details.

File without changes
File without changes
android_notify/core.py ADDED
@@ -0,0 +1,60 @@
1
+ from jnius import autoclass
2
+ import random
3
+
4
+ def send_notification(title, message, style=None, image=None, channel_id="default_channel"):
5
+ """
6
+ Send a notification on Android.
7
+
8
+ :param title: Title of the notification.
9
+ :param message: Message body.
10
+ :param style: Style of the notification ('big_text', 'big_picture', 'inbox').
11
+ :param image: Image URL or drawable for 'big_picture' style.
12
+ :param channel_id: Notification channel ID.
13
+ """
14
+ # Get the required Java classes
15
+ PythonActivity = autoclass('org.kivy.android.PythonActivity')
16
+ NotificationManager = autoclass('android.app.NotificationManager')
17
+ NotificationChannel = autoclass('android.app.NotificationChannel')
18
+ NotificationCompatBuilder = autoclass('androidx.core.app.NotificationCompat$Builder')
19
+ NotificationCompatBigTextStyle = autoclass('androidx.core.app.NotificationCompat$BigTextStyle')
20
+ NotificationCompatBigPictureStyle = autoclass('androidx.core.app.NotificationCompat$BigPictureStyle')
21
+ NotificationCompatInboxStyle = autoclass('androidx.core.app.NotificationCompat$InboxStyle')
22
+ BitmapFactory = autoclass('android.graphics.BitmapFactory')
23
+
24
+ # Get the app's context and notification manager
25
+ context = PythonActivity.mActivity
26
+ notification_manager = context.getSystemService(context.NOTIFICATION_SERVICE)
27
+
28
+ # Notification Channel (Required for Android 8.0+)
29
+ if notification_manager.getNotificationChannel(channel_id) is None:
30
+ channel = NotificationChannel(
31
+ channel_id,
32
+ "Default Channel",
33
+ NotificationManager.IMPORTANCE_DEFAULT
34
+ )
35
+ notification_manager.createNotificationChannel(channel)
36
+
37
+ # Build the notification
38
+ builder = NotificationCompatBuilder(context, channel_id)
39
+ builder.setContentTitle(title)
40
+ builder.setContentText(message)
41
+ builder.setSmallIcon(context.getApplicationInfo().icon)
42
+
43
+ # Apply styles
44
+ if style == "big_text":
45
+ big_text_style = NotificationCompatBigTextStyle()
46
+ big_text_style.bigText(message)
47
+ builder.setStyle(big_text_style)
48
+ elif style == "big_picture" and image:
49
+ bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(image))
50
+ big_picture_style = NotificationCompatBigPictureStyle()
51
+ big_picture_style.bigPicture(bitmap)
52
+ builder.setStyle(big_picture_style)
53
+ elif style == "inbox":
54
+ inbox_style = NotificationCompatInboxStyle()
55
+ for line in message.split("\n"):
56
+ inbox_style.addLine(line)
57
+ builder.setStyle(inbox_style)
58
+
59
+ # Show the notification
60
+ notification_manager.notify(random.randint(0, 100), builder.build())
@@ -0,0 +1,4 @@
1
+ class NotificationStyles:
2
+ BIG_TEXT = "big_text"
3
+ BIG_PICTURE = "big_picture"
4
+ INBOX = "inbox"
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.1
2
+ Name: android_notify
3
+ Version: 0.1
4
+ Summary: A Python package for sending Android notifications.
5
+ Requires-Dist: pyjnius
@@ -0,0 +1,8 @@
1
+ android_notify/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ android_notify/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ android_notify/core.py,sha256=jBIoLL60Fuxy5AL9G62ZgBWE1ga8YVG8joQsKQzaaJE,2686
4
+ android_notify/styles.py,sha256=OJBh-a2d_iOPcv50n_wUXezmh8Oc9MKDwM7c-RjkLAI,104
5
+ android_notify-0.1.dist-info/METADATA,sha256=VN2Je_QPndtGpddzr99dnBwTv0jJr2BONTWJArZYgBU,140
6
+ android_notify-0.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
7
+ android_notify-0.1.dist-info/top_level.txt,sha256=IR1ONMrRSRINZpWn2X0dL5gbWwWINsK7PW8Jy2p4fU8,15
8
+ android_notify-0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ android_notify