Skip to content

Commit

Permalink
Merge branch 'release/1.6.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Dec 7, 2021
2 parents a516cd8 + d18ee57 commit cf5c7b9
Show file tree
Hide file tree
Showing 27 changed files with 134 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ allprojects {
ext {
androidApplicationId = 'org.cryptomator'
androidVersionCode = getVersionCode()
androidVersionName = '1.6.7'
androidVersionName = '1.6.8'
}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@ class DropboxClientFactory {
return HttpLoggingInterceptor(logger, context)
}

fun logout() {
instance = null
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ internal class DropboxCloudContentRepository(private val cloud: DropboxCloud, co

@Throws(BackendException::class)
override fun logout(cloud: DropboxCloud) {
// empty
this.cloud.logout()
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ internal class DropboxImpl(cloud: DropboxCloud, context: Context) {
return currentAccount.name.displayName
}

fun logout() {
DropboxClientFactory.logout()
}

companion object {

private const val CHUNKED_UPLOAD_CHUNK_SIZE = 8L shl 20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,10 @@ class OnedriveClientFactory private constructor() {

return HttpLoggingInterceptor(logger, context)
}

@Synchronized
fun logout() {
instance = null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ internal class OnedriveImpl(cloud: OnedriveCloud, context: Context, nodeInfoCach
} catch (e: ExecutionException) {
throw FatalBackendException(e)
}

OnedriveClientFactory.logout()
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,10 @@ class PCloudClientFactory {

return HttpLoggingInterceptor(logger, context)
}

@Synchronized
fun logout() {
instance = null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ internal class PCloudContentRepository(private val cloud: PCloud, context: Conte

@Throws(BackendException::class)
override fun logout(cloud: PCloud) {
// empty
this.cloud.logout()
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ internal class PCloudImpl(context: Context, cloud: PCloud) {
}
}

fun logout() {
PCloudClientFactory.logout()
}

init {
if (cloud.accessToken() == null) {
throw NoAuthenticationProvidedException(cloud)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,10 @@ class S3ClientFactory private constructor() {
val activeNetworkInfo = connectivityManager.activeNetworkInfo
return activeNetworkInfo != null && activeNetworkInfo.isConnected
}

@Synchronized
fun logout() {
instance = null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ internal class S3CloudContentRepository(private val cloud: S3Cloud, context: Con

@Throws(BackendException::class)
override fun logout(cloud: S3Cloud) {
// empty
this.cloud.logout()
}

}
Expand Down
4 changes: 4 additions & 0 deletions data/src/main/java/org/cryptomator/data/cloud/s3/S3Impl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ internal class S3Impl(context: Context, cloud: S3Cloud) {
}
}

fun logout() {
S3ClientFactory.logout()
}

companion object {

private const val DELIMITER = "/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ internal class WebDavCompatibleHttpClient(cloud: WebDavCloud, context: Context)
val credentials = Credentials(webDavCloud.username(), decryptPassword(context, webDavCloud.password()))
val basicAuthenticator = BasicAuthenticator(credentials, StandardCharsets.UTF_8)
val digestAuthenticator = DigestAuthenticator(credentials)
var result: Authenticator = DispatchingAuthenticator.Builder() //
val authenticator = DispatchingAuthenticator.Builder() //
.with("digest", digestAuthenticator) //
.with("basic", basicAuthenticator) //
.build()
result = CachingAuthenticatorDecorator(result, authCache)
return result
return CachingAuthenticatorDecorator(authenticator, authCache)
}

@Throws(UnableToDecryptWebdavPasswordException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,9 @@ class GoogleDriveClientFactory internal constructor() {
}
.build()
}

fun invalidateClient() {
instance = null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ internal class GoogleDriveCloudContentRepository(context: Context, private val c

@Throws(BackendException::class)
override fun logout(cloud: GoogleDriveCloud) {
// empty
impl.logout()
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ internal class GoogleDriveImpl(context: Context, googleDriveCloud: GoogleDriveCl
return about.user.displayName
}

fun logout() {
GoogleDriveClientFactory.invalidateClient()
}

companion object {

private const val STATUS_REQUEST_RANGE_NOT_SATISFIABLE = 416
Expand Down
3 changes: 2 additions & 1 deletion fastlane/metadata/android/de-DE/changelogs/default.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Automatischer Upload bei Geräten mit Android Version 10 behoben
- Zeige Dialog und Benachrichtigung an, wenn die Berechtigung "Dateien" widerrufen wird, erforderlich für den automatischen Upload
- Das Abmelden von einer Cloud löscht nun auch die Anmeldeinformationen einer aktiven Verbindung zu ihr
3 changes: 2 additions & 1 deletion fastlane/metadata/android/en-US/changelogs/default.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fixed auto upload via devices running Android version 10
- Show information when "Storage" permission revoked, required for auto upload
- Logging out of a cloud now also clears the credentials of an active connection to it
3 changes: 2 additions & 1 deletion fastlane/release-notes.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<ul>
<li>Fixed auto upload via devices running Android version 10</li>
<li>Show information when "Storage" permission revoked, required for auto upload</li>
<li>Logging out of a cloud now also clears the credentials of an active connection to it</li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class UnlockVaultPresenter @Inject constructor(
view?.closeDialog()
val error = result.getSingleResult(Throwable::class.java)
error?.let { showError(it) }
finishWithResult(null)
}
}

Expand Down Expand Up @@ -219,6 +220,7 @@ class UnlockVaultPresenter @Inject constructor(
view?.closeDialog()
val error = result.getSingleResult(Throwable::class.java)
error?.let { showError(it) }
finishWithResult(null)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cryptomator.presentation.presenter

import android.Manifest
import android.app.KeyguardManager
import android.app.admin.DevicePolicyManager
import android.content.ActivityNotFoundException
Expand Down Expand Up @@ -56,6 +57,7 @@ import org.cryptomator.presentation.workflow.ActivityResult
import org.cryptomator.presentation.workflow.AddExistingVaultWorkflow
import org.cryptomator.presentation.workflow.AuthenticationExceptionHandler
import org.cryptomator.presentation.workflow.CreateNewVaultWorkflow
import org.cryptomator.presentation.workflow.PermissionsResult
import org.cryptomator.presentation.workflow.Workflow
import org.cryptomator.util.SharedPreferencesHandler
import javax.inject.Inject
Expand Down Expand Up @@ -112,6 +114,10 @@ class VaultListPresenter @Inject constructor( //
}

checkLicense()

if(sharedPreferencesHandler.usePhotoUpload()) {
checkLocalStoragePermissionRegardingAutoUpload()
}
}

private fun checkLicense() {
Expand Down Expand Up @@ -185,6 +191,27 @@ class VaultListPresenter @Inject constructor( //
}
}

private fun checkLocalStoragePermissionRegardingAutoUpload() {
requestPermissions(
PermissionsResultCallbacks.onLocalStoragePermissionGrantedForAutoUpload(), //
R.string.permission_snackbar_auth_auto_upload, //
Manifest.permission.READ_EXTERNAL_STORAGE
)
}

@Callback
fun onLocalStoragePermissionGrantedForAutoUpload(result: PermissionsResult) {
if (!result.granted()) {
Timber.tag("VaultListPresenter").e("Local storage permission not granted, auto upload will not work")
}
}

fun loadVaultList() {
view?.hideVaultCreationHint()
vaultList
assertUnlockingVaultIsLocked()
}

private fun assertUnlockingVaultIsLocked() {
if (view?.isShowingDialog(EnterPasswordDialog::class) == true) {
if (view?.currentDialog() != null) {
Expand All @@ -196,12 +223,6 @@ class VaultListPresenter @Inject constructor( //
}
}

fun loadVaultList() {
view?.hideVaultCreationHint()
vaultList
assertUnlockingVaultIsLocked()
}

fun deleteVault(vaultModel: VaultModel) {
deleteVaultUseCase //
.withVault(vaultModel.toVault()) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,15 @@ class AutoUploadNotification(private val context: Context, private val amountOfP
}

private fun cancelNowAction(): NotificationCompat.Action {
val intentAction = cancelAutoUploadIntent(context)
val cancelIntent = PendingIntent.getService(context, 0, intentAction, FLAG_CANCEL_CURRENT)
return NotificationCompat.Action.Builder( //
R.drawable.ic_lock, //
getString(R.string.notification_cancel_auto_upload), //
cancelNowIntent() //
cancelIntent //
).build()
}

private fun cancelNowIntent(): PendingIntent {
val intentAction = cancelAutoUploadIntent(context)
return PendingIntent.getService(context, 0, intentAction, FLAG_CANCEL_CURRENT)
}

private fun startTheActivity(): PendingIntent {
val startTheActivity = Intent(context, VaultListActivity::class.java)
startTheActivity.action = ACTION_MAIN
Expand All @@ -67,8 +64,8 @@ class AutoUploadNotification(private val context: Context, private val amountOfP
}

fun update(progress: Int) {
builder.setContentIntent(startTheActivity())
builder //
.setContentIntent(startTheActivity())
.setContentText( //
String.format(
context.getString(R.string.notification_auto_upload_message), //
Expand Down Expand Up @@ -105,27 +102,32 @@ class AutoUploadNotification(private val context: Context, private val amountOfP
showErrorWithMessage(context.getString(R.string.notification_auto_upload_failed_due_to_vault_not_found))
}

fun showPermissionNotGrantedNotification() {
Timber.tag("AutoUploadNotification").i("Show storage permission required notification")
showErrorWithMessage(context.getString(R.string.notification_auto_upload_permission_not_granted))
}

private fun showErrorWithMessage(message: String) {
builder.setContentIntent(startTheActivity())
builder //
builder
.setContentIntent(startTheActivity())
.setContentTitle(context.getString(R.string.notification_auto_upload_failed_title))
.setContentText(message) //
.setProgress(0, 0, false)
.setAutoCancel(true)
.setOngoing(false)
.mActions.clear()
.clearActions()
show()
}

fun showUploadFinished(size: Int) {
builder.setContentIntent(startTheActivity())
builder //
builder
.setContentIntent(startTheActivity())
.setContentTitle(context.getString(R.string.notification_auto_upload_finished_title))
.setContentText(format(context.getString(R.string.notification_auto_upload_finished_message), size)) //
.setContentText(format(context.getString(R.string.notification_auto_upload_finished_message), size))
.setProgress(0, 0, false)
.setAutoCancel(true)
.setOngoing(false)
.mActions.clear()
.clearActions()
show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.system.ErrnoException;
import android.system.OsConstants;

import androidx.annotation.Nullable;

Expand Down Expand Up @@ -37,6 +39,7 @@
import org.cryptomator.util.SharedPreferencesHandler;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -111,6 +114,8 @@ private void startBackgroundImageUpload(Cloud cloud) {
notification.showVaultLockedDuringUpload();
} else if (e instanceof CancellationException) {
Timber.tag("AutoUploadService").i("Upload canceled by user");
} else if (wrappedStoragePermissionException(e)) {
notification.showPermissionNotGrantedNotification();
} else {
notification.showGeneralErrorDuringUpload();
}
Expand All @@ -122,6 +127,14 @@ private void startBackgroundImageUpload(Cloud cloud) {
worker.start();
}

private boolean wrappedStoragePermissionException(Exception e) {
return e.getCause() != null //
&& e.getCause() instanceof FileNotFoundException //
&& e.getCause().getCause() != null //
&& e.getCause().getCause() instanceof ErrnoException //
&& ((ErrnoException) e.getCause().getCause()).errno == OsConstants.EACCES;
}

private void updateNotification(int asPercentage) {
if (elapsedTimeAutoUploadNotificationDelay > 200 && !cancelled) {
new Handler(Looper.getMainLooper()).post(() -> {
Expand Down Expand Up @@ -170,8 +183,7 @@ private void upload(ProgressAware<UploadState> progressAware) throws BackendExce
} catch (FileRemovedDuringUploadException e) {
Timber.tag("AutoUploadService").i("Not uploading file because it was removed during upload");
Timber.tag("AutoUploadService").v(format("Not uploading file because it was removed during upload %s", file.getFileName()));
}
catch (Exception e) {
} catch (Exception e) {
cancelled = true;
fileUtil.removeImagesFromAutoUploads(uploadedCloudFileNames);
throw e;
Expand Down Expand Up @@ -200,7 +212,7 @@ private CloudFile upload(UploadFile uploadFile, DataSource dataSource, ProgressA

private CloudFile writeCloudFile(String fileName, CancelAwareDataSource dataSource, boolean replacing, ProgressAware<UploadState> progressAware) throws BackendException {
Long size = dataSource.size(context);
if(size == null) {
if (size == null) {
throw new FileRemovedDuringUploadException();
}
CloudFile source = cloudContentRepository.file(parent, fileName, size);
Expand Down
Loading

0 comments on commit cf5c7b9

Please sign in to comment.