Conversation
2c5b6dd to
318e80a
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11636 |
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11637 |
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11640 |
bf201fe to
1c44424
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11641 |
1c44424 to
0098d14
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11642 |
|
@tobiasKaminsky @AndyScherzinger Can you tell me if the account name in form of |
|
0098d14 to
84d42ff
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11643 |
84d42ff to
e3151d8
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11644 |
e3151d8 to
e3b5eed
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11645 |
e3b5eed to
f847f76
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11646 |
f847f76 to
8f26d24
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11656 |
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11659 |
|
GPlay tests are still failing to run: |
8f26d24 to
d03f723
Compare
I addressed both concerns:
|
|
Nice @ezaquarii thank you for the fast fixes 👍 I will resolve kotlin lint checks and then merge it. |
61c2e72 to
85ffb1c
Compare
|
@tobiasKaminsky I squashed and rebased on top of master. |
|
CI was cancelled, I restarted it and will merge afterwards. |
New non-nullable user model abstracts away all complexities of Nextcloud user account and provides. - backported java.util.Optional - extended UserAccountManager with User getters - deprecated CurrentAccountProvider.getCurrentAccount() method - migrated connectivity service to new user model - migrated UploadsStorageManager to new user model - migrated OCFileListAdapter Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
85ffb1c to
609b996
Compare
|
|
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/11698.apk |
|
Issues
======
+ Solved 1
- Added 5
Complexity increasing per file
==============================
- src/main/java/com/nextcloud/java/util/Optional.java 6
Complexity decreasing per file
==============================
+ src/main/java/com/nextcloud/client/network/ConnectivityServiceImpl.java -1
See the complete overview on Codacy |
|
|
||
| // get ocFile from Server to have an up-to-date copy | ||
| RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(account, | ||
| RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(user.toPlatformAccount(), |
There was a problem hiding this comment.
Issue found: Avoid instantiating new objects inside loops
| */ | ||
| default Predicate<T> or(Predicate<? super T> other) { | ||
| if (other == null) { | ||
| throw new NullPointerException(); |
There was a problem hiding this comment.
Issue found: Avoid throwing null pointer exceptions.
| /** | ||
| * Common instance for {@code empty()}. | ||
| */ | ||
| private static final Optional<?> EMPTY = new Optional<>(); |
There was a problem hiding this comment.
Issue found: Field EMPTY has the same name as a method
| } else { | ||
| Optional<U> u = mapper.invoke(value); | ||
| if (u == null) { | ||
| throw new NullPointerException(); |
There was a problem hiding this comment.
Issue found: Avoid throwing null pointer exceptions.
| * should exist per VM. | ||
| */ | ||
| private Optional() { | ||
| this.value = null; |
There was a problem hiding this comment.
Codacy567Lint
SpotBugs (new)
SpotBugs (master)
|
Codecov Report
@@ Coverage Diff @@
## master #4835 +/- ##
============================================
- Coverage 17.68% 17.63% -0.05%
Complexity 3 3
============================================
Files 377 383 +6
Lines 32403 32509 +106
Branches 4580 4587 +7
============================================
+ Hits 5729 5734 +5
- Misses 25753 25859 +106
+ Partials 921 916 -5
|
|
@tobiasKaminsky Finally CI is green. Ready. Phew... |
…ovider Remove getCurrentAccount() method from CurrentAccountProvider interface. The method was deprecated in favor of getUser() and had only one external caller (DrawerActivity), which has been migrated to use getUser() instead. The implementation in UserAccountManagerImpl remains as it's still used internally by getUser(), but removing it from the interface prevents new code from depending on the deprecated Account-based API. Refs: #4853, #4835 Signed-off-by: Josh <josh.t.richards@gmail.com>
…ovider Remove getCurrentAccount() method from CurrentAccountProvider interface. The method was deprecated in favor of getUser() and had only one external caller (DrawerActivity), which has been migrated to use getUser() instead. The implementation in UserAccountManagerImpl remains as it's still used internally by getUser(), but removing it from the interface prevents new code from depending on the deprecated Account-based API. Refs: #4853, #4835 Signed-off-by: Josh <josh.t.richards@gmail.com>

Here is the initial proposal of a new user model. There is very little there so far in terms of features, as I migrated few small portions of code to see what happens. There is a POJO and some trivial API changes.
The
Userobject offers 2 methods to obtain legacy account formats:Account User.toPlatformAccount()OwnCloudAccount User.toOwnCloudAccount()Migration plan:
CurrentAccountProvider.getCurrentAccount()and replace a call withgetUser()or try eliminating any existingUser.to*Account()Userinstance in place ofAccount/OwnCloudAccountUserand plug any potential rabbit holes withUser.toPlatformAccount()orUser.toOwnCloudAccount()while(!done) goto 1This means that temporarily we will be deadling with 5 account formats, but the remaining formats should be phased out interatively.
The use of
Userinterface is not about anectodal Java baclava abstractions. One of my goals is to eliminate "no user"ifcase by providing a default, semantically correct user value, eliminatingif-ology aroundnullvalues, for example from DB queries.I think that down the road we'll probably leave only one POJO type, but for the time being I decided to have 2 independent implementations behind an interface. This makes unit testing a bit more complex with mocking (instead of using a value), but I'm not yet sure if we'll be able to collapse both cases into 1 type and it's just easier to run development with 2 independent implementations. If we change decision later - client code won't be affected, so this is a safest route.
One of the things that come to my mind when looking at the code was that the accidental
CurrentAccountProviderinterface[1] can be turned into something likeSessionand possiblyenable multiple parallel operations that currently depend on selected user, such as background sync.
2 simple cases were migrated as a proof of concept:
ConnectivityService- somehow I started here as it had pretty complete test suiteUploadsStorageManager- you can see how the default "empty user" simplifiedifguards around DB queriesAlso, I had to backport Java 8
Optional<T>as it is not available on all Android API levels. Since this backport is semantically identical with the original, once Java 8 features become available (either by bumping min API level or using a support library), the change will be as easy as changing the package. Please bear in mind that the code is copyrighted by Oracle (still GNU GPL 2, so should be ok).I think I'll stop it here and allow us to review and merge this before starting migrating other areas of code, as this migrations - although rather trivial - needs incremental manual testing and I'm not very keen on dumping big diffs for review.
[1] - we created it as a temporary measure to break dependency loops in the early days, where everything depended on
AccountManagerfor exactly 1 method.