Skip to content

Commit

Permalink
Fixed bug where the Chrome custom tab would crash if the scheme was m…
Browse files Browse the repository at this point in the history
…issing from the Url.
  • Loading branch information
jguerinet committed Jul 1, 2017
1 parent 6b1569b commit 7798ac7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion util/src/main/java/com/guerinet/suitcase/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ object Utils {
@JvmStatic
fun openCustomTab(context: Context, url: String, @ColorRes toolbarColor: Int? = null,
@DrawableRes closeButtonId: Int? = null) {
// Check that the scheme is present, add it if not
val fullUrl : String
if (!url.startsWith("http://", true) && !url.startsWith("https://", true)) {
fullUrl = "http://" + url
} else {
fullUrl = url
}

val builder = CustomTabsIntent.Builder()
.addDefaultShareMenuItem()

Expand All @@ -102,7 +110,7 @@ object Utils {
}

// Build and launch
builder.build().launchUrl(context, Uri.parse(url))
builder.build().launchUrl(context, Uri.parse(fullUrl))
}

/**
Expand Down

0 comments on commit 7798ac7

Please sign in to comment.