implemented QrCode scanner feature for android and dekstop app

This commit is contained in:
navjot 2021-05-25 22:47:39 +05:30
parent 1afb59a2ad
commit 9333ade8cc
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
5 changed files with 15 additions and 13 deletions

View File

@ -60,6 +60,8 @@ class ScanScreen(Screen):
else: else:
print("Camera is not available!") print("Camera is not available!")
self.camera_avaialbe = False self.camera_avaialbe = False
else:
self.camera_avaialbe = True
def get_screen(self, screen_name, instance=None): def get_screen(self, screen_name, instance=None):
"""This method is used for getting previous screen name""" """This method is used for getting previous screen name"""
@ -74,7 +76,8 @@ class ScanScreen(Screen):
""" """
if not self.children: if not self.children:
tmp = Builder.load_file( tmp = Builder.load_file(
os.path.join(os.path.dirname(__file__), "kv/{}.kv").format("scanner") os.path.join(
os.path.dirname(os.path.dirname(__file__)), "kv/{}.kv").format("scanner")
) )
self.add_widget(tmp) self.add_widget(tmp)
if platform == "android": if platform == "android":

View File

@ -58,11 +58,11 @@ import ast
from bitmessagekivy.baseclass.common import toast from bitmessagekivy.baseclass.common import toast
if platform != "android":
from kivy.config import Config
from kivy_garden.zbarcam import ZBarCam from kivy_garden.zbarcam import ZBarCam
from pyzbar.pyzbar import ZBarSymbol from pyzbar.pyzbar import ZBarSymbol
if platform != "android":
from kivy.config import Config
Config.set("input", "mouse", "mouse, multitouch_on_demand") Config.set("input", "mouse", "mouse, multitouch_on_demand")
elif platform == "android": elif platform == "android":
from jnius import autoclass, cast from jnius import autoclass, cast
@ -944,10 +944,10 @@ class NavigateApp(MDApp):
print("Purchasing {} through {}".format(self.product_id, method_name)) print("Purchasing {} through {}".format(self.product_id, method_name))
def _after_scan(self, text): def _after_scan(self, text):
if platform == 'android': # if platform == 'android':
text = cast(CharSequence, String(text)) # toast_txt = cast(CharSequence, String(text))
show_toast(text, Toast.LENGTH_SHORT) # show_toast(toast_txt, Toast.LENGTH_SHORT)
elif self.root.ids.sc23.previous_open_screen == 'composer': if self.root.ids.sc23.previous_open_screen == 'composer':
self.root.ids.sc3.children[1].ids.txt_input.text = text self.root.ids.sc3.children[1].ids.txt_input.text = text
self.root.ids.scr_mngr.current = 'create' self.root.ids.scr_mngr.current = 'create'
elif self.root.ids.sc23.previous_open_screen: elif self.root.ids.sc23.previous_open_screen:

View File

@ -46,10 +46,9 @@ requirements =
libiconv, libiconv,
libzbar, libzbar,
pillow, pillow,
pyzbar,
bitmsghash, bitmsghash,
#git+https://github.com/navjotcis/KivyMD#egg=kivymd,
git+https://github.com/kivymd/KivyMD#egg=kivymd, git+https://github.com/kivymd/KivyMD#egg=kivymd,
#kivymd,
qrcode, qrcode,
msgpack msgpack
@ -100,7 +99,7 @@ fullscreen = 0
#android.presplash_color = #FFFFFF #android.presplash_color = #FFFFFF
# (list) Permissions # (list) Permissions
android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE, CAMERA
# (int) Target Android API, should be as high as possible. # (int) Target Android API, should be as high as possible.
android.api = 29 android.api = 29

View File

@ -24,7 +24,7 @@
icon_size: dp(70) icon_size: dp(70)
id: camera id: camera
resolution: 640, 480 #1920, 1080 # # # resolution: 640, 480 #1920, 1080 # #
allow_stretch: True allow_stretch: True
# Shoot button # Shoot button

View File

@ -8,7 +8,7 @@
XCamera: XCamera:
id: xcamera id: xcamera
play: True play: True
resolution: root.resolution # resolution: root.resolution
allow_stretch: True allow_stretch: True
keep_ratio: True keep_ratio: True
center: self.size and proxy.center center: self.size and proxy.center