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
.ReadRemoteFileOperation
;
8 import com
.owncloud
.android
.oc_framework
.operations
.remote
.RemoveRemoteFileOperation
;
9 import com
.owncloud
.android
.oc_framework
.operations
.remote
.RenameRemoteFileOperation
;
11 import android
.net
.Uri
;
12 import android
.os
.Bundle
;
13 import android
.app
.Activity
;
14 import android
.view
.Menu
;
17 * Activity to test OC framework
19 * @author David A. Velasco
21 public class TestActivity
extends Activity
{
23 // This account must exists on the simulator / device
24 private static final String mServerUri
= "https://beta.owncloud.com/owncloud/remote.php/webdav";
25 private static final String mUser
= "testandroid";
26 private static final String mPass
= "testandroid";
28 //private Account mAccount = null;
29 private WebdavClient mClient
;
32 protected void onCreate(Bundle savedInstanceState
) {
33 super.onCreate(savedInstanceState
);
34 setContentView(R
.layout
.activity_test
);
35 Uri uri
= Uri
.parse(mServerUri
);
36 mClient
= OwnCloudClientFactory
.createOwnCloudClient(uri
,getApplicationContext(), true
);
37 mClient
.setBasicCredentials(mUser
, mPass
);
41 public boolean onCreateOptionsMenu(Menu menu
) {
42 // Inflate the menu; this adds items to the action bar if it is present.
43 getMenuInflater().inflate(R
.menu
.test
, menu
);
48 * Access to the library method to Create a Folder
49 * @param remotePath Full path to the new directory to create in the remote server.
50 * @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet.
54 public RemoteOperationResult
createFolder(String remotePath
, boolean createFullPath
) {
56 CreateRemoteFolderOperation createOperation
= new CreateRemoteFolderOperation(remotePath
, createFullPath
);
57 RemoteOperationResult result
= createOperation
.execute(mClient
);
63 * Access to the library method to Rename a File or Folder
64 * @param oldName Old name of the file.
65 * @param oldRemotePath Old remote path of the file. For folders it starts and ends by "/"
66 * @param newName New name to set as the name of file.
67 * @param isFolder 'true' for folder and 'false' for files
72 public RemoteOperationResult
renameFile(String oldName
, String oldRemotePath
, String newName
, boolean isFolder
) {
74 RenameRemoteFileOperation renameOperation
= new RenameRemoteFileOperation(oldName
, oldRemotePath
, newName
, isFolder
);
75 RemoteOperationResult result
= renameOperation
.execute(mClient
);
81 * Access to the library method to Remove a File or Folder
83 * @param remotePath Remote path of the file or folder in the server.
86 public RemoteOperationResult
removeFile(String remotePath
) {
88 RemoveRemoteFileOperation removeOperation
= new RemoveRemoteFileOperation(remotePath
);
89 RemoteOperationResult result
= removeOperation
.execute(mClient
);
95 * Access to the library method to Read a File or Folder (PROPFIND DEPTH 1)
100 public RemoteOperationResult
readFile(String remotePath
) {
102 ReadRemoteFileOperation readOperation
= new ReadRemoteFileOperation(remotePath
);
103 RemoteOperationResult result
= readOperation
.execute(mClient
);