X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/aae90eb1aa42a11449e30330e3e23e1e9e5eebb6..HEAD:/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java diff --git a/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java b/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java index 29b3be28..7b58f4d8 100644 --- a/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java @@ -1,5 +1,8 @@ -/* 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, @@ -17,16 +20,16 @@ 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 com.owncloud.android.ui.activity.ComponentsGetter; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; 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; @@ -37,12 +40,10 @@ import android.widget.Toast; /** * 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"; @@ -50,9 +51,9 @@ 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(); @@ -71,7 +72,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { 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 @@ -80,7 +81,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { 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) @@ -100,23 +101,29 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { 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); } }