Skip to content

Commit 8588a3c

Browse files
committed
Merge pull request #571 from tito/sdl2-intent-filters-add-jar
sdl2/bootstrap: add --add-jar and --intent-filters support
2 parents 49e287e + 28dd8c0 commit 8588a3c

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ def compile_dir(dfn):
198198

199199

200200
def make_package(args):
201-
url_scheme = 'kivy'
202-
203-
# Figure out versions of the private and public data.
204-
private_version = str(time.time())
205-
206201
# # Update the project to a recent version.
207202
# try:
208203
# subprocess.call([ANDROID, 'update', 'project', '-p', '.', '-t',
@@ -253,6 +248,14 @@ def make_package(args):
253248
shutil.copy(args.presplash or default_presplash,
254249
'res/drawable/presplash.jpg')
255250

251+
# If extra Java jars were requested, copy them into the libs directory
252+
if args.add_jar:
253+
for jarname in args.add_jar:
254+
if not os.path.exists(jarname):
255+
print('Requested jar does not exist: {}'.format(jarname))
256+
sys.exit(-1)
257+
shutil.copy(jarname, 'libs')
258+
256259
versioned_name = (args.name.replace(' ', '').replace('\'', '') +
257260
'-' + args.version)
258261

@@ -263,6 +266,10 @@ def make_package(args):
263266
version_code += int(i)
264267
args.numeric_version = str(version_code)
265268

269+
if args.intent_filters:
270+
with open(args.intent_filters) as fd:
271+
args.intent_filters = fd.read()
272+
266273
render(
267274
'AndroidManifest.tmpl.xml',
268275
'AndroidManifest.xml',
@@ -345,6 +352,16 @@ def parse_args(args=None):
345352
default=join(curdir, 'whitelist.txt'),
346353
help=('Use a whitelist file to prevent blacklisting of '
347354
'file in the final APK'))
355+
ap.add_argument('--add-jar', dest='add_jar', action='append',
356+
help=('Add a Java .jar to the libs, so you can access its '
357+
'classes with pyjnius. You can specify this '
358+
'argument more than once to include multiple jars'))
359+
ap.add_argument('--intent-filters', dest='intent_filters',
360+
help=('Add intent-filters xml rules to the '
361+
'AndroidManifest.xml file. The argument is a '
362+
'filename containing xml. The filename should be '
363+
'located relative to the python-for-android '
364+
'directory'))
348365

349366
if args is None:
350367
args = sys.argv[1:]

pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
<action android:name="android.intent.action.MAIN" />
5353
<category android:name="android.intent.category.LAUNCHER" />
5454
</intent-filter>
55+
{%- if args.intent_filters -%}
56+
{{- args.intent_filters -}}
57+
{%- endif -%}
5558
</activity>
5659
</application>
5760

58-
</manifest>
61+
</manifest>

0 commit comments

Comments
 (0)