Skip to content
Merged
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 @@ -21,7 +21,6 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import com.duckduckgo.app.CoroutineTestRule
import com.duckduckgo.app.browser.BrowserViewModel.Command
import com.duckduckgo.app.browser.BrowserViewModel.Command.DisplayMessage
import com.duckduckgo.app.browser.omnibar.OmnibarEntryConverter
import com.duckduckgo.app.fire.DataClearer
import com.duckduckgo.app.global.events.db.UserEventsStore
Expand Down Expand Up @@ -177,13 +176,6 @@ class BrowserViewModelTest {
verify(mockCommandObserver, never()).onChanged(any())
}

@Test
fun whenClearCompleteThenMessageDisplayed() {
testee.onClearComplete()
verify(mockCommandObserver).onChanged(commandCaptor.capture())
assertEquals(DisplayMessage(R.string.fireDataCleared), commandCaptor.lastValue)
}

@Test
fun whenUserSelectedToRateAppThenPlayStoreCommandTriggered() {
testee.onUserSelectedToRateApp(PromptCount.first())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package com.duckduckgo.app.tabs.ui
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.lifecycle.Observer
import com.duckduckgo.app.CoroutineTestRule
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.browser.session.WebViewSessionInMemoryStorage
import com.duckduckgo.app.tabs.model.TabEntity
import com.duckduckgo.app.tabs.model.TabRepository
Expand Down Expand Up @@ -105,14 +104,6 @@ class TabSwitcherViewModelTest {
verify(mockTabRepository).delete(entity)
}

@Test
fun whenClearCompleteThenMessageDisplayedAndSwitcherClosed() {
testee.onClearComplete()
verify(mockCommandObserver, times(2)).onChanged(commandCaptor.capture())
assertEquals(Command.DisplayMessage(R.string.fireDataCleared), commandCaptor.allValues[0])
assertEquals(Command.Close, commandCaptor.allValues[1])
}

@Test
fun whenOnMarkTabAsDeletableThenCallMarkDeletable() = runBlocking {
val entity = TabEntity("abc", "", "", position = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ class BrowserActivity : DuckDuckGoActivity(), CoroutineScope by MainScope() {
when (command) {
is Query -> currentTab?.submitQuery(command.query)
is Refresh -> currentTab?.onRefreshRequested()
is Command.DisplayMessage -> Toast.makeText(applicationContext, command.messageId, Toast.LENGTH_LONG).show()
is Command.LaunchPlayStore -> launchPlayStore()
is Command.ShowAppEnjoymentPrompt -> showAppEnjoymentPrompt(AppEnjoymentDialogFragment.create(command.promptCount, viewModel))
is Command.ShowAppRatingPrompt -> showAppEnjoymentPrompt(RateAppDialogFragment.create(command.promptCount, viewModel))
Expand Down Expand Up @@ -320,7 +319,6 @@ class BrowserActivity : DuckDuckGoActivity(), CoroutineScope by MainScope() {
dialog.clearStarted = {
removeObservers()
}
dialog.clearComplete = { viewModel.onClearComplete() }
dialog.setOnShowListener { currentTab?.onFireDialogVisibilityChanged(isVisible = true) }
dialog.setOnCancelListener {
pixel.fire(if (dialog.ctaVisible) FIRE_DIALOG_PROMOTED_CANCEL else FIRE_DIALOG_CANCEL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package com.duckduckgo.app.browser

import androidx.annotation.StringRes
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import com.duckduckgo.app.browser.BrowserViewModel.Command.DisplayMessage
import com.duckduckgo.app.browser.BrowserViewModel.Command.Refresh
import com.duckduckgo.app.browser.omnibar.OmnibarEntryConverter
import com.duckduckgo.app.browser.omnibar.QueryUrlConverter
Expand Down Expand Up @@ -79,7 +77,6 @@ class BrowserViewModel(
sealed class Command {
object Refresh : Command()
data class Query(val query: String) : Command()
data class DisplayMessage(@StringRes val messageId: Int) : Command()
object LaunchPlayStore : Command()
object LaunchFeedbackView : Command()
data class ShowAppEnjoymentPrompt(val promptCount: PromptCount) : Command()
Expand Down Expand Up @@ -168,10 +165,6 @@ class BrowserViewModel(
if (resultCode == RELOAD_RESULT_CODE) command.value = Refresh
}

fun onClearComplete() {
command.value = DisplayMessage(R.string.fireDataCleared)
}

/**
* To ensure the best UX, we might not want to show anything to the user while the clear is taking place.
* This method will await until the ApplicationClearDataState.FINISHED event is received before observing for other changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class FireDialog(
) : BottomSheetDialog(context, R.style.FireDialog), CoroutineScope by MainScope() {

var clearStarted: (() -> Unit) = {}
var clearComplete: (() -> Unit) = {}
val ctaVisible: Boolean
get() = daxCtaContainer?.isVisible == true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
Expand All @@ -42,7 +41,6 @@ import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.app.tabs.model.TabEntity
import com.duckduckgo.app.tabs.ui.TabSwitcherViewModel.Command
import com.duckduckgo.app.tabs.ui.TabSwitcherViewModel.Command.Close
import com.duckduckgo.app.tabs.ui.TabSwitcherViewModel.Command.DisplayMessage
import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -172,7 +170,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine

private fun processCommand(command: Command?) {
when (command) {
is DisplayMessage -> Toast.makeText(applicationContext, command.messageId, Toast.LENGTH_LONG).show()
is Close -> finishAfterTransition()
}
}
Expand Down Expand Up @@ -202,7 +199,6 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine
settingsDataStore = settingsDataStore,
userEventsStore = userEventsStore
)
dialog.clearComplete = { viewModel.onClearComplete() }
dialog.show()
}

Expand Down Expand Up @@ -240,7 +236,8 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine
BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_SWIPE,
BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_TIMEOUT -> launch { viewModel.purgeDeletableTabs() }
BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_CONSECUTIVE,
BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_MANUAL -> { /* noop */ }
BaseTransientBottomBar.BaseCallback.DISMISS_EVENT_MANUAL -> { /* noop */
}
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package com.duckduckgo.app.tabs.ui

import androidx.annotation.StringRes
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.browser.session.WebViewSessionStorage
import com.duckduckgo.app.global.SingleLiveEvent
import com.duckduckgo.app.global.plugins.view_model.ViewModelFactoryPlugin
Expand All @@ -41,7 +39,6 @@ class TabSwitcherViewModel(private val tabRepository: TabRepository, private val
val command: SingleLiveEvent<Command> = SingleLiveEvent()

sealed class Command {
data class DisplayMessage(@StringRes val messageId: Int) : Command()
object Close : Command()
}

Expand Down Expand Up @@ -71,11 +68,6 @@ class TabSwitcherViewModel(private val tabRepository: TabRepository, private val
suspend fun purgeDeletableTabs() {
tabRepository.purgeDeletableTabs()
}

fun onClearComplete() {
command.value = Command.DisplayMessage(R.string.fireDataCleared)
command.value = Command.Close
}
}

@ContributesMultibinding(AppObjectGraph::class)
Expand Down