|
|
@ -64,6 +64,9 @@ class MainActivity : AppCompatActivity(), ThemeProvider { |
|
|
|
|
|
|
|
|
override var themeId: Int = 0 |
|
|
override var themeId: Int = 0 |
|
|
|
|
|
|
|
|
|
|
|
private val CHECKED_DECRYPTION = "CheckedDecryption" |
|
|
|
|
|
private var checkedDecryption = false |
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
val splashScreen = installSplashScreen() |
|
|
val splashScreen = installSplashScreen() |
|
|
splashScreen.setKeepOnScreenCondition { !DirectoryInitialization.areDirectoriesReady } |
|
|
splashScreen.setKeepOnScreenCondition { !DirectoryInitialization.areDirectoriesReady } |
|
|
@ -75,6 +78,18 @@ class MainActivity : AppCompatActivity(), ThemeProvider { |
|
|
binding = ActivityMainBinding.inflate(layoutInflater) |
|
|
binding = ActivityMainBinding.inflate(layoutInflater) |
|
|
setContentView(binding.root) |
|
|
setContentView(binding.root) |
|
|
|
|
|
|
|
|
|
|
|
if (savedInstanceState != null) { |
|
|
|
|
|
checkedDecryption = savedInstanceState.getBoolean(CHECKED_DECRYPTION) |
|
|
|
|
|
} |
|
|
|
|
|
if (!checkedDecryption) { |
|
|
|
|
|
val firstTimeSetup = PreferenceManager.getDefaultSharedPreferences(applicationContext) |
|
|
|
|
|
.getBoolean(Settings.PREF_FIRST_APP_LAUNCH, true) |
|
|
|
|
|
if (!firstTimeSetup) { |
|
|
|
|
|
checkKeys() |
|
|
|
|
|
} |
|
|
|
|
|
checkedDecryption = true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WindowCompat.setDecorFitsSystemWindows(window, false) |
|
|
WindowCompat.setDecorFitsSystemWindows(window, false) |
|
|
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING) |
|
|
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING) |
|
|
|
|
|
|
|
|
@ -150,6 +165,16 @@ class MainActivity : AppCompatActivity(), ThemeProvider { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
launch { |
|
|
|
|
|
repeatOnLifecycle(Lifecycle.State.CREATED) { |
|
|
|
|
|
homeViewModel.checkKeys.collect { |
|
|
|
|
|
if (it) { |
|
|
|
|
|
checkKeys() |
|
|
|
|
|
homeViewModel.setCheckKeys(false) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Dismiss previous notifications (should not happen unless a crash occurred) |
|
|
// Dismiss previous notifications (should not happen unless a crash occurred) |
|
|
@ -158,6 +183,21 @@ class MainActivity : AppCompatActivity(), ThemeProvider { |
|
|
setInsets() |
|
|
setInsets() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun checkKeys() { |
|
|
|
|
|
if (!NativeLibrary.areKeysPresent()) { |
|
|
|
|
|
MessageDialogFragment.newInstance( |
|
|
|
|
|
titleId = R.string.keys_missing, |
|
|
|
|
|
descriptionId = R.string.keys_missing_description, |
|
|
|
|
|
helpLinkId = R.string.keys_missing_help |
|
|
|
|
|
).show(supportFragmentManager, MessageDialogFragment.TAG) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onSaveInstanceState(outState: Bundle) { |
|
|
|
|
|
super.onSaveInstanceState(outState) |
|
|
|
|
|
outState.putBoolean(CHECKED_DECRYPTION, checkedDecryption) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
fun finishSetup(navController: NavController) { |
|
|
fun finishSetup(navController: NavController) { |
|
|
navController.navigate(R.id.action_firstTimeSetupFragment_to_gamesFragment) |
|
|
navController.navigate(R.id.action_firstTimeSetupFragment_to_gamesFragment) |
|
|
(binding.navigationView as NavigationBarView).setupWithNavController(navController) |
|
|
(binding.navigationView as NavigationBarView).setupWithNavController(navController) |
|
|
@ -349,6 +389,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { |
|
|
R.string.install_keys_success, |
|
|
R.string.install_keys_success, |
|
|
Toast.LENGTH_SHORT |
|
|
Toast.LENGTH_SHORT |
|
|
).show() |
|
|
).show() |
|
|
|
|
|
homeViewModel.setCheckKeys(true) |
|
|
gamesViewModel.reloadGames(true) |
|
|
gamesViewModel.reloadGames(true) |
|
|
return true |
|
|
return true |
|
|
} else { |
|
|
} else { |
|
|
@ -399,6 +440,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { |
|
|
firmwarePath.deleteRecursively() |
|
|
firmwarePath.deleteRecursively() |
|
|
cacheFirmwareDir.copyRecursively(firmwarePath, true) |
|
|
cacheFirmwareDir.copyRecursively(firmwarePath, true) |
|
|
NativeLibrary.initializeSystem(true) |
|
|
NativeLibrary.initializeSystem(true) |
|
|
|
|
|
homeViewModel.setCheckKeys(true) |
|
|
getString(R.string.save_file_imported_success) |
|
|
getString(R.string.save_file_imported_success) |
|
|
} |
|
|
} |
|
|
} catch (e: Exception) { |
|
|
} catch (e: Exception) { |
|
|
|