Skip to content

Commit

Permalink
Merge branch 'release/2019.0907'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Sep 7, 2019
2 parents eb648c5 + ed1e3fa commit e52c1ca
Show file tree
Hide file tree
Showing 14 changed files with 198 additions and 77 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log

## [20190902]
## [2019.0907]

- Update buildozer, p4a, and ndk versions, refs #21
- Publish to F-Droid, refs #20
- Improve Android camera permission handling, refs #12, #16
- Use upstream autofocus, refs #8

## [2019.0902]

- Update Cython for Python3.7 support, refs #35
- Make garden.zbarcam a package again, refs #36
Expand Down
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ PIP=$(VENV_NAME)/bin/pip
TOX=`which tox`
GARDEN=$(VENV_NAME)/bin/garden
PYTHON=$(VENV_NAME)/bin/python
ISORT=$(VENV_NAME)/bin/isort
FLAKE8=$(VENV_NAME)/bin/flake8
TWINE=`which twine`
SOURCES=src/ tests/ setup.py setup_meta.py
# using full path so it can be used outside the root dir
SPHINXBUILD=$(shell realpath venv/bin/sphinx-build)
DOCS_DIR=doc
Expand Down Expand Up @@ -116,7 +120,27 @@ test:

uitest: virtualenv
$(PIP) install -r requirements/test_requirements.txt
$(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/
PYTHONPATH=src $(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/

isort-check:
$(ISORT) --check-only --recursive --diff $(SOURCES)

isort-fix:
$(ISORT) --recursive $(SOURCES)

flake8:
$(FLAKE8) $(SOURCES)

lint: isort-check flake8

docs:
cd $(DOCS_DIR) && SPHINXBUILD=$(SPHINXBUILD) make html

release/build:
rm -rf dist/ build/
$(PYTHON) setup.py sdist bdist_wheel
$(PYTHON) setup_meta.py sdist bdist_wheel
$(TWINE) check dist/*

release/upload:
$(TWINE) upload dist/*
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# zbarcam

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

Real time Barcode and QR Code scanner using the camera.
It's built on top of [Kivy](https://github.com/kivy/kivy) and [pyzbar](https://github.com/NaturalHistoryMuseum/pyzbar).
Expand All @@ -23,7 +25,7 @@ BoxLayout:
size: self.texture_size[0], 50
text: ', '.join([str(symbol.data) for symbol in zbarcam.symbols])
```
A full working demo is available in [kivy_garden/zbarcam/main.py](kivy_garden/zbarcam/main.py).
A full working demo is available in [src/main.py](https://github.com/kivy-garden/zbarcam/blob/master/src/main.py).
## Install
Expand Down
38 changes: 32 additions & 6 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ garden_requirements = xcamera
# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png
# (str) Supported orientation (one of landscape, portrait or all)
# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = portrait
# (list) List of service to declare
Expand Down Expand Up @@ -106,7 +106,7 @@ android.minapi = 21
android.sdk = 20
# (str) Android NDK version to use
android.ndk = 17c
android.ndk = 19b
# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
android.ndk_api = 21
Expand Down Expand Up @@ -164,8 +164,8 @@ android.accept_sdk_license = True
# bootstrap)
#android.gradle_dependencies =
# (str) python-for-android branch to use, defaults to master
p4a.branch = master
# (list) Java classes to add as activities to the manifest.
#android.add_activites = com.example.ExampleActivity
# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
Expand All @@ -177,9 +177,13 @@ p4a.branch = master
# (str) XML file to include as an intent filters in <activity> tag
#android.manifest.intent_filters =
# (list) Android additionnal libraries to copy into libs/armeabi
# (str) launchMode to set for the main activity
#android.manifest.launch_mode = standard
# (list) Android additional libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
#android.add_libs_arm64_v8a = libs/android-v8/*.so
#android.add_libs_x86 = libs/android-x86/*.so
#android.add_libs_mips = libs/android-mips/*.so
Expand All @@ -194,19 +198,28 @@ p4a.branch = master
# project.properties automatically.)
#android.library_references =
# (list) Android shared libraries which will be added to AndroidManifest.xml using <uses-library> tag
#android.uses_library =
# (str) Android logcat filters to use
#android.logcat_filters = *:S python:D
# (bool) Copy library instead of making a libpymodules.so
#android.copy_libs = 1
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
android.arch = armeabi-v7a
#
# Python for android (p4a) specific
#
# (str) python-for-android fork to use, defaults to upstream (kivy)
#p4a.fork = kivy
# (str) python-for-android branch to use, defaults to master
p4a.branch = develop
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#p4a.source_dir =
Expand All @@ -219,13 +232,26 @@ android.arch = armeabi-v7a
# (str) Bootstrap to use for android builds
# p4a.bootstrap = sdl2
# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
#p4a.port =
#
# iOS specific
#
# (str) Path to a custom kivy-ios folder
#ios.kivy_ios_dir = ../kivy-ios
# Alternately, specify the URL and branch of a git checkout:
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master
# Another platform dependency: ios-deploy
# Uncomment to use a custom checkout
#ios.ios_deploy_dir = ../ios_deploy
# Or specify URL and branch
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.7.0
# (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities
Expand Down
4 changes: 2 additions & 2 deletions doc/source/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ This is documenting the release process.
Make sure the CHANGELOG.md is up to date and follows the http://keepachangelog.com guidelines.
Start the release with git flow:
```sh
git flow release start YYYYMMDD
git flow release start YYYY.MMDD
```
Now update the [CHANGELOG.md](/CHANGELOG.md) `[Unreleased]` section to match the new release version.
Also update the `version` string from the
[src/kivy_garden/zbarcam/version.py](https://github.com/kivy-garden/zbarcam/blob/develop/src/kivy_garden/zbarcam/version.py)
file.
Then commit and finish release.
```sh
git commit -a -m "YYYYMMDD"
git commit -a -m "YYYY.MMDD"
git flow release finish
```
Push everything, make sure tags are also pushed:
Expand Down
20 changes: 11 additions & 9 deletions dockerfiles/Dockerfile-android
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ ENV USER="user"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}" \
PATH="${HOME_DIR}/.local/bin:${PATH}"
ENV DOCKERFILES_VERSION="master" \
ENV DOCKERFILES_VERSION="v20190902" \
DOCKERFILES_URL="https://raw.githubusercontent.com/AndreMiras/dockerfiles"
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android_new"
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android"
ENV BUILDOZER_VERSION="182d13f"


# configure locale
Expand All @@ -31,22 +32,23 @@ ENV LANG="en_US.UTF-8" \
RUN apt install -qq --yes --no-install-recommends \
autoconf \
automake \
cmake \
make \
ca-certificates \
cmake \
curl \
gettext \
libffi-dev \
libltdl-dev \
libpython2.7-dev \
libpython3.6-dev \
libtool \
file \
make \
openjdk-8-jdk \
pkg-config \
python3.6 \
python3-setuptools \
python-pip \
python-setuptools \
python3-pip \
python3-setuptools \
python \
sudo \
unzip \
xz-utils \
Expand All @@ -64,8 +66,8 @@ WORKDIR ${WORK_DIR}
# install buildozer and dependencies
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk
RUN make -f buildozer.mk
# enforces buildozer master (cf880a3) until next release
RUN pip install --upgrade https://github.com/kivy/buildozer/archive/cf880a3.zip
# enforces buildozer master until next release
RUN pip3 install --upgrade https://github.com/kivy/buildozer/archive/${BUILDOZER_VERSION}.zip

COPY . ${WORK_DIR}
# limits the amount of logs for Travis
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from setuptools import find_namespace_packages, setup

from src.kivy_garden.zbarcam import version


Expand Down
44 changes: 44 additions & 0 deletions src/kivy_garden/zbarcam/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from kivy.utils import platform
from PIL import ImageOps


def is_android():
return platform == 'android'


def is_ios():
return platform == 'ios'


def check_camera_permission():
"""
Android runtime `CAMERA` permission check.
"""
if not is_android():
return True
from android.permissions import Permission, check_permission
permission = Permission.CAMERA
return check_permission(permission)


def check_request_camera_permission(callback=None):
"""
Android runtime `CAMERA` permission check & request.
"""
had_permission = check_camera_permission()
if not had_permission:
from android.permissions import Permission, request_permissions
permissions = [Permission.CAMERA]
request_permissions(permissions, callback)
return had_permission


def fix_android_image(pil_image):
"""
On Android, the image seems mirrored and rotated somehow, refs #32.
"""
if not is_android():
return pil_image
pil_image = pil_image.rotate(90)
pil_image = ImageOps.mirror(pil_image)
return pil_image
8 changes: 7 additions & 1 deletion src/kivy_garden/zbarcam/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
__version__ = '2019.0902'
__version__ = '2019.0907'
# The `__version_code__` is used for the F-Droid auto update and should match
# the `versionCode` from the `build.gradle` file located in:
# `.buildozer/android/platform/build/dists/zbarcamdemo/`
# The auto update method used is the `HTTP`, see:
# https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
__version_code__ = 721202807
8 changes: 4 additions & 4 deletions src/kivy_garden/zbarcam/zbarcam.kv
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#:import XCamera kivy.garden.xcamera.XCamera
#:import is_android kivy_garden.zbarcam.utils.is_android
<ZBarCam>:
Widget:
# invert width/height on rotated Android
# https://stackoverflow.com/a/45192295/185510
id: proxy
XCamera:
CustomXCamera:
id: xcamera
play: True
resolution: root.resolution
allow_stretch: True
keep_ratio: True
center: self.size and proxy.center
size:
(proxy.height, proxy.width) if root.is_android() \
(proxy.height, proxy.width) if is_android() \
else (proxy.width, proxy.height)
# Android camera rotation workaround, refs:
# https://github.com/AndreMiras/garden.zbarcam/issues/3
canvas.before:
PushMatrix
Rotate:
angle: -90 if root.is_android() else 0
angle: -90 if is_android() else 0
origin: self.center
canvas.after:
PopMatrix
Loading

0 comments on commit e52c1ca

Please sign in to comment.