Skip to content

Commit

Permalink
add click handling for other platforms
Browse files Browse the repository at this point in the history
We just open the browser on duckduckgo.com/app page which lists our other platforms
  • Loading branch information
mikescamell committed Nov 29, 2024
1 parent 8c04d41 commit 96eaeec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchAppearance
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchAutofillSettings
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchCookiePopupProtectionScreen
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchDefaultBrowser
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchOtherPlatforms
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchEmailProtection
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchEmailProtectionNotSupported
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchFeedback
Expand Down Expand Up @@ -91,6 +92,8 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import timber.log.Timber

private const val OTHER_PLATFORMS_URL = "https://duckduckgo.com/app"

@InjectWith(ActivityScope::class)
class NewSettingsActivity : DuckDuckGoActivity() {

Expand Down Expand Up @@ -198,6 +201,7 @@ class NewSettingsActivity : DuckDuckGoActivity() {
with(viewsOther) {
aboutSetting.setOnClickListener { viewModel.onAboutSettingClicked() }
shareFeedbackSetting.setOnClickListener { viewModel.onShareFeedbackClicked() }
ddgOnOtherPlatformsSetting.setOnClickListener { viewModel.onDdgOnOtherPlatformsClicked() }
}
}

Expand Down Expand Up @@ -322,6 +326,7 @@ class NewSettingsActivity : DuckDuckGoActivity() {
is LaunchGeneralSettingsScreen -> launchGeneralSettingsScreen()
is LaunchFeedback -> launchFeedback()
is LaunchPproUnifiedFeedback -> launchPproUnifiedFeedback()
is LaunchOtherPlatforms -> launchOtherPlatforms()
null -> TODO()
}
}
Expand Down Expand Up @@ -437,6 +442,11 @@ class NewSettingsActivity : DuckDuckGoActivity() {
)
}

private fun launchOtherPlatforms() {
startActivity(BrowserActivity.intent(context = this, queryExtra = OTHER_PLATFORMS_URL))
finish()
}

companion object {
const val LAUNCH_FROM_NOTIFICATION_PIXEL_NAME = "LAUNCH_FROM_NOTIFICATION_PIXEL_NAME"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchAppearance
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchAutofillSettings
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchCookiePopupProtectionScreen
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchDefaultBrowser
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchOtherPlatforms
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchEmailProtection
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchEmailProtectionNotSupported
import com.duckduckgo.app.settings.NewSettingsViewModel.Command.LaunchFeedback
Expand Down Expand Up @@ -135,6 +136,7 @@ class NewSettingsViewModel @Inject constructor(
data object LaunchGeneralSettingsScreen : Command()
data object LaunchFeedback : Command()
data object LaunchPproUnifiedFeedback : Command()
data object LaunchOtherPlatforms : Command()
}

private val viewState = MutableStateFlow(ViewState())
Expand Down Expand Up @@ -322,6 +324,10 @@ class NewSettingsViewModel @Inject constructor(
pixel.fire(pixelName)
}

fun onDdgOnOtherPlatformsClicked() {
viewModelScope.launch { command.send(LaunchOtherPlatforms) }
}

companion object {
const val EMAIL_PROTECTION_URL = "https://duckduckgo.com/email"
}
Expand Down

0 comments on commit 96eaeec

Please sign in to comment.