diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 36c89370..81b9494e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -34,7 +34,7 @@
diff --git a/build.gradle b/build.gradle
index 64b3f1dd..3fe45e41 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,25 +1,29 @@
buildscript {
repositories {
jcenter()
+ google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.android.tools.build:gradle:3.1.2'
}
}
apply plugin: 'com.android.library'
-repositories {
- jcenter()
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ }
}
dependencies {
- compile 'org.apache.jackrabbit:jackrabbit-webdav:2.12.4'
+ api 'org.apache.jackrabbit:jackrabbit-webdav:2.12.4'
+ api 'com.squareup.okhttp3:okhttp:3.10.0'
}
android {
compileSdkVersion 26
- buildToolsVersion '26.0.2'
sourceSets {
main {
@@ -33,7 +37,7 @@ android {
}
// Move the tests to tests/java, tests/res, etc...
- instrumentTest.setRoot('tests')
+ androidTest.setRoot('tests')
// Move the build types to build-types/
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a04cf10f..267dfc1e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
\ No newline at end of file
diff --git a/sample_client/AndroidManifest.xml b/sample_client/AndroidManifest.xml
index df33bb06..a2697540 100644
--- a/sample_client/AndroidManifest.xml
+++ b/sample_client/AndroidManifest.xml
@@ -22,24 +22,29 @@
THE SOFTWARE.
-->
-
+
-
+ package="com.owncloud.android.lib.sampleclient"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+
-
-
+ android:minSdkVersion="14"
+ android:targetSdkVersion="26"/>
+
+
-
-
+
+
diff --git a/sample_client/assets/oc_sample.txt b/sample_client/assets/oc_sample.txt
new file mode 100644
index 00000000..49254be3
--- /dev/null
+++ b/sample_client/assets/oc_sample.txt
@@ -0,0 +1 @@
+Testing ownCloud uploads
diff --git a/sample_client/build.gradle b/sample_client/build.gradle
index 2c7a6b08..c0f96865 100644
--- a/sample_client/build.gradle
+++ b/sample_client/build.gradle
@@ -5,12 +5,11 @@ repositories {
}
dependencies {
- compile project(':')
+ implementation project(':')
}
android {
compileSdkVersion 26
- buildToolsVersion "26.0.2"
sourceSets {
main {
@@ -24,7 +23,7 @@ android {
}
// Move the tests to tests/java, tests/res, etc...
- instrumentTest.setRoot('tests')
+ androidTest.setRoot('tests')
// Move the build types to build-types/
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
@@ -43,9 +42,4 @@ android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
- android {
- lintOptions {
- abortOnError false
- }
- }
}
diff --git a/sample_client/gradle/wrapper/gradle-wrapper.properties b/sample_client/gradle/wrapper/gradle-wrapper.properties
index 122a0dca..fc5d4423 100644
--- a/sample_client/gradle/wrapper/gradle-wrapper.properties
+++ b/sample_client/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
\ No newline at end of file
diff --git a/sample_client/res/layout/main.xml b/sample_client/res/layout/main.xml
index c011ce78..6a15c528 100644
--- a/sample_client/res/layout/main.xml
+++ b/sample_client/res/layout/main.xml
@@ -22,101 +22,152 @@
THE SOFTWARE.
-->
-
+
+
+
+
+
-
-
-
+ android:layout_below="@id/server_address"
+ android:layout_marginTop="10dp"
+ android:onClick="onClickHandler"
+ android:text="@string/refresh"/>
-
-
-
-
-
-
-
+ android:layout_below="@id/button_refresh"
+ android:layout_marginTop="10dp"
+ android:onClick="onClickHandler"
+ android:text="@string/upload"/>
-
-
+ android:layout_below="@id/button_upload"
+ android:layout_marginTop="10dp"
+ android:onClick="onClickHandler"
+ android:text="@string/download"/>
+ android:id="@+id/button_delete_remote"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@id/button_download"
+ android:layout_marginTop="10dp"
+ android:onClick="onClickHandler"
+ android:text="@string/delete_remote_file"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sample_client/res/values/strings.xml b/sample_client/res/values/strings.xml
index 63a37cd9..6ef9c46c 100644
--- a/sample_client/res/values/strings.xml
+++ b/sample_client/res/values/strings.xml
@@ -26,6 +26,7 @@
ownCloud Sample Client
Refresh
+ Check server
Upload
Delete remote file
Download
@@ -41,7 +42,7 @@
to_upload
downloaded
Sample file could not be saved in temporal folder; upload will not work
- oc_sample.png
+ oc_sample.png
image/png
Downloaded file could not be deleted
diff --git a/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java
index 3cb43f72..e87dbc4c 100644
--- a/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java
+++ b/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java
@@ -1,5 +1,7 @@
/* ownCloud Android Library is available under MIT license
- * Copyright (C) 2016 ownCloud GmbH.
+ * Copyright (C) 2018 ownCloud GmbH.
+ *
+ * @author David González Verdugo
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +26,35 @@
package com.owncloud.android.lib.sampleclient;
+import android.app.Activity;
+import android.content.res.AssetManager;
+import android.graphics.drawable.BitmapDrawable;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientFactory;
+import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory;
+import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
+import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation;
+import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
+import com.owncloud.android.lib.resources.files.RemoteFile;
+import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
+import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -32,35 +63,30 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
-import com.owncloud.android.lib.common.OwnCloudClientFactory;
-import com.owncloud.android.lib.common.OwnCloudClient;
-import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory;
-import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
-import com.owncloud.android.lib.resources.files.RemoteFile;
-import com.owncloud.android.lib.common.operations.RemoteOperation;
-import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation;
-import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
-import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
-import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
-import com.owncloud.android.lib.resources.files.FileUtils;
-
-import android.app.Activity;
-import android.content.res.AssetManager;
-import android.graphics.drawable.BitmapDrawable;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Credentials;
+import okhttp3.Headers;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
public class MainActivity extends Activity implements OnRemoteOperationListener, OnDatatransferProgressListener {
- private static String LOG_TAG = MainActivity.class.getCanonicalName();
+ private static String LOG_TAG = MainActivity.class.getCanonicalName();
+
+ private static final String NODE_VERSION = "version";
+ private static final String WEBDAV_PATH_4_0 = "/remote.php/webdav/";
+ private static final String NEW_WEBDAV_PATH = "/remote.php/dav/files/";
+ private static final String OC_TOTAL_LENGTH_HEADER = "OC-Total-Length";
+ private static final String OC_X_OC_MTIME_HEADER = "X-OC-Mtime";
+ private static final String AUTHORIZATION_HEADER = "Authorization";
+ private static final String USER_AGENT_HEADER = "User-Agent";
+ private static final String CONTENT_TYPE_HEADER = "Content-Type";
+ private static final String USER_AGENT_VALUE = "Mozilla/5.0 (Android) ownCloud-android/2.7.0";
+ private static final String CONTENT_TYPE_VALUE = "multipart/form-data";
private Handler mHandler;
@@ -69,6 +95,10 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
private FilesArrayAdapter mFilesAdapter;
private View mFrame;
+
+ private OkHttpClient mOkHttpClient;
+
+ private String mCredentials;
/** Called when the activity is first created. */
@Override
@@ -88,7 +118,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
);
mFilesAdapter = new FilesArrayAdapter(this, R.layout.file_in_list);
- ((ListView)findViewById(R.id.list_view)).setAdapter(mFilesAdapter);
+// ((ListView)findViewById(R.id.list_view)).setAdapter(mFilesAdapter);
// TODO move to background thread or task
AssetManager assets = getAssets();
@@ -110,8 +140,14 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
Toast.makeText(this, R.string.error_copying_sample_file, Toast.LENGTH_SHORT).show();
Log.e(LOG_TAG, getString(R.string.error_copying_sample_file), e);
}
+
+ ((TextView) findViewById(R.id.server_address)).setText(getString(R.string.server_base_url));
+
+ mOkHttpClient = new OkHttpClient();
+
+ mCredentials = Credentials.basic(getString(R.string.username), getString(R.string.password));
- mFrame = findViewById(R.id.frame);
+// mFrame = findViewById(R.id.frame);
}
@@ -127,63 +163,264 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
public void onClickHandler(View button) {
switch (button.getId()) {
+ case R.id.button_check_server:
+ startCheck();
+ break;
case R.id.button_refresh:
startRefresh();
break;
case R.id.button_upload:
startUpload();
break;
+ case R.id.button_download:
+ startDownload();
+ break;
case R.id.button_delete_remote:
startRemoteDeletion();
break;
- case R.id.button_download:
- startDownload();
- break;
- case R.id.button_delete_local:
- startLocalDeletion();
- break;
+// case R.id.button_delete_local:
+// startLocalDeletion();
+// break;
default:
Toast.makeText(this, R.string.youre_doing_it_wrong, Toast.LENGTH_SHORT).show();
}
}
-
- private void startRefresh() {
- ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR);
- refreshOperation.execute(mClient, this, mHandler);
- }
+
+ private void startCheck() {
+
+ if (!validServerAddress()) return;
+
+ Request request = new Request.Builder()
+ .url(getString(R.string.server_base_url) + "/status.php")
+ .get()
+ .build();
+
+ mOkHttpClient.newCall(request).enqueue(new Callback() {
+
+ @Override public void onResponse(Call call, final Response response) throws IOException {
+
+ if (!response.isSuccessful()) {
+
+ showMessage("Response not successful with code: " + response.code());
+
+ throw new IOException("Unexpected code " + response);
+ }
+
+ try { // Successful response
+
+ String jsonData = response.body().string();
+
+ JSONObject Jobject = new JSONObject(jsonData);
+
+ final String serverVersion = Jobject.get("version").toString();
+
+ showMessage("Server with version " + serverVersion + " detected");
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ Headers responseHeaders = response.headers();
+ for (int i = 0, size = responseHeaders.size(); i < size; i++) {
+ System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
+ }
+ }
+
+ @Override public void onFailure(Call call, final IOException e) {
+ e.printStackTrace();
+ showMessage("Something was wrong: " + e.toString());
+ }
+ });
+ }
+
+ private void startRefresh() {
+
+// Let's first use OKHttp with the new endpoint without depending on our library operations
+
+// ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR);
+// refreshOperation.execute(mClient, this, mHandler);
+
+ if (!validServerAddress()) return;
+
+ final Request request = new Request.Builder()
+ .url(getString(R.string.server_base_url) + NEW_WEBDAV_PATH + getString(R.string.username))
+ .addHeader(AUTHORIZATION_HEADER, mCredentials)
+ .addHeader(USER_AGENT_HEADER, USER_AGENT_VALUE)
+ .method("PROPFIND", null)
+ .build();
+
+ mOkHttpClient.newCall(request).enqueue(new Callback() {
+
+ @Override public void onResponse(Call call, final Response response) throws IOException {
+
+ if (!response.isSuccessful()) {
+
+ showMessage("Response not successful with code: " + response.code());
+
+ throw new IOException("Unexpected code " + response);
+
+ } else { // Successful response
+
+ final String propFindResult = response.body().string();
+
+ showMessage(propFindResult);
+
+ Headers responseHeaders = response.headers();
+ for (int i = 0, size = responseHeaders.size(); i < size; i++) {
+ System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
+ }
+ }
+ }
+
+ @Override public void onFailure(Call call, IOException e) {
+ showMessage("Something was wrong: " + e.toString());
+ e.printStackTrace();
+ }
+ });
+ }
private void startUpload() {
+
File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
- File fileToUpload = upFolder.listFiles()[0];
+ final File fileToUpload = upFolder.listFiles()[0];
String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
String mimeType = getString(R.string.sample_file_mimetype);
+ MediaType mediaType = MediaType.parse(mimeType);
+
// Get the last modification date of the file from the file system
Long timeStampLong = fileToUpload.lastModified()/1000;
String timeStamp = timeStampLong.toString();
- UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType, timeStamp);
- uploadOperation.addDatatransferProgressListener(this);
- uploadOperation.execute(mClient, this, mHandler);
+// Let's first use OKHttp with the new endpoint without depending on our library operations
+
+// UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType, timeStamp);
+// uploadOperation.addDatatransferProgressListener(this);
+// uploadOperation.execute(mClient, this, mHandler);
+
+ if (!validServerAddress()) return;
+
+ RequestBody requestBody = RequestBody.create(mediaType, fileToUpload);
+
+ final Request request = new Request.Builder()
+ .url(getString(R.string.server_base_url) + NEW_WEBDAV_PATH + getString(R.string.username) + remotePath)
+ .addHeader(AUTHORIZATION_HEADER, mCredentials)
+ .addHeader(USER_AGENT_HEADER, USER_AGENT_VALUE)
+ .addHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_VALUE)
+ .addHeader(OC_TOTAL_LENGTH_HEADER, String.valueOf(fileToUpload.length()))
+ .addHeader(OC_X_OC_MTIME_HEADER, timeStamp)
+ .put(requestBody)
+ .build();
+
+ mOkHttpClient.newCall(request).enqueue(new Callback() {
+
+ @Override public void onResponse(Call call, final Response response) throws IOException {
+
+ if (!response.isSuccessful()) {
+
+ showMessage("Response not successful with code: " + response.code());
+
+ throw new IOException("Unexpected code " + response);
+
+ } else { // Successful response
+
+ showMessage("Successful upload of " + fileToUpload.getName());
+ }
+ }
+
+ @Override public void onFailure(Call call, IOException e) {
+ e.printStackTrace();
+ showMessage("Something was wrong: " + e.toString());
+ }
+ });
}
-
- private void startRemoteDeletion() {
+
+ private void startDownload() {
+ File downFolder = new File(getCacheDir(), getString(R.string.download_folder_path));
+ downFolder.mkdir();
+ File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
+ final File fileToUpload = upFolder.listFiles()[0];
+ String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
+
+// Let's first use OKHttp with the new endpoint without depending on our library operations
+
+// DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath());
+// downloadOperation.addDatatransferProgressListener(this);
+// downloadOperation.execute(mClient, this, mHandler);
+
+ if (!validServerAddress()) return;
+
+ final Request request = new Request.Builder()
+ .url(getString(R.string.server_base_url) + NEW_WEBDAV_PATH + getString(R.string.username) + remotePath)
+ .addHeader(AUTHORIZATION_HEADER, mCredentials)
+ .addHeader(USER_AGENT_HEADER, USER_AGENT_VALUE)
+ .get()
+ .build();
+
+
+ mOkHttpClient.newCall(request).enqueue(new Callback() {
+
+ @Override public void onResponse(Call call, final Response response) throws IOException {
+
+ if (!response.isSuccessful()) {
+
+ showMessage("Response not successful with code: " + response.code());
+
+ throw new IOException("Unexpected code " + response);
+
+ } else { // Successful response
+
+ showMessage("Successful download of " + fileToUpload.getName() + " although local file " +
+ "won't be created in this stage");
+ }
+ }
+
+ @Override public void onFailure(Call call, IOException e) {
+ e.printStackTrace();
+ showMessage("Something was wrong: " + e.toString());
+ }
+ });
+ }
+
+ private void startRemoteDeletion() {
File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
- File fileToUpload = upFolder.listFiles()[0];
+ final File fileToUpload = upFolder.listFiles()[0];
String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
- RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath);
- removeOperation.execute(mClient, this, mHandler);
- }
-
- private void startDownload() {
- File downFolder = new File(getCacheDir(), getString(R.string.download_folder_path));
- downFolder.mkdir();
- File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
- File fileToUpload = upFolder.listFiles()[0];
- String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
- DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath());
- downloadOperation.addDatatransferProgressListener(this);
- downloadOperation.execute(mClient, this, mHandler);
+
+// Let's first use OKHttp with the new endpoint without depending on our library operations
+// RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath);
+// removeOperation.execute(mClient, this, mHandler);
+
+ if (!validServerAddress()) return;
+
+ final Request request = new Request.Builder()
+ .url(getString(R.string.server_base_url) + NEW_WEBDAV_PATH + getString(R.string.username) + remotePath)
+ .addHeader(AUTHORIZATION_HEADER, mCredentials)
+ .addHeader(USER_AGENT_HEADER, USER_AGENT_VALUE)
+ .delete()
+ .build();
+
+ mOkHttpClient.newCall(request).enqueue(new Callback() {
+
+ @Override public void onResponse(Call call, final Response response) throws IOException {
+
+ if (!response.isSuccessful()) {
+
+ showMessage("Response not successful with code: " + response.code());
+
+ throw new IOException("Unexpected code " + response);
+
+ } else { // Successful response
+
+ showMessage("Successful deletion of " + fileToUpload.getName());
+ }
+ }
+
+ @Override public void onFailure(Call call, IOException e) {
+ e.printStackTrace();
+ showMessage("Something was wrong: " + e.toString());
+ }
+ });
}
@SuppressWarnings("deprecation")
@@ -193,8 +430,8 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
if (!downloadedFile.delete() && downloadedFile.exists()) {
Toast.makeText(this, R.string.error_deleting_local_file, Toast.LENGTH_SHORT).show();
} else {
- ((TextView) findViewById(R.id.download_progress)).setText("0%");
- findViewById(R.id.frame).setBackgroundDrawable(null);
+// ((TextView) findViewById(R.id.download_progress)).setText("0%");
+// findViewById(R.id.frame).setBackgroundDrawable(null);
}
}
@@ -243,10 +480,10 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
private void onSuccessfulRemoteDeletion(RemoveRemoteFileOperation operation, RemoteOperationResult result) {
startRefresh();
- TextView progressView = (TextView) findViewById(R.id.upload_progress);
- if (progressView != null) {
- progressView.setText("0%");
- }
+// TextView progressView = (TextView) findViewById(R.id.upload_progress);
+// if (progressView != null) {
+// progressView.setText("0%");
+// }
}
@SuppressWarnings("deprecation")
@@ -266,11 +503,11 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
@Override
public void run() {
TextView progressView = null;
- if (upload) {
- progressView = (TextView) findViewById(R.id.upload_progress);
- } else {
- progressView = (TextView) findViewById(R.id.download_progress);
- }
+// if (upload) {
+// progressView = (TextView) findViewById(R.id.upload_progress);
+// } else {
+// progressView = (TextView) findViewById(R.id.download_progress);
+// }
if (progressView != null) {
progressView.setText(Long.toString(percentage) + "%");
}
@@ -278,4 +515,32 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
});
}
+ private boolean validServerAddress() {
+
+ String serverAddress = ((TextView) findViewById(R.id.server_address)).getText().toString();
+
+ if (serverAddress.equals("") || (!serverAddress.contains("http://") && !serverAddress.contains("https://"))) {
+ showToastMessage("Introduce a proper server address with http/https");
+ return false;
+ }
+ return true;
+ }
+
+ private void showMessage(final String message) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+
+ showToastMessage(message);
+ }
+ });
+ }
+
+ private void showToastMessage(String message) {
+ Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
+
+ toast.setGravity(Gravity.CENTER, 0, 0);
+
+ toast.show();
+ }
}
diff --git a/src/com/owncloud/android/lib/common/network/WebdavEntry.java b/src/com/owncloud/android/lib/common/network/WebdavEntry.java
index d93286b3..248350b3 100644
--- a/src/com/owncloud/android/lib/common/network/WebdavEntry.java
+++ b/src/com/owncloud/android/lib/common/network/WebdavEntry.java
@@ -1,5 +1,7 @@
-/* ownCloud Android Library is available under MIT license
- * Copyright (C) 2016 ownCloud GmbH.
+/** ownCloud Android Library is available under MIT license
+ *
+ * @author Christian Schabesberger
+ * Copyright (C) 2018 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -164,7 +166,7 @@ public class WebdavEntry {
prop = propSet.get(
EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(NAMESPACE_OC)
);
- if (prop != null) {
+ if (prop != null && prop.getValue() != null) {
mPermissions = prop.getValue().toString();
}
diff --git a/src/com/owncloud/android/lib/common/network/WebdavUtils.java b/src/com/owncloud/android/lib/common/network/WebdavUtils.java
index 8c307b60..1bbf3aa9 100644
--- a/src/com/owncloud/android/lib/common/network/WebdavUtils.java
+++ b/src/com/owncloud/android/lib/common/network/WebdavUtils.java
@@ -140,6 +140,17 @@ public class WebdavUtils {
return propSet;
}
+ /**
+ * Builds a DavPropertyNameSet with properties for user quotas
+ * @return set of quota properties
+ */
+ public static DavPropertyNameSet getQuotaPropSet() {
+ DavPropertyNameSet propSet = new DavPropertyNameSet();
+ propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_AVAILABLE_BYTES));
+ propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_USED_BYTES));
+ return propSet;
+ }
+
/**
*
* @param rawEtag
diff --git a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java
index e8699e7d..56722fe5 100644
--- a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java
+++ b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java
@@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license
- * Copyright (C) 2016 ownCloud GmbH.
+ * Copyright (C) 2018 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -55,11 +55,12 @@ import javax.net.ssl.SSLException;
/**
* The result of a remote operation required to an ownCloud server.
- *
+ *
* Provides a common classification of remote operation results for all the
* application.
*
* @author David A. Velasco
+ * @author David González Verdugo
*/
public class RemoteOperationResult implements Serializable {
@@ -378,8 +379,8 @@ public class RemoteOperationResult implements Serializable {
}
}
- public void setData(ArrayList