Fix, the message is not correct when creating a folder with /
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / CreateFolderDialogFragment.java
index 170fe08..52e0425 100644 (file)
@@ -21,6 +21,7 @@
 package com.owncloud.android.ui.dialog;
 
 import com.actionbarsherlock.app.SherlockDialogFragment;
+import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.lib.resources.files.FileUtils;
@@ -52,8 +53,8 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener {
     /**
      * Public factory method to create new CreateFolderDialogFragment instances.
      * 
-     * @param file            File to remove.
-     * @return                Dialog ready to show.
+     * @param parentFolder            Folder to create
+     * @return                        Dialog ready to show.
      */
     public static CreateFolderDialogFragment newInstance(OCFile parentFolder) {
         CreateFolderDialogFragment frag = new CreateFolderDialogFragment();
@@ -106,12 +107,18 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener {
                         Toast.LENGTH_LONG).show();
                 return;
             }
-            
-            if (!FileUtils.isValidName(newFolderName)) {
-                Toast.makeText(
-                        getSherlockActivity(), 
-                        R.string.filename_forbidden_characters, 
-                        Toast.LENGTH_LONG).show();
+
+            boolean serverWithForbiddenChars = ((ComponentsGetter)getSherlockActivity()).
+                    getFileOperationsHelper().isVersionWithForbiddenCharacters();
+
+            if (!FileUtils.isValidName(newFolderName, 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;
             }