Skip to content

Commit aab6001

Browse files
committed
Merge branch 'master' of github.com:chozabu/python-for-android
2 parents 162edb2 + 80eb744 commit aab6001

File tree

13 files changed

+690
-67
lines changed

13 files changed

+690
-67
lines changed

docs/source/example_helloworld.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Let's create a simple Hello world application, with one Label and one Button.
4343
class HelloWorldScreen(GridLayout):
4444
counter = NumericProperty(0)
4545
def my_callback(self):
46-
print 'The button have been pushed'
46+
print 'The button has been pushed'
4747
self.counter += 1
4848

4949
class HelloWorldApp(App):

docs/source/examples.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ A good starting point to build an APK are prebuilt VirtualBox images, where
88
the Android NDK, the Android SDK and the Kivy Python-For-Android sources
99
are prebuilt in an VirtualBox image. Please search the `Download Section
1010
<http://kivy.org/#download>`__ for
11-
such an image.
11+
such an image. You will also need to create a device filter for the Android
12+
USB device using the VirtualBox OS settings.
1213

1314
.. include:: example_helloworld.rst
1415
.. include:: example_compass.rst

docs/source/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ You can include other modules (or "recipes") to compile using `-m`::
2020
You can also specify a specific version for each package. Please note that the
2121
compilation might **break** if you don't use the default version. Most recipes
2222
have patch to fixes android issues, and might not apply if you specify a
23-
version. We also recommand to clean build/ before changing version.::
23+
version. We also recommend to clean build/ before changing version.::
2424

2525
./distribute.sh -m "openssl kivy==master"
2626

recipes/android/src/android/_android.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ def get_dpi():
170170
cdef extern void android_show_keyboard(int)
171171
cdef extern void android_hide_keyboard()
172172

173+
# get keyboard height
174+
def get_keyboard_height():
175+
from jnius import autoclass
176+
python_act = autoclass('org.renpy.android.PythonActivity')
177+
rctx = autoclass('android.graphics.Rect')()
178+
mActivity = python_act.mActivity
179+
mActivity.getWindow().getDecorView().\
180+
getWindowVisibleDisplayFrame(rctx)
181+
height = mActivity.getWindowManager().getDefaultDisplay().getHeight()
182+
return height - rctx.bottom
183+
184+
173185
# Flags for input_type, for requesting a particular type of keyboard
174186
#android FLAGS
175187
TYPE_CLASS_DATETIME = 4

recipes/android/src/android/broadcast.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def _expand_partial_name(partial_name):
3939
resolved_categories = [_expand_partial_name(x) for x in categories or []]
4040

4141
# resolve android API
42-
PythonActivity = autoclass('org.renpy.android.PythonActivity')
4342
GenericBroadcastReceiver = autoclass('org.renpy.android.GenericBroadcastReceiver')
4443
IntentFilter = autoclass('android.content.IntentFilter')
4544
HandlerThread = autoclass('android.os.HandlerThread')
@@ -48,7 +47,6 @@ def _expand_partial_name(partial_name):
4847
self.handlerthread = HandlerThread('handlerthread')
4948

5049
# create a listener
51-
self.context = PythonActivity.mActivity
5250
self.listener = BroadcastReceiver.Callback(self.callback)
5351
self.receiver = GenericBroadcastReceiver(self.listener)
5452
self.receiver_filter = IntentFilter()
@@ -68,4 +66,12 @@ def stop(self):
6866
self.context.unregisterReceiver(self.receiver)
6967
self.handlerthread.quit()
7068

69+
@property
70+
def context(self):
71+
from os import environ
72+
if 'PYTHON_SERVICE_ARGUMENT' in environ:
73+
PythonService = autoclass('org.renpy.android.PythonService')
74+
return PythonService.mService
75+
PythonActivity = autoclass('org.renpy.android.PythonActivity')
76+
return PythonActivity.mActivity
7177

