Merge pull request #219 from TouchInstinct/add/extension-browser-intent
MOBILE-1144
This commit is contained in:
commit
a1db8b8ac2
|
|
@ -6,6 +6,7 @@ import android.content.Intent
|
|||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import ru.touchin.roboswag.core.log.Lc
|
||||
import android.provider.Browser
|
||||
|
||||
fun Context.safeStartActivity(intent: Intent, options: Bundle? = null) =
|
||||
try {
|
||||
|
|
@ -18,6 +19,18 @@ fun Context.openBrowser(url: String) = Intent(Intent.ACTION_VIEW)
|
|||
.setData(Uri.parse(url))
|
||||
.let { intent -> safeStartActivity(intent) }
|
||||
|
||||
fun Context.openBrowserWithHeaders(url: String, headersMap: Map<String, String>) = Intent(Intent.ACTION_VIEW)
|
||||
.setData(Uri.parse(url))
|
||||
.let { intent ->
|
||||
val bundle = Bundle().apply {
|
||||
headersMap.forEach { (key, value) ->
|
||||
putString(key, value)
|
||||
}
|
||||
}
|
||||
intent.putExtra(Browser.EXTRA_HEADERS, bundle)
|
||||
safeStartActivity(intent)
|
||||
}
|
||||
|
||||
fun Context.callToPhoneNumber(phoneNumber: String) = Intent(Intent.ACTION_VIEW)
|
||||
.setData(Uri.parse("tel:$phoneNumber"))
|
||||
.let { intent -> safeStartActivity(intent) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue