Skip to content

Commit

Permalink
Merge branch 'investigate-lifecycle-of-activity-droid-1187'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Jul 18, 2024
2 parents 2368bb8 + 3375aec commit a13428f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import net.mullvad.mullvadvpn.repository.RelayOverridesRepository
import net.mullvad.mullvadvpn.repository.SettingsRepository
import net.mullvad.mullvadvpn.repository.SplashCompleteRepository
import net.mullvad.mullvadvpn.repository.SplitTunnelingRepository
import net.mullvad.mullvadvpn.ui.MainActivity
import net.mullvad.mullvadvpn.ui.serviceconnection.AppVersionInfoRepository
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager
import net.mullvad.mullvadvpn.usecase.AccountExpiryNotificationUseCase
Expand Down Expand Up @@ -97,9 +98,9 @@ val uiModule = module {
single<String>(named(SELF_PACKAGE_NAME)) { androidContext().packageName }

viewModel { SplitTunnelingViewModel(get(), get(), Dispatchers.Default) }
single { ApplicationsProvider(get(), get(named(SELF_PACKAGE_NAME))) }

single { ServiceConnectionManager(androidContext()) }
single { ApplicationsProvider(get(), get(named(SELF_PACKAGE_NAME))) }
scope<MainActivity> { scoped { ServiceConnectionManager(androidContext()) } }
single { InetAddressValidator.getInstance() }
single { androidContext().resources }
single { androidContext().assets }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,34 @@ import net.mullvad.mullvadvpn.repository.PrivacyDisclaimerRepository
import net.mullvad.mullvadvpn.repository.SplashCompleteRepository
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager
import net.mullvad.mullvadvpn.viewmodel.NoDaemonViewModel
import org.koin.android.ext.android.getKoin
import org.koin.android.ext.android.inject
import org.koin.android.scope.AndroidScopeComponent
import org.koin.androidx.scope.activityScope
import org.koin.core.context.loadKoinModules

class MainActivity : ComponentActivity() {
class MainActivity : ComponentActivity(), AndroidScopeComponent {
override val scope by activityScope()

private val requestNotificationPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) {
// NotificationManager.areNotificationsEnabled is used to check the state rather than
// handling the callback value.
}

private lateinit var privacyDisclaimerRepository: PrivacyDisclaimerRepository
private lateinit var serviceConnectionManager: ServiceConnectionManager
private lateinit var splashCompleteRepository: SplashCompleteRepository
private val intentProvider by inject<IntentProvider>()
private val noDaemonViewModel by inject<NoDaemonViewModel>()
private val privacyDisclaimerRepository by inject<PrivacyDisclaimerRepository>()
private val serviceConnectionManager by inject<ServiceConnectionManager>()
private val splashCompleteRepository by inject<SplashCompleteRepository>()

private var isReadyNextDraw: Boolean = false
private lateinit var noDaemonViewModel: NoDaemonViewModel
private lateinit var intentProvider: IntentProvider

override fun onCreate(savedInstanceState: Bundle?) {
loadKoinModules(listOf(uiModule, paymentModule))

// Tell the system that we will draw behind the status bar and navigation bar
WindowCompat.setDecorFitsSystemWindows(window, false)

with(getKoin()) {
privacyDisclaimerRepository = get()
serviceConnectionManager = get()
noDaemonViewModel = get()
intentProvider = get()
splashCompleteRepository = get()
}
lifecycle.addObserver(noDaemonViewModel)

installSplashScreen().setKeepOnScreenCondition {
Expand Down

0 comments on commit a13428f

Please sign in to comment.