1 package com
.owncloud
.android
.oc_framework_test_project
;
3 import com
.owncloud
.android
.oc_framework
.network
.webdav
.OwnCloudClientFactory
;
4 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavClient
;
5 import com
.owncloud
.android
.oc_framework
.operations
.RemoteOperationResult
;
6 import com
.owncloud
.android
.oc_framework
.operations
.remote
.CreateRemoteFolderOperation
;
7 import com
.owncloud
.android
.oc_framework
.operations
.remote
.RenameRemoteFileOperation
;
9 import android
.net
.Uri
;
10 import android
.os
.Bundle
;
11 import android
.app
.Activity
;
12 import android
.view
.Menu
;
15 * Activity to test OC framework
17 * @author David A. Velasco
19 public class TestActivity
extends Activity
{
21 // This account must exists on the simulator / device
22 private static final String mServerUri
= "https://beta.owncloud.com/owncloud/remote.php/webdav";
23 private static final String mUser
= "testandroid";
24 private static final String mPass
= "testandroid";
26 //private Account mAccount = null;
27 private WebdavClient mClient
;
30 protected void onCreate(Bundle savedInstanceState
) {
31 super.onCreate(savedInstanceState
);
32 setContentView(R
.layout
.activity_test
);
33 Uri uri
= Uri
.parse(mServerUri
);
34 mClient
= OwnCloudClientFactory
.createOwnCloudClient(uri
,getApplicationContext(), true
);
35 mClient
.setBasicCredentials(mUser
, mPass
);
39 public boolean onCreateOptionsMenu(Menu menu
) {
40 // Inflate the menu; this adds items to the action bar if it is present.
41 getMenuInflater().inflate(R
.menu
.test
, menu
);
46 * Access to the library method to Create a Folder
48 * @param createFullPath
52 public RemoteOperationResult
createFolder(String remotePath
, boolean createFullPath
) {
54 CreateRemoteFolderOperation createOperation
= new CreateRemoteFolderOperation(remotePath
, createFullPath
);
55 RemoteOperationResult result
= createOperation
.execute(mClient
);
61 * Access to the library method to Rename a File or Folder
62 * @param oldName Old name of the file.
63 * @param oldRemotePath Old remote path of the file. For folders it starts and ends by "/"
64 * @param newName New name to set as the name of file.
65 * @param isFolder 'true' for folder and 'false' for files
70 public RemoteOperationResult
renameFile(String oldName
, String oldRemotePath
, String newName
, boolean isFolder
) {
72 RenameRemoteFileOperation renameOperation
= new RenameRemoteFileOperation(oldName
, oldRemotePath
, newName
, isFolder
);
73 RemoteOperationResult result
= renameOperation
.execute(mClient
);