lichess-org / mobile

Lichess mobile app v2
GNU General Public License v3.0
1.1k stars 150 forks source link

Make it possible to install Play Store and debug builds on the same device #731

Closed timmcca-be closed 3 weeks ago

timmcca-be commented 4 weeks ago

Summary

The Android emulator performs poorly on my computer, so I have been using my personal phone to test changes. With this change, I will no longer have to uninstall the production app from the Play Store in order to develop.

Testing

Initial testing:

After additional request:

veloce commented 3 weeks ago

Thanks for this! I didn't know we could achieve this with only this simple change.

Can you also make sure the release build works and is correctly named?

timmcca-be commented 3 weeks ago

@veloce verified!

julien4215 commented 3 weeks ago

Not sure that this is a better solution but another way of doing it would be to add resValue "string", "app_name", "Lichess" in the defaultConfig block and resValue "string", "app_name", "Lichess Debug" in the debug block. The value can then be used in the main AndroidManifest with @string/app_name. This would move the logic from the debug AndroidManifest to the build.gradle.

julien4215 commented 3 weeks ago

We should change the appAuthRedirectScheme value used by flutter_appauth for debug mode. It should be org.lichess.mobileV2.debug.

By the way why theappAuthRedirectScheme value is org.lichess.mobile rather than org.lichess.mobileV2 ?

veloce commented 3 weeks ago

Is it really needed that the appAuthRedirectScheme is the same as the app id? I guess not since it works like that?

Why would we want it to be the same then?

julien4215 commented 3 weeks ago

After logging in Lichess users are redirected to both the Lichess and Lichess-DEBUG app and have to choose one between the two. If the appAuthRedirectScheme is the same as the app id, users will redirected to the right app but maybe this is not worth taking the risk of breaking things to save one click.

veloce commented 3 weeks ago

hmm. doesn't seem too risky though, does it?

Will accept a PR if you're willing to test that. I guess the only change should be done in the build.gradle so it looks simple.

Do not use org.lichess.mobileV2 because the flutter appauth doc says it should be all in lowercase.

So just keep it the same and append .debug in debug mode I'd say.

julien4215 commented 3 weeks ago

This doesn't work with org.lichess.mobile.debug because this is not the app id.

veloce commented 3 weeks ago

But then why does it work with org.lichess.mobile? It is also not the app id.

julien4215 commented 3 weeks ago

My fault, I was wrong, the redirect uri doesn't need match the app id, it just that it often does.

And it works with org.lichess.mobile.debug, it didn't work when I tried because I just didn't set the redirect_uri in the auth call.

There is still a small problem when I login. Since the redirect uri org.lichess.mobile.debug://login-callback is not trusted by the server, there is warning like on the screenshot.

To remove this warning, it would require to replace the redirect_uri here on dev environments so in the end I am not sure if this is worth the change.

veloce commented 3 weeks ago

Yes I think it's fine the way it is.