Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translations for open tabs in search autosuggest #5065

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b8eb08f
Added translations.
anikiki Sep 25, 2024
fb60bd9
Translate strings to values-sl
daxmobile Sep 25, 2024
589543b
Translate strings to values-hu
daxmobile Sep 25, 2024
477b6ac
Translate strings to values-sk
daxmobile Sep 25, 2024
d255578
Translate strings to values-pt
daxmobile Sep 26, 2024
d2ee6e6
Translate strings to values-ro
daxmobile Sep 26, 2024
b4c4406
Translate strings to values-es
daxmobile Sep 26, 2024
0c609ff
Translate strings to values-et
daxmobile Sep 26, 2024
5efc940
Translate strings to values-sv
daxmobile Sep 26, 2024
e4c09e7
Translate strings to values-fi
daxmobile Sep 26, 2024
49eb2d4
Translate strings to values-nl
daxmobile Sep 26, 2024
f016810
Translate strings to values-es
daxmobile Sep 26, 2024
fec254e
Translate strings to values-lv
daxmobile Sep 26, 2024
b4e1c05
Translate strings to values-bg
daxmobile Sep 26, 2024
f85edfe
Translate strings to values-it
daxmobile Sep 26, 2024
3c04bee
Translate strings to values-tr
daxmobile Sep 26, 2024
c97fa89
Translate strings to values-nb
daxmobile Sep 26, 2024
8e67527
Translate strings to values-de
daxmobile Sep 27, 2024
3bb159b
Translate strings to values-el
daxmobile Sep 27, 2024
cda832b
Translate strings to values-pl
daxmobile Sep 27, 2024
ab6fe61
Translate strings-autofill-impl to values-hr
daxmobile Oct 10, 2024
98fd269
Translate strings-autofill-impl to values-hr
daxmobile Oct 10, 2024
f7a8db6
Translate strings-duckplayer to values-el
daxmobile Oct 18, 2024
a62cc5a
Address the tasks in the Meta section (#5105)
anikiki Oct 22, 2024
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 @@ -45,6 +45,7 @@ import com.duckduckgo.adclick.api.AdClickManager
import com.duckduckgo.app.ValueCaptorObserver
import com.duckduckgo.app.accessibility.data.AccessibilitySettingsDataStore
import com.duckduckgo.app.accessibility.data.AccessibilitySettingsSharedPreferences
import com.duckduckgo.app.autocomplete.AutocompleteTabsFeature
import com.duckduckgo.app.autocomplete.api.AutoComplete
import com.duckduckgo.app.autocomplete.api.AutoComplete.AutoCompleteResult
import com.duckduckgo.app.autocomplete.api.AutoComplete.AutoCompleteSuggestion.AutoCompleteDefaultSuggestion
Expand Down Expand Up @@ -236,9 +237,6 @@ import com.duckduckgo.sync.api.favicons.FaviconsFetchingPrompt
import com.duckduckgo.voice.api.VoiceSearchAvailability
import com.duckduckgo.voice.api.VoiceSearchAvailabilityPixelLogger
import dagger.Lazy
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.observers.TestObserver
import java.io.File
import java.math.BigInteger
import java.security.cert.X509Certificate
Expand All @@ -249,6 +247,7 @@ import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
Expand Down Expand Up @@ -487,6 +486,7 @@ class BrowserTabViewModelTest {
private val mockUserBrowserProperties: UserBrowserProperties = mock()
private val mockAutoCompleteRepository: AutoCompleteRepository = mock()
private val changeOmnibarPositionFeature: ChangeOmnibarPositionFeature = mock()
private val mockAutocompleteTabsFeature: AutocompleteTabsFeature = mock()

@Before
fun before() = runTest {
Expand All @@ -506,6 +506,7 @@ class BrowserTabViewModelTest {
mockTabRepository,
mockUserStageStore,
coroutineRule.testDispatcherProvider,
mockAutocompleteTabsFeature,
)
val fireproofWebsiteRepositoryImpl = FireproofWebsiteRepositoryImpl(
fireproofWebsiteDao,
Expand All @@ -532,6 +533,8 @@ class BrowserTabViewModelTest {
whenever(mockDuckPlayer.isDuckPlayerUri(anyString())).thenReturn(false)
whenever(mockDuckPlayer.getDuckPlayerState()).thenReturn(ENABLED)
whenever(changeOmnibarPositionFeature.refactor()).thenReturn(mockEnabledToggle)
whenever(mockAutocompleteTabsFeature.self()).thenReturn(mockEnabledToggle)
whenever(mockAutocompleteTabsFeature.self().isEnabled()).thenReturn(true)

remoteMessagingModel = givenRemoteMessagingModel(mockRemoteMessagingRepository, mockPixel, coroutineRule.testDispatcherProvider)

Expand Down Expand Up @@ -1387,8 +1390,8 @@ class BrowserTabViewModelTest {
}

@Test
fun whenTriggeringAutocompleteThenAutoCompleteSuggestionsShown() {
whenever(mockAutoCompleteService.autoComplete("foo")).thenReturn(Observable.just(emptyList()))
fun whenTriggeringAutocompleteThenAutoCompleteSuggestionsShown() = runTest {
whenever(mockAutoCompleteService.autoComplete("foo")).thenReturn(emptyList())
doReturn(true).whenever(mockSettingsStore).autoCompleteSuggestionsEnabled
testee.triggerAutocomplete("foo", true, hasQueryChanged = true)
assertTrue(autoCompleteViewState().showSuggestions)
Expand Down Expand Up @@ -1447,18 +1450,18 @@ class BrowserTabViewModelTest {
@Test
fun wheneverAutoCompleteIsGoneAndHistoryIAMHasBeenShownThenNotifyUserSeenIAM() {
runTest {
whenever(mockAutoCompleteService.autoComplete("title")).thenReturn(Observable.just(emptyList()))
whenever(mockSavedSitesRepository.getBookmarksObservable()).thenReturn(
Single.just(listOf(Bookmark("abc", "title", "https://example.com", lastModified = null))),
whenever(mockAutoCompleteService.autoComplete("title")).thenReturn(emptyList())
whenever(mockSavedSitesRepository.getBookmarks()).thenReturn(
flowOf(listOf(Bookmark("abc", "title", "https://example.com", lastModified = null))),
)
whenever(mockSavedSitesRepository.getFavoritesObservable()).thenReturn(
Single.just(listOf(Favorite("abc", "title", "https://example.com", position = 1, lastModified = null))),
whenever(mockSavedSitesRepository.getFavorites()).thenReturn(
flowOf(listOf(Favorite("abc", "title", "https://example.com", position = 1, lastModified = null))),
)
whenever(mockNavigationHistory.getHistorySingle()).thenReturn(
Single.just(listOf(VisitedPage("https://foo.com".toUri(), "title", listOf(LocalDateTime.now())))),
whenever(mockNavigationHistory.getHistory()).thenReturn(
flowOf(listOf(VisitedPage("https://foo.com".toUri(), "title", listOf(LocalDateTime.now())))),
)
whenever(mockTabRepository.getTabsObservable()).thenReturn(
Single.just(listOf(TabEntity(tabId = "1", position = 1, url = "https://example.com", title = "title"))),
whenever(mockTabRepository.flowTabs).thenReturn(
flowOf(listOf(TabEntity(tabId = "1", position = 1, url = "https://example.com", title = "title"))),
)
doReturn(true).whenever(mockSettingsStore).autoCompleteSuggestionsEnabled

Expand All @@ -1467,7 +1470,9 @@ class BrowserTabViewModelTest {
whenever(mockAutoCompleteScorer.score("title", "https://foo.com".toUri(), 1, "title")).thenReturn(1)
whenever(mockUserStageStore.getUserAppStage()).thenReturn(ESTABLISHED)

testee.autoCompletePublishSubject.accept("title")
testee.onAutoCompleteSuggestionsChanged()
testee.autoCompleteStateFlow.value = "title"
delay(500)
testee.autoCompleteSuggestionsGone()
verify(mockAutoCompleteRepository).submitUserSeenHistoryIAM()
verify(mockPixel).fire(AUTOCOMPLETE_BANNER_SHOWN)
Expand All @@ -1477,16 +1482,16 @@ class BrowserTabViewModelTest {
@Test
fun wheneverAutoCompleteIsGoneAndHistoryIAMHasNotBeenShownThenDoNotNotifyUserSeenIAM() {
runTest {
whenever(mockAutoCompleteService.autoComplete("query")).thenReturn(Observable.just(emptyList()))
whenever(mockSavedSitesRepository.getBookmarksObservable()).thenReturn(
Single.just(listOf(Bookmark("abc", "title", "https://example.com", lastModified = null))),
whenever(mockAutoCompleteService.autoComplete("query")).thenReturn(emptyList())
whenever(mockSavedSitesRepository.getBookmarks()).thenReturn(
flowOf(listOf(Bookmark("abc", "title", "https://example.com", lastModified = null))),
)
whenever(mockSavedSitesRepository.getFavoritesObservable()).thenReturn(
Single.just(listOf(Favorite("abc", "title", "https://example.com", position = 1, lastModified = null))),
whenever(mockSavedSitesRepository.getFavorites()).thenReturn(
flowOf(listOf(Favorite("abc", "title", "https://example.com", position = 1, lastModified = null))),
)
whenever(mockNavigationHistory.getHistorySingle()).thenReturn(Single.just(listOf()))
whenever(mockNavigationHistory.getHistory()).thenReturn(flowOf(emptyList()))
doReturn(true).whenever(mockSettingsStore).autoCompleteSuggestionsEnabled
testee.autoCompletePublishSubject.accept("query")
testee.autoCompleteStateFlow.value = "query"
testee.autoCompleteSuggestionsGone()
verify(mockAutoCompleteRepository, never()).submitUserSeenHistoryIAM()
verify(mockPixel, never()).fire(AUTOCOMPLETE_BANNER_SHOWN)
Expand Down Expand Up @@ -5865,15 +5870,11 @@ class BrowserTabViewModelTest {
val suggestion = AutoCompleteHistorySuggestion(phrase = "phrase", title = "title", url = "url", isAllowedInTopHits = false)
val omnibarText = "foo"

val testObserver = TestObserver.create<String>()
testee.autoCompletePublishSubject.subscribe(testObserver)

testee.onRemoveSearchSuggestionConfirmed(suggestion, omnibarText)

verify(mockPixel).fire(AppPixelName.AUTOCOMPLETE_RESULT_DELETED)
verify(mockPixel).fire(AppPixelName.AUTOCOMPLETE_RESULT_DELETED_DAILY, type = Daily())
verify(mockNavigationHistory).removeHistoryEntryByUrl(suggestion.url)
testObserver.assertValue(omnibarText)
assertCommandIssued<Command.AutocompleteItemRemoved>()
}

Expand All @@ -5882,15 +5883,11 @@ class BrowserTabViewModelTest {
val suggestion = AutoCompleteHistorySearchSuggestion(phrase = "phrase", isAllowedInTopHits = false)
val omnibarText = "foo"

val testObserver = TestObserver.create<String>()
testee.autoCompletePublishSubject.subscribe(testObserver)

testee.onRemoveSearchSuggestionConfirmed(suggestion, omnibarText)

verify(mockPixel).fire(AppPixelName.AUTOCOMPLETE_RESULT_DELETED)
verify(mockPixel).fire(AppPixelName.AUTOCOMPLETE_RESULT_DELETED_DAILY, type = Daily())
verify(mockNavigationHistory).removeHistoryEntryByQuery(suggestion.phrase)
testObserver.assertValue(omnibarText)
assertCommandIssued<Command.AutocompleteItemRemoved>()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.app.autocomplete

import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle

@ContributesRemoteFeature(
scope = AppScope::class,
featureName = "autocompleteTabs",
)
interface AutocompleteTabsFeature {
@Toggle.DefaultValue(false)
fun self(): Toggle
}
Loading
Loading