From: David A. Velasco Date: Tue, 19 Nov 2013 13:53:11 +0000 (+0100) Subject: Fixed test of oc_framework; more simple initialization X-Git-Tag: oc-android-1.5.5~123^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/11c261c6cc91a5c25aa729e1266ec9a0b4934725?hp=--cc Fixed test of oc_framework; more simple initialization --- 11c261c6cc91a5c25aa729e1266ec9a0b4934725 diff --git a/oc_framework-test-project/.classpath b/oc_framework-test-project/.classpath index d3d9f2d8..394360f0 100644 --- a/oc_framework-test-project/.classpath +++ b/oc_framework-test-project/.classpath @@ -1,10 +1,10 @@ - - - + + + diff --git a/oc_framework-test-project/libs/android-support-v4.jar b/oc_framework-test-project/libs/android-support-v4.jar index 9056828a..feaf44f8 100644 Binary files a/oc_framework-test-project/libs/android-support-v4.jar and b/oc_framework-test-project/libs/android-support-v4.jar differ diff --git a/oc_framework-test-project/oc_framework-test-test/.classpath b/oc_framework-test-project/oc_framework-test-test/.classpath index 49a8ebcf..6c54c1c9 100644 --- a/oc_framework-test-project/oc_framework-test-test/.classpath +++ b/oc_framework-test-project/oc_framework-test-test/.classpath @@ -1,10 +1,10 @@ - - + + diff --git a/oc_framework-test-project/res/values/strings.xml b/oc_framework-test-project/res/values/strings.xml index e50b40df..3a21cff9 100644 --- a/oc_framework-test-project/res/values/strings.xml +++ b/oc_framework-test-project/res/values/strings.xml @@ -4,5 +4,6 @@ oc_framework-test-project Settings Hello world! + The test account %1$s could not be found in the device diff --git a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java index 7fdf9cd4..7687bb2f 100644 --- a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@ -1,63 +1,38 @@ package com.owncloud.android.oc_framework_test_project; -import java.io.IOException; - -import com.owncloud.android.oc_framework.accounts.AccountUtils.AccountNotFoundException; 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.AsyncTask; +import android.net.Uri; import android.os.Bundle; -import android.accounts.Account; -import android.accounts.AccountManager; -import android.accounts.AuthenticatorException; -import android.accounts.OperationCanceledException; import android.app.Activity; -import android.content.Context; -import android.util.Log; import android.view.Menu; /** * Activity to test OC framework * @author masensio - * + * @author David A. Velasco */ 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 static final String mServerUri = "https://beta.owncloud.com/owncloud/remote.php/webdav"; + private static final String mUser = "testandroid"; + private static final String mPass = "testandroid"; - private Account mAccount = null; + //private Account mAccount = null; private WebdavClient mClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); - - AccountManager am = AccountManager.get(this); - - Account[] ocAccounts = am.getAccountsByType(mAccountType); - for (Account ac : ocAccounts) { - if (ac.name.equals(mAccountName)) { - mAccount = ac; - break; - } - } - - // Get the WebDavClient - AuthTask task = new AuthTask(); - task.execute(this.getApplicationContext()); - + Uri uri = Uri.parse(mServerUri); + mClient = OwnCloudClientFactory.createOwnCloudClient(uri ,getApplicationContext(), true); + mClient.setBasicCredentials(mUser, mPass); } @Override @@ -100,38 +75,4 @@ public class TestActivity extends Activity { return result; } - private class AuthTask extends AsyncTask { - - @Override - protected WebdavClient doInBackground(Context... params) { - WebdavClient client = null; - try { - client = OwnCloudClientFactory.createOwnCloudClient(mAccount, (Context) params[0] ); - } catch (OperationCanceledException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (AuthenticatorException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (AccountNotFoundException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (IOException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (IllegalStateException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } - return client; - } - - @Override - protected void onPostExecute(WebdavClient result) { - // TODO Auto-generated method stub - super.onPostExecute(result); - mClient = result; - } - - } }