1616
1717package com.duckduckgo.app.settings
1818
19- import android.app.ActivityOptions
2019import android.content.Context
2120import android.content.Intent
2221import android.os.Bundle
@@ -81,6 +80,7 @@ import com.duckduckgo.internal.features.api.InternalFeaturePlugin
8180import com.duckduckgo.mobile.android.app.tracking.ui.AppTrackingProtectionScreens.AppTrackerActivityWithEmptyParams
8281import com.duckduckgo.mobile.android.app.tracking.ui.AppTrackingProtectionScreens.AppTrackerOnboardingActivityWithEmptyParamsParams
8382import com.duckduckgo.navigation.api.GlobalActivityStarter
83+ import com.duckduckgo.navigation.api.GlobalActivityStarter.ActivityParams
8484import com.duckduckgo.settings.api.DuckPlayerSettingsPlugin
8585import com.duckduckgo.settings.api.ProSettingsPlugin
8686import com.duckduckgo.subscriptions.api.PrivacyProFeedbackScreens.GeneralPrivacyProFeedbackScreenNoParams
@@ -305,29 +305,28 @@ class NewSettingsActivity : DuckDuckGoActivity() {
305305 viewsPrivacy.cookiePopupProtectionSetting.setStatus(isOn = enabled)
306306 }
307307
308- private fun processCommand (it : Command ? ) {
308+ private fun processCommand (it : Command ) {
309309 when (it) {
310310 is LaunchDefaultBrowser -> launchDefaultAppScreen()
311- is LaunchAutofillSettings -> launchAutofillSettings( )
312- is LaunchAccessibilitySettings -> launchAccessibilitySettings( )
313- is LaunchAppTPTrackersScreen -> launchAppTPTrackersScreen( )
314- is LaunchAppTPOnboarding -> launchAppTPOnboardingScreen( )
315- is LaunchEmailProtection -> launchEmailProtectionScreen( it.url)
316- is LaunchEmailProtectionNotSupported -> launchEmailProtectionNotSupported( )
311+ is LaunchAutofillSettings -> launchScreen( AutofillSettingsScreen (source = AutofillSettingsLaunchSource . SettingsActivity ) )
312+ is LaunchAccessibilitySettings -> launchScreen( AccessibilityScreens . Default )
313+ is LaunchAppTPTrackersScreen -> launchScreen( AppTrackerActivityWithEmptyParams )
314+ is LaunchAppTPOnboarding -> launchScreen( AppTrackerOnboardingActivityWithEmptyParamsParams )
315+ is LaunchEmailProtection -> launchActivityAndFinish( BrowserActivity .intent( this , it.url, interstitialScreen = true ) )
316+ is LaunchEmailProtectionNotSupported -> launchScreen( EmailProtectionUnsupportedScreenNoParams )
317317 is LaunchAddHomeScreenWidget -> launchAddHomeScreenWidget()
318- is LaunchSyncSettings -> launchSyncSettings( )
319- is LaunchPrivateSearchWebPage -> launchPrivateSearchScreen( )
320- is LaunchWebTrackingProtectionScreen -> launchWebTrackingProtectionScreen( )
321- is LaunchCookiePopupProtectionScreen -> launchCookiePopupProtectionScreen( )
322- is LaunchFireButtonScreen -> launchFireButtonScreen( )
323- is LaunchPermissionsScreen -> launchPermissionsScreen( )
324- is LaunchAppearanceScreen -> launchAppearanceScreen( )
325- is LaunchAboutScreen -> launchAboutScreen( )
326- is LaunchGeneralSettingsScreen -> launchGeneralSettingsScreen( )
318+ is LaunchSyncSettings -> launchScreen( SyncActivityWithEmptyParams )
319+ is LaunchPrivateSearchWebPage -> launchScreen( PrivateSearchScreenNoParams )
320+ is LaunchWebTrackingProtectionScreen -> launchScreen( WebTrackingProtectionScreenNoParams )
321+ is LaunchCookiePopupProtectionScreen -> launchActivity( AutoconsentSettingsActivity .intent( this ) )
322+ is LaunchFireButtonScreen -> launchScreen( FireButtonScreenNoParams )
323+ is LaunchPermissionsScreen -> launchScreen( PermissionsScreenNoParams )
324+ is LaunchAppearanceScreen -> launchScreen( AppearanceScreen . Default )
325+ is LaunchAboutScreen -> launchScreen( AboutScreenNoParams )
326+ is LaunchGeneralSettingsScreen -> launchScreen( GeneralSettingsScreenNoParams )
327327 is LaunchFeedback -> launchFeedback()
328- is LaunchPproUnifiedFeedback -> launchPproUnifiedFeedback()
329- is LaunchOtherPlatforms -> launchOtherPlatforms()
330- null -> TODO ()
328+ is LaunchPproUnifiedFeedback -> launchScreen(GeneralPrivacyProFeedbackScreenNoParams )
329+ is LaunchOtherPlatforms -> launchActivityAndFinish(BrowserActivity .intent(context = this , queryExtra = OTHER_PLATFORMS_URL ))
331330 }
332331 }
333332
@@ -350,103 +349,28 @@ class NewSettingsActivity : DuckDuckGoActivity() {
350349 launchDefaultAppActivity()
351350 }
352351
353- private fun launchAutofillSettings () {
354- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
355- globalActivityStarter.start(this , AutofillSettingsScreen (source = AutofillSettingsLaunchSource .SettingsActivity ), options)
352+ private fun launchScreen (activityParams : ActivityParams ) {
353+ globalActivityStarter.start(this , activityParams)
356354 }
357355
358- private fun launchAccessibilitySettings () {
359- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
360- globalActivityStarter.start(this , AccessibilityScreens .Default , options)
356+ private fun launchActivity (intent : Intent ) {
357+ startActivity(intent)
361358 }
362359
363- private fun launchEmailProtectionScreen (url : String ) {
364- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
365- startActivity(BrowserActivity .intent(this , url, interstitialScreen = true ), options)
366- this .finish()
367- }
368-
369- private fun launchEmailProtectionNotSupported () {
370- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
371- globalActivityStarter.start(this , EmailProtectionUnsupportedScreenNoParams , options)
372- }
373-
374- private fun launchSyncSettings () {
375- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
376- globalActivityStarter.start(this , SyncActivityWithEmptyParams , options)
377- }
378-
379- private fun launchAppTPTrackersScreen () {
380- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
381- globalActivityStarter.start(this , AppTrackerActivityWithEmptyParams , options)
382- }
383-
384- private fun launchAppTPOnboardingScreen () {
385- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
386- globalActivityStarter.start(this , AppTrackerOnboardingActivityWithEmptyParamsParams , options)
360+ private fun launchActivityAndFinish (intent : Intent ) {
361+ launchActivity(intent)
362+ finish()
387363 }
388364
389365 private fun launchAddHomeScreenWidget () {
390366 pixel.fire(AppPixelName .SETTINGS_ADD_HOME_SCREEN_WIDGET_CLICKED )
391367 addWidgetLauncher.launchAddWidget(this )
392368 }
393369
394- private fun launchPrivateSearchScreen () {
395- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
396- globalActivityStarter.start(this , PrivateSearchScreenNoParams , options)
397- }
398-
399- private fun launchWebTrackingProtectionScreen () {
400- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
401- globalActivityStarter.start(this , WebTrackingProtectionScreenNoParams , options)
402- }
403-
404- private fun launchCookiePopupProtectionScreen () {
405- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
406- startActivity(AutoconsentSettingsActivity .intent(this ), options)
407- }
408-
409- private fun launchFireButtonScreen () {
410- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
411- globalActivityStarter.start(this , FireButtonScreenNoParams , options)
412- }
413-
414- private fun launchPermissionsScreen () {
415- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
416- globalActivityStarter.start(this , PermissionsScreenNoParams , options)
417- }
418-
419- private fun launchAppearanceScreen () {
420- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
421- globalActivityStarter.start(this , AppearanceScreen .Default , options)
422- }
423-
424- private fun launchAboutScreen () {
425- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
426- globalActivityStarter.start(this , AboutScreenNoParams , options)
427- }
428-
429- private fun launchGeneralSettingsScreen () {
430- val options = ActivityOptions .makeSceneTransitionAnimation(this ).toBundle()
431- globalActivityStarter.start(this , GeneralSettingsScreenNoParams , options)
432- }
433-
434370 private fun launchFeedback () {
435371 feedbackFlow.launch(null )
436372 }
437373
438- private fun launchPproUnifiedFeedback () {
439- globalActivityStarter.start(
440- this ,
441- GeneralPrivacyProFeedbackScreenNoParams ,
442- )
443- }
444-
445- private fun launchOtherPlatforms () {
446- startActivity(BrowserActivity .intent(context = this , queryExtra = OTHER_PLATFORMS_URL ))
447- finish()
448- }
449-
450374 companion object {
451375 const val LAUNCH_FROM_NOTIFICATION_PIXEL_NAME = " LAUNCH_FROM_NOTIFICATION_PIXEL_NAME"
452376
0 commit comments