added google inapp purchase and qrcode scanner feature

This commit is contained in:
surbhicis 2020-06-10 16:45:20 +05:30
parent 487eab6f78
commit 14c5984a1b
Signed by untrusted user: surbhicis
GPG Key ID: 48A8C2D218DE7B0B
9 changed files with 808 additions and 288 deletions

View File

@ -2,19 +2,29 @@ astroid==2.3.3
certifi==2019.9.11 certifi==2019.9.11
chardet==3.0.4 chardet==3.0.4
docutils==0.15.2 docutils==0.15.2
flake8==3.8.2
idna==2.8 idna==2.8
importlib-metadata==1.6.0
isort==4.3.21 isort==4.3.21
Kivy==1.11.1 Kivy==1.11.1
Kivy-Garden==0.1.4 Kivy-Garden==0.1.4
-e git+https://github.com/surbhicis/KivyMD-1#egg=kivymd kivy-garden.qrcode==2019.914
kivymd==0.104.0
lazy-object-proxy==1.4.3 lazy-object-proxy==1.4.3
mccabe==0.6.1 mccabe==0.6.1
numpy==1.18.4
opencv-python==4.2.0.34
Pillow==6.1.0 Pillow==6.1.0
pycodestyle==2.6.0
pydenticon==0.3.1 pydenticon==0.3.1
pyflakes==2.2.0
Pygments==2.4.2 Pygments==2.4.2
pylint==2.4.4 pylint==2.4.4
pyzbar==0.1.8
qrcode==6.1 qrcode==6.1
requests==2.22.0 requests==2.22.0
six==1.12.0 six==1.12.0
typed-ast==1.4.0 typed-ast==1.4.0
urllib3==1.25.6 urllib3==1.25.6
wrapt==1.11.2
zipp==3.1.0

View File

@ -54,7 +54,8 @@
MDIconButton: MDIconButton:
icon: 'qrcode-scan' icon: 'qrcode-scan'
pos_hint: {'center_x': 0, 'center_y': .8} pos_hint: {'center_x': 0, 'center_y': .8}
on_press: root.qrScanner() on_release:
app.root.ids.scr_mngr.current = 'scanscreen'
MyMDTextField: MyMDTextField:
id: subject id: subject

View File

