Skip to content

Commit

Permalink
Merge branch 'release/v20171022'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Oct 22, 2017
2 parents 728f7bc + 6c47962 commit e544036
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ before_install:
# https://kivy.org/docs/installation/installation-linux.html#dependencies-with-sdl2
- sudo apt-get install python-pip build-essential git python-dev
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev
# Required for the project
- sudo apt-get install libzbar-dev

install:
- sudo pip install coveralls
Expand Down
8 changes: 8 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
* pydevp2p
* fix broken tests:
* https://github.com/ethereum/pydevp2p/commit/8e1f2b2ef28ecba22bf27eac346bfa7007eaf0fe
* python-for-android recipes
* secp256k1
* `env['CFLAGS'] += ' -I' + join(libsecp256k1_dir, 'include')` # note the `+=`
* `env['INCLUDE_DIR'] = join(libsecp256k1_dir, 'include')` # see secp256k1-py README.md
* `env['LIB_DIR'] = join(libsecp256k1_dir, '.libs')` # see secp256k1-py README.md
* `env['LDFLAGS'] += ' -L' + join(libsecp256k1_dir, '.libs')` # note the `.libs`
* But in fact passing the library path ("LIB_DIR" and "LDFLAGS") may not be required
because libsecp256k1 recipe has `self.install_libs(arch, *libs)`
* MISC
* kill running threads on application leave
so it doesn't hangs when you quite while the thread tries to connect
11 changes: 8 additions & 3 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,20 @@ requirements =
secp256k1,
qrcode,
contextlib2,
raven
raven,
libiconv,
libzbar,
zbar,
pil,
https://github.com/AndreMiras/garden.zbarcam/archive/20171020.zip
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy
# (list) Garden requirements
#garden_requirements =
garden_requirements = qrcode
garden_requirements = qrcode, xcamera
# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png
Expand Down Expand Up @@ -115,7 +120,7 @@ fullscreen = 0
# (list) Permissions
#android.permissions = INTERNET
android.permissions = INTERNET
android.permissions = INTERNET, CAMERA
# (int) Android API to use
#android.api = 19
Expand Down
13 changes: 13 additions & 0 deletions docs/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Installing `test_requirements.txt` is only required if you want to contribute an

You can also take a look at [script_linux.sh](/travis/script_linux.sh) to see how it's being automated for Travis.

### Linux Camera support (optional)
See [OpenCV.md](/docs/OpenCV.md).

## Ubuntu host, Android target
To be able to build the project for Android from Ubuntu, follow python-for-android official guide (for core dependencies):
Expand All @@ -27,3 +29,14 @@ Before installing additional dependencies.
sudo apt install zlib1g-dev default-jdk
```
Check [script_android.sh](/travis/script_android.sh) or [Dockerfile](https://github.com/AndreMiras/PyWallet/blob/feature/ticket37_travis_docker/Dockerfile) to see two different ways to do it in Travis.

## Gentoo 64 host, Android target
Build zlib in 32-bit:
```
echo 'sys-libs/zlib abi_x86_32' >> /etc/portage/package.use
emerge -1av sys-libs/zlib
```
Install buildozer outside the virtualenv:
```
pip install --user buildozer
```
22 changes: 22 additions & 0 deletions docs/OpenCV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OpenCV

## Linux Camera support
In order to be able to use the camera on Linux, you need to compile OpenCV.
Simply installing `opencv-python` from pypi is not enough.
Currently only OpenCV2 works with Kivy on Linux (see https://github.com/kivy/kivy/issues/5404).
Download and extract the OpenCV2 archive:
```
wget https://github.com/opencv/opencv/archive/2.4.13.3.tar.gz -O opencv-2.4.13.3.tar.gz
tar -xvzf opencv-2.4.13.3.tar.gz
```
Prepare and build:
```
cd opencv-2.4.13.3/
mkdir build && cd build/
cmake ..
make -j4
```
Copy your compiled `cv2.so` to your virtualenv:
```
cp lib/cv2.so venv/lib/python2.7/site-packages/cv2.so
```
6 changes: 6 additions & 0 deletions docs/Troubleshoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ Fix it by installing autogen autoconf and libtool:
sudo apt install autogen autoconf libtool
```

