diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 89aa93c4..bce60cfa 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -283,7 +283,6 @@ dependencies { implementation("androidx.palette:palette-ktx:1.0.0") implementation("org.skyscreamer:jsonassert:1.2.3") - implementation("androidx.browser:browser:1.4.0") implementation("com.google.api-client:google-api-client:2.0.0") { exclude( group = "org.apache.httpcomponents", diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/GoogleDriveApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/GoogleDriveApi.kt index 2ca37ed2..1f8f983e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/GoogleDriveApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/GoogleDriveApi.kt @@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.syncproviders.providers import android.content.Context import android.net.Uri import android.util.Log -import androidx.browser.customtabs.CustomTabsIntent import androidx.fragment.app.FragmentActivity import com.google.api.client.auth.oauth2.AuthorizationCodeFlow import com.google.api.client.auth.oauth2.Credential @@ -19,6 +18,7 @@ import com.google.api.services.drive.DriveScopes import com.google.api.services.drive.model.File import com.lagradost.cloudstream3.AcraApplication import com.lagradost.cloudstream3.AcraApplication.Companion.getKey +import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey import com.lagradost.cloudstream3.AcraApplication.Companion.setKey import com.lagradost.cloudstream3.CommonActivity @@ -133,6 +133,7 @@ class GoogleDriveApi(index: Int) : data.clientId ) + registerAccount() storeValue(K.TOKEN, googleTokenResponse) storeValue(K.IS_READY, true) @@ -202,7 +203,8 @@ class GoogleDriveApi(index: Int) : data: InAppOAuth2API.LoginData ) { val credential = loginInfo() - if (credential != null) { + // Repeated attempts will not switch account because IS_READY is false + if (credential != null && getValue(K.IS_READY) != false) { switchToNewAccount() } @@ -213,13 +215,9 @@ class GoogleDriveApi(index: Int) : this.tempAuthFlow = authFlow try { - registerAccount() - val url = authFlow.newAuthorizationUrl().setRedirectUri(data.redirectUrl).build() - val customTabIntent = CustomTabsIntent.Builder().setShowTitle(true).build() - customTabIntent.launchUrl(activity, Uri.parse(url)) - } catch (e: Exception) { - switchToOldAccount() + openBrowser(url) + } catch (e: Throwable) { CommonActivity.showToast( activity, activity.getString(R.string.authenticated_user_fail).format(name) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/InAppOAuth2DialogBuilder.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/InAppOAuth2DialogBuilder.kt index 9abe0eb9..85ae3db1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/InAppOAuth2DialogBuilder.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/InAppOAuth2DialogBuilder.kt @@ -1,12 +1,11 @@ package com.lagradost.cloudstream3.ui.settings.helpers.settings.account -import android.net.Uri import android.view.View import androidx.appcompat.app.AlertDialog -import androidx.browser.customtabs.CustomTabsIntent import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.fragment.app.FragmentActivity +import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.databinding.AddAccountInputOauthBinding import com.lagradost.cloudstream3.syncproviders.InAppOAuth2API @@ -40,8 +39,7 @@ class InAppOAuth2DialogBuilder( infoButton.isGone = api.infoUrl.isNullOrBlank() infoButton.setOnClickListener { - val customTabIntent = CustomTabsIntent.Builder().setShowTitle(true).build() - customTabIntent.launchUrl(binding.root.context, Uri.parse(api.infoUrl)) + api.infoUrl?.let { url -> openBrowser(url) } } }