1 package com
.owncloud
.android
.oc_framework_test_project
;
3 import java
.io
.IOException
;
4 import com
.owncloud
.android
.oc_framework
.authentication
.AccountUtils
.AccountNotFoundException
;
5 import com
.owncloud
.android
.oc_framework
.network
.OwnCloudClientUtils
;
6 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavClient
;
7 import com
.owncloud
.android
.oc_framework
.operations
.RemoteOperationResult
;
8 import com
.owncloud
.android
.oc_framework
.operations
.remote
.CreateRemoteFolderOperation
;
10 import android
.os
.Bundle
;
11 import android
.accounts
.Account
;
12 import android
.accounts
.AccountManager
;
13 import android
.accounts
.AuthenticatorException
;
14 import android
.accounts
.OperationCanceledException
;
15 import android
.app
.Activity
;
16 import android
.util
.Log
;
17 import android
.view
.Menu
;
19 public class TestActivity
extends Activity
{
21 private static final String TAG
= "TestActivity";
23 private Account mAccount
;
24 private WebdavClient mClient
;
27 protected void onCreate(Bundle savedInstanceState
) {
28 super.onCreate(savedInstanceState
);
29 setContentView(R
.layout
.activity_test
);
31 String accountName
= "admin@beta.owncloud.com";
32 String accountHost
= "beta.owncloud.com";
33 String accountUser
= "admin";
34 String accountPass
= "owncloud42";
35 String accountType
= "owncloud";
36 String accountTypePass
= "owncloud.password";
37 String authorities
= "org.owncloud";
39 mAccount
= new Account(accountName
, accountType
);
40 AccountManager am
= AccountManager
.get(this);
41 am
.addAccountExplicitly(mAccount
, accountPass
, null
);
45 mClient
= OwnCloudClientUtils
.createOwnCloudClient(mAccount
, this.getApplicationContext(), authorities
);
46 } catch (OperationCanceledException e
) {
47 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
49 } catch (AuthenticatorException e
) {
50 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
52 } catch (AccountNotFoundException e
) {
53 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
55 } catch (IOException e
) {
56 Log
.e(TAG
, "Error while trying to access to " + mAccount
.name
, e
);
62 public boolean onCreateOptionsMenu(Menu menu
) {
63 // Inflate the menu; this adds items to the action bar if it is present.
64 getMenuInflater().inflate(R
.menu
.test
, menu
);
68 public RemoteOperationResult
createFolder(String remotePath
, boolean createFullPath
) {
70 CreateRemoteFolderOperation createOperation
= new CreateRemoteFolderOperation(remotePath
, createFullPath
);
71 RemoteOperationResult result
= createOperation
.execute(mClient
);