|
@@ -35,6 +35,7 @@ import com.nextcloud.client.jobs.upload.FileUploadWorker;
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
import com.nextcloud.utils.extensions.ActivityExtensionsKt;
|
|
import com.nextcloud.utils.extensions.ActivityExtensionsKt;
|
|
import com.nextcloud.utils.extensions.FileExtensionsKt;
|
|
import com.nextcloud.utils.extensions.FileExtensionsKt;
|
|
|
|
+import com.nextcloud.utils.fileNameValidator.FileNameValidator;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.databinding.UploadFilesLayoutBinding;
|
|
import com.owncloud.android.databinding.UploadFilesLayoutBinding;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
@@ -642,8 +643,15 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList
|
|
|
|
|
|
finish();
|
|
finish();
|
|
} else {
|
|
} else {
|
|
- new CheckAvailableSpaceTask(this, mFileListFragment.getCheckedFilePaths())
|
|
|
|
- .execute(binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition() == 0);
|
|
|
|
|
|
+ String[] selectedFilePaths = mFileListFragment.getCheckedFilePaths();
|
|
|
|
+ String filenameErrorMessage = checkFileNameBeforeUpload(selectedFilePaths);
|
|
|
|
+ if (filenameErrorMessage != null) {
|
|
|
|
+ DisplayUtils.showSnackMessage(this, filenameErrorMessage);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean isPositionZero = (binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition() == 0);
|
|
|
|
+ new CheckAvailableSpaceTask(this, selectedFilePaths).execute(isPositionZero);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
requestPermissions();
|
|
requestPermissions();
|
|
@@ -651,6 +659,19 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String checkFileNameBeforeUpload(String[] selectedFilePaths) {
|
|
|
|
+ for (String filePath : selectedFilePaths) {
|
|
|
|
+ File file = new File(filePath);
|
|
|
|
+ String filenameErrorMessage = FileNameValidator.INSTANCE.isValid(file.getName(), getCapabilities(), this, null);
|
|
|
|
+
|
|
|
|
+ if (filenameErrorMessage != null) {
|
|
|
|
+ return filenameErrorMessage;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onConfirmation(String callerTag) {
|
|
public void onConfirmation(String callerTag) {
|
|
Log_OC.d(TAG, "Positive button in dialog was clicked; dialog tag is " + callerTag);
|
|
Log_OC.d(TAG, "Positive button in dialog was clicked; dialog tag is " + callerTag);
|