Fixed lock of buttons in details view when the 'Keep both' option in conflicts dialog...
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 20 Nov 2012 13:41:04 +0000 (14:41 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 20 Nov 2012 13:41:04 +0000 (14:41 +0100)
res/values/strings.xml
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/ui/fragment/FileDetailFragment.java

index f737c65..0428f41 100644 (file)
@@ -77,6 +77,7 @@
     <string name="filedetails_sync_file">Refresh</string>
        <string name="filedetails_redownload">Redownload</string>
     <string name="filedetails_open">Open</string>
     <string name="filedetails_sync_file">Refresh</string>
        <string name="filedetails_redownload">Redownload</string>
     <string name="filedetails_open">Open</string>
+    <string name="filedetails_renamed_in_upload_msg">File was renamed to %1$s during upload</string>
     <string name="common_yes">Yes</string>
     <string name="common_no">No</string>
     <string name="common_ok">OK</string>
     <string name="common_yes">Yes</string>
     <string name="common_no">No</string>
     <string name="common_ok">OK</string>
index 393013a..87dc177 100644 (file)
@@ -74,6 +74,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
     public static final String EXTRA_PARENT_DIR_ID = "PARENT_DIR_ID";
     public static final String EXTRA_UPLOAD_RESULT = "RESULT";
     public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
     public static final String EXTRA_PARENT_DIR_ID = "PARENT_DIR_ID";
     public static final String EXTRA_UPLOAD_RESULT = "RESULT";
     public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
+    public static final String EXTRA_OLD_REMOTE_PATH = "OLD_REMOTE_PATH";
     public static final String EXTRA_FILE_PATH = "FILE_PATH";
     public static final String ACCOUNT_NAME = "ACCOUNT_NAME";    
     
     public static final String EXTRA_FILE_PATH = "FILE_PATH";
     public static final String ACCOUNT_NAME = "ACCOUNT_NAME";    
     
@@ -674,6 +675,9 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
     private void sendFinalBroadcast(UploadFileOperation upload, RemoteOperationResult uploadResult) {
         Intent end = new Intent(UPLOAD_FINISH_MESSAGE);
         end.putExtra(EXTRA_REMOTE_PATH, upload.getRemotePath());    // real remote path, after possible automatic renaming
     private void sendFinalBroadcast(UploadFileOperation upload, RemoteOperationResult uploadResult) {
         Intent end = new Intent(UPLOAD_FINISH_MESSAGE);
         end.putExtra(EXTRA_REMOTE_PATH, upload.getRemotePath());    // real remote path, after possible automatic renaming
+        if (upload.wasRenamed()) {
+            end.putExtra(EXTRA_OLD_REMOTE_PATH, upload.getOldFile().getRemotePath());
+        }
         end.putExtra(EXTRA_FILE_PATH, upload.getStoragePath());
         end.putExtra(ACCOUNT_NAME, upload.getAccount().name);
         end.putExtra(EXTRA_UPLOAD_RESULT, uploadResult.isSuccess());
         end.putExtra(EXTRA_FILE_PATH, upload.getStoragePath());
         end.putExtra(ACCOUNT_NAME, upload.getAccount().name);
         end.putExtra(EXTRA_UPLOAD_RESULT, uploadResult.isSuccess());
index 49384e8..17bde9b 100644 (file)
@@ -712,10 +712,16 @@ public class FileDetailFragment extends SherlockFragment implements
             if (!isEmpty() && accountName.equals(mAccount.name)) {\r
                 boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, false);\r
                 String uploadRemotePath = intent.getStringExtra(FileUploader.EXTRA_REMOTE_PATH);\r
             if (!isEmpty() && accountName.equals(mAccount.name)) {\r
                 boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, false);\r
                 String uploadRemotePath = intent.getStringExtra(FileUploader.EXTRA_REMOTE_PATH);\r
-                if (mFile.getRemotePath().equals(uploadRemotePath)) {\r
+                boolean renamedInUpload = mFile.getRemotePath().equals(intent.getStringExtra(FileUploader.EXTRA_OLD_REMOTE_PATH));\r
+                if (mFile.getRemotePath().equals(uploadRemotePath) ||\r
+                    renamedInUpload) {\r
                     if (uploadWasFine) {\r
                     if (uploadWasFine) {\r
-                        FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());\r
-                        mFile = fdsm.getFileByPath(mFile.getRemotePath());\r
+                        mFile = mStorageManager.getFileByPath(mFile.getRemotePath());\r
+                    }\r
+                    if (renamedInUpload) {\r
+                        String newName = (new File(uploadRemotePath)).getName();\r
+                        Toast msg = Toast.makeText(getActivity().getApplicationContext(), String.format(getString(R.string.filedetails_renamed_in_upload_msg), newName), Toast.LENGTH_LONG);\r
+                        msg.show();\r
                     }\r
                     updateFileDetails();    // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server\r
                 }\r
                     }\r
                     updateFileDetails();    // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server\r
                 }\r