Skip to content

Commit

Permalink
exposing editing flag for autofill
Browse files Browse the repository at this point in the history
  • Loading branch information
malmstein committed Jan 6, 2025
1 parent aa3ba70 commit add4946
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3999,11 +3999,6 @@ class BrowserTabViewModelTest {
assertTrue(testee.canAutofillSelectCredentialsDialogCanAutomaticallyShow())
}

@Test
fun whenEditingUrlBarAndNotCancelledThenCannotAutomaticallyShowAutofillPrompt() {
assertFalse(testee.canAutofillSelectCredentialsDialogCanAutomaticallyShow())
}

@Test
fun whenNotEditingUrlBarAndCancelledThenCannotAutomaticallyShowAutofillPrompt() {
testee.cancelPendingAutofillRequestToChooseCredentials()
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,9 @@ class BrowserTabFragment :
credentials: List<LoginCredentials>,
triggerType: LoginTriggerType,
) {
if (triggerType == LoginTriggerType.AUTOPROMPT && !(viewModel.canAutofillSelectCredentialsDialogCanAutomaticallyShow())) {
if (triggerType == LoginTriggerType.AUTOPROMPT &&
!(viewModel.canAutofillSelectCredentialsDialogCanAutomaticallyShow()) && omnibar.isEditing()
) {
Timber.d("AutoPrompt is disabled, not showing dialog")
return
}
Expand Down Expand Up @@ -877,7 +879,10 @@ class BrowserTabFragment :
userEnteredQuery(text)
}

private fun onUserEnteredText(text: String, hasFocus: Boolean = true) {
private fun onUserEnteredText(
text: String,
hasFocus: Boolean = true,
) {
viewModel.triggerAutocomplete(text, hasFocus, true)
}

Expand Down Expand Up @@ -1487,10 +1492,12 @@ class BrowserTabFragment :
refresh()
privacyProtectionEnabledConfirmation(it.domain)
}

is Command.RefreshAndShowPrivacyProtectionDisabledConfirmation -> {
refresh()
privacyProtectionDisabledConfirmation(it.domain)
}

is NavigationCommand.Navigate -> {
dismissAppLinkSnackBar()
navigate(it.url, it.headers)
Expand Down Expand Up @@ -1695,12 +1702,14 @@ class BrowserTabFragment :
contentScopeScripts.sendSubscriptionEvent(it.cssData)
duckPlayerScripts.sendSubscriptionEvent(it.duckPlayerData)
}

is Command.SetBrowserBackground -> setBrowserBackgroundRes(it.backgroundRes)
is Command.SetOnboardingDialogBackground -> setOnboardingDialogBackgroundRes(it.backgroundRes)
is Command.LaunchFireDialogFromOnboardingDialog -> {
hideOnboardingDaxDialog(it.onboardingCta)
browserActivity?.launchFire()
}

is Command.SwitchToTab -> {
binding.focusedView.gone()
if (binding.autoCompleteSuggestionsList.isVisible) {
Expand All @@ -1709,6 +1718,7 @@ class BrowserTabFragment :
binding.autoCompleteSuggestionsList.gone()
browserActivity?.openExistingTab(it.tabId)
}

else -> {
// NO OP
}
Expand Down Expand Up @@ -3804,6 +3814,7 @@ class BrowserTabFragment :
is DaxBubbleCta.DaxExperimentIntroSearchOptionsCta, is DaxBubbleCta.DaxExperimentIntroVisitSiteOptionsCta,
is DaxBubbleCta.DaxExperimentEndCta, is DaxBubbleCta.DaxExperimentPrivacyProCta,
-> showDaxExperimentOnboardingBubbleCta(configuration as DaxBubbleCta)

is DaxBubbleCta -> showDaxOnboardingBubbleCta(configuration)
is OnboardingDaxDialogCta -> showOnboardingDialogCta(configuration)
is BrokenSitePromptDialogCta -> showBrokenSitePromptCta(configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ class Omnibar(
return omniBarContainer.isPressed
}

fun isEditing(): Boolean {
return newOmnibar.isEditing
}

fun renderBrowserViewState(
viewState: BrowserViewState,
tabDisplayedInCustomTabScreen: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ class OmnibarLayout @JvmOverloads constructor(
}
}

val isEditing: Boolean
get() {
return if (isAttachedToWindow) {
viewModel.viewState.value.hasFocus
} else {
false
}
}

private var coroutineScope: CoroutineScope? = null

private val smoothProgressAnimator by lazy { SmoothProgressAnimator(pageLoadingIndicator) }
Expand Down

0 comments on commit add4946

Please sign in to comment.