@@ -24,31 +24,26 @@ def __init__(self, callback, actions=None, categories=None):
24
24
if not actions and not categories :
25
25
raise Exception ('You need to define at least actions or categories' )
26
26
27
+ def _expand_partial_name (partial_name ):
28
+ if '.' in partial_name :
29
+ return partial_name # Its actually a full dotted name
30
+ else :
31
+ name = 'ACTION_{}' .format (partial_name .upper ())
32
+ if not hasattr (Intent , name ):
33
+ raise Exception ('The intent {} doesnt exist' .format (name ))
34
+ return getattr (Intent , name )
35
+
27
36
# resolve actions/categories first
28
37
Intent = autoclass ('android.content.Intent' )
29
38
resolved_actions = []
30
39
if actions :
31
40
for x in actions :
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 ]
41
+ resolved_actions += [_expand_partial_name (x )]
40
42
41
43
resolved_categories = []
42
44
if categories :
43
45
for x in categories :
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 ]
46
+ resolved_categories += [_expand_partial_name (x )]
52
47
53
48
# resolve android API
54
49
PythonActivity = autoclass ('org.renpy.android.PythonActivity' )
0 commit comments