Skip to content

Commit e52c1ca

Browse files
committed
Merge branch 'release/2019.0907'
2 parents eb648c5 + ed1e3fa commit e52c1ca

File tree

14 files changed

+198
-77
lines changed

14 files changed

+198
-77
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22

3-
## [20190902]
3+
## [2019.0907]
4+
5+
- Update buildozer, p4a, and ndk versions, refs #21
6+
- Publish to F-Droid, refs #20
7+
- Improve Android camera permission handling, refs #12, #16
8+
- Use upstream autofocus, refs #8
9+
10+
## [2019.0902]
411

512
- Update Cython for Python3.7 support, refs #35
613
- Make garden.zbarcam a package again, refs #36

Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ PIP=$(VENV_NAME)/bin/pip
33
TOX=`which tox`
44
GARDEN=$(VENV_NAME)/bin/garden
55
PYTHON=$(VENV_NAME)/bin/python
6+
ISORT=$(VENV_NAME)/bin/isort
7+
FLAKE8=$(VENV_NAME)/bin/flake8
8+
TWINE=`which twine`
9+
SOURCES=src/ tests/ setup.py setup_meta.py
610
# using full path so it can be used outside the root dir
711
SPHINXBUILD=$(shell realpath venv/bin/sphinx-build)
812
DOCS_DIR=doc
@@ -116,7 +120,27 @@ test:
116120

