Skip to content

Commit c781ad7

Browse files
committed
start to support custom meta-data
1 parent c0637f4 commit c781ad7

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

docs/source/usage.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,33 @@ Available options to `build.py`::
120120
Minimum Android SDK version to use. Default to 8
121121
--window Indicate if the application will be windowed
122122

123+
Meta-data
124+
---------
125+
126+
.. versionadded:: 1.3
127+
128+
You can extend the `AndroidManifest.xml` with application meta-data. If you are
129+
using external toolkits like Google Maps, you might want to set your API key in
130+
the meta-data. You could do it like this::
131+
132+
./build.py ... --meta-data com.google.android.maps.v2.API_KEY=YOURAPIKEY
133+
134+
Some meta-data can be used to interact with the behavior of our internal
135+
component.
136+
137+
.. list-table::
138+
:widths: 100 500
139+
:header-rows: 1
140+
141+
* - Token
142+
- Description
143+
* - `surface.transluent`
144+
- If set to 1, the created surface will be transluent (can be used
145+
to add background Android widget in the background, or use accelerated
146+
widgets)
147+
* - `surface.depth`
148+
- Size of the depth component, default to 0. 0 means automatic, but you
149+
can force it to a specific value. Be warned, some old phone might not
150+
support the depth you want.
151+
* - `surface.stencil`
152+
- Size of the stencil component, default to 8.

src/build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ def make_package(args):
377377
help='Indicate if the application needs the device to stay on')
378378
ap.add_argument('command', nargs='*', help='The command to pass to ant (debug, release, installd, installr)')
379379
ap.add_argument('--add-jar', dest='add_jar', action='append', help='Add a Java .jar to the libs, so you can access its classes with pyjnius. You can specify this argument more than once to include multiple jars')
380+
ap.add_argument('--meta-data', dest='meta_data', action='append',
381+
help='Custom key=value to add in application metadata')
380382

381383
args = ap.parse_args()
382384

src/src/org/renpy/android/SDLSurfaceView.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import android.os.PowerManager;
4646
import android.content.pm.PackageManager;
4747
import android.content.pm.ApplicationInfo;
48+
import android.graphics.PixelFormat;
4849

4950
import java.io.IOException;
5051
import java.io.InputStream;
@@ -594,11 +595,23 @@ public void run() {
594595
try {
595596
if (configToTest == 0) {
596597
Log.i(TAG, "Try to use graphics config R8G8B8A8S8");
597-
ConfigChooser chooser = new ConfigChooser(8, 8, 8, 8, 0, 8);
598+
ConfigChooser chooser = new ConfigChooser(
599+
// rgba
600+
8, 8, 8, 8,
601+
// depth
602+
mActivity.mInfo.metaData.getInt("surface:depth", 0),
603+
// stencil
604+
mActivity.mInfo.metaData.getInt("surface:stencil", 8));
598605
mEglConfig = chooser.chooseConfig(mEgl, mEglDisplay);
599606
} else if (configToTest == 1) {
600607
Log.i(TAG, "Try to use graphics config R5G6B5S8");
601-
ConfigChooser chooser = new ConfigChooser(5, 6, 5, 0, 0, 8);
608+
ConfigChooser chooser = new ConfigChooser(
609+
// rgba
610+
5, 6, 5, 0,
611+
// depth
612+
mActivity.mInfo.metaData.getInt("surface:depth", 0),
613+
// stencil
614+
mActivity.mInfo.metaData.getInt("surface:stencil", 8));
602615
mEglConfig = chooser.chooseConfig(mEgl, mEglDisplay);
603616
} else {
604617
Log.e(TAG, "Unable to find a correct surface for this device !");
@@ -637,6 +650,9 @@ public void run() {
637650
Log.w(TAG, "Done");
638651
waitForStart();
639652

653+
if ( mActivity.mInfo.metaData.getBoolean("surface:transluent") )
654+
getHolder().setFormat(PixelFormat.TRANSLUCENT);
655+
640656
nativeResize(mWidth, mHeight);
641657
nativeInitJavaCallbacks();
642658
nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory);

src/templates/AndroidManifest.tmpl.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88

99
<application android:label="@string/appName"
1010
android:icon="@drawable/icon"
11+
android:hardwareAccelerated="true"
1112
>
1213

14+
{% for m in args.meta_data %}
15+
<meta-data android:name="{{ m.split('=', 1)[0] }}" android:value="{{ m.split('=', 1)[-1] }}"/>{% endfor %}
1316
<meta-data android:name="fullscreen" android:value="{% if args.window %}0{% else %}1{% endif %}"/>
1417
<meta-data android:name="wakelock" android:value="{% if args.wakelock %}1{% else %}0{% endif %}"/>
1518

19+
1620
<activity android:name="org.renpy.android.PythonActivity"
1721
android:label="@string/iconName"
1822
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode{% if android_api >= 13 %}|screenSize{% endif %}"
@@ -89,7 +93,11 @@
8993
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9094

9195
{% for perm in args.permissions %}
96+
{% if '.' in perm %}
97+
<uses-permission android:name="{{ perm }}" />
98+
{% else %}
9299
<uses-permission android:name="android.permission.{{ perm }}" />
100+
{% endif %}
93101
{% endfor %}
94102

95103
{% if args.billing_pubkey %}

0 commit comments

Comments
 (0)