-
-
Notifications
You must be signed in to change notification settings - Fork 846
Rework OnboardApp to adjust to new architecture #6115
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
TimoPtr
wants to merge
1
commit into
feature/use_new_onboarding
Choose a base branch
from
feature/onboarding-rework-onboardapp
base: feature/use_new_onboarding
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
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
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
106 changes: 0 additions & 106 deletions
106
app/src/main/kotlin/io/homeassistant/companion/android/onboarding/OnboardApp.kt
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
app/src/main/kotlin/io/homeassistant/companion/android/onboarding/WearOnboardApp.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,59 @@ | ||
| package io.homeassistant.companion.android.onboarding | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.os.Build | ||
| import androidx.activity.result.contract.ActivityResultContract | ||
| import io.homeassistant.companion.android.launcher.intentLauncherWearOnboarding | ||
|
|
||
| class WearOnboardApp : ActivityResultContract<WearOnboardApp.Input, WearOnboardApp.Output?>() { | ||
| data class Input(val url: String? = null, val defaultDeviceName: String = Build.MODEL) | ||
|
|
||
| data class Output( | ||
| val url: String, | ||
| val authCode: String, | ||
| val deviceName: String, | ||
| val tlsClientCertificateUri: String?, | ||
| val tlsClientCertificatePassword: String?, | ||
| ) { | ||
| fun toIntent(): Intent { | ||
| return Intent().apply { | ||
| putExtra(EXTRA_OUTPUT_URL, url) | ||
| putExtra(EXTRA_OUTPUT_AUTH_CODE, authCode) | ||
| putExtra(EXTRA_OUTPUT_DEVICE_NAME, deviceName) | ||
| putExtra(EXTRA_OUTPUT_TLS_CLIENT_CERTIFICATE_URI, tlsClientCertificateUri) | ||
| putExtra(EXTRA_OUTPUT_TLS_CLIENT_CERTIFICATE_PASSWORD, tlsClientCertificatePassword) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private const val EXTRA_OUTPUT_URL = "URL" | ||
| private const val EXTRA_OUTPUT_AUTH_CODE = "AuthCode" | ||
| private const val EXTRA_OUTPUT_DEVICE_NAME = "DeviceName" | ||
| private const val EXTRA_OUTPUT_TLS_CLIENT_CERTIFICATE_URI = "TLSClientCertificateUri" | ||
| private const val EXTRA_OUTPUT_TLS_CLIENT_CERTIFICATE_PASSWORD = "TLSClientCertificatePassword" | ||
|
|
||
| fun fromIntent(intent: Intent): Output { | ||
| return Output( | ||
| url = intent.getStringExtra(EXTRA_OUTPUT_URL).toString(), | ||
| authCode = intent.getStringExtra(EXTRA_OUTPUT_AUTH_CODE).toString(), | ||
| deviceName = intent.getStringExtra(EXTRA_OUTPUT_DEVICE_NAME).toString(), | ||
| tlsClientCertificateUri = intent.getStringExtra(EXTRA_OUTPUT_TLS_CLIENT_CERTIFICATE_URI), | ||
| tlsClientCertificatePassword = intent.getStringExtra(EXTRA_OUTPUT_TLS_CLIENT_CERTIFICATE_PASSWORD), | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun createIntent(context: Context, input: Input): Intent { | ||
| return context.intentLauncherWearOnboarding(input.defaultDeviceName, input.url) | ||
| } | ||
|
|
||
| override fun parseResult(resultCode: Int, intent: Intent?): Output? { | ||
| if (intent == null) { | ||
| return null | ||
| } | ||
|
|
||
| return Output.fromIntent(intent) | ||
| } | ||
| } |
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
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.
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 don't think this is for Wear, and it's also a behavior change I don't fully understand the reasoning behind. Can you elaborate / pull it out into another PR?
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.
It was called in the results of the onboarding after adding a server. If you look at the old code activity result in settings you would see that. I moved it here so it replicates the same behavior as before.
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.
For app usage it may replicate the same usage, but now it also tries to active the Wear server on the phone that started onboarding it, no?
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.
It's probably not clear enough and would deserve a comment in the nameyourweardevice package that actually it uses the screen but not the view model actually.
So no it doesn't activate the server on the wear onboarding.
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.
Yes please add a comment as that seems like something you may easily miss like I did