-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(run-v2): link installation #90
Conversation
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 only blocking change is that the deeplinks don't work if the app is not running.
composeApp/src/androidMain/kotlin/org/ooni/probe/MainActivity.kt
Outdated
Show resolved
Hide resolved
android:scheme="https" /> | ||
</intent-filter> | ||
|
||
<intent-filter android:autoVerify="true"> |
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.
I'm getting a Missing required elements/attributes for Android App Links
warning here.
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.
android wants the scheme below to be http/https
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.
Then maybe we don't need the autoVerify
here? Or we can still verify the ooni
scheme?
composeApp/src/commonMain/kotlin/org/ooni/probe/domain/BootstrapTestDescriptors.kt
Outdated
Show resolved
Hide resolved
composeApp/src/commonMain/kotlin/org/ooni/probe/domain/RunNetTest.kt
Outdated
Show resolved
Hide resolved
composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/AddDescriptorScreen.kt
Outdated
Show resolved
Hide resolved
) | ||
} | ||
}.onFailure { | ||
onError() |
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.
You can also tell the Screen to display the error, and use the onBack here instead. Snackbars are tied to the Activity, so they survive if you switch screens.
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.
onError
shows an error message before going back
onEvent(AddDescriptorViewModel.Event.AutoRunChanged(!state.allTestsSelected())) | ||
}, | ||
) { | ||
Checkbox( |
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.
I found out there's a TriStateCheckbox that I used on my run tests PR.
onBack() | ||
}, | ||
fetchDescriptor = { | ||
withContext(backgroundDispatcher) { |
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.
You should hide this detail inside the fetchDescriptor
, but the engine.httpDo
call is already running on the backgroundDispatcher.
saveTestDescriptors = { | ||
saveTestDescriptors.invoke(it) | ||
// TODO(aanorbel): show toast/snackbar | ||
onBack() |
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.
I would prefer if we don't have logic in the Dependencies
class where it's hard to find. Why not call onBack
inside of the viewModel?
Co-authored-by: Sérgio Santos <me@sergiosantos.info>
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.
A bug I found, you can only the same deeplink once. And I believe you should be able to re-open the same link.
android:scheme="https" /> | ||
</intent-filter> | ||
|
||
<intent-filter android:autoVerify="true"> |
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.
Then maybe we don't need the autoVerify
here? Or we can still verify the ooni
scheme?
onCancel = { | ||
snackbarHostState?.let { | ||
showSnackbar( | ||
scope = scope, | ||
snackbarHostState = it, | ||
message = cancelMessage, | ||
) | ||
} | ||
onBack() | ||
}, | ||
onError = { | ||
snackbarHostState?.let { | ||
showSnackbar( | ||
scope = scope, | ||
snackbarHostState = it, | ||
message = errorMessage, | ||
) | ||
} | ||
onBack() | ||
}, | ||
saveTestDescriptors = { | ||
saveTestDescriptors.invoke(it) | ||
snackbarHostState?.let { | ||
showSnackbar( | ||
scope = scope, | ||
snackbarHostState = it, | ||
message = installCompleteMessage, | ||
) | ||
} | ||
onBack() | ||
}, | ||
fetchDescriptor = { | ||
fetchDescriptor(descriptorId) | ||
}, |
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.
I feel it's not a good practice to have any sort of logic in the Dependencies
class. We're not expecting to find it there, it's not testable, and it will make this file to be bloated very quickly.
Ideally this logic should be inside the ViewModel. Even the fetchDescriptor
argument should just be something like fetchDescriptor = fetchDescriptor::invoke
.
snackbarHostState?.let { | ||
showSnackbar( | ||
scope = scope, | ||
snackbarHostState = it, | ||
message = cancelMessage, | ||
) | ||
} |
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.
Do we need to show a snackbar saying the installation was cancelled? It felt a bit obvious to the user.
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.
I dont think we need it but i am trying to do backwards compatibility at once
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.
) | ||
} | ||
}.onFailure { | ||
onError() |
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.
This failure is not being logged, it might be useful.
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.
Yeah. I am working on the update as we speak.
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.
.onOpenURL { url in | ||
handleDeepLink(url: url) | ||
} |
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.
Wrong indentation
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.
) = ComposeUIViewController { | ||
App( | ||
dependencies = dependencies, | ||
deepLink = deepLinkFlow.collectAsState(null).value, |
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.
This will only get a a deepLink once. Or does opening a deep link in iOS restart the whole app?
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.
Having some difficulties with this.
val snackbarHostState = LocalSnackbarHostState.current | ||
val cancelMessage = stringResource(Res.string.LoadingScreen_Runv2_Canceled) | ||
val errorMessage = stringResource(Res.string.LoadingScreen_Runv2_Failure) | ||
val installCompleteMessage = stringResource(Res.string.AddDescriptor_Toasts_Installed) |
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.
If the ViewModel ends up with the code to trigger a snackbar, the actual code that fetches the strings and the SnackbarHostState should be in the View.
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.
Fixes: #52