@ -1,120 +1,303 @@
#:import SlideTransition kivy.uix.screenmanager.SlideTransition
<Login>: <Login>:
name: 'login' name:"login"
ScrollView: BoxLayout:
do_scroll_x: False orientation: "vertical"
#buttons-area-outer
BoxLayout: BoxLayout:
orientation: 'vertical' size_hint_y: .53
size_hint_y: None canvas:
height: dp(450) + self.minimum_height Color:
padding: dp(10) rgba: 1,1,1,1
BoxLayout: Rectangle:
MDLabel: pos: self.pos
font_style: 'Subtitle2' size: self.size
theme_text_color: 'Primary'
text: root.log_text1 ScreenManager:
halign: 'left' id: check_screenmgr
color:app.theme_cls.primary_dark Screen:
BoxLayout: name: "check_screen"
MDLabel: BoxLayout:
font_style: 'Subtitle2' orientation: "vertical"
theme_text_color: 'Primary' padding: 0, dp(5), 0, dp(5)
text: root.log_text2 spacing: dp(5)
halign: 'left'
color:app.theme_cls.primary_dark #label area
Widget: AnchorLayout:
size_hint: (None, None) size_hint_y: None
height: dp(10) height: dp(50)
MDCheckbox: MDLabel:
id: grp_chkbox_1 text: "Select method to make an address:"
group: 'test' bold: True
size_hint: None, None halign: "center"
size: dp(48), dp(48) theme_text_color: "Custom"
pos_hint: {'center_x': .5, 'center_y': .5} text_color: .4,.4,.4,1
active: True
allow_no_selection: False #upper-checkbor-area
MDLabel: AnchorLayout:
font_style: 'Body2' size_hint_y: None
theme_text_color: 'Primary' height: dp(40)
text: "use a random number generator to make an address" BoxLayout:
halign: 'center' size_hint_x: None
size_hint_y: None width: self.minimum_width
height: self.texture_size[1] + dp(4)
color: [0.941, 0, 0,1] #check-container
MDCheckbox: AnchorLayout:
id: grp_chkbox_1 size_hint_x: None
group: 'test' width: dp(40)
size_hint: None, None Check:
size: dp(48), dp(48) active: True
pos_hint: {'center_x': .5, 'center_y': .5}
allow_no_selection: False #text-container
MDLabel: AnchorLayout:
font_style: 'Body2' size_hint_x: None
theme_text_color: 'Primary' width: dp(200)
text: "use a pseudo number generator to make an address" MDLabel:
halign: 'center' text: "Random Number Generator"
size_hint_y: None
color: [0.941, 0, 0,1] AnchorLayout:
height: self.texture_size[1] + dp(4) size_hint_y: None
BoxLayout: height: dp(40)
AnchorLayout: BoxLayout:
MDRaisedButton: size_hint_x: None
size_hint: (.2, None) width: self.minimum_width
# height: dp(40)
on_press: app.root.ids.scr_mngr.current = 'random' #check-container
on_press: app.root.ids.sc7.reset_address_label() AnchorLayout:
MDLabel: size_hint_x: None
font_style: 'H6' width: dp(40)
text: 'proceed' Check:
font_size: '13sp'
color: (1,1,1,1) #text-container
halign: 'center' AnchorLayout:
size_hint_x: None
width: dp(200)
MDLabel:
text: "Pseudo Number Generator"
AnchorLayout:
MDFillRoundFlatIconButton:
icon: "chevron-double-right"
text: "Proceed Next"
on_release:
app.root.ids.scr_mngr.current = 'random'
on_press:
app.root.ids.sc7.reset_address_label(app)
Screen:
name: "label_screen"
BoxLayout:
orientation: "vertical"
padding: 0, dp(5), 0, dp(5)
spacing: dp(5)
#label area
AnchorLayout:
size_hint_y: None
height: dp(50)
MDLabel:
text: "Enter a label to generate address for:"
bold: True
halign: "center"
theme_text_color: "Custom"
text_color: .4,.4,.4,1
AnchorLayout:
size_hint_y: None
height: dp(40)
MDTextField:
hint_text: "Label"
required: True
size_hint_x: None
width: dp(190)
AnchorLayout:
MDFillRoundFlatIconButton:
icon: "chevron-double-right"
text: "Proceed Next"
Widget:
#info-area-outer
BoxLayout:
size_hint_y: .47
padding: dp(7)
InfoLayout:
orientation:"vertical"
padding: 0, dp(5), 0, dp(5)
canvas:
Color:
rgba:1,1,1,1
Rectangle:
pos: self.pos
size: self.size
Color:
rgba: app.theme_cls.primary_color
Line:
rounded_rectangle: (self.pos[0]+4, self.pos[1]+4, self.width-8,self.height-8, 10, 10, 10, 10, 50)
width: dp(1)
ScreenManager:
id: info_screenmgr
Screen:
name: "info1"
ScrollView:
bar_width:0
do_scroll_x: False
BoxLayout:
orientation: "vertical"
size_hint_y: None
height: self.minimum_height
#note area
ContentHead:
section_name: "NOTE:"
ContentBody:
section_text: ("You may generate addresses by using either random numbers or by using a pass-phrase.If you use a pass-phrase, the address is called a deterministic address. The Random Number option is selected by default but deterministic addresses may have several pros and cons.")
#pros area
ContentHead:
section_name: "PROS:"
ContentBody:
section_text: ("You can re-create your addresses on any computer from memory you need-not-to worry about backing up your keys.dat file as long as you can remember your pass-phrase.")
#cons area
ContentHead:
section_name: "CONS:"
ContentBody:
section_text: ("You must remember (or write down) your address version number and the stream number along with your pass-phrase.If you choose a weak pass-phrase and someone on the internet can brute-force it, they can read your messages and send messages as you.")
<Random>: <Random>:
name: 'random' name:"random"
ScrollView: BoxLayout:
id: add_random_bx orientation: "vertical"
id:add_random_bx
#buttons-area-outer
BoxLayout:
size_hint_y: .53
canvas:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
<RandomBoxlayout>: ScreenManager:
orientation: 'vertical' id: check_screenmgr
Screen:
name: "label_screen"
BoxLayout:
orientation: "vertical"
padding: 0, dp(5), 0, dp(5)
spacing: dp(5)
#label area
AnchorLayout:
size_hint_y: None
height: dp(50)
MDLabel:
text: "Enter a label to generate address for:"
bold: True
halign: "center"
theme_text_color: "Custom"
text_color: .4,.4,.4,1
AnchorLayout:
size_hint_y: None
height: dp(40)
MDTextField:
id:lab
hint_text: "Label"
required: True
size_hint_x: None
width: dp(190)
helper_text_mode: "on_error"
helper_text: "Please enter your label name"
AnchorLayout:
MDFillRoundFlatIconButton:
icon: "chevron-double-right"
text: "Proceed Next"
on_release: app.root.ids.sc7.generateaddress(app)
Widget:
#info-area-outer
BoxLayout:
size_hint_y: .47
padding: dp(7)
InfoLayout:
orientation:"vertical"
padding: 0, dp(5), 0, dp(5)
canvas:
Color:
rgba:1,1,1,1
Rectangle:
pos: self.pos
size: self.size
Color:
rgba: app.theme_cls.primary_color
Line:
rounded_rectangle: (self.pos[0]+4, self.pos[1]+4, self.width-8,self.height-8, 10, 10, 10, 10, 50)
width: dp(1)
ScreenManager:
id: info_screenmgr
Screen:
name: "info2"
ScrollView:
bar_width:0
do_scroll_x: False
BoxLayout:
orientation: "vertical"
size_hint_y: None
height: self.minimum_height
#note area
ContentHead:
section_name: "NOTE:"
ContentBody:
section_text: ("Here you may generate as many addresses as you like..Indeed creating and abandoning addresses is not encouraged.")
<Check@MDCheckbox>:
group: 'group'
size_hint: None, None
size: dp(48), dp(48)
<ContentHead@BoxLayout>:
section_name: ""
orientation: "vertical"
size_hint_y: None
height: dp(50)
padding: dp(20), 0, 0, 0
Widget:
size_hint_y: None
height: dp(25)
MDLabel:
theme_text_color: "Custom"
text_color: .1,.1,.1,.9
text: root.section_name
bold: True
font_style: "Button"
<ContentBody@BoxLayout>:
section_text: ""
size_hint_y: None size_hint_y: None
height: self.minimum_height height: self.minimum_height
padding: dp(20) padding: dp(50), 0, dp(10), 0
spacing: 100
MDLabel:
font_style: 'Subtitle2'
theme_text_color: 'Primary'
text: "Random Addresses"
halign: 'center'
color:app.theme_cls.primary_dark
MDLabel: MDLabel:
font_style: 'Subtitle2' size_hint_y: None
theme_text_color: 'Primary' height: self.texture_size[1]+dp(10)
text: "Here you may generate as many addresses as you like, Indeed creating and abandoning addresses is encouraged" theme_text_color: "Custom"
halign: 'left' text_color: 0.3,0.3,0.3,1
color:app.theme_cls.primary_dark font_style: "Body1"
text: root.section_text
MDTextField:
id: label
multiline: False
hint_text: "Label"
required: True
helper_text_mode: "on_error"
on_text: app.root.ids.sc7.add_validation(self)
canvas.before:
Color:
rgba: (0,0,0,1)
BoxLayout:
AnchorLayout:
MDRaisedButton:
size_hint: (.2, None)
# height: dp(40)
on_release: app.root.ids.sc7.generateaddress(app)
opposite_colors: True
MDLabel:
font_style: 'H6'
text: 'next'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'

