Skip to content

Commit b599430

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into enable_androidx
2 parents cec0254 + b10a796 commit b599430

File tree

36 files changed

+444
-103
lines changed

36 files changed

+444
-103
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
# See also: https://github.com/travis-ci/travis-ci/issues/8589
2424
- type -t deactivate && deactivate || true
2525
- export PATH=/opt/python/3.7.1/bin:$PATH
26+
# Update pip
27+
- python3.7 -m pip install --upgrade pip
2628
# Install tox
2729
- python3.7 -m pip install tox>=2.0
2830
# Install coveralls & dependencies

ci/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class TargetPython(Enum):
2626
# mpmath package with a version >= 0.19 required
2727
'sympy',
2828
'vlc',
29+
# need extra gfortran NDK system add-on
30+
'lapack', 'scipy',
2931
])
3032

3133
BROKEN_RECIPES = {

doc/source/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ On macOS::
9797

9898
brew install autoconf automake libtool openssl pkg-config
9999
brew tap homebrew/cask-versions
100-
brew cask install homebrew/cask-versions/adoptopenjdk8
100+
brew install --cask homebrew/cask-versions/adoptopenjdk8
101101

102102
Installing Android SDK
103103
~~~~~~~~~~~~~~~~~~~~~~

pythonforandroid/archs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ def get_env(self, with_flags_in_cc=True):
234234

235235
env['PATH'] = environ['PATH']
236236

237+
# for reproducible builds
238+
if 'SOURCE_DATE_EPOCH' in environ:
239+
for k in 'LC_ALL TZ SOURCE_DATE_EPOCH PYTHONHASHSEED BUILD_DATE BUILD_TIME'.split():
240+
if k in environ:
241+
env[k] = environ[k]
242+
237243
return env
238244

239245

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env python3
22

3+
from gzip import GzipFile
4+
import hashlib
35
import json
46
from os.path import (
57
dirname, join, isfile, realpath,
68
relpath, split, exists, basename
79
)
8-
from os import listdir, makedirs, remove
10+
from os import environ, listdir, makedirs, remove
911
import os
1012
import shlex
1113
import shutil
@@ -87,6 +89,10 @@ def get_bootstrap_name():
8789
join(curdir, 'templates')))
8890

8991

92+
DEFAULT_PYTHON_ACTIVITY_JAVA_CLASS = 'org.kivy.android.PythonActivity'
93+
DEFAULT_PYTHON_SERVICE_JAVA_CLASS = 'org.kivy.android.PythonService'
94+
95+
9096
def ensure_dir(path):
9197
if not exists(path):
9298
makedirs(path)
@@ -161,16 +167,25 @@ def select(fn):
161167
return False
162168
return not is_blacklist(fn)
163169

170+
def clean(tinfo):
171+
"""cleaning function (for reproducible builds)"""
172+
tinfo.uid = tinfo.gid = 0
173+
tinfo.uname = tinfo.gname = ''
174+
tinfo.mtime = 0
175+
return tinfo
176+
164177
# get the files and relpath file of all the directory we asked for
165178
files = []
166179
for sd in source_dirs:
167180
sd = realpath(sd)
168181
compile_dir(sd, optimize_python=optimize_python)
169182
files += [(x, relpath(realpath(x), sd)) for x in listfiles(sd)
170183
if select(x)]
184+
files.sort() # deterministic
171185

172186
# create tar.gz of thoses files
173-
tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
187+
gf = GzipFile(tfn, 'wb', mtime=0) # deterministic
188+
tf = tarfile.open(None, 'w', gf, format=tarfile.USTAR_FORMAT)
174189
dirs = []
175190
for fn, afn in files:
176191
dn = dirname(afn)
@@ -189,8 +204,9 @@ def select(fn):
189204
tf.addfile(tinfo)
190205

191206
# put the file
192-
tf.add(fn, afn)
207+
tf.add(fn, afn, filter=clean)
193208
tf.close()
209+
gf.close()
194210

195211

196212
def compile_dir(dfn, optimize_python=True):
@@ -421,6 +437,7 @@ def make_package(args):
421437
service = True
422438

423439
service_names = []
440+
base_service_class = args.service_class_name.split('.')[-1]
424441
for sid, spec in enumerate(args.services):
425442
spec = spec.split(':')
426443
name = spec[0]
@@ -445,6 +462,7 @@ def make_package(args):
445462
foreground=foreground,
446463
sticky=sticky,
447464
service_id=sid + 1,
465+
base_service_class=base_service_class,
448466
)
449467