Buildozer fails with when building cffi:
```
c/_cffi_backend.c:13:17: fatal error: ffi.h: No such file or directory
```
See upstream ticket: https://github.com/kivy/python-for-android/issues/1148


## Kivy

Expand Down
1 change: 1 addition & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Kivy-Garden==0.1.4
https://gitlab.com/kivymd/KivyMD/repository/archive.zip?ref=7de5790274a45c4fa2fb9c6fcd875645e536c95b
Pillow==4.1.1
raven==6.1.0
https://github.com/AndreMiras/garden.zbarcam/archive/20171016.zip
4 changes: 4 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [v20171022]

- Add flash QR Code support, refs #85

## [v20170920]

- Fix flaky scrypt test, refs #59
Expand Down
47 changes: 47 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,45 @@ class AboutScreen(Screen):
pass


class FlashQrCodeScreen(Screen):

def __init__(self, **kwargs):
super(FlashQrCodeScreen, self).__init__(**kwargs)
self.setup()

def setup(self):
"""
Binds Controller.current_account property.
"""
self.controller = App.get_running_app().controller
self.zbarcam = self.ids.zbarcam_id

def bind_on_symbols(self):
"""
Since the camera doesn't seem to stop properly, we always bind/unbind
on_pre_enter/on_pre_leave.
"""
self.zbarcam.bind(symbols=self.on_symbols)

def unbind_on_symbols(self):
"""
Since the camera doesn't seem to stop properly, makes sure at least
events are unbound.
"""
self.zbarcam.unbind(symbols=self.on_symbols)

def on_symbols(self, instance, symbols):
# also ignores if more than 1 code were found since we don't want to
# send to the wrong one
if len(symbols) != 1:
return
symbol = symbols[0]
# update Send screen address
self.controller.send.send_to_address = symbol.data
self.zbarcam.play = False
self.controller.load_landing_page()


class Controller(FloatLayout):

current_account = ObjectProperty()
Expand Down Expand Up @@ -1024,6 +1063,7 @@ def screen_manager_current(self, current, direction=None):
'overview': OverviewScreen,
'switch_account': SwitchAccountScreen,
'manage_keystores': ManageKeystoreScreen,
'flashqrcode': FlashQrCodeScreen,
'about': AboutScreen,
}
screen_manager = self.screen_manager
Expand Down Expand Up @@ -1332,6 +1372,13 @@ def load_create_new_account(self):
manage_keystores.ids.create_new_account_nav_item_id
create_new_account_nav_item.dispatch('on_tab_press')

def load_flash_qr_code(self):
"""
Loads the flash QR Code screen.
"""
# loads the flash QR Code screen
self.screen_manager_current('flashqrcode', direction='left')

def load_about_screen(self):
"""
Loads the about screen.
Expand Down
25 changes: 25 additions & 0 deletions src/pywallet.kv
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#:kivy 1.10.0

#:import ZBarCam zbarcam
#:import ROUND_DIGITS pywalib.ROUND_DIGITS
#:import webbrowser webbrowser
#:import Window kivy.core.window.Window
#:import platform kivy.utils.platform
#:import MDList kivymd.list.MDList
#:import MDSlider kivymd.slider.MDSlider
#:import MDTextField kivymd.textfields.MDTextField
Expand Down Expand Up @@ -84,6 +86,9 @@
write_tab: False
text: root.send_to_address
on_text: root.send_to_address = args[1]
MDRaisedButton:
text: "Flash QR Code"
on_release: app.controller.load_flash_qr_code()
FloatInput:
hint_text: "Amount ETH (e.g. 1.10)"
required: True
Expand Down Expand Up @@ -413,6 +418,26 @@
id: manage_keystores_id


<FlashQrCodeScreen@BoxLayout>:
on_pre_enter:
zbarcam_id.play = True
self.bind_on_symbols()
on_pre_leave:
zbarcam_id.play = False
self.unbind_on_symbols()
ZBarCam:
id: zbarcam_id
# Android camera rotation workaround, refs:
# https://github.com/AndreMiras/garden.zbarcam/issues/3
canvas.before:
PushMatrix
Rotate:
angle: -90 if platform == 'android' else 0
origin: self.center
canvas.after:
PopMatrix


<AboutScreen>:
name: 'about'
on_pre_enter:
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2017.0920'
__version__ = '2017.1022'

0 comments on commit e544036

Please sign in to comment.