Browse Source

Display name is sync'ed whenever a refresh of root folder occurs

David A. Velasco 8 years ago
parent
commit
0913e3f234

+ 13 - 4
src/com/owncloud/android/operations/RefreshFolderOperation.java

@@ -187,7 +187,7 @@ public class RefreshFolderOperation extends RemoteOperation {
         
         if (OCFile.ROOT_PATH.equals(mLocalFolder.getRemotePath()) && !mSyncFullAccount) {
             updateOCVersion(client);
-
+            updateUserProfile();
         }
         
         result = checkForChanges(client);
@@ -226,7 +226,6 @@ public class RefreshFolderOperation extends RemoteOperation {
         
     }
 
-
     private void updateOCVersion(OwnCloudClient client) {
         UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext);
         RemoteOperationResult result = update.execute(client);
@@ -235,14 +234,24 @@ public class RefreshFolderOperation extends RemoteOperation {
 
             // Update Capabilities for this account
             if (update.getOCVersion().isVersionWithCapabilitiesAPI()) {
-                updateCapabilities(client);
+                updateCapabilities();
             } else {
                 Log_OC.d(TAG, "Capabilities API disabled");
             }
         }
     }
 
-    private void updateCapabilities(OwnCloudClient client){
+    private void updateUserProfile() {
+        GetUserProfileOperation update = new GetUserProfileOperation();
+        RemoteOperationResult result = update.execute(mStorageManager, mContext);
+        if (!result.isSuccess()) {
+            Log_OC.w(TAG, "Couldn't update user profile from server");
+        } else {
+            Log_OC.i(TAG, "Got display name: " + result.getData().get(0));
+        }
+    }
+
+    private void updateCapabilities(){
         GetCapabilitiesOperarion getCapabilities = new GetCapabilitiesOperarion();
         RemoteOperationResult  result = getCapabilities.execute(mStorageManager,mContext);
         if (!result.isSuccess()){

+ 15 - 9
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -977,22 +977,28 @@ public class FileDisplayActivity extends HookActivity
                                         .equals(event));
 
                         if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
-                            equals(event) &&/// TODO refactor and make common
+                            equals(event)) {
 
-                            synchResult != null && !synchResult.isSuccess()) {
+                            if (synchResult != null && !synchResult.isSuccess()) {
+                                /// TODO refactor and make common
 
-                            if(ResultCode.UNAUTHORIZED.equals(synchResult.getCode()) ||
-                                (synchResult.isException() && synchResult.getException()
-                                    instanceof AuthenticatorException)) {
+                                if (ResultCode.UNAUTHORIZED.equals(synchResult.getCode()) ||
+                                    (synchResult.isException() && synchResult.getException()
+                                        instanceof AuthenticatorException)) {
 
-                                requestCredentialsUpdate(context);
+                                    requestCredentialsUpdate(context);
 
-                            } else if(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
-                                synchResult.getCode())) {
+                                } else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(
+                                    synchResult.getCode())) {
+
+                                    showUntrustedCertDialog(synchResult);
+                                }
 
-                                showUntrustedCertDialog(synchResult);
                             }
 
+                            if (synchFolderRemotePath.equals(OCFile.ROOT_PATH)) {
+                                setUsernameInDrawer(mDrawerLayout, getAccount());
+                            }
                         }
 
                     }