View File

@ -1,148 +1,253 @@
#:import get_color_from_hex kivy.utils.get_color_from_hex
<Payment>: <Payment>:
name: 'payment' name: "payment"
ScrollView: BoxLayout:
do_scroll_x: False ScrollView:
bar_width:0
do_scroll_x: False
#scroll_y:0
BoxLayout:
spacing: dp(8)
padding: dp(5)
size_hint_y: None
height: self.minimum_height
orientation: "vertical"
ProductCategoryLayout:
category_text: "Monthly-Subscriptions"
ProductLayout:
heading_text: "Gas (Play Billing Codelab)"
price_text: "$0.99"
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/buynew1.png"
description_text: "Buy gasoline to ride!"
product_id: "SKUGASBILLING"
ProductLayout:
heading_text: "Upgrade your car (Play Billing Codelab)"
price_text: "$1.49"
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/buynew1.png"
description_text: "Buy a premium outfit for your car!"
product_id: "SKUUPGRADECAR"
ProductLayout:
heading_text: "Month in gold status (Play Billing Codelab)"
price_text: "$0.99"
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/buynew1.png"
description_text: "Enjoy a gold status for a month!"
product_id: "SKUMONTHLYGOLD"
ProductCategoryLayout:
category_text: "One-time payment"
ProductLayout:
heading_text: "Gas (Play Billing Codelab)"
price_text: "$0.99"
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/buynew1.png"
description_text: "Buy gasoline to ride!"
product_id: "SKUONETIMEGAS"
ProductCategoryLayout:
category_text: "Annual-Subscriptions"
ProductLayout:
heading_text: "Gas (Play Billing Codelab)"
price_text: "$0.99"
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/buynew1.png"
description_text: "Buy gasoline to ride!"
product_id: "SKUANNUALGAS"
ProductLayout:
heading_text: "Year in gold status (Play Billing Codelab)"
price_text: "$10.99"
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/buynew1.png"
description_text: "Enjoy a gold status for a year!"
product_id: "SKUANNUALGOLD"
<ProductCategoryLayout@BoxLayout>:
size_hint_y: None
height: self.minimum_height
category_text:""
orientation: "vertical"
spacing: 2
#category area
Category:
text_: root.category_text
<Category>:
canvas:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
text_: ""
size_hint_y: None
height: dp(30)
Widget:
size_hint_x: None
width: dp(20)
MDLabel:
text: root.text_
font_size: sp(15)
<ProductLayout>:
heading_text: ""
price_text: ""
source: ""
description_text: ""
product_id: ""
canvas:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
size_hint_y: None
height: dp(200)
orientation: "vertical"
#heading area
BoxLayout:
size_hint_y: 0.3
#text heading
BoxLayout: BoxLayout:
orientation: 'vertical' Widget:
padding: [dp(app.window_size[0]/16 if app.window_size[0] <= 720 else app.window_size[0]/6 if app.window_size[0] <= 800 else app.window_size[0]/18), dp(10)] size_hint_x: None
spacing: 12 width: dp(20)
size_hint_y: None MDLabel:
height: self.minimum_height + dp(app.window_size[1]) if app.window_size[1] > app.window_size[0] else dp(app.window_size[0]) text: root.heading_text
bold: True
#price text
BoxLayout:
size_hint_x:.3
MDLabel:
text: root.price_text
bold: True
halign: "right"
theme_text_color: "Custom"
text_color: 0,0,1,1
Widget:
size_hint_x: None
width: dp(20)
#details area
BoxLayout:
size_hint_y: 0.3
Widget:
size_hint_x: None
width: dp(20)
#image area
AnchorLayout:
size_hint_x: None
width: self.height
BoxLayout: BoxLayout:
orientation: 'vertical' canvas:
padding: dp(5)
canvas.before:
Color: Color:
rgba: app.theme_cls.primary_dark rgba: 1,1,1,1
Rectangle: Ellipse:
# self here refers to the widget i.e FloatLayout
pos: self.pos
size: self.size size: self.size
MDLabel:
size_hint_y: None
font_style: 'H5'
theme_text_color: 'Primary'
text: 'Platinum'
halign: 'center'
color: 1,1,1,1
MDLabel:
font_style: 'Subtitle1'
theme_text_color: 'Primary'
text: 'We provide subscriptions for proof of work calculation for first month. '
halign: 'center'
color: 1,1,1,1
MDLabel:
id: free_pak
font_style: 'H5'
theme_text_color: 'Primary'
text: '€ 50.0'
halign: 'center'
color: 1,1,1,1
MDRaisedButton:
canvas:
Color:
rgb: (0.93, 0.93, 0.93)
Rectangle:
pos: self.pos
size: self.size
size: app.window_size[0] - 2*self.parent.parent.padding[0] - dp(10) , 1
height: dp(40)
on_press: root.get_free_credits(self)
MDLabel:
font_style: 'H6'
text: 'Get Free Credits'
font_size: '13sp'
color: (0,0,0,1)
halign: 'center'
BoxLayout:
orientation: 'vertical'
padding: dp(5)
canvas.before:
Color:
rgba: app.theme_cls.primary_dark
Rectangle:
# self here refers to the widget i.e FloatLayout
pos: self.pos pos: self.pos
size: self.size source: root.source
MDLabel: Widget:
size_hint_y: None size_hint_x: None
font_style: 'H5' width: dp(10)
theme_text_color: 'Primary'
text: 'Silver' #description text
halign: 'center' BoxLayout:
color: 1,1,1,1 #size_hint_x: 1
MDLabel: MDLabel:
font_style: 'Subtitle1' text: root.description_text
theme_text_color: 'Primary' font_size: sp(15)
text: 'We provide for proof of work calculation for six month. '
halign: 'center' #Button Area
color: 1,1,1,1 BoxLayout:
MDLabel: size_hint_y: 0.4
id: py2 Widget:
font_style: 'H5'
theme_text_color: 'Primary' AnchorLayout:
text: '€ 100.0' anchor_x: "right"
halign: 'center' MDRaisedButton:
color: 1,1,1,1 elevation_normal: 5
MDRaisedButton: text: "BUY"
canvas: on_release:
Color: #print(app)
rgb: (0.93, 0.93, 0.93) app.open_payment_layout(root.product_id)
Rectangle:
pos: self.pos Widget:
size: self.size size_hint_x: None
size: app.window_size[0] - 2*self.parent.parent.padding[0] - dp(10) , 1 width: dp(20)
height: dp(40)
on_press: root.create_hidden_payment_address(self) <ListItemWithLabel>:
MDLabel: on_release: app.initiate_purchase(self.method_name)
font_style: 'H6' recent: False
text: 'Buy 100 Credits' source: ""
font_size: '13sp' method_name: ""
color: (0,0,0,1) right_label_text: "Recent" if self.recent else ""
halign: 'center'
BoxLayout: ImageLeftWidget:
orientation: 'vertical' source: root.source
padding: dp(5)
canvas.before: RightLabel:
Color: text: root.right_label_text
rgba: app.theme_cls.primary_dark theme_text_color: "Custom"
Rectangle: text_color: 0,0,0,.4
# self here refers to the widget i.e FloatLayout font_size: sp(12)
pos: self.pos
size: self.size <PaymentMethodLayout>:
MDLabel: orientation: "vertical"
size_hint_y: None size_hint_y: None
font_style: 'H5' height: "200dp"
theme_text_color: 'Primary'
text: 'Gold' BoxLayout:
halign: 'center' size_hint_y: None
color: 1,1,1,1 height: dp(40)
MDLabel:
font_style: 'Subtitle1' Widget:
theme_text_color: 'Primary' size_hint_x: None
text: 'We provide for proof of work calculation for 1years. ' width: dp(20)
halign: 'center' MDLabel:
color: 1,1,1,1 text: "Select Payment Method"
MDLabel: font_size: sp(14)
id: py3 bold: True
font_style: 'H5' theme_text_color: "Custom"
theme_text_color: 'Primary' text_color: 0,0,0,.5
text: '€ 500.0'
halign: 'center'
color: 1,1,1,1 ScrollView:
MDRaisedButton:
canvas: GridLayout:
Color: cols: 1
rgb: (0.93, 0.93, 0.93) size_hint_y:None
Rectangle: height:self.minimum_height
pos: self.pos
size: self.size ListItemWithLabel:
size: app.window_size[0] - 2*self.parent.parent.padding[0] - dp(10) , 1 source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/gplay.png"
height: dp(40) text: "Google Play"
on_press: root.create_hidden_payment_address(self) method_name: "gplay"
MDLabel: recent: True
font_style: 'H6'
text: 'Buy 500 Credits' ListItemWithLabel:
font_size: '13sp' source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/btc.png"
color: (0,0,0,1) text: "BTC"
halign: 'center' method_name: "btc"
ListItemWithLabel:
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/paypal.png"
text: "Paypal"
method_name: "som"
ListItemWithLabel:
source: "/home/surbhi/Downloads/peter3/PyBitmessage/src/images/buy.png"
text: "One more method"
method_name: "omm"