117121
uitest: virtualenv
118122
$(PIP) install -r requirements/test_requirements.txt
119-
$(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/
123+
PYTHONPATH=src $(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/
124+
125+
isort-check:
126+
$(ISORT) --check-only --recursive --diff $(SOURCES)
127+
128+
isort-fix:
129+
$(ISORT) --recursive $(SOURCES)
130+
131+
flake8:
132+
$(FLAKE8) $(SOURCES)
133+
134+
lint: isort-check flake8
120135

121136
docs:
122137
cd $(DOCS_DIR) && SPHINXBUILD=$(SPHINXBUILD) make html
138+
139+
release/build:
140+
rm -rf dist/ build/
141+
$(PYTHON) setup.py sdist bdist_wheel
142+
$(PYTHON) setup_meta.py sdist bdist_wheel
143+
$(TWINE) check dist/*
144+
145+
release/upload:
146+
$(TWINE) upload dist/*

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# zbarcam
22

33
[![Build Status](https://travis-ci.org/kivy-garden/zbarcam.svg?branch=develop)](https://travis-ci.org/kivy-garden/zbarcam)
4+
[![PyPI version](https://badge.fury.io/py/zbarcam.svg)](https://badge.fury.io/py/zbarcam)
5+
[![Documentation Status](https://readthedocs.org/projects/zbarcam/badge/?version=latest)](https://zbarcam.readthedocs.io/en/latest/?badge=latest)
46

57
Real time Barcode and QR Code scanner using the camera.
68
It's built on top of [Kivy](https://github.com/kivy/kivy) and [pyzbar](https://github.com/NaturalHistoryMuseum/pyzbar).
@@ -23,7 +25,7 @@ BoxLayout:
2325
size: self.texture_size[0], 50
2426
text: ', '.join([str(symbol.data) for symbol in zbarcam.symbols])
2527
```
26-
A full working demo is available in [kivy_garden/zbarcam/main.py](kivy_garden/zbarcam/main.py).
28+
A full working demo is available in [src/main.py](https://github.com/kivy-garden/zbarcam/blob/master/src/main.py).
2729
2830
## Install
2931

buildozer.spec

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ garden_requirements = xcamera
6060
# (str) Icon of the application
6161
#icon.filename = %(source.dir)s/data/icon.png
6262
63-
# (str) Supported orientation (one of landscape, portrait or all)
63+
# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
6464
orientation = portrait
6565
6666
# (list) List of service to declare
@@ -106,7 +106,7 @@ android.minapi = 21
106106
android.sdk = 20
107107
108108
# (str) Android NDK version to use
109-
android.ndk = 17c
109+
android.ndk = 19b
110110
111111
# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
112112
android.ndk_api = 21
@@ -164,8 +164,8 @@ android.accept_sdk_license = True
164164
# bootstrap)
165165
#android.gradle_dependencies =
166166
167-
# (str) python-for-android branch to use, defaults to master
168-
p4a.branch = master
167+
# (list) Java classes to add as activities to the manifest.
168+
#android.add_activites = com.example.ExampleActivity
169169
170170
# (str) OUYA Console category. Should be one of GAME or APP
171171
# If you leave this blank, OUYA support will not be enabled
@@ -177,9 +177,13 @@ p4a.branch = master
177177
# (str) XML file to include as an intent filters in <activity> tag
178178
#android.manifest.intent_filters =
179179
180-
# (list) Android additionnal libraries to copy into libs/armeabi
180+
# (str) launchMode to set for the main activity
181+
#android.manifest.launch_mode = standard
182+
183+
# (list) Android additional libraries to copy into libs/armeabi
181184
#android.add_libs_armeabi = libs/android/*.so
182185
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
186+
#android.add_libs_arm64_v8a = libs/android-v8/*.so
183187
#android.add_libs_x86 = libs/android-x86/*.so
184188
#android.add_libs_mips = libs/android-mips/*.so
185189
@@ -194,19 +198,28 @@ p4a.branch = master
194198
# project.properties automatically.)
195199
#android.library_references =
196200
201+
# (list) Android shared libraries which will be added to AndroidManifest.xml using <uses-library> tag
202+
#android.uses_library =
203+
197204
# (str) Android logcat filters to use
198205
#android.logcat_filters = *:S python:D
199206
200207
# (bool) Copy library instead of making a libpymodules.so
201208
#android.copy_libs = 1
202209
203-
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
210+
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
204211
android.arch = armeabi-v7a
205212
206213
#
207214
# Python for android (p4a) specific
208215
#
209216
217+
# (str) python-for-android fork to use, defaults to upstream (kivy)
218+
#p4a.fork = kivy
219+
220+
# (str) python-for-android branch to use, defaults to master
221+
p4a.branch = develop
222+
210223
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
211224
#p4a.source_dir =
212225
@@ -219,13 +232,26 @@ android.arch = armeabi-v7a
219232
# (str) Bootstrap to use for android builds
220233
# p4a.bootstrap = sdl2
221234
235+
# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
236+
#p4a.port =
237+
222238
223239
#
224240
# iOS specific
225241
#
226242
227243
# (str) Path to a custom kivy-ios folder
228244
#ios.kivy_ios_dir = ../kivy-ios
245+
# Alternately, specify the URL and branch of a git checkout:
246+
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
247+
ios.kivy_ios_branch = master
248+
249+
# Another platform dependency: ios-deploy
250+
# Uncomment to use a custom checkout
251+
#ios.ios_deploy_dir = ../ios_deploy
252+
# Or specify URL and branch
253+
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
254+
ios.ios_deploy_branch = 1.7.0
229255
230256
# (str) Name of the certificate to use for signing the debug version
231257
# Get a list of available identities: buildozer ios list_identities

doc/source/release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ This is documenting the release process.
88
Make sure the CHANGELOG.md is up to date and follows the http://keepachangelog.com guidelines.
99
Start the release with git flow:
1010
```sh
11-
git flow release start YYYYMMDD
11+
git flow release start YYYY.MMDD
1212
```
1313
Now update the [CHANGELOG.md](/CHANGELOG.md) `[Unreleased]` section to match the new release version.
1414
Also update the `version` string from the
1515
[src/kivy_garden/zbarcam/version.py](https://github.com/kivy-garden/zbarcam/blob/develop/src/kivy_garden/zbarcam/version.py)
1616
file.
1717
Then commit and finish release.
1818
```sh
19-
git commit -a -m "YYYYMMDD"
19+
git commit -a -m "YYYY.MMDD"
2020
git flow release finish
2121
```
2222
Push everything, make sure tags are also pushed:

dockerfiles/Dockerfile-android

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ ENV USER="user"
1414
ENV HOME_DIR="/home/${USER}"
1515
ENV WORK_DIR="${HOME_DIR}" \
1616
PATH="${HOME_DIR}/.local/bin:${PATH}"
17-
ENV DOCKERFILES_VERSION="master" \
17+
ENV DOCKERFILES_VERSION="v20190902" \
1818
DOCKERFILES_URL="https://raw.githubusercontent.com/AndreMiras/dockerfiles"
19-
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android_new"
19+
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android"
20+
ENV BUILDOZER_VERSION="182d13f"
2021

2122

2223
# configure locale
@@ -31,22 +32,23 @@ ENV LANG="en_US.UTF-8" \
3132
RUN apt install -qq --yes --no-install-recommends \
3233
autoconf \
3334
automake \
34-
cmake \
35-
make \
3635
ca-certificates \
36+
cmake \
3737
curl \
3838
gettext \
3939
libffi-dev \
4040
libltdl-dev \
41+
libpython2.7-dev \
4142
libpython3.6-dev \
4243
libtool \
43-
file \
44+
make \
4445
openjdk-8-jdk \
4546
pkg-config \
4647
python3.6 \
4748
python3-setuptools \
48-
python-pip \
49-
python-setuptools \
49+
python3-pip \
50+
python3-setuptools \
51+
python \
5052
sudo \
5153
unzip \
5254
xz-utils \
@@ -64,8 +66,8 @@ WORKDIR ${WORK_DIR}
6466
# install buildozer and dependencies
6567
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk
6668
RUN make -f buildozer.mk
67-
# enforces buildozer master (cf880a3) until next release
68-
RUN pip install --upgrade https://github.com/kivy/buildozer/archive/cf880a3.zip
69+
# enforces buildozer master until next release
70+
RUN pip3 install --upgrade https://github.com/kivy/buildozer/archive/${BUILDOZER_VERSION}.zip
6971

7072
COPY . ${WORK_DIR}
7173
# limits the amount of logs for Travis

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
from setuptools import find_namespace_packages, setup
4+
45
from src.kivy_garden.zbarcam import version
56

67

src/kivy_garden/zbarcam/utils.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from kivy.utils import platform
2+
from PIL import ImageOps
3+
4+
5+
def is_android():
6+
return platform == 'android'
7+
8+
9+
def is_ios():
10+
return platform == 'ios'
11+
12+
13+
def check_camera_permission():
14+
"""
15+
Android runtime `CAMERA` permission check.
16+
"""
17+
if not is_android():
18+
return True
19+
from android.permissions import Permission, check_permission
20+
permission = Permission.CAMERA
21+
return check_permission(permission)
22+
23+
24+
def check_request_camera_permission(callback=None):
25+
"""
26+
Android runtime `CAMERA` permission check & request.
27+
"""
28+
had_permission = check_camera_permission()
29+
if not had_permission:
30+
from android.permissions import Permission, request_permissions
31+
permissions = [Permission.CAMERA]
32+
request_permissions(permissions, callback)
33+
return had_permission
34+
35+
36+
def fix_android_image(pil_image):
37+
"""
38+
On Android, the image seems mirrored and rotated somehow, refs #32.
39+
"""
40+
if not is_android():
41+
return pil_image
42+
pil_image = pil_image.rotate(90)
43+
pil_image = ImageOps.mirror(pil_image)
44+
return pil_image

src/kivy_garden/zbarcam/version.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
__version__ = '2019.0902'
1+
__version__ = '2019.0907'
2+
# The `__version_code__` is used for the F-Droid auto update and should match
3+
# the `versionCode` from the `build.gradle` file located in:
4+
# `.buildozer/android/platform/build/dists/zbarcamdemo/`
5+
# The auto update method used is the `HTTP`, see:
6+
# https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
7+
__version_code__ = 721202807

src/kivy_garden/zbarcam/zbarcam.kv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
#:import XCamera kivy.garden.xcamera.XCamera
1+
#:import is_android kivy_garden.zbarcam.utils.is_android
22
<ZBarCam>:
33
Widget:
44
# invert width/height on rotated Android
55
# https://stackoverflow.com/a/45192295/185510
66
id: proxy
7-
XCamera:
7+
CustomXCamera:
88
id: xcamera
99
play: True
1010
resolution: root.resolution
1111
allow_stretch: True
1212
keep_ratio: True
1313
center: self.size and proxy.center
1414
size:
15-
(proxy.height, proxy.width) if root.is_android() \
15+
(proxy.height, proxy.width) if is_android() \
1616
else (proxy.width, proxy.height)
1717
# Android camera rotation workaround, refs:
1818
# https://github.com/AndreMiras/garden.zbarcam/issues/3
1919
canvas.before:
2020
PushMatrix
2121
Rotate:
22-
angle: -90 if root.is_android() else 0
22+
angle: -90 if is_android() else 0
2323
origin: self.center
2424
canvas.after:
2525
PopMatrix

0 commit comments

Comments
 (0)