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

Move user info to modern architecture #3781

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tobiasKaminsky
Copy link
Member

@tobiasKaminsky tobiasKaminsky commented Mar 22, 2019

@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@nextcloud nextcloud deleted a comment May 8, 2019
@AndyScherzinger AndyScherzinger force-pushed the userInfoModern branch 2 times, most recently from 4b9482b to cf6aa1a Compare May 21, 2019 20:30
@AndyScherzinger
Copy link
Member

❗️ @tobiasKaminsky I rebased the branch to resolve the conflicts and saw that it still uses room 1.1.1 while room v2 is already out (which has quite some API changes) so I'd say the PR should go straight to room2.

Also pinging @ezaquarii since this is an architecture change

I am positive about this PR especially for adding room for the persistence implementation 👍

}

public UserInfoModule(Application application) {
userInfoDatabase = Room.databaseBuilder(application, UserInfoDatabase.class, "userInfo.db").build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be @Provides-ed and @Singleton-ed.


@Provides
public UserInfoViewModel userInfoViewModel(UserInfoRepository userInfoRepository) {
return new UserInfoViewModel(userInfoRepository);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Watch out with view models. VMs are managed with activity lifecycle and require special approach to injection.

For the time being, it would be easier to have them managed in vanilla way in activity.

I have some code somewhere where VM factory is hooked up to dagger.

private UserInfoDatabase userInfoDatabase;

@Provides
public Executor executor() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one could go to main app component - it's pretty generic stuff.

@ezaquarii
Copy link
Collaborator

Room is huge improvement over raw SQLite and Cursor API - no doubt about it.

My biggest concern is that we're exposing Google junk. I don't trust Google a bit and as @AndyScherzinger observerd, they changed things before we even managed to finish implementing this and I'm sure they will break it again. Our persistence is already "challenging", migrating this will take time, so doing it on google's quicksand API could be risky.

Sadly, Google is not designing their APIs for longevity, as most mobile apps are one night stands, so they can innovate rapidly not caring about backward compatibility too much.

I totally understand this mentality, but it doesn't fit our case very well. IMO we should have our own repository data layer hiding whatever DB library is trending on social media this month and not leak any details outside it.

LiveData seems to be stable, tho.

@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment from ezaquarii May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment from ezaquarii May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment May 24, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud nextcloud deleted a comment Aug 8, 2019
@nextcloud-android-bot
Copy link
Collaborator

@nextcloud-android-bot
Copy link
Collaborator

@tobiasKaminsky
Copy link
Member Author

tobiasKaminsky commented Aug 12, 2019

2019-08-12-124633

@AndyScherzinger I want to add the possibility to change the infos, e.g. phone, address, etc.
Do you have a good UI idea? Just adding a "pencil" icon to the right is not that good.

  • groups cannot be be changed
  • only one entry at the same time can be changed

split up code
use data binding
add groups

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud nextcloud deleted a comment from AndyScherzinger Aug 12, 2019
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud nextcloud deleted a comment Aug 12, 2019
@nextcloud-android-bot
Copy link
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/10361.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@nextcloud-android-bot
Copy link
Collaborator

@nextcloud-android-bot
Copy link
Collaborator

Codacy

276

Lint

TypemasterPR
Warnings5961
Errors00

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings24
Correctness Warnings70
Internationalization Warnings12
Malicious code vulnerability Warnings4
Multithreaded correctness Warnings9
Performance Warnings110
Security Warnings48
Dodgy code Warnings140
Total417

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings24
Correctness Warnings69
Internationalization Warnings12
Malicious code vulnerability Warnings4
Multithreaded correctness Warnings9
Performance Warnings111
Security Warnings46
Dodgy code Warnings135
Total410

Lint increased!

SpotBugs increased!

@AndyScherzinger
Copy link
Member

@AndyScherzinger I want to add the possibility to change the infos, e.g. phone, address, etc.

sure thing, since I already had this discusion for the deck app with @juliushaertl. Simply replace it with EditText fields. For server propagation you likely will then have to do a check if the data changed for each field individually and send a request for each, changed field.
Alternative: check on "focus lost" and call the server right away.

@tobiasKaminsky
Copy link
Member Author

https://developer.android.com/topic/libraries/data-binding/two-way

I tried this and it seems that, as methods are auto generated, you cannot use this with adapter, but have to use one xml.
So we would to remove the user_info_details_table_item.xml and include every item in user_info_layout.
Then we get also rid of the UserInfoAdapter.

We will loose flexibility, but as far as I can see it, it should be easy to maintain.

Shall I go with this?

@AndyScherzinger
Copy link
Member

@tobiasKaminsky does this work for propagating data to the server and only doing so on focus lost / back navigatioen etc (as-in not with every character change)?

@tobiasKaminsky
Copy link
Member Author

@tobiasKaminsky does this work for propagating data to the server and only doing so on focus lost / back navigatioen etc (as-in not with every character change)?

This is something I have to test, but I would have expected that text somehow needs to be "confirmed".

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.

None yet

4 participants