450468
# Find the SDK directory and target API
@@ -524,9 +542,18 @@ def make_package(args):
524542
versioned_name=versioned_name)
525543

526544
# String resources:
545+
timestamp = time.time()
546+
if 'SOURCE_DATE_EPOCH' in environ:
547+
# for reproducible builds
548+
timestamp = int(environ['SOURCE_DATE_EPOCH'])
549+
private_version = "{} {} {}".format(
550+
args.version,
551+
args.numeric_version,
552+
timestamp
553+
)
527554
render_args = {
528555
"args": args,
529-
"private_version": str(time.time())
556+
"private_version": hashlib.sha1(private_version.encode()).hexdigest()
530557
}
531558
if get_bootstrap_name() == "sdl2":
532559
render_args["url_scheme"] = url_scheme
@@ -687,7 +714,7 @@ def parse_args_and_make_package(args=None):
687714
help=('Enable the AndroidX support library, '
688715
'requires api = 28 or greater'))
689716
ap.add_argument('--android-entrypoint', dest='android_entrypoint',
690-
default='org.kivy.android.PythonActivity',
717+
default=DEFAULT_PYTHON_ACTIVITY_JAVA_CLASS,
691718
help='Defines which java class will be used for startup, usually a subclass of PythonActivity')
692719
ap.add_argument('--android-apptheme', dest='android_apptheme',
693720
default='@android:style/Theme.NoTitleBar',
@@ -786,9 +813,16 @@ def parse_args_and_make_package(args=None):
786813
ap.add_argument('--extra-manifest-xml', default='',
787814
help=('Extra xml to write directly inside the <manifest> element of'
788815
'AndroidManifest.xml'))
816+
ap.add_argument('--extra-manifest-application-arguments', default='',
817+
help='Extra arguments to be added to the <manifest><application> tag of'
818+
'AndroidManifest.xml')
789819
ap.add_argument('--manifest-placeholders', dest='manifest_placeholders',
790820
default='[:]', help=('Inject build variables into the manifest '
791821
'via the manifestPlaceholders property'))
822+
ap.add_argument('--service-class-name', dest='service_class_name', default=DEFAULT_PYTHON_SERVICE_JAVA_CLASS,
823+
help='Use that parameter if you need to implement your own PythonServive Java class')
824+
ap.add_argument('--activity-class-name', dest='activity_class_name', default=DEFAULT_PYTHON_ACTIVITY_JAVA_CLASS,
825+
help='The full java class name of the main activity')
792826

793827
# Put together arguments, and add those from .p4a config file:
794828
if args is None:
@@ -808,6 +842,7 @@ def _read_configuration():
808842
_read_configuration()
809843

810844
args = ap.parse_args(args)
845+
811846
args.ignore_path = []
812847

813848
if args.name and args.name[0] == '"' and args.name[-1] == '"':

pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected static ArrayList<String> getLibraries(File libsDir) {
4444
libsList.add("python3.6m");
4545
libsList.add("python3.7m");
4646
libsList.add("python3.8");
47+
libsList.add("python3.9");
4748
libsList.add("main");
4849
return libsList;
4950
}
@@ -63,7 +64,7 @@ public static void loadLibraries(File filesDir, File libsDir) {
6364
// load, and it has failed, give a more
6465
// general error
6566
Log.v(TAG, "Library loading error: " + e.getMessage());
66-
if (lib.startsWith("python3.8") && !foundPython) {
67+
if (lib.startsWith("python3.9") && !foundPython) {
6768
throw new RuntimeException("Could not load any libpythonXXX.so");
6869
} else if (lib.startsWith("python")) {
6970
continue;

pythonforandroid/bootstraps/common/build/templates/Service.tmpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import android.content.Intent;
44
import android.content.Context;
5-
import org.kivy.android.PythonService;
5+
import {{ args.service_class_name }};
66

77

8-
public class Service{{ name|capitalize }} extends PythonService {
8+
public class Service{{ name|capitalize }} extends {{ base_service_class }} {
99
{% if sticky %}
1010
@Override
1111
public int startType() {

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.os.Bundle;
2626
import android.os.PowerManager;
2727
import android.util.Log;
28+
import android.view.inputmethod.InputMethodManager;
2829
import android.view.SurfaceView;
2930
import android.view.ViewGroup;
3031
import android.view.View;
@@ -632,4 +633,12 @@ public void requestPermissionsWithRequestCode(String[] permissions, int requestC
632633
public void requestPermissions(String[] permissions) {
633634
requestPermissionsWithRequestCode(permissions, 1);
634635
}
636+
637+
public static void changeKeyboard(int inputType) {
638+
if (SDLActivity.keyboardInputType != inputType){
639+
SDLActivity.keyboardInputType = inputType;
640+
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
641+
imm.restartInput(mTextEdit);
642+
}
643+
}
635644
}

pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
--- a/src/main/java/org/libsdl/app/SDLActivity.java
22
+++ b/src/main/java/org/libsdl/app/SDLActivity.java
3-
@@ -196,6 +196,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
3+
@@ -94,6 +94,8 @@
4+
// This is what SDL runs in. It invokes SDL_main(), eventually
5+
protected static Thread mSDLThread;
6+
7+
+ public static int keyboardInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
8+
+
9+
protected static SDLGenericMotionListener_API12 getMotionListener() {
10+
if (mMotionListener == null) {
11+
if (Build.VERSION.SDK_INT >= 26) {
12+
@@ -196,6 +198,15 @@
413
Log.v(TAG, "onCreate()");
514
super.onCreate(savedInstanceState);
6-
15+
716
+ SDLActivity.initialize();
817
+ // So we can call stuff from static callbacks
918
+ mSingleton = this;
@@ -16,19 +25,19 @@
1625
// Load shared libraries
1726
String errorMsgBrokenLib = "";
1827
try {
19-
@@ -639,7 +648,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
28+
@@ -639,7 +650,7 @@
2029
Handler commandHandler = new SDLCommandHandler();
21-
30+
2231
// Send a message from the SDLMain thread
2332
- boolean sendCommand(int command, Object data) {
2433
+ protected boolean sendCommand(int command, Object data) {
2534
Message msg = commandHandler.obtainMessage();
2635
msg.arg1 = command;
2736
msg.obj = data;
28-
@@ -1051,6 +1061,21 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
37+
@@ -1051,6 +1062,21 @@
2938
return Arrays.copyOf(filtered, used);
3039
}
31-
40+
3241
+ /**
3342
+ * Calls turnActive() on singleton to keep loading screen active
3443
+ */
@@ -45,11 +54,11 @@
4554
+
4655
+
4756
// APK expansion files support
48-
57+
4958
/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
50-
@@ -1341,14 +1366,13 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
59+
@@ -1341,14 +1367,13 @@
5160
};
52-
61+
5362
public void onSystemUiVisibilityChange(int visibility) {
5463
- if (SDLActivity.mFullscreenModeActive && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
5564
-
@@ -62,13 +71,21 @@
6271
}
6372
-
6473
}
65-
}
66-
67-
@@ -1475,6 +1499,7 @@ class SDLMain implements Runnable {
74+
}
75+
76+
@@ -1475,6 +1500,7 @@
6877
String[] arguments = SDLActivity.mSingleton.getArguments();
69-
78+
7079
Log.v("SDL", "Running main function " + function + " from library " + library);
7180
+ SDLActivity.mSingleton.appConfirmedActive();
7281
SDLActivity.nativeRunMain(library, function, arguments);
73-
82+
7483
Log.v("SDL", "Finished main function");
84+
@@ -2002,7 +2028,7 @@
85+
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
86+
ic = new SDLInputConnection(this, true);
87+
88+
- outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
89+
+ outAttrs.inputType = SDLActivity.keyboardInputType;
90+
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
91+
| EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959
android:icon="@drawable/icon"
6060
android:allowBackup="{{ args.allow_backup }}"
6161
{% if args.backup_rules %}android:fullBackupContent="@xml/{{ args.backup_rules }}"{% endif %}
62+
{{ args.extra_manifest_application_arguments }}
6263
android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}"
63-
android:hardwareAccelerated="true" >
64+
android:hardwareAccelerated="true"
65+
>
6466
{% for l in args.android_used_libs %}
6567
<uses-library android:name="{{ l }}" />
6668
{% endfor %}
@@ -110,7 +112,7 @@
110112
{% endif %}
111113

112114
{% if service or args.launcher %}
113-
<service android:name="org.kivy.android.PythonService"
115+
<service android:name="{{ args.service_class_name }}"
114116
android:process=":pythonservice" />
115117
{% endif %}
116118
{% for name in service_names %}

0 commit comments

Comments
 (0)