Skip to content

Commit 55a309c

Browse files
committed
do_share
1 parent b6ec14f commit 55a309c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

eventsapp/uix/screens/screentalks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from kivy.properties import StringProperty
77
from kivy.properties import ObjectProperty
88
from functools import partial
9+
from utils import do_share
910

1011
app = App.get_running_app()
1112

@@ -80,8 +81,10 @@ class ScreenTalks(Screen):
8081
height: dp(54)
8182
padding: dp(9)
8283
ImBut
84+
id: but_share
8385
source: 'atlas://data/default/share'
8486
color: app.base_active_bright[:3] + [.9]
87+
on_release: do_share(self.data, "PyCon India 2018")
8588
ImBut
8689
source: 'atlas://data/default/reminder'
8790
color: app.base_active_bright[:3] + [.9]
@@ -122,6 +125,8 @@ def on_enter(self, onsuccess=False):
122125
gl = GridLayout(cols=social_len, size_hint_y=None,
123126
padding='2dp', spacing='2dp')
124127
import webbrowser
128+
self.ids.but_share.data = "Checkout this talk "\
129+
+ speaker_social['cfp'] + " by " + speaker['name']
125130
for social_acc, social_link in items:
126131
imbt = Factory.ImBut()
127132
imbt.source = 'atlas://data/default/' + \

eventsapp/utils/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ def pause_app():
1919
app.stop()
2020

2121

22+
def do_share(data, title):
23+
if platform != 'android':
24+
return
25+
from jnius import autoclass, cast
26+
JS = autoclass('java.lang.String')
27+
Intent = autoclass('android.content.Intent')
28+
sendIntent = Intent()
29+
sendIntent.setAction(Intent.ACTION_SEND)
30+
sendIntent.setType("text/plain")
31+
sendIntent.putExtra(Intent.EXTRA_TEXT, JS(data))
32+
PythonActivity = autoclass('org.kivy.android.PythonActivity')
33+
currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
34+
it = Intent.createChooser(sendIntent, cast('java.lang.CharSequence', JS(title)))
35+
currentActivity.startActivity(it)
36+
37+
2238
def scan_qr(on_complete):
2339
if platform != 'android':
2440
return

0 commit comments

Comments
 (0)