View File

@ -79,6 +79,9 @@
MDRaisedButton: MDRaisedButton:
size_hint: 2, None size_hint: 2, None
height: dp(40) height: dp(40)
on_press: root.dismiss()
on_release:
app.root.ids.scr_mngr.current = 'scanscreen'
MDLabel: MDLabel:
font_style: 'H6' font_style: 'H6'
text: 'Scan QR code' text: 'Scan QR code'

View File

@ -16,6 +16,7 @@
#:import MDScrollViewRefreshLayout kivymd.uix.refreshlayout.MDScrollViewRefreshLayout #:import MDScrollViewRefreshLayout kivymd.uix.refreshlayout.MDScrollViewRefreshLayout
#:import MDSpinner kivymd.uix.spinner.MDSpinner #:import MDSpinner kivymd.uix.spinner.MDSpinner
#:import MDTabsBase kivymd.uix.tab.MDTabsBase #:import MDTabsBase kivymd.uix.tab.MDTabsBase
#:import ZBarSymbol pyzbar.pyzbar.ZBarSymbol
<Tab@BoxLayout+MDTabsBase> <Tab@BoxLayout+MDTabsBase>
#:set color_button (0.784, 0.443, 0.216, 1) # brown #:set color_button (0.784, 0.443, 0.216, 1) # brown
@ -180,8 +181,8 @@
on_release: app.root.ids.scr_mngr.current = 'set' on_release: app.root.ids.scr_mngr.current = 'set'
on_release: root.parent.set_state() on_release: root.parent.set_state()
NavigationItem: NavigationItem:
text: 'Payment' text: 'Purchase'
icon: 'bell' icon: 'shopping'
divider: None divider: None
on_release: app.root.ids.scr_mngr.current = 'payment' on_release: app.root.ids.scr_mngr.current = 'payment'
on_release: root.parent.set_state() on_release: root.parent.set_state()
@ -273,6 +274,8 @@ NavigationLayout:
id:sc21 id:sc21
ChatList: ChatList:
id:sc22 id:sc22
ScanScreen:
id:sc23
MDNavigationDrawer: MDNavigationDrawer:
id: nav_drawer id: nav_drawer
@ -342,3 +345,9 @@ NavigationLayout:
color: 0,0,0,1 color: 0,0,0,1
color: 0,0,0,1 color: 0,0,0,1
<ScanScreen>:
name:'scanscreen'

