Skip to content

Commit 24dc0dc

Browse files
committed
Merge branch 'master' into local
2 parents 25d3036 + 2b3d52b commit 24dc0dc

7 files changed

Lines changed: 175 additions & 16 deletions

File tree

pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/PythonService.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.renpy.android;
22

3+
import android.os.Build;
4+
import java.lang.reflect.Method;
5+
import java.lang.reflect.InvocationTargetException;
36
import android.app.Service;
47
import android.os.IBinder;
58
import android.os.Bundle;
@@ -54,14 +57,31 @@ public int onStartCommand(Intent intent, int flags, int startId) {
5457
pythonThread = new Thread(this);
5558
pythonThread.start();
5659

60+
Notification notification;
5761
Context context = getApplicationContext();
58-
Notification notification = new Notification(context.getApplicationInfo().icon,
59-
serviceTitle,
60-
System.currentTimeMillis());
6162
Intent contextIntent = new Intent(context, PythonActivity.class);
6263
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
6364
PendingIntent.FLAG_UPDATE_CURRENT);
64-
notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
65+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
66+
notification = new Notification(
67+
context.getApplicationInfo().icon, serviceTitle, System.currentTimeMillis());
68+
try {
69+
// prevent using NotificationCompat, this saves 100kb on apk
70+
Method func = notification.getClass().getMethod(
71+
"setLatestEventInfo", Context.class, CharSequence.class,
72+
CharSequence.class, PendingIntent.class);
73+
func.invoke(notification, context, serviceTitle, serviceDescription, pIntent);
74+
} catch (NoSuchMethodException | IllegalAccessException |
75+
IllegalArgumentException | InvocationTargetException e) {
76+
}
77+
} else {
78+
Notification.Builder builder = new Notification.Builder(context);
79+
builder.setContentTitle(serviceTitle);
80+
builder.setContentText(serviceDescription);
81+
builder.setContentIntent(pIntent);
82+
builder.setSmallIcon(context.getApplicationInfo().icon);
83+
notification = builder.build();
84+
}
6585
startForeground(1, notification);
6686

6787
return START_NOT_STICKY;

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.kivy.android;
22

3+
import android.os.Build;
4+
import java.lang.reflect.Method;
5+
import java.lang.reflect.InvocationTargetException;
36
import android.app.Service;
47
import android.os.IBinder;
58
import android.os.Bundle;
@@ -88,13 +91,31 @@ protected void doStartForeground(Bundle extras) {
8891
String serviceTitle = extras.getString("serviceTitle");
8992
String serviceDescription = extras.getString("serviceDescription");
9093

94+
Notification notification;
9195
Context context = getApplicationContext();
92-
Notification notification = new Notification(context.getApplicationInfo().icon,
93-
serviceTitle, System.currentTimeMillis());
9496
Intent contextIntent = new Intent(context, PythonActivity.class);
9597
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
9698
PendingIntent.FLAG_UPDATE_CURRENT);
97-
notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
99+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
100+
notification = new Notification(
101+
context.getApplicationInfo().icon, serviceTitle, System.currentTimeMillis());
102+
try {
103+
// prevent using NotificationCompat, this saves 100kb on apk
104+
Method func = notification.getClass().getMethod(
105+
"setLatestEventInfo", Context.class, CharSequence.class,
106+
CharSequence.class, PendingIntent.class);
107+
func.invoke(notification, context, serviceTitle, serviceDescription, pIntent);
108+
} catch (NoSuchMethodException | IllegalAccessException |
109+
IllegalArgumentException | InvocationTargetException e) {
110+
}
111+
} else {
112+
Notification.Builder builder = new Notification.Builder(context);
113+
builder.setContentTitle(serviceTitle);
114+
builder.setContentText(serviceDescription);
115+
builder.setContentIntent(pIntent);
116+
builder.setSmallIcon(context.getApplicationInfo().icon);
117+
notification = builder.build();
118+
}
98119
startForeground(1, notification);
99120
}
100121

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package {{ args.package }};
22

