kaiserbh / tachiyomi

Free and open source manga reader for Android.
https://tachiyomi.org/
Apache License 2.0
4 stars 3 forks source link

Added automatic change of the Google Drive's "Sign In" button to something else when the user has signed in #7

Open undefiened opened 1 year ago

undefiened commented 1 year ago

In addition to that, also hide the "purge google drive" button until the user signs in.

Unfortunately, I am not as advanced with Kotlin and Jetpack Compose, so it took me quite a while and I couldn't figure out how to implement it without introducing a mutableStateOf in the GoogleDriveService. The problem is that the GoogleDriveService gets updated only after the user is redirected from the browser into the GoogleDriveLoginActivity which then further runs the remaining part of the authorization process in GoogleDriveService, so it is pretty hard to subscribe to it. So I did the easiest possible solution instead, which unfortunately introduces a useless variable in the GoogleDriveService.

If it doesn't look good (and I do realize that it probably doesn't), could you please kindly point me in the direction of some mechanism that would allow me to do it in a cleaner way? Or should I do something like an Observable pattern (or something similar)? It is just that what I did feels exactly like that, but takes only 2 lines of code, so I am a bit split as to what would be the best practice.

kaiserbh commented 1 year ago

Hi @undefiened sorry I have been busy, but anyway I think the correct way to do it, will be something akin to what SettingsTrackingScreen.kt does it. When the user have logged in successfully it will have a check mark next to it, so I suggest checking that out and see how it's being done.

I did check out SettingsTrackingScreen.kt in the past but not entirely sure how they done it, other than that I suggest going into tachiyomi discord server and head to the #programming channel and ask there.