Skip to content

Commit 7a30836

Browse files
author
Egor Komarov
committed
[IT-487]: add mailto intent query
1 parent 5c7820e commit 7a30836

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

sdk/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'com.github.ogon-ru'
8-
version = '1.0.8'
8+
version = '1.0.9'
99

1010
android {
1111
compileSdkVersion 31
@@ -14,8 +14,8 @@ android {
1414
defaultConfig {
1515
minSdkVersion 19
1616
targetSdkVersion 31
17-
versionCode 30
18-
versionName '1.0.8'
17+
versionCode 31
18+
versionName '1.0.9'
1919

2020
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2121

sdk/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<category android:name="android.intent.category.BROWSABLE" />
3838
<data android:scheme="http" />
3939
</intent>
40+
<intent>
41+
<action android:name="android.intent.action.SENDTO" />
42+
<data android:scheme="mailto" />
43+
</intent>
4044
<intent>
4145
<action android:name="android.media.action.IMAGE_CAPTURE" />
4246
</intent>

sdk/src/main/java/ru/ogon/sdk/handlers/OpenUrlEventHandler.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ class OpenUrlEventHandler(private val context: Context) : MobileEventHandler {
1010
override fun handle(event: MobileEvent): Boolean = event.takeIf {
1111
it.type == MobileEventType.MOBILE_EVENT_OPEN_URL_REQUEST
1212
}?.let {
13-
val webpage = Uri.parse(it.openUrlRequest)
14-
val intent = Intent(Intent.ACTION_VIEW, webpage)
13+
val uri = Uri.parse(it.openUrlRequest)
14+
val intent = when(uri.scheme) {
15+
"mailto" -> Intent(Intent.ACTION_SENDTO, uri)
16+
else -> Intent(Intent.ACTION_VIEW, uri)
17+
}
1518
if (intent.resolveActivity(context.packageManager) != null) {
1619
context.startActivity(intent)
1720
}

0 commit comments

Comments
 (0)