recipes/apsw/recipe.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
# version of your package
4+
VERSION_apsw=${VERSION_apsw:-3.8.4.1-r1}
5+
6+
# dependencies of this recipe
7+
DEPS_apsw=(python)
8+
9+
# url of the package
10+
URL_apsw=https://github.com/rogerbinns/apsw/releases/download/3.8.4.1-r1/apsw-3.8.4.1-r1.zip
11+
12+
# md5 of the package
13+
MD5_apsw=5ad3098489576929b90f4215eb5b2621
14+
15+
# default build path
16+
BUILD_apsw=$BUILD_PATH/apsw/$(get_directory $URL_apsw)
17+
18+
# default recipe path
19+
RECIPE_apsw=$RECIPES_PATH/apsw
20+
21+
# function called for preparing source code if needed
22+
# (you can apply patch etc here.)
23+
function prebuild_apsw() {
24+
25+
# fetch sqlite if necessary
26+
cd ${BUILD_apsw}
27+
if [ ! -d ${BUILD_apsw}/sqlite3 ]; then
28+
echo "fetching sqlite..."
29+
# using /usr/bin/python for this
30+
python setup.py fetch --sqlite --version=3.8.4.1 --missing-checksum-ok
31+
fi
32+
33+
# apsw insists on configuring sqlite, but it's for the host, not the target.
34+
# So, put in the correct values.
35+
36+
cat >sqlite3/sqlite3config.h <<EOF
37+
#define HAVE_SYS_TYPES_H 1
38+
#define HAVE_SYS_STAT_H 1
39+
#define HAVE_STDLIB_H 1
40+
#define HAVE_STRING_H 1
41+
#define HAVE_MEMORY_H 1
42+
#define HAVE_STRINGS_H 1
43+
#define HAVE_INTTYPES_H 1
44+
#define HAVE_STDINT_H 1
45+
#define HAVE_UNISTD_H 1
46+
#define HAVE_DLFCN_H 1
47+
#define HAVE_FDATASYNC 0
48+
#define HAVE_USLEEP 1
49+
#define HAVE_LOCALTIME_R 1
50+
#define HAVE_GMTIME_R 1
51+
#define HAVE_DECL_STRERROR_R 1
52+
#define HAVE_STRERROR_R 1
53+
#define HAVE_POSIX_FALLOCATE 0
54+
EOF
55+
56+
}
57+
58+
function shouldbuild_apsw() {
59+
if [ -d "$SITEPACKAGES_PATH/apsw" ]; then
60+
DO_BUILD=0
61+
fi
62+
}
63+
64+
# function called to build the source code
65+
function build_apsw() {
66+
67+
cd ${BUILD_apsw}
68+
69+
export NDK=$ANDROIDNDK
70+
push_arm
71+
72+
# HOSTPYTHON can't do zipfile or tarfile modules because of
73+
# buildozer bug (missing LD_LIBRARY_PATH is what it looks like),
74+
# but we don't need them at this stage
75+
cp setup.py setup.py.backup
76+
sed -e 's/import zipfile, tarfile/# import zipfile, tarfile/g' <setup.py.backup >setup.py
77+
78+
# build python extension
79+
export LDFLAGS="$LDFLAGS -L$LIBS_PATH"
80+
export LDSHARED="$LIBLINK"
81+
82+
echo "building apsw in `pwd`..."
83+
# now we can build; enable the FTS4 sqlite extension for full-text search
84+
try ${HOSTPYTHON} setup.py build --enable=fts4
85+
echo "installing apsw..."
86+
try ${HOSTPYTHON} setup.py install
87+
echo "done with apsw."
88+
89+
pop_arm
90+
}
91+
92+
# function called after all the compile have been done
93+
function postbuild_apsw() {
94+
echo "apsw built"
95+
}

recipes/openssl/recipe.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

3-
VERSION_openssl=${VERSION_openssl:-1.0.1c}
3+
VERSION_openssl=${VERSION_openssl:-1.0.1g}
44
URL_openssl=http://www.openssl.org/source/openssl-$VERSION_openssl.tar.gz
55
DEPS_openssl=()
6-
MD5_openssl=ae412727c8c15b67880aef7bd2999b2e
6+
MD5_openssl=de62b43dfcd858e66a74bee1c834e959
77
BUILD_openssl=$BUILD_PATH/openssl/$(get_directory $URL_openssl)
88
RECIPE_openssl=$RECIPES_PATH/openssl
99

0 commit comments

Comments
 (0)