-
Notifications
You must be signed in to change notification settings - Fork 4
fix: gate screen deeplinks to debug #1157
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
Open
ovitrif
wants to merge
17
commits into
master
Choose a base branch
from
fix/1132-gate-screen-deeplinks-to-debug
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
58d394f
fix: confine screen deeplinks to debug
ovitrif fd3f925
test: cover debug and release deeplinks
ovitrif e5d4032
fix: keep debug deeplink ignore log
ovitrif 5bbc03d
chore: rename changelog fragment
ovitrif 398c53f
refactor: move screen deeplinks to debug
ovitrif 3ebac55
test: drop debug vs release source-set tests
ovitrif 2d6ac4c
chore: drop changelog fragment
ovitrif 91500f1
refactor: share screen deeplink helpers
ovitrif 3ecf621
test: fail ci if release enables screen links
ovitrif 753d61b
ci: keep release tests off unprotected ci
ovitrif 2c94cf9
revert: drop release unit test from just test
ovitrif 9ac2eb0
test: drop release source file gate
ovitrif ccfd060
test: simplify screen deeplink unit tests
ovitrif 6ed8684
test: drop debug screen deeplink register test
ovitrif e23264c
ci: retrigger checks after undraft
ovitrif 962da97
fix: update screen deeplink skip copy
ovitrif 477a10c
Merge remote-tracking branch 'origin/master' into fix/1132-gate-scree…
ovitrif 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
65 changes: 65 additions & 0 deletions
65
app/src/debug/java/to/bitkit/ui/utils/ScreenDeepLinkRuntime.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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package to.bitkit.ui.utils | ||
|
|
||
| import android.net.Uri | ||
| import androidx.navigation.NavDeepLink | ||
| import androidx.navigation.navDeepLink | ||
| import to.bitkit.ui.Routes | ||
| import to.bitkit.ui.components.Sheet | ||
| import to.bitkit.ui.screens.wallets.receive.ReceiveRoute | ||
| import to.bitkit.ui.sheets.BackupRoute | ||
| import to.bitkit.ui.sheets.SendRoute | ||
| import to.bitkit.ui.sheets.WidgetsRoute | ||
| import to.bitkit.ui.sheets.hardware.HardwareRoute | ||
| import kotlin.reflect.KClass | ||
|
|
||
| internal object ScreenDeepLinkRuntime { | ||
| val isEnabled = true | ||
|
|
||
| val sheetIds: Set<String> | ||
| get() { | ||
| val families = FAMILIES.mapNotNull { ScreenDeepLinks.kebabId(it.type) } | ||
| val standalone = STANDALONE.mapNotNull { ScreenDeepLinks.kebabId(it::class) } | ||
| return (families + standalone).toSet() | ||
| } | ||
|
|
||
| fun <T : Routes.DeepLinkable> linksFor(route: KClass<T>): List<NavDeepLink> { | ||
| val basePath = ScreenDeepLinks.basePath(route) ?: return emptyList() | ||
| return listOf(navDeepLink(route = route, basePath = basePath) {}) | ||
| } | ||
|
|
||
| fun sheetFor(uri: Uri): Sheet? { | ||
| if (!ScreenDeepLinks.isScreenDeepLink(uri)) return null | ||
|
|
||
| val segments = uri.pathSegments.orEmpty() | ||
| if (segments.isEmpty() || segments.size > 2) return null | ||
|
|
||
| val id = segments.first().lowercase() | ||
| val child = segments.getOrElse(1) { "" } | ||
|
|
||
| FAMILIES.firstOrNull { ScreenDeepLinks.kebabId(it.type) == id } | ||
| ?.let { return it.fromDeepLink(child) } | ||
|
|
||
| if (child.isNotEmpty()) return null | ||
|
|
||
| return STANDALONE.firstOrNull { ScreenDeepLinks.kebabId(it::class) == id } | ||
| } | ||
| } | ||
|
|
||
| private class SheetDeepLinkFamily( | ||
| val type: KClass<out Sheet>, | ||
| val fromDeepLink: (String) -> Sheet?, | ||
| ) | ||
|
|
||
| private val FAMILIES: List<SheetDeepLinkFamily> = listOf( | ||
| SheetDeepLinkFamily(Sheet.Send::class) { path -> SendRoute.fromDeepLink(path)?.let { Sheet.Send(it) } }, | ||
| SheetDeepLinkFamily(Sheet.Receive::class) { path -> ReceiveRoute.fromDeepLink(path)?.let { Sheet.Receive(it) } }, | ||
| SheetDeepLinkFamily(Sheet.Backup::class) { path -> BackupRoute.fromDeepLink(path)?.let { Sheet.Backup(it) } }, | ||
| SheetDeepLinkFamily(Sheet.Widgets::class) { path -> WidgetsRoute.fromDeepLink(path)?.let { Sheet.Widgets(it) } }, | ||
| SheetDeepLinkFamily(Sheet.Hardware::class) { path -> HardwareRoute.fromDeepLink(path)?.let { Sheet.Hardware(it) } }, | ||
| ) | ||
|
|
||
| private val STANDALONE: List<Sheet> = listOf( | ||
| Sheet.ActivityDateRangeSelector, | ||
| Sheet.ActivityTagSelector, | ||
| Sheet.QrScanner(), | ||
| ) |
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
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
18 changes: 18 additions & 0 deletions
18
app/src/release/java/to/bitkit/ui/utils/ScreenDeepLinkRuntime.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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package to.bitkit.ui.utils | ||
|
|
||
| import android.net.Uri | ||
| import androidx.navigation.NavDeepLink | ||
| import to.bitkit.ui.Routes | ||
| import to.bitkit.ui.components.Sheet | ||
| import kotlin.reflect.KClass | ||
|
|
||
| internal object ScreenDeepLinkRuntime { | ||
| val isEnabled = false | ||
| val sheetIds: Set<String> = emptySet() | ||
|
|
||
| @Suppress("UNUSED_PARAMETER") | ||
| fun <T : Routes.DeepLinkable> linksFor(route: KClass<T>): List<NavDeepLink> = emptyList() | ||
|
|
||
| @Suppress("UNUSED_PARAMETER") | ||
| fun sheetFor(uri: Uri): Sheet? = null | ||
| } |
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
File renamed without changes.
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.