Skip to content
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

Alpha application #4

Merged
merged 16 commits into from
Nov 2, 2019
Merged

Alpha application #4

merged 16 commits into from
Nov 2, 2019

Conversation

CedrickFlocon
Copy link
Member

No description provided.

@CedrickFlocon CedrickFlocon marked this pull request as ready for review November 1, 2019 16:50
if (Session.getInstance().url.isNullOrBlank()) {
startActivity(OnboardingActivity.newInstance(this))
} else {
startActivity(WebViewActivity.newInstance(this))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future, maybe a good idea to fire off token valid check here? That way we don't have to wait until the frontend requests a token but can make sure it's valid.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agreed. Could we enable Github Project to list all the task ?
like listen connection-status and display authentication screen again in case of "auth-invalid" | "disconnected"

webView.post {
webView.evaluateJavascript(
"${JSONObject(callback).get("callback")}(true, {\n" +
" \"access_token\": \"${token.accessToken}\",\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it is hardcoding the tokens from the first launch. However, if the token is expired in the frontend, this code should refresh the token before giving it to the app.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed token is refreshed if necessary when we open the webview. This will work ok if the user is not planning to use the app longer than that the token is currently valid. Better if we refresh it in this function, if necessary.

Ideally, it would work like this:

  • the moment the app starts up and it has tokens, start a refresh request if they are no longer valid
  • in the JavaScript interface, if a refresh request is in progress (because app got opened), wait for that request to finish, otherwise start own request for refresh.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it quicker I refresh the token (if needed) each time getExternalAuth is call. Is that ok for you ?

Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great ! It's up to you how you want to go from here. Want to merge this as-is or first address the few comments?

@w1ll1am23
Copy link

Noticed you are using findViewById in a few places. I know there isn't going to be a lot of native UI in the app to start with, but might want to look at using Kotlin Synthetic properties.

basically would let you replace, for example

findViewById<TextView>(R.id.version_text_view).text

with

version_text_view.text

no need to implicitly provide the view type.

Just a thought.

@CedrickFlocon
Copy link
Member Author

@w1ll1am23 As you say we won't have a lot of native UI component.
So do we need to include a dependencies (even if it won't impact the size of APK much) for 5 findViewById ?

@CedrickFlocon
Copy link
Member Author

@balloob I will fix these comment

Check token each time the frontend hit getExternalAuth
Use Android client id
@w1ll1am23
Copy link

@CedrickFlocon it was just a thought, no reason to actually implement it if there are no plans to add additional native UI. I could see the settings menu getting pretty full, but once that happens we can revisit. Thanks for all the hard work here! Looks great.

@balloob balloob merged commit e54311e into home-assistant:master Nov 2, 2019
@CedrickFlocon CedrickFlocon deleted the alpha branch November 2, 2019 14:12
@andriej
Copy link

andriej commented Nov 2, 2019

@CedrickFlocon - I'm no android dev, but when there will be possibility to join alpha/beta test, please provide way for people interested in. :-)

@CedrickFlocon
Copy link
Member Author

@andriej Sure, I am working on a CI / CD stuff.
I will probably deploy master commit thought Firebase App Distribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants