From 9a1d9b7e61b5999f2a9808f700f261651d2a587a Mon Sep 17 00:00:00 2001 From: Julian Raufelder Date: Fri, 23 Apr 2021 18:18:08 +0200 Subject: [PATCH 1/4] Bump version to 1.6.0-SNAPSHOT [ci skip] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index cdb486f93..93627bf26 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ allprojects { ext { androidApplicationId = 'org.cryptomator' androidVersionCode = getVersionCode() - androidVersionName = '1.5.16' + androidVersionName = '1.6.0-SNAPSHOT' } repositories { mavenCentral() From 4f8f8178085754e8d143a080643c970e541cb797 Mon Sep 17 00:00:00 2001 From: Julian Raufelder Date: Sat, 24 Apr 2021 23:37:07 +0200 Subject: [PATCH 2/4] #307 fix pCloud login in F-Droid --- .../CloudContentRepositoryFactories.java | 3 + .../presenter/AuthenticateCloudPresenter.kt | 135 +++++++++++++++++- 2 files changed, 132 insertions(+), 6 deletions(-) diff --git a/data/src/foss/java/org/cryptomator/data/cloud/CloudContentRepositoryFactories.java b/data/src/foss/java/org/cryptomator/data/cloud/CloudContentRepositoryFactories.java index 277858d24..f2bb16fa7 100644 --- a/data/src/foss/java/org/cryptomator/data/cloud/CloudContentRepositoryFactories.java +++ b/data/src/foss/java/org/cryptomator/data/cloud/CloudContentRepositoryFactories.java @@ -4,6 +4,7 @@ import org.cryptomator.data.cloud.dropbox.DropboxCloudContentRepositoryFactory; import org.cryptomator.data.cloud.local.LocalStorageContentRepositoryFactory; import org.cryptomator.data.cloud.onedrive.OnedriveCloudContentRepositoryFactory; +import org.cryptomator.data.cloud.pcloud.PCloudContentRepositoryFactory; import org.cryptomator.data.cloud.webdav.WebDavCloudContentRepositoryFactory; import org.cryptomator.data.repository.CloudContentRepositoryFactory; import org.jetbrains.annotations.NotNull; @@ -23,12 +24,14 @@ public class CloudContentRepositoryFactories implements Iterable(exceptionHandlers) { @@ -44,6 +70,7 @@ class AuthenticateCloudPresenter @Inject constructor( // private val strategies = arrayOf( // DropboxAuthStrategy(), // OnedriveAuthStrategy(), // + PCloudAuthStrategy(), // WebDAVAuthStrategy(), // LocalStorageAuthStrategy() // ) @@ -221,6 +248,102 @@ class AuthenticateCloudPresenter @Inject constructor( // } } + private inner class PCloudAuthStrategy : AuthStrategy { + + private var authenticationStarted = false + + override fun supports(cloud: CloudModel): Boolean { + return cloud.cloudType() == CloudTypeModel.PCLOUD + } + + override fun resumed(intent: AuthenticateCloudIntent) { + when { + ExceptionUtil.contains(intent.error(), WrongCredentialsException::class.java) -> { + if (!authenticationStarted) { + startAuthentication() + Toast.makeText( + context(), + String.format(getString(R.string.error_authentication_failed_re_authenticate), intent.cloud().username()), + Toast.LENGTH_LONG).show() + } + } + else -> { + Timber.tag("AuthicateCloudPrester").e(intent.error()) + failAuthentication(intent.cloud().name()) + } + } + } + + private fun startAuthentication() { + authenticationStarted = true + val authIntent: Intent = AuthorizationActivity.createIntent( + context(), + AuthorizationRequest.create() + .setType(AuthorizationRequest.Type.TOKEN) + .setClientId(BuildConfig.PCLOUD_CLIENT_ID) + .setForceAccessApproval(true) + .addPermission("manageshares") + .build()) + requestActivityResult(ActivityResultCallbacks.pCloudReAuthenticationFinished(), // + authIntent) + } + } + + @Callback + fun pCloudReAuthenticationFinished(activityResult: ActivityResult) { + val authData: AuthorizationData = AuthorizationActivity.getResult(activityResult.intent()) + val result: AuthorizationResult = authData.result + + when (result) { + AuthorizationResult.ACCESS_GRANTED -> { + val accessToken: String = CredentialCryptor // + .getInstance(context()) // + .encrypt(authData.token) + val pCloudSkeleton: PCloud = PCloud.aPCloud() // + .withAccessToken(accessToken) + .withUrl(authData.apiHost) + .build(); + getUsernameUseCase // + .withCloud(pCloudSkeleton) // + .run(object : DefaultResultHandler() { + override fun onSuccess(username: String?) { + prepareForSavingPCloud(PCloud.aCopyOf(pCloudSkeleton).withUsername(username).build()) + } + }) + } + AuthorizationResult.ACCESS_DENIED -> { + Timber.tag("CloudConnListPresenter").e("Account access denied") + view?.showMessage(String.format(getString(R.string.screen_authenticate_auth_authentication_failed), getString(R.string.cloud_names_pcloud))) + } + AuthorizationResult.AUTH_ERROR -> { + Timber.tag("CloudConnListPresenter").e("""Account access grant error: ${authData.errorMessage}""".trimIndent()) + view?.showMessage(String.format(getString(R.string.screen_authenticate_auth_authentication_failed), getString(R.string.cloud_names_pcloud))) + } + AuthorizationResult.CANCELLED -> { + Timber.tag("CloudConnListPresenter").i("Account access grant cancelled") + view?.showMessage(String.format(getString(R.string.screen_authenticate_auth_authentication_failed), getString(R.string.cloud_names_pcloud))) + } + } + } + + fun prepareForSavingPCloud(cloud: PCloud) { + getCloudsUseCase // + .withCloudType(cloud.type()) // + .run(object : DefaultResultHandler>() { + override fun onSuccess(clouds: List) { + clouds.firstOrNull { + (it as PCloud).username() == cloud.username() + }?.let { + it as PCloud + succeedAuthenticationWith(PCloud.aCopyOf(it) // + .withUrl(cloud.url()) + .withAccessToken(cloud.accessToken()) + .build()) + } ?: succeedAuthenticationWith(cloud) + } + }) + } + private inner class WebDAVAuthStrategy : AuthStrategy { override fun supports(cloud: CloudModel): Boolean { @@ -342,6 +465,6 @@ class AuthenticateCloudPresenter @Inject constructor( // } init { - unsubscribeOnDestroy(addOrChangeCloudConnectionUseCase, getUsernameUseCase) + unsubscribeOnDestroy(addOrChangeCloudConnectionUseCase, getCloudsUseCase, getUsernameUseCase) } } From 67af7af5e2076614bf119d5a6a270dfa2f207c95 Mon Sep 17 00:00:00 2001 From: Julian Raufelder Date: Sat, 24 Apr 2021 23:44:02 +0200 Subject: [PATCH 3/4] Update release notes [ci skip] --- fastlane/metadata/android/de-DE/changelogs/default.txt | 3 +-- fastlane/metadata/android/en-US/changelogs/default.txt | 3 +-- fastlane/release-notes.html | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fastlane/metadata/android/de-DE/changelogs/default.txt b/fastlane/metadata/android/de-DE/changelogs/default.txt index 4fc6bd799..e15151b61 100644 --- a/fastlane/metadata/android/de-DE/changelogs/default.txt +++ b/fastlane/metadata/android/de-DE/changelogs/default.txt @@ -1,2 +1 @@ -- Fehler beim Erstellen neuer Tresore in pCloud behoben -- Fehler in der Lizenz-Anzeige der Einstellungen behoben \ No newline at end of file +- Problem bei der pCloud-Anmeldung in der F-Droid-Variante behoben \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/default.txt b/fastlane/metadata/android/en-US/changelogs/default.txt index e0479683e..8dfdac01a 100644 --- a/fastlane/metadata/android/en-US/changelogs/default.txt +++ b/fastlane/metadata/android/en-US/changelogs/default.txt @@ -1,2 +1 @@ -- Fixed creating new vaults in pCloud -- Fixed license screen in settings \ No newline at end of file +- Fixed pCloud login using F-Droid \ No newline at end of file diff --git a/fastlane/release-notes.html b/fastlane/release-notes.html index 8ff274812..faa77e7b0 100644 --- a/fastlane/release-notes.html +++ b/fastlane/release-notes.html @@ -1,4 +1,3 @@
    -
  • Fixed creating new vaults in pCloud
  • -
  • Fixed license screen in settings
  • +
  • Fixed pCloud login using F-Droid
\ No newline at end of file From 5c8b006c3a72d8ff3c17b957017b81cf4f9f0ad6 Mon Sep 17 00:00:00 2001 From: Julian Raufelder Date: Sat, 24 Apr 2021 23:46:27 +0200 Subject: [PATCH 4/4] Bump version to 1.5.17 [ci skip] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 93627bf26..55e719ae6 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ allprojects { ext { androidApplicationId = 'org.cryptomator' androidVersionCode = getVersionCode() - androidVersionName = '1.6.0-SNAPSHOT' + androidVersionName = '1.5.17' } repositories { mavenCentral()