Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

104 add http protocol if user website is missing it #108

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ private fun UserProfileDetails(
val context = LocalContext.current
val uiScope = rememberCoroutineScope()
val keyCopiedText = stringResource(id = R.string.settings_keys_key_copied)
val protocolPrefix = "http"
val protocolPrefixReplacement = "https://"

Column(
modifier = Modifier
Expand Down Expand Up @@ -715,17 +717,23 @@ private fun UserProfileDetails(
}

if (state.profileDetails?.website?.isNotEmpty() == true) {
val websiteWithProtocol = if (state.profileDetails.website.startsWith(protocolPrefix, true)) {
state.profileDetails.website
} else {
protocolPrefixReplacement + state.profileDetails.website
}

UserWebsiteText(
website = state.profileDetails.website,
onClick = {
try {
localUriHandler.openUri(state.profileDetails.website)
localUriHandler.openUri(websiteWithProtocol)
} catch (error: ActivityNotFoundException) {
Timber.w(error)
uiScope.launch {
Toast.makeText(
context,
"App not found that could open ${state.profileDetails.website}.",
"App not found that could open $websiteWithProtocol.",
Toast.LENGTH_SHORT,
).show()
}
Expand Down
Loading