Skip to content

Commit

Permalink
Merge branch 'hotfix/1.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Oct 25, 2021
2 parents f6cc2c7 + 337afee commit 65e0a9f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 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.1'
androidVersionName = '1.6.2'
}
repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion fastlane/metadata/android/de-DE/changelogs/default.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Kompatibilität zu Tresor-Format 8 verbessert
- Fixed add pCloud connection on some devices
2 changes: 1 addition & 1 deletion fastlane/metadata/android/en-US/changelogs/default.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Enhanced compatibility to vault format 8
- pCloud-Verbindung können wieder auf allen Geräten hinzugefügt werden
2 changes: 1 addition & 1 deletion fastlane/release-notes.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ul>
<li>Enhanced compatibility to vault format 8</li>
<li>Fixed add pCloud connection on some devices</li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.cryptomator.presentation.ui.activity

import android.content.Intent
import android.net.Uri
import android.os.Handler
import android.widget.Toast
import org.cryptomator.generator.Activity
import org.cryptomator.presentation.BuildConfig
Expand All @@ -13,6 +14,12 @@ import timber.log.Timber
@Activity
class AuthenticatePCloudActivity : BaseActivity() {

private val startAuthenticationRequestCode = 1232
private val redirectTimeoutAfterAuthenticationAndResumed = 1000L

private var cancelAuthenticationHandler: Handler = Handler()
private var oAuthResultReceived = false

override fun setupView() {
val uri = Uri.parse("https://my.pcloud.com/oauth2/authorize")
.buildUpon()
Expand All @@ -21,18 +28,27 @@ class AuthenticatePCloudActivity : BaseActivity() {
.appendQueryParameter("redirect_uri", "pcloudoauth://redirect")
.build()

startActivityForResult(Intent(Intent.ACTION_VIEW, uri), 25)
startActivityForResult(Intent(Intent.ACTION_VIEW, uri), startAuthenticationRequestCode)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
super.onActivityResult(requestCode, resultCode, intent)
finish()
if (requestCode == startAuthenticationRequestCode) {
cancelAuthenticationHandler.postDelayed({
if (!oAuthResultReceived) {
Timber.tag("AuthenticatePCloudActivity").i("Authentication canceled or no redirect received after resuming Cryptomator since 1.5s")
Toast.makeText(context(), R.string.error_authentication_failed, Toast.LENGTH_SHORT).show()
finish()
}
}, redirectTimeoutAfterAuthenticationAndResumed)
}
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
intent.data?.let {
if(it.host == "redirect" && it.scheme == "pcloudoauth") {
if (it.host == "redirect" && it.scheme == "pcloudoauth") {
oAuthResultReceived = true
val parameters = parseUrlFragmentParameters(it)
val accessToken = parameters["access_token"]
val hostname = parameters["hostname"]
Expand All @@ -41,10 +57,11 @@ class AuthenticatePCloudActivity : BaseActivity() {
result.putExtra(CloudConnectionListPresenter.PCLOUD_OAUTH_AUTH_CODE, accessToken)
result.putExtra(CloudConnectionListPresenter.PCLOUD_HOSTNAME, hostname)
setResult(android.app.Activity.RESULT_OK, result)
finish()
} else {
Toast.makeText(this, R.string.error_authentication_failed, Toast.LENGTH_LONG).show()
Timber.tag("AuthenticatePCloudActivity").i("Authentication failed as the access token or hostname is null")
}
finish()
} else {
Timber.tag("AuthenticatePCloudActivity").e("Tried to call activity using a different redirect scheme")
}
Expand All @@ -63,4 +80,9 @@ class AuthenticatePCloudActivity : BaseActivity() {
}
return emptyMap()
}

override fun onDestroy() {
super.onDestroy()
cancelAuthenticationHandler.removeCallbacksAndMessages(null)
}
}

0 comments on commit 65e0a9f

Please sign in to comment.