3+
import android.os.Build;
4+
import java.lang.reflect.Method;
5+
import java.lang.reflect.InvocationTargetException;
36
import android.content.Intent;
47
import android.content.Context;
58
import android.app.Notification;
@@ -26,13 +29,31 @@ public boolean canDisplayNotification() {
2629

2730
@Override
2831
protected void doStartForeground(Bundle extras) {
32+
Notification notification;
2933
Context context = getApplicationContext();
30-
Notification notification = new Notification(context.getApplicationInfo().icon,
31-
"{{ args.name }}", System.currentTimeMillis());
3234
Intent contextIntent = new Intent(context, PythonActivity.class);
3335
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
3436
PendingIntent.FLAG_UPDATE_CURRENT);
35-
notification.setLatestEventInfo(context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);
37+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
38+
notification = new Notification(
39+
context.getApplicationInfo().icon, "{{ args.name }}", System.currentTimeMillis());
40+
try {
41+
// prevent using NotificationCompat, this saves 100kb on apk
42+
Method func = notification.getClass().getMethod(
43+
"setLatestEventInfo", Context.class, CharSequence.class,
44+
CharSequence.class, PendingIntent.class);
45+
func.invoke(notification, context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);
46+
} catch (NoSuchMethodException | IllegalAccessException |
47+
IllegalArgumentException | InvocationTargetException e) {
48+
}
49+
} else {
50+
Notification.Builder builder = new Notification.Builder(context);
51+
builder.setContentTitle("{{ args.name }}");
52+
builder.setContentText("{{ name| capitalize }}");
53+
builder.setContentIntent(pIntent);
54+
builder.setSmallIcon(context.getApplicationInfo().icon);
55+
notification = builder.build();
56+
}
3657
startForeground({{ service_id }}, notification);
3758
}
3859

pythonforandroid/bootstraps/webview/build/src/org/kivy/android/PythonService.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.kivy.android;
22

3+
import android.os.Build;
4+
import java.lang.reflect.Method;
5+
import java.lang.reflect.InvocationTargetException;
36
import android.app.Service;
47
import android.os.IBinder;
58
import android.os.Bundle;
@@ -87,13 +90,31 @@ protected void doStartForeground(Bundle extras) {
8790
String serviceTitle = extras.getString("serviceTitle");
8891
String serviceDescription = extras.getString("serviceDescription");
8992

93+
Notification notification;
9094
Context context = getApplicationContext();
91-
Notification notification = new Notification(context.getApplicationInfo().icon,
92-
serviceTitle, System.currentTimeMillis());
9395
Intent contextIntent = new Intent(context, PythonActivity.class);
9496
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
9597
PendingIntent.FLAG_UPDATE_CURRENT);
96-
notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
98+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
99+
notification = new Notification(
100+
context.getApplicationInfo().icon, serviceTitle, System.currentTimeMillis());
101+
try {
102+
// prevent using NotificationCompat, this saves 100kb on apk
103+
Method func = notification.getClass().getMethod(
104+
"setLatestEventInfo", Context.class, CharSequence.class,
105+
CharSequence.class, PendingIntent.class);
106+
func.invoke(notification, context, serviceTitle, serviceDescription, pIntent);
107+
} catch (NoSuchMethodException | IllegalAccessException |
108+
IllegalArgumentException | InvocationTargetException e) {
109+
}
110+
} else {
111+
Notification.Builder builder = new Notification.Builder(context);
112+
builder.setContentTitle(serviceTitle);
113+
builder.setContentText(serviceDescription);
114+
builder.setContentIntent(pIntent);
115+
builder.setSmallIcon(context.getApplicationInfo().icon);
116+
notification = builder.build();
117+
}
97118
startForeground(1, notification);
98119
}
99120

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package {{ args.package }};
22

