Skip to content

Commit 5c8b109

Browse files
committed
Custom actions and categories for BroadcastReceiver
android.broadcast.BroadcastReceiver now accepts non-standard actions & categories. Detects by checking the presence of '.' on the name of it
1 parent 86f96bf commit 5c8b109

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

recipes/android/src/android/broadcast.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,26 @@ def __init__(self, callback, actions=None, categories=None):
2929
resolved_actions = []
3030
if actions:
3131
for x in actions:
32-
name = 'ACTION_{}'.format(x.upper())
33-
if not hasattr(Intent, name):
34-
raise Exception('The intent {} doesnt exist'.format(name))
35-
resolved_actions += [getattr(Intent, name)]
32+
if '.' in x:
33+
full_name = x
34+
else:
35+
name = 'ACTION_{}'.format(x.upper())
36+
if not hasattr(Intent, name):
37+
raise Exception('The intent {} doesnt exist'.format(name))
38+
full_name = getattr(Intent, name)
39+
resolved_actions += [full_name]
3640

3741
resolved_categories = []
3842
if categories:
3943
for x in categories:
40-
name = 'CATEGORY_{}'.format(x.upper())
41-
if not hasattr(Intent, name):
42-
raise Exception('The intent {} doesnt exist'.format(name))
43-
resolved_categories += [getattr(Intent, name)]
44+
if '.' in x:
45+
full_name = x
46+
else:
47+
name = 'CATEGORY_{}'.format(x.upper())
48+
if not hasattr(Intent, name):
49+
raise Exception('The intent {} doesnt exist'.format(name))
50+
full_name = getattr(Intent, name)
51+
resolved_categories += [full_name]
4452

4553
# resolve android API
4654
PythonActivity = autoclass('org.renpy.android.PythonActivity')

0 commit comments

Comments
 (0)