-/* ownCloud Android client application
- * Copyright (C) 2014 ownCloud Inc.
+/**
+ * ownCloud Android client application
+ *
+ * @author David A. Velasco
+ * Copyright (C) 2015 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
package com.owncloud.android.ui.dialog;
-import com.actionbarsherlock.app.SherlockDialogFragment;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.resources.files.FileUtils;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.LayoutParams;
/**
* Dialog to input the name for a new folder to create.
*
- * Triggers the folder creation when name is confirmed.
- *
- * @author David A. Velasco
+ * Triggers the folder creation when name is confirmed.
*/
-public class CreateFolderDialogFragment
-extends SherlockDialogFragment implements DialogInterface.OnClickListener {
+public class CreateFolderDialogFragment
+ extends DialogFragment implements DialogInterface.OnClickListener {
private static final String ARG_PARENT_FOLDER = "PARENT_FOLDER";
/**
* 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();
mParentFolder = getArguments().getParcelable(ARG_PARENT_FOLDER);
// Inflate the layout for the dialog
- LayoutInflater inflater = getSherlockActivity().getLayoutInflater();
+ LayoutInflater inflater = getActivity().getLayoutInflater();
View v = inflater.inflate(R.layout.edit_box_dialog, null);
// Setup layout
inputText.requestFocus();
// Build the dialog
- AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity());
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(v)
.setPositiveButton(R.string.common_ok, this)
.setNegativeButton(R.string.common_cancel, this)
if (newFolderName.length() <= 0) {
Toast.makeText(
- getSherlockActivity(),
+ getActivity(),
R.string.filename_empty,
Toast.LENGTH_LONG).show();
return;
}
-
- if (!FileUtils.isValidName(newFolderName)) {
- Toast.makeText(
- getSherlockActivity(),
- R.string.filename_forbidden_characters,
- Toast.LENGTH_LONG).show();
+ boolean serverWithForbiddenChars = ((ComponentsGetter)getActivity()).
+ 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(getActivity(), messageId, Toast.LENGTH_LONG).show();
+
return;
}
String path = mParentFolder.getRemotePath();
path += newFolderName + OCFile.PATH_SEPARATOR;
- ((ComponentsGetter)getSherlockActivity()).
+ ((ComponentsGetter)getActivity()).
getFileOperationsHelper().createFolder(path, false);
}
}