blob: 79923e46cd805f2551cec0c77a949297f8dd4309 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
from jnius import autoclass, cast
from plyer.facades import Email
from plyer.platforms.android import activity
Intent = autoclass('android.content.Intent')
AndroidString = autoclass('java.lang.String')
class AndroidEmail(Email):
def _send(self, **kwargs):
intent = Intent(Intent.ACTION_SEND)
intent.setType('text/plain')
recipient = kwargs.get('recipient')
subject = kwargs.get('subject')
text = kwargs.get('text')
create_chooser = kwargs.get('create_chooser')
if recipient:
intent.putExtra(Intent.EXTRA_EMAIL, [recipient])
if subject:
android_subject = cast('java.lang.CharSequence',
AndroidString(subject))
intent.putExtra(Intent.EXTRA_SUBJECT, android_subject)
if text:
android_text = cast('java.lang.CharSequence',
AndroidString(text))
intent.putExtra(Intent.EXTRA_TEXT, android_text)
if create_chooser:
chooser_title = cast('java.lang.CharSequence',
AndroidString('Send message with:'))
activity.startActivity(Intent.createChooser(intent,
chooser_title))
else:
activity.startActivity(intent)
def instance():
return AndroidEmail()
|