Skip to content

Commit d635581

Browse files
committed
fixed entrypoint option and added several others for integration of native android activities
1 parent 06b5958 commit d635581

File tree

3 files changed

+84
-43
lines changed

3 files changed

+84
-43
lines changed

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,30 @@ def parse_args(args=None):
665665
'https://developer.android.com/guide/'
666666
'topics/manifest/'
667667
'activity-element.html'))
668+
669+
ap.add_argument('--android-entrypoint', dest='android_entrypoint',
670+
default='org.kivy.android.PythonActivity',
671+
help='defines which java class sill be used for startup, usually a subclass of PythonActivity')
672+
ap.add_argument('--android-apptheme', dest='android_apptheme',
673+
default='@android:style/Theme.NoTitleBar',
674+
help='defines which app theme should be selected for the main activity')
675+
ap.add_argument('--add-java-source-compat', dest='java_source_compat',
676+
default=[],
677+
action='append',
678+
help='add java source compatibility to gradle.build')
679+
ap.add_argument('--add-java-target-compat', dest='java_target_compat',
680+
default=[],
681+
action='append',
682+
help='add java target compatibility to gradle.build')
683+
ap.add_argument('--add-gradle-repository', dest='gradle_repositories',
684+
default=[],
685+
action='append',
686+
help='add a repository for gradle')
687+
ap.add_argument('--add-packaging-option', dest='packaging_options',
688+
default=[],
689+
action='append',
690+
help='android packaging options')
691+
668692
ap.add_argument('--wakelock', dest='wakelock', action='store_true',
669693
help=('Indicate if the application needs the device '
670694
'to stay on'))

pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,68 +13,85 @@ allprojects {
1313
repositories {
1414
google()
1515
jcenter()
16-
flatDir {
17-
dirs 'libs'
18-
}
16+
{%- for repo in args.gradle_repositories %}
17+
{{repo}}
18+
{%- endfor %}
19+
flatDir {
20+
dirs 'libs'
21+
}
1922
}
2023
}
2124

2225
apply plugin: 'com.android.application'
2326

2427
android {
25-
compileSdkVersion {{ android_api }}
26-
buildToolsVersion '{{ build_tools_version }}'
27-
defaultConfig {
28-
minSdkVersion {{ args.min_sdk_version }}
29-
targetSdkVersion {{ android_api }}
30-
versionCode {{ args.numeric_version }}
31-
versionName '{{ args.version }}'
32-
}
28+
compileSdkVersion {{ android_api }}
29+
buildToolsVersion '{{ build_tools_version }}'
30+
defaultConfig {
31+
minSdkVersion {{ args.min_sdk_version }}
32+
targetSdkVersion {{ android_api }}
33+
versionCode {{ args.numeric_version }}
34+
versionName '{{ args.version }}'
35+
}
3336

34-
{% if args.sign -%}
35-
signingConfigs {
36-
release {
37-
storeFile file(System.getenv("P4A_RELEASE_KEYSTORE"))
38-
keyAlias System.getenv("P4A_RELEASE_KEYALIAS")
39-
storePassword System.getenv("P4A_RELEASE_KEYSTORE_PASSWD")
40-
keyPassword System.getenv("P4A_RELEASE_KEYALIAS_PASSWD")
41-
}
42-
}
37+
{% if args.sign -%}
38+
signingConfigs {
39+
release {
40+
storeFile file(System.getenv("P4A_RELEASE_KEYSTORE"))
41+
keyAlias System.getenv("P4A_RELEASE_KEYALIAS")
42+
storePassword System.getenv("P4A_RELEASE_KEYSTORE_PASSWD")
43+
keyPassword System.getenv("P4A_RELEASE_KEYALIAS_PASSWD")
44+
}
45+
}
4346
{%- endif %}
4447

45-
buildTypes {
46-
debug {
47-
}
48-
release {
49-
{% if args.sign -%}
50-
signingConfig signingConfigs.release
51-
{%- endif %}
52-
}
53-
}
48+
{% if args.packaging_options -%}
49+
packagingOptions {
50+
{%- for option in args.packaging_options %}
51+
{{option}}
52+
{%- endfor %}
53+
}
54+
{%- endif %}
55+
56+
buildTypes {
57+
debug {
58+
}
59+
release {
60+
{% if args.sign -%}
61+
signingConfig signingConfigs.release
62+
{%- endif %}
63+
}
64+
}
5465

5566
compileOptions {
5667
sourceCompatibility JavaVersion.VERSION_1_7
5768
targetCompatibility JavaVersion.VERSION_1_7
69+
{%- for compat in args.java_source_compat %}
70+
sourceCompatibility {{compat}}
71+
{%- endfor %}
72+
{%- for compat in args.java_target_compat %}
73+
targetCompatibility {{compat}}
74+
{%- endfor %}
5875
}
5976

6077
sourceSets {
6178
main {
6279
jniLibs.srcDir 'libs'
63-
}
80+
}
6481
}
6582

6683
}
6784

6885
dependencies {
69-
{%- for aar in aars %}
70-
compile(name: '{{ aar }}', ext: 'aar')
71-
{%- endfor -%}
72-
{%- for jar in jars %}
73-
compile files('src/main/libs/{{ jar }}')
74-
{%- endfor -%}
75-
{%- if args.depends -%}
76-
{%- for depend in args.depends %}
77-
compile '{{ depend }}'
78-
{%- endfor %}
79-
{%- endif %}
86+
{%- for aar in aars %}
87+
compile(name: '{{ aar }}', ext: 'aar')
88+
{%- endfor -%}
89+
{%- for jar in jars %}
90+
compile files('src/main/libs/{{ jar }}')
91+
{%- endfor -%}
92+
{%- if args.depends -%}
93+
{%- for depend in args.depends %}
94+
compile '{{ depend }}'
95+
{%- endfor %}
96+
{%- endif %}
8097
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<application android:label="@string/app_name"
5555
android:icon="@drawable/icon"
5656
android:allowBackup="{{ args.allow_backup }}"
57-
android:theme="@android:style/Theme.NoTitleBar{% if not args.window %}.Fullscreen{% endif %}"
57+
android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}"
5858
android:hardwareAccelerated="true" >
5959
{% for l in args.android_used_libs %}
6060
<uses-library android:name="{{ l }}" />
@@ -64,7 +64,7 @@
6464
<meta-data android:name="{{ m.split('=', 1)[0] }}" android:value="{{ m.split('=', 1)[-1] }}"/>{% endfor %}
6565
<meta-data android:name="wakelock" android:value="{% if args.wakelock %}1{% else %}0{% endif %}"/>
6666

67-
<activity android:name="org.kivy.android.PythonActivity"
67+
<activity android:name="{{args.android_entrypoint}}"
6868
android:label="@string/app_name"
6969
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode{% if args.min_sdk_version >= 8 %}|uiMode{% endif %}{% if args.min_sdk_version >= 13 %}|screenSize|smallestScreenSize{% endif %}{% if args.min_sdk_version >= 17 %}|layoutDirection{% endif %}{% if args.min_sdk_version >= 24 %}|density{% endif %}"
7070
android:screenOrientation="{{ args.orientation }}"

0 commit comments

Comments
 (0)