From d585b9f2408a2f466d65c2e903d4ad2b6960111e Mon Sep 17 00:00:00 2001 From: Oleg Koretsky Date: Tue, 14 Jan 2025 14:09:23 +0200 Subject: [PATCH] Fix some not clickable links --- CHANGELOG.md | 1 + .../baker/BakerRegistrationOpenActivity.kt | 5 +- .../wallet/ui/more/about/AboutActivity.kt | 49 +++++++++++-------- app/src/main/res/values/strings.xml | 4 +- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c5234ea..ee122a58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixed - Incorrect support email address in some error messages +- Not working links to the documentation on some screens ### Removed diff --git a/app/src/main/java/com/concordium/wallet/ui/bakerdelegation/baker/BakerRegistrationOpenActivity.kt b/app/src/main/java/com/concordium/wallet/ui/bakerdelegation/baker/BakerRegistrationOpenActivity.kt index 53e001fb..fd73b29e 100644 --- a/app/src/main/java/com/concordium/wallet/ui/bakerdelegation/baker/BakerRegistrationOpenActivity.kt +++ b/app/src/main/java/com/concordium/wallet/ui/bakerdelegation/baker/BakerRegistrationOpenActivity.kt @@ -43,11 +43,14 @@ class BakerRegistrationOpenActivity : BaseDelegationBakerActivity( } } - binding.openUrlExplain.handleUrlClicks { url -> + fun onUrlClicked(url: String) { val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) ContextCompat.startActivity(this, browserIntent, null) } + binding.openUrlExplain.handleUrlClicks(::onUrlClicked) + binding.readMoreTextView.handleUrlClicks(::onUrlClicked) + binding.bakerRegistrationOpenContinue.setOnClickListener { KeyboardUtil.hideKeyboard(this) viewModel.bakerDelegationData.metadataUrl = binding.openUrl.text?.toString() diff --git a/app/src/main/java/com/concordium/wallet/ui/more/about/AboutActivity.kt b/app/src/main/java/com/concordium/wallet/ui/more/about/AboutActivity.kt index b3561fa5..5c769b33 100644 --- a/app/src/main/java/com/concordium/wallet/ui/more/about/AboutActivity.kt +++ b/app/src/main/java/com/concordium/wallet/ui/more/about/AboutActivity.kt @@ -26,33 +26,40 @@ class AboutActivity : BaseActivity( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - binding.aboutContactText.handleUrlClicks { url -> - val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) - ContextCompat.startActivity(this, browserIntent, null) - } + fun onUrlClicked(url: String) = when { + url == "#terms" -> { + startActivity(Intent(this, WelcomeTermsActivity::class.java)) + } + + url.startsWith("mailto") -> { + val emailIntent = Intent(Intent.ACTION_SENDTO) + emailIntent.data = Uri.parse(url) + emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(url)) + try { + // start email intent + startActivity( + Intent.createChooser( + emailIntent, + getString(R.string.about_support) + ) + ) + } catch (e: Exception) { + // Left empty on purpose + } + } - binding.aboutSupportText.handleUrlClicks { url -> - val emailIntent = Intent(Intent.ACTION_SENDTO) - emailIntent.data = Uri.parse(url) - emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(url)) - try { - // start email intent - startActivity(Intent.createChooser(emailIntent, getString(R.string.about_support))) - } catch (e: Exception) { - // Left empty on purpose + else -> { + val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + ContextCompat.startActivity(this, browserIntent, null) } } binding.aboutVersionText.text = AppConfig.appVersion - binding.termsTextView.handleUrlClicks { - startActivity(Intent(this, WelcomeTermsActivity::class.java)) - } - - binding.privacyTextView.handleUrlClicks { url -> - val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) - ContextCompat.startActivity(this, browserIntent, null) - } + binding.aboutContactText.handleUrlClicks(::onUrlClicked) + binding.aboutSupportText.handleUrlClicks(::onUrlClicked) + binding.termsTextView.handleUrlClicks(::onUrlClicked) + binding.privacyTextView.handleUrlClicks(::onUrlClicked) hideActionBarBack(isVisible = true) binding.toolbarLayout.toolbarTitle.setTextAppearance(R.style.CCX_Typography_PageTitle) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5201c5b5..65254ebc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -662,7 +662,7 @@ You can delegate to an open pool of your choice, or you can stake using passive delegation. If you don\'t already know which validator pool you want to delegate an amount to, you can look for one here:\n\nhttps://ccdscan.io/staking - Passive delegation is an alternative to delegation to a specific validator pool that has lower rewards. With passive delegation you do not have to worry about the uptime or quality of a validator node.\n\nFor more info you can visit\n\ndeveloper.concordium.software + Passive delegation is an alternative to delegation to a specific validator pool that has lower rewards. With passive delegation you do not have to worry about the uptime or quality of a validator node.\n\nFor more info you can visit\n\ndocs.concordium.com Enter validator pool ID Optional: New validator pool ID Current target: Validator id %1$s @@ -790,7 +790,7 @@ Add validator You can choose to add a URL with metadata about your validator. Leave it blank if you don’t have any. - You can read more about the metadata URL on developer.concordium.software + You can read more about the metadata URL on docs.concordium.com Continue Paste your metadata URL here Please enter a valid HTTP or HTTPS URL