Migrate simple cases of get current account to get user#4853
Conversation
097addd to
e6fc540
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11661 |
0779a6b to
84b0849
Compare
|
I guess this needs to be rebased on master, as newUser PR is now in. |
84b0849 to
faa9d77
Compare
Codecov Report
@@ Coverage Diff @@
## master #4853 +/- ##
============================================
+ Coverage 17.62% 17.69% +0.06%
Complexity 3 3
============================================
Files 383 384 +1
Lines 32509 32528 +19
Branches 4587 4588 +1
============================================
+ Hits 5731 5757 +26
+ Misses 25857 25848 -9
- Partials 921 923 +2
|
522e79f to
33afcbc
Compare
c3e5f70 to
dc4f44a
Compare
|
Unit test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11719 |
c2473b4 to
436b564
Compare
|
Unit test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11725 |
| @Deprecated | ||
| boolean isSearchSupported(@Nullable Account account); | ||
|
|
||
| @Deprecated |
There was a problem hiding this comment.
can you add here, what to use instead?
There was a problem hiding this comment.
JavaDoc updated.
| public OwnCloudClient create(User user) throws CreationException { | ||
| try { | ||
| return OwnCloudClientFactory.createOwnCloudClient(user.toPlatformAccount(), context); | ||
| } catch (OperationCanceledException|AuthenticatorException|IOException|AccountUtils.AccountNotFoundException e) { |
There was a problem hiding this comment.
as this is too long, please also line wrap it
There was a problem hiding this comment.
Long exceptions list reformatted into vertical.
|
|
||
| FileDataStorageManager manager = new FileDataStorageManager(account, getContext().getContentResolver()); | ||
| boolean federatedShareAllowed = manager.getCapability(account.name).getFilesSharingFederationOutgoing() | ||
| FileDataStorageManager manager = new FileDataStorageManager(user.toPlatformAccount(), getContext().getContentResolver()); |
| Account account = accountManager.getCurrentAccount(); | ||
| GetActivityListTask getActivityListTask = new GetActivityListTask(account, accountManager, lastGiven, callback); | ||
| User user = accountManager.getUser(); | ||
| GetActivityListTask getActivityListTask = new GetActivityListTask(user.toPlatformAccount(), accountManager, lastGiven, callback); |
src/main/java/com/owncloud/android/ui/adapter/TrashbinListAdapter.java
Outdated
Show resolved
Hide resolved
src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java
Outdated
Show resolved
Hide resolved
src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java
Show resolved
Hide resolved
src/main/java/com/owncloud/android/ui/trashbin/RemoteTrashbinRepository.java
Outdated
Show resolved
Hide resolved
|
Nice! Again this is a great PR! Some very small issues and then we can merge. |
Migrate trivially convertible uses of getCurrentAccount() to new user model - getUser(). Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
1c2ae46 to
a7eb714
Compare
ezaquarii
left a comment
There was a problem hiding this comment.
All issues addressed.
|
@tobiasKaminsky Please bear in mind that #4884 is causing CI to fail sporadicaly. Just restart the build if this particular test fails. |
… [skip ci] Signed-off-by: nextcloud-android-bot <android@nextcloud.com>
|
Issues
======
+ Solved 3
- Added 3
Complexity increasing per file
==============================
- src/main/java/com/nextcloud/client/network/ClientFactoryImpl.java 2
- src/main/java/com/owncloud/android/ui/trashbin/RemoteTrashbinRepository.java 1
- src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java 2
Complexity decreasing per file
==============================
+ src/main/java/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java -2
+ src/main/java/com/owncloud/android/ui/activities/data/files/FilesServiceApiImpl.java -3
See the complete overview on Codacy |
| String accountName = getIntent().getExtras().getString(NotificationJob.KEY_NOTIFICATION_ACCOUNT); | ||
| if(accountName != null && optionalUser.isPresent()) { | ||
| User user = optionalUser.get(); | ||
| if (user.getAccountName().equalsIgnoreCase(accountName)) { |
There was a problem hiding this comment.
Issue found: Deeply nested if..then statements are hard to read
| if (optionalUser.isPresent()) { | ||
| mLastDisplayedAccount = optionalUser.get().toPlatformAccount(); | ||
| } else { | ||
| mLastDisplayedAccount = null; |
There was a problem hiding this comment.
| Optional<User> optionalUser = getUser(); | ||
| if (optionalUser.isPresent() && accountName != null) { | ||
| User user = optionalUser.get(); | ||
| if (!accountName.equalsIgnoreCase(user.getAccountName())) { |
There was a problem hiding this comment.
Issue found: Deeply nested if..then statements are hard to read
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/11734 |
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/11743.apk |
|
@tobiasKaminsky |
Codacy312Lint
SpotBugs (new)
SpotBugs (master)
|
|
Ha finally greeeen :-) |
e92daa2 Merge pull request #4853 from nextcloud/migrate-simple-cases-of-get-current-account-to-get-user 99d9a69 Merge pull request #4885 from nextcloud/disable_android_backup_qa 10960bf [tx-robot] updated from transifex 9f24b25 [tx-robot] updated from transifex b7876c4 disable GoogleAppIndexingWarning lint check 11687c6 Drone: update FindBugs results to reflect reduced error/warning count [skip ci] 80fb800 Merge commit 'a7eb7148fa0ceb42981366eb2ddcf0ff921e6a55' b91136c Disable android backup on the QA app a7eb714 Migrate simple cases of getCurrentAccount() to getUser() 6249a06 daily dev 20191123
…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>

This branch is an attempt to migrate all trivial use cases of
UserAccountManager.getCurrentAccount()toUserAccountManager.getUser(), leveragingUser.toPlatformAccount()andUser.toOwnCloudAccount()APIs whenever refactoring becomes problematic or too risky.Since
UserAccountManageris injected in top-level component, such asActivities(top), this PR shall open path to migration of internal components, deeper in the object hierarchy (bottom).My initial plan to start from internal componentsand taking migration up to
Activity/Fragment/Servicelevel - botton-top approach - turned out to not be feasible, because various internal componetns require refactoring of the callers anyway (top) atd those refactorings spill horribly all over the codebase.I try to keep the risk of this change in reasonable bounds, but it will require complehensive application testing nevertheless.