Fix, the message is not correct when creating a folder with /
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / RenameFileDialogFragment.java
index d285f1e..fa0c65d 100644 (file)
@@ -1,4 +1,7 @@
-/* ownCloud Android client application
+/**
+ *   ownCloud Android client application
+ *
+ *   @author David A. Velasco
  *   Copyright (C) 2014 ownCloud Inc.
  *
  *   This program is free software: you can redistribute it and/or modify
  *   Copyright (C) 2014 ownCloud Inc.
  *
  *   This program is free software: you can redistribute it and/or modify
@@ -43,9 +46,7 @@ import com.owncloud.android.ui.activity.ComponentsGetter;
 /**
  *  Dialog to input a new name for a file or folder to rename.  
  * 
 /**
  *  Dialog to input a new name for a file or folder to rename.  
  * 
- *  Triggers the rename operation when name is confirmed. 
- *  
- *  @author David A. Velasco
+ *  Triggers the rename operation when name is confirmed.
  */
 public class RenameFileDialogFragment
 extends SherlockDialogFragment implements DialogInterface.OnClickListener {
  */
 public class RenameFileDialogFragment
 extends SherlockDialogFragment implements DialogInterface.OnClickListener {
@@ -117,16 +118,23 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener {
                         Toast.LENGTH_LONG).show();
                 return;
             }
                         Toast.LENGTH_LONG).show();
                 return;
             }
-            
-            if (!FileUtils.isValidName(newFileName)) {
-                Toast.makeText(
-                        getSherlockActivity(), 
-                        R.string.filename_forbidden_characters, 
-                        Toast.LENGTH_LONG).show();
+
+            boolean serverWithForbiddenChars = ((ComponentsGetter)getSherlockActivity()).
+                    getFileOperationsHelper().isVersionWithForbiddenCharacters();
+
+            if (!FileUtils.isValidName(newFileName, serverWithForbiddenChars)) {
+                int messageId = 0;
+                if (serverWithForbiddenChars) {
+                    messageId = R.string.filename_forbidden_charaters_from_server;
+                } else {
+                    messageId = R.string.filename_forbidden_characters;
+                }
+                Toast.makeText(getSherlockActivity(), messageId, Toast.LENGTH_LONG).show();
                 return;
             }
 
                 return;
             }
 
-            ((ComponentsGetter)getSherlockActivity()).getFileOperationsHelper().renameFile(mTargetFile, newFileName);
+            ((ComponentsGetter)getSherlockActivity()).getFileOperationsHelper().
+                    renameFile(mTargetFile, newFileName);
         }
     }
 }
         }
     }
 }