-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
198 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.