mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Merge pull request #297 from owncloud/BuildSampleApp
Build sample app successful
This commit is contained in:
commit
015011b6e0
5
.gitignore
vendored
5
.gitignore
vendored
@ -19,11 +19,6 @@ gen/
|
|||||||
# Local configuration files (sdk path, etc)
|
# Local configuration files (sdk path, etc)
|
||||||
.gradle/
|
.gradle/
|
||||||
local.properties
|
local.properties
|
||||||
sample_client/local.properties
|
|
||||||
|
|
||||||
# Mac .DS_Store files
|
# Mac .DS_Store files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Proguard README
|
|
||||||
proguard-project.txt
|
|
||||||
sample_client/proguard-project.txt
|
|
@ -1,7 +1,7 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
// Libraries
|
// Libraries
|
||||||
kotlinVersion = '1.3.50'
|
kotlinVersion = '1.3.61'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@ -9,7 +9,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.5.2'
|
classpath 'com.android.tools.build:gradle:3.5.3'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
|
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
|
||||||
}
|
}
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
|
||||||
|
@ -64,7 +64,7 @@ public class AccountUtils {
|
|||||||
webDavUrlForAccount = getBaseUrlForAccount(context, account) + OwnCloudClient.WEBDAV_FILES_PATH_4_0
|
webDavUrlForAccount = getBaseUrlForAccount(context, account) + OwnCloudClient.WEBDAV_FILES_PATH_4_0
|
||||||
+ ownCloudCredentials.getUsername();
|
+ ownCloudCredentials.getUsername();
|
||||||
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
|
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
|
||||||
e.printStackTrace();
|
Timber.e(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return webDavUrlForAccount;
|
return webDavUrlForAccount;
|
||||||
|
@ -31,8 +31,6 @@ import okhttp3.internal.Util;
|
|||||||
|
|
||||||
public class OwnCloudBasicCredentials implements OwnCloudCredentials {
|
public class OwnCloudBasicCredentials implements OwnCloudCredentials {
|
||||||
|
|
||||||
private static final String TAG = OwnCloudCredentials.class.getSimpleName();
|
|
||||||
|
|
||||||
private String mUsername;
|
private String mUsername;
|
||||||
private String mPassword;
|
private String mPassword;
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class OAuth2QueryParser {
|
public class OAuth2QueryParser {
|
||||||
|
|
||||||
private static final String TAG = OAuth2QueryParser.class.getName();
|
|
||||||
|
|
||||||
private Map<String, String> mOAuth2ParsedAuthorizationResponse;
|
private Map<String, String> mOAuth2ParsedAuthorizationResponse;
|
||||||
|
|
||||||
public OAuth2QueryParser() {
|
public OAuth2QueryParser() {
|
||||||
|
@ -43,11 +43,8 @@ import java.security.cert.X509Certificate;
|
|||||||
*/
|
*/
|
||||||
public class AdvancedX509TrustManager implements X509TrustManager {
|
public class AdvancedX509TrustManager implements X509TrustManager {
|
||||||
|
|
||||||
private static final String TAG = AdvancedX509TrustManager.class.getSimpleName();
|
|
||||||
|
|
||||||
private X509TrustManager mStandardTrustManager;
|
private X509TrustManager mStandardTrustManager;
|
||||||
private KeyStore mKnownServersKeyStore;
|
private KeyStore mKnownServersKeyStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AdvancedX509TrustManager
|
* Constructor for AdvancedX509TrustManager
|
||||||
*
|
*
|
||||||
|
@ -24,13 +24,12 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.common.network;
|
package com.owncloud.android.lib.common.network;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import okio.Okio;
|
import okio.Okio;
|
||||||
import okio.Source;
|
import okio.Source;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -45,8 +44,6 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class FileRequestBody extends RequestBody implements ProgressiveDataTransferer {
|
public class FileRequestBody extends RequestBody implements ProgressiveDataTransferer {
|
||||||
|
|
||||||
private static final String TAG = FileRequestBody.class.getSimpleName();
|
|
||||||
|
|
||||||
protected File mFile;
|
protected File mFile;
|
||||||
private MediaType mContentType;
|
private MediaType mContentType;
|
||||||
final Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<>();
|
final Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<>();
|
||||||
@ -87,11 +84,10 @@ public class FileRequestBody extends RequestBody implements ProgressiveDataTrans
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "File with name " + mFile.getName() + " and size " + mFile.length() +
|
Timber.d("File with name " + mFile.getName() + " and size " + mFile.length() + " written in request body");
|
||||||
" written in request body");
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Timber.e(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.files;
|
package com.owncloud.android.lib.resources.files;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.http.HttpConstants;
|
import com.owncloud.android.lib.common.http.HttpConstants;
|
||||||
import com.owncloud.android.lib.common.http.methods.webdav.CopyMethod;
|
import com.owncloud.android.lib.common.http.methods.webdav.CopyMethod;
|
||||||
@ -33,6 +31,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
|
|||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -49,8 +48,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class CopyRemoteFileOperation extends RemoteOperation<String> {
|
public class CopyRemoteFileOperation extends RemoteOperation<String> {
|
||||||
|
|
||||||
private static final String TAG = CopyRemoteFileOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final int COPY_READ_TIMEOUT = 600000;
|
private static final int COPY_READ_TIMEOUT = 600000;
|
||||||
private static final int COPY_CONNECTION_TIMEOUT = 5000;
|
private static final int COPY_CONNECTION_TIMEOUT = 5000;
|
||||||
|
|
||||||
@ -120,13 +117,11 @@ public class CopyRemoteFileOperation extends RemoteOperation<String> {
|
|||||||
client.exhaustResponse(copyMethod.getResponseBodyAsStream());
|
client.exhaustResponse(copyMethod.getResponseBodyAsStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " +
|
Timber.i("Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage());
|
||||||
result.getLogMessage());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
Log.e(TAG, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " +
|
Timber.e(e, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage());
|
||||||
result.getLogMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
package com.owncloud.android.lib.resources.files;
|
package com.owncloud.android.lib.resources.files;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.http.HttpConstants;
|
import com.owncloud.android.lib.common.http.HttpConstants;
|
||||||
@ -34,6 +33,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
|
|||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -49,8 +49,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class MoveRemoteFileOperation extends RemoteOperation {
|
public class MoveRemoteFileOperation extends RemoteOperation {
|
||||||
|
|
||||||
private static final String TAG = MoveRemoteFileOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final int MOVE_READ_TIMEOUT = 600000;
|
private static final int MOVE_READ_TIMEOUT = 600000;
|
||||||
private static final int MOVE_CONNECTION_TIMEOUT = 5000;
|
private static final int MOVE_CONNECTION_TIMEOUT = 5000;
|
||||||
|
|
||||||
@ -132,13 +130,11 @@ public class MoveRemoteFileOperation extends RemoteOperation {
|
|||||||
client.exhaustResponse(move.getResponseBodyAsStream());
|
client.exhaustResponse(move.getResponseBodyAsStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " +
|
Timber.i("Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage());
|
||||||
result.getLogMessage());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
Log.e(TAG, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " +
|
Timber.e(e, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage());
|
||||||
result.getLogMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -99,8 +99,7 @@ public class ReadRemoteFileOperation extends RemoteOperation<RemoteFile> {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
e.printStackTrace();
|
Timber.e(e, "Synchronizing file %s", mRemotePath);
|
||||||
Timber.e(result.getException(), "Synchronizing file " + mRemotePath + ": " + result.getLogMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -383,8 +383,6 @@ class ShareXMLParser {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
//private static final String TAG = ShareXMLParser.class.getSimpleName();
|
|
||||||
|
|
||||||
// No namespaces
|
// No namespaces
|
||||||
private val ns: String? = null
|
private val ns: String? = null
|
||||||
|
|
||||||
|
69
pom.xml
69
pom.xml
@ -1,69 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>com.owncloud.android</groupId>
|
|
||||||
<artifactId>owncloud-android-library</artifactId>
|
|
||||||
<version>${owncloud.version}</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>owncloud-android-library for Owncloud Android</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<owncloud.version>1.5.1-SNAPSHOT</owncloud.version>
|
|
||||||
<java-version>1.6</java-version>
|
|
||||||
<!-- Given by maven-android-sdk-deployer -->
|
|
||||||
<google.android-version>4.4.2_r4</google.android-version>
|
|
||||||
<!-- Usually the latest Android API -->
|
|
||||||
<google.android-api>19</google.android-api>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<description>owncloud-android-library for Owncloud for Android</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>android</groupId>
|
|
||||||
<artifactId>android</artifactId>
|
|
||||||
<version>${google.android-version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
|
|
||||||
<plugins>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.0</version>
|
|
||||||
<configuration>
|
|
||||||
<source>${java-version}</source>
|
|
||||||
<target>${java-version}</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
|
|
||||||
<artifactId>android-maven-plugin</artifactId>
|
|
||||||
<version>3.8.0</version>
|
|
||||||
<configuration>
|
|
||||||
<sdk>
|
|
||||||
<path>${env.ANDROID_HOME}</path>
|
|
||||||
<platform>${google.android-api}</platform>
|
|
||||||
</sdk>
|
|
||||||
</configuration>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
|
||||||
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
|
|
@ -33,7 +33,6 @@ import android.graphics.drawable.BitmapDrawable;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -47,28 +46,24 @@ import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
|
|||||||
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation;
|
import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation;
|
||||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||||
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
|
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
|
||||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||||
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
|
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
|
||||||
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
|
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
|
||||||
|
import info.hannes.timber.DebugTree;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity implements OnRemoteOperationListener, OnDatatransferProgressListener {
|
public class MainActivity extends Activity implements OnRemoteOperationListener, OnDatatransferProgressListener {
|
||||||
|
|
||||||
private static String LOG_TAG = MainActivity.class.getCanonicalName();
|
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private OwnCloudClient mClient;
|
private OwnCloudClient mClient;
|
||||||
private FilesArrayAdapter mFilesAdapter;
|
private FilesArrayAdapter mFilesAdapter;
|
||||||
@ -82,6 +77,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
|
Timber.plant(new DebugTree());
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
|
|
||||||
final Uri serverUri = Uri.parse(getString(R.string.server_base_url));
|
final Uri serverUri = Uri.parse(getString(R.string.server_base_url));
|
||||||
@ -108,7 +104,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
File upFile = new File(upFolder, sampleFileName);
|
File upFile = new File(upFolder, sampleFileName);
|
||||||
FileOutputStream fos = new FileOutputStream(upFile);
|
FileOutputStream fos = new FileOutputStream(upFile);
|
||||||
InputStream is = assets.open(sampleFileName);
|
InputStream is = assets.open(sampleFileName);
|
||||||
int count = 0;
|
int count;
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
while ((count = is.read(buffer, 0, buffer.length)) >= 0) {
|
while ((count = is.read(buffer, 0, buffer.length)) >= 0) {
|
||||||
fos.write(buffer, 0, count);
|
fos.write(buffer, 0, count);
|
||||||
@ -117,7 +113,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
fos.close();
|
fos.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Toast.makeText(this, R.string.error_copying_sample_file, Toast.LENGTH_SHORT).show();
|
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);
|
Timber.e(e, getString(R.string.error_copying_sample_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
mFrame = findViewById(R.id.frame);
|
mFrame = findViewById(R.id.frame);
|
||||||
@ -166,8 +162,8 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
String mimeType = getString(R.string.sample_file_mimetype);
|
String mimeType = getString(R.string.sample_file_mimetype);
|
||||||
|
|
||||||
// Get the last modification date of the file from the file system
|
// Get the last modification date of the file from the file system
|
||||||
Long timeStampLong = fileToUpload.lastModified() / 1000;
|
long timeStampLong = fileToUpload.lastModified() / 1000;
|
||||||
String timeStamp = timeStampLong.toString();
|
String timeStamp = Long.toString(timeStampLong);
|
||||||
|
|
||||||
UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(),
|
UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(),
|
||||||
remotePath, mimeType, timeStamp);
|
remotePath, mimeType, timeStamp);
|
||||||
@ -212,16 +208,16 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
|
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
|
||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess()) {
|
||||||
Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show();
|
||||||
Log.e(LOG_TAG, result.getLogMessage(), result.getException());
|
Timber.e(result.getException(), result.getLogMessage());
|
||||||
|
|
||||||
} else if (operation instanceof ReadRemoteFolderOperation) {
|
} else if (operation instanceof ReadRemoteFolderOperation) {
|
||||||
onSuccessfulRefresh((ReadRemoteFolderOperation) operation, result);
|
onSuccessfulRefresh(result);
|
||||||
|
|
||||||
} else if (operation instanceof com.owncloud.android.lib.resources.files.UploadRemoteFileOperation) {
|
} else if (operation instanceof com.owncloud.android.lib.resources.files.UploadRemoteFileOperation) {
|
||||||
onSuccessfulUpload((com.owncloud.android.lib.resources.files.UploadRemoteFileOperation) operation, result);
|
onSuccessfulUpload();
|
||||||
|
|
||||||
} else if (operation instanceof RemoveRemoteFileOperation) {
|
} else if (operation instanceof RemoveRemoteFileOperation) {
|
||||||
onSuccessfulRemoteDeletion((RemoveRemoteFileOperation) operation, result);
|
onSuccessfulRemoteDeletion();
|
||||||
|
|
||||||
} else if (operation instanceof DownloadRemoteFileOperation) {
|
} else if (operation instanceof DownloadRemoteFileOperation) {
|
||||||
onSuccessfulDownload();
|
onSuccessfulDownload();
|
||||||
@ -231,29 +227,26 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSuccessfulRefresh(ReadRemoteFolderOperation operation, RemoteOperationResult result) {
|
private void onSuccessfulRefresh(RemoteOperationResult result) {
|
||||||
mFilesAdapter.clear();
|
mFilesAdapter.clear();
|
||||||
List<RemoteFile> files = new ArrayList<>();
|
List<RemoteFile> files = new ArrayList<>();
|
||||||
for (RemoteFile remoteFile : (List<RemoteFile>) result.getData()) {
|
for (RemoteFile remoteFile : (List<RemoteFile>) result.getData()) {
|
||||||
files.add(remoteFile);
|
files.add(remoteFile);
|
||||||
}
|
}
|
||||||
if (files != null) {
|
for (RemoteFile file : files) {
|
||||||
Iterator<RemoteFile> it = files.iterator();
|
mFilesAdapter.add(file);
|
||||||
while (it.hasNext()) {
|
|
||||||
mFilesAdapter.add(it.next());
|
|
||||||
}
|
|
||||||
mFilesAdapter.remove(mFilesAdapter.getItem(0));
|
|
||||||
}
|
}
|
||||||
|
mFilesAdapter.remove(mFilesAdapter.getItem(0));
|
||||||
mFilesAdapter.notifyDataSetChanged();
|
mFilesAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSuccessfulUpload(com.owncloud.android.lib.resources.files.UploadRemoteFileOperation operation, RemoteOperationResult result) {
|
private void onSuccessfulUpload() {
|
||||||
startRefresh();
|
startRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSuccessfulRemoteDeletion(RemoveRemoteFileOperation operation, RemoteOperationResult result) {
|
private void onSuccessfulRemoteDeletion() {
|
||||||
startRefresh();
|
startRefresh();
|
||||||
TextView progressView = (TextView) findViewById(R.id.upload_progress);
|
TextView progressView = findViewById(R.id.upload_progress);
|
||||||
if (progressView != null) {
|
if (progressView != null) {
|
||||||
progressView.setText("0%");
|
progressView.setText("0%");
|
||||||
}
|
}
|
||||||
@ -266,23 +259,21 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
mFrame.setBackgroundDrawable(bDraw);
|
mFrame.setBackgroundDrawable(bDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String fileName) {
|
public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String fileName) {
|
||||||
final long percentage = (totalToTransfer > 0 ? totalTransferredSoFar * 100 / totalToTransfer : 0);
|
final long percentage = (totalToTransfer > 0 ? totalTransferredSoFar * 100 / totalToTransfer : 0);
|
||||||
final boolean upload = fileName.contains(getString(R.string.upload_folder_path));
|
final boolean upload = fileName.contains(getString(R.string.upload_folder_path));
|
||||||
Log.d(LOG_TAG, "progressRate " + percentage);
|
Timber.d("progressRate %s", percentage);
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(() -> {
|
||||||
@Override
|
TextView progressView;
|
||||||
public void run() {
|
if (upload) {
|
||||||
TextView progressView = null;
|
progressView = findViewById(R.id.upload_progress);
|
||||||
if (upload) {
|
} else {
|
||||||
progressView = findViewById(R.id.upload_progress);
|
progressView = findViewById(R.id.download_progress);
|
||||||
} else {
|
}
|
||||||
progressView = findViewById(R.id.download_progress);
|
if (progressView != null) {
|
||||||
}
|
progressView.setText(percentage + "%");
|
||||||
if (progressView != null) {
|
|
||||||
progressView.setText(Long.toString(percentage) + "%");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -301,7 +292,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
|||||||
version = pInfo.versionName;
|
version = pInfo.versionName;
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
Log_OC.e(TAG, "Trying to get packageName", e.getCause());
|
Timber.e(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mozilla/5.0 (Android) ownCloud-android/1.7.0
|
// Mozilla/5.0 (Android) ownCloud-android/1.7.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user