1 package com
.owncloud
.android
.oc_framework_test_project
;
3 import java
.io
.IOException
;
5 import com
.owncloud
.android
.oc_framework
.accounts
.AccountUtils
.AccountNotFoundException
;
6 import com
.owncloud
.android
.oc_framework
.network
.webdav
.OwnCloudClientFactory
;
7 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavClient
;
8 import com
.owncloud
.android
.oc_framework
.operations
.RemoteOperationResult
;
9 import com
.owncloud
.android
.oc_framework
.operations
.remote
.CreateRemoteFolderOperation
;
11 import android
.os
.Bundle
;
12 import android
.accounts
.Account
;
13 import android
.accounts
.AccountManager
;
14 import android
.accounts
.AuthenticatorException
;
15 import android
.accounts
.OperationCanceledException
;
16 import android
.app
.Activity
;
17 import android
.util
.Log
;
18 import android
.view
.Menu
;
21 * Activity to test OC framework
25 public class TestActivity
extends Activity
{
27 private static final String TAG
= "TestActivity";
29 private Account mAccount
= null
;
30 private WebdavClient mClient
;
33 protected void onCreate(Bundle savedInstanceState
) {
34 super.onCreate(savedInstanceState
);
35 setContentView(R
.layout
.activity_test
);
37 // This account must exists on the simulator / device
38 String accountHost
= "beta.owncloud.com";
39 String accountUser
= "testandroid";
40 String accountName
= accountUser
+ "@"+ accountHost
;
41 String accountPass
= "testandroid";
42 String accountType
= "owncloud";
44 AccountManager am
= AccountManager
.get(this);
46 Account
[] ocAccounts
= am
.getAccountsByType(accountType
);
47 for (Account ac
: ocAccounts
) {
48 if (ac
.name
.equals(accountName
)) {
54 // if (mAccount == null) {
55 // mAccount = new Account(accountName, accountType);
56 // am.addAccountExplicitly(mAccount, accountPass, null);
57 // am.setUserData(mAccount, "oc_version", "5.0.14");
58 // am.setUserData(mAccount, "oc_base_url", "http://beta.owncloud.com/owncloud");
60 Log
.d(TAG
, "oc_version --->"+ am
.getUserData(mAccount
, "oc_version") );
61 Log
.d(TAG
, "oc_base_url --->"+ am
.getUserData(mAccount
, "oc_base_url") );
66 mClient
= OwnCloudClientFactory
.createOwnCloudClient(mAccount
, this.getApplicationContext());
67 } catch (OperationCanceledException e
) {
68 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
70 } catch (AuthenticatorException e
) {
71 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
73 } catch (AccountNotFoundException e
) {
74 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
76 } catch (IOException e
) {
77 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
83 public boolean onCreateOptionsMenu(Menu menu
) {
84 // Inflate the menu; this adds items to the action bar if it is present.
85 getMenuInflater().inflate(R
.menu
.test
, menu
);
90 * Access to the library method to Create a Folder
92 * @param createFullPath
95 public RemoteOperationResult
createFolder(String remotePath
, boolean createFullPath
) {
97 CreateRemoteFolderOperation createOperation
= new CreateRemoteFolderOperation(remotePath
, createFullPath
);
98 RemoteOperationResult result
= createOperation
.execute(mClient
);