View File

@ -4,6 +4,71 @@ Bitmessage android(mobile) interface
# pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument # pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument
# pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation # pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation
# pylint: disable=protected-access # pylint: disable=protected-access
from sys import platform as _sys_platform
from os import environ
'''
We need to check platform and set environ for KIVY_CAMERA, if requires, before importing kivy.
We cannot use sys.platform directly because it returns 'linux' on android devices as well.
We cannot use kivy.util.platform beacuse it imports kivy beforehand and thus setting environ
after that doesn't make any sense.
So we needed to copy the `_get_platform` function from kivy.utils
'''
def _get_platform():
# On Android sys.platform returns 'linux2', so prefer to check the
# existence of environ variables set during Python initialization
kivy_build = environ.get('KIVY_BUILD', '')
if kivy_build in {'android', 'ios'}:
return kivy_build
elif 'P4A_BOOTSTRAP' in environ:
return 'android'
elif 'ANDROID_ARGUMENT' in environ:
# We used to use this method to detect android platform,
# leaving it here to be backwards compatible with `pydroid3`
# and similar tools outside kivy's ecosystem
return 'android'
elif _sys_platform in ('win32', 'cygwin'):
return 'win'
elif _sys_platform == 'darwin':
return 'macosx'
elif _sys_platform.startswith('linux'):
return 'linux'
elif _sys_platform.startswith('freebsd'):
return 'linux'
return 'unknown'
platform= _get_platform()
if platform=='android':
from jnius import autoclass, cast
from android.runnable import run_on_ui_thread
from android import python_act as PythonActivity
Toast= autoclass('android.widget.Toast')
String = autoclass('java.lang.String')
CharSequence= autoclass('java.lang.CharSequence')
context= PythonActivity.mActivity
@run_on_ui_thread
def show_toast(text, length):
t= Toast.makeText(context, text, length)
t.show()
else:
'''
After tweaking a little bit with opencv camera, it's possible to make camera
go on and off as required while the app is still running.
Other camera provider such as `gi` has some issue upon closing the camera.
by setting KIVY_CAMERA environment variable before importing kivy, we are forcing it to use opencv camera provider.
'''
environ['KIVY_CAMERA']='opencv'
import os import os
import time import time
from bitmessagekivy import identiconGeneration from bitmessagekivy import identiconGeneration
@ -71,6 +136,11 @@ import state
from addresses import decodeAddress from addresses import decodeAddress
from kivy.uix.modalview import ModalView from kivy.uix.modalview import ModalView
from datetime import datetime from datetime import datetime
from kivymd.uix.behaviors.elevation import RectangularElevationBehavior
from kivymd.uix.bottomsheet import MDCustomBottomSheet
from kivy.effects.dampedscroll import DampedScrollEffect
from kivy_garden.zbarcam import ZBarCam
from pyzbar.pyzbar import ZBarSymbol
if platform != 'android': if platform != 'android':
from kivy.config import Config from kivy.config import Config
@ -832,6 +902,57 @@ class DropDownWidget(BoxLayout):
"""This method is used for scanning Qr code""" """This method is used for scanning Qr code"""
pass pass
class ScanScreen(Screen):
def on_pre_enter(self):
'''
on_pre_enter works little better on android
It affects screen transition on linux
'''
if not self.children:
tmp= Builder.load_file(os.path.join(os.path.dirname(__file__), "kv/{}.kv").format('scanner'))
self.add_widget(tmp)
if platform=='android':
Clock.schedule_once(self.start_camera, 0)
def on_enter(self):
'''
on_enter works better on linux
It creates a black screen on android until camera gets loaded
'''
#print(self.children)
if platform!='android':
#pass
Clock.schedule_once(self.start_camera, 0)
def on_leave(self):
#pass
Clock.schedule_once(self.stop_camera, 0)
def start_camera(self, *args):
self.xcam= self.children[0].ids.zbarcam.ids.xcamera
#pass
#self.xxx= self.children[0].ids.zbarcam.ids.xcamera
#print(self.cam._device.isOpened())
if platform=='android':
self.xcam.play= True
else:
Clock.schedule_once(self.open_cam, 0)
def stop_camera(self, *args):
#print(self.children[0].ids.zbarcam.ids.xcamera.play)
self.xcam.play= False
#self.xcam._camera.stop()
#self.children[0].ids.zbarcam.stop()
if platform != 'android':
self.xcam._camera._device.release()
def open_cam(self, *args):
if not self.xcam._camera._device.isOpened():
self.xcam._camera._device.open(self.xcam._camera._index)
self.xcam.play= True
class MyTextInput(TextInput): class MyTextInput(TextInput):
"""Takes the text input in the field""" """Takes the text input in the field"""
@ -902,6 +1023,23 @@ class Payment(Screen):
payloadLengthExtraBytes)) payloadLengthExtraBytes))
toast('hidden payment address Creating for buying subscription....') toast('hidden payment address Creating for buying subscription....')
class Category(BoxLayout, RectangularElevationBehavior):
elevation_normal= .01
class ProductLayout(BoxLayout, RectangularElevationBehavior):
elevation_normal= .01
class PaymentMethodLayout(BoxLayout):
pass
class ListItemWithLabel(OneLineAvatarIconListItem):
pass
class RightLabel(IRightBodyTouch, MDLabel):
pass
class HomeScreen(Screen):
pass
class Credits(Screen): class Credits(Screen):
"""Credits Method""" """Credits Method"""
@ -987,9 +1125,10 @@ class Random(Screen):
def generateaddress(self, navApp): def generateaddress(self, navApp):
"""Method for Address Generator""" """Method for Address Generator"""
entered_label = str(self.ids.add_random_bx.children[0].ids.label.text).strip() entered_label = str(self.ids.lab.text).strip()
if not entered_label: if not entered_label:
self.ids.add_random_bx.children[0].ids.label.focus = True self.ids.lab.focus = True
# self.ids.add_random_bx.children[0].ids.label.focus = True
# self.ids.label.error = True # self.ids.label.error = True
# self.ids.label.helper_text = 'This field is required' # self.ids.label.helper_text = 'This field is required'
streamNumberForAddress = 1 streamNumberForAddress = 1
@ -1045,7 +1184,7 @@ class Random(Screen):
instance.error = False instance.error = False
instance.helper_text = 'This field is required' instance.helper_text = 'This field is required'
def reset_address_label(self): def reset_address_label(self, n):
"""Resetting address labels""" """Resetting address labels"""
if not self.ids.add_random_bx.children: if not self.ids.add_random_bx.children:
self.ids.add_random_bx.add_widget(RandomBoxlayout()) self.ids.add_random_bx.add_widget(RandomBoxlayout())
@ -2081,9 +2220,26 @@ class NavigateApp(MDApp):
def reset_login_screen(self): def reset_login_screen(self):
"""This method is used for clearing random screen""" """This method is used for clearing random screen"""
if self.root.ids.sc7.ids.add_random_bx.children: # if self.root.ids.sc7.ids.add_random_bx.children:
self.root.ids.sc7.ids.add_random_bx.clear_widgets() # self.root.ids.sc7.ids.add_random_bx.clear_widgets()
def open_payment_layout(self, sku):
pml= PaymentMethodLayout()
self.product_id= sku
self.custom_sheet= MDCustomBottomSheet(screen= pml)
self.custom_sheet.open()
def initiate_purchase(self, method_name):
#self.custom_sheet.dismiss()
print("Purchasing {} through {}".format(self.product_id, method_name))
def _after_scan(self, text):
if platform=='android':
text= cast(CharSequence, String(text))
show_toast(text,Toast.LENGTH_SHORT)
else:
self.root.ids.sc3.children[1].ids.txt_input.text = text
self.root.ids.scr_mngr.current = 'create'
class GrashofPopup(Popup): class GrashofPopup(Popup):
"""Moule for save contacts and error messages""" """Moule for save contacts and error messages"""
@ -2199,6 +2355,8 @@ class GrashofPopup(Popup):
text = "Some data encoded in the address is malformed." text = "Some data encoded in the address is malformed."
return text return text
class InfoLayout(BoxLayout, RectangularElevationBehavior):
pass
class AvatarSampleWidget(ILeftBody, Image): class AvatarSampleWidget(ILeftBody, Image):
"""Avatar Sample Widget""" """Avatar Sample Widget"""
@ -2515,7 +2673,7 @@ class ShowQRCode(Screen):
"""Method used for showing QR Code""" """Method used for showing QR Code"""
self.ids.qr.clear_widgets() self.ids.qr.clear_widgets()
state.kivyapp.set_toolbar_for_QrCode() state.kivyapp.set_toolbar_for_QrCode()
from kivy.garden.qrcode import QRCodeWidget from kivy_garden.qrcode import QRCodeWidget
try: try:
address = self.manager.get_parent_window().children[0].address address = self.manager.get_parent_window().children[0].address
except Exception: except Exception:

