diff --git a/.gitignore b/.gitignore index 491cdfc4..172bedd2 100644 --- a/.gitignore +++ b/.gitignore @@ -19,11 +19,6 @@ gen/ # Local configuration files (sdk path, etc) .gradle/ local.properties -sample_client/local.properties # Mac .DS_Store files .DS_Store - -# Proguard README -proguard-project.txt -sample_client/proguard-project.txt \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8461dad5..27226ce5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { // Libraries - kotlinVersion = '1.3.50' + kotlinVersion = '1.3.61' } repositories { @@ -9,7 +9,7 @@ buildscript { jcenter() } 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-allopen:$kotlinVersion" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ce011295..ea147fbb 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-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java index 649fb630..309344fa 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java @@ -64,7 +64,7 @@ public class AccountUtils { webDavUrlForAccount = getBaseUrlForAccount(context, account) + OwnCloudClient.WEBDAV_FILES_PATH_4_0 + ownCloudCredentials.getUsername(); } catch (OperationCanceledException | AuthenticatorException | IOException e) { - e.printStackTrace(); + Timber.e(e); } return webDavUrlForAccount; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java index ab1ba3ef..29c5ee54 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java @@ -31,8 +31,6 @@ import okhttp3.internal.Util; public class OwnCloudBasicCredentials implements OwnCloudCredentials { - private static final String TAG = OwnCloudCredentials.class.getSimpleName(); - private String mUsername; private String mPassword; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java index 152ffdbe..6ef50447 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java @@ -33,8 +33,6 @@ import java.util.Map; public class OAuth2QueryParser { - private static final String TAG = OAuth2QueryParser.class.getName(); - private Map mOAuth2ParsedAuthorizationResponse; public OAuth2QueryParser() { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java index f2513c3c..d76ecbca 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java @@ -43,11 +43,8 @@ import java.security.cert.X509Certificate; */ public class AdvancedX509TrustManager implements X509TrustManager { - private static final String TAG = AdvancedX509TrustManager.class.getSimpleName(); - private X509TrustManager mStandardTrustManager; private KeyStore mKnownServersKeyStore; - /** * Constructor for AdvancedX509TrustManager * diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java index 520d9a37..c7456ca5 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java @@ -24,13 +24,12 @@ package com.owncloud.android.lib.common.network; -import android.util.Log; - import okhttp3.MediaType; import okhttp3.RequestBody; import okio.BufferedSink; import okio.Okio; import okio.Source; +import timber.log.Timber; import java.io.File; import java.util.Collection; @@ -45,8 +44,6 @@ import java.util.Set; */ public class FileRequestBody extends RequestBody implements ProgressiveDataTransferer { - private static final String TAG = FileRequestBody.class.getSimpleName(); - protected File mFile; private MediaType mContentType; final Set 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() + - " written in request body"); + Timber.d("File with name " + mFile.getName() + " and size " + mFile.length() + " written in request body"); } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java index f41c8220..258f44bc 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java @@ -24,8 +24,6 @@ package com.owncloud.android.lib.resources.files; -import android.util.Log; - import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.http.HttpConstants; 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.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; +import timber.log.Timber; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -49,8 +48,6 @@ import java.util.concurrent.TimeUnit; */ public class CopyRemoteFileOperation extends RemoteOperation { - private static final String TAG = CopyRemoteFileOperation.class.getSimpleName(); - private static final int COPY_READ_TIMEOUT = 600000; private static final int COPY_CONNECTION_TIMEOUT = 5000; @@ -120,13 +117,11 @@ public class CopyRemoteFileOperation extends RemoteOperation { client.exhaustResponse(copyMethod.getResponseBodyAsStream()); } - Log.i(TAG, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage()); + Timber.i("Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log.e(TAG, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage(), e); + Timber.e(e, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java index d6275c1d..d131fe67 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java @@ -25,7 +25,6 @@ package com.owncloud.android.lib.resources.files; import android.net.Uri; -import android.util.Log; import com.owncloud.android.lib.common.OwnCloudClient; 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.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; +import timber.log.Timber; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -49,8 +49,6 @@ import java.util.concurrent.TimeUnit; */ 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_CONNECTION_TIMEOUT = 5000; @@ -132,13 +130,11 @@ public class MoveRemoteFileOperation extends RemoteOperation { client.exhaustResponse(move.getResponseBodyAsStream()); } - Log.i(TAG, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage()); + Timber.i("Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log.e(TAG, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage(), e); + Timber.e(e, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } return result; @@ -147,4 +143,4 @@ public class MoveRemoteFileOperation extends RemoteOperation { protected boolean isSuccess(int status) { return status == HttpConstants.HTTP_CREATED || status == HttpConstants.HTTP_NO_CONTENT; } -} \ No newline at end of file +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java index d18be319..9149e6d3 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java @@ -99,8 +99,7 @@ public class ReadRemoteFileOperation extends RemoteOperation { } catch (Exception e) { result = new RemoteOperationResult<>(e); - e.printStackTrace(); - Timber.e(result.getException(), "Synchronizing file " + mRemotePath + ": " + result.getLogMessage()); + Timber.e(e, "Synchronizing file %s", mRemotePath); } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt index c9ef0c12..105fb4d6 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt @@ -383,8 +383,6 @@ class ShareXMLParser { companion object { - //private static final String TAG = ShareXMLParser.class.getSimpleName(); - // No namespaces private val ns: String? = null diff --git a/pom.xml b/pom.xml deleted file mode 100644 index a72688d2..00000000 --- a/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - 4.0.0 - com.owncloud.android - owncloud-android-library - ${owncloud.version} - jar - owncloud-android-library for Owncloud Android - - - 1.5.1-SNAPSHOT - 1.6 - - 4.4.2_r4 - - 19 - - - owncloud-android-library for Owncloud for Android - - - - - android - android - ${google.android-version} - provided - - - - - - ${project.artifactId} - - src - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - ${java-version} - ${java-version} - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - 3.8.0 - - - ${env.ANDROID_HOME} - ${google.android-api} - - - true - - - - - - - - diff --git a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java index 953699ab..eeec3947 100644 --- a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java +++ b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java @@ -33,7 +33,6 @@ 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; @@ -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.RemoteOperation; 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.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 info.hannes.timber.DebugTree; +import timber.log.Timber; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; -import static android.content.ContentValues.TAG; - public class MainActivity extends Activity implements OnRemoteOperationListener, OnDatatransferProgressListener { - private static String LOG_TAG = MainActivity.class.getCanonicalName(); - private Handler mHandler; private OwnCloudClient mClient; private FilesArrayAdapter mFilesAdapter; @@ -82,6 +77,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, super.onCreate(savedInstanceState); setContentView(R.layout.main); + Timber.plant(new DebugTree()); mHandler = new Handler(); 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); FileOutputStream fos = new FileOutputStream(upFile); InputStream is = assets.open(sampleFileName); - int count = 0; + int count; byte[] buffer = new byte[1024]; while ((count = is.read(buffer, 0, buffer.length)) >= 0) { fos.write(buffer, 0, count); @@ -117,7 +113,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, fos.close(); } catch (IOException e) { 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); @@ -166,8 +162,8 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, String mimeType = getString(R.string.sample_file_mimetype); // Get the last modification date of the file from the file system - Long timeStampLong = fileToUpload.lastModified() / 1000; - String timeStamp = timeStampLong.toString(); + long timeStampLong = fileToUpload.lastModified() / 1000; + String timeStamp = Long.toString(timeStampLong); UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType, timeStamp); @@ -212,16 +208,16 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { if (!result.isSuccess()) { 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) { - onSuccessfulRefresh((ReadRemoteFolderOperation) operation, result); + onSuccessfulRefresh(result); } 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) { - onSuccessfulRemoteDeletion((RemoveRemoteFileOperation) operation, result); + onSuccessfulRemoteDeletion(); } else if (operation instanceof DownloadRemoteFileOperation) { 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(); List files = new ArrayList<>(); for (RemoteFile remoteFile : (List) result.getData()) { files.add(remoteFile); } - if (files != null) { - Iterator it = files.iterator(); - while (it.hasNext()) { - mFilesAdapter.add(it.next()); - } - mFilesAdapter.remove(mFilesAdapter.getItem(0)); + for (RemoteFile file : files) { + mFilesAdapter.add(file); } + mFilesAdapter.remove(mFilesAdapter.getItem(0)); mFilesAdapter.notifyDataSetChanged(); } - private void onSuccessfulUpload(com.owncloud.android.lib.resources.files.UploadRemoteFileOperation operation, RemoteOperationResult result) { + private void onSuccessfulUpload() { startRefresh(); } - private void onSuccessfulRemoteDeletion(RemoveRemoteFileOperation operation, RemoteOperationResult result) { + private void onSuccessfulRemoteDeletion() { startRefresh(); - TextView progressView = (TextView) findViewById(R.id.upload_progress); + TextView progressView = findViewById(R.id.upload_progress); if (progressView != null) { progressView.setText("0%"); } @@ -266,23 +259,21 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, mFrame.setBackgroundDrawable(bDraw); } + @SuppressLint("SetTextI18n") @Override public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String fileName) { final long percentage = (totalToTransfer > 0 ? totalTransferredSoFar * 100 / totalToTransfer : 0); final boolean upload = fileName.contains(getString(R.string.upload_folder_path)); - Log.d(LOG_TAG, "progressRate " + percentage); - mHandler.post(new Runnable() { - @Override - public void run() { - TextView progressView = null; - if (upload) { - progressView = findViewById(R.id.upload_progress); - } else { - progressView = findViewById(R.id.download_progress); - } - if (progressView != null) { - progressView.setText(Long.toString(percentage) + "%"); - } + Timber.d("progressRate %s", percentage); + mHandler.post(() -> { + TextView progressView; + if (upload) { + progressView = findViewById(R.id.upload_progress); + } else { + progressView = findViewById(R.id.download_progress); + } + if (progressView != null) { + progressView.setText(percentage + "%"); } }); } @@ -301,7 +292,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, version = pInfo.versionName; } } 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