|
@@ -7,6 +7,7 @@ import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;
|
|
|
import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
|
|
|
import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
|
|
|
import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation;
|
|
|
+import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
import android.accounts.Account;
|
|
@@ -26,6 +27,13 @@ public class TestActivity extends Activity {
|
|
|
|
|
|
private static final String TAG = "TestActivity";
|
|
|
|
|
|
+ // This account must exists on the simulator / device
|
|
|
+ private static final String mAccountHost = "beta.owncloud.com";
|
|
|
+ private static final String mAccountUser = "testandroid";
|
|
|
+ private static final String mAccountName = mAccountUser + "@"+ mAccountHost;
|
|
|
+ private static final String mAccountPass = "testandroid";
|
|
|
+ private static final String mAccountType = "owncloud";
|
|
|
+
|
|
|
private Account mAccount = null;
|
|
|
private WebdavClient mClient;
|
|
|
|
|
@@ -33,27 +41,20 @@ public class TestActivity extends Activity {
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_test);
|
|
|
-
|
|
|
- // This account must exists on the simulator / device
|
|
|
- String accountHost = "beta.owncloud.com";
|
|
|
- String accountUser = "masensio";
|
|
|
- String accountName = accountUser + "@"+ accountHost;
|
|
|
- String accountPass = "masensio";
|
|
|
- String accountType = "owncloud";
|
|
|
|
|
|
AccountManager am = AccountManager.get(this);
|
|
|
|
|
|
- Account[] ocAccounts = am.getAccountsByType(accountType);
|
|
|
+ Account[] ocAccounts = am.getAccountsByType(mAccountType);
|
|
|
for (Account ac : ocAccounts) {
|
|
|
- if (ac.name.equals(accountName)) {
|
|
|
+ if (ac.name.equals(mAccountName)) {
|
|
|
mAccount = ac;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if (mAccount == null) {
|
|
|
-// mAccount = new Account(accountName, accountType);
|
|
|
-// am.addAccountExplicitly(mAccount, accountPass, null);
|
|
|
+// mAccount = new Account(accountName, mAccountType);
|
|
|
+// am.addAccountExplicitly(mAccount, mAccountPass, null);
|
|
|
// am.setUserData(mAccount, "oc_version", "5.0.14");
|
|
|
// am.setUserData(mAccount, "oc_base_url", "http://beta.owncloud.com/owncloud");
|
|
|
// } else {
|
|
@@ -91,6 +92,7 @@ public class TestActivity extends Activity {
|
|
|
* @param folderName
|
|
|
* @param remotePath
|
|
|
* @param createFullPath
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public RemoteOperationResult createFolder(String folderName, String remotePath, boolean createFullPath) {
|
|
@@ -100,4 +102,22 @@ public class TestActivity extends Activity {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Access to the library method to Rename a File or Folder
|
|
|
+ * @param oldName Old name of the file.
|
|
|
+ * @param oldRemotePath Old remote path of the file. For folders it starts and ends by "/"
|
|
|
+ * @param newName New name to set as the name of file.
|
|
|
+ * @param newRemotePath New remote path to move the file, for folders it starts and ends by "/"
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ public RemoteOperationResult renameFile(String oldName, String oldRemotePath, String newName, String newRemotePath) {
|
|
|
+
|
|
|
+ RenameRemoteFileOperation renameOperation = new RenameRemoteFileOperation(oldName, oldRemotePath, newName, newRemotePath);
|
|
|
+ RemoteOperationResult result = renameOperation.execute(mClient);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|