diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/InAppOAuth2API.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/InAppOAuth2API.kt index 2d986d99..3788e26a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/InAppOAuth2API.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/InAppOAuth2API.kt @@ -23,6 +23,7 @@ interface InAppOAuth2API : OAuth2API { val defaultFilenameValue: String val defaultRedirectUrl: String + val infoUrl: String? // should launch intent to acquire token 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 17801a25..1b6d52d4 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 @@ -72,6 +72,7 @@ class GoogleDriveApi(index: Int) : override val requiresClientId = true override val defaultFilenameValue = "cloudstreamapp-sync-file" override val defaultRedirectUrl = "https://chiff.github.io/cloudstream-sync/google-drive" + override val infoUrl = "https://chiff.github.io/cloudstream-sync/google-drive/help.html" override var isActive: Boolean? = false override var willQueueSoon: Boolean? = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/DialogBuilder.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/DialogBuilder.kt index 741e2817..c493a104 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/DialogBuilder.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/helpers/settings/account/DialogBuilder.kt @@ -23,13 +23,13 @@ abstract class DialogBuilder( private val btnApply: MaterialButton, private val btnCancel: MaterialButton, private val btnAccCreate: MaterialButton?, - private val btnConfirmOauth: MaterialButton? + private val btnInfo: MaterialButton? ) { fun getTitle() = dialog.getCommonItem(title)!! fun getBtnApply() = dialog.getCommonItem(btnApply)!! fun getBtnCancel() = dialog.getCommonItem(btnCancel)!! fun getBtnAccCreate() = dialog.getCommonItem(btnAccCreate) - fun getBtnConfirm() = dialog.getCommonItem(btnConfirmOauth) + fun getBtnInfo() = dialog.getCommonItem(btnInfo) private fun AlertDialog.getCommonItem(view: T?): T? { return findViewById(view?.id ?: return null) @@ -122,6 +122,12 @@ abstract class DialogBuilder( it.nextFocusUpId = createAccount.id } + displayedItems.firstOrNull()?.let { + val infoButton = getCommonItems(dialog).getBtnInfo() ?: return@let + infoButton.nextFocusDownId = it.id + it.nextFocusUpId = infoButton.id + } + getCommonItems(dialog).getBtnApply().id.let { displayedItems.lastOrNull()?.nextFocusDownId = it } 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 1d93d682..1c15e7ea 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,14 +1,23 @@ 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.R import com.lagradost.cloudstream3.syncproviders.InAppOAuth2API import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe -import kotlinx.android.synthetic.main.add_account_input_oauth.* +import kotlinx.android.synthetic.main.add_account_input_oauth.apply_btt +import kotlinx.android.synthetic.main.add_account_input_oauth.cancel_btt +import kotlinx.android.synthetic.main.add_account_input_oauth.info_button +import kotlinx.android.synthetic.main.add_account_input_oauth.login_client_id +import kotlinx.android.synthetic.main.add_account_input_oauth.login_client_secret +import kotlinx.android.synthetic.main.add_account_input_oauth.login_file_name +import kotlinx.android.synthetic.main.add_account_input_oauth.text1 class InAppOAuth2DialogBuilder( @@ -16,7 +25,7 @@ class InAppOAuth2DialogBuilder( private val activity: FragmentActivity?, ) : DialogBuilder(api, activity, R.style.AlertDialogCustom, R.layout.add_account_input_oauth) { override fun getCommonItems(dialog: AlertDialog) = with(dialog) { - CommonDialogItems(dialog, text1, apply_btt, cancel_btt, null, null) + CommonDialogItems(dialog, text1, apply_btt, cancel_btt, null, info_button) } override fun getVisibilityMap(dialog: AlertDialog): Map = with(dialog) { @@ -31,6 +40,12 @@ class InAppOAuth2DialogBuilder( login_file_name?.isVisible = api.requiresFilename login_client_id?.isVisible = api.requiresClientId login_client_secret?.isVisible = api.requiresSecret + + info_button?.isGone = api.infoUrl.isNullOrBlank() + info_button?.setOnClickListener { + val customTabIntent = CustomTabsIntent.Builder().setShowTitle(true).build() + customTabIntent.launchUrl(context, Uri.parse(api.infoUrl)) + } } diff --git a/app/src/main/res/layout/add_account_input_oauth.xml b/app/src/main/res/layout/add_account_input_oauth.xml index efc929f2..acfd59e8 100644 --- a/app/src/main/res/layout/add_account_input_oauth.xml +++ b/app/src/main/res/layout/add_account_input_oauth.xml @@ -29,6 +29,14 @@ android:textStyle="bold" tools:text="Test" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68325225..25a2592d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -667,4 +667,5 @@ Sync file name (optional) Oauth redirect url (optional) https://chiff.github.io/cloudstream-sync/google-drive + Info \ No newline at end of file