|
@@ -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();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|