Browse Source

Fixed lock of buttons in details view when the 'Keep both' option in conflicts dialog is used

David A. Velasco 12 năm trước cách đây
mục cha
commit
38a80be828

+ 1 - 0
res/values/strings.xml

@@ -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_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>

+ 4 - 0
src/com/owncloud/android/files/services/FileUploader.java

@@ -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_OLD_REMOTE_PATH = "OLD_REMOTE_PATH";
     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
+        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());

+ 9 - 3
src/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -712,10 +712,16 @@ public class FileDetailFragment extends SherlockFragment implements
             if (!isEmpty() && accountName.equals(mAccount.name)) {
                 boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, false);
                 String uploadRemotePath = intent.getStringExtra(FileUploader.EXTRA_REMOTE_PATH);
-                if (mFile.getRemotePath().equals(uploadRemotePath)) {
+                boolean renamedInUpload = mFile.getRemotePath().equals(intent.getStringExtra(FileUploader.EXTRA_OLD_REMOTE_PATH));
+                if (mFile.getRemotePath().equals(uploadRemotePath) ||
+                    renamedInUpload) {
                     if (uploadWasFine) {
-                        FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());
-                        mFile = fdsm.getFileByPath(mFile.getRemotePath());
+                        mFile = mStorageManager.getFileByPath(mFile.getRemotePath());
+                    }
+                    if (renamedInUpload) {
+                        String newName = (new File(uploadRemotePath)).getName();
+                        Toast msg = Toast.makeText(getActivity().getApplicationContext(), String.format(getString(R.string.filedetails_renamed_in_upload_msg), newName), Toast.LENGTH_LONG);
+                        msg.show();
                     }
                     updateFileDetails();    // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server
                 }