From: David A. Velasco Date: Fri, 10 Jan 2014 12:42:13 +0000 (+0100) Subject: Added first use of oc_framework: start of ReadFolderOperation when 'Refresh' is clicked X-Git-Tag: oc-android-1.5.5~69^2~21 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/cd8fe018cf978a73497975ccb4c391eb3456ae06 Added first use of oc_framework: start of ReadFolderOperation when 'Refresh' is clicked --- diff --git a/oc_framework/sample_client/AndroidManifest.xml b/oc_framework/sample_client/AndroidManifest.xml index b929fd46..f594aa66 100644 --- a/oc_framework/sample_client/AndroidManifest.xml +++ b/oc_framework/sample_client/AndroidManifest.xml @@ -3,6 +3,7 @@ package="com.owncloud.android.oc_framework.sampleclient" android:versionCode="1" android:versionName="1.0"> + diff --git a/oc_framework/sample_client/res/values/setup.xml b/oc_framework/sample_client/res/values/setup.xml new file mode 100644 index 00000000..595d13e4 --- /dev/null +++ b/oc_framework/sample_client/res/values/setup.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/oc_framework/sample_client/res/values/strings.xml b/oc_framework/sample_client/res/values/strings.xml index 74e5507c..20c64ce2 100644 --- a/oc_framework/sample_client/res/values/strings.xml +++ b/oc_framework/sample_client/res/values/strings.xml @@ -11,5 +11,7 @@ TODO: start upload TODO: start remote deletion TODO: start download - TODO: start local deletion + TODO: start local deletion + TODO: operation finished in sucess + TODO: operation finished in fail diff --git a/oc_framework/sample_client/src/com/owncloud/android/oc_framework/sampleclient/MainActivity.java b/oc_framework/sample_client/src/com/owncloud/android/oc_framework/sampleclient/MainActivity.java index 1fab09dd..a5400259 100644 --- a/oc_framework/sample_client/src/com/owncloud/android/oc_framework/sampleclient/MainActivity.java +++ b/oc_framework/sample_client/src/com/owncloud/android/oc_framework/sampleclient/MainActivity.java @@ -1,17 +1,31 @@ package com.owncloud.android.oc_framework.sampleclient; +import com.owncloud.android.oc_framework.accounts.AccountUtils; +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.OnRemoteOperationListener; +import com.owncloud.android.oc_framework.operations.RemoteOperation; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework.operations.remote.ReadRemoteFolderOperation; +import com.owncloud.android.oc_framework.utils.FileUtils; + import android.app.Activity; +import android.net.Uri; import android.os.Bundle; +import android.os.Handler; import android.view.View; import android.widget.Toast; -public class MainActivity extends Activity { +public class MainActivity extends Activity implements OnRemoteOperationListener { + + private Handler mHandler; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); + mHandler = new Handler(); } public void onClickHandler(View button) { @@ -37,7 +51,11 @@ public class MainActivity extends Activity { } private void startRefresh() { - Toast.makeText(this, R.string.todo_start_refresh, Toast.LENGTH_SHORT).show(); + RemoteOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR); + Uri serverUri = Uri.parse(getString(R.string.server_base_url) + AccountUtils.WEBDAV_PATH_4_0); + WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true); + client.setBasicCredentials(getString(R.string.username), getString(R.string.password)); + refreshOperation.execute(client, this, mHandler); } private void startUpload() { @@ -55,5 +73,14 @@ public class MainActivity extends Activity { private void startLocalDeletion() { Toast.makeText(this, R.string.todo_start_local_deletion, Toast.LENGTH_SHORT).show(); } + + @Override + public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { + if (result.isSuccess()) { + Toast.makeText(this, R.string.todo_operation_finished_in_success, Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show(); + } + } }