Skip to content

Commit c3145cf

Browse files
zworkbinclement
authored andcommitted
customizability (kivy#1869)
* customizability options - added compile-options * apptheme option for all bootstraps
1 parent eb84372 commit c3145cf

File tree

5 files changed

+77
-45
lines changed

5 files changed

+77
-45
lines changed

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,24 @@ def parse_args(args=None):
663663
'https://developer.android.com/guide/'
664664
'topics/manifest/'
665665
'activity-element.html'))
666+
667+
ap.add_argument('--android-entrypoint', dest='android_entrypoint',
668+
default='org.kivy.android.PythonActivity',
669+
help='Defines which java class will be used for startup, usually a subclass of PythonActivity')
670+
ap.add_argument('--android-apptheme', dest='android_apptheme',
671+
default='@android:style/Theme.NoTitleBar',
672+
help='Defines which app theme should be selected for the main activity')
673+
ap.add_argument('--add-compile-option', dest='compile_options', default=[],
674+
action='append', help='add compile options to gradle.build')
675+
ap.add_argument('--add-gradle-repository', dest='gradle_repositories',
676+
default=[],
677+
action='append',
678+
help='Ddd a repository for gradle')
679+
ap.add_argument('--add-packaging-option', dest='packaging_options',
680+
default=[],
681+
action='append',
682+
help='Dndroid packaging options')
683+
666684
ap.add_argument('--wakelock', dest='wakelock', action='store_true',
667685
help=('Indicate if the application needs the device '
668686
'to stay on'))

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

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,68 +13,82 @@ 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 option in args.compile_options %}
70+
{{option}}
71+
{%- endfor %}
5872
}
5973

6074
sourceSets {
6175
main {
6276
jniLibs.srcDir 'libs'
63-
}
77+
}
6478
}
6579

6680
}
6781

6882
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 %}
83+
{%- for aar in aars %}
84+
compile(name: '{{ aar }}', ext: 'aar')
85+
{%- endfor -%}
86+
{%- for jar in jars %}
87+
compile files('src/main/libs/{{ jar }}')
88+
{%- endfor -%}
89+
{%- if args.depends -%}
90+
{%- for depend in args.depends %}
91+
compile '{{ depend }}'
92+
{%- endfor %}
93+
{%- endif %}
8094
}

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 }}"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<application android:label="@string/app_name"
4848
android:icon="@drawable/icon"
4949
android:allowBackup="true"
50-
android:theme="@android:style/Theme.NoTitleBar{% if not args.window %}.Fullscreen{% endif %}"
50+
android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}"
5151
android:hardwareAccelerated="true" >
5252
{% for l in args.android_used_libs %}
5353
<uses-library android:name="{{ l }}" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<application android:label="@string/app_name"
4949
android:icon="@drawable/icon"
5050
android:allowBackup="true"
51-
android:theme="@android:style/Theme.NoTitleBar{% if not args.window %}.Fullscreen{% endif %}"
51+
android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}"
5252
android:hardwareAccelerated="true" >
5353
{% for l in args.android_used_libs %}
5454
<uses-library android:name="{{ l }}" />

0 commit comments

Comments
 (0)