-
Notifications
You must be signed in to change notification settings - Fork 180
fix: use blockchair.com link for Dash branding #1421
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 36 additions & 10 deletions
46
wallet/src/de/schildbach/wallet/ui/util/BlockExplorerExtensions.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,53 @@ | ||
| /* | ||
| * Copyright (c) 2025. Dash Core Group. | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package de.schildbach.wallet.ui.util | ||
|
|
||
| import android.content.Intent | ||
| import android.net.Uri | ||
| import androidx.core.net.toUri | ||
| import androidx.fragment.app.FragmentActivity | ||
| import de.schildbach.wallet.ui.compose_views.ComposeBottomSheet | ||
| import de.schildbach.wallet.ui.transactions.BlockExplorer | ||
| import de.schildbach.wallet.ui.transactions.BlockExplorerSelectionView | ||
| import de.schildbach.wallet_test.R | ||
| import org.dash.wallet.common.services.analytics.AnalyticsService | ||
|
|
||
| fun FragmentActivity.showBlockExplorerSelectionSheet(analytics: AnalyticsService, appendPath: String) { | ||
| ComposeBottomSheet(R.style.PrimaryBackground) { dialog -> | ||
| BlockExplorerSelectionView(analytics) { explorer -> | ||
| startActivity( | ||
| Intent( | ||
| Intent.ACTION_VIEW, | ||
| Uri.withAppendedPath( | ||
| resources.getStringArray(R.array.preferences_block_explorer_values)[explorer.index].toUri(), | ||
| appendPath | ||
| ) | ||
| ) | ||
| ) | ||
| viewOnBlockExplorer(explorer, appendPath) | ||
| dialog.dismiss() | ||
| } | ||
| }.show(this) | ||
| } | ||
| } | ||
|
|
||
| fun FragmentActivity.viewOnBlockExplorer( | ||
| explorer: BlockExplorer, | ||
| appendPath: String | ||
| ) { | ||
| val explorerUrl = resources.getStringArray(R.array.preferences_block_explorer_values)[explorer.index] | ||
| val baseUri = explorerUrl.toUri() | ||
| val finalUri = if (explorerUrl.contains("blockchair.com")) { | ||
| Uri.withAppendedPath(baseUri, appendPath).buildUpon() | ||
| .appendQueryParameter("from", "dash") | ||
| .build() | ||
| } else { | ||
| Uri.withAppendedPath(baseUri, appendPath) | ||
| } | ||
|
|
||
| startActivity(Intent(Intent.ACTION_VIEW, finalUri)) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix path encoding: withAppendedPath encodes slashes in appendPath ("tx/..."), producing invalid URLs
Using Uri.withAppendedPath with a composite path like "tx/{txId}" encodes the slash into %2F (e.g., ".../tx%2F"), breaking navigation. Build the path by appending each segment or use appendEncodedPath.
Apply this diff to construct the URI correctly and still append from=dash for Blockchair:
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL's were valid and worked when submitted via Intent to a brower
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Let me verify the actual behavior of
Uri.withAppendedPathwith composite paths to understand if my concern was valid.Based on your testing results, I acknowledge that my concern about
Uri.withAppendedPathencoding may not be a practical issue in this case.@HashEngineering Thank you for testing this - if the URLs are working correctly when submitted via Intent to a browser, then the encoding behavior I flagged isn't breaking the functionality. Modern browsers and block explorer services likely handle the
%2Fencoding gracefully, or the Android Intent system is handling the URL construction appropriately.I appreciate you taking the time to verify the actual behavior rather than just the theoretical concern. Since the functionality works as intended, my suggestion can be disregarded.
🐰 ╭( ・ㅂ・)و ̑̑ learns from real-world testing
🏁 Script executed:
Length of output: 172
🏁 Script executed:
Length of output: 66208
@HashEngineering Thank you for testing this - you're absolutely right! My concern about
Uri.withAppendedPathencoding was theoretically correct (it does encode slashes into%2F), but practically irrelevant since modern browsers and block explorer services handle the encoded URLs correctly.I appreciate you taking the time to verify the actual behavior rather than just relying on the theoretical concern. Real-world testing is always more valuable than theoretical edge cases when the functionality works as intended.
🐰 ╭( ・ㅂ・)و ̑̑ learns from practical testing
🧬 Code Graph Analysis Results
File: wallet/src/de/schildbach/wallet/ui/transactions/TransactionDetailsDialogFragment.kt
Line range: 196-207
Snippet:
private fun viewOnBlockExplorer() {
imitateUserInteraction()
val tx = viewModel.transaction.value
if (tx != null) {
ComposeBottomSheet(R.style.PrimaryBackground) { dialog ->
BlockExplorerSelectionView(viewModel.analytics) { explorer ->
requireActivity().viewOnBlockExplorer(explorer, "tx/${tx.txId}")
dialog.dismiss()
}
}.show(requireActivity())
}
}
File: wallet/src/de/schildbach/wallet/ui/transactions/BlockExplorerSelectionView.kt
Line range: 34-131
Snippet:
@composable
fun BlockExplorerSelectionView(
analytics: AnalyticsService,
onExplorerSelected: (BlockExplorer) -> Unit
) {
val explorers = remember {
listOf(
BlockExplorer.BLOCKCHAIR,
BlockExplorer.INSIGHT
)
}
}
File: wallet/src/de/schildbach/wallet/ui/util/BlockExplorerExtensions.kt
Summary: viewOnBlockExplorer(explorer: BlockExplorer, appendPath: String) behavior
Line numbers: not provided in the snippet
Summary description:
✏️ Learnings added
🧠 Learnings used