3+
import android.os.Build;
4+
import java.lang.reflect.Method;
5+
import java.lang.reflect.InvocationTargetException;
36
import android.content.Intent;
47
import android.content.Context;
58
import android.app.Notification;
@@ -26,13 +29,31 @@ public boolean canDisplayNotification() {
2629

2730
@Override
2831
protected void doStartForeground(Bundle extras) {
32+
Notification notification;
2933
Context context = getApplicationContext();
30-
Notification notification = new Notification(context.getApplicationInfo().icon,
31-
"{{ args.name }}", System.currentTimeMillis());
3234
Intent contextIntent = new Intent(context, PythonActivity.class);
3335
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
3436
PendingIntent.FLAG_UPDATE_CURRENT);
35-
notification.setLatestEventInfo(context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);
37+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
38+
notification = new Notification(
39+
context.getApplicationInfo().icon, "{{ args.name }}", System.currentTimeMillis());
40+
try {
41+
// prevent using NotificationCompat, this saves 100kb on apk
42+
Method func = notification.getClass().getMethod(
43+
"setLatestEventInfo", Context.class, CharSequence.class,
44+
CharSequence.class, PendingIntent.class);
45+
func.invoke(notification, context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);
46+
} catch (NoSuchMethodException | IllegalAccessException |
47+
IllegalArgumentException | InvocationTargetException e) {
48+
}
49+
} else {
50+
Notification.Builder builder = new Notification.Builder(context);
51+
builder.setContentTitle("{{ args.name }}");
52+
builder.setContentText("{{ name| capitalize }}");
53+
builder.setContentIntent(pIntent);
54+
builder.setSmallIcon(context.getApplicationInfo().icon);
55+
notification = builder.build();
56+
}
3657
startForeground({{ service_id }}, notification);
3758
}
3859

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import sh
2+
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
3+
from pythonforandroid.util import ensure_dir
4+
from os.path import exists, join, abspath
5+
from multiprocessing import cpu_count
6+
7+
8+
class LibcurlRecipe(Recipe):
9+
version = '7.55.1'
10+
url = 'https://curl.haxx.se/download/curl-7.55.1.tar.gz'
11+
depends = ['openssl']
12+
13+
def should_build(self, arch):
14+
super(LibcurlRecipe, self).should_build(arch)
15+
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libcurl.so'))
16+
17+
def build_arch(self, arch):
18+
super(LibcurlRecipe, self).build_arch(arch)
19+
env = self.get_recipe_env(arch)
20+
21+
r = self.get_recipe('openssl', self.ctx)
22+
openssl_dir = r.get_build_dir(arch.arch)
23+
24+
with current_directory(self.get_build_dir(arch.arch)):
25+
dst_dir = join(self.get_build_dir(arch.arch), 'dist')
26+
shprint(
27+
sh.Command('./configure'),
28+
'--host=arm-linux-androideabi',
29+
'--enable-shared',
30+
'--with-ssl={}'.format(openssl_dir),
31+
'--prefix={}'.format(dst_dir),
32+
_env=env)
33+
shprint(sh.make, '-j', str(cpu_count()), _env=env)
34+
shprint(sh.make, 'install', _env=env)
35+
shutil.copyfile('{}/lib/libcurl.so'.format(dst_dir),
36+
join(
37+
self.ctx.get_libs_dir(arch.arch),
38+
'libcurl.so'))
39+
40+
recipe = LibcurlRecipe()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- zeroconf.orig/setup.py 2015-07-11 21:55:09.000000000 +0200
2+
+++ zeroconf/setup.py 2017-02-23 01:04:13.370018716 +0100
3+
@@ -55,12 +55,5 @@
4+
'mDNS',
5+
],
6+
install_requires=[
7+
- 'enum-compat',
8+
- # netifaces 0.10.5 has a bug that results in all interfaces' netmasks
9+
- # to be 255.255.255.255 on Windows which breaks things. See:
10+
- # * https://github.com/jstasiak/python-zeroconf/issues/84
11+
- # * https://bitbucket.org/al45tair/netifaces/issues/39/netmask-is-always-255255255255
12+
- 'netifaces<=0.10.4',
13+
- 'six',
14+
],
15+
)

0 commit comments

Comments
 (0)