Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typealias GECKO_AUTH_LEVEL = PromptDelegate.AuthPrompt.AuthOptions.Level
typealias GECKO_PROMPT_FILE_TYPE = PromptDelegate.FilePrompt.Type
typealias GECKO_PROMPT_PROVIDER_SELECTOR = ProviderSelectorPrompt.Provider
typealias GECKO_PROMPT_ACCOUNT_SELECTOR = AccountSelectorPrompt.Account
typealias GECKO_PROMPT_ACCOUNT_SELECTOR_PROVIDER = AccountSelectorPrompt.Provider
typealias GECKO_PROMPT_CHOICE_TYPE = PromptDelegate.ChoicePrompt.Type
typealias GECKO_PROMPT_FILE_CAPTURE = PromptDelegate.FilePrompt.Capture
typealias GECKO_PROMPT_SHARE_RESULT = PromptDelegate.SharePrompt.Result
Expand Down Expand Up @@ -132,6 +133,7 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
onPromptRequest(
PromptRequest.IdentityCredential.SelectAccount(
accounts = prompt.accounts.map { it.toAccount() },
provider = prompt.provider.let { it.toProvider() },
onConfirm = onConfirm,
onDismiss = onDismiss,
),
Expand Down Expand Up @@ -912,10 +914,15 @@ internal fun PromptDelegate.BasePrompt.dismissSafely(geckoResult: GeckoResult<Pr

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun GECKO_PROMPT_PROVIDER_SELECTOR.toProvider(): Provider {
return Provider(id, icon, name)
return Provider(id, icon, name, domain)
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun GECKO_PROMPT_ACCOUNT_SELECTOR.toAccount(): Account {
return Account(id, email, name, icon)
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun GECKO_PROMPT_ACCOUNT_SELECTOR_PROVIDER.toProvider(): Provider {
return Provider(0, icon, name, domain)
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ sealed class PromptRequest(
/**
* Value type that represents Identity Credential request for selecting an [Account] prompt.
* @property accounts A list of accounts which the user could select from.
* @property providerName The name of the provider that will be used for the login
* @property onConfirm callback to let the page know the user selected an account.
* @property onDismiss callback to let the page know the user dismissed the dialog.
*/
data class SelectAccount(
val accounts: List<Account>,
val provider: Provider,
val onConfirm: (Account) -> Unit,
override val onDismiss: () -> Unit,
) : IdentityCredential(onDismiss), Dismissible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ data class Provider(
val id: Int,
val icon: String?,
val name: String,
val domain: String,
) : Parcelable
17 changes: 17 additions & 0 deletions android-components/components/feature/prompts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ android {
}
}

composeOptions {
kotlinCompilerExtensionVersion = Versions.compose_compiler
}

buildFeatures {
compose true
}

namespace 'mozilla.components.feature.prompts'
}

Expand All @@ -40,11 +48,20 @@ dependencies {
implementation project(':support-utils')
implementation project(':ui-icons')
implementation project(':ui-widgets')
implementation project(':ui-colors')

implementation ComponentsDependencies.androidx_constraintlayout
implementation ComponentsDependencies.androidx_core_ktx
implementation ComponentsDependencies.google_material

implementation ComponentsDependencies.androidx_core_ktx
implementation ComponentsDependencies.androidx_compose_ui
implementation ComponentsDependencies.androidx_compose_ui_tooling_preview
implementation ComponentsDependencies.androidx_compose_foundation
implementation ComponentsDependencies.androidx_compose_material

debugImplementation ComponentsDependencies.androidx_compose_ui_tooling

testImplementation ComponentsDependencies.androidx_test_core
testImplementation ComponentsDependencies.androidx_test_junit
testImplementation ComponentsDependencies.testing_coroutines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ import mozilla.components.feature.prompts.facts.emitPromptDisplayedFact
import mozilla.components.feature.prompts.facts.emitSuccessfulAddressAutofillFormDetectedFact
import mozilla.components.feature.prompts.facts.emitSuccessfulCreditCardAutofillFormDetectedFact
import mozilla.components.feature.prompts.file.FilePicker
import mozilla.components.feature.prompts.identitycredential.DialogColors
import mozilla.components.feature.prompts.identitycredential.DialogColorsProvider
import mozilla.components.feature.prompts.identitycredential.PrivacyPolicyDialogFragment
import mozilla.components.feature.prompts.identitycredential.SelectAccountDialogFragment
import mozilla.components.feature.prompts.identitycredential.SelectProviderDialogFragment
Expand Down Expand Up @@ -154,6 +156,7 @@ class PromptFeature private constructor(
private val store: BrowserStore,
private var customTabId: String?,
private val fragmentManager: FragmentManager,
private val identityCredentialColorsProvider: DialogColorsProvider = DialogColorsProvider { DialogColors.default() },
private val tabsUseCases: TabsUseCases,
private val shareDelegate: ShareDelegate,
private val exitFullscreenUsecase: ExitFullScreenUseCase = SessionUseCases(store).exitFullscreen,
Expand Down Expand Up @@ -197,6 +200,7 @@ class PromptFeature private constructor(
customTabId: String? = null,
fragmentManager: FragmentManager,
tabsUseCases: TabsUseCases,
identityCredentialColorsProvider: DialogColorsProvider = DialogColorsProvider { DialogColors.default() },
shareDelegate: ShareDelegate = DefaultShareDelegate(),
exitFullscreenUsecase: ExitFullScreenUseCase = SessionUseCases(store).exitFullscreen,
creditCardValidationDelegate: CreditCardValidationDelegate? = null,
Expand All @@ -215,6 +219,7 @@ class PromptFeature private constructor(
customTabId = customTabId,
fragmentManager = fragmentManager,
tabsUseCases = tabsUseCases,
identityCredentialColorsProvider = identityCredentialColorsProvider,
shareDelegate = shareDelegate,
exitFullscreenUsecase = exitFullscreenUsecase,
creditCardValidationDelegate = creditCardValidationDelegate,
Expand Down Expand Up @@ -912,6 +917,7 @@ class PromptFeature private constructor(
promptRequestUID = promptRequest.uid,
shouldDismissOnLoad = true,
providers = promptRequest.providers,
colorsProvider = identityCredentialColorsProvider
)
}

Expand All @@ -921,6 +927,8 @@ class PromptFeature private constructor(
promptRequestUID = promptRequest.uid,
shouldDismissOnLoad = true,
accounts = promptRequest.accounts,
provider = promptRequest.provider,
colorsProvider = identityCredentialColorsProvider
)
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package mozilla.components.feature.prompts.identitycredential

import androidx.compose.material.ContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

/**
* Represents the colors used by the dialogs.
*/
data class DialogColors(
val title: Color,
val description: Color) {

companion object {

/**
* Creates an [DialogColors] that represents the default colors used in an
* IdentityCredential dialog.
*
* @param title The text color for the title of a suggestion.
* @param description The text color for the description of a suggestion.
*/
@Composable
fun default(
title: Color = MaterialTheme.colors.onBackground,
description: Color = MaterialTheme.colors.onBackground.copy(
alpha = ContentAlpha.medium,
)
) = DialogColors(
title,
description
)

fun defaultProvider() = DialogColorsProvider { default() }

}
}

/**
* An [DialogColorsProvider] implementation can provide an [DialogColors]
*/
fun interface DialogColorsProvider {
@Composable
fun provideColors(): DialogColors
}
Loading