2023-08-23 00:03:42 +03:00
|
|
|
package com.x8bit.bitwarden
|
|
|
|
|
2023-10-03 22:34:51 +03:00
|
|
|
import android.content.Intent
|
2023-08-23 00:03:42 +03:00
|
|
|
import android.os.Bundle
|
|
|
|
import androidx.activity.compose.setContent
|
2023-10-03 22:34:51 +03:00
|
|
|
import androidx.activity.viewModels
|
2024-01-13 00:43:18 +03:00
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate
|
|
|
|
import androidx.core.os.LocaleListCompat
|
2023-09-28 22:18:03 +03:00
|
|
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
2024-01-13 00:43:18 +03:00
|
|
|
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
|
2023-09-05 21:13:26 +03:00
|
|
|
import com.x8bit.bitwarden.ui.platform.feature.rootnav.RootNavScreen
|
|
|
|
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
2023-08-23 00:03:42 +03:00
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
2024-01-13 00:43:18 +03:00
|
|
|
import javax.inject.Inject
|
2023-08-23 00:03:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Primary entry point for the application.
|
|
|
|
*/
|
|
|
|
@AndroidEntryPoint
|
2024-01-13 00:43:18 +03:00
|
|
|
class MainActivity : AppCompatActivity() {
|
2023-10-03 22:34:51 +03:00
|
|
|
|
|
|
|
private val mainViewModel: MainViewModel by viewModels()
|
|
|
|
|
2024-01-13 00:43:18 +03:00
|
|
|
@Inject
|
|
|
|
lateinit var settingsRepository: SettingsRepository
|
|
|
|
|
2023-08-23 00:03:42 +03:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
2023-09-28 22:18:03 +03:00
|
|
|
var shouldShowSplashScreen = true
|
|
|
|
installSplashScreen().setKeepOnScreenCondition { shouldShowSplashScreen }
|
2023-08-23 00:03:42 +03:00
|
|
|
super.onCreate(savedInstanceState)
|
2024-01-13 00:43:18 +03:00
|
|
|
// Within the app the language will change dynamically and will be managed
|
|
|
|
// by the OS, but we need to ensure we properly set the language when
|
|
|
|
// upgrading from older versions that handle this differently.
|
|
|
|
settingsRepository.appLanguage.localeName?.let { localeName ->
|
|
|
|
val localeList = LocaleListCompat.forLanguageTags(localeName)
|
|
|
|
AppCompatDelegate.setApplicationLocales(localeList)
|
|
|
|
}
|
2023-08-29 17:43:15 +03:00
|
|
|
setContent {
|
|
|
|
BitwardenTheme {
|
2023-09-28 22:18:03 +03:00
|
|
|
RootNavScreen(
|
|
|
|
onSplashScreenRemoved = { shouldShowSplashScreen = false },
|
|
|
|
)
|
2023-08-29 17:43:15 +03:00
|
|
|
}
|
|
|
|
}
|
2023-08-23 00:03:42 +03:00
|
|
|
}
|
2023-10-03 22:34:51 +03:00
|
|
|
|
|
|
|
override fun onNewIntent(intent: Intent) {
|
|
|
|
super.onNewIntent(intent)
|
|
|
|
mainViewModel.sendAction(
|
|
|
|
action = MainAction.ReceiveNewIntent(
|
|
|
|
intent = intent,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|
2023-08-23 00:03:42 +03:00
|
|
|
}
|