View File

@ -1,19 +1,19 @@
[app] [app]
# (str) Title of your application # (str) Title of your application
title = py3 title = tor
# (str) Package name # (str) Package name
package.name = py3 package.name = tor
# (str) Package domain (needed for android/ios packaging) # (str) Package domain (needed for android/ios packaging)
package.domain = org.test package.domain = org.kel
# (str) Source code where the main.py live # (str) Source code where the main.py live
source.dir = . source.dir = .
# (list) Source files to include (let empty to include all the files) # (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas,gif,zip source.include_exts = py,png,jpg,kv,atlas,gif,zip, json, css, ttf,java
# (list) List of inclusions using pattern matching # (list) List of inclusions using pattern matching
#source.include_patterns = assets/*,images/*.png #source.include_patterns = assets/*,images/*.png
@ -38,17 +38,22 @@ version = 0.1
# comma separated e.g. requirements = sqlite3,kivy # comma separated e.g. requirements = sqlite3,kivy
requirements = requirements =
python3, python3,
android,
openssl, openssl,
sqlite3, sqlite3,
kivy, kivy,
pyjnius,
libiconv,
libzbar,
pillow,
bitmsghash, bitmsghash,
#git+https://github.com/surbhicis/KivyMD-1.git, #git+https://github.com/surbhicis/KivyMD-1.git,
git+https://github.com/surbhicis/KivyMD-1#egg=kivymd, git+https://github.com/surbhicis/KivyMD-1#egg=kivymd,
kivy-garden, kivy-garden,
qrcode, qrcode,
Pillow,
msgpack msgpack
# (str) Custom source folders for requirements # (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes # Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy # requirements.source.kivy = ../../kivy
@ -60,7 +65,7 @@ garden_requirements = qrcode
#presplash.filename = %(source.dir)s/data/presplash.png #presplash.filename = %(source.dir)s/data/presplash.png
# (str) Icon of the application # (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png #icon.filename = %(source.dir)s/logo.png
# (str) Supported orientation (one of landscape, portrait or all) # (str) Supported orientation (one of landscape, portrait or all)
orientation = portrait orientation = portrait
@ -98,20 +103,23 @@ fullscreen = 0
# (list) Permissions # (list) Permissions
android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE
# (int) Android API to use # (int) Target Android API, should be as high as possible.
android.api = 27 android.api = 29
# (int) Minimum API required # (int) Minimum API your APK will support.
android.minapi = 21 android.minapi = 21
# (int) Android SDK version to use # (int) Android SDK version to use
android.sdk = 20 android.sdk = 20
# (str) Android NDK version to use # (str) Android NDK version to use
android.ndk = 17c #android.ndk = 17c
# (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
# (bool) Use --private data storage (True) or --dir public storage (False) # (bool) Use --private data storage (True) or --dir public storage (False)
# android.private_storage = True #android.private_storage = True
# (str) Android NDK directory (if empty, it will be automatically downloaded.) # (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path = #android.ndk_path =
@ -127,9 +135,18 @@ android.ndk = 17c
# when an update is due and you just want to test/build your package # when an update is due and you just want to test/build your package
# android.skip_update = False # android.skip_update = False
# (bool) If True, then automatically accept SDK license
# agreements. This is intended for automation only. If set to False,
# the default, you will be shown the license when first running
# buildozer.
# android.accept_sdk_license = False
# (str) Android entry point, default is ok for Kivy-based app # (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity #android.entrypoint = org.renpy.android.PythonActivity
# (str) Android app theme, default is ok for Kivy-based app
# android.apptheme = "@android:style/Theme.NoTitleBar"
# (list) Pattern to whitelist for the whole project # (list) Pattern to whitelist for the whole project
#android.whitelist = #android.whitelist =
@ -143,11 +160,11 @@ android.ndk = 17c
# their classes. Don't add jars that you do not need, since extra jars can slow # their classes. Don't add jars that you do not need, since extra jars can slow
# down the build process. Allows wildcards matching, for example: # down the build process. Allows wildcards matching, for example:
# OUYA-ODK/libs/*.jar # OUYA-ODK/libs/*.jar
#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar #android.add_jars = libs/*.jar
# (list) List of Java files to add to the android project (can be java or a # (list) List of Java files to add to the android project (can be java or a
# directory containing the files) # directory containing the files)
#android.add_src = #android.add_src = Config.java
# (list) Android AAR archives to add (currently works only with sdl2_gradle # (list) Android AAR archives to add (currently works only with sdl2_gradle
# bootstrap) # bootstrap)
@ -157,12 +174,26 @@ android.ndk = 17c
# bootstrap) # bootstrap)
#android.gradle_dependencies = #android.gradle_dependencies =
# (list) add java compile options
# this can for example be necessary when importing certain java libraries using the 'android.gradle_dependencies' option
# see https://developer.android.com/studio/write/java8-support for further information
# android.add_compile_options = "sourceCompatibility = 1.8", "targetCompatibility = 1.8"
# (list) Gradle repositories to add {can be necessary for some android.gradle_dependencies}
# please enclose in double quotes
# e.g. android.gradle_repositories = "maven { url 'https://kotlin.bintray.com/ktor' }"
#android.add_gradle_repositories =
# (list) packaging options to add
# see https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
# can be necessary to solve conflicts in gradle_dependencies
# please enclose in double quotes
# e.g. android.add_packaging_options = "exclude 'META-INF/common.kotlin_module'", "exclude 'META-INF/*.kotlin_module'"
#android.add_gradle_repositories =
# (list) Java classes to add as activities to the manifest. # (list) Java classes to add as activities to the manifest.
#android.add_activites = com.example.ExampleActivity #android.add_activites = com.example.ExampleActivity
# (str) python-for-android branch to use, defaults to stable
p4a.branch = master
# (str) OUYA Console category. Should be one of GAME or APP # (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled # If you leave this blank, OUYA support will not be enabled
#android.ouya.category = GAME #android.ouya.category = GAME
@ -179,6 +210,7 @@ p4a.branch = master
# (list) Android additional libraries to copy into libs/armeabi # (list) Android additional libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so #android.add_libs_armeabi = libs/android/*.so
#android.add_libs_armeabi_v7a = libs/android-v7/*.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_x86 = libs/android-x86/*.so
#android.add_libs_mips = libs/android-mips/*.so #android.add_libs_mips = libs/android-mips/*.so
@ -193,24 +225,33 @@ p4a.branch = master
# project.properties automatically.) # project.properties automatically.)
#android.library_references = #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 # (str) Android logcat filters to use
#android.logcat_filters = *:S python:D #android.logcat_filters = *:S python:D
# (bool) Copy library instead of making a libpymodules.so # (bool) Copy library instead of making a libpymodules.so
#android.copy_libs = 1 #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 android.arch = arm64-v8a
# #
# Python for android (p4a) specific # 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) # (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
p4a.source_dir = /home/cis/Music/androidp4a/python-for-android #p4a.source_dir =
# (str) The directory in which python-for-android should look for your own build recipes (if any) # (str) The directory in which python-for-android should look for your own build recipes (if any)
p4a.local_recipes = /home/cis/navjotrepo/PyBitmessage/src/bitmessagekivy/android/python-for-android/recipes/ p4a.local_recipes = /home/surbhi/Downloads/peter3/PyBitmessage/src/bitmessagekivy/android/python-for-android/recipes/
# (str) Filename to the hook for p4a # (str) Filename to the hook for p4a
#p4a.hook = #p4a.hook =
@ -228,6 +269,16 @@ p4a.local_recipes = /home/cis/navjotrepo/PyBitmessage/src/bitmessagekivy/android
# (str) Path to a custom kivy-ios folder # (str) Path to a custom kivy-ios folder
#ios.kivy_ios_dir = ../kivy-ios #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 # (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities # Get a list of available identities: buildozer ios list_identities

View File

@ -1,8 +1,8 @@
"""This module is for thread start.""" """This module is for thread start."""
import state import state
from bitmessagemain import main
if __name__ == '__main__': if __name__ == '__main__':
state.kivy = True state.kivy = True
print("Kivy Loading for PyBitmessage......") print("Kivy Loading......")
from bitmessagemain import main
main() main()